figma-inspect-cli 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/README.md +156 -0
- package/dist/bin/figma-inspect.d.ts +3 -0
- package/dist/bin/figma-inspect.d.ts.map +1 -0
- package/dist/bin/figma-inspect.js +19 -0
- package/dist/bin/figma-inspect.js.map +1 -0
- package/dist/cli/errors.d.ts +3 -0
- package/dist/cli/errors.d.ts.map +1 -0
- package/dist/cli/errors.js +3 -0
- package/dist/cli/errors.js.map +1 -0
- package/dist/cli/export-component-set.d.ts +21 -0
- package/dist/cli/export-component-set.d.ts.map +1 -0
- package/dist/cli/export-component-set.js +173 -0
- package/dist/cli/export-component-set.js.map +1 -0
- package/dist/cli/export-contract.d.ts +20 -0
- package/dist/cli/export-contract.d.ts.map +1 -0
- package/dist/cli/export-contract.js +48 -0
- package/dist/cli/export-contract.js.map +1 -0
- package/dist/cli/export-node-contract.d.ts +17 -0
- package/dist/cli/export-node-contract.d.ts.map +1 -0
- package/dist/cli/export-node-contract.js +93 -0
- package/dist/cli/export-node-contract.js.map +1 -0
- package/dist/cli/export-result.d.ts +17 -0
- package/dist/cli/export-result.d.ts.map +1 -0
- package/dist/cli/export-result.js +22 -0
- package/dist/cli/export-result.js.map +1 -0
- package/dist/cli/export-team-index.d.ts +18 -0
- package/dist/cli/export-team-index.d.ts.map +1 -0
- package/dist/cli/export-team-index.js +121 -0
- package/dist/cli/export-team-index.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +3 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/output.d.ts +13 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +26 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/cli/parse-args.d.ts +3 -0
- package/dist/cli/parse-args.d.ts.map +1 -0
- package/dist/cli/parse-args.js +790 -0
- package/dist/cli/parse-args.js.map +1 -0
- package/dist/cli/run-cli.d.ts +3 -0
- package/dist/cli/run-cli.d.ts.map +1 -0
- package/dist/cli/run-cli.js +416 -0
- package/dist/cli/run-cli.js.map +1 -0
- package/dist/cli/types.d.ts +114 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +2 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/cli/usage.d.ts +2 -0
- package/dist/cli/usage.d.ts.map +1 -0
- package/dist/cli/usage.js +75 -0
- package/dist/cli/usage.js.map +1 -0
- package/dist/figma-api/cache/cached-request.d.ts +8 -0
- package/dist/figma-api/cache/cached-request.d.ts.map +1 -0
- package/dist/figma-api/cache/cached-request.js +100 -0
- package/dist/figma-api/cache/cached-request.js.map +1 -0
- package/dist/figma-api/cache/constants.d.ts +5 -0
- package/dist/figma-api/cache/constants.d.ts.map +1 -0
- package/dist/figma-api/cache/constants.js +5 -0
- package/dist/figma-api/cache/constants.js.map +1 -0
- package/dist/figma-api/cache/extract-metadata.d.ts +3 -0
- package/dist/figma-api/cache/extract-metadata.d.ts.map +1 -0
- package/dist/figma-api/cache/extract-metadata.js +13 -0
- package/dist/figma-api/cache/extract-metadata.js.map +1 -0
- package/dist/figma-api/cache/index.d.ts +3 -0
- package/dist/figma-api/cache/index.d.ts.map +1 -0
- package/dist/figma-api/cache/index.js +3 -0
- package/dist/figma-api/cache/index.js.map +1 -0
- package/dist/figma-api/cache/store.d.ts +10 -0
- package/dist/figma-api/cache/store.d.ts.map +1 -0
- package/dist/figma-api/cache/store.js +53 -0
- package/dist/figma-api/cache/store.js.map +1 -0
- package/dist/figma-api/cache/types.d.ts +20 -0
- package/dist/figma-api/cache/types.d.ts.map +1 -0
- package/dist/figma-api/cache/types.js +2 -0
- package/dist/figma-api/cache/types.js.map +1 -0
- package/dist/figma-api/cache/url.d.ts +5 -0
- package/dist/figma-api/cache/url.d.ts.map +1 -0
- package/dist/figma-api/cache/url.js +20 -0
- package/dist/figma-api/cache/url.js.map +1 -0
- package/dist/figma-api/constants.d.ts +2 -0
- package/dist/figma-api/constants.d.ts.map +1 -0
- package/dist/figma-api/constants.js +2 -0
- package/dist/figma-api/constants.js.map +1 -0
- package/dist/figma-api/fetch-with-retry.d.ts +2 -0
- package/dist/figma-api/fetch-with-retry.d.ts.map +1 -0
- package/dist/figma-api/fetch-with-retry.js +48 -0
- package/dist/figma-api/fetch-with-retry.js.map +1 -0
- package/dist/figma-api/figma-api-error.d.ts +4 -0
- package/dist/figma-api/figma-api-error.d.ts.map +1 -0
- package/dist/figma-api/figma-api-error.js +7 -0
- package/dist/figma-api/figma-api-error.js.map +1 -0
- package/dist/figma-api/figma-request.d.ts +2 -0
- package/dist/figma-api/figma-request.d.ts.map +1 -0
- package/dist/figma-api/figma-request.js +21 -0
- package/dist/figma-api/figma-request.js.map +1 -0
- package/dist/figma-api/format-figma-error.d.ts +2 -0
- package/dist/figma-api/format-figma-error.d.ts.map +1 -0
- package/dist/figma-api/format-figma-error.js +24 -0
- package/dist/figma-api/format-figma-error.js.map +1 -0
- package/dist/figma-api/get-component-set.d.ts +4 -0
- package/dist/figma-api/get-component-set.d.ts.map +1 -0
- package/dist/figma-api/get-component-set.js +8 -0
- package/dist/figma-api/get-component-set.js.map +1 -0
- package/dist/figma-api/get-file-images.d.ts +4 -0
- package/dist/figma-api/get-file-images.d.ts.map +1 -0
- package/dist/figma-api/get-file-images.js +45 -0
- package/dist/figma-api/get-file-images.js.map +1 -0
- package/dist/figma-api/get-file-node.d.ts +3 -0
- package/dist/figma-api/get-file-node.d.ts.map +1 -0
- package/dist/figma-api/get-file-node.js +8 -0
- package/dist/figma-api/get-file-node.js.map +1 -0
- package/dist/figma-api/get-file.d.ts +3 -0
- package/dist/figma-api/get-file.d.ts.map +1 -0
- package/dist/figma-api/get-file.js +6 -0
- package/dist/figma-api/get-file.js.map +1 -0
- package/dist/figma-api/index.d.ts +11 -0
- package/dist/figma-api/index.d.ts.map +1 -0
- package/dist/figma-api/index.js +11 -0
- package/dist/figma-api/index.js.map +1 -0
- package/dist/figma-api/list-file-component-sets.d.ts +4 -0
- package/dist/figma-api/list-file-component-sets.d.ts.map +1 -0
- package/dist/figma-api/list-file-component-sets.js +8 -0
- package/dist/figma-api/list-file-component-sets.js.map +1 -0
- package/dist/figma-api/list-file-components.d.ts +5 -0
- package/dist/figma-api/list-file-components.d.ts.map +1 -0
- package/dist/figma-api/list-file-components.js +13 -0
- package/dist/figma-api/list-file-components.js.map +1 -0
- package/dist/figma-api/list-file-pages.d.ts +4 -0
- package/dist/figma-api/list-file-pages.d.ts.map +1 -0
- package/dist/figma-api/list-file-pages.js +10 -0
- package/dist/figma-api/list-file-pages.js.map +1 -0
- package/dist/figma-api/list-project-files.d.ts +4 -0
- package/dist/figma-api/list-project-files.d.ts.map +1 -0
- package/dist/figma-api/list-project-files.js +8 -0
- package/dist/figma-api/list-project-files.js.map +1 -0
- package/dist/figma-api/list-team-component-sets.d.ts +4 -0
- package/dist/figma-api/list-team-component-sets.d.ts.map +1 -0
- package/dist/figma-api/list-team-component-sets.js +19 -0
- package/dist/figma-api/list-team-component-sets.js.map +1 -0
- package/dist/figma-api/list-team-project-files.d.ts +4 -0
- package/dist/figma-api/list-team-project-files.d.ts.map +1 -0
- package/dist/figma-api/list-team-project-files.js +19 -0
- package/dist/figma-api/list-team-project-files.js.map +1 -0
- package/dist/figma-api/list-team-projects.d.ts +4 -0
- package/dist/figma-api/list-team-projects.d.ts.map +1 -0
- package/dist/figma-api/list-team-projects.js +8 -0
- package/dist/figma-api/list-team-projects.js.map +1 -0
- package/dist/figma-api/schemas.d.ts +95 -0
- package/dist/figma-api/schemas.d.ts.map +1 -0
- package/dist/figma-api/schemas.js +154 -0
- package/dist/figma-api/schemas.js.map +1 -0
- package/dist/figma-api/types.d.ts +60 -0
- package/dist/figma-api/types.d.ts.map +1 -0
- package/dist/figma-api/types.js +2 -0
- package/dist/figma-api/types.js.map +1 -0
- package/dist/inspect/component-set-context.d.ts +11 -0
- package/dist/inspect/component-set-context.d.ts.map +1 -0
- package/dist/inspect/component-set-context.js +71 -0
- package/dist/inspect/component-set-context.js.map +1 -0
- package/dist/inspect/component-set-lookup.d.ts +6 -0
- package/dist/inspect/component-set-lookup.d.ts.map +1 -0
- package/dist/inspect/component-set-lookup.js +40 -0
- package/dist/inspect/component-set-lookup.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/asset-backed-contract.d.ts +3 -0
- package/dist/inspect/component-set-pseudocode/asset-backed-contract.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/asset-backed-contract.js +34 -0
- package/dist/inspect/component-set-pseudocode/asset-backed-contract.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/assets-contract.d.ts +9 -0
- package/dist/inspect/component-set-pseudocode/assets-contract.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/assets-contract.js +4 -0
- package/dist/inspect/component-set-pseudocode/assets-contract.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/baseline-contract.d.ts +17 -0
- package/dist/inspect/component-set-pseudocode/baseline-contract.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/baseline-contract.js +67 -0
- package/dist/inspect/component-set-pseudocode/baseline-contract.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/build-pseudocode.d.ts +24 -0
- package/dist/inspect/component-set-pseudocode/build-pseudocode.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/build-pseudocode.js +83 -0
- package/dist/inspect/component-set-pseudocode/build-pseudocode.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/index.d.ts +2 -0
- package/dist/inspect/component-set-pseudocode/index.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/index.js +2 -0
- package/dist/inspect/component-set-pseudocode/index.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/infer.d.ts +4 -0
- package/dist/inspect/component-set-pseudocode/infer.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/infer.js +426 -0
- package/dist/inspect/component-set-pseudocode/infer.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/meta-contract.d.ts +27 -0
- package/dist/inspect/component-set-pseudocode/meta-contract.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/meta-contract.js +136 -0
- package/dist/inspect/component-set-pseudocode/meta-contract.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/slim-node-guards.d.ts +14 -0
- package/dist/inspect/component-set-pseudocode/slim-node-guards.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/slim-node-guards.js +28 -0
- package/dist/inspect/component-set-pseudocode/slim-node-guards.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/structure-contract.d.ts +71 -0
- package/dist/inspect/component-set-pseudocode/structure-contract.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/structure-contract.js +281 -0
- package/dist/inspect/component-set-pseudocode/structure-contract.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/structure-dsl.d.ts +3 -0
- package/dist/inspect/component-set-pseudocode/structure-dsl.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/structure-dsl.js +170 -0
- package/dist/inspect/component-set-pseudocode/structure-dsl.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/types.d.ts +44 -0
- package/dist/inspect/component-set-pseudocode/types.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/types.js +2 -0
- package/dist/inspect/component-set-pseudocode/types.js.map +1 -0
- package/dist/inspect/component-set-pseudocode/universal.d.ts +14 -0
- package/dist/inspect/component-set-pseudocode/universal.d.ts.map +1 -0
- package/dist/inspect/component-set-pseudocode/universal.js +393 -0
- package/dist/inspect/component-set-pseudocode/universal.js.map +1 -0
- package/dist/inspect/component-set-spec/bound-variables.d.ts +14 -0
- package/dist/inspect/component-set-spec/bound-variables.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/bound-variables.js +53 -0
- package/dist/inspect/component-set-spec/bound-variables.js.map +1 -0
- package/dist/inspect/component-set-spec/build-spec.d.ts +9 -0
- package/dist/inspect/component-set-spec/build-spec.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/build-spec.js +102 -0
- package/dist/inspect/component-set-spec/build-spec.js.map +1 -0
- package/dist/inspect/component-set-spec/compact-spec.d.ts +3 -0
- package/dist/inspect/component-set-spec/compact-spec.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/compact-spec.js +357 -0
- package/dist/inspect/component-set-spec/compact-spec.js.map +1 -0
- package/dist/inspect/component-set-spec/extract-slots.d.ts +5 -0
- package/dist/inspect/component-set-spec/extract-slots.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/extract-slots.js +57 -0
- package/dist/inspect/component-set-spec/extract-slots.js.map +1 -0
- package/dist/inspect/component-set-spec/figma-node.d.ts +9 -0
- package/dist/inspect/component-set-spec/figma-node.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/figma-node.js +31 -0
- package/dist/inspect/component-set-spec/figma-node.js.map +1 -0
- package/dist/inspect/component-set-spec/index.d.ts +2 -0
- package/dist/inspect/component-set-spec/index.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/index.js +2 -0
- package/dist/inspect/component-set-spec/index.js.map +1 -0
- package/dist/inspect/component-set-spec/parse-props.d.ts +9 -0
- package/dist/inspect/component-set-spec/parse-props.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/parse-props.js +96 -0
- package/dist/inspect/component-set-spec/parse-props.js.map +1 -0
- package/dist/inspect/component-set-spec/prop-name.d.ts +5 -0
- package/dist/inspect/component-set-spec/prop-name.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/prop-name.js +26 -0
- package/dist/inspect/component-set-spec/prop-name.js.map +1 -0
- package/dist/inspect/component-set-spec/resolve-tokens.d.ts +4 -0
- package/dist/inspect/component-set-spec/resolve-tokens.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/resolve-tokens.js +42 -0
- package/dist/inspect/component-set-spec/resolve-tokens.js.map +1 -0
- package/dist/inspect/component-set-spec/slim-context.d.ts +6 -0
- package/dist/inspect/component-set-spec/slim-context.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/slim-context.js +2 -0
- package/dist/inspect/component-set-spec/slim-context.js.map +1 -0
- package/dist/inspect/component-set-spec/slim-node.d.ts +5 -0
- package/dist/inspect/component-set-spec/slim-node.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/slim-node.js +393 -0
- package/dist/inspect/component-set-spec/slim-node.js.map +1 -0
- package/dist/inspect/component-set-spec/slim-text-export.d.ts +8 -0
- package/dist/inspect/component-set-spec/slim-text-export.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/slim-text-export.js +74 -0
- package/dist/inspect/component-set-spec/slim-text-export.js.map +1 -0
- package/dist/inspect/component-set-spec/team-component-registry.d.ts +19 -0
- package/dist/inspect/component-set-spec/team-component-registry.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/team-component-registry.js +96 -0
- package/dist/inspect/component-set-spec/team-component-registry.js.map +1 -0
- package/dist/inspect/component-set-spec/types.d.ts +127 -0
- package/dist/inspect/component-set-spec/types.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/types.js +2 -0
- package/dist/inspect/component-set-spec/types.js.map +1 -0
- package/dist/inspect/component-set-spec/variable-registry.d.ts +8 -0
- package/dist/inspect/component-set-spec/variable-registry.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/variable-registry.js +74 -0
- package/dist/inspect/component-set-spec/variable-registry.js.map +1 -0
- package/dist/inspect/component-set-spec/variant-axes.d.ts +2 -0
- package/dist/inspect/component-set-spec/variant-axes.d.ts.map +1 -0
- package/dist/inspect/component-set-spec/variant-axes.js +14 -0
- package/dist/inspect/component-set-spec/variant-axes.js.map +1 -0
- package/dist/inspect/contract/contract-format.d.ts +5 -0
- package/dist/inspect/contract/contract-format.d.ts.map +1 -0
- package/dist/inspect/contract/contract-format.js +26 -0
- package/dist/inspect/contract/contract-format.js.map +1 -0
- package/dist/inspect/contract/contract-lock.d.ts +75 -0
- package/dist/inspect/contract/contract-lock.d.ts.map +1 -0
- package/dist/inspect/contract/contract-lock.js +326 -0
- package/dist/inspect/contract/contract-lock.js.map +1 -0
- package/dist/inspect/contract/contract-schema.d.ts +51 -0
- package/dist/inspect/contract/contract-schema.d.ts.map +1 -0
- package/dist/inspect/contract/contract-schema.js +130 -0
- package/dist/inspect/contract/contract-schema.js.map +1 -0
- package/dist/inspect/contract/fingerprint.d.ts +9 -0
- package/dist/inspect/contract/fingerprint.d.ts.map +1 -0
- package/dist/inspect/contract/fingerprint.js +301 -0
- package/dist/inspect/contract/fingerprint.js.map +1 -0
- package/dist/inspect/contract/lock-metadata.d.ts +30 -0
- package/dist/inspect/contract/lock-metadata.d.ts.map +1 -0
- package/dist/inspect/contract/lock-metadata.js +101 -0
- package/dist/inspect/contract/lock-metadata.js.map +1 -0
- package/dist/inspect/contract/stable-stringify.d.ts +2 -0
- package/dist/inspect/contract/stable-stringify.d.ts.map +1 -0
- package/dist/inspect/contract/stable-stringify.js +14 -0
- package/dist/inspect/contract/stable-stringify.js.map +1 -0
- package/dist/inspect/contract/verify-component-contract.d.ts +19 -0
- package/dist/inspect/contract/verify-component-contract.d.ts.map +1 -0
- package/dist/inspect/contract/verify-component-contract.js +126 -0
- package/dist/inspect/contract/verify-component-contract.js.map +1 -0
- package/dist/inspect/errors.d.ts +4 -0
- package/dist/inspect/errors.d.ts.map +1 -0
- package/dist/inspect/errors.js +7 -0
- package/dist/inspect/errors.js.map +1 -0
- package/dist/inspect/export/assert-asset-exportable.d.ts +3 -0
- package/dist/inspect/export/assert-asset-exportable.d.ts.map +1 -0
- package/dist/inspect/export/assert-asset-exportable.js +45 -0
- package/dist/inspect/export/assert-asset-exportable.js.map +1 -0
- package/dist/inspect/export/export-nested-assets.d.ts +94 -0
- package/dist/inspect/export/export-nested-assets.d.ts.map +1 -0
- package/dist/inspect/export/export-nested-assets.js +333 -0
- package/dist/inspect/export/export-nested-assets.js.map +1 -0
- package/dist/inspect/export/export-node-preview.d.ts +24 -0
- package/dist/inspect/export/export-node-preview.d.ts.map +1 -0
- package/dist/inspect/export/export-node-preview.js +34 -0
- package/dist/inspect/export/export-node-preview.js.map +1 -0
- package/dist/inspect/export/export-variant-assets.d.ts +18 -0
- package/dist/inspect/export/export-variant-assets.d.ts.map +1 -0
- package/dist/inspect/export/export-variant-assets.js +127 -0
- package/dist/inspect/export/export-variant-assets.js.map +1 -0
- package/dist/inspect/export/normalize-exported-svg.d.ts +2 -0
- package/dist/inspect/export/normalize-exported-svg.d.ts.map +1 -0
- package/dist/inspect/export/normalize-exported-svg.js +15 -0
- package/dist/inspect/export/normalize-exported-svg.js.map +1 -0
- package/dist/inspect/export/rendered-image-bytes.d.ts +4 -0
- package/dist/inspect/export/rendered-image-bytes.d.ts.map +1 -0
- package/dist/inspect/export/rendered-image-bytes.js +24 -0
- package/dist/inspect/export/rendered-image-bytes.js.map +1 -0
- package/dist/inspect/export-contract-target.d.ts +7 -0
- package/dist/inspect/export-contract-target.d.ts.map +1 -0
- package/dist/inspect/export-contract-target.js +33 -0
- package/dist/inspect/export-contract-target.js.map +1 -0
- package/dist/inspect/fetch-file-entry.d.ts +4 -0
- package/dist/inspect/fetch-file-entry.d.ts.map +1 -0
- package/dist/inspect/fetch-file-entry.js +7 -0
- package/dist/inspect/fetch-file-entry.js.map +1 -0
- package/dist/inspect/fetch-file-node-entry.d.ts +4 -0
- package/dist/inspect/fetch-file-node-entry.d.ts.map +1 -0
- package/dist/inspect/fetch-file-node-entry.js +7 -0
- package/dist/inspect/fetch-file-node-entry.js.map +1 -0
- package/dist/inspect/figma-node-url.d.ts +3 -0
- package/dist/inspect/figma-node-url.d.ts.map +1 -0
- package/dist/inspect/figma-node-url.js +30 -0
- package/dist/inspect/figma-node-url.js.map +1 -0
- package/dist/inspect/get-node-component-set.d.ts +5 -0
- package/dist/inspect/get-node-component-set.d.ts.map +1 -0
- package/dist/inspect/get-node-component-set.js +10 -0
- package/dist/inspect/get-node-component-set.js.map +1 -0
- package/dist/inspect/index.d.ts +17 -0
- package/dist/inspect/index.d.ts.map +1 -0
- package/dist/inspect/index.js +17 -0
- package/dist/inspect/index.js.map +1 -0
- package/dist/inspect/list-all-component-sets.d.ts +3 -0
- package/dist/inspect/list-all-component-sets.d.ts.map +1 -0
- package/dist/inspect/list-all-component-sets.js +27 -0
- package/dist/inspect/list-all-component-sets.js.map +1 -0
- package/dist/inspect/list-component-set-properties.d.ts +4 -0
- package/dist/inspect/list-component-set-properties.d.ts.map +1 -0
- package/dist/inspect/list-component-set-properties.js +73 -0
- package/dist/inspect/list-component-set-properties.js.map +1 -0
- package/dist/inspect/node-contract/build-node-contract.d.ts +12 -0
- package/dist/inspect/node-contract/build-node-contract.d.ts.map +1 -0
- package/dist/inspect/node-contract/build-node-contract.js +212 -0
- package/dist/inspect/node-contract/build-node-contract.js.map +1 -0
- package/dist/inspect/node-contract/dependencies.d.ts +5 -0
- package/dist/inspect/node-contract/dependencies.d.ts.map +1 -0
- package/dist/inspect/node-contract/dependencies.js +84 -0
- package/dist/inspect/node-contract/dependencies.js.map +1 -0
- package/dist/inspect/node-contract/index.d.ts +6 -0
- package/dist/inspect/node-contract/index.d.ts.map +1 -0
- package/dist/inspect/node-contract/index.js +6 -0
- package/dist/inspect/node-contract/index.js.map +1 -0
- package/dist/inspect/node-contract/node-kind.d.ts +9 -0
- package/dist/inspect/node-contract/node-kind.d.ts.map +1 -0
- package/dist/inspect/node-contract/node-kind.js +31 -0
- package/dist/inspect/node-contract/node-kind.js.map +1 -0
- package/dist/inspect/node-contract/node-lock.d.ts +6 -0
- package/dist/inspect/node-contract/node-lock.d.ts.map +1 -0
- package/dist/inspect/node-contract/node-lock.js +181 -0
- package/dist/inspect/node-contract/node-lock.js.map +1 -0
- package/dist/inspect/node-contract/node-schema.d.ts +14 -0
- package/dist/inspect/node-contract/node-schema.d.ts.map +1 -0
- package/dist/inspect/node-contract/node-schema.js +137 -0
- package/dist/inspect/node-contract/node-schema.js.map +1 -0
- package/dist/inspect/node-contract/paths.d.ts +10 -0
- package/dist/inspect/node-contract/paths.d.ts.map +1 -0
- package/dist/inspect/node-contract/paths.js +29 -0
- package/dist/inspect/node-contract/paths.js.map +1 -0
- package/dist/inspect/node-contract/tokens.d.ts +4 -0
- package/dist/inspect/node-contract/tokens.d.ts.map +1 -0
- package/dist/inspect/node-contract/tokens.js +30 -0
- package/dist/inspect/node-contract/tokens.js.map +1 -0
- package/dist/inspect/node-contract/types.d.ts +84 -0
- package/dist/inspect/node-contract/types.d.ts.map +1 -0
- package/dist/inspect/node-contract/types.js +2 -0
- package/dist/inspect/node-contract/types.js.map +1 -0
- package/dist/inspect/node-contract/verify-node-contract.d.ts +20 -0
- package/dist/inspect/node-contract/verify-node-contract.d.ts.map +1 -0
- package/dist/inspect/node-contract/verify-node-contract.js +131 -0
- package/dist/inspect/node-contract/verify-node-contract.js.map +1 -0
- package/dist/inspect/resolve-team-component-set.d.ts +14 -0
- package/dist/inspect/resolve-team-component-set.d.ts.map +1 -0
- package/dist/inspect/resolve-team-component-set.js +77 -0
- package/dist/inspect/resolve-team-component-set.js.map +1 -0
- package/dist/inspect/schemas.d.ts +37 -0
- package/dist/inspect/schemas.d.ts.map +1 -0
- package/dist/inspect/schemas.js +79 -0
- package/dist/inspect/schemas.js.map +1 -0
- package/dist/inspect/team-index.d.ts +76 -0
- package/dist/inspect/team-index.d.ts.map +1 -0
- package/dist/inspect/team-index.js +361 -0
- package/dist/inspect/team-index.js.map +1 -0
- package/dist/inspect/types.d.ts +46 -0
- package/dist/inspect/types.d.ts.map +1 -0
- package/dist/inspect/types.js +2 -0
- package/dist/inspect/types.js.map +1 -0
- package/dist/test/fixtures.d.ts +3 -0
- package/dist/test/fixtures.d.ts.map +1 -0
- package/dist/test/fixtures.js +6 -0
- package/dist/test/fixtures.js.map +1 -0
- package/dist/zod/parse-valid-entries.d.ts +4 -0
- package/dist/zod/parse-valid-entries.d.ts.map +1 -0
- package/dist/zod/parse-valid-entries.js +20 -0
- package/dist/zod/parse-valid-entries.js.map +1 -0
- package/package.json +39 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
const INDENT = " ";
|
|
2
|
+
function isElementNode(node) {
|
|
3
|
+
return "type" in node;
|
|
4
|
+
}
|
|
5
|
+
function isUseNode(node) {
|
|
6
|
+
return "$use" in node;
|
|
7
|
+
}
|
|
8
|
+
function isSlotNode(node) {
|
|
9
|
+
return "$slot" in node;
|
|
10
|
+
}
|
|
11
|
+
function formatWhenProps(props) {
|
|
12
|
+
if (!props || props.length === 0) {
|
|
13
|
+
return "";
|
|
14
|
+
}
|
|
15
|
+
return ` when ${props.join(", ")}`;
|
|
16
|
+
}
|
|
17
|
+
function formatWhenAxes(when) {
|
|
18
|
+
if (!when || Object.keys(when).length === 0) {
|
|
19
|
+
return "";
|
|
20
|
+
}
|
|
21
|
+
const parts = Object.entries(when).map(([axis, value]) => `${axis} = ${JSON.stringify(value)}`);
|
|
22
|
+
return ` when ${parts.join(", ")}`;
|
|
23
|
+
}
|
|
24
|
+
function formatPropDefinition(name, definition) {
|
|
25
|
+
if (definition.type === "variant" && definition.options) {
|
|
26
|
+
const defaultValue = String(definition.default ?? definition.options[0]);
|
|
27
|
+
return `${name} variant = ${JSON.stringify(defaultValue)} // ${definition.options.map((option) => JSON.stringify(option)).join(" | ")}`;
|
|
28
|
+
}
|
|
29
|
+
if (definition.type === "instance") {
|
|
30
|
+
return `${name} instance = ${JSON.stringify(name)}`;
|
|
31
|
+
}
|
|
32
|
+
if (definition.type === "boolean") {
|
|
33
|
+
return `${name} boolean = ${JSON.stringify(definition.default ?? false)}`;
|
|
34
|
+
}
|
|
35
|
+
return `${name} text = ${JSON.stringify(definition.default ?? "")}`;
|
|
36
|
+
}
|
|
37
|
+
function renderBindings(lines, level, styleRef, layoutRef) {
|
|
38
|
+
const indent = INDENT.repeat(level);
|
|
39
|
+
if (styleRef) {
|
|
40
|
+
lines.push(`${indent}style ${styleRef}`);
|
|
41
|
+
}
|
|
42
|
+
if (layoutRef) {
|
|
43
|
+
lines.push(`${indent}layout ${layoutRef}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function renderNode(lines, node, level) {
|
|
47
|
+
const indent = INDENT.repeat(level);
|
|
48
|
+
if (isUseNode(node)) {
|
|
49
|
+
lines.push(`${indent}use ${node.$use}`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (isSlotNode(node)) {
|
|
53
|
+
lines.push(`${indent}slot ${node.$slot}`);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (!isElementNode(node)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const whenProps = node.when?.map((entry) => entry.prop);
|
|
60
|
+
const header = `${node.type} ${node.key}${formatWhenProps(whenProps)}`;
|
|
61
|
+
const blockComment = node.name ? ` // ${node.name}` : "";
|
|
62
|
+
const extras = [];
|
|
63
|
+
if (node.content !== undefined) {
|
|
64
|
+
extras.push(typeof node.content === "string"
|
|
65
|
+
? `content ${JSON.stringify(node.content)}`
|
|
66
|
+
: `content \${${node.content.$prop}}`);
|
|
67
|
+
}
|
|
68
|
+
if (node.instance !== undefined) {
|
|
69
|
+
extras.push(typeof node.instance === "string"
|
|
70
|
+
? `instance ${node.instance}`
|
|
71
|
+
: `instance \${${node.instance.$prop}}`);
|
|
72
|
+
}
|
|
73
|
+
if (node.asset !== undefined) {
|
|
74
|
+
extras.push(`asset ${node.asset.$ref}`);
|
|
75
|
+
}
|
|
76
|
+
const styleRef = node.style?.$ref;
|
|
77
|
+
const layoutRef = node.layout?.$ref;
|
|
78
|
+
const children = node.children ?? [];
|
|
79
|
+
const hasBlock = Boolean(styleRef || layoutRef) || extras.length > 0 || children.length > 0;
|
|
80
|
+
if (!hasBlock) {
|
|
81
|
+
lines.push(`${indent}${header}`);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
lines.push(`${indent}${header} {${blockComment}`);
|
|
85
|
+
const bodyLevel = level + 1;
|
|
86
|
+
renderBindings(lines, bodyLevel, styleRef, layoutRef);
|
|
87
|
+
for (const extra of extras) {
|
|
88
|
+
lines.push(`${INDENT.repeat(bodyLevel)}${extra}`);
|
|
89
|
+
}
|
|
90
|
+
for (const child of children) {
|
|
91
|
+
renderNode(lines, child, bodyLevel);
|
|
92
|
+
}
|
|
93
|
+
lines.push(`${indent}}`);
|
|
94
|
+
}
|
|
95
|
+
function renderResolve(contract) {
|
|
96
|
+
const axes = Object.keys(contract.variantAxes);
|
|
97
|
+
if (axes.length === 0) {
|
|
98
|
+
const lines = [
|
|
99
|
+
"resolve {",
|
|
100
|
+
`${INDENT}scheme = visuals`,
|
|
101
|
+
`${INDENT}geometry = geometry`,
|
|
102
|
+
];
|
|
103
|
+
if (contract.assetBacked) {
|
|
104
|
+
lines.push(`${INDENT}asset = meta.assets`);
|
|
105
|
+
}
|
|
106
|
+
lines.push("}");
|
|
107
|
+
return lines;
|
|
108
|
+
}
|
|
109
|
+
const path = axes.join("][");
|
|
110
|
+
const lines = [
|
|
111
|
+
"resolve {",
|
|
112
|
+
`${INDENT}scheme = visuals[${path}]`,
|
|
113
|
+
`${INDENT}geometry = geometry[${path}]`,
|
|
114
|
+
];
|
|
115
|
+
if (contract.assetBacked) {
|
|
116
|
+
lines.push(`${INDENT}asset = meta.assets[${path}]`);
|
|
117
|
+
}
|
|
118
|
+
lines.push("}");
|
|
119
|
+
return lines;
|
|
120
|
+
}
|
|
121
|
+
export function renderStructureDsl(contract) {
|
|
122
|
+
const lines = [`component ${contract.component}`, ""];
|
|
123
|
+
if (Object.keys(contract.props ?? {}).length > 0) {
|
|
124
|
+
lines.push("props {");
|
|
125
|
+
for (const [name, definition] of Object.entries(contract.props ?? {})) {
|
|
126
|
+
lines.push(`${INDENT}${formatPropDefinition(name, definition)}`);
|
|
127
|
+
}
|
|
128
|
+
lines.push("}", "");
|
|
129
|
+
}
|
|
130
|
+
lines.push("contracts {", `${INDENT}visuals ${contract.contracts.visuals}`, `${INDENT}geometry ${contract.contracts.geometry}`, `${INDENT}meta ${contract.contracts.meta}`, "}", "");
|
|
131
|
+
if (Object.keys(contract.variantAxes).length > 0) {
|
|
132
|
+
lines.push("variantAxes {");
|
|
133
|
+
for (const [axis, values] of Object.entries(contract.variantAxes)) {
|
|
134
|
+
lines.push(`${INDENT}${axis}: ${values.join(" | ")}`);
|
|
135
|
+
}
|
|
136
|
+
lines.push("}", "");
|
|
137
|
+
}
|
|
138
|
+
lines.push(...renderResolve(contract), "");
|
|
139
|
+
if (contract.dispatch.length > 0 || contract.fallback) {
|
|
140
|
+
lines.push("dispatch {");
|
|
141
|
+
for (const entry of contract.dispatch) {
|
|
142
|
+
const whenLabel = formatWhenAxes(entry.when).replace(/^ when /, "");
|
|
143
|
+
lines.push(`${INDENT}${whenLabel} => ${entry.template}`);
|
|
144
|
+
}
|
|
145
|
+
if (contract.fallback) {
|
|
146
|
+
lines.push(`${INDENT}fallback => ${contract.fallback}`);
|
|
147
|
+
}
|
|
148
|
+
lines.push("}", "");
|
|
149
|
+
}
|
|
150
|
+
const templateNames = Object.keys(contract.templates).sort();
|
|
151
|
+
if (templateNames.length > 0) {
|
|
152
|
+
lines.push("templates {");
|
|
153
|
+
for (let index = 0; index < templateNames.length; index += 1) {
|
|
154
|
+
const name = templateNames[index];
|
|
155
|
+
const template = contract.templates[name];
|
|
156
|
+
lines.push(`${INDENT}template ${name}${formatWhenAxes(template.when)} {`);
|
|
157
|
+
renderNode(lines, template.root, 2);
|
|
158
|
+
lines.push(`${INDENT}}`);
|
|
159
|
+
if (index < templateNames.length - 1) {
|
|
160
|
+
lines.push("");
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
lines.push("}");
|
|
164
|
+
}
|
|
165
|
+
return `${lines
|
|
166
|
+
.join("\n")
|
|
167
|
+
.replace(/\n{3,}/g, "\n\n")
|
|
168
|
+
.trimEnd()}\n`;
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=structure-dsl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structure-dsl.js","sourceRoot":"","sources":["../../../src/inspect/component-set-pseudocode/structure-dsl.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CAAC;IAED,OAAO,GAAG,KAAK;SACZ,IAAI,CAAC,IAAI,CAAC;SACV,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC;SAC1B,OAAO,EAAE,IAAI,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ComponentSetPropDefinition, SlimNode } from "../component-set-spec/types.js";
|
|
2
|
+
export interface PseudocodeModel {
|
|
3
|
+
name: string;
|
|
4
|
+
props: Record<string, ComponentSetPropDefinition>;
|
|
5
|
+
baseVariant: Record<string, string>;
|
|
6
|
+
variantAxes: Record<string, string[]>;
|
|
7
|
+
definitions: Record<string, SlimNode>;
|
|
8
|
+
definitionTemplates: PseudocodeDefinitionTemplate[];
|
|
9
|
+
templates: PseudocodeTemplate[];
|
|
10
|
+
variantGroups: PseudocodeVariantGroup[];
|
|
11
|
+
stats: PseudocodeStats;
|
|
12
|
+
}
|
|
13
|
+
interface PseudocodeStats {
|
|
14
|
+
variants: number;
|
|
15
|
+
definitions: number;
|
|
16
|
+
definitionTemplates: number;
|
|
17
|
+
templates: number;
|
|
18
|
+
variantGroups: number;
|
|
19
|
+
}
|
|
20
|
+
export interface PseudocodeDefinitionTemplate {
|
|
21
|
+
name: string;
|
|
22
|
+
variables: string[];
|
|
23
|
+
node: unknown;
|
|
24
|
+
rows: PseudocodeTable;
|
|
25
|
+
}
|
|
26
|
+
export interface PseudocodeTemplate {
|
|
27
|
+
name: string;
|
|
28
|
+
when?: Record<string, string>;
|
|
29
|
+
variables: string[];
|
|
30
|
+
layout: unknown;
|
|
31
|
+
}
|
|
32
|
+
export interface PseudocodeVariantGroup {
|
|
33
|
+
template: string;
|
|
34
|
+
when?: Record<string, string>;
|
|
35
|
+
axes: string[];
|
|
36
|
+
values: string[];
|
|
37
|
+
rows: unknown[][];
|
|
38
|
+
}
|
|
39
|
+
interface PseudocodeTable {
|
|
40
|
+
columns: string[];
|
|
41
|
+
rows: unknown[][];
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/inspect/component-set-pseudocode/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,QAAQ,EACT,MAAM,gCAAgC,CAAC;AAExC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;IAClD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACtC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACtC,mBAAmB,EAAE,4BAA4B,EAAE,CAAC;IACpD,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAChC,aAAa,EAAE,sBAAsB,EAAE,CAAC;IACxC,KAAK,EAAE,eAAe,CAAC;CACxB;AAED,UAAU,eAAe;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,eAAe,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC;CACnB;AAED,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/inspect/component-set-pseudocode/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SlimNode } from "../component-set-spec/types.js";
|
|
2
|
+
import type { PseudocodeModel } from "./types.js";
|
|
3
|
+
export type NodeBundle = Record<string, Record<string, unknown>>;
|
|
4
|
+
export declare function extractVisualsFromNode(node: SlimNode): Record<string, unknown>;
|
|
5
|
+
export declare function extractGeometryFromNode(node: SlimNode): Record<string, unknown>;
|
|
6
|
+
export declare function mergeNodeBundle(target: NodeBundle, nodeName: string, visuals: Record<string, unknown>, geometry: Record<string, unknown>): void;
|
|
7
|
+
export declare function orderedAxes(model: PseudocodeModel): string[];
|
|
8
|
+
export declare function mergeNestedContracts(baseline: Record<string, unknown>, overrides: Record<string, unknown>, depth: number, axesDepth: number): Record<string, unknown>;
|
|
9
|
+
export declare function setNestedBundle(root: Record<string, unknown>, axes: string[], when: Record<string, string>, leaf: NodeBundle): void;
|
|
10
|
+
export declare function buildUniversalContracts(model: PseudocodeModel): {
|
|
11
|
+
visuals: Record<string, unknown>;
|
|
12
|
+
geometry: Record<string, unknown>;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=universal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"universal.d.ts","sourceRoot":"","sources":["../../../src/inspect/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M,EAAE,OAAO,CAAC,CAAC;IACjC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAqBA"}
|
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import { normalizePropName } from "../component-set-spec/prop-name.js";
|
|
2
|
+
import { extractBoundToken, extractTextVisuals, } from "../component-set-spec/slim-text-export.js";
|
|
3
|
+
import { isNode, isRecord, isRef } from "./slim-node-guards.js";
|
|
4
|
+
function extractToken(value) {
|
|
5
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
if (!isRecord(value)) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
if (typeof value.token === "string") {
|
|
12
|
+
return value.token;
|
|
13
|
+
}
|
|
14
|
+
if (typeof value.value === "number") {
|
|
15
|
+
return value.value;
|
|
16
|
+
}
|
|
17
|
+
if (isRecord(value.background) &&
|
|
18
|
+
typeof value.background.token === "string") {
|
|
19
|
+
return value.background.token;
|
|
20
|
+
}
|
|
21
|
+
if (typeof value.backgroundToken === "string") {
|
|
22
|
+
return value.backgroundToken;
|
|
23
|
+
}
|
|
24
|
+
if (typeof value.color === "string") {
|
|
25
|
+
return value.color;
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
function buildFragmentRowIndex(model) {
|
|
30
|
+
const index = new Map();
|
|
31
|
+
for (const template of model.definitionTemplates) {
|
|
32
|
+
for (const row of template.rows.rows) {
|
|
33
|
+
const [id] = row;
|
|
34
|
+
if (typeof id !== "string") {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
index.set(id, Object.fromEntries(template.rows.columns.map((column, columnIndex) => [
|
|
38
|
+
column,
|
|
39
|
+
row[columnIndex],
|
|
40
|
+
])));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return index;
|
|
44
|
+
}
|
|
45
|
+
function stylePropFromRowKey(key) {
|
|
46
|
+
if (key === "id") {
|
|
47
|
+
return key;
|
|
48
|
+
}
|
|
49
|
+
return key
|
|
50
|
+
.replace(/Token$/i, "")
|
|
51
|
+
.replace(/^(fieldName|button|shadow|icon)/i, "")
|
|
52
|
+
.replace(/^[A-Z]/, (char) => char.toLowerCase());
|
|
53
|
+
}
|
|
54
|
+
function isGeometryProp(key) {
|
|
55
|
+
return (/^padding/i.test(key) ||
|
|
56
|
+
key === "gap" ||
|
|
57
|
+
key === "grow" ||
|
|
58
|
+
key === "width" ||
|
|
59
|
+
key === "height" ||
|
|
60
|
+
key === "alignMain" ||
|
|
61
|
+
key === "alignCross" ||
|
|
62
|
+
key === "alignSelf" ||
|
|
63
|
+
key === "clip" ||
|
|
64
|
+
key === "wrap" ||
|
|
65
|
+
key === "minWidth" ||
|
|
66
|
+
key === "maxWidth" ||
|
|
67
|
+
key === "minHeight" ||
|
|
68
|
+
key === "maxHeight");
|
|
69
|
+
}
|
|
70
|
+
function partitionProps(props) {
|
|
71
|
+
const visuals = {};
|
|
72
|
+
const geometry = {};
|
|
73
|
+
for (const [key, value] of Object.entries(props)) {
|
|
74
|
+
if (isGeometryProp(key)) {
|
|
75
|
+
geometry[key] = value;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
visuals[key] = value;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return { visuals, geometry };
|
|
82
|
+
}
|
|
83
|
+
function rowToStyleProps(row) {
|
|
84
|
+
const props = {};
|
|
85
|
+
for (const [key, value] of Object.entries(row)) {
|
|
86
|
+
if (key === "id") {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const bound = extractBoundToken(value);
|
|
90
|
+
if (bound !== undefined) {
|
|
91
|
+
const prop = stylePropFromRowKey(key);
|
|
92
|
+
if (prop.length > 0) {
|
|
93
|
+
props[prop] = bound;
|
|
94
|
+
}
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const token = extractToken(value);
|
|
98
|
+
if (typeof token === "string") {
|
|
99
|
+
const prop = stylePropFromRowKey(key);
|
|
100
|
+
if (prop.length > 0) {
|
|
101
|
+
props[prop] = token;
|
|
102
|
+
}
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (typeof value === "string") {
|
|
106
|
+
props[stylePropFromRowKey(key)] = value;
|
|
107
|
+
}
|
|
108
|
+
if (isRecord(value) && !Array.isArray(value)) {
|
|
109
|
+
const prop = stylePropFromRowKey(key);
|
|
110
|
+
if (prop.length > 0) {
|
|
111
|
+
props[prop] = value;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return props;
|
|
116
|
+
}
|
|
117
|
+
export function extractVisualsFromNode(node) {
|
|
118
|
+
const props = {};
|
|
119
|
+
const style = isRecord(node.style) ? node.style : undefined;
|
|
120
|
+
const text = isRecord(node.text) ? node.text : undefined;
|
|
121
|
+
const icon = isRecord(node.icon) ? node.icon : undefined;
|
|
122
|
+
if (style) {
|
|
123
|
+
const background = extractToken(style.background);
|
|
124
|
+
if (background !== undefined) {
|
|
125
|
+
props.background = background;
|
|
126
|
+
}
|
|
127
|
+
const border = extractToken(style.border);
|
|
128
|
+
if (border !== undefined) {
|
|
129
|
+
props.border = border;
|
|
130
|
+
}
|
|
131
|
+
if (style.border &&
|
|
132
|
+
isRecord(style.border) &&
|
|
133
|
+
style.border.width !== undefined) {
|
|
134
|
+
props.borderWidth = style.border.width;
|
|
135
|
+
}
|
|
136
|
+
const radius = extractToken(style.radius);
|
|
137
|
+
if (radius !== undefined) {
|
|
138
|
+
props.radius = radius;
|
|
139
|
+
}
|
|
140
|
+
if (style.opacity !== undefined && style.opacity !== 1) {
|
|
141
|
+
props.opacity = style.opacity;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (text) {
|
|
145
|
+
Object.assign(props, extractTextVisuals(text, (value) => extractToken(value)));
|
|
146
|
+
}
|
|
147
|
+
if (icon) {
|
|
148
|
+
if (icon.size !== undefined) {
|
|
149
|
+
props.iconSize = icon.size;
|
|
150
|
+
}
|
|
151
|
+
const iconColor = extractToken(icon.color);
|
|
152
|
+
if (iconColor !== undefined) {
|
|
153
|
+
props.iconColor = iconColor;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return props;
|
|
157
|
+
}
|
|
158
|
+
export function extractGeometryFromNode(node) {
|
|
159
|
+
const props = {};
|
|
160
|
+
const layout = isRecord(node.layout) ? node.layout : undefined;
|
|
161
|
+
if (!layout) {
|
|
162
|
+
return props;
|
|
163
|
+
}
|
|
164
|
+
if (layout.mode === "row" || layout.mode === "column") {
|
|
165
|
+
props.layoutMode = layout.mode;
|
|
166
|
+
}
|
|
167
|
+
const height = extractToken(layout.height);
|
|
168
|
+
if (height !== undefined) {
|
|
169
|
+
props.height = height;
|
|
170
|
+
}
|
|
171
|
+
const width = extractToken(layout.width);
|
|
172
|
+
if (width !== undefined) {
|
|
173
|
+
props.width = width;
|
|
174
|
+
}
|
|
175
|
+
const gap = extractToken(layout.gap);
|
|
176
|
+
if (gap !== undefined) {
|
|
177
|
+
props.gap = gap;
|
|
178
|
+
}
|
|
179
|
+
if (isRecord(layout.padding)) {
|
|
180
|
+
for (const side of ["top", "right", "bottom", "left"]) {
|
|
181
|
+
const token = extractToken(layout.padding[side]);
|
|
182
|
+
if (token !== undefined) {
|
|
183
|
+
props[`padding${side.charAt(0).toUpperCase()}${side.slice(1)}`] = token;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (isRecord(layout.align)) {
|
|
188
|
+
if (layout.align.main) {
|
|
189
|
+
props.alignMain = layout.align.main;
|
|
190
|
+
}
|
|
191
|
+
if (layout.align.cross) {
|
|
192
|
+
props.alignCross = layout.align.cross;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (isRecord(layout.sizing)) {
|
|
196
|
+
if (layout.sizing.horizontal) {
|
|
197
|
+
props.sizingHorizontal = layout.sizing.horizontal;
|
|
198
|
+
}
|
|
199
|
+
if (layout.sizing.vertical) {
|
|
200
|
+
props.sizingVertical = layout.sizing.vertical;
|
|
201
|
+
}
|
|
202
|
+
if (layout.sizing.main) {
|
|
203
|
+
props.sizingMain = layout.sizing.main;
|
|
204
|
+
}
|
|
205
|
+
if (layout.sizing.cross) {
|
|
206
|
+
props.sizingCross = layout.sizing.cross;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
for (const key of [
|
|
210
|
+
"minWidth",
|
|
211
|
+
"maxWidth",
|
|
212
|
+
"minHeight",
|
|
213
|
+
"maxHeight",
|
|
214
|
+
]) {
|
|
215
|
+
const token = extractToken(layout[key]);
|
|
216
|
+
if (token !== undefined) {
|
|
217
|
+
props[key] = token;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (layout.grow !== undefined && layout.grow !== 0) {
|
|
221
|
+
props.grow = layout.grow;
|
|
222
|
+
}
|
|
223
|
+
if (layout.alignSelf !== undefined && layout.alignSelf !== "INHERIT") {
|
|
224
|
+
props.alignSelf = layout.alignSelf;
|
|
225
|
+
}
|
|
226
|
+
if (layout.wrap === true) {
|
|
227
|
+
props.wrap = true;
|
|
228
|
+
}
|
|
229
|
+
if (layout.clip === true) {
|
|
230
|
+
props.clip = true;
|
|
231
|
+
}
|
|
232
|
+
return props;
|
|
233
|
+
}
|
|
234
|
+
function nodeNameFromValueKey(key) {
|
|
235
|
+
const tokenMatch = key.match(/^([a-z][a-zA-Z0-9]*?)(Background|Border|Color|Align|Icon|Gap|Opacity|Padding|Height|Width)/);
|
|
236
|
+
if (tokenMatch?.[1]) {
|
|
237
|
+
return tokenMatch[1];
|
|
238
|
+
}
|
|
239
|
+
return key;
|
|
240
|
+
}
|
|
241
|
+
export function mergeNodeBundle(target, nodeName, visuals, geometry) {
|
|
242
|
+
if (Object.keys(visuals).length > 0) {
|
|
243
|
+
target[nodeName] ??= {};
|
|
244
|
+
Object.assign(target[nodeName], visuals);
|
|
245
|
+
}
|
|
246
|
+
if (Object.keys(geometry).length > 0) {
|
|
247
|
+
target[nodeName] ??= {};
|
|
248
|
+
Object.assign(target[nodeName], geometry);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
function absorbValue(visualBundle, geometryBundle, key, value, fragmentRows) {
|
|
252
|
+
if (key === "name" || key === "value") {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
if (isRef(value)) {
|
|
256
|
+
const row = fragmentRows.get(value.$ref);
|
|
257
|
+
if (row) {
|
|
258
|
+
const nodeName = value.$ref.replace(/\d+$/, "");
|
|
259
|
+
const { visuals, geometry } = partitionProps(rowToStyleProps(row));
|
|
260
|
+
mergeNodeBundle(visualBundle, nodeName, visuals, {});
|
|
261
|
+
mergeNodeBundle(geometryBundle, nodeName, {}, geometry);
|
|
262
|
+
}
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (isNode(value)) {
|
|
266
|
+
const nodeName = typeof value.name === "string"
|
|
267
|
+
? normalizePropName(value.name)
|
|
268
|
+
: nodeNameFromValueKey(key);
|
|
269
|
+
mergeNodeBundle(visualBundle, nodeName, extractVisualsFromNode(value), {});
|
|
270
|
+
mergeNodeBundle(geometryBundle, nodeName, {}, extractGeometryFromNode(value));
|
|
271
|
+
const children = Array.isArray(value.children) ? value.children : [];
|
|
272
|
+
for (const child of children) {
|
|
273
|
+
if (isRecord(child)) {
|
|
274
|
+
absorbValue(visualBundle, geometryBundle, normalizePropName(String(child.name ?? "child")), child, fragmentRows);
|
|
275
|
+
}
|
|
276
|
+
if (isRef(child)) {
|
|
277
|
+
absorbValue(visualBundle, geometryBundle, child.$ref, child, fragmentRows);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const bound = extractBoundToken(value);
|
|
283
|
+
if (bound !== undefined) {
|
|
284
|
+
const nodeName = nodeNameFromValueKey(key);
|
|
285
|
+
const prop = stylePropFromRowKey(key);
|
|
286
|
+
mergeNodeBundle(visualBundle, nodeName, { [prop]: bound }, {});
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const token = extractToken(value);
|
|
290
|
+
if (token !== undefined) {
|
|
291
|
+
const nodeName = nodeNameFromValueKey(key);
|
|
292
|
+
const prop = stylePropFromRowKey(key);
|
|
293
|
+
if (isGeometryProp(prop)) {
|
|
294
|
+
mergeNodeBundle(geometryBundle, nodeName, {}, { [prop]: token });
|
|
295
|
+
}
|
|
296
|
+
else if (typeof token === "string") {
|
|
297
|
+
mergeNodeBundle(visualBundle, nodeName, { [prop]: token }, {});
|
|
298
|
+
}
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
if (isRecord(value)) {
|
|
302
|
+
const { visuals, geometry } = partitionProps(rowToStyleProps(value));
|
|
303
|
+
mergeNodeBundle(visualBundle, key, visuals, {});
|
|
304
|
+
mergeNodeBundle(geometryBundle, key, {}, geometry);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
function collectVariantEntries(model) {
|
|
308
|
+
const entries = [];
|
|
309
|
+
for (const group of model.variantGroups) {
|
|
310
|
+
const valueOffset = group.axes.length;
|
|
311
|
+
for (const row of group.rows) {
|
|
312
|
+
const when = {
|
|
313
|
+
...(group.when ?? {}),
|
|
314
|
+
...Object.fromEntries(group.axes.map((axis, index) => [axis, String(row[index])])),
|
|
315
|
+
};
|
|
316
|
+
const values = Object.fromEntries(group.values.map((key, index) => [key, row[valueOffset + index]]));
|
|
317
|
+
entries.push({ when, values });
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return entries;
|
|
321
|
+
}
|
|
322
|
+
export function orderedAxes(model) {
|
|
323
|
+
return Object.keys(model.variantAxes);
|
|
324
|
+
}
|
|
325
|
+
export function mergeNestedContracts(baseline, overrides, depth, axesDepth) {
|
|
326
|
+
if (depth >= axesDepth) {
|
|
327
|
+
const result = {
|
|
328
|
+
...baseline,
|
|
329
|
+
};
|
|
330
|
+
for (const [nodeName, props] of Object.entries(overrides)) {
|
|
331
|
+
result[nodeName] = {
|
|
332
|
+
...(isRecord(result[nodeName]) ? result[nodeName] : {}),
|
|
333
|
+
...(isRecord(props) ? props : {}),
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
return result;
|
|
337
|
+
}
|
|
338
|
+
const result = { ...baseline };
|
|
339
|
+
for (const [key, value] of Object.entries(overrides)) {
|
|
340
|
+
if (!isRecord(value)) {
|
|
341
|
+
result[key] = value;
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
result[key] = mergeNestedContracts(isRecord(result[key]) ? result[key] : {}, value, depth + 1, axesDepth);
|
|
345
|
+
}
|
|
346
|
+
return result;
|
|
347
|
+
}
|
|
348
|
+
export function setNestedBundle(root, axes, when, leaf) {
|
|
349
|
+
if (axes.length === 0) {
|
|
350
|
+
Object.assign(root, leaf);
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
const [head, ...tail] = axes;
|
|
354
|
+
const raw = when[head];
|
|
355
|
+
if (raw === undefined) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
const key = raw;
|
|
359
|
+
if (tail.length === 0) {
|
|
360
|
+
const current = isRecord(root[key]) ? root[key] : {};
|
|
361
|
+
for (const [nodeName, nodeProps] of Object.entries(leaf)) {
|
|
362
|
+
current[nodeName] = {
|
|
363
|
+
...(isRecord(current[nodeName]) ? current[nodeName] : {}),
|
|
364
|
+
...nodeProps,
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
root[key] = current;
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
root[key] ??= {};
|
|
371
|
+
setNestedBundle(root[key], tail, when, leaf);
|
|
372
|
+
}
|
|
373
|
+
export function buildUniversalContracts(model) {
|
|
374
|
+
const axes = orderedAxes(model);
|
|
375
|
+
const fragmentRows = buildFragmentRowIndex(model);
|
|
376
|
+
const visualsRoot = {};
|
|
377
|
+
const geometryRoot = {};
|
|
378
|
+
for (const entry of collectVariantEntries(model)) {
|
|
379
|
+
const visualBundle = {};
|
|
380
|
+
const geometryBundle = {};
|
|
381
|
+
for (const [key, value] of Object.entries(entry.values)) {
|
|
382
|
+
absorbValue(visualBundle, geometryBundle, key, value, fragmentRows);
|
|
383
|
+
}
|
|
384
|
+
if (Object.keys(visualBundle).length > 0) {
|
|
385
|
+
setNestedBundle(visualsRoot, axes, entry.when, visualBundle);
|
|
386
|
+
}
|
|
387
|
+
if (Object.keys(geometryBundle).length > 0) {
|
|
388
|
+
setNestedBundle(geometryRoot, axes, entry.when, geometryBundle);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return { visuals: visualsRoot, geometry: geometryRoot };
|
|
392
|
+
}
|
|
393
|
+
//# sourceMappingURL=universal.js.map
|