@calibrate-ds/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/check-component.test.d.ts +2 -0
- package/dist/__tests__/check-component.test.d.ts.map +1 -0
- package/dist/__tests__/check-component.test.js +103 -0
- package/dist/__tests__/check-component.test.js.map +1 -0
- package/dist/__tests__/compare-components.test.d.ts +2 -0
- package/dist/__tests__/compare-components.test.d.ts.map +1 -0
- package/dist/__tests__/compare-components.test.js +145 -0
- package/dist/__tests__/compare-components.test.js.map +1 -0
- package/dist/__tests__/naming-strategy.test.d.ts +2 -0
- package/dist/__tests__/naming-strategy.test.d.ts.map +1 -0
- package/dist/__tests__/naming-strategy.test.js +71 -0
- package/dist/__tests__/naming-strategy.test.js.map +1 -0
- package/dist/ai/index.d.ts +3 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +3 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/ai/provider.d.ts +14 -0
- package/dist/ai/provider.d.ts.map +1 -0
- package/dist/ai/provider.js +63 -0
- package/dist/ai/provider.js.map +1 -0
- package/dist/ai/resolve-provider.d.ts +3 -0
- package/dist/ai/resolve-provider.d.ts.map +1 -0
- package/dist/ai/resolve-provider.js +61 -0
- package/dist/ai/resolve-provider.js.map +1 -0
- package/dist/bootstrap/generate-library-files.d.ts +7 -0
- package/dist/bootstrap/generate-library-files.d.ts.map +1 -0
- package/dist/bootstrap/generate-library-files.js +97 -0
- package/dist/bootstrap/generate-library-files.js.map +1 -0
- package/dist/bootstrap/index.d.ts +4 -0
- package/dist/bootstrap/index.d.ts.map +1 -0
- package/dist/bootstrap/index.js +4 -0
- package/dist/bootstrap/index.js.map +1 -0
- package/dist/bootstrap/types.d.ts +27 -0
- package/dist/bootstrap/types.d.ts.map +1 -0
- package/dist/bootstrap/types.js +2 -0
- package/dist/bootstrap/types.js.map +1 -0
- package/dist/bootstrap/write-library-bootstrap.d.ts +7 -0
- package/dist/bootstrap/write-library-bootstrap.d.ts.map +1 -0
- package/dist/bootstrap/write-library-bootstrap.js +35 -0
- package/dist/bootstrap/write-library-bootstrap.js.map +1 -0
- package/dist/config/config-schema.d.ts +131 -0
- package/dist/config/config-schema.d.ts.map +1 -0
- package/dist/config/config-schema.js +93 -0
- package/dist/config/config-schema.js.map +1 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +3 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/load-config.d.ts +7 -0
- package/dist/config/load-config.d.ts.map +1 -0
- package/dist/config/load-config.js +63 -0
- package/dist/config/load-config.js.map +1 -0
- package/dist/context/compressed-context.d.ts +3 -0
- package/dist/context/compressed-context.d.ts.map +1 -0
- package/dist/context/compressed-context.js +145 -0
- package/dist/context/compressed-context.js.map +1 -0
- package/dist/context/context-index.d.ts +18 -0
- package/dist/context/context-index.d.ts.map +1 -0
- package/dist/context/context-index.js +59 -0
- package/dist/context/context-index.js.map +1 -0
- package/dist/context/export-context.d.ts +61 -0
- package/dist/context/export-context.d.ts.map +1 -0
- package/dist/context/export-context.js +191 -0
- package/dist/context/export-context.js.map +1 -0
- package/dist/context/get-component-context.d.ts +3 -0
- package/dist/context/get-component-context.d.ts.map +1 -0
- package/dist/context/get-component-context.js +898 -0
- package/dist/context/get-component-context.js.map +1 -0
- package/dist/context/hashing.d.ts +14 -0
- package/dist/context/hashing.d.ts.map +1 -0
- package/dist/context/hashing.js +53 -0
- package/dist/context/hashing.js.map +1 -0
- package/dist/context/metadata-extraction.d.ts +15 -0
- package/dist/context/metadata-extraction.d.ts.map +1 -0
- package/dist/context/metadata-extraction.js +47 -0
- package/dist/context/metadata-extraction.js.map +1 -0
- package/dist/design-tool/figma-adapter.d.ts +20 -0
- package/dist/design-tool/figma-adapter.d.ts.map +1 -0
- package/dist/design-tool/figma-adapter.js +46 -0
- package/dist/design-tool/figma-adapter.js.map +1 -0
- package/dist/design-tool/index.d.ts +4 -0
- package/dist/design-tool/index.d.ts.map +1 -0
- package/dist/design-tool/index.js +3 -0
- package/dist/design-tool/index.js.map +1 -0
- package/dist/design-tool/registry.d.ts +12 -0
- package/dist/design-tool/registry.d.ts.map +1 -0
- package/dist/design-tool/registry.js +23 -0
- package/dist/design-tool/registry.js.map +1 -0
- package/dist/design-tool/types.d.ts +28 -0
- package/dist/design-tool/types.d.ts.map +1 -0
- package/dist/design-tool/types.js +2 -0
- package/dist/design-tool/types.js.map +1 -0
- package/dist/diff/compare-components.d.ts +3 -0
- package/dist/diff/compare-components.d.ts.map +1 -0
- package/dist/diff/compare-components.js +198 -0
- package/dist/diff/compare-components.js.map +1 -0
- package/dist/diff/compare-dependencies.d.ts +3 -0
- package/dist/diff/compare-dependencies.d.ts.map +1 -0
- package/dist/diff/compare-dependencies.js +30 -0
- package/dist/diff/compare-dependencies.js.map +1 -0
- package/dist/diff/compare-tokens.d.ts +3 -0
- package/dist/diff/compare-tokens.d.ts.map +1 -0
- package/dist/diff/compare-tokens.js +52 -0
- package/dist/diff/compare-tokens.js.map +1 -0
- package/dist/diff/compute-design-diff.d.ts +3 -0
- package/dist/diff/compute-design-diff.d.ts.map +1 -0
- package/dist/diff/compute-design-diff.js +27 -0
- package/dist/diff/compute-design-diff.js.map +1 -0
- package/dist/diff/format-diff-summary.d.ts +3 -0
- package/dist/diff/format-diff-summary.d.ts.map +1 -0
- package/dist/diff/format-diff-summary.js +59 -0
- package/dist/diff/format-diff-summary.js.map +1 -0
- package/dist/diff/index.d.ts +6 -0
- package/dist/diff/index.d.ts.map +1 -0
- package/dist/diff/index.js +6 -0
- package/dist/diff/index.js.map +1 -0
- package/dist/docs/generate-component-doc.d.ts +34 -0
- package/dist/docs/generate-component-doc.d.ts.map +1 -0
- package/dist/docs/generate-component-doc.js +269 -0
- package/dist/docs/generate-component-doc.js.map +1 -0
- package/dist/docs/generate-component-stories.d.ts +3 -0
- package/dist/docs/generate-component-stories.d.ts.map +1 -0
- package/dist/docs/generate-component-stories.js +116 -0
- package/dist/docs/generate-component-stories.js.map +1 -0
- package/dist/docs/generate-system-doc.d.ts +23 -0
- package/dist/docs/generate-system-doc.d.ts.map +1 -0
- package/dist/docs/generate-system-doc.js +337 -0
- package/dist/docs/generate-system-doc.js.map +1 -0
- package/dist/docs/index.d.ts +5 -0
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +5 -0
- package/dist/docs/index.js.map +1 -0
- package/dist/docs/setup-storybook.d.ts +26 -0
- package/dist/docs/setup-storybook.d.ts.map +1 -0
- package/dist/docs/setup-storybook.js +216 -0
- package/dist/docs/setup-storybook.js.map +1 -0
- package/dist/doctor/check-component.d.ts +5 -0
- package/dist/doctor/check-component.d.ts.map +1 -0
- package/dist/doctor/check-component.js +120 -0
- package/dist/doctor/check-component.js.map +1 -0
- package/dist/doctor/check-config.d.ts +4 -0
- package/dist/doctor/check-config.d.ts.map +1 -0
- package/dist/doctor/check-config.js +65 -0
- package/dist/doctor/check-config.js.map +1 -0
- package/dist/doctor/check-tokens.d.ts +4 -0
- package/dist/doctor/check-tokens.d.ts.map +1 -0
- package/dist/doctor/check-tokens.js +17 -0
- package/dist/doctor/check-tokens.js.map +1 -0
- package/dist/doctor/index.d.ts +5 -0
- package/dist/doctor/index.d.ts.map +1 -0
- package/dist/doctor/index.js +5 -0
- package/dist/doctor/index.js.map +1 -0
- package/dist/doctor/types.d.ts +30 -0
- package/dist/doctor/types.d.ts.map +1 -0
- package/dist/doctor/types.js +2 -0
- package/dist/doctor/types.js.map +1 -0
- package/dist/filesystem/ensure-dir.d.ts +5 -0
- package/dist/filesystem/ensure-dir.d.ts.map +1 -0
- package/dist/filesystem/ensure-dir.js +17 -0
- package/dist/filesystem/ensure-dir.js.map +1 -0
- package/dist/filesystem/index.d.ts +6 -0
- package/dist/filesystem/index.d.ts.map +1 -0
- package/dist/filesystem/index.js +6 -0
- package/dist/filesystem/index.js.map +1 -0
- package/dist/filesystem/resolve-component-path.d.ts +10 -0
- package/dist/filesystem/resolve-component-path.d.ts.map +1 -0
- package/dist/filesystem/resolve-component-path.js +32 -0
- package/dist/filesystem/resolve-component-path.js.map +1 -0
- package/dist/filesystem/resolve-ds-paths.d.ts +15 -0
- package/dist/filesystem/resolve-ds-paths.d.ts.map +1 -0
- package/dist/filesystem/resolve-ds-paths.js +51 -0
- package/dist/filesystem/resolve-ds-paths.js.map +1 -0
- package/dist/filesystem/workspace-root.d.ts +6 -0
- package/dist/filesystem/workspace-root.d.ts.map +1 -0
- package/dist/filesystem/workspace-root.js +21 -0
- package/dist/filesystem/workspace-root.js.map +1 -0
- package/dist/filesystem/write-json.d.ts +6 -0
- package/dist/filesystem/write-json.d.ts.map +1 -0
- package/dist/filesystem/write-json.js +10 -0
- package/dist/filesystem/write-json.js.map +1 -0
- package/dist/filesystem/write-text.d.ts +10 -0
- package/dist/filesystem/write-text.d.ts.map +1 -0
- package/dist/filesystem/write-text.js +22 -0
- package/dist/filesystem/write-text.js.map +1 -0
- package/dist/generators/components/generate-component-css.d.ts +6 -0
- package/dist/generators/components/generate-component-css.d.ts.map +1 -0
- package/dist/generators/components/generate-component-css.js +92 -0
- package/dist/generators/components/generate-component-css.js.map +1 -0
- package/dist/generators/components/generate-component-file.d.ts +8 -0
- package/dist/generators/components/generate-component-file.d.ts.map +1 -0
- package/dist/generators/components/generate-component-file.js +209 -0
- package/dist/generators/components/generate-component-file.js.map +1 -0
- package/dist/generators/components/generate-composite-file.d.ts +3 -0
- package/dist/generators/components/generate-composite-file.d.ts.map +1 -0
- package/dist/generators/components/generate-composite-file.js +77 -0
- package/dist/generators/components/generate-composite-file.js.map +1 -0
- package/dist/generators/components/generate-composite-types.d.ts +7 -0
- package/dist/generators/components/generate-composite-types.d.ts.map +1 -0
- package/dist/generators/components/generate-composite-types.js +43 -0
- package/dist/generators/components/generate-composite-types.js.map +1 -0
- package/dist/generators/components/generate-types-file.d.ts +8 -0
- package/dist/generators/components/generate-types-file.d.ts.map +1 -0
- package/dist/generators/components/generate-types-file.js +64 -0
- package/dist/generators/components/generate-types-file.js.map +1 -0
- package/dist/generators/components/helpers.d.ts +33 -0
- package/dist/generators/components/helpers.d.ts.map +1 -0
- package/dist/generators/components/helpers.js +124 -0
- package/dist/generators/components/helpers.js.map +1 -0
- package/dist/generators/components/index.d.ts +9 -0
- package/dist/generators/components/index.d.ts.map +1 -0
- package/dist/generators/components/index.js +10 -0
- package/dist/generators/components/index.js.map +1 -0
- package/dist/generators/components/layout-jsx.d.ts +14 -0
- package/dist/generators/components/layout-jsx.d.ts.map +1 -0
- package/dist/generators/components/layout-jsx.js +271 -0
- package/dist/generators/components/layout-jsx.js.map +1 -0
- package/dist/generators/components/prune-components.d.ts +15 -0
- package/dist/generators/components/prune-components.d.ts.map +1 -0
- package/dist/generators/components/prune-components.js +88 -0
- package/dist/generators/components/prune-components.js.map +1 -0
- package/dist/generators/components/token-helpers.d.ts +32 -0
- package/dist/generators/components/token-helpers.d.ts.map +1 -0
- package/dist/generators/components/token-helpers.js +188 -0
- package/dist/generators/components/token-helpers.js.map +1 -0
- package/dist/generators/components/write-components.d.ts +17 -0
- package/dist/generators/components/write-components.d.ts.map +1 -0
- package/dist/generators/components/write-components.js +212 -0
- package/dist/generators/components/write-components.js.map +1 -0
- package/dist/generators/components/write-composites.d.ts +4 -0
- package/dist/generators/components/write-composites.d.ts.map +1 -0
- package/dist/generators/components/write-composites.js +116 -0
- package/dist/generators/components/write-composites.js.map +1 -0
- package/dist/generators/composites/generate-composite-file.d.ts +3 -0
- package/dist/generators/composites/generate-composite-file.d.ts.map +1 -0
- package/dist/generators/composites/generate-composite-file.js +101 -0
- package/dist/generators/composites/generate-composite-file.js.map +1 -0
- package/dist/generators/composites/generate-composite-types.d.ts +7 -0
- package/dist/generators/composites/generate-composite-types.d.ts.map +1 -0
- package/dist/generators/composites/generate-composite-types.js +43 -0
- package/dist/generators/composites/generate-composite-types.js.map +1 -0
- package/dist/generators/composites/index.d.ts +4 -0
- package/dist/generators/composites/index.d.ts.map +1 -0
- package/dist/generators/composites/index.js +4 -0
- package/dist/generators/composites/index.js.map +1 -0
- package/dist/generators/composites/write-composites.d.ts +4 -0
- package/dist/generators/composites/write-composites.d.ts.map +1 -0
- package/dist/generators/composites/write-composites.js +116 -0
- package/dist/generators/composites/write-composites.js.map +1 -0
- package/dist/generators/registry.d.ts +9 -0
- package/dist/generators/registry.d.ts.map +1 -0
- package/dist/generators/registry.js +11 -0
- package/dist/generators/registry.js.map +1 -0
- package/dist/generators/scaffold/generate-placeholder-component-content.d.ts +9 -0
- package/dist/generators/scaffold/generate-placeholder-component-content.d.ts.map +1 -0
- package/dist/generators/scaffold/generate-placeholder-component-content.js +68 -0
- package/dist/generators/scaffold/generate-placeholder-component-content.js.map +1 -0
- package/dist/generators/scaffold/index.d.ts +3 -0
- package/dist/generators/scaffold/index.d.ts.map +1 -0
- package/dist/generators/scaffold/index.js +3 -0
- package/dist/generators/scaffold/index.js.map +1 -0
- package/dist/generators/scaffold/write-scaffold.d.ts +14 -0
- package/dist/generators/scaffold/write-scaffold.d.ts.map +1 -0
- package/dist/generators/scaffold/write-scaffold.js +87 -0
- package/dist/generators/scaffold/write-scaffold.js.map +1 -0
- package/dist/generators/tokens/generate-token-css.d.ts +6 -0
- package/dist/generators/tokens/generate-token-css.d.ts.map +1 -0
- package/dist/generators/tokens/generate-token-css.js +31 -0
- package/dist/generators/tokens/generate-token-css.js.map +1 -0
- package/dist/generators/tokens/generate-token-file-content.d.ts +6 -0
- package/dist/generators/tokens/generate-token-file-content.d.ts.map +1 -0
- package/dist/generators/tokens/generate-token-file-content.js +27 -0
- package/dist/generators/tokens/generate-token-file-content.js.map +1 -0
- package/dist/generators/tokens/index.d.ts +3 -0
- package/dist/generators/tokens/index.d.ts.map +1 -0
- package/dist/generators/tokens/index.js +3 -0
- package/dist/generators/tokens/index.js.map +1 -0
- package/dist/generators/tokens/write-tokens.d.ts +14 -0
- package/dist/generators/tokens/write-tokens.d.ts.map +1 -0
- package/dist/generators/tokens/write-tokens.js +96 -0
- package/dist/generators/tokens/write-tokens.js.map +1 -0
- package/dist/generators/types.d.ts +11 -0
- package/dist/generators/types.d.ts.map +1 -0
- package/dist/generators/types.js +2 -0
- package/dist/generators/types.js.map +1 -0
- package/dist/icons/enrich-icon-svgs.d.ts +10 -0
- package/dist/icons/enrich-icon-svgs.d.ts.map +1 -0
- package/dist/icons/enrich-icon-svgs.js +88 -0
- package/dist/icons/enrich-icon-svgs.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest/index.d.ts +8 -0
- package/dist/manifest/index.d.ts.map +1 -0
- package/dist/manifest/index.js +80 -0
- package/dist/manifest/index.js.map +1 -0
- package/dist/mappings/build-file-mappings.d.ts +6 -0
- package/dist/mappings/build-file-mappings.d.ts.map +1 -0
- package/dist/mappings/build-file-mappings.js +37 -0
- package/dist/mappings/build-file-mappings.js.map +1 -0
- package/dist/mappings/index.d.ts +3 -0
- package/dist/mappings/index.d.ts.map +1 -0
- package/dist/mappings/index.js +3 -0
- package/dist/mappings/index.js.map +1 -0
- package/dist/mappings/naming-strategy.d.ts +20 -0
- package/dist/mappings/naming-strategy.d.ts.map +1 -0
- package/dist/mappings/naming-strategy.js +78 -0
- package/dist/mappings/naming-strategy.js.map +1 -0
- package/dist/model/build-design-system-model.d.ts +7 -0
- package/dist/model/build-design-system-model.d.ts.map +1 -0
- package/dist/model/build-design-system-model.js +78 -0
- package/dist/model/build-design-system-model.js.map +1 -0
- package/dist/model/index.d.ts +2 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +2 -0
- package/dist/model/index.js.map +1 -0
- package/dist/model/resolve-component.d.ts +11 -0
- package/dist/model/resolve-component.d.ts.map +1 -0
- package/dist/model/resolve-component.js +110 -0
- package/dist/model/resolve-component.js.map +1 -0
- package/dist/normalizer/classify-entities.d.ts +12 -0
- package/dist/normalizer/classify-entities.d.ts.map +1 -0
- package/dist/normalizer/classify-entities.js +62 -0
- package/dist/normalizer/classify-entities.js.map +1 -0
- package/dist/normalizer/helpers.d.ts +13 -0
- package/dist/normalizer/helpers.d.ts.map +1 -0
- package/dist/normalizer/helpers.js +27 -0
- package/dist/normalizer/helpers.js.map +1 -0
- package/dist/normalizer/index.d.ts +7 -0
- package/dist/normalizer/index.d.ts.map +1 -0
- package/dist/normalizer/index.js +7 -0
- package/dist/normalizer/index.js.map +1 -0
- package/dist/normalizer/instance-resolver.d.ts +13 -0
- package/dist/normalizer/instance-resolver.d.ts.map +1 -0
- package/dist/normalizer/instance-resolver.js +747 -0
- package/dist/normalizer/instance-resolver.js.map +1 -0
- package/dist/normalizer/layout-tree.d.ts +12 -0
- package/dist/normalizer/layout-tree.d.ts.map +1 -0
- package/dist/normalizer/layout-tree.js +312 -0
- package/dist/normalizer/layout-tree.js.map +1 -0
- package/dist/normalizer/naming.d.ts +11 -0
- package/dist/normalizer/naming.d.ts.map +1 -0
- package/dist/normalizer/naming.js +44 -0
- package/dist/normalizer/naming.js.map +1 -0
- package/dist/normalizer/normalize-components.d.ts +13 -0
- package/dist/normalizer/normalize-components.d.ts.map +1 -0
- package/dist/normalizer/normalize-components.js +520 -0
- package/dist/normalizer/normalize-components.js.map +1 -0
- package/dist/normalizer/normalize-composites.d.ts +8 -0
- package/dist/normalizer/normalize-composites.d.ts.map +1 -0
- package/dist/normalizer/normalize-composites.js +22 -0
- package/dist/normalizer/normalize-composites.js.map +1 -0
- package/dist/normalizer/normalize-instances.d.ts +9 -0
- package/dist/normalizer/normalize-instances.d.ts.map +1 -0
- package/dist/normalizer/normalize-instances.js +32 -0
- package/dist/normalizer/normalize-instances.js.map +1 -0
- package/dist/normalizer/types.d.ts +22 -0
- package/dist/normalizer/types.d.ts.map +1 -0
- package/dist/normalizer/types.js +2 -0
- package/dist/normalizer/types.js.map +1 -0
- package/dist/normalizer/variant-diff.d.ts +101 -0
- package/dist/normalizer/variant-diff.d.ts.map +1 -0
- package/dist/normalizer/variant-diff.js +307 -0
- package/dist/normalizer/variant-diff.js.map +1 -0
- package/dist/plan/implementation-plan.d.ts +28 -0
- package/dist/plan/implementation-plan.d.ts.map +1 -0
- package/dist/plan/implementation-plan.js +60 -0
- package/dist/plan/implementation-plan.js.map +1 -0
- package/dist/plan/index.d.ts +3 -0
- package/dist/plan/index.d.ts.map +1 -0
- package/dist/plan/index.js +3 -0
- package/dist/plan/index.js.map +1 -0
- package/dist/plan/resolve-affected-files.d.ts +11 -0
- package/dist/plan/resolve-affected-files.d.ts.map +1 -0
- package/dist/plan/resolve-affected-files.js +73 -0
- package/dist/plan/resolve-affected-files.js.map +1 -0
- package/dist/prompt/generate-component-prompt.d.ts +6 -0
- package/dist/prompt/generate-component-prompt.d.ts.map +1 -0
- package/dist/prompt/generate-component-prompt.js +1644 -0
- package/dist/prompt/generate-component-prompt.js.map +1 -0
- package/dist/registry/ai-provider-registry.d.ts +7 -0
- package/dist/registry/ai-provider-registry.d.ts.map +1 -0
- package/dist/registry/ai-provider-registry.js +21 -0
- package/dist/registry/ai-provider-registry.js.map +1 -0
- package/dist/registry/build-component-registry.d.ts +6 -0
- package/dist/registry/build-component-registry.d.ts.map +1 -0
- package/dist/registry/build-component-registry.js +43 -0
- package/dist/registry/build-component-registry.js.map +1 -0
- package/dist/registry/build-dependency-graph.d.ts +7 -0
- package/dist/registry/build-dependency-graph.d.ts.map +1 -0
- package/dist/registry/build-dependency-graph.js +36 -0
- package/dist/registry/build-dependency-graph.js.map +1 -0
- package/dist/registry/generator-registry.d.ts +12 -0
- package/dist/registry/generator-registry.d.ts.map +1 -0
- package/dist/registry/generator-registry.js +22 -0
- package/dist/registry/generator-registry.js.map +1 -0
- package/dist/registry/index.d.ts +3 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +3 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/scaffold-plan/build-scaffold-plan.d.ts +16 -0
- package/dist/scaffold-plan/build-scaffold-plan.d.ts.map +1 -0
- package/dist/scaffold-plan/build-scaffold-plan.js +91 -0
- package/dist/scaffold-plan/build-scaffold-plan.js.map +1 -0
- package/dist/scaffold-plan/index.d.ts +2 -0
- package/dist/scaffold-plan/index.d.ts.map +1 -0
- package/dist/scaffold-plan/index.js +2 -0
- package/dist/scaffold-plan/index.js.map +1 -0
- package/dist/scanner/collect-components.d.ts +10 -0
- package/dist/scanner/collect-components.d.ts.map +1 -0
- package/dist/scanner/collect-components.js +103 -0
- package/dist/scanner/collect-components.js.map +1 -0
- package/dist/scanner/collect-instances.d.ts +6 -0
- package/dist/scanner/collect-instances.d.ts.map +1 -0
- package/dist/scanner/collect-instances.js +31 -0
- package/dist/scanner/collect-instances.js.map +1 -0
- package/dist/scanner/index.d.ts +6 -0
- package/dist/scanner/index.d.ts.map +1 -0
- package/dist/scanner/index.js +6 -0
- package/dist/scanner/index.js.map +1 -0
- package/dist/scanner/scan-file.d.ts +6 -0
- package/dist/scanner/scan-file.d.ts.map +1 -0
- package/dist/scanner/scan-file.js +28 -0
- package/dist/scanner/scan-file.js.map +1 -0
- package/dist/scanner/traverse-nodes.d.ts +15 -0
- package/dist/scanner/traverse-nodes.d.ts.map +1 -0
- package/dist/scanner/traverse-nodes.js +18 -0
- package/dist/scanner/traverse-nodes.js.map +1 -0
- package/dist/scanner/types.d.ts +89 -0
- package/dist/scanner/types.d.ts.map +1 -0
- package/dist/scanner/types.js +2 -0
- package/dist/scanner/types.js.map +1 -0
- package/dist/snapshots/index.d.ts +6 -0
- package/dist/snapshots/index.d.ts.map +1 -0
- package/dist/snapshots/index.js +6 -0
- package/dist/snapshots/index.js.map +1 -0
- package/dist/snapshots/load-imported-tokens.d.ts +8 -0
- package/dist/snapshots/load-imported-tokens.d.ts.map +1 -0
- package/dist/snapshots/load-imported-tokens.js +27 -0
- package/dist/snapshots/load-imported-tokens.js.map +1 -0
- package/dist/snapshots/load-latest-snapshot.d.ts +3 -0
- package/dist/snapshots/load-latest-snapshot.d.ts.map +1 -0
- package/dist/snapshots/load-latest-snapshot.js +16 -0
- package/dist/snapshots/load-latest-snapshot.js.map +1 -0
- package/dist/snapshots/load-previous-snapshot.d.ts +7 -0
- package/dist/snapshots/load-previous-snapshot.d.ts.map +1 -0
- package/dist/snapshots/load-previous-snapshot.js +39 -0
- package/dist/snapshots/load-previous-snapshot.js.map +1 -0
- package/dist/snapshots/save-imported-tokens.d.ts +4 -0
- package/dist/snapshots/save-imported-tokens.d.ts.map +1 -0
- package/dist/snapshots/save-imported-tokens.js +16 -0
- package/dist/snapshots/save-imported-tokens.js.map +1 -0
- package/dist/snapshots/save-snapshot.d.ts +3 -0
- package/dist/snapshots/save-snapshot.d.ts.map +1 -0
- package/dist/snapshots/save-snapshot.js +49 -0
- package/dist/snapshots/save-snapshot.js.map +1 -0
- package/dist/test-null-safety.d.ts +2 -0
- package/dist/test-null-safety.d.ts.map +1 -0
- package/dist/test-null-safety.js +67 -0
- package/dist/test-null-safety.js.map +1 -0
- package/dist/test-regex.d.ts +2 -0
- package/dist/test-regex.d.ts.map +1 -0
- package/dist/test-regex.js +25 -0
- package/dist/test-regex.js.map +1 -0
- package/dist/test-token-resolution.d.ts +2 -0
- package/dist/test-token-resolution.d.ts.map +1 -0
- package/dist/test-token-resolution.js +54 -0
- package/dist/test-token-resolution.js.map +1 -0
- package/dist/test-typography.d.ts +2 -0
- package/dist/test-typography.d.ts.map +1 -0
- package/dist/test-typography.js +69 -0
- package/dist/test-typography.js.map +1 -0
- package/dist/tokens/adapters/generic-adapter.d.ts +13 -0
- package/dist/tokens/adapters/generic-adapter.d.ts.map +1 -0
- package/dist/tokens/adapters/generic-adapter.js +74 -0
- package/dist/tokens/adapters/generic-adapter.js.map +1 -0
- package/dist/tokens/adapters/index.d.ts +3 -0
- package/dist/tokens/adapters/index.d.ts.map +1 -0
- package/dist/tokens/adapters/index.js +3 -0
- package/dist/tokens/adapters/index.js.map +1 -0
- package/dist/tokens/adapters/ptb-adapter.d.ts +13 -0
- package/dist/tokens/adapters/ptb-adapter.d.ts.map +1 -0
- package/dist/tokens/adapters/ptb-adapter.js +13 -0
- package/dist/tokens/adapters/ptb-adapter.js.map +1 -0
- package/dist/tokens/build-token-model.d.ts +12 -0
- package/dist/tokens/build-token-model.d.ts.map +1 -0
- package/dist/tokens/build-token-model.js +50 -0
- package/dist/tokens/build-token-model.js.map +1 -0
- package/dist/tokens/classify-token-kind.d.ts +7 -0
- package/dist/tokens/classify-token-kind.d.ts.map +1 -0
- package/dist/tokens/classify-token-kind.js +24 -0
- package/dist/tokens/classify-token-kind.js.map +1 -0
- package/dist/tokens/detect-format.d.ts +6 -0
- package/dist/tokens/detect-format.d.ts.map +1 -0
- package/dist/tokens/detect-format.js +23 -0
- package/dist/tokens/detect-format.js.map +1 -0
- package/dist/tokens/import-schema.d.ts +111 -0
- package/dist/tokens/import-schema.d.ts.map +1 -0
- package/dist/tokens/import-schema.js +45 -0
- package/dist/tokens/import-schema.js.map +1 -0
- package/dist/tokens/import-tokens.d.ts +16 -0
- package/dist/tokens/import-tokens.d.ts.map +1 -0
- package/dist/tokens/import-tokens.js +40 -0
- package/dist/tokens/import-tokens.js.map +1 -0
- package/dist/tokens/index.d.ts +12 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/index.js +12 -0
- package/dist/tokens/index.js.map +1 -0
- package/dist/tokens/naming.d.ts +19 -0
- package/dist/tokens/naming.d.ts.map +1 -0
- package/dist/tokens/naming.js +27 -0
- package/dist/tokens/naming.js.map +1 -0
- package/dist/tokens/normalize-token-collections.d.ts +7 -0
- package/dist/tokens/normalize-token-collections.d.ts.map +1 -0
- package/dist/tokens/normalize-token-collections.js +68 -0
- package/dist/tokens/normalize-token-collections.js.map +1 -0
- package/dist/tokens/resolution.d.ts +7 -0
- package/dist/tokens/resolution.d.ts.map +1 -0
- package/dist/tokens/resolution.js +223 -0
- package/dist/tokens/resolution.js.map +1 -0
- package/dist/tokens/resolve-token-source.d.ts +12 -0
- package/dist/tokens/resolve-token-source.d.ts.map +1 -0
- package/dist/tokens/resolve-token-source.js +37 -0
- package/dist/tokens/resolve-token-source.js.map +1 -0
- package/dist/tokens/types.d.ts +40 -0
- package/dist/tokens/types.d.ts.map +1 -0
- package/dist/tokens/types.js +2 -0
- package/dist/tokens/types.js.map +1 -0
- package/package.json +34 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const TokenModeSchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
export declare const TokenValueSchema: z.ZodObject<{
|
|
7
|
+
type: z.ZodString;
|
|
8
|
+
value: z.ZodAny;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export declare const ImportedTokenSchema: z.ZodObject<{
|
|
11
|
+
id: z.ZodString;
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
codeName: z.ZodOptional<z.ZodString>;
|
|
14
|
+
resolvedType: z.ZodString;
|
|
15
|
+
valuesByMode: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
16
|
+
type: z.ZodString;
|
|
17
|
+
value: z.ZodAny;
|
|
18
|
+
}, z.core.$strip>>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export declare const ImportedCollectionSchema: z.ZodObject<{
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
name: z.ZodString;
|
|
23
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
24
|
+
modes: z.ZodArray<z.ZodObject<{
|
|
25
|
+
id: z.ZodString;
|
|
26
|
+
name: z.ZodString;
|
|
27
|
+
}, z.core.$strip>>;
|
|
28
|
+
tokens: z.ZodArray<z.ZodObject<{
|
|
29
|
+
id: z.ZodString;
|
|
30
|
+
name: z.ZodString;
|
|
31
|
+
codeName: z.ZodOptional<z.ZodString>;
|
|
32
|
+
resolvedType: z.ZodString;
|
|
33
|
+
valuesByMode: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
34
|
+
type: z.ZodString;
|
|
35
|
+
value: z.ZodAny;
|
|
36
|
+
}, z.core.$strip>>;
|
|
37
|
+
}, z.core.$strip>>;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
export declare const TokenExportSourceSchema: z.ZodObject<{
|
|
40
|
+
tool: z.ZodString;
|
|
41
|
+
fileName: z.ZodOptional<z.ZodString>;
|
|
42
|
+
exportedAt: z.ZodString;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
export declare const PTBTokenExportSchema: z.ZodObject<{
|
|
45
|
+
version: z.ZodString;
|
|
46
|
+
source: z.ZodObject<{
|
|
47
|
+
tool: z.ZodString;
|
|
48
|
+
fileName: z.ZodOptional<z.ZodString>;
|
|
49
|
+
exportedAt: z.ZodString;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
collections: z.ZodArray<z.ZodObject<{
|
|
52
|
+
id: z.ZodString;
|
|
53
|
+
name: z.ZodString;
|
|
54
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
55
|
+
modes: z.ZodArray<z.ZodObject<{
|
|
56
|
+
id: z.ZodString;
|
|
57
|
+
name: z.ZodString;
|
|
58
|
+
}, z.core.$strip>>;
|
|
59
|
+
tokens: z.ZodArray<z.ZodObject<{
|
|
60
|
+
id: z.ZodString;
|
|
61
|
+
name: z.ZodString;
|
|
62
|
+
codeName: z.ZodOptional<z.ZodString>;
|
|
63
|
+
resolvedType: z.ZodString;
|
|
64
|
+
valuesByMode: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
65
|
+
type: z.ZodString;
|
|
66
|
+
value: z.ZodAny;
|
|
67
|
+
}, z.core.$strip>>;
|
|
68
|
+
}, z.core.$strip>>;
|
|
69
|
+
}, z.core.$strip>>;
|
|
70
|
+
}, z.core.$strip>;
|
|
71
|
+
export declare const GenericTokenExportSchema: z.ZodObject<{
|
|
72
|
+
collections: z.ZodArray<z.ZodObject<{
|
|
73
|
+
name: z.ZodOptional<z.ZodString>;
|
|
74
|
+
modes: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
75
|
+
tokens: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
76
|
+
variables: z.ZodOptional<z.ZodArray<z.ZodAny>>;
|
|
77
|
+
}, z.core.$loose>>;
|
|
78
|
+
}, z.core.$loose>;
|
|
79
|
+
export declare const CanonicalTokenExportSchema: z.ZodObject<{
|
|
80
|
+
version: z.ZodString;
|
|
81
|
+
source: z.ZodObject<{
|
|
82
|
+
tool: z.ZodString;
|
|
83
|
+
fileName: z.ZodOptional<z.ZodString>;
|
|
84
|
+
exportedAt: z.ZodString;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
collections: z.ZodArray<z.ZodObject<{
|
|
87
|
+
id: z.ZodString;
|
|
88
|
+
name: z.ZodString;
|
|
89
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
90
|
+
modes: z.ZodArray<z.ZodObject<{
|
|
91
|
+
id: z.ZodString;
|
|
92
|
+
name: z.ZodString;
|
|
93
|
+
}, z.core.$strip>>;
|
|
94
|
+
tokens: z.ZodArray<z.ZodObject<{
|
|
95
|
+
id: z.ZodString;
|
|
96
|
+
name: z.ZodString;
|
|
97
|
+
codeName: z.ZodOptional<z.ZodString>;
|
|
98
|
+
resolvedType: z.ZodString;
|
|
99
|
+
valuesByMode: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
100
|
+
type: z.ZodString;
|
|
101
|
+
value: z.ZodAny;
|
|
102
|
+
}, z.core.$strip>>;
|
|
103
|
+
}, z.core.$strip>>;
|
|
104
|
+
}, z.core.$strip>>;
|
|
105
|
+
}, z.core.$strip>;
|
|
106
|
+
export type PTBTokenExport = z.infer<typeof PTBTokenExportSchema>;
|
|
107
|
+
export type GenericTokenExport = z.infer<typeof GenericTokenExportSchema>;
|
|
108
|
+
export type CanonicalTokenExport = z.infer<typeof CanonicalTokenExportSchema>;
|
|
109
|
+
export type ImportedCollection = z.infer<typeof ImportedCollectionSchema>;
|
|
110
|
+
export type ImportedToken = z.infer<typeof ImportedTokenSchema>;
|
|
111
|
+
//# sourceMappingURL=import-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-schema.d.ts","sourceRoot":"","sources":["../../src/tokens/import-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,eAAe;;;iBAG1B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;iBAG3B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;iBAM9B,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;iBAMnC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;iBAIlC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;iBAI/B,CAAC;AAGH,eAAO,MAAM,wBAAwB;;;;;;;iBASrB,CAAC;AAGjB,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAuB,CAAC;AAE/D,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const TokenModeSchema = z.object({
|
|
3
|
+
id: z.string(),
|
|
4
|
+
name: z.string()
|
|
5
|
+
});
|
|
6
|
+
export const TokenValueSchema = z.object({
|
|
7
|
+
type: z.string(),
|
|
8
|
+
value: z.any() // Intentionally loose for mixed shape support (e.g. RGBA structs vs "string")
|
|
9
|
+
});
|
|
10
|
+
export const ImportedTokenSchema = z.object({
|
|
11
|
+
id: z.string(),
|
|
12
|
+
name: z.string(),
|
|
13
|
+
codeName: z.string().optional(),
|
|
14
|
+
resolvedType: z.string(),
|
|
15
|
+
valuesByMode: z.record(z.string(), TokenValueSchema)
|
|
16
|
+
});
|
|
17
|
+
export const ImportedCollectionSchema = z.object({
|
|
18
|
+
id: z.string(),
|
|
19
|
+
name: z.string(),
|
|
20
|
+
kind: z.string().optional(),
|
|
21
|
+
modes: z.array(TokenModeSchema),
|
|
22
|
+
tokens: z.array(ImportedTokenSchema)
|
|
23
|
+
});
|
|
24
|
+
export const TokenExportSourceSchema = z.object({
|
|
25
|
+
tool: z.string(),
|
|
26
|
+
fileName: z.string().optional(),
|
|
27
|
+
exportedAt: z.string()
|
|
28
|
+
});
|
|
29
|
+
export const PTBTokenExportSchema = z.object({
|
|
30
|
+
version: z.string(),
|
|
31
|
+
source: TokenExportSourceSchema,
|
|
32
|
+
collections: z.array(ImportedCollectionSchema)
|
|
33
|
+
});
|
|
34
|
+
// Generic fall-back matching any root object containing a `collections` array
|
|
35
|
+
export const GenericTokenExportSchema = z.object({
|
|
36
|
+
collections: z.array(z.object({
|
|
37
|
+
name: z.string().optional(),
|
|
38
|
+
modes: z.array(z.any()).optional(),
|
|
39
|
+
tokens: z.array(z.any()).optional(),
|
|
40
|
+
variables: z.array(z.any()).optional()
|
|
41
|
+
}).passthrough())
|
|
42
|
+
}).passthrough();
|
|
43
|
+
// Canonical format PTB utilizes internally (Mirroring PTBTokenExport exactly)
|
|
44
|
+
export const CanonicalTokenExportSchema = PTBTokenExportSchema;
|
|
45
|
+
//# sourceMappingURL=import-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-schema.js","sourceRoot":"","sources":["../../src/tokens/import-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;CACnB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,KAAK,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,8EAA8E;CAChG,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;IACxB,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,gBAAgB,CAAC;CACvD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC;IAC/B,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC;CACvC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;CACzB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,MAAM,EAAE,uBAAuB;IAC/B,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,wBAAwB,CAAC;CACjD,CAAC,CAAC;AAEH,8EAA8E;AAC9E,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,WAAW,EAAE,CAAC,CAAC,KAAK,CAChB,CAAC,CAAC,MAAM,CAAC;QACL,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC3B,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE;QAClC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE;QACnC,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE;KACzC,CAAC,CAAC,WAAW,EAAE,CACnB;CACJ,CAAC,CAAC,WAAW,EAAE,CAAC;AAEjB,8EAA8E;AAC9E,MAAM,CAAC,MAAM,0BAA0B,GAAG,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CanonicalTokenExport } from "./import-schema.js";
|
|
2
|
+
type ImportResult = {
|
|
3
|
+
success: true;
|
|
4
|
+
data: CanonicalTokenExport;
|
|
5
|
+
format: "ptb" | "generic";
|
|
6
|
+
} | {
|
|
7
|
+
success: false;
|
|
8
|
+
errorType: "not_found" | "invalid_json" | "unknown_format" | "schema_mismatch";
|
|
9
|
+
details?: any;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Validates, reads, and maps varying structural Token Export JSON files safely mapping it into Canonical TS structs.
|
|
13
|
+
*/
|
|
14
|
+
export declare function importTokenFile(filePath: string): Promise<ImportResult>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=import-tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-tokens.d.ts","sourceRoot":"","sources":["../../src/tokens/import-tokens.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,KAAK,YAAY,GACX;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,oBAAoB,CAAC;IAAC,MAAM,EAAE,KAAK,GAAG,SAAS,CAAA;CAAE,GACxE;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,SAAS,EAAE,WAAW,GAAG,cAAc,GAAG,gBAAgB,GAAG,iBAAiB,CAAC;IAAC,OAAO,CAAC,EAAE,GAAG,CAAA;CAAE,CAAC;AAExH;;GAEG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAoC7E"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as fs from "node:fs/promises";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { detectImportFormat } from "./detect-format.js";
|
|
4
|
+
import { adaptPTBTokenExportToCanonical, adaptGenericTokenExportToCanonical } from "./adapters/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* Validates, reads, and maps varying structural Token Export JSON files safely mapping it into Canonical TS structs.
|
|
7
|
+
*/
|
|
8
|
+
export async function importTokenFile(filePath) {
|
|
9
|
+
const resolvedPath = path.resolve(process.cwd(), filePath);
|
|
10
|
+
let rawContent;
|
|
11
|
+
try {
|
|
12
|
+
rawContent = await fs.readFile(resolvedPath, "utf-8");
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return { success: false, errorType: "not_found" };
|
|
16
|
+
}
|
|
17
|
+
let parsedJson;
|
|
18
|
+
try {
|
|
19
|
+
parsedJson = JSON.parse(rawContent);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return { success: false, errorType: "invalid_json" };
|
|
23
|
+
}
|
|
24
|
+
const format = detectImportFormat(parsedJson);
|
|
25
|
+
if (format === "unknown") {
|
|
26
|
+
return { success: false, errorType: "unknown_format" };
|
|
27
|
+
}
|
|
28
|
+
const adapterResult = format === "ptb"
|
|
29
|
+
? adaptPTBTokenExportToCanonical(parsedJson)
|
|
30
|
+
: adaptGenericTokenExportToCanonical(parsedJson);
|
|
31
|
+
if (!adapterResult.success) {
|
|
32
|
+
return {
|
|
33
|
+
success: false,
|
|
34
|
+
errorType: "schema_mismatch",
|
|
35
|
+
details: adapterResult.issues
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return { success: true, data: adapterResult.data, format };
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=import-tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-tokens.js","sourceRoot":"","sources":["../../src/tokens/import-tokens.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,8BAA8B,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAC;AAOzG;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,QAAgB;IAClD,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC;IAE3D,IAAI,UAAkB,CAAC;IACvB,IAAI,CAAC;QACD,UAAU,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;IACtD,CAAC;IAED,IAAI,UAAe,CAAC;IACpB,IAAI,CAAC;QACD,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;IACzD,CAAC;IAED,MAAM,MAAM,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAE9C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC3D,CAAC;IAED,MAAM,aAAa,GAAG,MAAM,KAAK,KAAK;QAClC,CAAC,CAAC,8BAA8B,CAAC,UAAU,CAAC;QAC5C,CAAC,CAAC,kCAAkC,CAAC,UAAU,CAAC,CAAC;IAErD,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;QACzB,OAAO;YACH,OAAO,EAAE,KAAK;YACd,SAAS,EAAE,iBAAiB;YAC5B,OAAO,EAAE,aAAa,CAAC,MAAM;SAChC,CAAC;IACN,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./build-token-model.js";
|
|
2
|
+
export * from "./types.js";
|
|
3
|
+
export * from "./naming.js";
|
|
4
|
+
export * from "./classify-token-kind.js";
|
|
5
|
+
export * from "./normalize-token-collections.js";
|
|
6
|
+
export * from "./import-schema.js";
|
|
7
|
+
export * from "./detect-format.js";
|
|
8
|
+
export * from "./adapters/index.js";
|
|
9
|
+
export * from "./import-tokens.js";
|
|
10
|
+
export * from "./resolve-token-source.js";
|
|
11
|
+
export * from "./resolution.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tokens/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./build-token-model.js";
|
|
2
|
+
export * from "./types.js";
|
|
3
|
+
export * from "./naming.js";
|
|
4
|
+
export * from "./classify-token-kind.js";
|
|
5
|
+
export * from "./normalize-token-collections.js";
|
|
6
|
+
export * from "./import-schema.js";
|
|
7
|
+
export * from "./detect-format.js";
|
|
8
|
+
export * from "./adapters/index.js";
|
|
9
|
+
export * from "./import-tokens.js";
|
|
10
|
+
export * from "./resolve-token-source.js";
|
|
11
|
+
export * from "./resolution.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tokens/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes a Figma token name into a safe, source-faithful CSS Custom Property segment.
|
|
3
|
+
*
|
|
4
|
+
* Rule: SOURCE IS TRUTH.
|
|
5
|
+
* - preserve characters like numbers and hyphens
|
|
6
|
+
* - replace illegal CSS variable characters with hyphens
|
|
7
|
+
* - collapse multiple hyphens
|
|
8
|
+
* - trim leading/trailing hyphens
|
|
9
|
+
*
|
|
10
|
+
* Example: "scale / 300 (12px)" -> "scale-300-12px"
|
|
11
|
+
*/
|
|
12
|
+
export declare function normalizeTokenVariablePart(name: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Generates the full PTB-standard CSS variable name for a token.
|
|
15
|
+
*
|
|
16
|
+
* Example: collection="Colors", token="Brand / 900" -> "--ptb-colors-brand-900"
|
|
17
|
+
*/
|
|
18
|
+
export declare function getPTBTokenVariableName(collectionName: string, tokenName: string): string;
|
|
19
|
+
//# sourceMappingURL=naming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../src/tokens/naming.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI/D;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAIzF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes a Figma token name into a safe, source-faithful CSS Custom Property segment.
|
|
3
|
+
*
|
|
4
|
+
* Rule: SOURCE IS TRUTH.
|
|
5
|
+
* - preserve characters like numbers and hyphens
|
|
6
|
+
* - replace illegal CSS variable characters with hyphens
|
|
7
|
+
* - collapse multiple hyphens
|
|
8
|
+
* - trim leading/trailing hyphens
|
|
9
|
+
*
|
|
10
|
+
* Example: "scale / 300 (12px)" -> "scale-300-12px"
|
|
11
|
+
*/
|
|
12
|
+
export function normalizeTokenVariablePart(name) {
|
|
13
|
+
return name.toLowerCase()
|
|
14
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
15
|
+
.replace(/(^-|-$)/g, "");
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Generates the full PTB-standard CSS variable name for a token.
|
|
19
|
+
*
|
|
20
|
+
* Example: collection="Colors", token="Brand / 900" -> "--ptb-colors-brand-900"
|
|
21
|
+
*/
|
|
22
|
+
export function getPTBTokenVariableName(collectionName, tokenName) {
|
|
23
|
+
const category = normalizeTokenVariablePart(collectionName);
|
|
24
|
+
const token = normalizeTokenVariablePart(tokenName);
|
|
25
|
+
return `--ptb-${category}-${token}`;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=naming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming.js","sourceRoot":"","sources":["../../src/tokens/naming.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,0BAA0B,CAAC,IAAY;IACnD,OAAO,IAAI,CAAC,WAAW,EAAE;SACpB,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AACjC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,cAAsB,EAAE,SAAiB;IAC7E,MAAM,QAAQ,GAAG,0BAA0B,CAAC,cAAc,CAAC,CAAC;IAC5D,MAAM,KAAK,GAAG,0BAA0B,CAAC,SAAS,CAAC,CAAC;IACpD,OAAO,SAAS,QAAQ,IAAI,KAAK,EAAE,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TokenCollection } from "@calibrate-ds/shared-types";
|
|
2
|
+
import type { FigmaVariablesMap } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Normalizes Figma Variable API response data into the generic DesignSystemModel TokenCollections format.
|
|
5
|
+
*/
|
|
6
|
+
export declare function normalizeTokenCollections(variablesMeta: FigmaVariablesMap): TokenCollection[];
|
|
7
|
+
//# sourceMappingURL=normalize-token-collections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-token-collections.d.ts","sourceRoot":"","sources":["../../src/tokens/normalize-token-collections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,4BAA4B,CAAC;AAC/E,OAAO,KAAK,EAAE,iBAAiB,EAAqC,MAAM,YAAY,CAAC;AAGvF;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,aAAa,EAAE,iBAAiB,GAAG,eAAe,EAAE,CA+D7F"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { classifyTokenKind } from "./classify-token-kind.js";
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes Figma Variable API response data into the generic DesignSystemModel TokenCollections format.
|
|
4
|
+
*/
|
|
5
|
+
export function normalizeTokenCollections(variablesMeta) {
|
|
6
|
+
const { variableCollections, variables } = variablesMeta || { variableCollections: {}, variables: {} };
|
|
7
|
+
const collections = [];
|
|
8
|
+
for (const [collectionId, rawCollection] of Object.entries(variableCollections)) {
|
|
9
|
+
if (rawCollection.hiddenFromPublishing) {
|
|
10
|
+
continue; // Skip collections explicitly hidden from consumers
|
|
11
|
+
}
|
|
12
|
+
const defaultModeId = rawCollection.defaultModeId;
|
|
13
|
+
const tokens = [];
|
|
14
|
+
for (const variableId of rawCollection.variableIds) {
|
|
15
|
+
const rawVar = variables[variableId];
|
|
16
|
+
if (!rawVar || rawVar.hiddenFromPublishing) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
// Simple heuristic to get a "safe" codename from the raw figma variable name.
|
|
20
|
+
const safeName = rawVar.name.replace(/\//g, "-").replace(/\s+/g, "-");
|
|
21
|
+
// Extract the value for the primary mode. If a collection has no modes
|
|
22
|
+
// for some reason, we fallback to the first object key value.
|
|
23
|
+
const valueForMode = rawVar.valuesByMode[defaultModeId] ?? Object.values(rawVar.valuesByMode)[0];
|
|
24
|
+
let normalizedValue = "";
|
|
25
|
+
let resolvedType = rawVar.resolvedType;
|
|
26
|
+
if (typeof valueForMode === "object" && valueForMode !== null) {
|
|
27
|
+
if ("type" in valueForMode && valueForMode.type === "VARIABLE_ALIAS") {
|
|
28
|
+
// Try to resolve alias at a basic string level
|
|
29
|
+
const aliasedVar = variables[valueForMode.id];
|
|
30
|
+
normalizedValue = aliasedVar ? `{${aliasedVar.name.replace(/\//g, "-").replace(/\s+/g, "-")}}` : "[Unknown Alias]";
|
|
31
|
+
}
|
|
32
|
+
else if ("r" in valueForMode) {
|
|
33
|
+
// It's a color
|
|
34
|
+
normalizedValue = rgbaToHex(valueForMode);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
// Number, String, Boolean
|
|
39
|
+
normalizedValue = valueForMode;
|
|
40
|
+
}
|
|
41
|
+
tokens.push({
|
|
42
|
+
id: rawVar.id,
|
|
43
|
+
key: rawVar.key,
|
|
44
|
+
name: safeName,
|
|
45
|
+
value: String(normalizedValue), // Store as string for flexibility inside model for now
|
|
46
|
+
type: classifyTokenKind(rawCollection.name), // Base type heavily off the parent classification collection
|
|
47
|
+
description: rawVar.description || undefined,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (tokens.length > 0) {
|
|
51
|
+
collections.push({
|
|
52
|
+
id: collectionId,
|
|
53
|
+
name: rawCollection.name,
|
|
54
|
+
tokens,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return collections;
|
|
59
|
+
}
|
|
60
|
+
// Convert 0-1 RGBA channels to Hex string
|
|
61
|
+
function rgbaToHex(color) {
|
|
62
|
+
const r = Math.round(color.r * 255).toString(16).padStart(2, "0");
|
|
63
|
+
const g = Math.round(color.g * 255).toString(16).padStart(2, "0");
|
|
64
|
+
const b = Math.round(color.b * 255).toString(16).padStart(2, "0");
|
|
65
|
+
const a = Math.round(color.a * 255).toString(16).padStart(2, "0");
|
|
66
|
+
return color.a === 1 ? `#${r}${g}${b}` : `#${r}${g}${b}${a}`;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=normalize-token-collections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-token-collections.js","sourceRoot":"","sources":["../../src/tokens/normalize-token-collections.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TokenCollection, ResolvedBinding } from "@calibrate-ds/shared-types";
|
|
2
|
+
/**
|
|
3
|
+
* Resolves a token binding fully through its alias chain.
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolveTokenBinding(sourceVariableId: string | undefined, collections: TokenCollection[]): ResolvedBinding | undefined;
|
|
6
|
+
export declare function resolveTokenBindingFromIndex(sourceVariableId: string | undefined, tokenIndex: Map<string, any>): ResolvedBinding | undefined;
|
|
7
|
+
//# sourceMappingURL=resolution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolution.d.ts","sourceRoot":"","sources":["../../src/tokens/resolution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAe,eAAe,EAAE,MAAM,4BAA4B,CAAC;AA+BhG;;GAEG;AACH,wBAAgB,mBAAmB,CAC/B,gBAAgB,EAAE,MAAM,GAAG,SAAS,EACpC,WAAW,EAAE,eAAe,EAAE,GAC/B,eAAe,GAAG,SAAS,CAoE7B;AAED,wBAAgB,4BAA4B,CACxC,gBAAgB,EAAE,MAAM,GAAG,SAAS,EACpC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAC7B,eAAe,GAAG,SAAS,CA2D7B"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { getPTBTokenVariableName } from "./naming.js";
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes a variable ID by stripping the prefix.
|
|
4
|
+
*/
|
|
5
|
+
function normalizeTokenId(id) {
|
|
6
|
+
if (!id)
|
|
7
|
+
return "";
|
|
8
|
+
return id.replace(/^VariableID:/i, "");
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Builds a lookup map for tokens from all collections.
|
|
12
|
+
*/
|
|
13
|
+
function buildTokenMap(collections) {
|
|
14
|
+
const map = new Map();
|
|
15
|
+
for (const col of collections) {
|
|
16
|
+
for (const token of col.tokens) {
|
|
17
|
+
const id = normalizeTokenId(token.id);
|
|
18
|
+
if (id)
|
|
19
|
+
map.set(id, { token, collection: col });
|
|
20
|
+
// Also index by persistent key if available (crucial for library resolution)
|
|
21
|
+
if (token.key) {
|
|
22
|
+
const key = normalizeTokenId(token.key);
|
|
23
|
+
if (key)
|
|
24
|
+
map.set(key, { token, collection: col });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return map;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Resolves a token binding fully through its alias chain.
|
|
32
|
+
*/
|
|
33
|
+
export function resolveTokenBinding(sourceVariableId, collections) {
|
|
34
|
+
if (!sourceVariableId)
|
|
35
|
+
return undefined;
|
|
36
|
+
const tokenMap = buildTokenMap(collections);
|
|
37
|
+
const normalizedId = normalizeTokenId(sourceVariableId);
|
|
38
|
+
// Attempt 1: Direct match (ID or Key)
|
|
39
|
+
let current = tokenMap.get(normalizedId);
|
|
40
|
+
// Attempt 2: Compound ID match (Key/SessionID format common in Figma libraries)
|
|
41
|
+
if (!current && normalizedId.includes("/")) {
|
|
42
|
+
const keyPart = normalizedId.split("/")[0];
|
|
43
|
+
current = tokenMap.get(keyPart);
|
|
44
|
+
}
|
|
45
|
+
if (!current)
|
|
46
|
+
return undefined;
|
|
47
|
+
const sourceToken = current.token;
|
|
48
|
+
const sourceCollection = current.collection;
|
|
49
|
+
const resolutionPath = [sourceToken.name];
|
|
50
|
+
let resolved = current;
|
|
51
|
+
// Follow aliasTargetId chain (populated when loaded via adaptCanonicalToTokenCollections)
|
|
52
|
+
let depth = 0;
|
|
53
|
+
while (resolved.token.aliasTargetId && depth < 10) {
|
|
54
|
+
const nextId = normalizeTokenId(resolved.token.aliasTargetId);
|
|
55
|
+
const next = tokenMap.get(nextId);
|
|
56
|
+
if (!next)
|
|
57
|
+
break;
|
|
58
|
+
resolved = next;
|
|
59
|
+
resolutionPath.push(resolved.token.name);
|
|
60
|
+
depth++;
|
|
61
|
+
}
|
|
62
|
+
// Belt-and-suspenders: also follow value-string alias references for tokens loaded
|
|
63
|
+
// from sources that don't populate aliasTargetId (e.g. direct REST normalisation)
|
|
64
|
+
let valueDepth = 0;
|
|
65
|
+
while (valueDepth < 10) {
|
|
66
|
+
const rawVal = resolved.token.value;
|
|
67
|
+
if (typeof rawVal !== "string" || !rawVal.includes("VariableID:"))
|
|
68
|
+
break;
|
|
69
|
+
const nextId = normalizeTokenId(rawVal);
|
|
70
|
+
const next = tokenMap.get(nextId) ?? tokenMap.get(rawVal);
|
|
71
|
+
if (!next)
|
|
72
|
+
break;
|
|
73
|
+
resolved = next;
|
|
74
|
+
resolutionPath.push(resolved.token.name);
|
|
75
|
+
valueDepth++;
|
|
76
|
+
}
|
|
77
|
+
// cssVar = the CSS variable the component is *directly bound to* in Figma (the source token).
|
|
78
|
+
// This is what the component's CSS should reference (e.g. --ptb-mapped-button-btn-primary).
|
|
79
|
+
// canonicalCssVar = the terminal resolved token's variable (for reference/documentation).
|
|
80
|
+
const cssVar = getPTBTokenVariableName(sourceCollection.name, sourceToken.name);
|
|
81
|
+
const canonicalCssVar = getPTBTokenVariableName(resolved.collection.name, resolved.token.name);
|
|
82
|
+
return {
|
|
83
|
+
sourceVariableId,
|
|
84
|
+
sourceTokenName: sourceToken.name,
|
|
85
|
+
sourceCodeName: sourceToken.codeName || sourceToken.name,
|
|
86
|
+
resolvedTokenId: resolved.token.id,
|
|
87
|
+
resolvedTokenName: resolved.token.name,
|
|
88
|
+
resolvedCodeName: resolved.token.codeName || resolved.token.name,
|
|
89
|
+
cssVar,
|
|
90
|
+
canonicalCssVar,
|
|
91
|
+
cssValue: formatCSSValue(resolved.token.value, resolved.token.type),
|
|
92
|
+
valueType: mapValueType(resolved.token.value, resolved.token.type),
|
|
93
|
+
resolutionPath: resolutionPath.length > 0 ? resolutionPath : [sourceToken.name]
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export function resolveTokenBindingFromIndex(sourceVariableId, tokenIndex) {
|
|
97
|
+
if (!sourceVariableId)
|
|
98
|
+
return undefined;
|
|
99
|
+
const normalizedId = normalizeTokenId(sourceVariableId);
|
|
100
|
+
let current = tokenIndex.get(normalizedId);
|
|
101
|
+
if (!current && normalizedId.includes("/")) {
|
|
102
|
+
const keyPart = normalizedId.split("/")[0];
|
|
103
|
+
current = tokenIndex.get(keyPart);
|
|
104
|
+
}
|
|
105
|
+
if (!current)
|
|
106
|
+
return undefined;
|
|
107
|
+
const sourceToken = current.token;
|
|
108
|
+
const sourceCollection = current.collection;
|
|
109
|
+
const resolutionPath = [sourceToken.name];
|
|
110
|
+
let resolved = current;
|
|
111
|
+
let depth = 0;
|
|
112
|
+
while (resolved.token.aliasTargetId && depth < 10) {
|
|
113
|
+
const nextId = normalizeTokenId(resolved.token.aliasTargetId);
|
|
114
|
+
const next = tokenIndex.get(nextId);
|
|
115
|
+
if (!next)
|
|
116
|
+
break;
|
|
117
|
+
resolved = next;
|
|
118
|
+
resolutionPath.push(resolved.token.name);
|
|
119
|
+
depth++;
|
|
120
|
+
}
|
|
121
|
+
let valueDepth = 0;
|
|
122
|
+
while (valueDepth < 10) {
|
|
123
|
+
const rawVal = resolved.token.value;
|
|
124
|
+
if (typeof rawVal !== "string" || !rawVal.includes("VariableID:"))
|
|
125
|
+
break;
|
|
126
|
+
const nextId = normalizeTokenId(rawVal);
|
|
127
|
+
const next = tokenIndex.get(nextId) ?? tokenIndex.get(rawVal);
|
|
128
|
+
if (!next)
|
|
129
|
+
break;
|
|
130
|
+
resolved = next;
|
|
131
|
+
resolutionPath.push(resolved.token.name);
|
|
132
|
+
valueDepth++;
|
|
133
|
+
}
|
|
134
|
+
const cssVar = getPTBTokenVariableName(sourceCollection.name, sourceToken.name);
|
|
135
|
+
const canonicalCssVar = getPTBTokenVariableName(resolved.collection.name, resolved.token.name);
|
|
136
|
+
return {
|
|
137
|
+
sourceVariableId,
|
|
138
|
+
sourceTokenName: sourceToken.name,
|
|
139
|
+
sourceCodeName: sourceToken.codeName || sourceToken.name,
|
|
140
|
+
resolvedTokenId: resolved.token.id,
|
|
141
|
+
resolvedTokenName: resolved.token.name,
|
|
142
|
+
resolvedCodeName: resolved.token.codeName || resolved.token.name,
|
|
143
|
+
cssVar,
|
|
144
|
+
canonicalCssVar,
|
|
145
|
+
cssValue: formatCSSValue(resolved.token.value, resolved.token.type),
|
|
146
|
+
valueType: mapValueType(resolved.token.value, resolved.token.type),
|
|
147
|
+
resolutionPath: resolutionPath.length > 0 ? resolutionPath : [sourceToken.name]
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function getActiveValue(value) {
|
|
151
|
+
if (value === null || value === undefined)
|
|
152
|
+
return value;
|
|
153
|
+
if (typeof value !== "object")
|
|
154
|
+
return value;
|
|
155
|
+
if ('value' in value)
|
|
156
|
+
return getActiveValue(value.value);
|
|
157
|
+
if ('r' in value && 'g' in value && 'b' in value)
|
|
158
|
+
return value;
|
|
159
|
+
const keys = Object.keys(value);
|
|
160
|
+
if (keys.length > 0) {
|
|
161
|
+
for (const key of keys) {
|
|
162
|
+
if (key.toLowerCase().includes("default") || key === "0") {
|
|
163
|
+
return getActiveValue(value[key]);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return getActiveValue(value[keys[0]]);
|
|
167
|
+
}
|
|
168
|
+
return value;
|
|
169
|
+
}
|
|
170
|
+
function extractScalarValue(value) {
|
|
171
|
+
const raw = getActiveValue(value);
|
|
172
|
+
if (typeof raw === "number")
|
|
173
|
+
return raw;
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
function mapValueType(value, type) {
|
|
177
|
+
if (type === "color")
|
|
178
|
+
return "COLOR";
|
|
179
|
+
const scalar = extractScalarValue(value);
|
|
180
|
+
if (scalar !== null) {
|
|
181
|
+
if (type === "spacing" || type === "radius" || type === "typography" || type === "dimension" || type === "other") {
|
|
182
|
+
return "DIMENSION";
|
|
183
|
+
}
|
|
184
|
+
return "NUMBER";
|
|
185
|
+
}
|
|
186
|
+
return "STRING";
|
|
187
|
+
}
|
|
188
|
+
function formatCSSValue(rawValue, type) {
|
|
189
|
+
const value = getActiveValue(rawValue);
|
|
190
|
+
if (type === "color") {
|
|
191
|
+
if (typeof value === "string")
|
|
192
|
+
return value;
|
|
193
|
+
if (typeof value === "object" && value !== null) {
|
|
194
|
+
const r = typeof value.r === 'number' ? Math.round(value.r * 255) : 0;
|
|
195
|
+
const g = typeof value.g === 'number' ? Math.round(value.g * 255) : 0;
|
|
196
|
+
const b = typeof value.b === 'number' ? Math.round(value.b * 255) : 0;
|
|
197
|
+
const a = typeof value.a === 'number' ? value.a : 1;
|
|
198
|
+
if (a < 1) {
|
|
199
|
+
return `rgba(${r}, ${g}, ${b}, ${a})`;
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
const toHex = (c) => {
|
|
203
|
+
const hex = c.toString(16);
|
|
204
|
+
return hex.length === 1 ? "0" + hex : hex;
|
|
205
|
+
};
|
|
206
|
+
return `#${toHex(r)}${toHex(g)}${toHex(b)}`.toUpperCase();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return String(value);
|
|
210
|
+
}
|
|
211
|
+
const scalar = extractScalarValue(rawValue);
|
|
212
|
+
if (scalar !== null) {
|
|
213
|
+
if (type === "spacing" || type === "radius" || type === "typography" || type === "dimension" || type === "other") {
|
|
214
|
+
return `${scalar}px`;
|
|
215
|
+
}
|
|
216
|
+
return String(scalar);
|
|
217
|
+
}
|
|
218
|
+
// Never surface unresolvable Figma variable IDs as CSS fallback values
|
|
219
|
+
if (typeof value === "string" && value.includes("VariableID:"))
|
|
220
|
+
return "";
|
|
221
|
+
return String(value);
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=resolution.js.map
|