@fluentic/style 0.1.0-beta.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/CHANGELOG.md +32 -0
- package/LICENSE +21 -0
- package/README.md +409 -0
- package/atomic/atRule/counterStyle.ts +35 -0
- package/atomic/atRule/fontFace.ts +37 -0
- package/atomic/atRule/fontPaletteValues.ts +36 -0
- package/atomic/atRule/fontSrc.ts +13 -0
- package/atomic/atRule/keyframes.ts +43 -0
- package/atomic/atRule/positionTry.ts +73 -0
- package/atomic/atRule/property.ts +39 -0
- package/atomic/atRule/utils.ts +81 -0
- package/atomic/className.ts +93 -0
- package/atomic/debug/className/className.ts +33 -0
- package/atomic/debug/className/index.ts +1 -0
- package/atomic/debug/property/data.ts +59 -0
- package/atomic/debug/property/index.ts +1 -0
- package/atomic/debug/property/property.ts +59 -0
- package/atomic/debug/selector.ts +88 -0
- package/atomic/debug/value.ts +53 -0
- package/atomic/element.ts +29 -0
- package/atomic/layer/README.md +116 -0
- package/atomic/layer/index.ts +3 -0
- package/atomic/layer/layer.ts +95 -0
- package/atomic/layer/types.ts +37 -0
- package/atomic/layer/utils.ts +51 -0
- package/atomic/property/index.ts +2 -0
- package/atomic/property/presets.ts +34 -0
- package/atomic/property/property.ts +13 -0
- package/atomic/property/type_maps.ts +389 -0
- package/atomic/property/types.ts +7 -0
- package/atomic/rule.ts +116 -0
- package/atomic/theme.ts +48 -0
- package/atomic/token.ts +53 -0
- package/atomic/utils/css.ts +49 -0
- package/atomic/utils/debug.ts +37 -0
- package/atomic/utils/format.ts +192 -0
- package/atomic/utils/selector.ts +14 -0
- package/atomic/utils/types.ts +11 -0
- package/atomic/value/index.ts +2 -0
- package/atomic/value/unitless.ts +47 -0
- package/atomic/value/value.ts +17 -0
- package/atomic/var.ts +19 -0
- package/builder/data/check_selector.noop.ts +8 -0
- package/builder/data/check_selector.ts +30 -0
- package/builder/data/const.ts +25 -0
- package/builder/data/create.ts +96 -0
- package/builder/data/data.ts +63 -0
- package/builder/data/debug.ts +113 -0
- package/builder/data/index.ts +9 -0
- package/builder/data/is.ts +68 -0
- package/builder/data/merge/index.ts +2 -0
- package/builder/data/merge/scope.ts +300 -0
- package/builder/data/merge/style.ts +284 -0
- package/builder/data/merge/utils.ts +35 -0
- package/builder/data/selector.ts +11 -0
- package/builder/data/state.ts +134 -0
- package/builder/extract/index.ts +6 -0
- package/builder/extract/scope.ts +30 -0
- package/builder/extract/slot.ts +36 -0
- package/builder/extract/style.ts +89 -0
- package/builder/extract/theme.ts +16 -0
- package/builder/extract/token.ts +41 -0
- package/builder/extract/utils.ts +95 -0
- package/builder/extract/withTokens.ts +64 -0
- package/builder/index.ts +2 -0
- package/builder/style_builder.ts +234 -0
- package/builder/style_data.ts +81 -0
- package/builder/style_fns.ts +611 -0
- package/builder/types/alias.ts +83 -0
- package/builder/types/fns.ts +185 -0
- package/builder/types/index.ts +1 -0
- package/builder/types/types.ts +51 -0
- package/builder/utils.ts +19 -0
- package/compiler/compiler/cache.ts +155 -0
- package/compiler/compiler/compiler.ts +173 -0
- package/compiler/compiler/index.ts +3 -0
- package/compiler/compiler/types.ts +62 -0
- package/compiler/extract/collector.ts +25 -0
- package/compiler/extract/extract.ts +51 -0
- package/compiler/extract/index.ts +3 -0
- package/compiler/extract/types.ts +35 -0
- package/compiler/index.ts +2 -0
- package/compiler/transform/debug/index.ts +2 -0
- package/compiler/transform/debug/plugin.ts +1347 -0
- package/compiler/transform/debug/transform.ts +47 -0
- package/compiler/transform/debug/utils/debug_data.ts +187 -0
- package/compiler/transform/debug/utils/source_url.ts +29 -0
- package/compiler/transform/evaluator/evaluator.ts +1138 -0
- package/compiler/transform/evaluator/index.ts +3 -0
- package/compiler/transform/evaluator/tracer.ts +607 -0
- package/compiler/transform/evaluator/types.ts +22 -0
- package/compiler/transform/extract/chain/chain.ts +2343 -0
- package/compiler/transform/extract/chain/extract_chain.ts +89 -0
- package/compiler/transform/extract/chain/index.ts +3 -0
- package/compiler/transform/extract/chain/types.ts +37 -0
- package/compiler/transform/extract/index.ts +2 -0
- package/compiler/transform/extract/plugin.ts +665 -0
- package/compiler/transform/extract/transform.ts +45 -0
- package/compiler/transform/extract/utils/imports.ts +132 -0
- package/compiler/transform/extract/utils/replacement.ts +349 -0
- package/compiler/transform/extract/utils/slot.ts +186 -0
- package/compiler/transform/extract/utils/state.ts +48 -0
- package/compiler/transform/extract/utils/theme.ts +86 -0
- package/compiler/transform/extract/utils/token.ts +1 -0
- package/compiler/transform/index.ts +5 -0
- package/compiler/transform/syntax/index.ts +5 -0
- package/compiler/transform/syntax/isStaticStyleValue.ts +44 -0
- package/compiler/transform/syntax/isStyleChainCall.ts +16 -0
- package/compiler/transform/syntax/static_ids.ts +282 -0
- package/compiler/transform/syntax/types.ts +7 -0
- package/compiler/transform/syntax/utils.ts +31 -0
- package/compiler/transform/utils/babel.ts +100 -0
- package/compiler/transform/utils/import.ts +47 -0
- package/compiler/transform/utils/path.ts +13 -0
- package/compiler/transform/utils/selector.ts +252 -0
- package/compiler/utils/constants.ts +69 -0
- package/compiler/utils/file_resolver.ts +72 -0
- package/compiler/utils/import_source.ts +200 -0
- package/compiler/utils/imports.ts +24 -0
- package/compiler/utils/path.ts +40 -0
- package/compiler/utils/sourcemap.ts +61 -0
- package/config/build.ts +32 -0
- package/config/config/css.ts +32 -0
- package/config/config/css_extra.ts +22 -0
- package/config/config/debug.ts +26 -0
- package/config/config/dev.ts +145 -0
- package/config/config/runtime.ts +29 -0
- package/config/configure.ts +28 -0
- package/config/constants.ts +1 -0
- package/config/index.ts +2 -0
- package/config/types.ts +56 -0
- package/config/utils.ts +5 -0
- package/css/counterStyle.ts +20 -0
- package/css/fontFace.ts +25 -0
- package/css/fontPaletteValues.ts +20 -0
- package/css/index.ts +8 -0
- package/css/keyframes.ts +20 -0
- package/css/positionTry.ts +20 -0
- package/css/property.ts +32 -0
- package/css/utils.ts +56 -0
- package/dev/config.ts +16 -0
- package/dev/fns.ts +48 -0
- package/dev/index.ts +2 -0
- package/dev/trace.ts +413 -0
- package/dev/utils.ts +528 -0
- package/dist/assert-h_Zkqc4E.js +105 -0
- package/dist/assert-h_Zkqc4E.js.map +1 -0
- package/dist/className-C1Ht5Wvv.js +144 -0
- package/dist/className-C1Ht5Wvv.js.map +1 -0
- package/dist/className-DC2Cq8p3.js +251 -0
- package/dist/className-DC2Cq8p3.js.map +1 -0
- package/dist/compiler/index.mjs +2 -0
- package/dist/compiler-DweanHoB.mjs +6847 -0
- package/dist/compiler-DweanHoB.mjs.map +1 -0
- package/dist/config/index.js +3 -0
- package/dist/config-BryWDfQX.js +25 -0
- package/dist/config-BryWDfQX.js.map +1 -0
- package/dist/config-DKHXWhe1.js +1 -0
- package/dist/config-Di2VYYKV.js +6 -0
- package/dist/config-Di2VYYKV.js.map +1 -0
- package/dist/config-DloHOG6I.js +13 -0
- package/dist/config-DloHOG6I.js.map +1 -0
- package/dist/css-BowBszUt.js +243 -0
- package/dist/css-BowBszUt.js.map +1 -0
- package/dist/css-ByOrugEX.js +805 -0
- package/dist/css-ByOrugEX.js.map +1 -0
- package/dist/css-DcazYor9.js +235 -0
- package/dist/css-DcazYor9.js.map +1 -0
- package/dist/css.js +2 -0
- package/dist/css_extra-DlOnsnR1.js +8 -0
- package/dist/css_extra-DlOnsnR1.js.map +1 -0
- package/dist/css_extra-oIi3UEPK.js +8 -0
- package/dist/css_extra-oIi3UEPK.js.map +1 -0
- package/dist/data-_te7t0M4.js +473 -0
- package/dist/data-_te7t0M4.js.map +1 -0
- package/dist/debug-BAw63qX6.js +15 -0
- package/dist/debug-BAw63qX6.js.map +1 -0
- package/dist/debug-DGki_v7g.js +15 -0
- package/dist/debug-DGki_v7g.js.map +1 -0
- package/dist/debug-n2aZQBSa.js +172 -0
- package/dist/debug-n2aZQBSa.js.map +1 -0
- package/dist/dev/rsc.js +183 -0
- package/dist/dev/rsc.js.map +1 -0
- package/dist/dev-CcphAa3R.js +376 -0
- package/dist/dev-CcphAa3R.js.map +1 -0
- package/dist/dev-DfBbuLeE.js +71 -0
- package/dist/dev-DfBbuLeE.js.map +1 -0
- package/dist/dev.js +2 -0
- package/dist/elementMarker-Bu7gDAkE.js +800 -0
- package/dist/elementMarker-Bu7gDAkE.js.map +1 -0
- package/dist/entry/dev/css.js +3 -0
- package/dist/entry/dev/jsx-dev-runtime.js +3 -0
- package/dist/entry/dev/jsx-runtime.js +3 -0
- package/dist/entry/dev.js +10 -0
- package/dist/entry/prod/css.js +3 -0
- package/dist/entry/prod/extract.js +3 -0
- package/dist/entry/prod/jsx-dev-runtime.js +3 -0
- package/dist/entry/prod/jsx-runtime.js +3 -0
- package/dist/entry/prod/runtime.js +5 -0
- package/dist/entry/prod.js +1230 -0
- package/dist/entry/prod.js.map +1 -0
- package/dist/entry/rsc-dev/css.js +3 -0
- package/dist/entry/rsc-dev/dev.js +544 -0
- package/dist/entry/rsc-dev/dev.js.map +1 -0
- package/dist/entry/rsc-dev/jsx-dev-runtime.js +12 -0
- package/dist/entry/rsc-dev/jsx-dev-runtime.js.map +1 -0
- package/dist/entry/rsc-dev/jsx-runtime.js +3 -0
- package/dist/entry/rsc-dev.js +1429 -0
- package/dist/entry/rsc-dev.js.map +1 -0
- package/dist/entry/rsc-prod/css.js +3 -0
- package/dist/entry/rsc-prod/jsx-dev-runtime.js +3 -0
- package/dist/entry/rsc-prod/jsx-runtime.js +3 -0
- package/dist/entry/rsc-prod/runtime.js +5 -0
- package/dist/entry/rsc-prod.js +10 -0
- package/dist/extract-CzWJeQi8.js +121 -0
- package/dist/extract-CzWJeQi8.js.map +1 -0
- package/dist/extract-DEwSDJ9Z.js +2 -0
- package/dist/format-3nKBE_5t.js +144 -0
- package/dist/format-3nKBE_5t.js.map +1 -0
- package/dist/getClassName-BlvXHYuf.js +260 -0
- package/dist/getClassName-BlvXHYuf.js.map +1 -0
- package/dist/global-CvfmFLsK.js +11 -0
- package/dist/global-CvfmFLsK.js.map +1 -0
- package/dist/index.js +9 -0
- package/dist/jsx/jsx-dev-runtime.js +12 -0
- package/dist/jsx/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx/jsx-dev-runtime.server.js +11 -0
- package/dist/jsx/jsx-dev-runtime.server.js.map +1 -0
- package/dist/jsx/jsx-runtime.js +13 -0
- package/dist/jsx/jsx-runtime.js.map +1 -0
- package/dist/jsx/jsx-runtime.server.js +12 -0
- package/dist/jsx/jsx-runtime.server.js.map +1 -0
- package/dist/jsx-CwTeyUxr.js +39 -0
- package/dist/jsx-CwTeyUxr.js.map +1 -0
- package/dist/jsx-D2BksHSv.js +38 -0
- package/dist/jsx-D2BksHSv.js.map +1 -0
- package/dist/jsx_dev_runtime-B6xs4by8.js +12 -0
- package/dist/jsx_dev_runtime-B6xs4by8.js.map +1 -0
- package/dist/jsx_runtime-04xfnsi7.js +13 -0
- package/dist/jsx_runtime-04xfnsi7.js.map +1 -0
- package/dist/jsx_runtime-iHLDwpcW.js +12 -0
- package/dist/jsx_runtime-iHLDwpcW.js.map +1 -0
- package/dist/layer-D1SaH07m.js +94 -0
- package/dist/layer-D1SaH07m.js.map +1 -0
- package/dist/loader-DS61nRqr.mjs +81 -0
- package/dist/loader-DS61nRqr.mjs.map +1 -0
- package/dist/misc-B9kqEb2N.mjs +360 -0
- package/dist/misc-B9kqEb2N.mjs.map +1 -0
- package/dist/plugin/farm/index.mjs +176 -0
- package/dist/plugin/farm/index.mjs.map +1 -0
- package/dist/plugin/nextjs/index.mjs +282 -0
- package/dist/plugin/nextjs/index.mjs.map +1 -0
- package/dist/plugin/nextjs/loader.mjs +162 -0
- package/dist/plugin/nextjs/loader.mjs.map +1 -0
- package/dist/plugin/parcel/index.cjs +9 -0
- package/dist/plugin/parcel/index.mjs +5 -0
- package/dist/plugin/parcel/optimizer.cjs +28 -0
- package/dist/plugin/parcel/optimizer.cjs.map +1 -0
- package/dist/plugin/parcel/optimizer.mjs +29 -0
- package/dist/plugin/parcel/optimizer.mjs.map +1 -0
- package/dist/plugin/parcel/resolver.cjs +17 -0
- package/dist/plugin/parcel/resolver.cjs.map +1 -0
- package/dist/plugin/parcel/resolver.mjs +18 -0
- package/dist/plugin/parcel/resolver.mjs.map +1 -0
- package/dist/plugin/parcel/runtime.cjs +17 -0
- package/dist/plugin/parcel/runtime.cjs.map +1 -0
- package/dist/plugin/parcel/runtime.mjs +17 -0
- package/dist/plugin/parcel/runtime.mjs.map +1 -0
- package/dist/plugin/parcel/transformer.cjs +41 -0
- package/dist/plugin/parcel/transformer.cjs.map +1 -0
- package/dist/plugin/parcel/transformer.mjs +41 -0
- package/dist/plugin/parcel/transformer.mjs.map +1 -0
- package/dist/plugin/rspack/index.mjs +11 -0
- package/dist/plugin/rspack/index.mjs.map +1 -0
- package/dist/plugin/vite/index.mjs +176 -0
- package/dist/plugin/vite/index.mjs.map +1 -0
- package/dist/plugin/webpack/index.mjs +2 -0
- package/dist/plugin/webpack/loader.mjs +19 -0
- package/dist/plugin/webpack/loader.mjs.map +1 -0
- package/dist/presets-Bye3ea2x.js +139 -0
- package/dist/presets-Bye3ea2x.js.map +1 -0
- package/dist/property-CnLFt5kx.js +406 -0
- package/dist/property-CnLFt5kx.js.map +1 -0
- package/dist/registry-CyIj8LYK.mjs +22 -0
- package/dist/registry-CyIj8LYK.mjs.map +1 -0
- package/dist/rules-9HSO1pxL.js +767 -0
- package/dist/rules-9HSO1pxL.js.map +1 -0
- package/dist/runtime-CYqNCiaM.js +53 -0
- package/dist/runtime-CYqNCiaM.js.map +1 -0
- package/dist/selector/index.js +3 -0
- package/dist/server.js +63 -0
- package/dist/server.js.map +1 -0
- package/dist/shared-BAL9peIw.cjs +7646 -0
- package/dist/shared-BAL9peIw.cjs.map +1 -0
- package/dist/shared-CCpq1zqA.mjs +132 -0
- package/dist/shared-CCpq1zqA.mjs.map +1 -0
- package/dist/sidecar-4u6GnlQG.mjs +236 -0
- package/dist/sidecar-4u6GnlQG.mjs.map +1 -0
- package/dist/style-4rFUy-zW.js +752 -0
- package/dist/style-4rFUy-zW.js.map +1 -0
- package/dist/style-B1UUqjj5.js +743 -0
- package/dist/style-B1UUqjj5.js.map +1 -0
- package/dist/style-Cw3NtvR0.js +5 -0
- package/dist/style-DNqQ6H-7.js +1255 -0
- package/dist/style-DNqQ6H-7.js.map +1 -0
- package/dist/styleStore-Dea_WVbr.js +2000 -0
- package/dist/styleStore-Dea_WVbr.js.map +1 -0
- package/dist/styleStore-DyNXBcUK.js +54 -0
- package/dist/styleStore-DyNXBcUK.js.map +1 -0
- package/dist/token-CKXUECuU.js +76 -0
- package/dist/token-CKXUECuU.js.map +1 -0
- package/dist/token-u_tM-mtg.js +204 -0
- package/dist/token-u_tM-mtg.js.map +1 -0
- package/dist/trace-Bu_qOqRy.js +245 -0
- package/dist/trace-Bu_qOqRy.js.map +1 -0
- package/dist/trace-CU0rvNYr.js +244 -0
- package/dist/trace-CU0rvNYr.js.map +1 -0
- package/dist/utils-BbehLOby.js +2415 -0
- package/dist/utils-BbehLOby.js.map +1 -0
- package/dist/utils-C7xfDxtM.mjs +97 -0
- package/dist/utils-C7xfDxtM.mjs.map +1 -0
- package/dist/utils-CWNHx4EC.js +170 -0
- package/dist/utils-CWNHx4EC.js.map +1 -0
- package/dist/utils-CdI6vZsP.js +37 -0
- package/dist/utils-CdI6vZsP.js.map +1 -0
- package/dist/utils-D7FAOyg6.js +129 -0
- package/dist/utils-D7FAOyg6.js.map +1 -0
- package/dist/utils-DMFgOOtA.mjs +49 -0
- package/dist/utils-DMFgOOtA.mjs.map +1 -0
- package/dist/utils.js +26 -0
- package/dist/utils.js.map +1 -0
- package/dist/value-BR4e2MKt.js +910 -0
- package/dist/value-BR4e2MKt.js.map +1 -0
- package/dist/value-E8rEv2Oe.js +136 -0
- package/dist/value-E8rEv2Oe.js.map +1 -0
- package/dist/valueRef-lshFk1Cs.js +16 -0
- package/dist/valueRef-lshFk1Cs.js.map +1 -0
- package/dist/webpack-CxS2FDYU.mjs +107 -0
- package/dist/webpack-CxS2FDYU.mjs.map +1 -0
- package/dist/withTokens-LRidu3Vc.js +95 -0
- package/dist/withTokens-LRidu3Vc.js.map +1 -0
- package/entry/dev/config.ts +2 -0
- package/entry/dev/css.ts +3 -0
- package/entry/dev/index.ts +3 -0
- package/entry/dev/jsx_dev_runtime.ts +3 -0
- package/entry/dev/jsx_runtime.ts +3 -0
- package/entry/prod/config.ts +2 -0
- package/entry/prod/css.ts +3 -0
- package/entry/prod/extract.ts +1 -0
- package/entry/prod/index.ts +3 -0
- package/entry/prod/jsx_dev_runtime.ts +3 -0
- package/entry/prod/jsx_runtime.ts +3 -0
- package/entry/prod/runtime.ts +14 -0
- package/entry/rsc_dev/config.ts +6 -0
- package/entry/rsc_dev/css.ts +3 -0
- package/entry/rsc_dev/dev.ts +5 -0
- package/entry/rsc_dev/index.ts +3 -0
- package/entry/rsc_dev/jsx_dev_runtime.ts +3 -0
- package/entry/rsc_dev/jsx_runtime.ts +3 -0
- package/entry/rsc_dev/server.ts +11 -0
- package/entry/rsc_prod/config.ts +6 -0
- package/entry/rsc_prod/css.ts +3 -0
- package/entry/rsc_prod/index.ts +3 -0
- package/entry/rsc_prod/jsx_dev_runtime.ts +3 -0
- package/entry/rsc_prod/jsx_runtime.ts +3 -0
- package/entry/rsc_prod/runtime.ts +12 -0
- package/entry/rsc_prod/server.ts +13 -0
- package/entry/shared/config.ts +5 -0
- package/entry/shared/dev.ts +19 -0
- package/entry/shared/prod.ts +4 -0
- package/index.ts +36 -0
- package/jsx/extracted/jsx_dev_runtime.ts +11 -0
- package/jsx/extracted/jsx_runtime.ts +12 -0
- package/jsx/rsc/jsx_dev_runtime.ts +11 -0
- package/jsx/rsc/jsx_runtime.ts +12 -0
- package/jsx/rsc_extracted/jsx_dev_runtime.ts +2 -0
- package/jsx/rsc_extracted/jsx_runtime.ts +2 -0
- package/jsx/runtime/jsx_dev_runtime.ts +11 -0
- package/jsx/runtime/jsx_runtime.ts +12 -0
- package/jsx/types.ts +8 -0
- package/jsx/utils.ts +59 -0
- package/package.json +298 -0
- package/plugin/bundler/farm/index.ts +1 -0
- package/plugin/bundler/farm/plugin.ts +320 -0
- package/plugin/bundler/parcel/config.json +19 -0
- package/plugin/bundler/parcel/index.ts +1 -0
- package/plugin/bundler/parcel/optimizer.ts +36 -0
- package/plugin/bundler/parcel/plugin.ts +4 -0
- package/plugin/bundler/parcel/resolver.ts +36 -0
- package/plugin/bundler/parcel/runtime.ts +23 -0
- package/plugin/bundler/parcel/shared.ts +234 -0
- package/plugin/bundler/parcel/transformer.ts +67 -0
- package/plugin/bundler/rspack/index.ts +1 -0
- package/plugin/bundler/rspack/plugin.ts +14 -0
- package/plugin/bundler/vite/index.ts +1 -0
- package/plugin/bundler/vite/plugin.ts +133 -0
- package/plugin/bundler/vite/state.ts +153 -0
- package/plugin/bundler/webpack/index.ts +1 -0
- package/plugin/bundler/webpack/loader.ts +19 -0
- package/plugin/bundler/webpack/plugin.ts +240 -0
- package/plugin/bundler/webpack/shared/index.ts +2 -0
- package/plugin/bundler/webpack/shared/loader.ts +155 -0
- package/plugin/bundler/webpack/shared/registry.ts +16 -0
- package/plugin/bundler/webpack/utils.ts +96 -0
- package/plugin/nextjs/constants.ts +7 -0
- package/plugin/nextjs/html.ts +62 -0
- package/plugin/nextjs/index.ts +2 -0
- package/plugin/nextjs/loader.ts +222 -0
- package/plugin/nextjs/plugin.ts +532 -0
- package/plugin/nextjs/types.ts +33 -0
- package/plugin/nextjs/utils.ts +210 -0
- package/plugin/utils/cache/css_cache.ts +146 -0
- package/plugin/utils/cache/file.ts +40 -0
- package/plugin/utils/cache/index.ts +2 -0
- package/plugin/utils/compiler.ts +94 -0
- package/plugin/utils/constants.ts +7 -0
- package/plugin/utils/cssMarker.ts +14 -0
- package/plugin/utils/cssOutput.ts +65 -0
- package/plugin/utils/filter.ts +98 -0
- package/plugin/utils/imports.ts +5 -0
- package/plugin/utils/index.ts +10 -0
- package/plugin/utils/injection.ts +28 -0
- package/plugin/utils/misc.ts +5 -0
- package/plugin/utils/runtimeEntry.ts +57 -0
- package/plugin/utils/sidecar/index.ts +1 -0
- package/plugin/utils/sidecar/server.ts +143 -0
- package/plugin/utils/sidecar/sidecar.ts +167 -0
- package/plugin/utils/sidecar/utils.ts +109 -0
- package/plugin/utils/sourcemap.ts +52 -0
- package/plugin/utils/virtual.ts +81 -0
- package/runtime/core/cache/combine.ts +102 -0
- package/runtime/core/cache/index.ts +5 -0
- package/runtime/core/cache/item.ts +231 -0
- package/runtime/core/cache/pool.ts +310 -0
- package/runtime/core/cache/prop.ts +283 -0
- package/runtime/core/cache/propCache.ts +62 -0
- package/runtime/core/cache/resolvedItem.ts +31 -0
- package/runtime/core/cache/result.ts +115 -0
- package/runtime/core/cache/stateItem.ts +208 -0
- package/runtime/core/cache/tokenValues.ts +150 -0
- package/runtime/core/cache/utils/tree.ts +57 -0
- package/runtime/core/cache/utils/walk.ts +24 -0
- package/runtime/core/className.ts +101 -0
- package/runtime/core/combinedStyle.ts +101 -0
- package/runtime/core/createTransformElement.ts +39 -0
- package/runtime/core/elementMarker.ts +189 -0
- package/runtime/core/elementMarkerData.ts +27 -0
- package/runtime/core/getClassName.ts +47 -0
- package/runtime/core/getSheetRules.ts +7 -0
- package/runtime/core/getToken.ts +14 -0
- package/runtime/core/index.ts +5 -0
- package/runtime/core/jsx.ts +4 -0
- package/runtime/core/resolveClassNameRuntime.ts +33 -0
- package/runtime/env.ts +7 -0
- package/runtime/extract/getClassName.ts +476 -0
- package/runtime/extract/index.ts +4 -0
- package/runtime/extract/jsx.ts +55 -0
- package/runtime/index.ts +12 -0
- package/runtime/rsc/constants.ts +6 -0
- package/runtime/rsc/dev.ts +38 -0
- package/runtime/rsc/getClassName.ts +98 -0
- package/runtime/rsc/index.ts +3 -0
- package/runtime/rsc/jsx.ts +4 -0
- package/runtime/rsc/observer.ts +238 -0
- package/runtime/rsc/styleStore.ts +82 -0
- package/runtime/sheet/element.ts +13 -0
- package/runtime/sheet/global-noop.ts +13 -0
- package/runtime/sheet/global-prod.ts +13 -0
- package/runtime/sheet/global.ts +13 -0
- package/runtime/sheet/index.ts +3 -0
- package/runtime/sheet/insert.ts +37 -0
- package/runtime/sheet/rule.ts +77 -0
- package/runtime/sheet/rules.ts +131 -0
- package/runtime/sheet/theme.ts +34 -0
- package/runtime/style/index.ts +3 -0
- package/runtime/style/scope.ts +65 -0
- package/runtime/style/style.ts +34 -0
- package/runtime/style/token.ts +1 -0
- package/runtime/types.ts +42 -0
- package/selector/assert.ts +131 -0
- package/selector/index.ts +5 -0
- package/selector/presets/default.ts +27 -0
- package/selector/presets/index.ts +3 -0
- package/selector/presets/minimal.ts +37 -0
- package/selector/presets/selectors.ts +85 -0
- package/selector/selector.ts +68 -0
- package/selector/types.ts +24 -0
- package/selector/validate.ts +91 -0
- package/sheet/dev/dev_layer.ts +151 -0
- package/sheet/dev/dev_sort.ts +249 -0
- package/sheet/dev/index.ts +129 -0
- package/sheet/dev/utils.ts +130 -0
- package/sheet/index.ts +4 -0
- package/sheet/prod.ts +109 -0
- package/sheet/sheet.ts +10 -0
- package/sheet/sourcemap.ts +70 -0
- package/sheet/types.ts +31 -0
- package/sheet/utils/dom.ts +71 -0
- package/sheet/utils/index.ts +4 -0
- package/sheet/utils/layer.ts +14 -0
- package/sheet/utils/noop.ts +11 -0
- package/sheet/utils/rule.ts +3 -0
- package/sheet/utils/sourcemap.ts +221 -0
- package/style/index.ts +9 -0
- package/style/keyframes.ts +40 -0
- package/style/style.ts +112 -0
- package/style/theme.ts +36 -0
- package/style/token.ts +101 -0
- package/style/tokens.ts +64 -0
- package/style/transform.ts +9 -0
- package/style/types.ts +32 -0
- package/style/utils/expose.ts +43 -0
- package/style/utils/index.ts +1 -0
- package/style/value.ts +103 -0
- package/style/valueRef.ts +25 -0
- package/utils/global.ts +44 -0
- package/utils/hash.ts +22 -0
- package/utils/id.ts +20 -0
- package/utils/object.ts +87 -0
- package/utils/trace.ts +211 -0
- package/utils/type.ts +22 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
type FormatInfo = { [key: string]: string | null; };
|
|
2
|
+
|
|
3
|
+
type NameFormatFn<Info> = (info: Info) => string;
|
|
4
|
+
type NameFormat<Info> = string | NameFormatFn<Info>;
|
|
5
|
+
|
|
6
|
+
type CompiledSegment<Key extends string> = {
|
|
7
|
+
optional: boolean;
|
|
8
|
+
parts: CompiledPart<Key>[];
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type CompiledPart<Key extends string> =
|
|
12
|
+
| { type: 'text'; value: string; }
|
|
13
|
+
| {
|
|
14
|
+
type: 'token';
|
|
15
|
+
key: Key;
|
|
16
|
+
maxLength: number | null;
|
|
17
|
+
truncate: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const TOKEN_REGEX = /\(([a-zA-Z][a-zA-Z0-9]*)(?::([0-9]+)(!)?)?\)/g;
|
|
21
|
+
const OPTIONAL_REGEX = /\[([^[\]]*)\]/g;
|
|
22
|
+
|
|
23
|
+
const HASH_TOKEN = '$hash';
|
|
24
|
+
|
|
25
|
+
export type NameFormatter<Info extends object> = ReturnType<typeof createNameFormatter<Info>>;
|
|
26
|
+
|
|
27
|
+
export function createNameFormatter<Info extends object>(
|
|
28
|
+
keys: readonly (keyof Info & string)[],
|
|
29
|
+
) {
|
|
30
|
+
const keySet = new Set<string>(keys);
|
|
31
|
+
const cache = new Map<string, NameFormatFn<Info>>();
|
|
32
|
+
|
|
33
|
+
function getFormatFn(format: NameFormat<Info>) {
|
|
34
|
+
if (typeof format === 'function') return format;
|
|
35
|
+
|
|
36
|
+
let fn = cache.get(format);
|
|
37
|
+
|
|
38
|
+
if (!fn) {
|
|
39
|
+
fn = compileFormat(format, keySet);
|
|
40
|
+
cache.set(format, fn);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return fn;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return function format(format: NameFormat<Info>, hash: string | null, info: Info) {
|
|
47
|
+
const name = getFormatFn(format)(info);
|
|
48
|
+
|
|
49
|
+
if (!hash) return name;
|
|
50
|
+
|
|
51
|
+
if (name.includes(HASH_TOKEN)) {
|
|
52
|
+
return name.replace(HASH_TOKEN, hash);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return name ? (name + '-' + hash) : hash;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function compileFormat<Info extends object>(
|
|
60
|
+
format: string,
|
|
61
|
+
keySet: ReadonlySet<string>,
|
|
62
|
+
): NameFormatFn<Info> {
|
|
63
|
+
type Key = keyof Info & string;
|
|
64
|
+
const segments = compileSegments<Key>(format, keySet);
|
|
65
|
+
|
|
66
|
+
return (info) => {
|
|
67
|
+
let name = '';
|
|
68
|
+
|
|
69
|
+
for (const segment of segments) {
|
|
70
|
+
const text = formatSegment(info, segment);
|
|
71
|
+
|
|
72
|
+
if (text === null) {
|
|
73
|
+
if (!segment.optional) return '';
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
name += text;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return name;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function compileSegments<Key extends string>(
|
|
85
|
+
format: string,
|
|
86
|
+
keySet: ReadonlySet<string>,
|
|
87
|
+
) {
|
|
88
|
+
const segments: CompiledSegment<Key>[] = [];
|
|
89
|
+
let lastIndex = 0;
|
|
90
|
+
|
|
91
|
+
for (const match of format.matchAll(OPTIONAL_REGEX)) {
|
|
92
|
+
const index = match.index ?? 0;
|
|
93
|
+
|
|
94
|
+
if (index > lastIndex) {
|
|
95
|
+
segments.push({
|
|
96
|
+
optional: false,
|
|
97
|
+
parts: compileParts<Key>(format.slice(lastIndex, index), keySet),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
segments.push({
|
|
102
|
+
optional: true,
|
|
103
|
+
parts: compileParts<Key>(match[1], keySet),
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
lastIndex = index + match[0].length;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (lastIndex < format.length) {
|
|
110
|
+
segments.push({
|
|
111
|
+
optional: false,
|
|
112
|
+
parts: compileParts<Key>(format.slice(lastIndex), keySet),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return segments;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function compileParts<Key extends string>(
|
|
120
|
+
segment: string,
|
|
121
|
+
keySet: ReadonlySet<string>,
|
|
122
|
+
) {
|
|
123
|
+
const parts: CompiledPart<Key>[] = [];
|
|
124
|
+
let lastIndex = 0;
|
|
125
|
+
|
|
126
|
+
for (const match of segment.matchAll(TOKEN_REGEX)) {
|
|
127
|
+
const index = match.index ?? 0;
|
|
128
|
+
const key = match[1];
|
|
129
|
+
|
|
130
|
+
if (!keySet.has(key)) continue;
|
|
131
|
+
|
|
132
|
+
if (index > lastIndex) {
|
|
133
|
+
parts.push({ type: 'text', value: segment.slice(lastIndex, index) });
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
parts.push({
|
|
137
|
+
type: 'token',
|
|
138
|
+
key: key as Key,
|
|
139
|
+
maxLength: match[2] ? Number(match[2]) : null,
|
|
140
|
+
truncate: Boolean(match[3]),
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
lastIndex = index + match[0].length;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (lastIndex < segment.length) {
|
|
147
|
+
parts.push({ type: 'text', value: segment.slice(lastIndex) });
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return parts;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function formatSegment<Info extends object, Key extends keyof Info & string>(
|
|
154
|
+
info: Info,
|
|
155
|
+
segment: CompiledSegment<Key>,
|
|
156
|
+
) {
|
|
157
|
+
let text = '';
|
|
158
|
+
|
|
159
|
+
for (const part of segment.parts) {
|
|
160
|
+
if (part.type === 'text') {
|
|
161
|
+
text += part.value;
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const value = formatTokenValue(
|
|
166
|
+
(info as FormatInfo)[part.key],
|
|
167
|
+
part.maxLength,
|
|
168
|
+
part.truncate,
|
|
169
|
+
);
|
|
170
|
+
if (value === null) {
|
|
171
|
+
if (segment.optional) return null;
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
text += value;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return text;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function formatTokenValue(
|
|
182
|
+
value: string | null,
|
|
183
|
+
maxLength: number | null,
|
|
184
|
+
truncate: boolean,
|
|
185
|
+
) {
|
|
186
|
+
if (!value) return null;
|
|
187
|
+
if (!maxLength) return value;
|
|
188
|
+
|
|
189
|
+
if (!Number.isFinite(maxLength) || maxLength < 0 || value.length <= maxLength) return value;
|
|
190
|
+
|
|
191
|
+
return truncate ? value.slice(0, maxLength) : null;
|
|
192
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ItemSelector } from '../../builder/data/state';
|
|
2
|
+
|
|
3
|
+
export function getSelectorText(selector: ItemSelector): string {
|
|
4
|
+
return Array.isArray(selector) ? selector[0] : selector;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function getSelectorHash(selector: ItemSelector): string {
|
|
8
|
+
return Array.isArray(selector) ? selector.join('|') : selector;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function getSelectorPriority(selector: ItemSelector | null): number {
|
|
12
|
+
if (!selector) return 0;
|
|
13
|
+
return Array.isArray(selector) ? selector[1] : 0;
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type * as CSS from 'csstype';
|
|
2
|
+
|
|
3
|
+
export type * as CSS from 'csstype';
|
|
4
|
+
|
|
5
|
+
export type CSSValueExclude = '-moz-initial';
|
|
6
|
+
|
|
7
|
+
export type CSSProperties = {
|
|
8
|
+
[P in keyof CSS.Properties<string | number>]: Exclude<CSS.Properties<string | number>[P], CSSValueExclude>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type CSSPropertyName = keyof CSS.Properties<string | number>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export const UnitlessProperties = [
|
|
2
|
+
'animationIterationCount',
|
|
3
|
+
'aspectRatio',
|
|
4
|
+
'borderImageOutset',
|
|
5
|
+
'borderImageSlice',
|
|
6
|
+
'borderImageWidth',
|
|
7
|
+
'boxFlex',
|
|
8
|
+
'boxFlexGroup',
|
|
9
|
+
'boxOrdinalGroup',
|
|
10
|
+
'columnCount',
|
|
11
|
+
'columns',
|
|
12
|
+
'fillOpacity',
|
|
13
|
+
'flex',
|
|
14
|
+
'flexGrow',
|
|
15
|
+
'flexNegative',
|
|
16
|
+
'flexOrder',
|
|
17
|
+
'flexPositive',
|
|
18
|
+
'flexShrink',
|
|
19
|
+
'floodOpacity',
|
|
20
|
+
'fontWeight',
|
|
21
|
+
'gridArea',
|
|
22
|
+
'gridColumn',
|
|
23
|
+
'gridColumnEnd',
|
|
24
|
+
'gridColumnSpan',
|
|
25
|
+
'gridColumnStart',
|
|
26
|
+
'gridRow',
|
|
27
|
+
'gridRowEnd',
|
|
28
|
+
'gridRowSpan',
|
|
29
|
+
'gridRowStart',
|
|
30
|
+
'imageOrientation',
|
|
31
|
+
'lineClamp',
|
|
32
|
+
'lineHeight',
|
|
33
|
+
'opacity',
|
|
34
|
+
'order',
|
|
35
|
+
'orphans',
|
|
36
|
+
'scale',
|
|
37
|
+
'stopOpacity',
|
|
38
|
+
'strokeDasharray',
|
|
39
|
+
'strokeDashoffset',
|
|
40
|
+
'strokeMiterlimit',
|
|
41
|
+
'strokeOpacity',
|
|
42
|
+
'strokeWidth',
|
|
43
|
+
'tabSize',
|
|
44
|
+
'widows',
|
|
45
|
+
'zIndex',
|
|
46
|
+
'zoom',
|
|
47
|
+
];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { UnitlessProperties } from './unitless';
|
|
2
|
+
|
|
3
|
+
const CSS_NUMBER_VALUE = /^-?(\d+\.?\d*|\.\d+)$/;
|
|
4
|
+
|
|
5
|
+
const UNITLESS = new Set(UnitlessProperties);
|
|
6
|
+
|
|
7
|
+
export function getCssPropertyValue(property: string, value: string): string {
|
|
8
|
+
if (!value || !shouldAppendCssPx(property)) return value;
|
|
9
|
+
|
|
10
|
+
if (CSS_NUMBER_VALUE.test(value)) return value + 'px';
|
|
11
|
+
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function shouldAppendCssPx(property: string): boolean {
|
|
16
|
+
return !UNITLESS.has(property);
|
|
17
|
+
}
|
package/atomic/var.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { VarNameFormat, VarNameInfo } from '../config/types';
|
|
2
|
+
import { getIdentifierSafeHash } from './utils/css';
|
|
3
|
+
import { createNameFormatter } from './utils/format';
|
|
4
|
+
|
|
5
|
+
export const VAR_NAME_FORMAT = 'var[-(name)]-$hash';
|
|
6
|
+
|
|
7
|
+
export const formatVarName = createNameFormatter<VarNameInfo>(['name']);
|
|
8
|
+
|
|
9
|
+
export function getLocalVarName(
|
|
10
|
+
filePath: string,
|
|
11
|
+
line: number,
|
|
12
|
+
column: number,
|
|
13
|
+
format: VarNameFormat | null | undefined,
|
|
14
|
+
) {
|
|
15
|
+
const hash = getIdentifierSafeHash(filePath + '\n' + line + ':' + column);
|
|
16
|
+
const name = formatVarName(format || VAR_NAME_FORMAT, hash, { name: '' });
|
|
17
|
+
|
|
18
|
+
return '--' + name;
|
|
19
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { assertSelector } from '../../selector/assert';
|
|
2
|
+
import type { Selector } from '../../selector/types';
|
|
3
|
+
import { traceError } from '../../utils/trace';
|
|
4
|
+
|
|
5
|
+
export function checkSelector(
|
|
6
|
+
fnPrefix: string,
|
|
7
|
+
fnName: string,
|
|
8
|
+
fnSelector: Selector,
|
|
9
|
+
arg: string,
|
|
10
|
+
) {
|
|
11
|
+
let message: string | null = null;
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
assertSelector(fnSelector.assert, arg);
|
|
15
|
+
} catch (error) {
|
|
16
|
+
if (typeof error === 'string' && error.trim()) {
|
|
17
|
+
message = error;
|
|
18
|
+
} else if (typeof error === 'object' && error && error instanceof Error) {
|
|
19
|
+
message = (error.message || '').trim();
|
|
20
|
+
} else {
|
|
21
|
+
message = 'selector is invalid: ' + arg;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!message) return;
|
|
26
|
+
|
|
27
|
+
const error = `${fnPrefix}${fnName}(${arg || ''}): ${message}`;
|
|
28
|
+
|
|
29
|
+
throw traceError(error);
|
|
30
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { symbol } from '../../utils/global';
|
|
2
|
+
|
|
3
|
+
export const BUILDER_TYPE: unique symbol = symbol('builder.type');
|
|
4
|
+
export const BUILDER_STATE: unique symbol = symbol('builder.state');
|
|
5
|
+
export const BUILDER_CALLSITE: unique symbol = symbol('builder.callsite');
|
|
6
|
+
export const BUILDER_SLOT_ID: unique symbol = symbol('builder.slotId');
|
|
7
|
+
export const BUILDER_SCOPE_ID: unique symbol = symbol('builder.scopeId');
|
|
8
|
+
export const BUILDER_SCOPE: unique symbol = symbol('builder.scope');
|
|
9
|
+
|
|
10
|
+
export const BUILDER_TYPE_STYLE = 1;
|
|
11
|
+
export const BUILDER_TYPE_SLOT = 2;
|
|
12
|
+
export const BUILDER_TYPE_SLOT_OVERRIDE = 3;
|
|
13
|
+
export const BUILDER_TYPE_SCOPE = 4;
|
|
14
|
+
export const BUILDER_TYPE_SCOPE_TARGET = 5;
|
|
15
|
+
export const BUILDER_TYPE_THEME = 6;
|
|
16
|
+
|
|
17
|
+
export const ITEM_RUNTIME_DEV = -1;
|
|
18
|
+
export const ITEM_RUNTIME_DEV_PLUGIN = -2;
|
|
19
|
+
export const ITEM_RUNTIME_PROD = -3;
|
|
20
|
+
export const ITEM_RUNTIME_PROD_PLUGIN = -4;
|
|
21
|
+
|
|
22
|
+
export const ITEM_VALUE_TYPE_VARIABLE = 1;
|
|
23
|
+
export const ITEM_VALUE_TYPE_STYLE_DATA = 2;
|
|
24
|
+
export const ITEM_VALUE_NUMBER_PX = 1;
|
|
25
|
+
export const ITEM_VALUE_TYPE_AT_RULE_REF = 3;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { StyleTokenOverride } from '../../style/token';
|
|
2
|
+
import {
|
|
3
|
+
BUILDER_CALLSITE,
|
|
4
|
+
BUILDER_SCOPE,
|
|
5
|
+
BUILDER_SCOPE_ID,
|
|
6
|
+
BUILDER_SLOT_ID,
|
|
7
|
+
BUILDER_STATE,
|
|
8
|
+
BUILDER_TYPE,
|
|
9
|
+
BUILDER_TYPE_SCOPE,
|
|
10
|
+
BUILDER_TYPE_SCOPE_TARGET,
|
|
11
|
+
BUILDER_TYPE_SLOT,
|
|
12
|
+
BUILDER_TYPE_SLOT_OVERRIDE,
|
|
13
|
+
BUILDER_TYPE_STYLE,
|
|
14
|
+
BUILDER_TYPE_THEME,
|
|
15
|
+
} from './const';
|
|
16
|
+
import type {
|
|
17
|
+
BuilderCallsite,
|
|
18
|
+
BuilderData,
|
|
19
|
+
ScopeData,
|
|
20
|
+
ScopeTargetData,
|
|
21
|
+
SlotData,
|
|
22
|
+
SlotOverrideData,
|
|
23
|
+
StyleData,
|
|
24
|
+
ThemeData,
|
|
25
|
+
} from './data';
|
|
26
|
+
|
|
27
|
+
export function createStyleData<Style>(
|
|
28
|
+
callsite: BuilderCallsite | null,
|
|
29
|
+
): StyleData<Style> {
|
|
30
|
+
return {
|
|
31
|
+
[BUILDER_TYPE]: BUILDER_TYPE_STYLE,
|
|
32
|
+
[BUILDER_STATE]: { items: [], lookup: {} },
|
|
33
|
+
[BUILDER_CALLSITE]: callsite,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function createSlotData<Style>(
|
|
38
|
+
callsite: BuilderCallsite | null,
|
|
39
|
+
slotId: string,
|
|
40
|
+
): SlotData<Style> {
|
|
41
|
+
return {
|
|
42
|
+
[BUILDER_TYPE]: BUILDER_TYPE_SLOT,
|
|
43
|
+
[BUILDER_STATE]: { items: [], lookup: {} },
|
|
44
|
+
[BUILDER_CALLSITE]: callsite,
|
|
45
|
+
[BUILDER_SLOT_ID]: slotId,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function createSlotOverrideData<Style>(
|
|
50
|
+
callsite: BuilderCallsite | null,
|
|
51
|
+
slotId: string,
|
|
52
|
+
): SlotOverrideData<Style> {
|
|
53
|
+
return {
|
|
54
|
+
[BUILDER_TYPE]: BUILDER_TYPE_SLOT_OVERRIDE,
|
|
55
|
+
[BUILDER_STATE]: { items: [], lookup: {} },
|
|
56
|
+
[BUILDER_CALLSITE]: callsite,
|
|
57
|
+
[BUILDER_SLOT_ID]: slotId,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function createScopeData<Style>(
|
|
62
|
+
callsite: BuilderCallsite | null,
|
|
63
|
+
): BuilderData<Style, typeof BUILDER_TYPE_SCOPE> {
|
|
64
|
+
return {
|
|
65
|
+
[BUILDER_TYPE]: BUILDER_TYPE_SCOPE,
|
|
66
|
+
[BUILDER_STATE]: { items: [], lookup: {} },
|
|
67
|
+
[BUILDER_CALLSITE]: callsite,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function createScopeTargetData<Style>(
|
|
72
|
+
scope: ScopeData<Style>,
|
|
73
|
+
slot: SlotData<Style>,
|
|
74
|
+
): ScopeTargetData<Style> {
|
|
75
|
+
return {
|
|
76
|
+
[BUILDER_TYPE]: BUILDER_TYPE_SCOPE_TARGET,
|
|
77
|
+
[BUILDER_SCOPE]: scope,
|
|
78
|
+
[BUILDER_SCOPE_ID]: slot[BUILDER_SLOT_ID],
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function createThemeData(
|
|
83
|
+
callsite: BuilderCallsite | null,
|
|
84
|
+
id: string,
|
|
85
|
+
className: string,
|
|
86
|
+
tokens: readonly StyleTokenOverride[],
|
|
87
|
+
): ThemeData {
|
|
88
|
+
return {
|
|
89
|
+
[BUILDER_TYPE]: BUILDER_TYPE_THEME,
|
|
90
|
+
[BUILDER_STATE]: { items: [], lookup: {} },
|
|
91
|
+
[BUILDER_CALLSITE]: callsite,
|
|
92
|
+
id,
|
|
93
|
+
className,
|
|
94
|
+
tokens,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { StyleTokenOverride } from '../../style/token';
|
|
2
|
+
import type { TraceCallsite } from '../../utils/trace';
|
|
3
|
+
import type {
|
|
4
|
+
BUILDER_CALLSITE,
|
|
5
|
+
BUILDER_SCOPE,
|
|
6
|
+
BUILDER_SCOPE_ID,
|
|
7
|
+
BUILDER_SLOT_ID,
|
|
8
|
+
BUILDER_STATE,
|
|
9
|
+
BUILDER_TYPE,
|
|
10
|
+
BUILDER_TYPE_SCOPE,
|
|
11
|
+
BUILDER_TYPE_SCOPE_TARGET,
|
|
12
|
+
BUILDER_TYPE_SLOT,
|
|
13
|
+
BUILDER_TYPE_SLOT_OVERRIDE,
|
|
14
|
+
BUILDER_TYPE_STYLE,
|
|
15
|
+
BUILDER_TYPE_THEME,
|
|
16
|
+
} from './const';
|
|
17
|
+
import type { BuilderState } from './state';
|
|
18
|
+
|
|
19
|
+
export type BuilderCallsite = TraceCallsite;
|
|
20
|
+
|
|
21
|
+
export type BuilderData<Style = unknown, Type = unknown> = {
|
|
22
|
+
[BUILDER_TYPE]: Type;
|
|
23
|
+
[BUILDER_STATE]: BuilderState<Style>;
|
|
24
|
+
[BUILDER_CALLSITE]: BuilderCallsite | null;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type AnyBuilderData<Style = unknown> =
|
|
28
|
+
| StyleData<Style>
|
|
29
|
+
| SlotData<Style>
|
|
30
|
+
| SlotOverrideData<Style>
|
|
31
|
+
| ScopeData<Style>
|
|
32
|
+
| ScopeTargetData<Style>
|
|
33
|
+
| ThemeData;
|
|
34
|
+
|
|
35
|
+
export type StyleData<Style = unknown> =
|
|
36
|
+
& BuilderData<Style, typeof BUILDER_TYPE_STYLE>
|
|
37
|
+
& {};
|
|
38
|
+
|
|
39
|
+
export type SlotData<Style = unknown> =
|
|
40
|
+
& BuilderData<Style, typeof BUILDER_TYPE_SLOT>
|
|
41
|
+
& { [BUILDER_SLOT_ID]: string; };
|
|
42
|
+
|
|
43
|
+
export type SlotOverrideData<Style = unknown> =
|
|
44
|
+
& BuilderData<Style, typeof BUILDER_TYPE_SLOT_OVERRIDE>
|
|
45
|
+
& { [BUILDER_SLOT_ID]: string; };
|
|
46
|
+
|
|
47
|
+
export type ScopeData<Style = unknown> =
|
|
48
|
+
& BuilderData<Style, typeof BUILDER_TYPE_SCOPE>
|
|
49
|
+
& {
|
|
50
|
+
(slot: SlotData<Style>): ScopeTargetData<Style>;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type ScopeTargetData<Style = unknown> = {
|
|
54
|
+
[BUILDER_TYPE]: typeof BUILDER_TYPE_SCOPE_TARGET;
|
|
55
|
+
[BUILDER_SCOPE]: ScopeData<Style>;
|
|
56
|
+
[BUILDER_SCOPE_ID]: string;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type ThemeData = BuilderData<unknown, typeof BUILDER_TYPE_THEME> & {
|
|
60
|
+
id: string;
|
|
61
|
+
className: string;
|
|
62
|
+
tokens: readonly StyleTokenOverride[];
|
|
63
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { DEV_CONFIG } from '../../config/config/dev';
|
|
2
|
+
import { hashString } from '../../utils/hash';
|
|
3
|
+
import { type TraceCallsite } from '../../utils/trace';
|
|
4
|
+
|
|
5
|
+
export const LOC_LINE = 0;
|
|
6
|
+
export const LOC_COL = 1;
|
|
7
|
+
|
|
8
|
+
export const TRACE_STYLE = 0;
|
|
9
|
+
export const TRACE_VALUE = 1;
|
|
10
|
+
|
|
11
|
+
export const LABEL_SHORT = 0;
|
|
12
|
+
export const LABEL_LONG = 1;
|
|
13
|
+
export const LABEL_FILE = 2;
|
|
14
|
+
|
|
15
|
+
export type DebugLoc = [
|
|
16
|
+
line: number,
|
|
17
|
+
column: number,
|
|
18
|
+
trace?: number,
|
|
19
|
+
sourceUrl?: string,
|
|
20
|
+
sourceContent?: string,
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
type DebugLabel = [
|
|
24
|
+
short: string,
|
|
25
|
+
long: string,
|
|
26
|
+
file: string,
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
export type DebugData = {
|
|
30
|
+
$$debug: true;
|
|
31
|
+
loc: DebugLoc;
|
|
32
|
+
label: DebugLabel;
|
|
33
|
+
fields?: Record<string, DebugLoc | Record<number, DebugLoc>>;
|
|
34
|
+
vars?: Record<string, string>;
|
|
35
|
+
sourceUrl: string;
|
|
36
|
+
code?: string;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export function isDebugData(value: unknown): value is DebugData {
|
|
40
|
+
if (!value || typeof value !== 'object') return false;
|
|
41
|
+
|
|
42
|
+
const data = value as Partial<DebugData>;
|
|
43
|
+
return data.$$debug === true && Array.isArray(data.loc) && Array.isArray(data.label);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function getDebugCallsiteId(debug: DebugData) {
|
|
47
|
+
const label = debug.label[LABEL_SHORT] || debug.label[LABEL_LONG];
|
|
48
|
+
|
|
49
|
+
if (!label) return null;
|
|
50
|
+
|
|
51
|
+
const hash = debug.sourceUrl + '\n' + debug.loc[LOC_LINE] + ':' + debug.loc[LOC_COL] + '\n' +
|
|
52
|
+
(debug.label[LABEL_LONG] || label);
|
|
53
|
+
|
|
54
|
+
return label + '_' + hashString(hash);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function getTraceCallsiteId(callsite: TraceCallsite) {
|
|
58
|
+
const hash = callsite.filePath + '\n' + callsite.line + ':' + callsite.column;
|
|
59
|
+
|
|
60
|
+
return hashString(hash);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function getDebugCallsite(debug: DebugData): TraceCallsite {
|
|
64
|
+
return createDebugCallsite(debug.loc, debug);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function getDebugFieldCallsite(
|
|
68
|
+
debug: DebugData | null,
|
|
69
|
+
field: string,
|
|
70
|
+
): TraceCallsite | null {
|
|
71
|
+
if (!debug) return null;
|
|
72
|
+
|
|
73
|
+
const loc = getDebugFieldLoc(debug, field);
|
|
74
|
+
|
|
75
|
+
return loc ? createDebugCallsite(loc, debug) : null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function getDebugFieldVarName(
|
|
79
|
+
debug: DebugData | null,
|
|
80
|
+
field: string,
|
|
81
|
+
) {
|
|
82
|
+
return debug?.vars?.[field] ?? null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function getDebugFieldLoc(
|
|
86
|
+
debug: DebugData | null,
|
|
87
|
+
field: string,
|
|
88
|
+
) {
|
|
89
|
+
const loc = debug?.fields?.[field];
|
|
90
|
+
if (!loc) return null;
|
|
91
|
+
if (Array.isArray(loc)) return loc;
|
|
92
|
+
|
|
93
|
+
const trace = DEV_CONFIG.sourcemapLocationMode === 'value'
|
|
94
|
+
? TRACE_VALUE
|
|
95
|
+
: TRACE_STYLE;
|
|
96
|
+
|
|
97
|
+
return loc[trace] ?? loc[TRACE_STYLE] ?? loc[TRACE_VALUE] ?? null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function createDebugCallsite(loc: DebugLoc, debug: DebugData): TraceCallsite {
|
|
101
|
+
const [line, column] = loc;
|
|
102
|
+
const sourceUrl = loc[3] ?? debug.sourceUrl;
|
|
103
|
+
const sourceContent = loc[4] ?? debug.code;
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
stack: `Error\n at ${sourceUrl}:${line}:${column}`,
|
|
107
|
+
filePath: sourceUrl,
|
|
108
|
+
sourceUrl,
|
|
109
|
+
sourceContent,
|
|
110
|
+
line,
|
|
111
|
+
column,
|
|
112
|
+
};
|
|
113
|
+
}
|