@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,130 @@
|
|
|
1
|
+
import { globalData } from '../../utils/global';
|
|
2
|
+
import { createSourceMapComment, type SourcemapRule } from '../sourcemap';
|
|
3
|
+
import type { SheetRule } from '../types';
|
|
4
|
+
import { createStyleTag, insertStyleTagAfter, insertStyleTagAtTop } from '../utils';
|
|
5
|
+
|
|
6
|
+
export type DevRuleTag = {
|
|
7
|
+
tag: HTMLStyleElement;
|
|
8
|
+
rules: SourcemapRule[];
|
|
9
|
+
sourceMapNode: Text | null;
|
|
10
|
+
insertBeforeNode: Text | null;
|
|
11
|
+
count: number;
|
|
12
|
+
updateSourceMap(): void;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const SOURCEMAP_TAGS = globalData<DevRuleTag[]>(
|
|
16
|
+
'sheet.dev.sourcemapTags',
|
|
17
|
+
() => [],
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export function getDevSourcemapTags() {
|
|
21
|
+
return SOURCEMAP_TAGS;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function refreshDevSourcemapTags() {
|
|
25
|
+
for (let i = 0, len = SOURCEMAP_TAGS.length; i < len; i++) {
|
|
26
|
+
SOURCEMAP_TAGS[i].updateSourceMap();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function pruneDevSourcemapTags() {
|
|
31
|
+
for (let i = SOURCEMAP_TAGS.length - 1; i >= 0; i--) {
|
|
32
|
+
if (!SOURCEMAP_TAGS[i].tag.parentNode) {
|
|
33
|
+
SOURCEMAP_TAGS.splice(i, 1);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function createDevTag(
|
|
39
|
+
document: Document,
|
|
40
|
+
previous: HTMLStyleElement | null,
|
|
41
|
+
options: {
|
|
42
|
+
sourcemap: boolean;
|
|
43
|
+
nonce?: string | null;
|
|
44
|
+
className?: string;
|
|
45
|
+
before?: HTMLStyleElement | Text | null;
|
|
46
|
+
top?: boolean;
|
|
47
|
+
wrapper?: {
|
|
48
|
+
before: string;
|
|
49
|
+
after: string;
|
|
50
|
+
sourceMapLineOffset: number;
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
): DevRuleTag {
|
|
54
|
+
const tag = createStyleTag(document, options.className ?? 'rules', options.nonce);
|
|
55
|
+
const wrapperEndNode = options.wrapper
|
|
56
|
+
? document.createTextNode(options.wrapper.after)
|
|
57
|
+
: null;
|
|
58
|
+
const sourceMapNode = options.sourcemap ? document.createTextNode('') : null;
|
|
59
|
+
|
|
60
|
+
if (options.wrapper) tag.appendChild(document.createTextNode(options.wrapper.before));
|
|
61
|
+
if (wrapperEndNode) tag.appendChild(wrapperEndNode);
|
|
62
|
+
if (sourceMapNode) tag.appendChild(sourceMapNode);
|
|
63
|
+
|
|
64
|
+
if (options.before) {
|
|
65
|
+
options.before.parentNode?.insertBefore(tag, options.before);
|
|
66
|
+
} else if (options.top && (!previous || !previous.parentNode)) {
|
|
67
|
+
insertStyleTagAtTop(document, tag);
|
|
68
|
+
} else {
|
|
69
|
+
insertStyleTagAfter(document, tag, previous);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const item: DevRuleTag = {
|
|
73
|
+
tag,
|
|
74
|
+
rules: [],
|
|
75
|
+
sourceMapNode,
|
|
76
|
+
insertBeforeNode: wrapperEndNode ?? sourceMapNode,
|
|
77
|
+
count: 0,
|
|
78
|
+
updateSourceMap() {
|
|
79
|
+
if (!sourceMapNode) return;
|
|
80
|
+
|
|
81
|
+
if (sourceMapNode.parentNode !== tag) {
|
|
82
|
+
tag.appendChild(sourceMapNode);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
sourceMapNode.data = '\n' + createSourceMapComment(
|
|
86
|
+
getSourceMapRules(item.rules, options.wrapper?.sourceMapLineOffset ?? 0),
|
|
87
|
+
);
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
if (sourceMapNode) {
|
|
92
|
+
SOURCEMAP_TAGS.push(item);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return item;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function insertDevRule(
|
|
99
|
+
document: Document,
|
|
100
|
+
item: DevRuleTag,
|
|
101
|
+
fragment: DocumentFragment,
|
|
102
|
+
css: string,
|
|
103
|
+
rule: SheetRule | null,
|
|
104
|
+
) {
|
|
105
|
+
fragment.appendChild(document.createTextNode(css + '\n'));
|
|
106
|
+
|
|
107
|
+
item.rules.push({
|
|
108
|
+
css,
|
|
109
|
+
callsite: rule?.callsite ?? null,
|
|
110
|
+
debug: rule?.debug ?? null,
|
|
111
|
+
debugField: rule?.debugField ?? null,
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
item.count++;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function getSourceMapRules(
|
|
118
|
+
rules: SourcemapRule[],
|
|
119
|
+
offset: number,
|
|
120
|
+
) {
|
|
121
|
+
if (!offset) return rules;
|
|
122
|
+
|
|
123
|
+
const output: SourcemapRule[] = [];
|
|
124
|
+
|
|
125
|
+
for (let i = 0; i < offset; i++) {
|
|
126
|
+
output.push({ css: '', callsite: null });
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return output.concat(rules);
|
|
130
|
+
}
|
package/sheet/index.ts
ADDED
package/sheet/prod.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { getLayerBlockCss, getLayerOrderCss } from '../atomic/layer';
|
|
2
|
+
import { CSS_CONFIG, CSS_CONFIG_DEFAULT } from '../config/config/css';
|
|
3
|
+
import type { SheetOptions, StyleSheet } from './types';
|
|
4
|
+
import {
|
|
5
|
+
createNoopSheet,
|
|
6
|
+
createSheetLayerState,
|
|
7
|
+
createStyleTag,
|
|
8
|
+
getSheetRulePriority,
|
|
9
|
+
insertStyleTagAfter,
|
|
10
|
+
normalizeRule,
|
|
11
|
+
resolveDocument,
|
|
12
|
+
} from './utils';
|
|
13
|
+
|
|
14
|
+
export function createProdSheet(options: SheetOptions = {}): StyleSheet {
|
|
15
|
+
const document = resolveDocument(options.document);
|
|
16
|
+
|
|
17
|
+
if (!document) return createNoopSheet();
|
|
18
|
+
|
|
19
|
+
const inserted = new Set<string>();
|
|
20
|
+
const layerState = createSheetLayerState();
|
|
21
|
+
|
|
22
|
+
let activeLayers: readonly string[] = CSS_CONFIG.layers ?? CSS_CONFIG_DEFAULT.layers ?? [];
|
|
23
|
+
|
|
24
|
+
let layerText = '';
|
|
25
|
+
let layerTag: HTMLStyleElement | null = null;
|
|
26
|
+
let ruleTag: HTMLStyleElement | null = null;
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
updateLayers(layers) {
|
|
30
|
+
activeLayers = layers;
|
|
31
|
+
|
|
32
|
+
const next = getLayerOrderCss(layers, layerState.getNames());
|
|
33
|
+
if (next === layerText) return;
|
|
34
|
+
|
|
35
|
+
layerText = next;
|
|
36
|
+
layerTag = ensureLayerTag(document, layerTag, options.nonce);
|
|
37
|
+
layerTag.textContent = next;
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
insert(rule) {
|
|
41
|
+
const rawCss = normalizeRule(rule);
|
|
42
|
+
const ruleKey = typeof rule === 'string' ? null : rule.key;
|
|
43
|
+
|
|
44
|
+
if (ruleKey && inserted.has(ruleKey)) return;
|
|
45
|
+
|
|
46
|
+
const priority = typeof rule === 'string' ? null : rule.priority;
|
|
47
|
+
const layerName = layerState.getName(getSheetRulePriority(priority));
|
|
48
|
+
|
|
49
|
+
const nextLayerText = getLayerOrderCss(
|
|
50
|
+
activeLayers,
|
|
51
|
+
layerState.getNames(),
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
if (nextLayerText !== layerText) {
|
|
55
|
+
layerText = nextLayerText;
|
|
56
|
+
layerTag = ensureLayerTag(document, layerTag, options.nonce);
|
|
57
|
+
layerTag.textContent = nextLayerText;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const css = getLayerBlockCss(layerName, rawCss);
|
|
61
|
+
const key = typeof rule === 'string' ? css : ruleKey;
|
|
62
|
+
|
|
63
|
+
if (key && inserted.has(key)) return;
|
|
64
|
+
if (key) inserted.add(key);
|
|
65
|
+
|
|
66
|
+
const activeLayerTag = ensureLayerTag(document, layerTag, options.nonce);
|
|
67
|
+
|
|
68
|
+
layerTag = activeLayerTag;
|
|
69
|
+
|
|
70
|
+
if (!ruleTag) {
|
|
71
|
+
ruleTag = createStyleTag(document, 'rules', options.nonce);
|
|
72
|
+
insertStyleTagAfter(document, ruleTag, activeLayerTag);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
insertRule(ruleTag, css);
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
flush() {},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function ensureLayerTag(
|
|
83
|
+
document: Document,
|
|
84
|
+
tag: HTMLStyleElement | null,
|
|
85
|
+
nonce?: string | null,
|
|
86
|
+
) {
|
|
87
|
+
if (tag) return tag;
|
|
88
|
+
|
|
89
|
+
const next = createStyleTag(document, 'layers', nonce);
|
|
90
|
+
|
|
91
|
+
insertStyleTagAfter(document, next, null);
|
|
92
|
+
|
|
93
|
+
return next;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function insertRule(tag: HTMLStyleElement, css: string) {
|
|
97
|
+
const sheet = tag.sheet;
|
|
98
|
+
|
|
99
|
+
if (sheet) {
|
|
100
|
+
try {
|
|
101
|
+
sheet.insertRule(css, sheet.cssRules.length);
|
|
102
|
+
return;
|
|
103
|
+
} catch {
|
|
104
|
+
// Keep prod resilient. Invalid CSS should not break rendering.
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
tag.appendChild(tag.ownerDocument.createTextNode(css));
|
|
109
|
+
}
|
package/sheet/sheet.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DEV_CONFIG } from '../config/config/dev';
|
|
2
|
+
import { createDevSheet } from './dev';
|
|
3
|
+
import { createProdSheet } from './prod';
|
|
4
|
+
import type { SheetOptions } from './types';
|
|
5
|
+
|
|
6
|
+
export function createStyleSheet(options: SheetOptions = {}) {
|
|
7
|
+
const dev = options.dev ?? DEV_CONFIG.isDev;
|
|
8
|
+
|
|
9
|
+
return dev ? createDevSheet(options) : createProdSheet(options);
|
|
10
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type DebugData, getDebugFieldLoc, LOC_COL, LOC_LINE } from '../builder/data/debug';
|
|
2
|
+
import { normalizeCallsiteSourceUrl } from '../utils/trace';
|
|
3
|
+
import type { SheetCallsite } from './types';
|
|
4
|
+
import { createSourceMapComment as createSourceMapCommentBase } from './utils/sourcemap';
|
|
5
|
+
|
|
6
|
+
export type SourcemapRule = {
|
|
7
|
+
css: string;
|
|
8
|
+
callsite: SheetCallsite | null;
|
|
9
|
+
debug?: DebugData | null;
|
|
10
|
+
debugField?: string | null;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export function getRuleCallsite(
|
|
14
|
+
callsite: SheetCallsite | null | undefined,
|
|
15
|
+
debug: DebugData | null | undefined,
|
|
16
|
+
debugField?: string | null,
|
|
17
|
+
): SheetCallsite | null {
|
|
18
|
+
if (debug && debugField) {
|
|
19
|
+
const loc = getDebugFieldLoc(debug, debugField);
|
|
20
|
+
|
|
21
|
+
if (loc) {
|
|
22
|
+
return normalizeRuleCallsite({
|
|
23
|
+
filePath: loc[3] ?? debug.sourceUrl,
|
|
24
|
+
sourceUrl: loc[3] ?? debug.sourceUrl,
|
|
25
|
+
sourceContent: loc[4] ?? debug.code,
|
|
26
|
+
line: loc[LOC_LINE],
|
|
27
|
+
column: loc[LOC_COL],
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (callsite) return normalizeRuleCallsite(callsite);
|
|
33
|
+
|
|
34
|
+
if (debug) {
|
|
35
|
+
return normalizeRuleCallsite({
|
|
36
|
+
filePath: debug.sourceUrl,
|
|
37
|
+
sourceUrl: debug.sourceUrl,
|
|
38
|
+
sourceContent: debug.code,
|
|
39
|
+
line: debug.loc[LOC_LINE],
|
|
40
|
+
column: debug.loc[LOC_COL],
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return callsite || null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function normalizeRuleCallsite(callsite: SheetCallsite): SheetCallsite {
|
|
48
|
+
return {
|
|
49
|
+
...callsite,
|
|
50
|
+
filePath: normalizeCallsiteSourceUrl(callsite.filePath),
|
|
51
|
+
sourceUrl: callsite.sourceUrl
|
|
52
|
+
? normalizeCallsiteSourceUrl(callsite.sourceUrl)
|
|
53
|
+
: callsite.sourceUrl,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function createSourceMapComment(
|
|
58
|
+
rules: SourcemapRule[],
|
|
59
|
+
) {
|
|
60
|
+
return createSourceMapCommentBase(
|
|
61
|
+
rules.map((rule) => ({
|
|
62
|
+
css: rule.css,
|
|
63
|
+
source: getSourcemapRuleCallsite(rule),
|
|
64
|
+
})),
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function getSourcemapRuleCallsite(rule: SourcemapRule) {
|
|
69
|
+
return getRuleCallsite(rule.callsite, rule.debug, rule.debugField);
|
|
70
|
+
}
|
package/sheet/types.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { LayerPriority } from '../atomic/layer';
|
|
2
|
+
import type { DebugData } from '../builder/data/debug';
|
|
3
|
+
import type { TraceCallsite } from '../utils/trace';
|
|
4
|
+
|
|
5
|
+
export type SheetCallsite = Pick<TraceCallsite, 'filePath' | 'sourceUrl' | 'sourceContent' | 'line' | 'column'>;
|
|
6
|
+
|
|
7
|
+
export type SheetRule = {
|
|
8
|
+
css: string;
|
|
9
|
+
key?: string | null;
|
|
10
|
+
priority?: LayerPriority | null;
|
|
11
|
+
callsite?: SheetCallsite | null;
|
|
12
|
+
debug?: DebugData | null;
|
|
13
|
+
debugField?: string | null;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type SheetOptions = {
|
|
17
|
+
document?: Document | null;
|
|
18
|
+
dev?: boolean;
|
|
19
|
+
maxRules?: number;
|
|
20
|
+
nonce?: string | null;
|
|
21
|
+
sourcemap?: boolean;
|
|
22
|
+
tagName?: string;
|
|
23
|
+
top?: boolean;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type StyleSheet = {
|
|
27
|
+
updateLayers(layers: readonly string[]): void;
|
|
28
|
+
insert(rule: SheetRule | string): void;
|
|
29
|
+
flush(): void;
|
|
30
|
+
destroy?(): void;
|
|
31
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { DEV_CONFIG } from '../../config/config/dev';
|
|
2
|
+
|
|
3
|
+
export function resolveDocument(documentOverride?: Document | null) {
|
|
4
|
+
if (documentOverride !== undefined) return documentOverride;
|
|
5
|
+
if (typeof document === 'undefined') return null;
|
|
6
|
+
|
|
7
|
+
return document;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function createStyleTag(
|
|
11
|
+
document: Document,
|
|
12
|
+
name: string,
|
|
13
|
+
nonce = DEV_CONFIG.sheetStyleTagNonce,
|
|
14
|
+
) {
|
|
15
|
+
const tag = document.createElement('style');
|
|
16
|
+
|
|
17
|
+
tag.setAttribute('data-css-sheet', name);
|
|
18
|
+
|
|
19
|
+
if (nonce) tag.setAttribute('nonce', nonce);
|
|
20
|
+
|
|
21
|
+
return tag;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function appendStyleTag(
|
|
25
|
+
document: Document,
|
|
26
|
+
tag: HTMLStyleElement,
|
|
27
|
+
) {
|
|
28
|
+
const head = document.head || document.getElementsByTagName('head')[0] || document.documentElement;
|
|
29
|
+
|
|
30
|
+
head.appendChild(tag);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function insertStyleTagAfter(
|
|
34
|
+
document: Document,
|
|
35
|
+
tag: HTMLStyleElement,
|
|
36
|
+
previous: HTMLStyleElement | null,
|
|
37
|
+
) {
|
|
38
|
+
if (!previous || !previous.parentNode) {
|
|
39
|
+
appendStyleTag(document, tag);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
previous.parentNode.insertBefore(tag, previous.nextSibling);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function insertStyleTagAtTop(
|
|
47
|
+
document: Document,
|
|
48
|
+
tag: HTMLStyleElement,
|
|
49
|
+
) {
|
|
50
|
+
const head = document.head || document.getElementsByTagName('head')[0] || document.documentElement;
|
|
51
|
+
const first = getFirstCssSheetTag(head);
|
|
52
|
+
|
|
53
|
+
if (first) {
|
|
54
|
+
head.insertBefore(tag, first);
|
|
55
|
+
} else {
|
|
56
|
+
head.appendChild(tag);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function getFirstCssSheetTag(head: HTMLElement) {
|
|
61
|
+
const nodes = head.childNodes;
|
|
62
|
+
|
|
63
|
+
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
64
|
+
const node = nodes[i] as HTMLElement;
|
|
65
|
+
|
|
66
|
+
if (typeof node.getAttribute !== 'function') continue;
|
|
67
|
+
if (node.getAttribute('data-css-sheet')) return node;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createLayerPool, LayerDefaultNamespace, LayerDefaultPriority, type LayerPriority } from '../../atomic/layer';
|
|
2
|
+
import { CSS_CONFIG } from '../../config/config/css';
|
|
3
|
+
|
|
4
|
+
export function createSheetLayerState() {
|
|
5
|
+
return createLayerPool(getStyleLayerName());
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function getSheetRulePriority(priority: LayerPriority | null | undefined) {
|
|
9
|
+
return priority ?? LayerDefaultPriority;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function getStyleLayerName() {
|
|
13
|
+
return CSS_CONFIG.layerNamespace || LayerDefaultNamespace;
|
|
14
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { SIDECAR_URL_GLOBAL_SYMBOL } from '../../config/utils';
|
|
2
|
+
import { normalizeCallsiteSourceUrl } from '../../utils/trace';
|
|
3
|
+
|
|
4
|
+
export type SourceMapSource = {
|
|
5
|
+
filePath: string;
|
|
6
|
+
sourceUrl?: string;
|
|
7
|
+
sourceContent?: string;
|
|
8
|
+
line: number;
|
|
9
|
+
column: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type SourceMapRule = {
|
|
13
|
+
css: string;
|
|
14
|
+
source: SourceMapSource | null;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type SourceEntry = {
|
|
18
|
+
filePath: string;
|
|
19
|
+
sourceIndex: number;
|
|
20
|
+
sourceContent?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const VLQ_BASE_SHIFT = 5;
|
|
24
|
+
const VLQ_BASE = 1 << VLQ_BASE_SHIFT;
|
|
25
|
+
const VLQ_BASE_MASK = VLQ_BASE - 1;
|
|
26
|
+
const VLQ_CONTINUATION_BIT = VLQ_BASE;
|
|
27
|
+
const BASE64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
28
|
+
|
|
29
|
+
const SOURCE_URL_PREFIX = 'source://';
|
|
30
|
+
|
|
31
|
+
export function createSourceMapComment(
|
|
32
|
+
rules: SourceMapRule[],
|
|
33
|
+
) {
|
|
34
|
+
const sources: SourceEntry[] = [];
|
|
35
|
+
const sourceLookup: Record<string, SourceEntry> = Object.create(null);
|
|
36
|
+
|
|
37
|
+
let generatedLine = 0;
|
|
38
|
+
let previousSource = 0;
|
|
39
|
+
let previousOriginalLine = 0;
|
|
40
|
+
let previousOriginalColumn = 0;
|
|
41
|
+
const mappingLines: string[] = [];
|
|
42
|
+
|
|
43
|
+
for (let i = 0, len = rules.length; i < len; i++) {
|
|
44
|
+
const rule = rules[i];
|
|
45
|
+
const sourceData = rule.source;
|
|
46
|
+
let mapping = '';
|
|
47
|
+
|
|
48
|
+
if (sourceData) {
|
|
49
|
+
const source = getSource(
|
|
50
|
+
sources,
|
|
51
|
+
sourceLookup,
|
|
52
|
+
getSourceMapSourceUrl(sourceData),
|
|
53
|
+
sourceData.sourceContent,
|
|
54
|
+
);
|
|
55
|
+
const originalLine = Math.max(sourceData.line - 1, 0);
|
|
56
|
+
const originalColumn = Math.max(sourceData.column - 1, 0);
|
|
57
|
+
|
|
58
|
+
mapping += encodeVlq(0);
|
|
59
|
+
mapping += encodeVlq(source.sourceIndex - previousSource);
|
|
60
|
+
mapping += encodeVlq(originalLine - previousOriginalLine);
|
|
61
|
+
mapping += encodeVlq(originalColumn - previousOriginalColumn);
|
|
62
|
+
|
|
63
|
+
previousSource = source.sourceIndex;
|
|
64
|
+
previousOriginalLine = originalLine;
|
|
65
|
+
previousOriginalColumn = originalColumn;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
mappingLines[generatedLine] = mapping;
|
|
69
|
+
|
|
70
|
+
const lineCount = getLineCount(rule.css);
|
|
71
|
+
|
|
72
|
+
for (let j = 1; j < lineCount; j++) {
|
|
73
|
+
mappingLines[generatedLine + j] = '';
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
generatedLine += lineCount;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (!sources.length) return '';
|
|
80
|
+
|
|
81
|
+
const data = {
|
|
82
|
+
version: 3,
|
|
83
|
+
sources: sources.map((source) => source.filePath),
|
|
84
|
+
sourcesContent: sources.some((source) => source.sourceContent !== undefined)
|
|
85
|
+
? sources.map((source) => source.sourceContent ?? null)
|
|
86
|
+
: undefined,
|
|
87
|
+
names: [],
|
|
88
|
+
mappings: mappingLines.join(';'),
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
return '/*# sourceMappingURL=data:application/json;charset=utf-8;base64,' +
|
|
92
|
+
encodeBase64(JSON.stringify(data)) +
|
|
93
|
+
' */';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function encodeBase64(text: string) {
|
|
97
|
+
const bytes = new TextEncoder().encode(text);
|
|
98
|
+
let binary = '';
|
|
99
|
+
|
|
100
|
+
for (let i = 0, len = bytes.length; i < len; i++) {
|
|
101
|
+
binary += String.fromCharCode(bytes[i]);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return btoa(binary);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function getSource(
|
|
108
|
+
sources: SourceEntry[],
|
|
109
|
+
sourceLookup: Record<string, SourceEntry>,
|
|
110
|
+
filePath: string,
|
|
111
|
+
sourceContent?: string,
|
|
112
|
+
) {
|
|
113
|
+
let source = sourceLookup[filePath];
|
|
114
|
+
|
|
115
|
+
if (source) {
|
|
116
|
+
if (source.sourceContent === undefined) {
|
|
117
|
+
source.sourceContent = sourceContent;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return source;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
source = {
|
|
124
|
+
filePath,
|
|
125
|
+
sourceIndex: sources.length,
|
|
126
|
+
sourceContent,
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
sources.push(source);
|
|
130
|
+
sourceLookup[filePath] = source;
|
|
131
|
+
|
|
132
|
+
return source;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function normalizeSourcePath(filePath: string) {
|
|
136
|
+
filePath = normalizeCallsiteSourceUrl(filePath);
|
|
137
|
+
|
|
138
|
+
const atIndex = filePath.indexOf('/at ');
|
|
139
|
+
|
|
140
|
+
if (atIndex !== -1) {
|
|
141
|
+
return filePath.slice(atIndex + '/at '.length);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return filePath.replace(/^at\s+/, '');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function getSourceMapSourceUrl(sourceData: SourceMapSource) {
|
|
148
|
+
const sourceUrl = sourceData.sourceUrl || sourceData.filePath;
|
|
149
|
+
|
|
150
|
+
if (sourceData.sourceContent !== undefined) {
|
|
151
|
+
return normalizeSourcePath(sourceUrl);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return normalizeSourcePath(resolveSidecarSourceUrl(sourceUrl));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function resolveSidecarSourceUrl(sourceUrl: string) {
|
|
158
|
+
const sidecarUrl = getSidecarUrl();
|
|
159
|
+
if (!sidecarUrl) return sourceUrl;
|
|
160
|
+
|
|
161
|
+
const sourcePath = getSourceUrlPath(sourceUrl);
|
|
162
|
+
return joinSourceUrl(sidecarUrl, sourcePath);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function getSidecarUrl() {
|
|
166
|
+
const value = (globalThis as Record<symbol, unknown>)[
|
|
167
|
+
Symbol.for(SIDECAR_URL_GLOBAL_SYMBOL)
|
|
168
|
+
];
|
|
169
|
+
|
|
170
|
+
return typeof value === 'string' && value ? value : null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function getSourceUrlPath(sourceUrl: string) {
|
|
174
|
+
if (sourceUrl.startsWith(SOURCE_URL_PREFIX)) {
|
|
175
|
+
return sourceUrl.slice(SOURCE_URL_PREFIX.length).replace(/^\/+/, '');
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
try {
|
|
179
|
+
return new URL(sourceUrl).pathname.replace(/^\/+/, '');
|
|
180
|
+
} catch {
|
|
181
|
+
return sourceUrl
|
|
182
|
+
.replace(/^[a-zA-Z][a-zA-Z\d+.-]*:\/+/, '')
|
|
183
|
+
.replace(/^\/+/, '');
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function joinSourceUrl(baseUrl: string, sourcePath: string) {
|
|
188
|
+
const base = baseUrl.replace(/\/+$/, '');
|
|
189
|
+
const path = sourcePath.replace(/^\/+/, '');
|
|
190
|
+
|
|
191
|
+
return path ? `${base}/${path}` : base;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function getLineCount(css: string) {
|
|
195
|
+
let count = 1;
|
|
196
|
+
|
|
197
|
+
for (let i = 0, len = css.length; i < len; i++) {
|
|
198
|
+
if (css.charCodeAt(i) === 10) count++;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return count;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function encodeVlq(value: number) {
|
|
205
|
+
let vlq = value < 0 ? ((-value) << 1) + 1 : value << 1;
|
|
206
|
+
let encoded = '';
|
|
207
|
+
|
|
208
|
+
do {
|
|
209
|
+
let digit = vlq & VLQ_BASE_MASK;
|
|
210
|
+
|
|
211
|
+
vlq >>>= VLQ_BASE_SHIFT;
|
|
212
|
+
|
|
213
|
+
if (vlq > 0) {
|
|
214
|
+
digit |= VLQ_CONTINUATION_BIT;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
encoded += BASE64[digit];
|
|
218
|
+
} while (vlq > 0);
|
|
219
|
+
|
|
220
|
+
return encoded;
|
|
221
|
+
}
|
package/style/index.ts
ADDED