From 6edd4a7cb013b2f456502201b976d73e3ef1408d Mon Sep 17 00:00:00 2001 From: Tomas Francisco <4301103+tomasfrancisco@users.noreply.github.com> Date: Fri, 15 Nov 2024 15:01:44 +0100 Subject: [PATCH] feat: reduce right for layered effects --- .../design-tokens/extractors/effect-style.ts | 13 ++-- pnpm-lock.yaml | 69 +++++++++++++------ 2 files changed, 53 insertions(+), 29 deletions(-) diff --git a/packages/figma-widget/src/widget/modules/design-tokens/extractors/effect-style.ts b/packages/figma-widget/src/widget/modules/design-tokens/extractors/effect-style.ts index b7b342a..c310a3c 100644 --- a/packages/figma-widget/src/widget/modules/design-tokens/extractors/effect-style.ts +++ b/packages/figma-widget/src/widget/modules/design-tokens/extractors/effect-style.ts @@ -69,15 +69,8 @@ async function extractEffect(effect: Effect): Promise { } export async function extractEffectStyle(effectStyle: EffectStyle) { - const variableAlias = await Promise.all( - (effectStyle.boundVariables?.effects ?? []).map>( - (value) => extractAlias(value.id) - ) - ); - - console.log({ variableAlias }); - - const effectValues = await effectStyle.effects.reduce( + // reduceRight is used because for some reason figma order is reversed + const effectValues = await effectStyle.effects.reduceRight( async (accumulator, effect) => { const effectToken = await extractEffect(effect); return effectToken ? [...(await accumulator), effectToken] : accumulator; @@ -85,6 +78,8 @@ export async function extractEffectStyle(effectStyle: EffectStyle) { Promise.resolve([] as ShadowValue[]) ); + console.log({ effects: effectStyle.effects }); + const token = { $type: 'shadow', $value: effectValues, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bc2b7eb..0894d77 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,7 +13,7 @@ catalogs: specifier: ^1.9.1 version: 1.9.1 '@terrazzo/token-tools': - specifier: ^0.1.0 + specifier: ^0.1.2 version: 0.1.0 '@trpc/react-query': specifier: 11.0.0-rc.482 @@ -119,13 +119,13 @@ importers: version: 3.9.0(react-hook-form@7.52.2(react@18.3.1)) '@mdx-js/loader': specifier: ^3.1.0 - version: 3.1.0(acorn@8.12.1)(webpack@5.94.0) + version: 3.1.0(acorn@8.12.1)(webpack@5.94.0(esbuild@0.19.12)) '@mdx-js/react': specifier: ^3.1.0 version: 3.1.0(@types/react@18.3.3)(react@18.3.1) '@next/mdx': specifier: ^15.0.2 - version: 15.0.2(@mdx-js/loader@3.1.0(acorn@8.12.1)(webpack@5.94.0))(@mdx-js/react@3.1.0(@types/react@18.3.3)(react@18.3.1)) + version: 15.0.2(@mdx-js/loader@3.1.0(acorn@8.12.1)(webpack@5.94.0(esbuild@0.19.12)))(@mdx-js/react@3.1.0(@types/react@18.3.3)(react@18.3.1)) '@octokit/app': specifier: ^15.1.0 version: 15.1.0 @@ -137,7 +137,7 @@ importers: version: 6.1.2 '@sentry/nextjs': specifier: ^8.30.0 - version: 8.30.0(@opentelemetry/api@1.9.0)(@opentelemetry/core@1.26.0(@opentelemetry/api@1.9.0))(@opentelemetry/instrumentation@0.53.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.26.0(@opentelemetry/api@1.9.0))(next@14.2.12(@opentelemetry/api@1.9.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react@18.3.1)(webpack@5.94.0) + version: 8.30.0(@opentelemetry/api@1.9.0)(@opentelemetry/core@1.26.0(@opentelemetry/api@1.9.0))(@opentelemetry/instrumentation@0.53.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.26.0(@opentelemetry/api@1.9.0))(next@14.2.12(@opentelemetry/api@1.9.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react@18.3.1)(webpack@5.94.0(esbuild@0.19.12)) '@supabase/ssr': specifier: ^0.4.0 version: 0.4.0(@supabase/supabase-js@2.45.0) @@ -9894,12 +9894,12 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.4.15 - '@mdx-js/loader@3.1.0(acorn@8.12.1)(webpack@5.94.0)': + '@mdx-js/loader@3.1.0(acorn@8.12.1)(webpack@5.94.0(esbuild@0.19.12))': dependencies: '@mdx-js/mdx': 3.1.0(acorn@8.12.1) source-map: 0.7.4 optionalDependencies: - webpack: 5.94.0 + webpack: 5.94.0(esbuild@0.19.12) transitivePeerDependencies: - acorn - supports-color @@ -10021,11 +10021,11 @@ snapshots: dependencies: glob: 10.3.10 - '@next/mdx@15.0.2(@mdx-js/loader@3.1.0(acorn@8.12.1)(webpack@5.94.0))(@mdx-js/react@3.1.0(@types/react@18.3.3)(react@18.3.1))': + '@next/mdx@15.0.2(@mdx-js/loader@3.1.0(acorn@8.12.1)(webpack@5.94.0(esbuild@0.19.12)))(@mdx-js/react@3.1.0(@types/react@18.3.3)(react@18.3.1))': dependencies: source-map: 0.7.4 optionalDependencies: - '@mdx-js/loader': 3.1.0(acorn@8.12.1)(webpack@5.94.0) + '@mdx-js/loader': 3.1.0(acorn@8.12.1)(webpack@5.94.0(esbuild@0.19.12)) '@mdx-js/react': 3.1.0(@types/react@18.3.3)(react@18.3.1) '@next/swc-darwin-arm64@14.2.12': @@ -11438,7 +11438,7 @@ snapshots: '@sentry/types': 8.30.0 '@sentry/utils': 8.30.0 - '@sentry/nextjs@8.30.0(@opentelemetry/api@1.9.0)(@opentelemetry/core@1.26.0(@opentelemetry/api@1.9.0))(@opentelemetry/instrumentation@0.53.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.26.0(@opentelemetry/api@1.9.0))(next@14.2.12(@opentelemetry/api@1.9.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react@18.3.1)(webpack@5.94.0)': + '@sentry/nextjs@8.30.0(@opentelemetry/api@1.9.0)(@opentelemetry/core@1.26.0(@opentelemetry/api@1.9.0))(@opentelemetry/instrumentation@0.53.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@1.26.0(@opentelemetry/api@1.9.0))(next@14.2.12(@opentelemetry/api@1.9.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react@18.3.1)(webpack@5.94.0(esbuild@0.19.12))': dependencies: '@opentelemetry/instrumentation-http': 0.53.0(@opentelemetry/api@1.9.0) '@opentelemetry/semantic-conventions': 1.27.0 @@ -11450,14 +11450,14 @@ snapshots: '@sentry/types': 8.30.0 '@sentry/utils': 8.30.0 '@sentry/vercel-edge': 8.30.0 - '@sentry/webpack-plugin': 2.22.3(webpack@5.94.0) + '@sentry/webpack-plugin': 2.22.3(webpack@5.94.0(esbuild@0.19.12)) chalk: 3.0.0 next: 14.2.12(@opentelemetry/api@1.9.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8) resolve: 1.22.8 rollup: 3.29.4 stacktrace-parser: 0.1.10 optionalDependencies: - webpack: 5.94.0 + webpack: 5.94.0(esbuild@0.19.12) transitivePeerDependencies: - '@opentelemetry/api' - '@opentelemetry/core' @@ -11536,12 +11536,12 @@ snapshots: '@sentry/types': 8.30.0 '@sentry/utils': 8.30.0 - '@sentry/webpack-plugin@2.22.3(webpack@5.94.0)': + '@sentry/webpack-plugin@2.22.3(webpack@5.94.0(esbuild@0.19.12))': dependencies: '@sentry/bundler-plugin-core': 2.22.3 unplugin: 1.0.1 uuid: 9.0.1 - webpack: 5.94.0 + webpack: 5.94.0(esbuild@0.19.12) transitivePeerDependencies: - encoding - supports-color @@ -12671,7 +12671,7 @@ snapshots: eslint-import-resolver-alias: 1.1.2(eslint-plugin-import@2.29.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0)) eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-plugin-import@2.29.1)(eslint@8.57.0) eslint-plugin-eslint-comments: 3.2.0(eslint@8.57.0) - eslint-plugin-import: 2.29.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0) + eslint-plugin-import: 2.29.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint@8.57.0) eslint-plugin-jest: 27.9.0(@typescript-eslint/eslint-plugin@6.21.0(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint@8.57.0)(typescript@5.5.4))(eslint@8.57.0)(typescript@5.5.4) eslint-plugin-jsx-a11y: 6.8.0(eslint@8.57.0) eslint-plugin-playwright: 0.16.0(eslint-plugin-jest@27.9.0(@typescript-eslint/eslint-plugin@6.21.0(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint@8.57.0)(typescript@5.5.4))(eslint@8.57.0)(typescript@5.5.4))(eslint@8.57.0) @@ -14091,7 +14091,7 @@ snapshots: eslint-import-resolver-alias@1.1.2(eslint-plugin-import@2.29.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0)): dependencies: - eslint-plugin-import: 2.29.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0) + eslint-plugin-import: 2.29.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint@8.57.0) eslint-import-resolver-node@0.3.9: dependencies: @@ -14124,7 +14124,7 @@ snapshots: enhanced-resolve: 5.16.1 eslint: 8.57.0 eslint-module-utils: 2.8.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-plugin-import@2.29.1)(eslint@8.57.0))(eslint@8.57.0) - eslint-plugin-import: 2.29.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0) + eslint-plugin-import: 2.29.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint@8.57.0) fast-glob: 3.3.2 get-tsconfig: 4.7.5 is-core-module: 2.13.1 @@ -14174,6 +14174,33 @@ snapshots: ignore: 5.3.1 eslint-plugin-import@2.29.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0): + dependencies: + array-includes: 3.1.8 + array.prototype.findlastindex: 1.2.5 + array.prototype.flat: 1.3.2 + array.prototype.flatmap: 1.3.2 + debug: 3.2.7 + doctrine: 2.1.0 + eslint: 8.57.0 + eslint-import-resolver-node: 0.3.9 + eslint-module-utils: 2.8.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0) + hasown: 2.0.2 + is-core-module: 2.13.1 + is-glob: 4.0.3 + minimatch: 3.1.2 + object.fromentries: 2.0.8 + object.groupby: 1.0.3 + object.values: 1.2.0 + semver: 6.3.1 + tsconfig-paths: 3.15.0 + optionalDependencies: + '@typescript-eslint/parser': 6.21.0(eslint@8.57.0)(typescript@5.5.4) + transitivePeerDependencies: + - eslint-import-resolver-typescript + - eslint-import-resolver-webpack + - supports-color + + eslint-plugin-import@2.29.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.4))(eslint@8.57.0): dependencies: array-includes: 3.1.8 array.prototype.findlastindex: 1.2.5 @@ -17185,14 +17212,16 @@ snapshots: dependencies: memoizerific: 1.11.3 - terser-webpack-plugin@5.3.10(webpack@5.94.0): + terser-webpack-plugin@5.3.10(esbuild@0.19.12)(webpack@5.94.0(esbuild@0.19.12)): dependencies: '@jridgewell/trace-mapping': 0.3.25 jest-worker: 27.5.1 schema-utils: 3.3.0 serialize-javascript: 6.0.2 terser: 5.33.0 - webpack: 5.94.0 + webpack: 5.94.0(esbuild@0.19.12) + optionalDependencies: + esbuild: 0.19.12 terser@5.33.0: dependencies: @@ -17612,7 +17641,7 @@ snapshots: webpack-virtual-modules@0.6.2: {} - webpack@5.94.0: + webpack@5.94.0(esbuild@0.19.12): dependencies: '@types/estree': 1.0.5 '@webassemblyjs/ast': 1.12.1 @@ -17634,7 +17663,7 @@ snapshots: neo-async: 2.6.2 schema-utils: 3.3.0 tapable: 2.2.1 - terser-webpack-plugin: 5.3.10(webpack@5.94.0) + terser-webpack-plugin: 5.3.10(esbuild@0.19.12)(webpack@5.94.0(esbuild@0.19.12)) watchpack: 2.4.2 webpack-sources: 3.2.3 transitivePeerDependencies: