@fluixi-css/core 0.1.0-next.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/LICENSE +21 -0
- package/README.md +52 -0
- package/base.css +4 -0
- package/components.css +1 -0
- package/dist/base.css +4 -0
- package/dist/components.css +1 -0
- package/dist/index.css +2 -0
- package/dist/package.json +139 -0
- package/dist/reset.css +168 -0
- package/dist/src/ast.d.ts +298 -0
- package/dist/src/ast.js +2240 -0
- package/dist/src/ast.js.map +1 -0
- package/dist/src/commons/constants.d.ts +1193 -0
- package/dist/src/commons/constants.js +1323 -0
- package/dist/src/commons/constants.js.map +1 -0
- package/dist/src/commons/helper.d.ts +1298 -0
- package/dist/src/commons/helper.js +1310 -0
- package/dist/src/commons/helper.js.map +1 -0
- package/dist/src/commons/index.d.ts +3 -0
- package/dist/src/commons/index.js +4 -0
- package/dist/src/commons/index.js.map +1 -0
- package/dist/src/commons/properties.d.ts +1431 -0
- package/dist/src/commons/properties.js +2855 -0
- package/dist/src/commons/properties.js.map +1 -0
- package/dist/src/commons/types.d.ts +359 -0
- package/dist/src/commons/types.js +4 -0
- package/dist/src/commons/types.js.map +1 -0
- package/dist/src/components/avatar/index.d.ts +19 -0
- package/dist/src/components/avatar/index.js +22 -0
- package/dist/src/components/avatar/index.js.map +1 -0
- package/dist/src/components/button/index.d.ts +48 -0
- package/dist/src/components/button/index.js +51 -0
- package/dist/src/components/button/index.js.map +1 -0
- package/dist/src/components/card/index.d.ts +44 -0
- package/dist/src/components/card/index.js +47 -0
- package/dist/src/components/card/index.js.map +1 -0
- package/dist/src/components/checkbox/index.d.ts +69 -0
- package/dist/src/components/checkbox/index.js +80 -0
- package/dist/src/components/checkbox/index.js.map +1 -0
- package/dist/src/components/daterangepicker/index.d.ts +147 -0
- package/dist/src/components/daterangepicker/index.js +150 -0
- package/dist/src/components/daterangepicker/index.js.map +1 -0
- package/dist/src/components/dialog/index.d.ts +71 -0
- package/dist/src/components/dialog/index.js +74 -0
- package/dist/src/components/dialog/index.js.map +1 -0
- package/dist/src/components/drawer/index.d.ts +26 -0
- package/dist/src/components/drawer/index.js +29 -0
- package/dist/src/components/drawer/index.js.map +1 -0
- package/dist/src/components/dropdown/index.d.ts +101 -0
- package/dist/src/components/dropdown/index.js +104 -0
- package/dist/src/components/dropdown/index.js.map +1 -0
- package/dist/src/components/forms/index.d.ts +58 -0
- package/dist/src/components/forms/index.js +62 -0
- package/dist/src/components/forms/index.js.map +1 -0
- package/dist/src/components/index.d.ts +1228 -0
- package/dist/src/components/index.js +64 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/components/layout/index.d.ts +28 -0
- package/dist/src/components/layout/index.js +33 -0
- package/dist/src/components/layout/index.js.map +1 -0
- package/dist/src/components/list/index.d.ts +65 -0
- package/dist/src/components/list/index.js +68 -0
- package/dist/src/components/list/index.js.map +1 -0
- package/dist/src/components/popover/index.d.ts +79 -0
- package/dist/src/components/popover/index.js +82 -0
- package/dist/src/components/popover/index.js.map +1 -0
- package/dist/src/components/radio/index.d.ts +77 -0
- package/dist/src/components/radio/index.js +80 -0
- package/dist/src/components/radio/index.js.map +1 -0
- package/dist/src/components/select/index.d.ts +102 -0
- package/dist/src/components/select/index.js +105 -0
- package/dist/src/components/select/index.js.map +1 -0
- package/dist/src/components/sidenav/index.d.ts +98 -0
- package/dist/src/components/sidenav/index.js +101 -0
- package/dist/src/components/sidenav/index.js.map +1 -0
- package/dist/src/components/table/index.d.ts +95 -0
- package/dist/src/components/table/index.js +98 -0
- package/dist/src/components/table/index.js.map +1 -0
- package/dist/src/constants.d.ts +3 -0
- package/dist/src/constants.js +29 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/css-ast.d.ts +48 -0
- package/dist/src/css-ast.js +2 -0
- package/dist/src/css-ast.js.map +1 -0
- package/dist/src/css-generator.d.ts +29 -0
- package/dist/src/css-generator.js +104 -0
- package/dist/src/css-generator.js.map +1 -0
- package/dist/src/css-helpers.d.ts +76 -0
- package/dist/src/css-helpers.js +272 -0
- package/dist/src/css-helpers.js.map +1 -0
- package/dist/src/css-lexer.d.ts +48 -0
- package/dist/src/css-lexer.js +255 -0
- package/dist/src/css-lexer.js.map +1 -0
- package/dist/src/css-parser.cjs +2047 -0
- package/dist/src/css-parser.cjs.map +1 -0
- package/dist/src/css-parser.d.ts +100 -0
- package/dist/src/css-parser.js +1098 -0
- package/dist/src/css-parser.js.map +1 -0
- package/dist/src/css-parser.mjs +2028 -0
- package/dist/src/css-parser.mjs.map +1 -0
- package/dist/src/design-system.d.ts +210 -0
- package/dist/src/design-system.js +1034 -0
- package/dist/src/design-system.js.map +1 -0
- package/dist/src/engine/ast.d.ts +44 -0
- package/dist/src/engine/ast.js +92 -0
- package/dist/src/engine/ast.js.map +1 -0
- package/dist/src/engine/atom.d.ts +74 -0
- package/dist/src/engine/atom.js +227 -0
- package/dist/src/engine/atom.js.map +1 -0
- package/dist/src/engine/compile.d.ts +5 -0
- package/dist/src/engine/compile.js +79 -0
- package/dist/src/engine/compile.js.map +1 -0
- package/dist/src/engine/defaults.d.ts +2 -0
- package/dist/src/engine/defaults.js +14 -0
- package/dist/src/engine/defaults.js.map +1 -0
- package/dist/src/engine/directives.d.ts +2 -0
- package/dist/src/engine/directives.js +191 -0
- package/dist/src/engine/directives.js.map +1 -0
- package/dist/src/engine/index.d.ts +41 -0
- package/dist/src/engine/index.js +88 -0
- package/dist/src/engine/index.js.map +1 -0
- package/dist/src/engine/registry.d.ts +46 -0
- package/dist/src/engine/registry.js +49 -0
- package/dist/src/engine/registry.js.map +1 -0
- package/dist/src/engine/scanner.d.ts +1 -0
- package/dist/src/engine/scanner.js +45 -0
- package/dist/src/engine/scanner.js.map +1 -0
- package/dist/src/engine/source.d.ts +12 -0
- package/dist/src/engine/source.js +81 -0
- package/dist/src/engine/source.js.map +1 -0
- package/dist/src/engine/theme-defaults.d.ts +2 -0
- package/dist/src/engine/theme-defaults.js +54 -0
- package/dist/src/engine/theme-defaults.js.map +1 -0
- package/dist/src/engine/theme-source.d.ts +5 -0
- package/dist/src/engine/theme-source.js +71 -0
- package/dist/src/engine/theme-source.js.map +1 -0
- package/dist/src/engine/theme.d.ts +10 -0
- package/dist/src/engine/theme.js +42 -0
- package/dist/src/engine/theme.js.map +1 -0
- package/dist/src/engine/transform.d.ts +25 -0
- package/dist/src/engine/transform.js +91 -0
- package/dist/src/engine/transform.js.map +1 -0
- package/dist/src/engine/ui-preset.d.ts +4 -0
- package/dist/src/engine/ui-preset.js +56 -0
- package/dist/src/engine/ui-preset.js.map +1 -0
- package/dist/src/engine/utilities/backgrounds.d.ts +2 -0
- package/dist/src/engine/utilities/backgrounds.js +32 -0
- package/dist/src/engine/utilities/backgrounds.js.map +1 -0
- package/dist/src/engine/utilities/borders.d.ts +2 -0
- package/dist/src/engine/utilities/borders.js +95 -0
- package/dist/src/engine/utilities/borders.js.map +1 -0
- package/dist/src/engine/utilities/effects.d.ts +2 -0
- package/dist/src/engine/utilities/effects.js +61 -0
- package/dist/src/engine/utilities/effects.js.map +1 -0
- package/dist/src/engine/utilities/flexgrid.d.ts +2 -0
- package/dist/src/engine/utilities/flexgrid.js +125 -0
- package/dist/src/engine/utilities/flexgrid.js.map +1 -0
- package/dist/src/engine/utilities/index.d.ts +3 -0
- package/dist/src/engine/utilities/index.js +20 -0
- package/dist/src/engine/utilities/index.js.map +1 -0
- package/dist/src/engine/utilities/layout.d.ts +2 -0
- package/dist/src/engine/utilities/layout.js +84 -0
- package/dist/src/engine/utilities/layout.js.map +1 -0
- package/dist/src/engine/utilities/sizing.d.ts +2 -0
- package/dist/src/engine/utilities/sizing.js +21 -0
- package/dist/src/engine/utilities/sizing.js.map +1 -0
- package/dist/src/engine/utilities/spacing.d.ts +2 -0
- package/dist/src/engine/utilities/spacing.js +39 -0
- package/dist/src/engine/utilities/spacing.js.map +1 -0
- package/dist/src/engine/utilities/typography.d.ts +2 -0
- package/dist/src/engine/utilities/typography.js +120 -0
- package/dist/src/engine/utilities/typography.js.map +1 -0
- package/dist/src/engine/utilities/values.d.ts +16 -0
- package/dist/src/engine/utilities/values.js +91 -0
- package/dist/src/engine/utilities/values.js.map +1 -0
- package/dist/src/engine/variants.d.ts +2 -0
- package/dist/src/engine/variants.js +99 -0
- package/dist/src/engine/variants.js.map +1 -0
- package/dist/src/extractor.d.ts +146 -0
- package/dist/src/extractor.js +3862 -0
- package/dist/src/extractor.js.map +1 -0
- package/dist/src/index.cjs +4518 -0
- package/dist/src/index.cjs.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +9 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/index.mjs +4480 -0
- package/dist/src/index.mjs.map +1 -0
- package/dist/src/keyframes.cjs +367 -0
- package/dist/src/keyframes.cjs.map +1 -0
- package/dist/src/keyframes.d.ts +27 -0
- package/dist/src/keyframes.js +188 -0
- package/dist/src/keyframes.js.map +1 -0
- package/dist/src/keyframes.mjs +362 -0
- package/dist/src/keyframes.mjs.map +1 -0
- package/dist/src/logger.d.ts +2 -0
- package/dist/src/logger.js +31 -0
- package/dist/src/logger.js.map +1 -0
- package/dist/src/plugin.cjs +43 -0
- package/dist/src/plugin.cjs.map +1 -0
- package/dist/src/plugin.d.ts +12 -0
- package/dist/src/plugin.js +39 -0
- package/dist/src/plugin.js.map +1 -0
- package/dist/src/plugin.mjs +41 -0
- package/dist/src/plugin.mjs.map +1 -0
- package/dist/src/presets-plugins.cjs +99 -0
- package/dist/src/presets-plugins.cjs.map +1 -0
- package/dist/src/presets-plugins.d.ts +1 -0
- package/dist/src/presets-plugins.js +56 -0
- package/dist/src/presets-plugins.js.map +1 -0
- package/dist/src/presets-plugins.mjs +97 -0
- package/dist/src/presets-plugins.mjs.map +1 -0
- package/dist/src/state.d.ts +76 -0
- package/dist/src/state.js +314 -0
- package/dist/src/state.js.map +1 -0
- package/dist/src/theme/constants.d.ts +22 -0
- package/dist/src/theme/constants.js +17 -0
- package/dist/src/theme/constants.js.map +1 -0
- package/dist/src/theme/index.d.ts +2 -0
- package/dist/src/theme/index.js +48 -0
- package/dist/src/theme/index.js.map +1 -0
- package/dist/src/theme/types.d.ts +13 -0
- package/dist/src/theme/types.js +2 -0
- package/dist/src/theme/types.js.map +1 -0
- package/dist/src/types/ast.d.ts +23 -0
- package/dist/src/types/ast.js +2 -0
- package/dist/src/types/ast.js.map +1 -0
- package/dist/src/types/base-types.d.ts +53 -0
- package/dist/src/types/base-types.js +2 -0
- package/dist/src/types/base-types.js.map +1 -0
- package/dist/src/types/components-types.d.ts +28 -0
- package/dist/src/types/components-types.js +2 -0
- package/dist/src/types/components-types.js.map +1 -0
- package/dist/src/types/config.d.ts +90 -0
- package/dist/src/types/config.js +3 -0
- package/dist/src/types/config.js.map +1 -0
- package/dist/src/types/css-parser.d.ts +361 -0
- package/dist/src/types/css-parser.js +2 -0
- package/dist/src/types/css-parser.js.map +1 -0
- package/dist/src/types/keyframes-type.d.ts +47 -0
- package/dist/src/types/keyframes-type.js +2 -0
- package/dist/src/types/keyframes-type.js.map +1 -0
- package/dist/src/types/plugin.d.ts +10 -0
- package/dist/src/types/plugin.js +2 -0
- package/dist/src/types/plugin.js.map +1 -0
- package/dist/src/types/screens-types.d.ts +47 -0
- package/dist/src/types/screens-types.js +2 -0
- package/dist/src/types/screens-types.js.map +1 -0
- package/dist/src/types/utilities-types.d.ts +147 -0
- package/dist/src/types/utilities-types.js +2 -0
- package/dist/src/types/utilities-types.js.map +1 -0
- package/dist/src/types.d.ts +77 -0
- package/dist/src/types.js +12 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/units/constants.d.ts +35 -0
- package/dist/src/units/constants.js +9 -0
- package/dist/src/units/constants.js.map +1 -0
- package/dist/src/units/index.d.ts +15 -0
- package/dist/src/units/index.js +7 -0
- package/dist/src/units/index.js.map +1 -0
- package/dist/src/units/types.d.ts +9 -0
- package/dist/src/units/types.js +2 -0
- package/dist/src/units/types.js.map +1 -0
- package/dist/src/utilities/backgrounds/constants.d.ts +2810 -0
- package/dist/src/utilities/backgrounds/constants.js +119 -0
- package/dist/src/utilities/backgrounds/constants.js.map +1 -0
- package/dist/src/utilities/backgrounds/index.d.ts +1 -0
- package/dist/src/utilities/backgrounds/index.js +2 -0
- package/dist/src/utilities/backgrounds/index.js.map +1 -0
- package/dist/src/utilities/borders/constants.d.ts +10586 -0
- package/dist/src/utilities/borders/constants.js +309 -0
- package/dist/src/utilities/borders/constants.js.map +1 -0
- package/dist/src/utilities/borders/index.d.ts +1 -0
- package/dist/src/utilities/borders/index.js +2 -0
- package/dist/src/utilities/borders/index.js.map +1 -0
- package/dist/src/utilities/breakpoints/constants.d.ts +330 -0
- package/dist/src/utilities/breakpoints/constants.js +269 -0
- package/dist/src/utilities/breakpoints/constants.js.map +1 -0
- package/dist/src/utilities/breakpoints/index.d.ts +2 -0
- package/dist/src/utilities/breakpoints/index.js +3 -0
- package/dist/src/utilities/breakpoints/index.js.map +1 -0
- package/dist/src/utilities/breakpoints/types.d.ts +8 -0
- package/dist/src/utilities/breakpoints/types.js +2 -0
- package/dist/src/utilities/breakpoints/types.js.map +1 -0
- package/dist/src/utilities/colors/base.d.ts +778 -0
- package/dist/src/utilities/colors/base.js +872 -0
- package/dist/src/utilities/colors/base.js.map +1 -0
- package/dist/src/utilities/colors/color.d.ts +1122 -0
- package/dist/src/utilities/colors/color.js +957 -0
- package/dist/src/utilities/colors/color.js.map +1 -0
- package/dist/src/utilities/colors/constants.d.ts +1 -0
- package/dist/src/utilities/colors/constants.js +2 -0
- package/dist/src/utilities/colors/constants.js.map +1 -0
- package/dist/src/utilities/colors/index.d.ts +4 -0
- package/dist/src/utilities/colors/index.js +29 -0
- package/dist/src/utilities/colors/index.js.map +1 -0
- package/dist/src/utilities/colors/types.d.ts +3 -0
- package/dist/src/utilities/colors/types.js +2 -0
- package/dist/src/utilities/colors/types.js.map +1 -0
- package/dist/src/utilities/effects/constants.d.ts +641 -0
- package/dist/src/utilities/effects/constants.js +83 -0
- package/dist/src/utilities/effects/constants.js.map +1 -0
- package/dist/src/utilities/effects/index.d.ts +1 -0
- package/dist/src/utilities/effects/index.js +2 -0
- package/dist/src/utilities/effects/index.js.map +1 -0
- package/dist/src/utilities/filters/constants.d.ts +406 -0
- package/dist/src/utilities/filters/constants.js +206 -0
- package/dist/src/utilities/filters/constants.js.map +1 -0
- package/dist/src/utilities/filters/index.d.ts +1 -0
- package/dist/src/utilities/filters/index.js +2 -0
- package/dist/src/utilities/filters/index.js.map +1 -0
- package/dist/src/utilities/flex/constants.d.ts +934 -0
- package/dist/src/utilities/flex/constants.js +221 -0
- package/dist/src/utilities/flex/constants.js.map +1 -0
- package/dist/src/utilities/flex/index.d.ts +1 -0
- package/dist/src/utilities/flex/index.js +2 -0
- package/dist/src/utilities/flex/index.js.map +1 -0
- package/dist/src/utilities/flex/types.d.ts +0 -0
- package/dist/src/utilities/flex/types.js +4 -0
- package/dist/src/utilities/flex/types.js.map +1 -0
- package/dist/src/utilities/index.d.ts +31338 -0
- package/dist/src/utilities/index.js +333 -0
- package/dist/src/utilities/index.js.map +1 -0
- package/dist/src/utilities/interactivity/constants.d.ts +1244 -0
- package/dist/src/utilities/interactivity/constants.js +165 -0
- package/dist/src/utilities/interactivity/constants.js.map +1 -0
- package/dist/src/utilities/interactivity/index.d.ts +1 -0
- package/dist/src/utilities/interactivity/index.js +2 -0
- package/dist/src/utilities/interactivity/index.js.map +1 -0
- package/dist/src/utilities/layout/constants.d.ts +837 -0
- package/dist/src/utilities/layout/constants.js +159 -0
- package/dist/src/utilities/layout/constants.js.map +1 -0
- package/dist/src/utilities/layout/index.d.ts +1 -0
- package/dist/src/utilities/layout/index.js +2 -0
- package/dist/src/utilities/layout/index.js.map +1 -0
- package/dist/src/utilities/layout/types.d.ts +0 -0
- package/dist/src/utilities/layout/types.js +2 -0
- package/dist/src/utilities/layout/types.js.map +1 -0
- package/dist/src/utilities/sizing/constants.d.ts +989 -0
- package/dist/src/utilities/sizing/constants.js +53 -0
- package/dist/src/utilities/sizing/constants.js.map +1 -0
- package/dist/src/utilities/sizing/index.d.ts +2 -0
- package/dist/src/utilities/sizing/index.js +3 -0
- package/dist/src/utilities/sizing/index.js.map +1 -0
- package/dist/src/utilities/sizing/types.d.ts +10 -0
- package/dist/src/utilities/sizing/types.js +2 -0
- package/dist/src/utilities/sizing/types.js.map +1 -0
- package/dist/src/utilities/spacing/constants.d.ts +1779 -0
- package/dist/src/utilities/spacing/constants.js +142 -0
- package/dist/src/utilities/spacing/constants.js.map +1 -0
- package/dist/src/utilities/spacing/index.d.ts +2 -0
- package/dist/src/utilities/spacing/index.js +3 -0
- package/dist/src/utilities/spacing/index.js.map +1 -0
- package/dist/src/utilities/spacing/types.d.ts +15 -0
- package/dist/src/utilities/spacing/types.js +8 -0
- package/dist/src/utilities/spacing/types.js.map +1 -0
- package/dist/src/utilities/svg/constants.d.ts +1062 -0
- package/dist/src/utilities/svg/constants.js +34 -0
- package/dist/src/utilities/svg/constants.js.map +1 -0
- package/dist/src/utilities/transforms/constants.d.ts +247 -0
- package/dist/src/utilities/transforms/constants.js +74 -0
- package/dist/src/utilities/transforms/constants.js.map +1 -0
- package/dist/src/utilities/transforms/index.d.ts +1 -0
- package/dist/src/utilities/transforms/index.js +2 -0
- package/dist/src/utilities/transforms/index.js.map +1 -0
- package/dist/src/utilities/transitions/constants.d.ts +116 -0
- package/dist/src/utilities/transitions/constants.js +91 -0
- package/dist/src/utilities/transitions/constants.js.map +1 -0
- package/dist/src/utilities/transitions/index.d.ts +1 -0
- package/dist/src/utilities/transitions/index.js +2 -0
- package/dist/src/utilities/transitions/index.js.map +1 -0
- package/dist/src/utilities/typography/constants.d.ts +2401 -0
- package/dist/src/utilities/typography/constants.js +401 -0
- package/dist/src/utilities/typography/constants.js.map +1 -0
- package/dist/src/utilities/typography/index.d.ts +1 -0
- package/dist/src/utilities/typography/index.js +2 -0
- package/dist/src/utilities/typography/index.js.map +1 -0
- package/dist/src/utils.d.ts +18 -0
- package/dist/src/utils.js +282 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/src/watcher.d.ts +15 -0
- package/dist/src/watcher.js +62 -0
- package/dist/src/watcher.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utilities.css +1 -0
- package/index.css +2 -0
- package/package.json +139 -0
- package/reset.css +168 -0
- package/utilities.css +1 -0
|
@@ -0,0 +1,4518 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var sourceMap = require('source-map');
|
|
4
|
+
var fs = require('node:fs');
|
|
5
|
+
var path = require('node:path');
|
|
6
|
+
var fg = require('fast-glob');
|
|
7
|
+
|
|
8
|
+
function _arrayLikeToArray(r, a) {
|
|
9
|
+
(null == a || a > r.length) && (a = r.length);
|
|
10
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
11
|
+
return n;
|
|
12
|
+
}
|
|
13
|
+
function _arrayWithHoles(r) {
|
|
14
|
+
if (Array.isArray(r)) return r;
|
|
15
|
+
}
|
|
16
|
+
function _arrayWithoutHoles(r) {
|
|
17
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
18
|
+
}
|
|
19
|
+
function _classCallCheck(a, n) {
|
|
20
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
21
|
+
}
|
|
22
|
+
function _defineProperties(e, r) {
|
|
23
|
+
for (var t = 0; t < r.length; t++) {
|
|
24
|
+
var o = r[t];
|
|
25
|
+
o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function _createClass(e, r, t) {
|
|
29
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
30
|
+
writable: false
|
|
31
|
+
}), e;
|
|
32
|
+
}
|
|
33
|
+
function _createForOfIteratorHelper(r, e) {
|
|
34
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
35
|
+
if (!t) {
|
|
36
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
|
|
37
|
+
t && (r = t);
|
|
38
|
+
var n = 0,
|
|
39
|
+
F = function () {};
|
|
40
|
+
return {
|
|
41
|
+
s: F,
|
|
42
|
+
n: function () {
|
|
43
|
+
return n >= r.length ? {
|
|
44
|
+
done: true
|
|
45
|
+
} : {
|
|
46
|
+
done: false,
|
|
47
|
+
value: r[n++]
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
e: function (r) {
|
|
51
|
+
throw r;
|
|
52
|
+
},
|
|
53
|
+
f: F
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
57
|
+
}
|
|
58
|
+
var o,
|
|
59
|
+
a = true,
|
|
60
|
+
u = false;
|
|
61
|
+
return {
|
|
62
|
+
s: function () {
|
|
63
|
+
t = t.call(r);
|
|
64
|
+
},
|
|
65
|
+
n: function () {
|
|
66
|
+
var r = t.next();
|
|
67
|
+
return a = r.done, r;
|
|
68
|
+
},
|
|
69
|
+
e: function (r) {
|
|
70
|
+
u = true, o = r;
|
|
71
|
+
},
|
|
72
|
+
f: function () {
|
|
73
|
+
try {
|
|
74
|
+
a || null == t.return || t.return();
|
|
75
|
+
} finally {
|
|
76
|
+
if (u) throw o;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function _defineProperty(e, r, t) {
|
|
82
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
83
|
+
value: t,
|
|
84
|
+
enumerable: true,
|
|
85
|
+
configurable: true,
|
|
86
|
+
writable: true
|
|
87
|
+
}) : e[r] = t, e;
|
|
88
|
+
}
|
|
89
|
+
function _iterableToArray(r) {
|
|
90
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
91
|
+
}
|
|
92
|
+
function _iterableToArrayLimit(r, l) {
|
|
93
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
94
|
+
if (null != t) {
|
|
95
|
+
var e,
|
|
96
|
+
n,
|
|
97
|
+
i,
|
|
98
|
+
u,
|
|
99
|
+
a = [],
|
|
100
|
+
f = true,
|
|
101
|
+
o = false;
|
|
102
|
+
try {
|
|
103
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
104
|
+
if (Object(t) !== t) return;
|
|
105
|
+
f = !1;
|
|
106
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
107
|
+
} catch (r) {
|
|
108
|
+
o = true, n = r;
|
|
109
|
+
} finally {
|
|
110
|
+
try {
|
|
111
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
112
|
+
} finally {
|
|
113
|
+
if (o) throw n;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return a;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function _nonIterableRest() {
|
|
120
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
121
|
+
}
|
|
122
|
+
function _nonIterableSpread() {
|
|
123
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
124
|
+
}
|
|
125
|
+
function ownKeys(e, r) {
|
|
126
|
+
var t = Object.keys(e);
|
|
127
|
+
if (Object.getOwnPropertySymbols) {
|
|
128
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
129
|
+
r && (o = o.filter(function (r) {
|
|
130
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
131
|
+
})), t.push.apply(t, o);
|
|
132
|
+
}
|
|
133
|
+
return t;
|
|
134
|
+
}
|
|
135
|
+
function _objectSpread2(e) {
|
|
136
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
137
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
138
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|
139
|
+
_defineProperty(e, r, t[r]);
|
|
140
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
141
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return e;
|
|
145
|
+
}
|
|
146
|
+
function _slicedToArray(r, e) {
|
|
147
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
148
|
+
}
|
|
149
|
+
function _toConsumableArray(r) {
|
|
150
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
151
|
+
}
|
|
152
|
+
function _toPrimitive(t, r) {
|
|
153
|
+
if ("object" != typeof t || !t) return t;
|
|
154
|
+
var e = t[Symbol.toPrimitive];
|
|
155
|
+
if (void 0 !== e) {
|
|
156
|
+
var i = e.call(t, r);
|
|
157
|
+
if ("object" != typeof i) return i;
|
|
158
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
159
|
+
}
|
|
160
|
+
return ("string" === r ? String : Number)(t);
|
|
161
|
+
}
|
|
162
|
+
function _toPropertyKey(t) {
|
|
163
|
+
var i = _toPrimitive(t, "string");
|
|
164
|
+
return "symbol" == typeof i ? i : i + "";
|
|
165
|
+
}
|
|
166
|
+
function _unsupportedIterableToArray(r, a) {
|
|
167
|
+
if (r) {
|
|
168
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
169
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
170
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Where a node came from in an input file. `line` is 1-based, `column` 0-based
|
|
175
|
+
// (the source-map convention). Set on passthrough nodes so `stringify` can emit
|
|
176
|
+
// a source map; generated utilities have no meaningful origin and leave it unset.
|
|
177
|
+
|
|
178
|
+
// Verbatim CSS the transform passes through from the input (author rules the
|
|
179
|
+
// engine doesn't model structurally). Emitted as-is; carries its origin `loc`.
|
|
180
|
+
|
|
181
|
+
function decl(property, value) {
|
|
182
|
+
var important = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
183
|
+
var loc = arguments.length > 3 ? arguments[3] : undefined;
|
|
184
|
+
return loc ? {
|
|
185
|
+
kind: 'declaration',
|
|
186
|
+
property: property,
|
|
187
|
+
value: value,
|
|
188
|
+
important: important,
|
|
189
|
+
loc: loc
|
|
190
|
+
} : {
|
|
191
|
+
kind: 'declaration',
|
|
192
|
+
property: property,
|
|
193
|
+
value: value,
|
|
194
|
+
important: important
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function rule(selector, nodes, loc) {
|
|
198
|
+
return loc ? {
|
|
199
|
+
kind: 'rule',
|
|
200
|
+
selector: selector,
|
|
201
|
+
nodes: nodes,
|
|
202
|
+
loc: loc
|
|
203
|
+
} : {
|
|
204
|
+
kind: 'rule',
|
|
205
|
+
selector: selector,
|
|
206
|
+
nodes: nodes
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
function atRule(name, params, nodes, loc) {
|
|
210
|
+
return loc ? {
|
|
211
|
+
kind: 'at-rule',
|
|
212
|
+
name: name,
|
|
213
|
+
params: params,
|
|
214
|
+
nodes: nodes,
|
|
215
|
+
loc: loc
|
|
216
|
+
} : {
|
|
217
|
+
kind: 'at-rule',
|
|
218
|
+
name: name,
|
|
219
|
+
params: params,
|
|
220
|
+
nodes: nodes
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
function raw(text, loc) {
|
|
224
|
+
return loc ? {
|
|
225
|
+
kind: 'raw',
|
|
226
|
+
text: text,
|
|
227
|
+
loc: loc
|
|
228
|
+
} : {
|
|
229
|
+
kind: 'raw',
|
|
230
|
+
text: text
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
// Accumulates the output string while tracking the current line/column, so a node
|
|
234
|
+
// carrying a `loc` can be mapped to its origin. Without a map it's just a string
|
|
235
|
+
// builder — `stringify` and `stringifyWithMap` share one write path.
|
|
236
|
+
var Writer = /*#__PURE__*/function () {
|
|
237
|
+
function Writer(map) {
|
|
238
|
+
_classCallCheck(this, Writer);
|
|
239
|
+
_defineProperty(this, "css", '');
|
|
240
|
+
_defineProperty(this, "line", 1);
|
|
241
|
+
_defineProperty(this, "column", 0);
|
|
242
|
+
this.map = map;
|
|
243
|
+
}
|
|
244
|
+
return _createClass(Writer, [{
|
|
245
|
+
key: "emit",
|
|
246
|
+
value: function emit(text) {
|
|
247
|
+
this.css += text;
|
|
248
|
+
var nl = text.indexOf('\n');
|
|
249
|
+
if (nl === -1) {
|
|
250
|
+
this.column += text.length;
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
var last = 0;
|
|
254
|
+
while (nl !== -1) {
|
|
255
|
+
this.line++;
|
|
256
|
+
last = nl + 1;
|
|
257
|
+
nl = text.indexOf('\n', last);
|
|
258
|
+
}
|
|
259
|
+
this.column = text.length - last;
|
|
260
|
+
}
|
|
261
|
+
}, {
|
|
262
|
+
key: "mark",
|
|
263
|
+
value: function mark(loc) {
|
|
264
|
+
if (this.map && loc) {
|
|
265
|
+
this.map.addMapping({
|
|
266
|
+
source: loc.source,
|
|
267
|
+
original: {
|
|
268
|
+
line: loc.line,
|
|
269
|
+
column: loc.column
|
|
270
|
+
},
|
|
271
|
+
generated: {
|
|
272
|
+
line: this.line,
|
|
273
|
+
column: this.column
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}]);
|
|
279
|
+
}();
|
|
280
|
+
function stringify(nodes) {
|
|
281
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
282
|
+
var w = new Writer();
|
|
283
|
+
var _iterator = _createForOfIteratorHelper(nodes),
|
|
284
|
+
_step;
|
|
285
|
+
try {
|
|
286
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
287
|
+
var node = _step.value;
|
|
288
|
+
write(node, options.minify ? -1 : 0, options, w);
|
|
289
|
+
}
|
|
290
|
+
} catch (err) {
|
|
291
|
+
_iterator.e(err);
|
|
292
|
+
} finally {
|
|
293
|
+
_iterator.f();
|
|
294
|
+
}
|
|
295
|
+
return w.css;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// Like {@link stringify} but also returns a source map keyed on each node's `loc`.
|
|
299
|
+
function stringifyWithMap(nodes) {
|
|
300
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
301
|
+
var w = new Writer(new sourceMap.SourceMapGenerator());
|
|
302
|
+
var _iterator2 = _createForOfIteratorHelper(nodes),
|
|
303
|
+
_step2;
|
|
304
|
+
try {
|
|
305
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
306
|
+
var node = _step2.value;
|
|
307
|
+
write(node, options.minify ? -1 : 0, options, w);
|
|
308
|
+
}
|
|
309
|
+
} catch (err) {
|
|
310
|
+
_iterator2.e(err);
|
|
311
|
+
} finally {
|
|
312
|
+
_iterator2.f();
|
|
313
|
+
}
|
|
314
|
+
return {
|
|
315
|
+
css: w.css,
|
|
316
|
+
map: w.map
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
function write(node, depth, opts, w) {
|
|
320
|
+
var minify = depth < 0;
|
|
321
|
+
var pad = minify ? '' : ' '.repeat(depth);
|
|
322
|
+
var nl = minify ? '' : '\n';
|
|
323
|
+
var sp = minify ? '' : ' ';
|
|
324
|
+
if (node.kind === 'declaration') {
|
|
325
|
+
var bang = node.important ? "".concat(sp, "!important") : '';
|
|
326
|
+
w.emit(pad);
|
|
327
|
+
w.mark(node.loc);
|
|
328
|
+
w.emit("".concat(node.property, ":").concat(sp).concat(node.value).concat(bang, ";").concat(nl));
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
if (node.kind === 'raw') {
|
|
332
|
+
w.emit(pad);
|
|
333
|
+
w.mark(node.loc);
|
|
334
|
+
w.emit("".concat(node.text).concat(nl));
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
var header = node.kind === 'rule' ? node.selector : "@".concat(node.name).concat(node.params ? ' ' + node.params : '');
|
|
338
|
+
w.emit(pad);
|
|
339
|
+
w.mark(node.loc);
|
|
340
|
+
w.emit("".concat(header).concat(sp, "{").concat(nl));
|
|
341
|
+
var inner = minify ? -1 : depth + 1;
|
|
342
|
+
var _iterator3 = _createForOfIteratorHelper(node.nodes),
|
|
343
|
+
_step3;
|
|
344
|
+
try {
|
|
345
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
346
|
+
var child = _step3.value;
|
|
347
|
+
write(child, inner, opts, w);
|
|
348
|
+
}
|
|
349
|
+
} catch (err) {
|
|
350
|
+
_iterator3.e(err);
|
|
351
|
+
} finally {
|
|
352
|
+
_iterator3.f();
|
|
353
|
+
}
|
|
354
|
+
w.emit("".concat(pad, "}").concat(nl));
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// Parses one raw utility (e.g. `md:hover:-bg-red-500/50!` or `[&_p]:text-[13px]`)
|
|
358
|
+
// into a structured Atom in a single pass. Splitting is bracket/paren aware,
|
|
359
|
+
// so `:` `/` `-` inside arbitrary values are left alone — no regex, no
|
|
360
|
+
// backtracking. Which part is the root and which is the value can't be known from
|
|
361
|
+
// the string alone (`text-red-500` vs `grid-cols-3`), so that split is resolved
|
|
362
|
+
// against the registry through AtomContext.
|
|
363
|
+
|
|
364
|
+
// Split on `sep` at depth 0 only; `[...]` and `(...)` are opaque, and `\` escapes
|
|
365
|
+
// the next character.
|
|
366
|
+
function splitAtTopLevel(input, sep) {
|
|
367
|
+
var out = [];
|
|
368
|
+
var depthBracket = 0;
|
|
369
|
+
var depthParen = 0;
|
|
370
|
+
var start = 0;
|
|
371
|
+
for (var i = 0; i < input.length; i++) {
|
|
372
|
+
var c = input[i];
|
|
373
|
+
if (c === '\\') {
|
|
374
|
+
i++; // skip the escaped char
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
if (c === '[') depthBracket++;else if (c === ']') depthBracket = Math.max(0, depthBracket - 1);else if (c === '(') depthParen++;else if (c === ')') depthParen = Math.max(0, depthParen - 1);else if (c === sep && depthBracket === 0 && depthParen === 0) {
|
|
378
|
+
out.push(input.slice(start, i));
|
|
379
|
+
start = i + 1;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
out.push(input.slice(start));
|
|
383
|
+
return out;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// Content of a `[...]` or `(...)` wrapper, or null when `s` isn't wrapped.
|
|
387
|
+
function unwrap(s, open) {
|
|
388
|
+
var close = open === '[' ? ']' : ')';
|
|
389
|
+
return s.length >= 2 && s[0] === open && s[s.length - 1] === close ? s.slice(1, -1) : null;
|
|
390
|
+
}
|
|
391
|
+
function parseModifier(raw) {
|
|
392
|
+
if (!raw) return null;
|
|
393
|
+
var arb = unwrap(raw, '[');
|
|
394
|
+
if (arb !== null) return {
|
|
395
|
+
kind: 'arbitrary',
|
|
396
|
+
value: arb
|
|
397
|
+
};
|
|
398
|
+
// `(--name)` is shorthand for the custom property it references.
|
|
399
|
+
var paren = unwrap(raw, '(');
|
|
400
|
+
if (paren !== null) return {
|
|
401
|
+
kind: 'arbitrary',
|
|
402
|
+
value: "var(".concat(paren, ")")
|
|
403
|
+
};
|
|
404
|
+
return {
|
|
405
|
+
kind: 'named',
|
|
406
|
+
value: raw
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
function splitModifier(base) {
|
|
410
|
+
var parts = splitAtTopLevel(base, '/');
|
|
411
|
+
if (parts.length === 1) return {
|
|
412
|
+
base: base,
|
|
413
|
+
modifier: null
|
|
414
|
+
};
|
|
415
|
+
var modifier = parseModifier(parts.slice(1).join('/'));
|
|
416
|
+
return {
|
|
417
|
+
base: parts[0],
|
|
418
|
+
modifier: modifier
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// In arbitrary values `_` stands in for a space; `\_` is a literal underscore.
|
|
423
|
+
function decodeUnderscores(value) {
|
|
424
|
+
return value.replace(/\\_/g, '\0').replace(/_/g, ' ').replace(/\0/g, '_');
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// An arbitrary value may lead with a `type:` hint, e.g. `[length:12px]`.
|
|
428
|
+
function parseArbitraryValue(body) {
|
|
429
|
+
var colon = body.indexOf(':');
|
|
430
|
+
if (colon > 0) {
|
|
431
|
+
var maybeType = body.slice(0, colon);
|
|
432
|
+
if (/^[a-z-]+$/.test(maybeType)) {
|
|
433
|
+
return {
|
|
434
|
+
dataType: maybeType,
|
|
435
|
+
value: decodeUnderscores(body.slice(colon + 1))
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return {
|
|
440
|
+
dataType: null,
|
|
441
|
+
value: decodeUnderscores(body)
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// The `(--name)` shorthand, optionally typed: `(length:--size)`. The custom
|
|
446
|
+
// property name keeps its underscores.
|
|
447
|
+
function parseParenValue(paren) {
|
|
448
|
+
var colon = paren.indexOf(':');
|
|
449
|
+
if (colon > 0 && /^[a-z-]+$/.test(paren.slice(0, colon))) {
|
|
450
|
+
return {
|
|
451
|
+
dataType: paren.slice(0, colon),
|
|
452
|
+
value: "var(".concat(paren.slice(colon + 1), ")")
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
return {
|
|
456
|
+
dataType: null,
|
|
457
|
+
value: "var(".concat(paren, ")")
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
function parseVariant(raw) {
|
|
461
|
+
var ctx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
462
|
+
if (!raw) return null;
|
|
463
|
+
|
|
464
|
+
// `[&:hover]`, `[@media(...)]` — the selector is written out; a `&` means it's
|
|
465
|
+
// relative to the element.
|
|
466
|
+
var arb = unwrap(raw, '[');
|
|
467
|
+
if (arb !== null) {
|
|
468
|
+
return {
|
|
469
|
+
kind: 'arbitrary',
|
|
470
|
+
selector: arb,
|
|
471
|
+
relative: arb.includes('&')
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
var _splitModifier = splitModifier(raw),
|
|
475
|
+
base = _splitModifier.base,
|
|
476
|
+
modifier = _splitModifier.modifier;
|
|
477
|
+
|
|
478
|
+
// A variant carrying a value: `group-hover`, `data-[open]`, `supports-[display:grid]`.
|
|
479
|
+
var dash = base.indexOf('-');
|
|
480
|
+
if (dash > 0) {
|
|
481
|
+
var _ctx$isDynamicVariant, _ctx$isDynamicVariant2;
|
|
482
|
+
var _root = base.slice(0, dash);
|
|
483
|
+
var rest = base.slice(dash + 1);
|
|
484
|
+
if ((_ctx$isDynamicVariant = ctx.isDynamicVariant) !== null && _ctx$isDynamicVariant !== void 0 && _ctx$isDynamicVariant.call(ctx, _root) || (_ctx$isDynamicVariant2 = ctx.isDynamicVariant) !== null && _ctx$isDynamicVariant2 !== void 0 && _ctx$isDynamicVariant2.call(ctx, _root + '-')) {
|
|
485
|
+
// A variant's `[...]` is a raw condition/attribute, not a typed value.
|
|
486
|
+
var arbVal = unwrap(rest, '[');
|
|
487
|
+
var value = arbVal !== null ? {
|
|
488
|
+
kind: 'arbitrary',
|
|
489
|
+
value: arbVal,
|
|
490
|
+
dataType: null
|
|
491
|
+
} : {
|
|
492
|
+
kind: 'named',
|
|
493
|
+
value: rest
|
|
494
|
+
};
|
|
495
|
+
return {
|
|
496
|
+
kind: 'functional',
|
|
497
|
+
root: _root,
|
|
498
|
+
value: value,
|
|
499
|
+
modifier: modifier
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
return {
|
|
504
|
+
kind: 'functional',
|
|
505
|
+
root: base,
|
|
506
|
+
value: null,
|
|
507
|
+
modifier: modifier
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// Returns null for structurally invalid input (empty or dangling segments).
|
|
512
|
+
// Without a context the root/value split falls back to the first dash, which is
|
|
513
|
+
// enough to test the scanner on its own.
|
|
514
|
+
function parseAtom(raw) {
|
|
515
|
+
var _ctx$isRule, _ctx$isRule2;
|
|
516
|
+
var ctx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
517
|
+
if (!raw) return null;
|
|
518
|
+
var segments = splitAtTopLevel(raw, ':');
|
|
519
|
+
var utility = segments.pop();
|
|
520
|
+
if (utility === undefined || utility === '') return null;
|
|
521
|
+
var variants = [];
|
|
522
|
+
var _iterator = _createForOfIteratorHelper(segments),
|
|
523
|
+
_step;
|
|
524
|
+
try {
|
|
525
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
526
|
+
var seg = _step.value;
|
|
527
|
+
if (seg === '') return null; // dangling `::`
|
|
528
|
+
var v = parseVariant(seg, ctx);
|
|
529
|
+
if (!v) return null;
|
|
530
|
+
variants.push(v);
|
|
531
|
+
}
|
|
532
|
+
// Written left-to-right (outermost first), stored innermost-first so consumers
|
|
533
|
+
// can wrap the declaration outward.
|
|
534
|
+
} catch (err) {
|
|
535
|
+
_iterator.e(err);
|
|
536
|
+
} finally {
|
|
537
|
+
_iterator.f();
|
|
538
|
+
}
|
|
539
|
+
variants.reverse();
|
|
540
|
+
|
|
541
|
+
// `!` marks important, accepted on either end.
|
|
542
|
+
var body = utility;
|
|
543
|
+
var important = false;
|
|
544
|
+
if (body.endsWith('!')) {
|
|
545
|
+
important = true;
|
|
546
|
+
body = body.slice(0, -1);
|
|
547
|
+
} else if (body.startsWith('!')) {
|
|
548
|
+
important = true;
|
|
549
|
+
body = body.slice(1);
|
|
550
|
+
}
|
|
551
|
+
if (body === '') return null;
|
|
552
|
+
|
|
553
|
+
// Split off a trailing `/modifier` once, up front — it applies uniformly to
|
|
554
|
+
// arbitrary-property, static, and functional atoms.
|
|
555
|
+
var _splitModifier2 = splitModifier(body),
|
|
556
|
+
core0 = _splitModifier2.base,
|
|
557
|
+
modifier = _splitModifier2.modifier;
|
|
558
|
+
|
|
559
|
+
// Arbitrary property: `[color:red]`, `[--my-var:0]` (optionally with modifier).
|
|
560
|
+
var arbProp = unwrap(core0, '[');
|
|
561
|
+
if (arbProp !== null && arbProp.includes(':')) {
|
|
562
|
+
var colon = arbProp.indexOf(':');
|
|
563
|
+
if (colon <= 0) return null;
|
|
564
|
+
return {
|
|
565
|
+
kind: 'arbitrary-property',
|
|
566
|
+
property: arbProp.slice(0, colon),
|
|
567
|
+
value: decodeUnderscores(arbProp.slice(colon + 1)),
|
|
568
|
+
modifier: modifier,
|
|
569
|
+
important: important,
|
|
570
|
+
variants: variants,
|
|
571
|
+
raw: raw
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// Negative.
|
|
576
|
+
var negative = false;
|
|
577
|
+
var base = core0;
|
|
578
|
+
if (base[0] === '-') {
|
|
579
|
+
negative = true;
|
|
580
|
+
base = base.slice(1);
|
|
581
|
+
if (base === '') return null;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
// Static utility (only when unambiguous: no negative/modifier).
|
|
585
|
+
if (!negative && modifier === null && (_ctx$isRule = ctx.isRule) !== null && _ctx$isRule !== void 0 && _ctx$isRule.call(ctx, base)) {
|
|
586
|
+
return {
|
|
587
|
+
kind: 'static',
|
|
588
|
+
root: base,
|
|
589
|
+
important: important,
|
|
590
|
+
variants: variants,
|
|
591
|
+
raw: raw
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
// Functional: split root ↔ value. Prefer the longest known functional root;
|
|
596
|
+
// fall back to the first-dash split when no context is supplied.
|
|
597
|
+
var _splitRootValue = splitRootValue(base, ctx),
|
|
598
|
+
root = _splitRootValue.root,
|
|
599
|
+
valueStr = _splitRootValue.valueStr;
|
|
600
|
+
if (root === '') return null;
|
|
601
|
+
var value = null;
|
|
602
|
+
if (valueStr !== null && valueStr !== '') {
|
|
603
|
+
var arbVal = unwrap(valueStr, '[');
|
|
604
|
+
if (arbVal !== null) {
|
|
605
|
+
value = _objectSpread2({
|
|
606
|
+
kind: 'arbitrary'
|
|
607
|
+
}, parseArbitraryValue(arbVal));
|
|
608
|
+
} else {
|
|
609
|
+
var paren = unwrap(valueStr, '(');
|
|
610
|
+
value = paren !== null ? _objectSpread2({
|
|
611
|
+
kind: 'arbitrary'
|
|
612
|
+
}, parseParenValue(paren)) : {
|
|
613
|
+
kind: 'named',
|
|
614
|
+
value: valueStr,
|
|
615
|
+
fraction: null
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
} else if ((_ctx$isRule2 = ctx.isRule) !== null && _ctx$isRule2 !== void 0 && _ctx$isRule2.call(ctx, base)) {
|
|
619
|
+
// A bare root that is registered static (reached here due to a modifier).
|
|
620
|
+
return {
|
|
621
|
+
kind: 'static',
|
|
622
|
+
root: base,
|
|
623
|
+
important: important,
|
|
624
|
+
variants: variants,
|
|
625
|
+
raw: raw
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
return {
|
|
629
|
+
kind: 'functional',
|
|
630
|
+
root: root,
|
|
631
|
+
value: value,
|
|
632
|
+
modifier: modifier,
|
|
633
|
+
important: important,
|
|
634
|
+
negative: negative,
|
|
635
|
+
variants: variants,
|
|
636
|
+
raw: raw
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
// Splits `bg-red-500` into a root and value. The longest registered root wins
|
|
641
|
+
// (`grid-cols-3` → `grid-cols` + `3`); with no context, split at the first dash.
|
|
642
|
+
function splitRootValue(base, ctx) {
|
|
643
|
+
if (ctx.isDynamicRule) {
|
|
644
|
+
// The whole class is itself the longest possible root (`rounded-t`, `border-x`);
|
|
645
|
+
// prefer it before splitting off a shorter registered prefix (`rounded` + `t`).
|
|
646
|
+
if (ctx.isDynamicRule(base)) return {
|
|
647
|
+
root: base,
|
|
648
|
+
valueStr: null
|
|
649
|
+
};
|
|
650
|
+
var dashes = [];
|
|
651
|
+
for (var i = 0; i < base.length; i++) if (base[i] === '-') dashes.push(i);
|
|
652
|
+
for (var d = dashes.length - 1; d >= 0; d--) {
|
|
653
|
+
var idx = dashes[d];
|
|
654
|
+
var _root2 = base.slice(0, idx);
|
|
655
|
+
if (ctx.isDynamicRule(_root2)) return {
|
|
656
|
+
root: _root2,
|
|
657
|
+
valueStr: base.slice(idx + 1)
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
var first = base.indexOf('-');
|
|
662
|
+
if (first <= 0) return {
|
|
663
|
+
root: base,
|
|
664
|
+
valueStr: null
|
|
665
|
+
};
|
|
666
|
+
return {
|
|
667
|
+
root: base.slice(0, first),
|
|
668
|
+
valueStr: base.slice(first + 1)
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
// The resolved token table. Every entry is a CSS custom property (`--color-red-500`,
|
|
673
|
+
// `--spacing`, `--breakpoint-md`, …); utilities read them by namespace and emit
|
|
674
|
+
// `var()` references, so the tokens stay live and themeable at runtime.
|
|
675
|
+
|
|
676
|
+
var Theme = /*#__PURE__*/function () {
|
|
677
|
+
function Theme() {
|
|
678
|
+
_classCallCheck(this, Theme);
|
|
679
|
+
_defineProperty(this, "values", new Map());
|
|
680
|
+
}
|
|
681
|
+
return _createClass(Theme, [{
|
|
682
|
+
key: "add",
|
|
683
|
+
value: function add(name, value) {
|
|
684
|
+
this.values.set(name, value);
|
|
685
|
+
return this;
|
|
686
|
+
}
|
|
687
|
+
}, {
|
|
688
|
+
key: "addAll",
|
|
689
|
+
value: function addAll(entries) {
|
|
690
|
+
for (var name in entries) this.add(name, entries[name]);
|
|
691
|
+
return this;
|
|
692
|
+
}
|
|
693
|
+
}, {
|
|
694
|
+
key: "get",
|
|
695
|
+
value: function get(name) {
|
|
696
|
+
return this.values.get(name);
|
|
697
|
+
}
|
|
698
|
+
}, {
|
|
699
|
+
key: "has",
|
|
700
|
+
value: function has(name) {
|
|
701
|
+
return this.values.has(name);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
// A `var()` reference to `--<namespace>-<key>` when that token exists.
|
|
705
|
+
}, {
|
|
706
|
+
key: "resolve",
|
|
707
|
+
value: function resolve(namespace, key) {
|
|
708
|
+
var name = "--".concat(namespace, "-").concat(key);
|
|
709
|
+
return this.values.has(name) ? "var(".concat(name, ")") : null;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
// Bare keys registered under a namespace, e.g. every color name.
|
|
713
|
+
}, {
|
|
714
|
+
key: "keysIn",
|
|
715
|
+
value: function keysIn(namespace) {
|
|
716
|
+
var prefix = "--".concat(namespace, "-");
|
|
717
|
+
var out = [];
|
|
718
|
+
var _iterator = _createForOfIteratorHelper(this.values.keys()),
|
|
719
|
+
_step;
|
|
720
|
+
try {
|
|
721
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
722
|
+
var name = _step.value;
|
|
723
|
+
if (name.startsWith(prefix)) out.push(name.slice(prefix.length));
|
|
724
|
+
}
|
|
725
|
+
} catch (err) {
|
|
726
|
+
_iterator.e(err);
|
|
727
|
+
} finally {
|
|
728
|
+
_iterator.f();
|
|
729
|
+
}
|
|
730
|
+
return out;
|
|
731
|
+
}
|
|
732
|
+
}, {
|
|
733
|
+
key: "entries",
|
|
734
|
+
value: function entries() {
|
|
735
|
+
return _toConsumableArray(this.values.entries());
|
|
736
|
+
}
|
|
737
|
+
}]);
|
|
738
|
+
}();
|
|
739
|
+
|
|
740
|
+
// ─── Charcode constants (avoids string allocation on hot paths) ───────────────
|
|
741
|
+
var CC_TAB = 9,
|
|
742
|
+
CC_LF = 10,
|
|
743
|
+
CC_CR = 13,
|
|
744
|
+
CC_FF = 12,
|
|
745
|
+
CC_SPACE = 32;
|
|
746
|
+
var CC_DQUOTE = 34,
|
|
747
|
+
CC_HASH = 35,
|
|
748
|
+
CC_AMP = 38,
|
|
749
|
+
CC_SQUOTE = 39;
|
|
750
|
+
var CC_LPAREN = 40,
|
|
751
|
+
CC_RPAREN = 41,
|
|
752
|
+
CC_STAR = 42,
|
|
753
|
+
CC_PLUS = 43;
|
|
754
|
+
var CC_COMMA = 44,
|
|
755
|
+
CC_MINUS = 45,
|
|
756
|
+
CC_DOT = 46,
|
|
757
|
+
CC_SLASH = 47;
|
|
758
|
+
var CC_COLON = 58,
|
|
759
|
+
CC_SEMI = 59,
|
|
760
|
+
CC_GT = 62;
|
|
761
|
+
var CC_AT = 64,
|
|
762
|
+
CC_LBRACK = 91,
|
|
763
|
+
CC_BSLASH = 92,
|
|
764
|
+
CC_RBRACK = 93;
|
|
765
|
+
var CC_UNDER = 95,
|
|
766
|
+
CC_LBRACE = 123,
|
|
767
|
+
CC_RBRACE = 125,
|
|
768
|
+
CC_TILDE = 126;
|
|
769
|
+
|
|
770
|
+
// ─── Character predicates (charcode-based, no regex) ─────────────────────────
|
|
771
|
+
|
|
772
|
+
function isWS(c) {
|
|
773
|
+
return c === CC_SPACE || c === CC_TAB || c === CC_LF || c === CC_CR || c === CC_FF;
|
|
774
|
+
}
|
|
775
|
+
function isDigit(c) {
|
|
776
|
+
return c >= 48 && c <= 57;
|
|
777
|
+
}
|
|
778
|
+
function isAlpha(c) {
|
|
779
|
+
return c >= 65 && c <= 90 || c >= 97 && c <= 122;
|
|
780
|
+
}
|
|
781
|
+
function isHex(c) {
|
|
782
|
+
return isDigit(c) || c >= 65 && c <= 70 || c >= 97 && c <= 102;
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* CSS ident-start: letter | underscore | non-ASCII | hyphen.
|
|
786
|
+
* A leading hyphen is valid (vendor prefixes, custom properties).
|
|
787
|
+
*/
|
|
788
|
+
function isNameStart(c) {
|
|
789
|
+
return isAlpha(c) || c === CC_UNDER || c === CC_MINUS || c > 127;
|
|
790
|
+
}
|
|
791
|
+
/** CSS ident-char: ident-start | digit */
|
|
792
|
+
function isNameChar(c) {
|
|
793
|
+
return isAlpha(c) || isDigit(c) || c === CC_UNDER || c === CC_MINUS || c > 127;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
// ─── Block context ────────────────────────────────────────────────────────────
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* Determines what may legally appear inside a block:
|
|
800
|
+
* stylesheet – top-level: rules + at-rules
|
|
801
|
+
* mixed – @media/@supports/@container/@layer: rules + at-rules
|
|
802
|
+
* rule – inside a style rule: declarations + optional CSS nesting
|
|
803
|
+
* keyframes – inside @keyframes: keyframe stops (from/to/%)
|
|
804
|
+
* declarations– @font-face/@page/etc.: declarations only
|
|
805
|
+
*/
|
|
806
|
+
|
|
807
|
+
// ─── CssParser ────────────────────────────────────────────────────────────────
|
|
808
|
+
|
|
809
|
+
var CssParser = /*#__PURE__*/function () {
|
|
810
|
+
function CssParser() {
|
|
811
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
812
|
+
_classCallCheck(this, CssParser);
|
|
813
|
+
_defineProperty(this, "input", '');
|
|
814
|
+
_defineProperty(this, "pos", 0);
|
|
815
|
+
_defineProperty(this, "length", 0);
|
|
816
|
+
_defineProperty(this, "line", 1);
|
|
817
|
+
_defineProperty(this, "col", 1);
|
|
818
|
+
_defineProperty(this, "errors", []);
|
|
819
|
+
_defineProperty(this, "warnings", []);
|
|
820
|
+
_defineProperty(this, "stats", CssParser.emptyStats());
|
|
821
|
+
this.options = _objectSpread2({
|
|
822
|
+
parseAtrulePrelude: true,
|
|
823
|
+
parseValue: true,
|
|
824
|
+
parseCustomProperty: true,
|
|
825
|
+
parseRulePrelude: true,
|
|
826
|
+
parseSelector: true,
|
|
827
|
+
includeComments: true,
|
|
828
|
+
includeSourceMaps: true,
|
|
829
|
+
includeSpecificity: true,
|
|
830
|
+
includeVendorPrefixes: true,
|
|
831
|
+
onError: function onError() {/* noop */},
|
|
832
|
+
onWarning: function onWarning() {/* noop */},
|
|
833
|
+
maxDepth: 100,
|
|
834
|
+
maxNodes: 100000,
|
|
835
|
+
enableNesting: true,
|
|
836
|
+
enableCustomProperties: true,
|
|
837
|
+
enableLogicalProperties: true,
|
|
838
|
+
enableContainerQueries: true,
|
|
839
|
+
enableLayerQueries: true,
|
|
840
|
+
enableSupportsQueries: true,
|
|
841
|
+
// middleware — undefined by default (fast path skips them)
|
|
842
|
+
onRule: undefined,
|
|
843
|
+
onAtRule: undefined,
|
|
844
|
+
onDeclaration: undefined,
|
|
845
|
+
onComment: undefined,
|
|
846
|
+
onKeyframe: undefined
|
|
847
|
+
}, options);
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
// ── Public API ────────────────────────────────────────────────────────────
|
|
851
|
+
return _createClass(CssParser, [{
|
|
852
|
+
key: "parse",
|
|
853
|
+
value: function parse(css) {
|
|
854
|
+
var t0 = typeof performance !== 'undefined' ? performance.now() : Date.now();
|
|
855
|
+
this.reset(css);
|
|
856
|
+
var sheet = this.parseStylesheet();
|
|
857
|
+
this.stats.parseTime = (typeof performance !== 'undefined' ? performance.now() : Date.now()) - t0;
|
|
858
|
+
return sheet;
|
|
859
|
+
}
|
|
860
|
+
}, {
|
|
861
|
+
key: "getErrors",
|
|
862
|
+
value: function getErrors() {
|
|
863
|
+
return _toConsumableArray(this.errors);
|
|
864
|
+
}
|
|
865
|
+
}, {
|
|
866
|
+
key: "getWarnings",
|
|
867
|
+
value: function getWarnings() {
|
|
868
|
+
return _toConsumableArray(this.warnings);
|
|
869
|
+
}
|
|
870
|
+
}, {
|
|
871
|
+
key: "getStats",
|
|
872
|
+
value: function getStats() {
|
|
873
|
+
return _objectSpread2({}, this.stats);
|
|
874
|
+
}
|
|
875
|
+
}, {
|
|
876
|
+
key: "toLegacyFormat",
|
|
877
|
+
value: function toLegacyFormat(stylesheet) {
|
|
878
|
+
var _this = this;
|
|
879
|
+
return stylesheet.children.map(function (c) {
|
|
880
|
+
return _this.toLegacyNode(c);
|
|
881
|
+
}).filter(Boolean);
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
// ── Reset ─────────────────────────────────────────────────────────────────
|
|
885
|
+
}, {
|
|
886
|
+
key: "reset",
|
|
887
|
+
value: function reset(css) {
|
|
888
|
+
this.input = css;
|
|
889
|
+
this.pos = 0;
|
|
890
|
+
this.length = css.length;
|
|
891
|
+
this.line = 1;
|
|
892
|
+
this.col = 1;
|
|
893
|
+
this.errors = [];
|
|
894
|
+
this.warnings = [];
|
|
895
|
+
this.stats = CssParser.emptyStats();
|
|
896
|
+
}
|
|
897
|
+
}, {
|
|
898
|
+
key: "parseStylesheet",
|
|
899
|
+
value:
|
|
900
|
+
// ── Stylesheet ────────────────────────────────────────────────────────────
|
|
901
|
+
|
|
902
|
+
function parseStylesheet() {
|
|
903
|
+
var locStart = this.locPos();
|
|
904
|
+
var ss = {
|
|
905
|
+
type: 'stylesheet',
|
|
906
|
+
source: this.input,
|
|
907
|
+
children: [],
|
|
908
|
+
charset: undefined,
|
|
909
|
+
imports: [],
|
|
910
|
+
namespaces: [],
|
|
911
|
+
mediaQueries: [],
|
|
912
|
+
keyframes: [],
|
|
913
|
+
fontFaces: [],
|
|
914
|
+
layers: [],
|
|
915
|
+
containers: [],
|
|
916
|
+
supports: [],
|
|
917
|
+
documents: [],
|
|
918
|
+
pages: [],
|
|
919
|
+
counterStyles: [],
|
|
920
|
+
fontFeatureValues: [],
|
|
921
|
+
viewports: [],
|
|
922
|
+
charsets: []
|
|
923
|
+
};
|
|
924
|
+
while (this.pos < this.length) {
|
|
925
|
+
this.skipWS();
|
|
926
|
+
if (this.pos >= this.length) break;
|
|
927
|
+
var node = this.parseTopNode();
|
|
928
|
+
if (node) {
|
|
929
|
+
ss.children.push(node);
|
|
930
|
+
this.categorize(ss, node);
|
|
931
|
+
this.stats.totalNodes++;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
if (this.options.includeSourceMaps) {
|
|
935
|
+
ss.loc = {
|
|
936
|
+
start: locStart,
|
|
937
|
+
end: this.locPos(),
|
|
938
|
+
source: this.input
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
return ss;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
// ── Top-level node dispatch ───────────────────────────────────────────────
|
|
945
|
+
}, {
|
|
946
|
+
key: "parseTopNode",
|
|
947
|
+
value: function parseTopNode() {
|
|
948
|
+
var c = this.peek();
|
|
949
|
+
if (c === CC_SLASH && this.peek(1) === CC_STAR) {
|
|
950
|
+
var comment = this.parseComment();
|
|
951
|
+
return this.options.includeComments ? comment : null;
|
|
952
|
+
}
|
|
953
|
+
if (c === CC_AT) return this.parseAtRule();
|
|
954
|
+
// Skip stray closing braces that can appear in malformed CSS
|
|
955
|
+
if (c === CC_RBRACE) {
|
|
956
|
+
this.advance();
|
|
957
|
+
return null;
|
|
958
|
+
}
|
|
959
|
+
return this.parseRule();
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
// ── Block-level node dispatch ─────────────────────────────────────────────
|
|
963
|
+
}, {
|
|
964
|
+
key: "parseBlockNode",
|
|
965
|
+
value: function parseBlockNode(mode) {
|
|
966
|
+
this.skipWS();
|
|
967
|
+
if (this.pos >= this.length || this.peek() === CC_RBRACE) return null;
|
|
968
|
+
var c = this.peek();
|
|
969
|
+
if (c === CC_SLASH && this.peek(1) === CC_STAR) {
|
|
970
|
+
var comment = this.parseComment();
|
|
971
|
+
return this.options.includeComments ? comment : null;
|
|
972
|
+
}
|
|
973
|
+
if (c === CC_AT) return this.parseAtRule();
|
|
974
|
+
switch (mode) {
|
|
975
|
+
case 'keyframes':
|
|
976
|
+
return this.parseKeyframeStop();
|
|
977
|
+
case 'declarations':
|
|
978
|
+
return this.parseDeclaration();
|
|
979
|
+
case 'mixed':
|
|
980
|
+
case 'stylesheet':
|
|
981
|
+
if (c === CC_RBRACE) return null;
|
|
982
|
+
return this.parseRule();
|
|
983
|
+
case 'rule':
|
|
984
|
+
default:
|
|
985
|
+
// Unambiguous nesting-selector starters
|
|
986
|
+
if (this.isNestingStart(c)) return this.parseRule();
|
|
987
|
+
// Lookahead: first unescaped { at depth 0 → rule, ; or } → declaration
|
|
988
|
+
if (this.lookaheadIsRule()) return this.parseRule();
|
|
989
|
+
// console.log('parse block', c, mode);
|
|
990
|
+
return this.parseDeclaration();
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
// ── At-rule ───────────────────────────────────────────────────────────────
|
|
995
|
+
}, {
|
|
996
|
+
key: "parseAtRule",
|
|
997
|
+
value: function parseAtRule() {
|
|
998
|
+
if (this.peek() !== CC_AT) return null;
|
|
999
|
+
var locStart = this.locPos();
|
|
1000
|
+
this.advance(); // '@'
|
|
1001
|
+
|
|
1002
|
+
var name = this.readIdent();
|
|
1003
|
+
if (!name) {
|
|
1004
|
+
this.recoverPast(CC_SEMI, CC_RBRACE);
|
|
1005
|
+
return null;
|
|
1006
|
+
}
|
|
1007
|
+
this.skipWS();
|
|
1008
|
+
var preludeText = this.readPrelude();
|
|
1009
|
+
this.skipWS();
|
|
1010
|
+
var baseName = name.replace(/^-(webkit|moz|ms|o)-/, '');
|
|
1011
|
+
var ar = {
|
|
1012
|
+
type: 'atrule',
|
|
1013
|
+
name: name,
|
|
1014
|
+
preludeText: preludeText,
|
|
1015
|
+
prelude: this.options.parseAtrulePrelude ? this.tokenizeValue(preludeText) : []
|
|
1016
|
+
};
|
|
1017
|
+
if (this.options.includeVendorPrefixes) {
|
|
1018
|
+
var vp = name.match(/^-(webkit|moz|ms|o)-/);
|
|
1019
|
+
if (vp) ar.vendorPrefix = vp[0];
|
|
1020
|
+
}
|
|
1021
|
+
if (this.peek() === CC_LBRACE) {
|
|
1022
|
+
var mode = this.modeForAtRule(baseName);
|
|
1023
|
+
var blockStart = this.locPos();
|
|
1024
|
+
var children = this.parseBlockChildren(mode);
|
|
1025
|
+
var blockEnd = this.locPos();
|
|
1026
|
+
ar.block = _objectSpread2({
|
|
1027
|
+
type: 'block',
|
|
1028
|
+
children: children
|
|
1029
|
+
}, this.options.includeSourceMaps ? {
|
|
1030
|
+
loc: {
|
|
1031
|
+
start: blockStart,
|
|
1032
|
+
end: blockEnd
|
|
1033
|
+
}
|
|
1034
|
+
} : {});
|
|
1035
|
+
|
|
1036
|
+
// Populate keyframes shortcut
|
|
1037
|
+
if (baseName === 'keyframes') {
|
|
1038
|
+
ar.keyframes = children.filter(function (n) {
|
|
1039
|
+
return n.type === 'keyframe';
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
} else if (this.peek() === CC_SEMI) {
|
|
1043
|
+
this.advance();
|
|
1044
|
+
}
|
|
1045
|
+
this.stats.totalAtRules++;
|
|
1046
|
+
if (this.options.includeSourceMaps) {
|
|
1047
|
+
ar.loc = {
|
|
1048
|
+
start: locStart,
|
|
1049
|
+
end: this.locPos(),
|
|
1050
|
+
source: this.input
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
if (this.options.onAtRule) {
|
|
1054
|
+
var result = this.options.onAtRule(ar);
|
|
1055
|
+
if (result === null) return null;
|
|
1056
|
+
if (result) return result;
|
|
1057
|
+
}
|
|
1058
|
+
return ar;
|
|
1059
|
+
}
|
|
1060
|
+
}, {
|
|
1061
|
+
key: "modeForAtRule",
|
|
1062
|
+
value: function modeForAtRule(baseName) {
|
|
1063
|
+
// AWC encodes comments as @comment-XXXXXXXX { --rule-...: "..."; }
|
|
1064
|
+
// which contain only declarations — must NOT use mixed/rule mode or
|
|
1065
|
+
// readUntilLBrace() will consume past the closing } and corrupt state.
|
|
1066
|
+
if (baseName.startsWith('comment')) return 'declarations';
|
|
1067
|
+
switch (baseName) {
|
|
1068
|
+
case 'keyframes':
|
|
1069
|
+
return 'keyframes';
|
|
1070
|
+
case 'font-face':
|
|
1071
|
+
case 'page':
|
|
1072
|
+
case 'counter-style':
|
|
1073
|
+
case 'viewport':
|
|
1074
|
+
case 'theme':
|
|
1075
|
+
case 'utility':
|
|
1076
|
+
return 'declarations';
|
|
1077
|
+
case 'media':
|
|
1078
|
+
case 'supports':
|
|
1079
|
+
case 'container':
|
|
1080
|
+
case 'layer':
|
|
1081
|
+
case 'document':
|
|
1082
|
+
default:
|
|
1083
|
+
return 'mixed';
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
// ── Regular rule ──────────────────────────────────────────────────────────
|
|
1088
|
+
}, {
|
|
1089
|
+
key: "parseRule",
|
|
1090
|
+
value: function parseRule() {
|
|
1091
|
+
var locStart = this.locPos();
|
|
1092
|
+
var rawSelector = this.readUntilLBrace().trim();
|
|
1093
|
+
if (!rawSelector || this.peek() !== CC_LBRACE) {
|
|
1094
|
+
// Malformed — skip to closing brace
|
|
1095
|
+
if (this.peek() === CC_LBRACE) {
|
|
1096
|
+
this.skipBalancedBraces();
|
|
1097
|
+
}
|
|
1098
|
+
return null;
|
|
1099
|
+
}
|
|
1100
|
+
var mode = this.options.enableNesting ? 'rule' : 'declarations';
|
|
1101
|
+
var children = this.parseBlockChildren(mode);
|
|
1102
|
+
var declarations = [];
|
|
1103
|
+
var nested = [];
|
|
1104
|
+
var _iterator = _createForOfIteratorHelper(children),
|
|
1105
|
+
_step;
|
|
1106
|
+
try {
|
|
1107
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1108
|
+
var child = _step.value;
|
|
1109
|
+
var t = child.type;
|
|
1110
|
+
if (t === 'declaration') declarations.push(child);else if (t === 'rule') nested.push(child);else if (t === 'atrule') nested.push(child);
|
|
1111
|
+
}
|
|
1112
|
+
} catch (err) {
|
|
1113
|
+
_iterator.e(err);
|
|
1114
|
+
} finally {
|
|
1115
|
+
_iterator.f();
|
|
1116
|
+
}
|
|
1117
|
+
var selectors = this.parseSelectorList(rawSelector);
|
|
1118
|
+
this.stats.totalRules++;
|
|
1119
|
+
this.stats.totalSelectors += selectors.length;
|
|
1120
|
+
var rule = {
|
|
1121
|
+
type: 'rule',
|
|
1122
|
+
rawSelector: rawSelector,
|
|
1123
|
+
selectors: selectors,
|
|
1124
|
+
declarations: declarations
|
|
1125
|
+
};
|
|
1126
|
+
if (nested.length > 0) rule.children = nested;
|
|
1127
|
+
if (this.options.includeSpecificity) {
|
|
1128
|
+
rule.specificity = this.calcSpecificity(rawSelector);
|
|
1129
|
+
}
|
|
1130
|
+
if (this.options.includeSourceMaps) {
|
|
1131
|
+
rule.loc = {
|
|
1132
|
+
start: locStart,
|
|
1133
|
+
end: this.locPos(),
|
|
1134
|
+
source: this.input
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
if (this.options.onRule) {
|
|
1138
|
+
var result = this.options.onRule(rule);
|
|
1139
|
+
if (result === null) return null;
|
|
1140
|
+
if (result) return result;
|
|
1141
|
+
}
|
|
1142
|
+
return rule;
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
// ── Keyframe stop (from / to / <percentage>) ──────────────────────────────
|
|
1146
|
+
}, {
|
|
1147
|
+
key: "parseKeyframeStop",
|
|
1148
|
+
value: function parseKeyframeStop() {
|
|
1149
|
+
var locStart = this.locPos();
|
|
1150
|
+
var selector = this.readUntilLBrace().trim();
|
|
1151
|
+
if (!selector || this.peek() !== CC_LBRACE) return null;
|
|
1152
|
+
var children = this.parseBlockChildren('declarations');
|
|
1153
|
+
var declarations = children.filter(function (n) {
|
|
1154
|
+
return n.type === 'declaration';
|
|
1155
|
+
});
|
|
1156
|
+
var kf = _objectSpread2({
|
|
1157
|
+
type: 'keyframe',
|
|
1158
|
+
selector: selector,
|
|
1159
|
+
declarations: declarations
|
|
1160
|
+
}, this.options.includeSourceMaps ? {
|
|
1161
|
+
loc: {
|
|
1162
|
+
start: locStart,
|
|
1163
|
+
end: this.locPos()
|
|
1164
|
+
}
|
|
1165
|
+
} : {});
|
|
1166
|
+
if (this.options.onKeyframe) {
|
|
1167
|
+
var result = this.options.onKeyframe(kf);
|
|
1168
|
+
if (result === null) return null;
|
|
1169
|
+
if (result) return result;
|
|
1170
|
+
}
|
|
1171
|
+
return kf;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
// ── Block (consumes { … }) ────────────────────────────────────────────────
|
|
1175
|
+
}, {
|
|
1176
|
+
key: "parseBlockChildren",
|
|
1177
|
+
value: function parseBlockChildren(mode) {
|
|
1178
|
+
if (this.peek() !== CC_LBRACE) return [];
|
|
1179
|
+
this.advance(); // '{'
|
|
1180
|
+
|
|
1181
|
+
var children = [];
|
|
1182
|
+
while (this.pos < this.length) {
|
|
1183
|
+
this.skipWS();
|
|
1184
|
+
if (this.pos >= this.length || this.peek() === CC_RBRACE) break;
|
|
1185
|
+
var prevPos = this.pos;
|
|
1186
|
+
var node = this.parseBlockNode(mode);
|
|
1187
|
+
// Guard against infinite loop: if nothing was consumed, force-advance
|
|
1188
|
+
if (this.pos === prevPos) {
|
|
1189
|
+
this.advance();
|
|
1190
|
+
continue;
|
|
1191
|
+
}
|
|
1192
|
+
if (node) {
|
|
1193
|
+
children.push(node);
|
|
1194
|
+
this.stats.totalNodes++;
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
if (this.pos < this.length && this.peek() === CC_RBRACE) this.advance(); // '}'
|
|
1198
|
+
return children;
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
// ── Declaration ───────────────────────────────────────────────────────────
|
|
1202
|
+
}, {
|
|
1203
|
+
key: "parseDeclaration",
|
|
1204
|
+
value: function parseDeclaration() {
|
|
1205
|
+
var locStart = this.locPos();
|
|
1206
|
+
|
|
1207
|
+
// Property name (supports --custom-props and -vendor-prefixed)
|
|
1208
|
+
var property = this.readIdent();
|
|
1209
|
+
if (!property) {
|
|
1210
|
+
this.recoverTo(CC_SEMI, CC_RBRACE);
|
|
1211
|
+
return null;
|
|
1212
|
+
}
|
|
1213
|
+
this.skipWS();
|
|
1214
|
+
if (this.peek() !== CC_COLON) {
|
|
1215
|
+
this.recoverTo(CC_SEMI, CC_RBRACE);
|
|
1216
|
+
return null;
|
|
1217
|
+
}
|
|
1218
|
+
this.advance(); // ':'
|
|
1219
|
+
this.skipWS();
|
|
1220
|
+
var rawFull = this.readRawValue();
|
|
1221
|
+
|
|
1222
|
+
// Strip !important
|
|
1223
|
+
var rawValue = rawFull;
|
|
1224
|
+
var important = false;
|
|
1225
|
+
var impMatch = rawFull.match(/\s*!important\s*$/i);
|
|
1226
|
+
if (impMatch) {
|
|
1227
|
+
important = true;
|
|
1228
|
+
rawValue = rawFull.slice(0, rawFull.length - impMatch[0].length).trimEnd();
|
|
1229
|
+
}
|
|
1230
|
+
this.skipWS();
|
|
1231
|
+
if (this.pos < this.length && this.peek() === CC_SEMI) this.advance();
|
|
1232
|
+
this.stats.totalDeclarations++;
|
|
1233
|
+
var decl = {
|
|
1234
|
+
type: 'declaration',
|
|
1235
|
+
property: property,
|
|
1236
|
+
rawValue: rawValue,
|
|
1237
|
+
value: this.options.parseValue ? this.tokenizeValue(rawValue) : [],
|
|
1238
|
+
important: important
|
|
1239
|
+
};
|
|
1240
|
+
if (this.options.enableCustomProperties && property.startsWith('--')) {
|
|
1241
|
+
decl.customProperty = true;
|
|
1242
|
+
}
|
|
1243
|
+
if (this.options.includeVendorPrefixes) {
|
|
1244
|
+
var vp = property.match(/^-(webkit|moz|ms|o)-/);
|
|
1245
|
+
if (vp) decl.vendorPrefix = vp[0];
|
|
1246
|
+
}
|
|
1247
|
+
if (this.options.includeSourceMaps) {
|
|
1248
|
+
decl.loc = {
|
|
1249
|
+
start: locStart,
|
|
1250
|
+
end: this.locPos(),
|
|
1251
|
+
source: this.input
|
|
1252
|
+
};
|
|
1253
|
+
}
|
|
1254
|
+
if (this.options.onDeclaration) {
|
|
1255
|
+
var result = this.options.onDeclaration(decl);
|
|
1256
|
+
if (result === null) return null;
|
|
1257
|
+
if (result) return result;
|
|
1258
|
+
}
|
|
1259
|
+
return decl;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
// ── Comment ───────────────────────────────────────────────────────────────
|
|
1263
|
+
}, {
|
|
1264
|
+
key: "parseComment",
|
|
1265
|
+
value: function parseComment() {
|
|
1266
|
+
var locStart = this.locPos();
|
|
1267
|
+
this.advance(); // '/'
|
|
1268
|
+
this.advance(); // '*'
|
|
1269
|
+
var start = this.pos;
|
|
1270
|
+
while (this.pos < this.length - 1) {
|
|
1271
|
+
if (this.peek() === CC_STAR && this.peek(1) === CC_SLASH) {
|
|
1272
|
+
var _value = this.input.slice(start, this.pos);
|
|
1273
|
+
this.advance();
|
|
1274
|
+
this.advance(); // '*/'
|
|
1275
|
+
this.stats.totalComments++;
|
|
1276
|
+
var _c = _objectSpread2({
|
|
1277
|
+
type: 'comment',
|
|
1278
|
+
value: _value,
|
|
1279
|
+
style: _value.includes('\n') ? 'multi-line' : 'single-line'
|
|
1280
|
+
}, this.options.includeSourceMaps ? {
|
|
1281
|
+
loc: {
|
|
1282
|
+
start: locStart,
|
|
1283
|
+
end: this.locPos()
|
|
1284
|
+
}
|
|
1285
|
+
} : {});
|
|
1286
|
+
if (this.options.onComment) {
|
|
1287
|
+
var result = this.options.onComment(_c);
|
|
1288
|
+
if (result === null) return null;
|
|
1289
|
+
if (result) return result;
|
|
1290
|
+
}
|
|
1291
|
+
return _c;
|
|
1292
|
+
}
|
|
1293
|
+
this.advance();
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
// Unterminated comment
|
|
1297
|
+
var value = this.input.slice(start);
|
|
1298
|
+
this.pos = this.length;
|
|
1299
|
+
this.stats.totalComments++;
|
|
1300
|
+
var c = {
|
|
1301
|
+
type: 'comment',
|
|
1302
|
+
value: value,
|
|
1303
|
+
style: 'multi-line'
|
|
1304
|
+
};
|
|
1305
|
+
if (this.options.onComment) {
|
|
1306
|
+
var _result = this.options.onComment(c);
|
|
1307
|
+
if (_result === null) return null;
|
|
1308
|
+
if (_result) return _result;
|
|
1309
|
+
}
|
|
1310
|
+
return c;
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
// ── Selectors ─────────────────────────────────────────────────────────────
|
|
1314
|
+
|
|
1315
|
+
/**
|
|
1316
|
+
* Splits a raw selector string on commas (respecting parentheses depth)
|
|
1317
|
+
* and returns one CssSelector per part.
|
|
1318
|
+
*/
|
|
1319
|
+
}, {
|
|
1320
|
+
key: "parseSelectorList",
|
|
1321
|
+
value: function parseSelectorList(raw) {
|
|
1322
|
+
var parts = [];
|
|
1323
|
+
var depth = 0,
|
|
1324
|
+
start = 0;
|
|
1325
|
+
for (var i = 0; i < raw.length; i++) {
|
|
1326
|
+
var c = raw.charCodeAt(i);
|
|
1327
|
+
if (c === CC_LPAREN || c === CC_LBRACK) depth++;else if (c === CC_RPAREN || c === CC_RBRACK) depth--;else if (c === CC_COMMA && depth === 0) {
|
|
1328
|
+
parts.push(raw.slice(start, i).trim());
|
|
1329
|
+
start = i + 1;
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
parts.push(raw.slice(start).trim());
|
|
1333
|
+
return parts.filter(function (p) {
|
|
1334
|
+
return p.length > 0;
|
|
1335
|
+
}).map(function (p) {
|
|
1336
|
+
return {
|
|
1337
|
+
type: 'selector',
|
|
1338
|
+
value: p
|
|
1339
|
+
};
|
|
1340
|
+
});
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
/**
|
|
1344
|
+
* Simple specificity scorer — counts IDs, classes/attributes/pseudos, elements.
|
|
1345
|
+
*/
|
|
1346
|
+
}, {
|
|
1347
|
+
key: "calcSpecificity",
|
|
1348
|
+
value: function calcSpecificity(sel) {
|
|
1349
|
+
var ids = 0,
|
|
1350
|
+
classes = 0,
|
|
1351
|
+
elements = 0;
|
|
1352
|
+
var i = 0;
|
|
1353
|
+
while (i < sel.length) {
|
|
1354
|
+
var c = sel.charCodeAt(i);
|
|
1355
|
+
if (c === CC_HASH) {
|
|
1356
|
+
ids++;
|
|
1357
|
+
i++;
|
|
1358
|
+
while (i < sel.length && isNameChar(sel.charCodeAt(i))) i++;
|
|
1359
|
+
} else if (c === CC_DOT) {
|
|
1360
|
+
classes++;
|
|
1361
|
+
i++;
|
|
1362
|
+
while (i < sel.length && isNameChar(sel.charCodeAt(i))) i++;
|
|
1363
|
+
} else if (c === CC_LBRACK) {
|
|
1364
|
+
classes++;
|
|
1365
|
+
while (i < sel.length && sel.charCodeAt(i) !== CC_RBRACK) i++;
|
|
1366
|
+
i++;
|
|
1367
|
+
} else if (c === CC_COLON) {
|
|
1368
|
+
if (sel.charCodeAt(i + 1) === CC_COLON) {
|
|
1369
|
+
elements++;
|
|
1370
|
+
i += 2;
|
|
1371
|
+
} else {
|
|
1372
|
+
// :not(), :is(), :has() — don't double-count the wrapper
|
|
1373
|
+
classes++;
|
|
1374
|
+
i++;
|
|
1375
|
+
}
|
|
1376
|
+
while (i < sel.length && isNameChar(sel.charCodeAt(i))) i++;
|
|
1377
|
+
// skip argument parens
|
|
1378
|
+
if (i < sel.length && sel.charCodeAt(i) === CC_LPAREN) {
|
|
1379
|
+
var d = 1;
|
|
1380
|
+
i++;
|
|
1381
|
+
while (i < sel.length && d > 0) {
|
|
1382
|
+
if (sel.charCodeAt(i) === CC_LPAREN) d++;else if (sel.charCodeAt(i) === CC_RPAREN) d--;
|
|
1383
|
+
i++;
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
} else if (isAlpha(c) || c === CC_UNDER) {
|
|
1387
|
+
elements++;
|
|
1388
|
+
while (i < sel.length && isNameChar(sel.charCodeAt(i))) i++;
|
|
1389
|
+
} else {
|
|
1390
|
+
i++;
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
return {
|
|
1394
|
+
ids: ids,
|
|
1395
|
+
classes: classes,
|
|
1396
|
+
elements: elements,
|
|
1397
|
+
total: ids * 100 + classes * 10 + elements
|
|
1398
|
+
};
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
// ── Value tokenizer ───────────────────────────────────────────────────────
|
|
1402
|
+
|
|
1403
|
+
/**
|
|
1404
|
+
* Tokenises a raw CSS value string into a flat array of CssValue tokens.
|
|
1405
|
+
* Handles: strings, colors (#hex), numbers/dimensions/percentages,
|
|
1406
|
+
* functions (recursive), identifiers, operators, commas.
|
|
1407
|
+
*/
|
|
1408
|
+
}, {
|
|
1409
|
+
key: "tokenizeValue",
|
|
1410
|
+
value: function tokenizeValue(raw) {
|
|
1411
|
+
var tokens = [];
|
|
1412
|
+
var i = 0;
|
|
1413
|
+
var len = raw.length;
|
|
1414
|
+
while (i < len) {
|
|
1415
|
+
var c = raw.charCodeAt(i);
|
|
1416
|
+
|
|
1417
|
+
// Whitespace — skip (no whitespace tokens)
|
|
1418
|
+
if (isWS(c)) {
|
|
1419
|
+
i++;
|
|
1420
|
+
continue;
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
// Quoted string
|
|
1424
|
+
if (c === CC_DQUOTE || c === CC_SQUOTE) {
|
|
1425
|
+
var q = c;
|
|
1426
|
+
i++;
|
|
1427
|
+
var s = i;
|
|
1428
|
+
while (i < len && raw.charCodeAt(i) !== q) {
|
|
1429
|
+
if (raw.charCodeAt(i) === CC_BSLASH) i++;
|
|
1430
|
+
i++;
|
|
1431
|
+
}
|
|
1432
|
+
tokens.push({
|
|
1433
|
+
type: 'string',
|
|
1434
|
+
value: raw.slice(s, i)
|
|
1435
|
+
});
|
|
1436
|
+
i++; // closing quote
|
|
1437
|
+
continue;
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
// Hex color (#rrggbb / #rgb / #rrggbbaa / #rgba)
|
|
1441
|
+
if (c === CC_HASH) {
|
|
1442
|
+
var _s = i++;
|
|
1443
|
+
while (i < len && isHex(raw.charCodeAt(i))) i++;
|
|
1444
|
+
tokens.push({
|
|
1445
|
+
type: 'color',
|
|
1446
|
+
value: raw.slice(_s, i)
|
|
1447
|
+
});
|
|
1448
|
+
continue;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
// Number / dimension / percentage
|
|
1452
|
+
// Handles: 10, 1.5, .5, 1e3, +10px, -2em, 50%
|
|
1453
|
+
var isNumStart = isDigit(c) || c === CC_DOT && isDigit(raw.charCodeAt(i + 1)) || (c === CC_PLUS || c === CC_MINUS) && (isDigit(raw.charCodeAt(i + 1)) || raw.charCodeAt(i + 1) === CC_DOT && isDigit(raw.charCodeAt(i + 2)));
|
|
1454
|
+
if (isNumStart) {
|
|
1455
|
+
var _s2 = i;
|
|
1456
|
+
if (c === CC_PLUS || c === CC_MINUS) i++;
|
|
1457
|
+
while (i < len && isDigit(raw.charCodeAt(i))) i++;
|
|
1458
|
+
if (i < len && raw.charCodeAt(i) === CC_DOT) {
|
|
1459
|
+
i++;
|
|
1460
|
+
while (i < len && isDigit(raw.charCodeAt(i))) i++;
|
|
1461
|
+
}
|
|
1462
|
+
// Exponent
|
|
1463
|
+
if (i < len && (raw.charCodeAt(i) === 101 || raw.charCodeAt(i) === 69)) {
|
|
1464
|
+
i++;
|
|
1465
|
+
if (i < len && (raw.charCodeAt(i) === CC_PLUS || raw.charCodeAt(i) === CC_MINUS)) i++;
|
|
1466
|
+
while (i < len && isDigit(raw.charCodeAt(i))) i++;
|
|
1467
|
+
}
|
|
1468
|
+
var num = parseFloat(raw.slice(_s2, i));
|
|
1469
|
+
// Unit / percentage
|
|
1470
|
+
var us = i;
|
|
1471
|
+
while (i < len && (isAlpha(raw.charCodeAt(i)) || raw.charCodeAt(i) === CC_UNDER)) i++;
|
|
1472
|
+
if (i < len && raw[i] === '%') i++;
|
|
1473
|
+
var unit = raw.slice(us, i);
|
|
1474
|
+
if (unit === '%') tokens.push({
|
|
1475
|
+
type: 'percentage',
|
|
1476
|
+
value: num
|
|
1477
|
+
});else if (unit) tokens.push({
|
|
1478
|
+
type: 'dimension',
|
|
1479
|
+
value: num,
|
|
1480
|
+
unit: unit
|
|
1481
|
+
});else tokens.push({
|
|
1482
|
+
type: 'number',
|
|
1483
|
+
value: num
|
|
1484
|
+
});
|
|
1485
|
+
continue;
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
// Identifier or function call
|
|
1489
|
+
if (isNameStart(c)) {
|
|
1490
|
+
var _s3 = i;
|
|
1491
|
+
while (i < len && isNameChar(raw.charCodeAt(i))) i++;
|
|
1492
|
+
var name = raw.slice(_s3, i);
|
|
1493
|
+
if (i < len && raw.charCodeAt(i) === CC_LPAREN) {
|
|
1494
|
+
i++; // '('
|
|
1495
|
+
var as_ = i;
|
|
1496
|
+
var depth = 1;
|
|
1497
|
+
while (i < len && depth > 0) {
|
|
1498
|
+
var ch = raw.charCodeAt(i);
|
|
1499
|
+
if (ch === CC_LPAREN) depth++;else if (ch === CC_RPAREN) depth--;
|
|
1500
|
+
i++;
|
|
1501
|
+
}
|
|
1502
|
+
var argStr = raw.slice(as_, i - 1);
|
|
1503
|
+
var args = name.toLowerCase() === 'url' ? [{
|
|
1504
|
+
type: 'string',
|
|
1505
|
+
value: argStr.replace(/^['"]|['"]$/g, '')
|
|
1506
|
+
}] : this.tokenizeValue(argStr);
|
|
1507
|
+
tokens.push({
|
|
1508
|
+
type: 'function',
|
|
1509
|
+
name: name,
|
|
1510
|
+
value: "".concat(name, "(").concat(argStr, ")"),
|
|
1511
|
+
args: args
|
|
1512
|
+
});
|
|
1513
|
+
} else {
|
|
1514
|
+
tokens.push({
|
|
1515
|
+
type: 'identifier',
|
|
1516
|
+
value: name
|
|
1517
|
+
});
|
|
1518
|
+
}
|
|
1519
|
+
continue;
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
// Comma
|
|
1523
|
+
if (c === CC_COMMA) {
|
|
1524
|
+
tokens.push({
|
|
1525
|
+
type: 'comma',
|
|
1526
|
+
value: ','
|
|
1527
|
+
});
|
|
1528
|
+
i++;
|
|
1529
|
+
continue;
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
// Operator or any other character
|
|
1533
|
+
tokens.push({
|
|
1534
|
+
type: 'operator',
|
|
1535
|
+
value: raw[i]
|
|
1536
|
+
});
|
|
1537
|
+
i++;
|
|
1538
|
+
}
|
|
1539
|
+
this.stats.totalValues += tokens.length;
|
|
1540
|
+
return tokens;
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
// ── Scanner primitives ────────────────────────────────────────────────────
|
|
1544
|
+
}, {
|
|
1545
|
+
key: "peek",
|
|
1546
|
+
value: function peek() {
|
|
1547
|
+
var offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
1548
|
+
return this.input.charCodeAt(this.pos + offset);
|
|
1549
|
+
}
|
|
1550
|
+
}, {
|
|
1551
|
+
key: "advance",
|
|
1552
|
+
value: function advance() {
|
|
1553
|
+
if (this.pos < this.length) {
|
|
1554
|
+
if (this.input.charCodeAt(this.pos) === CC_LF) {
|
|
1555
|
+
this.line++;
|
|
1556
|
+
this.col = 1;
|
|
1557
|
+
} else this.col++;
|
|
1558
|
+
this.pos++;
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
}, {
|
|
1562
|
+
key: "skipWS",
|
|
1563
|
+
value: function skipWS() {
|
|
1564
|
+
while (this.pos < this.length && isWS(this.peek())) this.advance();
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
/**
|
|
1568
|
+
* Read a CSS identifier (supports `--custom-props` and `-vendor-prefix`).
|
|
1569
|
+
* Returns empty string if the current position isn't the start of an ident.
|
|
1570
|
+
*/
|
|
1571
|
+
}, {
|
|
1572
|
+
key: "readIdent",
|
|
1573
|
+
value: function readIdent() {
|
|
1574
|
+
if (this.pos >= this.length) return '';
|
|
1575
|
+
var c = this.peek();
|
|
1576
|
+
// Allow backslash-escape as a valid ident start (e.g. \/ in custom props)
|
|
1577
|
+
if (!isNameStart(c) && c !== CC_BSLASH) return '';
|
|
1578
|
+
var start = this.pos;
|
|
1579
|
+
while (this.pos < this.length) {
|
|
1580
|
+
var ch = this.peek();
|
|
1581
|
+
if (ch === CC_BSLASH) {
|
|
1582
|
+
// CSS escape sequence: consume backslash + following char/codepoint
|
|
1583
|
+
// Preserve raw text (including the backslash) so the generator
|
|
1584
|
+
// can emit valid CSS unchanged.
|
|
1585
|
+
this.advance(); // consume '\'
|
|
1586
|
+
if (this.pos >= this.length) break;
|
|
1587
|
+
var next = this.peek();
|
|
1588
|
+
if (isHex(next)) {
|
|
1589
|
+
// 1–6 hex digits
|
|
1590
|
+
var hexLen = 0;
|
|
1591
|
+
while (this.pos < this.length && isHex(this.peek()) && hexLen < 6) {
|
|
1592
|
+
this.advance();
|
|
1593
|
+
hexLen++;
|
|
1594
|
+
}
|
|
1595
|
+
// optional single whitespace after hex escape
|
|
1596
|
+
if (this.pos < this.length && isWS(this.peek())) this.advance();
|
|
1597
|
+
} else if (next === CC_LF || next === CC_CR || next === CC_FF) {
|
|
1598
|
+
// newline inside escape — skip
|
|
1599
|
+
this.advance();
|
|
1600
|
+
} else {
|
|
1601
|
+
// e.g. \/ — consume the escaped character
|
|
1602
|
+
this.advance();
|
|
1603
|
+
}
|
|
1604
|
+
} else if (isNameChar(ch)) {
|
|
1605
|
+
this.advance();
|
|
1606
|
+
} else {
|
|
1607
|
+
break;
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
return this.input.slice(start, this.pos);
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
/**
|
|
1614
|
+
* Read at-rule prelude: raw text from current position up to (but not
|
|
1615
|
+
* including) the next `{` or `;` at depth 0.
|
|
1616
|
+
* Parentheses, brackets, strings and comments are respected.
|
|
1617
|
+
*/
|
|
1618
|
+
}, {
|
|
1619
|
+
key: "readPrelude",
|
|
1620
|
+
value: function readPrelude() {
|
|
1621
|
+
var start = this.pos;
|
|
1622
|
+
var depth = 0;
|
|
1623
|
+
while (this.pos < this.length) {
|
|
1624
|
+
var c = this.peek();
|
|
1625
|
+
if (c === CC_DQUOTE || c === CC_SQUOTE) {
|
|
1626
|
+
this.skipString(c);
|
|
1627
|
+
continue;
|
|
1628
|
+
}
|
|
1629
|
+
if (c === CC_SLASH && this.peek(1) === CC_STAR) {
|
|
1630
|
+
this.skipMLComment();
|
|
1631
|
+
continue;
|
|
1632
|
+
}
|
|
1633
|
+
if (c === CC_LPAREN || c === CC_LBRACK) {
|
|
1634
|
+
depth++;
|
|
1635
|
+
this.advance();
|
|
1636
|
+
continue;
|
|
1637
|
+
}
|
|
1638
|
+
if (c === CC_RPAREN || c === CC_RBRACK) {
|
|
1639
|
+
depth--;
|
|
1640
|
+
this.advance();
|
|
1641
|
+
continue;
|
|
1642
|
+
}
|
|
1643
|
+
if (depth === 0 && (c === CC_LBRACE || c === CC_SEMI)) break;
|
|
1644
|
+
this.advance();
|
|
1645
|
+
}
|
|
1646
|
+
return this.input.slice(start, this.pos).trim();
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
/**
|
|
1650
|
+
* Read a declaration value: raw text up to `;` or `}` at depth 0.
|
|
1651
|
+
*/
|
|
1652
|
+
}, {
|
|
1653
|
+
key: "readRawValue",
|
|
1654
|
+
value: function readRawValue() {
|
|
1655
|
+
var start = this.pos;
|
|
1656
|
+
var depth = 0;
|
|
1657
|
+
while (this.pos < this.length) {
|
|
1658
|
+
var c = this.peek();
|
|
1659
|
+
// Backslash escape: consume '\' + next char as a unit.
|
|
1660
|
+
// This prevents '\"' from being misread as a string delimiter,
|
|
1661
|
+
// '\;' from prematurely terminating the value, and '\(' from
|
|
1662
|
+
// incorrectly incrementing paren depth.
|
|
1663
|
+
if (c === CC_BSLASH) {
|
|
1664
|
+
this.advance(); // consume '\'
|
|
1665
|
+
if (this.pos < this.length) this.advance(); // consume escaped char
|
|
1666
|
+
continue;
|
|
1667
|
+
}
|
|
1668
|
+
if (c === CC_DQUOTE || c === CC_SQUOTE) {
|
|
1669
|
+
this.skipString(c);
|
|
1670
|
+
continue;
|
|
1671
|
+
}
|
|
1672
|
+
if (c === CC_SLASH && this.peek(1) === CC_STAR) {
|
|
1673
|
+
this.skipMLComment();
|
|
1674
|
+
continue;
|
|
1675
|
+
}
|
|
1676
|
+
if (c === CC_LPAREN || c === CC_LBRACK) {
|
|
1677
|
+
depth++;
|
|
1678
|
+
this.advance();
|
|
1679
|
+
continue;
|
|
1680
|
+
}
|
|
1681
|
+
if (c === CC_RPAREN || c === CC_RBRACK) {
|
|
1682
|
+
depth--;
|
|
1683
|
+
this.advance();
|
|
1684
|
+
continue;
|
|
1685
|
+
}
|
|
1686
|
+
if (depth === 0 && (c === CC_SEMI || c === CC_RBRACE)) break;
|
|
1687
|
+
this.advance();
|
|
1688
|
+
}
|
|
1689
|
+
return this.input.slice(start, this.pos).trim();
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
/**
|
|
1693
|
+
* Read a selector (rule prelude): raw text up to the first `{` at depth 0.
|
|
1694
|
+
* Parentheses, brackets, strings and comments are respected.
|
|
1695
|
+
*/
|
|
1696
|
+
}, {
|
|
1697
|
+
key: "readUntilLBrace",
|
|
1698
|
+
value: function readUntilLBrace() {
|
|
1699
|
+
var start = this.pos;
|
|
1700
|
+
var depth = 0;
|
|
1701
|
+
while (this.pos < this.length) {
|
|
1702
|
+
var c = this.peek();
|
|
1703
|
+
// Backslash escape: consume '\' + next char as a unit.
|
|
1704
|
+
// Prevents '\{' from falsely terminating the selector,
|
|
1705
|
+
// and '\"' from being misread as a string delimiter.
|
|
1706
|
+
if (c === CC_BSLASH) {
|
|
1707
|
+
this.advance(); // consume '\'
|
|
1708
|
+
if (this.pos < this.length) this.advance(); // consume escaped char
|
|
1709
|
+
continue;
|
|
1710
|
+
}
|
|
1711
|
+
if (c === CC_DQUOTE || c === CC_SQUOTE) {
|
|
1712
|
+
this.skipString(c);
|
|
1713
|
+
continue;
|
|
1714
|
+
}
|
|
1715
|
+
if (c === CC_SLASH && this.peek(1) === CC_STAR) {
|
|
1716
|
+
this.skipMLComment();
|
|
1717
|
+
continue;
|
|
1718
|
+
}
|
|
1719
|
+
if (c === CC_LPAREN || c === CC_LBRACK) {
|
|
1720
|
+
depth++;
|
|
1721
|
+
this.advance();
|
|
1722
|
+
continue;
|
|
1723
|
+
}
|
|
1724
|
+
if (c === CC_RPAREN || c === CC_RBRACK) {
|
|
1725
|
+
depth--;
|
|
1726
|
+
this.advance();
|
|
1727
|
+
continue;
|
|
1728
|
+
}
|
|
1729
|
+
if (depth === 0 && c === CC_LBRACE) break;
|
|
1730
|
+
this.advance();
|
|
1731
|
+
}
|
|
1732
|
+
return this.input.slice(start, this.pos);
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
/** Skip a quoted string starting at the current position (quote char given). */
|
|
1736
|
+
}, {
|
|
1737
|
+
key: "skipString",
|
|
1738
|
+
value: function skipString(quote) {
|
|
1739
|
+
this.advance(); // opening quote
|
|
1740
|
+
while (this.pos < this.length) {
|
|
1741
|
+
var c = this.peek();
|
|
1742
|
+
if (c === CC_BSLASH) {
|
|
1743
|
+
this.advance();
|
|
1744
|
+
this.advance();
|
|
1745
|
+
continue;
|
|
1746
|
+
}
|
|
1747
|
+
if (c === quote) {
|
|
1748
|
+
this.advance();
|
|
1749
|
+
return;
|
|
1750
|
+
}
|
|
1751
|
+
if (c === CC_LF) return; // unterminated → stop
|
|
1752
|
+
this.advance();
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
/** Skip a block comment (slash-star ... star-slash) starting at current position. */
|
|
1757
|
+
}, {
|
|
1758
|
+
key: "skipMLComment",
|
|
1759
|
+
value: function skipMLComment() {
|
|
1760
|
+
this.advance();
|
|
1761
|
+
this.advance(); // '/' '*'
|
|
1762
|
+
while (this.pos < this.length - 1) {
|
|
1763
|
+
if (this.peek() === CC_STAR && this.peek(1) === CC_SLASH) {
|
|
1764
|
+
this.advance();
|
|
1765
|
+
this.advance();
|
|
1766
|
+
return;
|
|
1767
|
+
}
|
|
1768
|
+
this.advance();
|
|
1769
|
+
}
|
|
1770
|
+
this.pos = this.length;
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
/** Skip a balanced `{ … }` block (including the opening brace). */
|
|
1774
|
+
}, {
|
|
1775
|
+
key: "skipBalancedBraces",
|
|
1776
|
+
value: function skipBalancedBraces() {
|
|
1777
|
+
if (this.peek() !== CC_LBRACE) return;
|
|
1778
|
+
var depth = 0;
|
|
1779
|
+
while (this.pos < this.length) {
|
|
1780
|
+
var c = this.peek();
|
|
1781
|
+
if (c === CC_LBRACE) depth++;else if (c === CC_RBRACE) {
|
|
1782
|
+
depth--;
|
|
1783
|
+
if (depth === 0) {
|
|
1784
|
+
this.advance();
|
|
1785
|
+
return;
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
this.advance();
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
/**
|
|
1793
|
+
* Lookahead: scan forward from current position and return true if
|
|
1794
|
+
* an unescaped `{` at depth 0 is found before any `;` or `}`.
|
|
1795
|
+
* Used in `rule` block mode to distinguish declarations from nested rules.
|
|
1796
|
+
*/
|
|
1797
|
+
}, {
|
|
1798
|
+
key: "lookaheadIsRule",
|
|
1799
|
+
value: function lookaheadIsRule() {
|
|
1800
|
+
var i = this.pos,
|
|
1801
|
+
depth = 0;
|
|
1802
|
+
while (i < this.length) {
|
|
1803
|
+
var c = this.input.charCodeAt(i);
|
|
1804
|
+
if (c === CC_DQUOTE || c === CC_SQUOTE) {
|
|
1805
|
+
var q = c;
|
|
1806
|
+
i++;
|
|
1807
|
+
while (i < this.length && this.input.charCodeAt(i) !== q) {
|
|
1808
|
+
if (this.input.charCodeAt(i) === CC_BSLASH) i++;
|
|
1809
|
+
i++;
|
|
1810
|
+
}
|
|
1811
|
+
i++;
|
|
1812
|
+
continue;
|
|
1813
|
+
}
|
|
1814
|
+
if (c === CC_LPAREN || c === CC_LBRACK) {
|
|
1815
|
+
depth++;
|
|
1816
|
+
i++;
|
|
1817
|
+
continue;
|
|
1818
|
+
}
|
|
1819
|
+
if (c === CC_RPAREN || c === CC_RBRACK) {
|
|
1820
|
+
depth--;
|
|
1821
|
+
i++;
|
|
1822
|
+
continue;
|
|
1823
|
+
}
|
|
1824
|
+
if (depth === 0) {
|
|
1825
|
+
if (c === CC_LBRACE) return true;
|
|
1826
|
+
if (c === CC_SEMI || c === CC_RBRACE) return false;
|
|
1827
|
+
}
|
|
1828
|
+
i++;
|
|
1829
|
+
}
|
|
1830
|
+
return false;
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
/**
|
|
1834
|
+
* Characters that unambiguously start a CSS nesting selector
|
|
1835
|
+
* (can never be the start of a property name).
|
|
1836
|
+
*/
|
|
1837
|
+
}, {
|
|
1838
|
+
key: "isNestingStart",
|
|
1839
|
+
value: function isNestingStart(c) {
|
|
1840
|
+
return c === CC_AMP // & nesting selector
|
|
1841
|
+
|| c === CC_DOT // . class
|
|
1842
|
+
|| c === CC_HASH // # id
|
|
1843
|
+
|| c === CC_LBRACK // [ attribute
|
|
1844
|
+
|| c === 42 // * universal
|
|
1845
|
+
|| c === CC_GT // > child combinator
|
|
1846
|
+
|| c === CC_PLUS // + adjacent sibling
|
|
1847
|
+
|| c === CC_TILDE // ~ general sibling
|
|
1848
|
+
|| c === CC_COLON; // : pseudo-class / ::pseudo-element
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
/** Advance past chars until one of the given charcodes (exclusive). */
|
|
1852
|
+
}, {
|
|
1853
|
+
key: "recoverTo",
|
|
1854
|
+
value: function recoverTo() {
|
|
1855
|
+
for (var _len = arguments.length, stops = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1856
|
+
stops[_key] = arguments[_key];
|
|
1857
|
+
}
|
|
1858
|
+
while (this.pos < this.length && !stops.includes(this.peek())) this.advance();
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
/** Advance past chars until one of the given charcodes, then advance one more. */
|
|
1862
|
+
}, {
|
|
1863
|
+
key: "recoverPast",
|
|
1864
|
+
value: function recoverPast() {
|
|
1865
|
+
this.recoverTo.apply(this, arguments);
|
|
1866
|
+
if (this.pos < this.length) this.advance();
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
// ── Location helpers ──────────────────────────────────────────────────────
|
|
1870
|
+
}, {
|
|
1871
|
+
key: "locPos",
|
|
1872
|
+
value: function locPos() {
|
|
1873
|
+
return {
|
|
1874
|
+
line: this.line,
|
|
1875
|
+
column: this.col,
|
|
1876
|
+
offset: this.pos
|
|
1877
|
+
};
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
// ── Stylesheet categorizer ────────────────────────────────────────────────
|
|
1881
|
+
}, {
|
|
1882
|
+
key: "categorize",
|
|
1883
|
+
value: function categorize(ss, node) {
|
|
1884
|
+
var _ar$preludeText, _ar$preludeText2;
|
|
1885
|
+
if (node.type !== 'atrule') return;
|
|
1886
|
+
var ar = node;
|
|
1887
|
+
var base = ar.name.replace(/^-(webkit|moz|ms|o)-/, '');
|
|
1888
|
+
switch (base) {
|
|
1889
|
+
case 'import':
|
|
1890
|
+
ss.imports.push(ar);
|
|
1891
|
+
break;
|
|
1892
|
+
case 'media':
|
|
1893
|
+
ss.mediaQueries.push({
|
|
1894
|
+
type: 'media-query',
|
|
1895
|
+
media: (_ar$preludeText = ar.preludeText) !== null && _ar$preludeText !== void 0 ? _ar$preludeText : '',
|
|
1896
|
+
features: [],
|
|
1897
|
+
loc: ar.loc
|
|
1898
|
+
});
|
|
1899
|
+
break;
|
|
1900
|
+
case 'namespace':
|
|
1901
|
+
ss.namespaces.push(ar);
|
|
1902
|
+
break;
|
|
1903
|
+
case 'keyframes':
|
|
1904
|
+
ss.keyframes.push(ar);
|
|
1905
|
+
break;
|
|
1906
|
+
case 'font-face':
|
|
1907
|
+
ss.fontFaces.push(ar);
|
|
1908
|
+
break;
|
|
1909
|
+
case 'layer':
|
|
1910
|
+
{
|
|
1911
|
+
var layerRule = ar;
|
|
1912
|
+
// preludeText holds the layer name (e.g. "atomic" for "@layer atomic { … }")
|
|
1913
|
+
if (ar.preludeText) layerRule.layerName = ar.preludeText.trim();
|
|
1914
|
+
ss.layers.push(layerRule);
|
|
1915
|
+
break;
|
|
1916
|
+
}
|
|
1917
|
+
case 'container':
|
|
1918
|
+
{
|
|
1919
|
+
var containerRule = ar;
|
|
1920
|
+
if (ar.preludeText) {
|
|
1921
|
+
// "@container main (width > 600px)" → name is the first token
|
|
1922
|
+
var parts = ar.preludeText.trim().match(/^([\w-]+)?\s*(.*)/);
|
|
1923
|
+
if (parts !== null && parts !== void 0 && parts[1]) containerRule.containerName = parts[1];
|
|
1924
|
+
if (parts !== null && parts !== void 0 && parts[2]) containerRule.containerQuery = parts[2].trim();
|
|
1925
|
+
}
|
|
1926
|
+
ss.containers.push(containerRule);
|
|
1927
|
+
break;
|
|
1928
|
+
}
|
|
1929
|
+
case 'supports':
|
|
1930
|
+
ss.supports.push(ar);
|
|
1931
|
+
break;
|
|
1932
|
+
case 'document':
|
|
1933
|
+
ss.documents.push(ar);
|
|
1934
|
+
break;
|
|
1935
|
+
case 'page':
|
|
1936
|
+
ss.pages.push(ar);
|
|
1937
|
+
break;
|
|
1938
|
+
case 'counter-style':
|
|
1939
|
+
ss.counterStyles.push(ar);
|
|
1940
|
+
break;
|
|
1941
|
+
case 'font-feature-values':
|
|
1942
|
+
ss.fontFeatureValues.push(ar);
|
|
1943
|
+
break;
|
|
1944
|
+
case 'viewport':
|
|
1945
|
+
ss.viewports.push(ar);
|
|
1946
|
+
break;
|
|
1947
|
+
case 'charset':
|
|
1948
|
+
ss.charsets.push(ar);
|
|
1949
|
+
ss.charset = (_ar$preludeText2 = ar.preludeText) === null || _ar$preludeText2 === void 0 ? void 0 : _ar$preludeText2.replace(/^['"]|['"]$/g, '');
|
|
1950
|
+
break;
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
// ── Legacy format ─────────────────────────────────────────────────────────
|
|
1955
|
+
}, {
|
|
1956
|
+
key: "toLegacyNode",
|
|
1957
|
+
value: function toLegacyNode(node) {
|
|
1958
|
+
var _this2 = this;
|
|
1959
|
+
switch (node.type) {
|
|
1960
|
+
case 'rule':
|
|
1961
|
+
{
|
|
1962
|
+
var _r$rawSelector;
|
|
1963
|
+
var r = node;
|
|
1964
|
+
var name = (_r$rawSelector = r.rawSelector) !== null && _r$rawSelector !== void 0 ? _r$rawSelector : r.selectors.map(function (s) {
|
|
1965
|
+
return s.value;
|
|
1966
|
+
}).join(', ');
|
|
1967
|
+
return {
|
|
1968
|
+
kind: 'rule',
|
|
1969
|
+
name: name,
|
|
1970
|
+
value: r.declarations.map(function (d) {
|
|
1971
|
+
var _d$rawValue;
|
|
1972
|
+
return "".concat(d.property, ": ").concat((_d$rawValue = d.rawValue) !== null && _d$rawValue !== void 0 ? _d$rawValue : d.value.map(function (v) {
|
|
1973
|
+
return String(v.value);
|
|
1974
|
+
}).join(' ')).concat(d.important ? ' !important' : '');
|
|
1975
|
+
}).join('; '),
|
|
1976
|
+
important: false,
|
|
1977
|
+
children: r.declarations.map(function (d) {
|
|
1978
|
+
return _this2.toLegacyNode(d);
|
|
1979
|
+
}).filter(Boolean),
|
|
1980
|
+
loc: r.loc,
|
|
1981
|
+
node: 'rule',
|
|
1982
|
+
cssNode: {},
|
|
1983
|
+
parents: [],
|
|
1984
|
+
selectors: r.selectors.map(function (s) {
|
|
1985
|
+
return {
|
|
1986
|
+
kind: 'rule',
|
|
1987
|
+
name: s.value,
|
|
1988
|
+
value: s.value,
|
|
1989
|
+
loc: s.loc,
|
|
1990
|
+
node: 'selector',
|
|
1991
|
+
cssNode: {},
|
|
1992
|
+
parents: []
|
|
1993
|
+
};
|
|
1994
|
+
})
|
|
1995
|
+
};
|
|
1996
|
+
}
|
|
1997
|
+
case 'atrule':
|
|
1998
|
+
{
|
|
1999
|
+
var _ref, _ar$preludeText3, _ar$prelude, _ar$block$children, _ar$block;
|
|
2000
|
+
var ar = node;
|
|
2001
|
+
return {
|
|
2002
|
+
kind: 'atrule',
|
|
2003
|
+
name: ar.name,
|
|
2004
|
+
value: (_ref = (_ar$preludeText3 = ar.preludeText) !== null && _ar$preludeText3 !== void 0 ? _ar$preludeText3 : (_ar$prelude = ar.prelude) === null || _ar$prelude === void 0 ? void 0 : _ar$prelude.map(function (v) {
|
|
2005
|
+
return String(v.value);
|
|
2006
|
+
}).join(' ')) !== null && _ref !== void 0 ? _ref : '',
|
|
2007
|
+
important: false,
|
|
2008
|
+
children: ((_ar$block$children = (_ar$block = ar.block) === null || _ar$block === void 0 ? void 0 : _ar$block.children) !== null && _ar$block$children !== void 0 ? _ar$block$children : []).map(function (c) {
|
|
2009
|
+
return _this2.toLegacyNode(c);
|
|
2010
|
+
}).filter(Boolean),
|
|
2011
|
+
loc: ar.loc,
|
|
2012
|
+
node: 'atrule',
|
|
2013
|
+
cssNode: {},
|
|
2014
|
+
parents: []
|
|
2015
|
+
};
|
|
2016
|
+
}
|
|
2017
|
+
case 'declaration':
|
|
2018
|
+
{
|
|
2019
|
+
var _d$rawValue2;
|
|
2020
|
+
var d = node;
|
|
2021
|
+
return {
|
|
2022
|
+
kind: 'decl',
|
|
2023
|
+
name: d.property,
|
|
2024
|
+
value: (_d$rawValue2 = d.rawValue) !== null && _d$rawValue2 !== void 0 ? _d$rawValue2 : d.value.map(function (v) {
|
|
2025
|
+
return String(v.value);
|
|
2026
|
+
}).join(' '),
|
|
2027
|
+
important: d.important,
|
|
2028
|
+
children: [],
|
|
2029
|
+
loc: d.loc,
|
|
2030
|
+
node: 'declaration',
|
|
2031
|
+
cssNode: {},
|
|
2032
|
+
parents: []
|
|
2033
|
+
};
|
|
2034
|
+
}
|
|
2035
|
+
case 'comment':
|
|
2036
|
+
{
|
|
2037
|
+
var c = node;
|
|
2038
|
+
return {
|
|
2039
|
+
kind: 'comment',
|
|
2040
|
+
name: undefined,
|
|
2041
|
+
value: c.value,
|
|
2042
|
+
important: false,
|
|
2043
|
+
children: [],
|
|
2044
|
+
loc: c.loc,
|
|
2045
|
+
node: 'comment',
|
|
2046
|
+
cssNode: {},
|
|
2047
|
+
parents: []
|
|
2048
|
+
};
|
|
2049
|
+
}
|
|
2050
|
+
default:
|
|
2051
|
+
return null;
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
}], [{
|
|
2055
|
+
key: "emptyStats",
|
|
2056
|
+
value: function emptyStats() {
|
|
2057
|
+
return {
|
|
2058
|
+
totalNodes: 0,
|
|
2059
|
+
totalRules: 0,
|
|
2060
|
+
totalDeclarations: 0,
|
|
2061
|
+
totalAtRules: 0,
|
|
2062
|
+
totalComments: 0,
|
|
2063
|
+
totalSelectors: 0,
|
|
2064
|
+
totalValues: 0,
|
|
2065
|
+
parseTime: 0,
|
|
2066
|
+
memoryUsage: 0,
|
|
2067
|
+
errors: 0,
|
|
2068
|
+
warnings: 0
|
|
2069
|
+
};
|
|
2070
|
+
}
|
|
2071
|
+
}]);
|
|
2072
|
+
}();
|
|
2073
|
+
|
|
2074
|
+
// ─── Public parse helpers ─────────────────────────────────────────────────────
|
|
2075
|
+
|
|
2076
|
+
/** Parse a CSS string into a stylesheet AST. */
|
|
2077
|
+
function parseCss(css, options) {
|
|
2078
|
+
return new CssParser(options).parse(css);
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
// Read `@theme { --color-red-500: …; --spacing: …; }` blocks from CSS into a
|
|
2082
|
+
// Theme. This is the CSS-first way to define tokens; the registry is then
|
|
2083
|
+
// built from the resulting theme.
|
|
2084
|
+
function loadTheme(css) {
|
|
2085
|
+
var theme = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Theme();
|
|
2086
|
+
var sheet = parseCss(css);
|
|
2087
|
+
var _iterator = _createForOfIteratorHelper(sheet.children),
|
|
2088
|
+
_step;
|
|
2089
|
+
try {
|
|
2090
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2091
|
+
var node = _step.value;
|
|
2092
|
+
if (node.type === 'atrule' && node.name === 'theme' && node.block) {
|
|
2093
|
+
collect(node, theme);
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
} catch (err) {
|
|
2097
|
+
_iterator.e(err);
|
|
2098
|
+
} finally {
|
|
2099
|
+
_iterator.f();
|
|
2100
|
+
}
|
|
2101
|
+
return theme;
|
|
2102
|
+
}
|
|
2103
|
+
function collect(atRule, theme) {
|
|
2104
|
+
var _iterator2 = _createForOfIteratorHelper(atRule.block.children),
|
|
2105
|
+
_step2;
|
|
2106
|
+
try {
|
|
2107
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
2108
|
+
var child = _step2.value;
|
|
2109
|
+
if (child.type === 'declaration' && isCustomProperty(child)) {
|
|
2110
|
+
var _child$rawValue;
|
|
2111
|
+
theme.add(child.property, ((_child$rawValue = child.rawValue) !== null && _child$rawValue !== void 0 ? _child$rawValue : '').trim());
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
} catch (err) {
|
|
2115
|
+
_iterator2.e(err);
|
|
2116
|
+
} finally {
|
|
2117
|
+
_iterator2.f();
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
function isCustomProperty(d) {
|
|
2121
|
+
return d.customProperty === true || d.property.startsWith('--');
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2124
|
+
// Emit the theme as `:root { --token: value; … }` so the tokens ship as live
|
|
2125
|
+
// custom properties. Pass `used` to emit only the tokens actually referenced
|
|
2126
|
+
// (plus any they transitively reference) — see {@link collectVarRefs}.
|
|
2127
|
+
function emitTheme(theme) {
|
|
2128
|
+
var selector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ':root';
|
|
2129
|
+
var used = arguments.length > 2 ? arguments[2] : undefined;
|
|
2130
|
+
var entries = used ? usedEntries(theme, used) : theme.entries();
|
|
2131
|
+
return rule(selector, entries.map(function (_ref) {
|
|
2132
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
2133
|
+
name = _ref2[0],
|
|
2134
|
+
value = _ref2[1];
|
|
2135
|
+
return decl(name, value);
|
|
2136
|
+
}));
|
|
2137
|
+
}
|
|
2138
|
+
var VAR_REF = /var\(\s*(--[\w-]+)/g;
|
|
2139
|
+
|
|
2140
|
+
// Every `--token` referenced through `var(--token)` across a compiled tree.
|
|
2141
|
+
function collectVarRefs(nodes) {
|
|
2142
|
+
var into = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Set();
|
|
2143
|
+
var _iterator3 = _createForOfIteratorHelper(nodes),
|
|
2144
|
+
_step3;
|
|
2145
|
+
try {
|
|
2146
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
2147
|
+
var node = _step3.value;
|
|
2148
|
+
if (node.kind === 'declaration') {
|
|
2149
|
+
var _iterator4 = _createForOfIteratorHelper(node.value.matchAll(VAR_REF)),
|
|
2150
|
+
_step4;
|
|
2151
|
+
try {
|
|
2152
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
2153
|
+
var m = _step4.value;
|
|
2154
|
+
into.add(m[1]);
|
|
2155
|
+
}
|
|
2156
|
+
} catch (err) {
|
|
2157
|
+
_iterator4.e(err);
|
|
2158
|
+
} finally {
|
|
2159
|
+
_iterator4.f();
|
|
2160
|
+
}
|
|
2161
|
+
} else if (node.kind === 'raw') {
|
|
2162
|
+
var _iterator5 = _createForOfIteratorHelper(node.text.matchAll(VAR_REF)),
|
|
2163
|
+
_step5;
|
|
2164
|
+
try {
|
|
2165
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
2166
|
+
var _m = _step5.value;
|
|
2167
|
+
into.add(_m[1]);
|
|
2168
|
+
}
|
|
2169
|
+
} catch (err) {
|
|
2170
|
+
_iterator5.e(err);
|
|
2171
|
+
} finally {
|
|
2172
|
+
_iterator5.f();
|
|
2173
|
+
}
|
|
2174
|
+
} else {
|
|
2175
|
+
collectVarRefs(node.nodes, into);
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
} catch (err) {
|
|
2179
|
+
_iterator3.e(err);
|
|
2180
|
+
} finally {
|
|
2181
|
+
_iterator3.f();
|
|
2182
|
+
}
|
|
2183
|
+
return into;
|
|
2184
|
+
}
|
|
2185
|
+
|
|
2186
|
+
// The theme entries to keep for `used`: the referenced tokens plus the transitive
|
|
2187
|
+
// closure of any tokens their own values reference (e.g. `--color-primary:
|
|
2188
|
+
// var(--color-blue-500)`). Insertion order is preserved.
|
|
2189
|
+
function usedEntries(theme, used) {
|
|
2190
|
+
var keep = new Set();
|
|
2191
|
+
var stack = _toConsumableArray(used);
|
|
2192
|
+
while (stack.length) {
|
|
2193
|
+
var name = stack.pop();
|
|
2194
|
+
if (keep.has(name)) continue;
|
|
2195
|
+
var value = theme.get(name);
|
|
2196
|
+
if (value === undefined) continue; // referenced but not a theme token
|
|
2197
|
+
keep.add(name);
|
|
2198
|
+
var _iterator6 = _createForOfIteratorHelper(value.matchAll(VAR_REF)),
|
|
2199
|
+
_step6;
|
|
2200
|
+
try {
|
|
2201
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
2202
|
+
var m = _step6.value;
|
|
2203
|
+
stack.push(m[1]);
|
|
2204
|
+
}
|
|
2205
|
+
} catch (err) {
|
|
2206
|
+
_iterator6.e(err);
|
|
2207
|
+
} finally {
|
|
2208
|
+
_iterator6.f();
|
|
2209
|
+
}
|
|
2210
|
+
}
|
|
2211
|
+
return theme.entries().filter(function (_ref3) {
|
|
2212
|
+
var _ref4 = _slicedToArray(_ref3, 1),
|
|
2213
|
+
name = _ref4[0];
|
|
2214
|
+
return keep.has(name);
|
|
2215
|
+
});
|
|
2216
|
+
}
|
|
2217
|
+
|
|
2218
|
+
// Reads `@utility` and `@custom-variant` blocks from CSS and registers them into
|
|
2219
|
+
// the registry — the CSS-first way to add utilities and variants, alongside
|
|
2220
|
+
// `@theme` for tokens. Call after loadTheme so functional utilities can resolve
|
|
2221
|
+
// against the theme.
|
|
2222
|
+
function loadDirectives(css, reg) {
|
|
2223
|
+
var sheet = parseCss(css);
|
|
2224
|
+
var _iterator = _createForOfIteratorHelper(sheet.children),
|
|
2225
|
+
_step;
|
|
2226
|
+
try {
|
|
2227
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2228
|
+
var node = _step.value;
|
|
2229
|
+
if (node.type !== 'atrule') continue;
|
|
2230
|
+
if (node.name === 'utility') registerUtility(node, reg);else if (node.name === 'custom-variant') registerVariant(node, reg);
|
|
2231
|
+
}
|
|
2232
|
+
} catch (err) {
|
|
2233
|
+
_iterator.e(err);
|
|
2234
|
+
} finally {
|
|
2235
|
+
_iterator.f();
|
|
2236
|
+
}
|
|
2237
|
+
return reg;
|
|
2238
|
+
}
|
|
2239
|
+
function registerUtility(atRule, reg) {
|
|
2240
|
+
var _atRule$preludeText;
|
|
2241
|
+
var name = ((_atRule$preludeText = atRule.preludeText) !== null && _atRule$preludeText !== void 0 ? _atRule$preludeText : '').trim();
|
|
2242
|
+
if (!name || !atRule.block) return;
|
|
2243
|
+
var decls = atRule.block.children.filter(function (c) {
|
|
2244
|
+
return c.type === 'declaration';
|
|
2245
|
+
}).map(function (d) {
|
|
2246
|
+
var _d$rawValue;
|
|
2247
|
+
return decl(d.property, ((_d$rawValue = d.rawValue) !== null && _d$rawValue !== void 0 ? _d$rawValue : '').trim(), d.important === true);
|
|
2248
|
+
});
|
|
2249
|
+
if (decls.length === 0) return;
|
|
2250
|
+
|
|
2251
|
+
// A trailing `-*` marks a functional utility: `tab-*` handles `tab-2`, `tab-[3]`.
|
|
2252
|
+
if (name.endsWith('-*')) {
|
|
2253
|
+
var root = name.slice(0, -2);
|
|
2254
|
+
if (root) reg.dynamicRule(root, function (ctx) {
|
|
2255
|
+
return resolveDeclarations(decls, ctx);
|
|
2256
|
+
});
|
|
2257
|
+
return;
|
|
2258
|
+
}
|
|
2259
|
+
reg.rule(name, decls);
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
// Applies a functional utility's declaration templates to one atom. `--value()`
|
|
2263
|
+
// is required — if it can't resolve, the whole utility is dropped (returns null).
|
|
2264
|
+
// `--modifier()` is optional — a declaration using it is skipped when there's no
|
|
2265
|
+
// matching modifier, so `text-lg` and `text-lg/7` share one definition.
|
|
2266
|
+
function resolveDeclarations(templates, ctx) {
|
|
2267
|
+
var out = [];
|
|
2268
|
+
var _iterator2 = _createForOfIteratorHelper(templates),
|
|
2269
|
+
_step2;
|
|
2270
|
+
try {
|
|
2271
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
2272
|
+
var t = _step2.value;
|
|
2273
|
+
var withValue = replaceFn(t.value, '--value', function (args) {
|
|
2274
|
+
return resolveValue(args, ctx);
|
|
2275
|
+
});
|
|
2276
|
+
if (withValue === null) return null;
|
|
2277
|
+
var withModifier = replaceFn(withValue, '--modifier', function (args) {
|
|
2278
|
+
return resolveModifier(args, ctx);
|
|
2279
|
+
});
|
|
2280
|
+
if (withModifier === null) continue;
|
|
2281
|
+
out.push(_objectSpread2(_objectSpread2({}, t), {}, {
|
|
2282
|
+
value: withModifier
|
|
2283
|
+
}));
|
|
2284
|
+
}
|
|
2285
|
+
} catch (err) {
|
|
2286
|
+
_iterator2.e(err);
|
|
2287
|
+
} finally {
|
|
2288
|
+
_iterator2.f();
|
|
2289
|
+
}
|
|
2290
|
+
return out.length ? out : null;
|
|
2291
|
+
}
|
|
2292
|
+
function resolveValue(args, ctx) {
|
|
2293
|
+
var value = ctx.value;
|
|
2294
|
+
if (!value) return null;
|
|
2295
|
+
for (var _i = 0, _splitArgs = splitArgs(args); _i < _splitArgs.length; _i++) {
|
|
2296
|
+
var arg = _splitArgs[_i];
|
|
2297
|
+
var themed = fromTheme(arg, value.kind === 'named' ? value.value : null, ctx);
|
|
2298
|
+
if (themed !== null) return themed;
|
|
2299
|
+
if (value.kind === 'named') {
|
|
2300
|
+
var lit = fromNamed(arg, value.value);
|
|
2301
|
+
if (lit !== null) return lit;
|
|
2302
|
+
} else {
|
|
2303
|
+
var arb = fromArbitrary(arg, value.value, value.dataType);
|
|
2304
|
+
if (arb !== null) return arb;
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
return null;
|
|
2308
|
+
}
|
|
2309
|
+
function resolveModifier(args, ctx) {
|
|
2310
|
+
var modifier = ctx.modifier;
|
|
2311
|
+
if (!modifier) return null;
|
|
2312
|
+
for (var _i2 = 0, _splitArgs2 = splitArgs(args); _i2 < _splitArgs2.length; _i2++) {
|
|
2313
|
+
var arg = _splitArgs2[_i2];
|
|
2314
|
+
var themed = fromTheme(arg, modifier.kind === 'named' ? modifier.value : null, ctx);
|
|
2315
|
+
if (themed !== null) return themed;
|
|
2316
|
+
if (modifier.kind === 'named') {
|
|
2317
|
+
var lit = fromNamed(arg, modifier.value);
|
|
2318
|
+
if (lit !== null) return lit;
|
|
2319
|
+
} else {
|
|
2320
|
+
var arb = fromArbitrary(arg, modifier.value, null);
|
|
2321
|
+
if (arb !== null) return arb;
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2324
|
+
return null;
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2327
|
+
// `--foo` / `--foo-*` names a theme namespace; the atom's named value keys into
|
|
2328
|
+
// it (`--value(--tab-size)` + `tab-2` → `var(--tab-size-2)`).
|
|
2329
|
+
function fromTheme(arg, key, ctx) {
|
|
2330
|
+
if (key === null || !arg.startsWith('--')) return null;
|
|
2331
|
+
var ns = arg.replace(/-?\*$/, '').slice(2);
|
|
2332
|
+
return ns ? ctx.theme.resolve(ns, key) : null;
|
|
2333
|
+
}
|
|
2334
|
+
|
|
2335
|
+
// A bare value against a data-type keyword (`integer`, `number`, `percentage`) or a
|
|
2336
|
+
// quoted literal (`'inline'`).
|
|
2337
|
+
function fromNamed(arg, value) {
|
|
2338
|
+
if (isQuoted(arg)) return arg.slice(1, -1) === value ? value : null;
|
|
2339
|
+
var rx = NUMERIC[arg];
|
|
2340
|
+
return rx ? rx.test(value) ? value : null : null;
|
|
2341
|
+
}
|
|
2342
|
+
|
|
2343
|
+
// An arbitrary value against `[*]` (anything) or a typed bracket (`[integer]`,
|
|
2344
|
+
// `[length]`), gated on the value's own `type:` hint when it carries one.
|
|
2345
|
+
function fromArbitrary(arg, value, dataType) {
|
|
2346
|
+
if (arg[0] !== '[' || arg[arg.length - 1] !== ']') return null;
|
|
2347
|
+
var want = arg.slice(1, -1);
|
|
2348
|
+
if (want === '*') return value;
|
|
2349
|
+
if (dataType !== null) return dataType === want ? value : null;
|
|
2350
|
+
// Untyped arbitrary: validate against the simple numeric types we can check.
|
|
2351
|
+
var rx = NUMERIC[want];
|
|
2352
|
+
return rx ? rx.test(value) ? value : null : value;
|
|
2353
|
+
}
|
|
2354
|
+
var NUMERIC = {
|
|
2355
|
+
integer: /^-?\d+$/,
|
|
2356
|
+
number: /^-?\d*\.?\d+$/,
|
|
2357
|
+
percentage: /^-?\d*\.?\d+%$/
|
|
2358
|
+
};
|
|
2359
|
+
function isQuoted(s) {
|
|
2360
|
+
return s.length >= 2 && (s[0] === '"' || s[0] === "'") && s[s.length - 1] === s[0];
|
|
2361
|
+
}
|
|
2362
|
+
function splitArgs(args) {
|
|
2363
|
+
return splitAtTopLevel(args, ',').map(function (a) {
|
|
2364
|
+
return a.trim();
|
|
2365
|
+
}).filter(function (a) {
|
|
2366
|
+
return a !== '';
|
|
2367
|
+
});
|
|
2368
|
+
}
|
|
2369
|
+
|
|
2370
|
+
// Replaces every `name(...)` call in `input` (parens balanced, even when nested in
|
|
2371
|
+
// `calc(...)`) with `resolve`'s result. Returns null if any call fails to resolve.
|
|
2372
|
+
function replaceFn(input, name, resolve) {
|
|
2373
|
+
var token = name + '(';
|
|
2374
|
+
var out = '';
|
|
2375
|
+
var i = 0;
|
|
2376
|
+
for (;;) {
|
|
2377
|
+
var start = input.indexOf(token, i);
|
|
2378
|
+
if (start === -1) return out + input.slice(i);
|
|
2379
|
+
out += input.slice(i, start);
|
|
2380
|
+
var depth = 0;
|
|
2381
|
+
var j = start + token.length - 1;
|
|
2382
|
+
for (; j < input.length; j++) {
|
|
2383
|
+
if (input[j] === '(') depth++;else if (input[j] === ')' && --depth === 0) break;
|
|
2384
|
+
}
|
|
2385
|
+
if (j >= input.length) return null; // unbalanced
|
|
2386
|
+
var resolved = resolve(input.slice(start + token.length, j));
|
|
2387
|
+
if (resolved === null) return null;
|
|
2388
|
+
out += resolved;
|
|
2389
|
+
i = j + 1;
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
function registerVariant(atRule, reg) {
|
|
2393
|
+
var _atRule$preludeText2;
|
|
2394
|
+
var prelude = ((_atRule$preludeText2 = atRule.preludeText) !== null && _atRule$preludeText2 !== void 0 ? _atRule$preludeText2 : '').trim();
|
|
2395
|
+
if (!prelude) return;
|
|
2396
|
+
|
|
2397
|
+
// `name (condition)` shorthand — the block form isn't supported yet.
|
|
2398
|
+
var paren = prelude.indexOf('(');
|
|
2399
|
+
if (paren === -1 || !prelude.endsWith(')')) return;
|
|
2400
|
+
var name = prelude.slice(0, paren).trim();
|
|
2401
|
+
var condition = prelude.slice(paren + 1, -1).trim();
|
|
2402
|
+
if (!name || !condition) return;
|
|
2403
|
+
reg.variant(name, wrapFor(condition));
|
|
2404
|
+
}
|
|
2405
|
+
function wrapFor(condition) {
|
|
2406
|
+
if (condition[0] === '@') {
|
|
2407
|
+
var cut = condition.search(/[\s(]/);
|
|
2408
|
+
var at = cut === -1 ? condition.slice(1) : condition.slice(1, cut);
|
|
2409
|
+
var params = cut === -1 ? '' : condition.slice(cut).trim();
|
|
2410
|
+
return {
|
|
2411
|
+
atRule: {
|
|
2412
|
+
name: at,
|
|
2413
|
+
params: params
|
|
2414
|
+
}
|
|
2415
|
+
};
|
|
2416
|
+
}
|
|
2417
|
+
return {
|
|
2418
|
+
selector: condition.includes('&') ? condition : "&".concat(condition)
|
|
2419
|
+
};
|
|
2420
|
+
}
|
|
2421
|
+
|
|
2422
|
+
// A variant either narrows the selector (`&:hover`, `.group:hover &`) or wraps
|
|
2423
|
+
// the rule in an at-rule (`@media`, `@supports`). It may do both.
|
|
2424
|
+
|
|
2425
|
+
// Holds the theme plus the rule and variant tables, and answers the keyword vs
|
|
2426
|
+
// value-taking questions the atom parser asks.
|
|
2427
|
+
var Registry = /*#__PURE__*/function () {
|
|
2428
|
+
function Registry() {
|
|
2429
|
+
var _this = this;
|
|
2430
|
+
var theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Theme();
|
|
2431
|
+
_classCallCheck(this, Registry);
|
|
2432
|
+
_defineProperty(this, "rules", new Map());
|
|
2433
|
+
_defineProperty(this, "dynamicRules", new Map());
|
|
2434
|
+
_defineProperty(this, "variants", new Map());
|
|
2435
|
+
_defineProperty(this, "dynamicVariants", new Map());
|
|
2436
|
+
_defineProperty(this, "isRule", function (root) {
|
|
2437
|
+
return _this.rules.has(root);
|
|
2438
|
+
});
|
|
2439
|
+
_defineProperty(this, "isDynamicRule", function (root) {
|
|
2440
|
+
return _this.dynamicRules.has(root);
|
|
2441
|
+
});
|
|
2442
|
+
_defineProperty(this, "isVariant", function (root) {
|
|
2443
|
+
return _this.variants.has(root);
|
|
2444
|
+
});
|
|
2445
|
+
_defineProperty(this, "isDynamicVariant", function (root) {
|
|
2446
|
+
return _this.dynamicVariants.has(root);
|
|
2447
|
+
});
|
|
2448
|
+
this.theme = theme;
|
|
2449
|
+
}
|
|
2450
|
+
return _createClass(Registry, [{
|
|
2451
|
+
key: "rule",
|
|
2452
|
+
value: function rule(name, declarations) {
|
|
2453
|
+
this.rules.set(name, declarations);
|
|
2454
|
+
return this;
|
|
2455
|
+
}
|
|
2456
|
+
}, {
|
|
2457
|
+
key: "dynamicRule",
|
|
2458
|
+
value: function dynamicRule(name, handler) {
|
|
2459
|
+
this.dynamicRules.set(name, handler);
|
|
2460
|
+
return this;
|
|
2461
|
+
}
|
|
2462
|
+
}, {
|
|
2463
|
+
key: "variant",
|
|
2464
|
+
value: function variant(name, wrap) {
|
|
2465
|
+
this.variants.set(name, wrap);
|
|
2466
|
+
return this;
|
|
2467
|
+
}
|
|
2468
|
+
}, {
|
|
2469
|
+
key: "dynamicVariant",
|
|
2470
|
+
value: function dynamicVariant(name, handler) {
|
|
2471
|
+
this.dynamicVariants.set(name, handler);
|
|
2472
|
+
return this;
|
|
2473
|
+
}
|
|
2474
|
+
}, {
|
|
2475
|
+
key: "getRule",
|
|
2476
|
+
value: function getRule(root) {
|
|
2477
|
+
var _this$rules$get;
|
|
2478
|
+
return (_this$rules$get = this.rules.get(root)) !== null && _this$rules$get !== void 0 ? _this$rules$get : null;
|
|
2479
|
+
}
|
|
2480
|
+
}, {
|
|
2481
|
+
key: "getDynamicRule",
|
|
2482
|
+
value: function getDynamicRule(root) {
|
|
2483
|
+
var _this$dynamicRules$ge;
|
|
2484
|
+
return (_this$dynamicRules$ge = this.dynamicRules.get(root)) !== null && _this$dynamicRules$ge !== void 0 ? _this$dynamicRules$ge : null;
|
|
2485
|
+
}
|
|
2486
|
+
}, {
|
|
2487
|
+
key: "getVariant",
|
|
2488
|
+
value: function getVariant(name) {
|
|
2489
|
+
var _this$variants$get;
|
|
2490
|
+
return (_this$variants$get = this.variants.get(name)) !== null && _this$variants$get !== void 0 ? _this$variants$get : null;
|
|
2491
|
+
}
|
|
2492
|
+
}, {
|
|
2493
|
+
key: "getDynamicVariant",
|
|
2494
|
+
value: function getDynamicVariant(root) {
|
|
2495
|
+
var _this$dynamicVariants;
|
|
2496
|
+
return (_this$dynamicVariants = this.dynamicVariants.get(root)) !== null && _this$dynamicVariants !== void 0 ? _this$dynamicVariants : null;
|
|
2497
|
+
}
|
|
2498
|
+
}]);
|
|
2499
|
+
}();
|
|
2500
|
+
|
|
2501
|
+
// Turns a parsed atom into CSS. Returns null when the utility or any of its
|
|
2502
|
+
// variants aren't registered, so an unknown class simply produces nothing.
|
|
2503
|
+
function compileAtom(atom, reg) {
|
|
2504
|
+
var declarations = declarationsFor(atom, reg);
|
|
2505
|
+
if (!declarations || declarations.length === 0) return null;
|
|
2506
|
+
if (atom.important) {
|
|
2507
|
+
var _iterator = _createForOfIteratorHelper(declarations),
|
|
2508
|
+
_step;
|
|
2509
|
+
try {
|
|
2510
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2511
|
+
var d = _step.value;
|
|
2512
|
+
d.important = true;
|
|
2513
|
+
}
|
|
2514
|
+
} catch (err) {
|
|
2515
|
+
_iterator.e(err);
|
|
2516
|
+
} finally {
|
|
2517
|
+
_iterator.f();
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
var selector = '.' + escapeClass(atom.raw);
|
|
2521
|
+
var atRules = [];
|
|
2522
|
+
var _iterator2 = _createForOfIteratorHelper(atom.variants),
|
|
2523
|
+
_step2;
|
|
2524
|
+
try {
|
|
2525
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
2526
|
+
var variant = _step2.value;
|
|
2527
|
+
var wrap = resolveVariant(variant, reg);
|
|
2528
|
+
if (!wrap) return null;
|
|
2529
|
+
if (wrap.selector) selector = substitute(wrap.selector, selector);
|
|
2530
|
+
if (wrap.atRule) atRules.push(wrap.atRule);
|
|
2531
|
+
}
|
|
2532
|
+
} catch (err) {
|
|
2533
|
+
_iterator2.e(err);
|
|
2534
|
+
} finally {
|
|
2535
|
+
_iterator2.f();
|
|
2536
|
+
}
|
|
2537
|
+
var node = rule(selector, declarations);
|
|
2538
|
+
for (var _i = 0, _atRules = atRules; _i < _atRules.length; _i++) {
|
|
2539
|
+
var ar = _atRules[_i];
|
|
2540
|
+
node = atRule(ar.name, ar.params, [node]);
|
|
2541
|
+
}
|
|
2542
|
+
return [node];
|
|
2543
|
+
}
|
|
2544
|
+
function declarationsFor(atom, reg) {
|
|
2545
|
+
if (atom.kind === 'arbitrary-property') {
|
|
2546
|
+
return [decl(atom.property, atom.value)];
|
|
2547
|
+
}
|
|
2548
|
+
if (atom.kind === 'static') {
|
|
2549
|
+
var decls = reg.getRule(atom.root);
|
|
2550
|
+
return decls ? decls.map(function (d) {
|
|
2551
|
+
return _objectSpread2({}, d);
|
|
2552
|
+
}) : null;
|
|
2553
|
+
}
|
|
2554
|
+
var handler = reg.getDynamicRule(atom.root);
|
|
2555
|
+
if (!handler) return null;
|
|
2556
|
+
return handler({
|
|
2557
|
+
value: atom.value,
|
|
2558
|
+
modifier: atom.modifier,
|
|
2559
|
+
negative: atom.negative,
|
|
2560
|
+
theme: reg.theme
|
|
2561
|
+
});
|
|
2562
|
+
}
|
|
2563
|
+
function resolveVariant(variant, reg) {
|
|
2564
|
+
if (variant.kind === 'arbitrary') return arbitraryVariant(variant.selector);
|
|
2565
|
+
if (variant.kind === 'static') return reg.getVariant(variant.root);
|
|
2566
|
+
// functional: a null value means it's really a static variant (hover, md, …).
|
|
2567
|
+
if (variant.value === null) return reg.getVariant(variant.root);
|
|
2568
|
+
var handler = reg.getDynamicVariant(variant.root);
|
|
2569
|
+
return handler ? handler(variant.value, variant.modifier) : null;
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2572
|
+
// `[&_p]` → `& p`, `[.parent_&]` → `.parent &`, `[@media(...)]` → an at-rule.
|
|
2573
|
+
// A bare selector with no `&` is attached to the element.
|
|
2574
|
+
function arbitraryVariant(source) {
|
|
2575
|
+
if (source[0] === '@') {
|
|
2576
|
+
var cut = source.search(/[\s(]/);
|
|
2577
|
+
var name = cut === -1 ? source.slice(1) : source.slice(1, cut);
|
|
2578
|
+
var params = cut === -1 ? '' : source.slice(cut).trim();
|
|
2579
|
+
return {
|
|
2580
|
+
atRule: {
|
|
2581
|
+
name: name,
|
|
2582
|
+
params: params
|
|
2583
|
+
}
|
|
2584
|
+
};
|
|
2585
|
+
}
|
|
2586
|
+
var sel = spacesFromUnderscores(source);
|
|
2587
|
+
return {
|
|
2588
|
+
selector: sel.includes('&') ? sel : "&".concat(sel)
|
|
2589
|
+
};
|
|
2590
|
+
}
|
|
2591
|
+
function spacesFromUnderscores(s) {
|
|
2592
|
+
return s.replace(/\\_/g, '\0').replace(/_/g, ' ').replace(/\0/g, '_');
|
|
2593
|
+
}
|
|
2594
|
+
function substitute(template, current) {
|
|
2595
|
+
return template.replace(/&/g, current);
|
|
2596
|
+
}
|
|
2597
|
+
|
|
2598
|
+
// Backslash-escape everything outside [A-Za-z0-9_-] so a utility name is a valid
|
|
2599
|
+
// class selector (`hover:bg-red-500/50` → `hover\:bg-red-500\/50`).
|
|
2600
|
+
function escapeClass(name) {
|
|
2601
|
+
return name.replace(/[^a-zA-Z0-9_-]/g, function (c) {
|
|
2602
|
+
return '\\' + c;
|
|
2603
|
+
});
|
|
2604
|
+
}
|
|
2605
|
+
|
|
2606
|
+
var Palettes = {
|
|
2607
|
+
"slate": {
|
|
2608
|
+
"50": "#f8fafc",
|
|
2609
|
+
"100": "#f1f5f9",
|
|
2610
|
+
"200": "#e2e8f0",
|
|
2611
|
+
"300": "#cbd5e1",
|
|
2612
|
+
"400": "#94a3b8",
|
|
2613
|
+
"500": "#64748b",
|
|
2614
|
+
"600": "#475569",
|
|
2615
|
+
"700": "#334155",
|
|
2616
|
+
"800": "#1e293b",
|
|
2617
|
+
"900": "#0f172a",
|
|
2618
|
+
"950": "#020617"
|
|
2619
|
+
},
|
|
2620
|
+
"gray": {
|
|
2621
|
+
"50": "#f9fafb",
|
|
2622
|
+
"100": "#f3f4f6",
|
|
2623
|
+
"200": "#e5e7eb",
|
|
2624
|
+
"300": "#d1d5db",
|
|
2625
|
+
"400": "#9ca3af",
|
|
2626
|
+
"500": "#6b7280",
|
|
2627
|
+
"600": "#4b5563",
|
|
2628
|
+
"700": "#374151",
|
|
2629
|
+
"800": "#1f2937",
|
|
2630
|
+
"900": "#111827",
|
|
2631
|
+
"950": "#030712"
|
|
2632
|
+
},
|
|
2633
|
+
"zinc": {
|
|
2634
|
+
"50": "#fafafa",
|
|
2635
|
+
"100": "#f4f4f5",
|
|
2636
|
+
"200": "#e4e4e7",
|
|
2637
|
+
"300": "#d4d4d8",
|
|
2638
|
+
"400": "#a1a1aa",
|
|
2639
|
+
"500": "#71717a",
|
|
2640
|
+
"600": "#52525b",
|
|
2641
|
+
"700": "#3f3f46",
|
|
2642
|
+
"800": "#27272a",
|
|
2643
|
+
"900": "#18181b",
|
|
2644
|
+
"950": "#09090b"
|
|
2645
|
+
},
|
|
2646
|
+
"neutral": {
|
|
2647
|
+
"50": "#fafafa",
|
|
2648
|
+
"100": "#f5f5f5",
|
|
2649
|
+
"200": "#e5e5e5",
|
|
2650
|
+
"300": "#d4d4d4",
|
|
2651
|
+
"400": "#a3a3a3",
|
|
2652
|
+
"500": "#737373",
|
|
2653
|
+
"600": "#525252",
|
|
2654
|
+
"700": "#404040",
|
|
2655
|
+
"800": "#262626",
|
|
2656
|
+
"900": "#171717",
|
|
2657
|
+
"950": "#0a0a0a"
|
|
2658
|
+
},
|
|
2659
|
+
"stone": {
|
|
2660
|
+
"50": "#fafaf9",
|
|
2661
|
+
"100": "#f5f5f4",
|
|
2662
|
+
"200": "#e7e5e4",
|
|
2663
|
+
"300": "#d6d3d1",
|
|
2664
|
+
"400": "#a8a29e",
|
|
2665
|
+
"500": "#78716c",
|
|
2666
|
+
"600": "#57534e",
|
|
2667
|
+
"700": "#44403c",
|
|
2668
|
+
"800": "#292524",
|
|
2669
|
+
"900": "#1c1917",
|
|
2670
|
+
"950": "#0c0a09"
|
|
2671
|
+
},
|
|
2672
|
+
"red": {
|
|
2673
|
+
"50": "#fef2f2",
|
|
2674
|
+
"100": "#fee2e2",
|
|
2675
|
+
"200": "#fecaca",
|
|
2676
|
+
"300": "#fca5a5",
|
|
2677
|
+
"400": "#f87171",
|
|
2678
|
+
"500": "#ef4444",
|
|
2679
|
+
"600": "#dc2626",
|
|
2680
|
+
"700": "#b91c1c",
|
|
2681
|
+
"800": "#991b1b",
|
|
2682
|
+
"900": "#7f1d1d",
|
|
2683
|
+
"950": "#450a0a"
|
|
2684
|
+
},
|
|
2685
|
+
"orange": {
|
|
2686
|
+
"50": "#fff7ed",
|
|
2687
|
+
"100": "#ffedd5",
|
|
2688
|
+
"200": "#fed7aa",
|
|
2689
|
+
"300": "#fdba74",
|
|
2690
|
+
"400": "#fb923c",
|
|
2691
|
+
"500": "#f97316",
|
|
2692
|
+
"600": "#ea580c",
|
|
2693
|
+
"700": "#c2410c",
|
|
2694
|
+
"800": "#9a3412",
|
|
2695
|
+
"900": "#7c2d12",
|
|
2696
|
+
"950": "#431407"
|
|
2697
|
+
},
|
|
2698
|
+
"amber": {
|
|
2699
|
+
"50": "#fffbeb",
|
|
2700
|
+
"100": "#fef3c7",
|
|
2701
|
+
"200": "#fde68a",
|
|
2702
|
+
"300": "#fcd34d",
|
|
2703
|
+
"400": "#fbbf24",
|
|
2704
|
+
"500": "#f59e0b",
|
|
2705
|
+
"600": "#d97706",
|
|
2706
|
+
"700": "#b45309",
|
|
2707
|
+
"800": "#92400e",
|
|
2708
|
+
"900": "#78350f",
|
|
2709
|
+
"950": "#451a03"
|
|
2710
|
+
},
|
|
2711
|
+
"yellow": {
|
|
2712
|
+
"50": "#fefce8",
|
|
2713
|
+
"100": "#fef9c3",
|
|
2714
|
+
"200": "#fef08a",
|
|
2715
|
+
"300": "#fde047",
|
|
2716
|
+
"400": "#facc15",
|
|
2717
|
+
"500": "#eab308",
|
|
2718
|
+
"600": "#ca8a04",
|
|
2719
|
+
"700": "#a16207",
|
|
2720
|
+
"800": "#854d0e",
|
|
2721
|
+
"900": "#713f12",
|
|
2722
|
+
"950": "#422006"
|
|
2723
|
+
},
|
|
2724
|
+
"lime": {
|
|
2725
|
+
"50": "#f7fee7",
|
|
2726
|
+
"100": "#ecfccb",
|
|
2727
|
+
"200": "#d9f99d",
|
|
2728
|
+
"300": "#bef264",
|
|
2729
|
+
"400": "#a3e635",
|
|
2730
|
+
"500": "#84cc16",
|
|
2731
|
+
"600": "#65a30d",
|
|
2732
|
+
"700": "#4d7c0f",
|
|
2733
|
+
"800": "#3f6212",
|
|
2734
|
+
"900": "#365314",
|
|
2735
|
+
"950": "#1a2e05"
|
|
2736
|
+
},
|
|
2737
|
+
"green": {
|
|
2738
|
+
"50": "#f0fdf4",
|
|
2739
|
+
"100": "#dcfce7",
|
|
2740
|
+
"200": "#bbf7d0",
|
|
2741
|
+
"300": "#86efac",
|
|
2742
|
+
"400": "#4ade80",
|
|
2743
|
+
"500": "#22c55e",
|
|
2744
|
+
"600": "#16a34a",
|
|
2745
|
+
"700": "#15803d",
|
|
2746
|
+
"800": "#166534",
|
|
2747
|
+
"900": "#14532d",
|
|
2748
|
+
"950": "#052e16"
|
|
2749
|
+
},
|
|
2750
|
+
"emerald": {
|
|
2751
|
+
"50": "#ecfdf5",
|
|
2752
|
+
"100": "#d1fae5",
|
|
2753
|
+
"200": "#a7f3d0",
|
|
2754
|
+
"300": "#6ee7b7",
|
|
2755
|
+
"400": "#34d399",
|
|
2756
|
+
"500": "#10b981",
|
|
2757
|
+
"600": "#059669",
|
|
2758
|
+
"700": "#047857",
|
|
2759
|
+
"800": "#065f46",
|
|
2760
|
+
"900": "#064e3b",
|
|
2761
|
+
"950": "#022c22"
|
|
2762
|
+
},
|
|
2763
|
+
"teal": {
|
|
2764
|
+
"50": "#f0fdfa",
|
|
2765
|
+
"100": "#ccfbf1",
|
|
2766
|
+
"200": "#99f6e4",
|
|
2767
|
+
"300": "#5eead4",
|
|
2768
|
+
"400": "#2dd4bf",
|
|
2769
|
+
"500": "#14b8a6",
|
|
2770
|
+
"600": "#0d9488",
|
|
2771
|
+
"700": "#0f766e",
|
|
2772
|
+
"800": "#115e59",
|
|
2773
|
+
"900": "#134e4a",
|
|
2774
|
+
"950": "#042f2e"
|
|
2775
|
+
},
|
|
2776
|
+
"cyan": {
|
|
2777
|
+
"50": "#ecfeff",
|
|
2778
|
+
"100": "#cffafe",
|
|
2779
|
+
"200": "#a5f3fc",
|
|
2780
|
+
"300": "#67e8f9",
|
|
2781
|
+
"400": "#22d3ee",
|
|
2782
|
+
"500": "#06b6d4",
|
|
2783
|
+
"600": "#0891b2",
|
|
2784
|
+
"700": "#0e7490",
|
|
2785
|
+
"800": "#155e75",
|
|
2786
|
+
"900": "#164e63",
|
|
2787
|
+
"950": "#083344"
|
|
2788
|
+
},
|
|
2789
|
+
"sky": {
|
|
2790
|
+
"50": "#f0f9ff",
|
|
2791
|
+
"100": "#e0f2fe",
|
|
2792
|
+
"200": "#bae6fd",
|
|
2793
|
+
"300": "#7dd3fc",
|
|
2794
|
+
"400": "#38bdf8",
|
|
2795
|
+
"500": "#0ea5e9",
|
|
2796
|
+
"600": "#0284c7",
|
|
2797
|
+
"700": "#0369a1",
|
|
2798
|
+
"800": "#075985",
|
|
2799
|
+
"900": "#0c4a6e",
|
|
2800
|
+
"950": "#082f49"
|
|
2801
|
+
},
|
|
2802
|
+
"blue": {
|
|
2803
|
+
"50": "#eff6ff",
|
|
2804
|
+
"100": "#dbeafe",
|
|
2805
|
+
"200": "#bfdbfe",
|
|
2806
|
+
"300": "#93c5fd",
|
|
2807
|
+
"400": "#60a5fa",
|
|
2808
|
+
"500": "#3b82f6",
|
|
2809
|
+
"600": "#2563eb",
|
|
2810
|
+
"700": "#1d4ed8",
|
|
2811
|
+
"800": "#1e40af",
|
|
2812
|
+
"900": "#1e3a8a",
|
|
2813
|
+
"950": "#172554"
|
|
2814
|
+
},
|
|
2815
|
+
"indigo": {
|
|
2816
|
+
"50": "#eef2ff",
|
|
2817
|
+
"100": "#e0e7ff",
|
|
2818
|
+
"200": "#c7d2fe",
|
|
2819
|
+
"300": "#a5b4fc",
|
|
2820
|
+
"400": "#818cf8",
|
|
2821
|
+
"500": "#6366f1",
|
|
2822
|
+
"600": "#4f46e5",
|
|
2823
|
+
"700": "#4338ca",
|
|
2824
|
+
"800": "#3730a3",
|
|
2825
|
+
"900": "#312e81",
|
|
2826
|
+
"950": "#1e1b4b"
|
|
2827
|
+
},
|
|
2828
|
+
"violet": {
|
|
2829
|
+
"50": "#f5f3ff",
|
|
2830
|
+
"100": "#ede9fe",
|
|
2831
|
+
"200": "#ddd6fe",
|
|
2832
|
+
"300": "#c4b5fd",
|
|
2833
|
+
"400": "#a78bfa",
|
|
2834
|
+
"500": "#8b5cf6",
|
|
2835
|
+
"600": "#7c3aed",
|
|
2836
|
+
"700": "#6d28d9",
|
|
2837
|
+
"800": "#5b21b6",
|
|
2838
|
+
"900": "#4c1d95",
|
|
2839
|
+
"950": "#2e1065"
|
|
2840
|
+
},
|
|
2841
|
+
"purple": {
|
|
2842
|
+
"50": "#faf5ff",
|
|
2843
|
+
"100": "#f3e8ff",
|
|
2844
|
+
"200": "#e9d5ff",
|
|
2845
|
+
"300": "#d8b4fe",
|
|
2846
|
+
"400": "#c084fc",
|
|
2847
|
+
"500": "#a855f7",
|
|
2848
|
+
"600": "#9333ea",
|
|
2849
|
+
"700": "#7e22ce",
|
|
2850
|
+
"800": "#6b21a8",
|
|
2851
|
+
"900": "#581c87",
|
|
2852
|
+
"950": "#3b0764"
|
|
2853
|
+
},
|
|
2854
|
+
"fuchsia": {
|
|
2855
|
+
"50": "#fdf4ff",
|
|
2856
|
+
"100": "#fae8ff",
|
|
2857
|
+
"200": "#f5d0fe",
|
|
2858
|
+
"300": "#f0abfc",
|
|
2859
|
+
"400": "#e879f9",
|
|
2860
|
+
"500": "#d946ef",
|
|
2861
|
+
"600": "#c026d3",
|
|
2862
|
+
"700": "#a21caf",
|
|
2863
|
+
"800": "#86198f",
|
|
2864
|
+
"900": "#701a75",
|
|
2865
|
+
"950": "#4a044e"
|
|
2866
|
+
},
|
|
2867
|
+
"pink": {
|
|
2868
|
+
"50": "#fdf2f8",
|
|
2869
|
+
"100": "#fce7f3",
|
|
2870
|
+
"200": "#fbcfe8",
|
|
2871
|
+
"300": "#f9a8d4",
|
|
2872
|
+
"400": "#f472b6",
|
|
2873
|
+
"500": "#ec4899",
|
|
2874
|
+
"600": "#db2777",
|
|
2875
|
+
"700": "#be185d",
|
|
2876
|
+
"800": "#9d174d",
|
|
2877
|
+
"900": "#831843",
|
|
2878
|
+
"950": "#500724"
|
|
2879
|
+
},
|
|
2880
|
+
"rose": {
|
|
2881
|
+
"50": "#fff1f2",
|
|
2882
|
+
"100": "#ffe4e6",
|
|
2883
|
+
"200": "#fecdd3",
|
|
2884
|
+
"300": "#fda4af",
|
|
2885
|
+
"400": "#fb7185",
|
|
2886
|
+
"500": "#f43f5e",
|
|
2887
|
+
"600": "#e11d48",
|
|
2888
|
+
"700": "#be123c",
|
|
2889
|
+
"800": "#9f1239",
|
|
2890
|
+
"900": "#881337",
|
|
2891
|
+
"950": "#4c0519"
|
|
2892
|
+
},
|
|
2893
|
+
"black": {
|
|
2894
|
+
"DEFAULT": "rgb(16,16,16)"
|
|
2895
|
+
},
|
|
2896
|
+
"white": {
|
|
2897
|
+
"DEFAULT": "rgb(255,255,255)"
|
|
2898
|
+
}
|
|
2899
|
+
};
|
|
2900
|
+
|
|
2901
|
+
// The default token set for `createRegistry`. Colours reuse the repo's shared
|
|
2902
|
+
// `Palettes` data; the rest are the usual scales. Projects override any of this
|
|
2903
|
+
// through `@theme`.
|
|
2904
|
+
function defaultTheme() {
|
|
2905
|
+
var theme = new Theme();
|
|
2906
|
+
for (var name in Palettes) {
|
|
2907
|
+
var shades = Palettes[name];
|
|
2908
|
+
for (var shade in shades) {
|
|
2909
|
+
// Scaled colours only (50–950); the palette's black/white carry custom
|
|
2910
|
+
// values, so we set the plain ones below.
|
|
2911
|
+
if (shade !== 'DEFAULT') theme.add("--color-".concat(name, "-").concat(shade), shades[shade]);
|
|
2912
|
+
}
|
|
2913
|
+
}
|
|
2914
|
+
theme.add('--color-black', '#000');
|
|
2915
|
+
theme.add('--color-white', '#fff');
|
|
2916
|
+
theme.addAll({
|
|
2917
|
+
'--spacing': '0.25rem',
|
|
2918
|
+
'--breakpoint-sm': '40rem',
|
|
2919
|
+
'--breakpoint-md': '48rem',
|
|
2920
|
+
'--breakpoint-lg': '64rem',
|
|
2921
|
+
'--breakpoint-xl': '80rem',
|
|
2922
|
+
'--breakpoint-2xl': '96rem',
|
|
2923
|
+
'--radius-DEFAULT': '0.25rem',
|
|
2924
|
+
'--radius-xs': '0.125rem',
|
|
2925
|
+
'--radius-sm': '0.25rem',
|
|
2926
|
+
'--radius-md': '0.375rem',
|
|
2927
|
+
'--radius-lg': '0.5rem',
|
|
2928
|
+
'--radius-xl': '0.75rem',
|
|
2929
|
+
'--radius-2xl': '1rem',
|
|
2930
|
+
'--radius-3xl': '1.5rem',
|
|
2931
|
+
'--text-xs': '0.75rem',
|
|
2932
|
+
'--text-sm': '0.875rem',
|
|
2933
|
+
'--text-base': '1rem',
|
|
2934
|
+
'--text-lg': '1.125rem',
|
|
2935
|
+
'--text-xl': '1.25rem',
|
|
2936
|
+
'--text-2xl': '1.5rem',
|
|
2937
|
+
'--text-3xl': '1.875rem',
|
|
2938
|
+
'--text-4xl': '2.25rem',
|
|
2939
|
+
'--text-5xl': '3rem',
|
|
2940
|
+
'--text-6xl': '3.75rem',
|
|
2941
|
+
'--text-7xl': '4.5rem',
|
|
2942
|
+
'--shadow-sm': '0 1px 2px 0 rgb(0 0 0 / 0.05)',
|
|
2943
|
+
'--shadow-DEFAULT': '0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)',
|
|
2944
|
+
'--shadow-md': '0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)',
|
|
2945
|
+
'--shadow-lg': '0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)',
|
|
2946
|
+
'--shadow-xl': '0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)',
|
|
2947
|
+
'--shadow-2xl': '0 25px 50px -12px rgb(0 0 0 / 0.25)'
|
|
2948
|
+
});
|
|
2949
|
+
return theme;
|
|
2950
|
+
}
|
|
2951
|
+
|
|
2952
|
+
// Shared value resolvers and registration helpers used across the utility families.
|
|
2953
|
+
|
|
2954
|
+
var SPECIAL_COLORS = {
|
|
2955
|
+
transparent: 'transparent',
|
|
2956
|
+
current: 'currentColor',
|
|
2957
|
+
inherit: 'inherit'
|
|
2958
|
+
};
|
|
2959
|
+
var CONTENT_SIZES = {
|
|
2960
|
+
auto: 'auto',
|
|
2961
|
+
min: 'min-content',
|
|
2962
|
+
max: 'max-content',
|
|
2963
|
+
fit: 'fit-content',
|
|
2964
|
+
px: '1px',
|
|
2965
|
+
full: '100%'
|
|
2966
|
+
};
|
|
2967
|
+
function colorValue(value, modifier, theme) {
|
|
2968
|
+
var _ref, _theme$resolve;
|
|
2969
|
+
if (!value) return null;
|
|
2970
|
+
var base = value.kind === 'arbitrary' ? value.value : (_ref = (_theme$resolve = theme.resolve('color', value.value)) !== null && _theme$resolve !== void 0 ? _theme$resolve : SPECIAL_COLORS[value.value]) !== null && _ref !== void 0 ? _ref : null;
|
|
2971
|
+
if (!base) return null;
|
|
2972
|
+
if (!modifier) return base;
|
|
2973
|
+
var alpha = modifier.kind === 'named' ? "".concat(modifier.value, "%") : percent(modifier.value);
|
|
2974
|
+
return "color-mix(in oklab, ".concat(base, " ").concat(alpha, ", transparent)");
|
|
2975
|
+
}
|
|
2976
|
+
function percent(raw) {
|
|
2977
|
+
return raw.includes('%') ? raw : "calc(".concat(raw, " * 100%)");
|
|
2978
|
+
}
|
|
2979
|
+
// Length/size values: theme spacing, the `n * --spacing` scale, fractions (`1/2`),
|
|
2980
|
+
// viewport/content keywords, and arbitraries. `axis` picks vw vs vh for `screen`.
|
|
2981
|
+
function sizeValue(value, theme) {
|
|
2982
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2983
|
+
if (!value) return null;
|
|
2984
|
+
var _options$negative = options.negative,
|
|
2985
|
+
negative = _options$negative === void 0 ? false : _options$negative,
|
|
2986
|
+
_options$axis = options.axis,
|
|
2987
|
+
axis = _options$axis === void 0 ? null : _options$axis,
|
|
2988
|
+
_options$modifier = options.modifier,
|
|
2989
|
+
modifier = _options$modifier === void 0 ? null : _options$modifier;
|
|
2990
|
+
var base;
|
|
2991
|
+
if (value.kind === 'arbitrary') {
|
|
2992
|
+
base = value.value;
|
|
2993
|
+
} else if (modifier && modifier.kind === 'named' && /^\d+$/.test(value.value) && /^\d+$/.test(modifier.value)) {
|
|
2994
|
+
base = toPercent(+value.value, +modifier.value);
|
|
2995
|
+
} else {
|
|
2996
|
+
base = namedSize(value.value, theme, axis);
|
|
2997
|
+
}
|
|
2998
|
+
if (!base) return null;
|
|
2999
|
+
return negative ? "calc(".concat(base, " * -1)") : base;
|
|
3000
|
+
}
|
|
3001
|
+
function namedSize(key, theme, axis) {
|
|
3002
|
+
var _CONTENT_SIZES$key;
|
|
3003
|
+
var token = theme.resolve('spacing', key);
|
|
3004
|
+
if (token) return token;
|
|
3005
|
+
if (/^\d+(\.\d+)?$/.test(key) && theme.has('--spacing')) return "calc(var(--spacing) * ".concat(key, ")");
|
|
3006
|
+
var fraction = key.match(/^(\d+)\/(\d+)$/);
|
|
3007
|
+
if (fraction) return toPercent(+fraction[1], +fraction[2]);
|
|
3008
|
+
if (key === 'screen') return axis === 'y' ? '100vh' : '100vw';
|
|
3009
|
+
return (_CONTENT_SIZES$key = CONTENT_SIZES[key]) !== null && _CONTENT_SIZES$key !== void 0 ? _CONTENT_SIZES$key : null;
|
|
3010
|
+
}
|
|
3011
|
+
function toPercent(a, b) {
|
|
3012
|
+
if (b === 0) return '0%';
|
|
3013
|
+
var n = a / b * 100;
|
|
3014
|
+
return "".concat(+n.toFixed(6), "%");
|
|
3015
|
+
}
|
|
3016
|
+
|
|
3017
|
+
// Register a group of static keyword utilities that all set one property:
|
|
3018
|
+
// `keywords(reg, 'justify', 'justify-content', { start: 'flex-start', … })`.
|
|
3019
|
+
// An empty-string key registers the bare root (`underline`).
|
|
3020
|
+
function keywords(reg, root, property, map) {
|
|
3021
|
+
for (var suffix in map) {
|
|
3022
|
+
var name = suffix === '' ? root : "".concat(root, "-").concat(suffix);
|
|
3023
|
+
reg.rule(name, [decl(property, map[suffix])]);
|
|
3024
|
+
}
|
|
3025
|
+
}
|
|
3026
|
+
|
|
3027
|
+
// Register several standalone static utilities keyed by their full class name.
|
|
3028
|
+
function statics(reg, map) {
|
|
3029
|
+
for (var name in map) reg.rule(name, map[name]);
|
|
3030
|
+
}
|
|
3031
|
+
|
|
3032
|
+
// Like {@link keywords} but the map key is the full class name, for groups whose
|
|
3033
|
+
// members don't share a `root-` prefix: `props(reg, 'display', { flex: 'flex', … })`.
|
|
3034
|
+
function props(reg, property, map) {
|
|
3035
|
+
for (var name in map) reg.rule(name, [decl(property, map[name])]);
|
|
3036
|
+
}
|
|
3037
|
+
|
|
3038
|
+
function registerBackgrounds(reg) {
|
|
3039
|
+
reg.dynamicRule('bg', function (_ref) {
|
|
3040
|
+
var value = _ref.value,
|
|
3041
|
+
modifier = _ref.modifier,
|
|
3042
|
+
theme = _ref.theme;
|
|
3043
|
+
var c = colorValue(value, modifier, theme);
|
|
3044
|
+
return c ? [decl('background-color', c)] : null;
|
|
3045
|
+
});
|
|
3046
|
+
|
|
3047
|
+
// Keyword forms of `bg-*` — these win over the colour root above.
|
|
3048
|
+
keywords(reg, 'bg', 'background-repeat', {
|
|
3049
|
+
repeat: 'repeat',
|
|
3050
|
+
'no-repeat': 'no-repeat',
|
|
3051
|
+
'repeat-x': 'repeat-x',
|
|
3052
|
+
'repeat-y': 'repeat-y',
|
|
3053
|
+
'repeat-round': 'round',
|
|
3054
|
+
'repeat-space': 'space'
|
|
3055
|
+
});
|
|
3056
|
+
keywords(reg, 'bg', 'background-size', {
|
|
3057
|
+
auto: 'auto',
|
|
3058
|
+
cover: 'cover',
|
|
3059
|
+
contain: 'contain'
|
|
3060
|
+
});
|
|
3061
|
+
keywords(reg, 'bg', 'background-attachment', {
|
|
3062
|
+
fixed: 'fixed',
|
|
3063
|
+
local: 'local',
|
|
3064
|
+
scroll: 'scroll'
|
|
3065
|
+
});
|
|
3066
|
+
keywords(reg, 'bg', 'background-position', {
|
|
3067
|
+
center: 'center',
|
|
3068
|
+
top: 'top',
|
|
3069
|
+
bottom: 'bottom',
|
|
3070
|
+
left: 'left',
|
|
3071
|
+
right: 'right',
|
|
3072
|
+
'left-top': 'left top',
|
|
3073
|
+
'right-top': 'right top',
|
|
3074
|
+
'left-bottom': 'left bottom',
|
|
3075
|
+
'right-bottom': 'right bottom'
|
|
3076
|
+
});
|
|
3077
|
+
props(reg, 'background-image', {
|
|
3078
|
+
'bg-none': 'none'
|
|
3079
|
+
});
|
|
3080
|
+
}
|
|
3081
|
+
|
|
3082
|
+
function registerBorders(reg) {
|
|
3083
|
+
border(reg, 'border', 'border', ['-top', '-right', '-bottom', '-left']);
|
|
3084
|
+
border(reg, 'border-x', 'border', ['-left', '-right']);
|
|
3085
|
+
border(reg, 'border-y', 'border', ['-top', '-bottom']);
|
|
3086
|
+
border(reg, 'border-t', 'border', ['-top']);
|
|
3087
|
+
border(reg, 'border-r', 'border', ['-right']);
|
|
3088
|
+
border(reg, 'border-b', 'border', ['-bottom']);
|
|
3089
|
+
border(reg, 'border-l', 'border', ['-left']);
|
|
3090
|
+
border(reg, 'border-s', 'border', ['-inline-start']);
|
|
3091
|
+
border(reg, 'border-e', 'border', ['-inline-end']);
|
|
3092
|
+
keywords(reg, 'border', 'border-style', {
|
|
3093
|
+
solid: 'solid',
|
|
3094
|
+
dashed: 'dashed',
|
|
3095
|
+
dotted: 'dotted',
|
|
3096
|
+
"double": 'double',
|
|
3097
|
+
hidden: 'hidden',
|
|
3098
|
+
none: 'none'
|
|
3099
|
+
});
|
|
3100
|
+
rounded(reg, 'rounded', ['']);
|
|
3101
|
+
rounded(reg, 'rounded-t', ['-top-left', '-top-right']);
|
|
3102
|
+
rounded(reg, 'rounded-r', ['-top-right', '-bottom-right']);
|
|
3103
|
+
rounded(reg, 'rounded-b', ['-bottom-right', '-bottom-left']);
|
|
3104
|
+
rounded(reg, 'rounded-l', ['-top-left', '-bottom-left']);
|
|
3105
|
+
rounded(reg, 'rounded-tl', ['-top-left']);
|
|
3106
|
+
rounded(reg, 'rounded-tr', ['-top-right']);
|
|
3107
|
+
rounded(reg, 'rounded-br', ['-bottom-right']);
|
|
3108
|
+
rounded(reg, 'rounded-bl', ['-bottom-left']);
|
|
3109
|
+
outline(reg);
|
|
3110
|
+
}
|
|
3111
|
+
|
|
3112
|
+
// `border`, `border-2`, `border-red-500`, `border-[#fff]`, `border-[2px]` all share
|
|
3113
|
+
// one root: a bare value or number is a width, a colour token/arbitrary is a colour.
|
|
3114
|
+
function border(reg, root, base, sides) {
|
|
3115
|
+
reg.dynamicRule(root, function (_ref) {
|
|
3116
|
+
var value = _ref.value,
|
|
3117
|
+
modifier = _ref.modifier,
|
|
3118
|
+
theme = _ref.theme;
|
|
3119
|
+
var width = widthValue(value, '1px' );
|
|
3120
|
+
if (width !== null) return sides.map(function (s) {
|
|
3121
|
+
return decl("".concat(base).concat(s, "-width"), width);
|
|
3122
|
+
});
|
|
3123
|
+
var color = colorFor(value, modifier, theme);
|
|
3124
|
+
return color ? sides.map(function (s) {
|
|
3125
|
+
return decl("".concat(base).concat(s, "-color"), color);
|
|
3126
|
+
}) : null;
|
|
3127
|
+
});
|
|
3128
|
+
}
|
|
3129
|
+
function widthValue(value, bare) {
|
|
3130
|
+
if (value === null) return bare;
|
|
3131
|
+
if (value.kind === 'arbitrary') {
|
|
3132
|
+
if (value.dataType === 'length') return value.value;
|
|
3133
|
+
if (value.dataType === null && /^[\d.]+(px|rem|em|%)$/.test(value.value)) return value.value;
|
|
3134
|
+
return null;
|
|
3135
|
+
}
|
|
3136
|
+
return /^\d+$/.test(value.value) ? "".concat(value.value, "px") : null;
|
|
3137
|
+
}
|
|
3138
|
+
function colorFor(value, modifier, theme) {
|
|
3139
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'arbitrary' && value.dataType === 'length') return null;
|
|
3140
|
+
return colorValue(value, modifier, theme);
|
|
3141
|
+
}
|
|
3142
|
+
function rounded(reg, root, corners) {
|
|
3143
|
+
reg.dynamicRule(root, function (_ref2) {
|
|
3144
|
+
var value = _ref2.value,
|
|
3145
|
+
theme = _ref2.theme;
|
|
3146
|
+
var r = radiusValue(value, theme);
|
|
3147
|
+
return r ? corners.map(function (c) {
|
|
3148
|
+
return decl("border".concat(c, "-radius"), r);
|
|
3149
|
+
}) : null;
|
|
3150
|
+
});
|
|
3151
|
+
}
|
|
3152
|
+
function radiusValue(value, theme) {
|
|
3153
|
+
if (value === null) return theme.resolve('radius', 'DEFAULT');
|
|
3154
|
+
if (value.kind === 'arbitrary') return value.value;
|
|
3155
|
+
if (value.value === 'none') return '0';
|
|
3156
|
+
if (value.value === 'full') return 'calc(infinity * 1px)';
|
|
3157
|
+
return theme.resolve('radius', value.value);
|
|
3158
|
+
}
|
|
3159
|
+
function outline(reg) {
|
|
3160
|
+
keywords(reg, 'outline', 'outline-style', {
|
|
3161
|
+
none: 'none',
|
|
3162
|
+
solid: 'solid',
|
|
3163
|
+
dashed: 'dashed',
|
|
3164
|
+
dotted: 'dotted',
|
|
3165
|
+
"double": 'double'
|
|
3166
|
+
});
|
|
3167
|
+
reg.dynamicRule('outline', function (_ref3) {
|
|
3168
|
+
var value = _ref3.value,
|
|
3169
|
+
modifier = _ref3.modifier,
|
|
3170
|
+
theme = _ref3.theme;
|
|
3171
|
+
if (value === null) return [decl('outline-style', 'solid')];
|
|
3172
|
+
var width = widthValue(value, null);
|
|
3173
|
+
if (width !== null) return [decl('outline-width', width)];
|
|
3174
|
+
var color = colorFor(value, modifier, theme);
|
|
3175
|
+
return color ? [decl('outline-color', color)] : null;
|
|
3176
|
+
});
|
|
3177
|
+
}
|
|
3178
|
+
|
|
3179
|
+
function registerEffects(reg) {
|
|
3180
|
+
reg.dynamicRule('shadow', function (_ref) {
|
|
3181
|
+
var value = _ref.value,
|
|
3182
|
+
theme = _ref.theme;
|
|
3183
|
+
if (value === null) return wrap(theme.resolve('shadow', 'DEFAULT'));
|
|
3184
|
+
if (value.kind === 'arbitrary') return [decl('box-shadow', value.value)];
|
|
3185
|
+
if (value.value === 'none') return [decl('box-shadow', 'none')];
|
|
3186
|
+
return wrap(theme.resolve('shadow', value.value));
|
|
3187
|
+
});
|
|
3188
|
+
reg.dynamicRule('opacity', function (_ref2) {
|
|
3189
|
+
var value = _ref2.value;
|
|
3190
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'arbitrary') return [decl('opacity', value.value)];
|
|
3191
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && /^\d+$/.test(value.value)) return [decl('opacity', "".concat(+value.value / 100))];
|
|
3192
|
+
return null;
|
|
3193
|
+
});
|
|
3194
|
+
keywords(reg, 'mix-blend', 'mix-blend-mode', BLEND);
|
|
3195
|
+
keywords(reg, 'bg-blend', 'background-blend-mode', BLEND);
|
|
3196
|
+
keywords(reg, 'cursor', 'cursor', {
|
|
3197
|
+
auto: 'auto',
|
|
3198
|
+
"default": 'default',
|
|
3199
|
+
pointer: 'pointer',
|
|
3200
|
+
wait: 'wait',
|
|
3201
|
+
text: 'text',
|
|
3202
|
+
move: 'move',
|
|
3203
|
+
help: 'help',
|
|
3204
|
+
'not-allowed': 'not-allowed',
|
|
3205
|
+
progress: 'progress',
|
|
3206
|
+
grab: 'grab',
|
|
3207
|
+
grabbing: 'grabbing'
|
|
3208
|
+
});
|
|
3209
|
+
keywords(reg, 'select', 'user-select', {
|
|
3210
|
+
none: 'none',
|
|
3211
|
+
text: 'text',
|
|
3212
|
+
all: 'all',
|
|
3213
|
+
auto: 'auto'
|
|
3214
|
+
});
|
|
3215
|
+
keywords(reg, 'resize', 'resize', {
|
|
3216
|
+
'': 'both',
|
|
3217
|
+
none: 'none',
|
|
3218
|
+
x: 'horizontal',
|
|
3219
|
+
y: 'vertical'
|
|
3220
|
+
});
|
|
3221
|
+
keywords(reg, 'pointer-events', 'pointer-events', {
|
|
3222
|
+
none: 'none',
|
|
3223
|
+
auto: 'auto'
|
|
3224
|
+
});
|
|
3225
|
+
keywords(reg, 'appearance', 'appearance', {
|
|
3226
|
+
none: 'none',
|
|
3227
|
+
auto: 'auto'
|
|
3228
|
+
});
|
|
3229
|
+
}
|
|
3230
|
+
function wrap(shadow) {
|
|
3231
|
+
return shadow ? [decl('box-shadow', shadow)] : null;
|
|
3232
|
+
}
|
|
3233
|
+
var BLEND = {
|
|
3234
|
+
normal: 'normal',
|
|
3235
|
+
multiply: 'multiply',
|
|
3236
|
+
screen: 'screen',
|
|
3237
|
+
overlay: 'overlay',
|
|
3238
|
+
darken: 'darken',
|
|
3239
|
+
lighten: 'lighten',
|
|
3240
|
+
'color-dodge': 'color-dodge',
|
|
3241
|
+
'color-burn': 'color-burn',
|
|
3242
|
+
'hard-light': 'hard-light',
|
|
3243
|
+
'soft-light': 'soft-light',
|
|
3244
|
+
difference: 'difference',
|
|
3245
|
+
exclusion: 'exclusion',
|
|
3246
|
+
hue: 'hue',
|
|
3247
|
+
saturation: 'saturation',
|
|
3248
|
+
color: 'color',
|
|
3249
|
+
luminosity: 'luminosity'
|
|
3250
|
+
};
|
|
3251
|
+
|
|
3252
|
+
function registerFlexGrid(reg) {
|
|
3253
|
+
props(reg, 'flex-direction', {
|
|
3254
|
+
'flex-row': 'row',
|
|
3255
|
+
'flex-row-reverse': 'row-reverse',
|
|
3256
|
+
'flex-col': 'column',
|
|
3257
|
+
'flex-col-reverse': 'column-reverse'
|
|
3258
|
+
});
|
|
3259
|
+
props(reg, 'flex-wrap', {
|
|
3260
|
+
'flex-wrap': 'wrap',
|
|
3261
|
+
'flex-wrap-reverse': 'wrap-reverse',
|
|
3262
|
+
'flex-nowrap': 'nowrap'
|
|
3263
|
+
});
|
|
3264
|
+
props(reg, 'flex', {
|
|
3265
|
+
'flex-1': '1 1 0%',
|
|
3266
|
+
'flex-auto': '1 1 auto',
|
|
3267
|
+
'flex-initial': '0 1 auto',
|
|
3268
|
+
'flex-none': 'none'
|
|
3269
|
+
});
|
|
3270
|
+
props(reg, 'flex-grow', {
|
|
3271
|
+
grow: '1',
|
|
3272
|
+
'grow-0': '0'
|
|
3273
|
+
});
|
|
3274
|
+
props(reg, 'flex-shrink', {
|
|
3275
|
+
shrink: '1',
|
|
3276
|
+
'shrink-0': '0'
|
|
3277
|
+
});
|
|
3278
|
+
reg.dynamicRule('basis', function (_ref) {
|
|
3279
|
+
var value = _ref.value,
|
|
3280
|
+
modifier = _ref.modifier,
|
|
3281
|
+
theme = _ref.theme;
|
|
3282
|
+
var v = sizeValue(value, theme, {
|
|
3283
|
+
modifier: modifier
|
|
3284
|
+
});
|
|
3285
|
+
return v ? [decl('flex-basis', v)] : null;
|
|
3286
|
+
});
|
|
3287
|
+
reg.dynamicRule('order', function (_ref2) {
|
|
3288
|
+
var value = _ref2.value;
|
|
3289
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'arbitrary') return [decl('order', value.value)];
|
|
3290
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'named') {
|
|
3291
|
+
if (value.value === 'first') return [decl('order', '-9999')];
|
|
3292
|
+
if (value.value === 'last') return [decl('order', '9999')];
|
|
3293
|
+
if (value.value === 'none') return [decl('order', '0')];
|
|
3294
|
+
if (/^\d+$/.test(value.value)) return [decl('order', value.value)];
|
|
3295
|
+
}
|
|
3296
|
+
return null;
|
|
3297
|
+
});
|
|
3298
|
+
keywords(reg, 'justify', 'justify-content', CONTENT);
|
|
3299
|
+
keywords(reg, 'content', 'align-content', CONTENT);
|
|
3300
|
+
keywords(reg, 'items', 'align-items', ALIGN);
|
|
3301
|
+
keywords(reg, 'self', 'align-self', _objectSpread2({
|
|
3302
|
+
auto: 'auto'
|
|
3303
|
+
}, ALIGN));
|
|
3304
|
+
keywords(reg, 'justify-items', 'justify-items', {
|
|
3305
|
+
start: 'start',
|
|
3306
|
+
end: 'end',
|
|
3307
|
+
center: 'center',
|
|
3308
|
+
stretch: 'stretch'
|
|
3309
|
+
});
|
|
3310
|
+
keywords(reg, 'justify-self', 'justify-self', {
|
|
3311
|
+
auto: 'auto',
|
|
3312
|
+
start: 'start',
|
|
3313
|
+
end: 'end',
|
|
3314
|
+
center: 'center',
|
|
3315
|
+
stretch: 'stretch'
|
|
3316
|
+
});
|
|
3317
|
+
keywords(reg, 'place-content', 'place-content', CONTENT);
|
|
3318
|
+
keywords(reg, 'place-items', 'place-items', {
|
|
3319
|
+
start: 'start',
|
|
3320
|
+
end: 'end',
|
|
3321
|
+
center: 'center',
|
|
3322
|
+
stretch: 'stretch',
|
|
3323
|
+
baseline: 'baseline'
|
|
3324
|
+
});
|
|
3325
|
+
keywords(reg, 'place-self', 'place-self', {
|
|
3326
|
+
auto: 'auto',
|
|
3327
|
+
start: 'start',
|
|
3328
|
+
end: 'end',
|
|
3329
|
+
center: 'center',
|
|
3330
|
+
stretch: 'stretch'
|
|
3331
|
+
});
|
|
3332
|
+
gap(reg, 'gap', ['gap']);
|
|
3333
|
+
gap(reg, 'gap-x', ['column-gap']);
|
|
3334
|
+
gap(reg, 'gap-y', ['row-gap']);
|
|
3335
|
+
reg.dynamicRule('grid-cols', function (_ref3) {
|
|
3336
|
+
var value = _ref3.value;
|
|
3337
|
+
return track('grid-template-columns', value);
|
|
3338
|
+
});
|
|
3339
|
+
reg.dynamicRule('grid-rows', function (_ref4) {
|
|
3340
|
+
var value = _ref4.value;
|
|
3341
|
+
return track('grid-template-rows', value);
|
|
3342
|
+
});
|
|
3343
|
+
span(reg, 'col-span', 'grid-column', 'span');
|
|
3344
|
+
span(reg, 'row-span', 'grid-row', 'span');
|
|
3345
|
+
line(reg, 'col-start', 'grid-column-start');
|
|
3346
|
+
line(reg, 'col-end', 'grid-column-end');
|
|
3347
|
+
line(reg, 'row-start', 'grid-row-start');
|
|
3348
|
+
line(reg, 'row-end', 'grid-row-end');
|
|
3349
|
+
props(reg, 'grid-auto-flow', {
|
|
3350
|
+
'grid-flow-row': 'row',
|
|
3351
|
+
'grid-flow-col': 'column',
|
|
3352
|
+
'grid-flow-dense': 'dense',
|
|
3353
|
+
'grid-flow-row-dense': 'row dense',
|
|
3354
|
+
'grid-flow-col-dense': 'column dense'
|
|
3355
|
+
});
|
|
3356
|
+
}
|
|
3357
|
+
var CONTENT = {
|
|
3358
|
+
normal: 'normal',
|
|
3359
|
+
start: 'flex-start',
|
|
3360
|
+
end: 'flex-end',
|
|
3361
|
+
center: 'center',
|
|
3362
|
+
between: 'space-between',
|
|
3363
|
+
around: 'space-around',
|
|
3364
|
+
evenly: 'space-evenly',
|
|
3365
|
+
stretch: 'stretch'
|
|
3366
|
+
};
|
|
3367
|
+
var ALIGN = {
|
|
3368
|
+
start: 'flex-start',
|
|
3369
|
+
end: 'flex-end',
|
|
3370
|
+
center: 'center',
|
|
3371
|
+
baseline: 'baseline',
|
|
3372
|
+
stretch: 'stretch'
|
|
3373
|
+
};
|
|
3374
|
+
function gap(reg, root, props) {
|
|
3375
|
+
reg.dynamicRule(root, function (_ref5) {
|
|
3376
|
+
var value = _ref5.value,
|
|
3377
|
+
theme = _ref5.theme;
|
|
3378
|
+
var v = sizeValue(value, theme);
|
|
3379
|
+
return v ? props.map(function (p) {
|
|
3380
|
+
return decl(p, v);
|
|
3381
|
+
}) : null;
|
|
3382
|
+
});
|
|
3383
|
+
}
|
|
3384
|
+
function track(property, value) {
|
|
3385
|
+
if (!value) return null;
|
|
3386
|
+
if (value.kind === 'arbitrary') return [decl(property, value.value)];
|
|
3387
|
+
if (value.value === 'none') return [decl(property, 'none')];
|
|
3388
|
+
if (/^\d+$/.test(value.value)) return [decl(property, "repeat(".concat(value.value, ", minmax(0, 1fr))"))];
|
|
3389
|
+
return null;
|
|
3390
|
+
}
|
|
3391
|
+
function span(reg, root, property, kind) {
|
|
3392
|
+
reg.dynamicRule(root, function (_ref6) {
|
|
3393
|
+
var value = _ref6.value;
|
|
3394
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'arbitrary') return [decl(property, value.value)];
|
|
3395
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'named') {
|
|
3396
|
+
if (value.value === 'full') return [decl(property, '1 / -1')];
|
|
3397
|
+
if (/^\d+$/.test(value.value)) return [decl(property, "".concat(kind, " ").concat(value.value, " / ").concat(kind, " ").concat(value.value))];
|
|
3398
|
+
}
|
|
3399
|
+
return null;
|
|
3400
|
+
});
|
|
3401
|
+
}
|
|
3402
|
+
function line(reg, root, property) {
|
|
3403
|
+
reg.dynamicRule(root, function (_ref7) {
|
|
3404
|
+
var value = _ref7.value;
|
|
3405
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'arbitrary') return [decl(property, value.value)];
|
|
3406
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'named') {
|
|
3407
|
+
if (value.value === 'auto') return [decl(property, 'auto')];
|
|
3408
|
+
if (/^\d+$/.test(value.value)) return [decl(property, value.value)];
|
|
3409
|
+
}
|
|
3410
|
+
return null;
|
|
3411
|
+
});
|
|
3412
|
+
}
|
|
3413
|
+
|
|
3414
|
+
function registerLayout(reg) {
|
|
3415
|
+
props(reg, 'display', {
|
|
3416
|
+
block: 'block',
|
|
3417
|
+
inline: 'inline',
|
|
3418
|
+
'inline-block': 'inline-block',
|
|
3419
|
+
flex: 'flex',
|
|
3420
|
+
'inline-flex': 'inline-flex',
|
|
3421
|
+
grid: 'grid',
|
|
3422
|
+
'inline-grid': 'inline-grid',
|
|
3423
|
+
table: 'table',
|
|
3424
|
+
'flow-root': 'flow-root',
|
|
3425
|
+
contents: 'contents',
|
|
3426
|
+
hidden: 'none'
|
|
3427
|
+
});
|
|
3428
|
+
props(reg, 'position', {
|
|
3429
|
+
"static": 'static',
|
|
3430
|
+
fixed: 'fixed',
|
|
3431
|
+
absolute: 'absolute',
|
|
3432
|
+
relative: 'relative',
|
|
3433
|
+
sticky: 'sticky'
|
|
3434
|
+
});
|
|
3435
|
+
keywords(reg, 'overflow', 'overflow', OVERFLOW);
|
|
3436
|
+
keywords(reg, 'overflow-x', 'overflow-x', OVERFLOW);
|
|
3437
|
+
keywords(reg, 'overflow-y', 'overflow-y', OVERFLOW);
|
|
3438
|
+
props(reg, 'visibility', {
|
|
3439
|
+
visible: 'visible',
|
|
3440
|
+
invisible: 'hidden',
|
|
3441
|
+
collapse: 'collapse'
|
|
3442
|
+
});
|
|
3443
|
+
keywords(reg, 'box', 'box-sizing', {
|
|
3444
|
+
border: 'border-box',
|
|
3445
|
+
content: 'content-box'
|
|
3446
|
+
});
|
|
3447
|
+
props(reg, 'isolation', {
|
|
3448
|
+
isolate: 'isolate',
|
|
3449
|
+
'isolation-auto': 'auto'
|
|
3450
|
+
});
|
|
3451
|
+
keywords(reg, 'object', 'object-fit', {
|
|
3452
|
+
contain: 'contain',
|
|
3453
|
+
cover: 'cover',
|
|
3454
|
+
fill: 'fill',
|
|
3455
|
+
none: 'none',
|
|
3456
|
+
'scale-down': 'scale-down'
|
|
3457
|
+
});
|
|
3458
|
+
keywords(reg, 'object', 'object-position', {
|
|
3459
|
+
top: 'top',
|
|
3460
|
+
bottom: 'bottom',
|
|
3461
|
+
center: 'center',
|
|
3462
|
+
left: 'left',
|
|
3463
|
+
right: 'right',
|
|
3464
|
+
'left-top': 'left top',
|
|
3465
|
+
'right-top': 'right top',
|
|
3466
|
+
'left-bottom': 'left bottom',
|
|
3467
|
+
'right-bottom': 'right bottom'
|
|
3468
|
+
});
|
|
3469
|
+
keywords(reg, 'float', 'float', {
|
|
3470
|
+
start: 'inline-start',
|
|
3471
|
+
end: 'inline-end',
|
|
3472
|
+
left: 'left',
|
|
3473
|
+
right: 'right',
|
|
3474
|
+
none: 'none'
|
|
3475
|
+
});
|
|
3476
|
+
keywords(reg, 'clear', 'clear', {
|
|
3477
|
+
start: 'inline-start',
|
|
3478
|
+
end: 'inline-end',
|
|
3479
|
+
left: 'left',
|
|
3480
|
+
right: 'right',
|
|
3481
|
+
both: 'both',
|
|
3482
|
+
none: 'none'
|
|
3483
|
+
});
|
|
3484
|
+
inset(reg, 'inset', ['top', 'right', 'bottom', 'left']);
|
|
3485
|
+
inset(reg, 'inset-x', ['left', 'right']);
|
|
3486
|
+
inset(reg, 'inset-y', ['top', 'bottom']);
|
|
3487
|
+
inset(reg, 'top', ['top']);
|
|
3488
|
+
inset(reg, 'right', ['right']);
|
|
3489
|
+
inset(reg, 'bottom', ['bottom']);
|
|
3490
|
+
inset(reg, 'left', ['left']);
|
|
3491
|
+
inset(reg, 'start', ['inset-inline-start']);
|
|
3492
|
+
inset(reg, 'end', ['inset-inline-end']);
|
|
3493
|
+
reg.dynamicRule('z', function (_ref) {
|
|
3494
|
+
var value = _ref.value;
|
|
3495
|
+
if (!value) return null;
|
|
3496
|
+
if (value.kind === 'arbitrary') return [decl('z-index', value.value)];
|
|
3497
|
+
if (value.value === 'auto') return [decl('z-index', 'auto')];
|
|
3498
|
+
return /^\d+$/.test(value.value) ? [decl('z-index', value.value)] : null;
|
|
3499
|
+
});
|
|
3500
|
+
}
|
|
3501
|
+
var OVERFLOW = {
|
|
3502
|
+
auto: 'auto',
|
|
3503
|
+
hidden: 'hidden',
|
|
3504
|
+
clip: 'clip',
|
|
3505
|
+
visible: 'visible',
|
|
3506
|
+
scroll: 'scroll'
|
|
3507
|
+
};
|
|
3508
|
+
function inset(reg, root, props) {
|
|
3509
|
+
reg.dynamicRule(root, function (_ref2) {
|
|
3510
|
+
var value = _ref2.value,
|
|
3511
|
+
negative = _ref2.negative,
|
|
3512
|
+
modifier = _ref2.modifier,
|
|
3513
|
+
theme = _ref2.theme;
|
|
3514
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'auto') return props.map(function (p) {
|
|
3515
|
+
return decl(p, 'auto');
|
|
3516
|
+
});
|
|
3517
|
+
var v = sizeValue(value, theme, {
|
|
3518
|
+
negative: negative,
|
|
3519
|
+
modifier: modifier
|
|
3520
|
+
});
|
|
3521
|
+
return v ? props.map(function (p) {
|
|
3522
|
+
return decl(p, v);
|
|
3523
|
+
}) : null;
|
|
3524
|
+
});
|
|
3525
|
+
}
|
|
3526
|
+
|
|
3527
|
+
function registerSizing(reg) {
|
|
3528
|
+
size(reg, 'w', ['width'], 'x');
|
|
3529
|
+
size(reg, 'h', ['height'], 'y');
|
|
3530
|
+
size(reg, 'size', ['width', 'height'], null);
|
|
3531
|
+
size(reg, 'min-w', ['min-width'], 'x');
|
|
3532
|
+
size(reg, 'min-h', ['min-height'], 'y');
|
|
3533
|
+
size(reg, 'max-w', ['max-width'], 'x');
|
|
3534
|
+
size(reg, 'max-h', ['max-height'], 'y');
|
|
3535
|
+
}
|
|
3536
|
+
function size(reg, root, props, axis) {
|
|
3537
|
+
reg.dynamicRule(root, function (_ref) {
|
|
3538
|
+
var value = _ref.value,
|
|
3539
|
+
modifier = _ref.modifier,
|
|
3540
|
+
theme = _ref.theme;
|
|
3541
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'none' && root.startsWith('max')) {
|
|
3542
|
+
return props.map(function (p) {
|
|
3543
|
+
return decl(p, 'none');
|
|
3544
|
+
});
|
|
3545
|
+
}
|
|
3546
|
+
var v = sizeValue(value, theme, {
|
|
3547
|
+
axis: axis,
|
|
3548
|
+
modifier: modifier
|
|
3549
|
+
});
|
|
3550
|
+
return v ? props.map(function (p) {
|
|
3551
|
+
return decl(p, v);
|
|
3552
|
+
}) : null;
|
|
3553
|
+
});
|
|
3554
|
+
}
|
|
3555
|
+
|
|
3556
|
+
function registerSpacing(reg) {
|
|
3557
|
+
for (var _i = 0, _Object$entries = Object.entries(SPACING); _i < _Object$entries.length; _i++) {
|
|
3558
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
3559
|
+
root = _Object$entries$_i[0],
|
|
3560
|
+
props = _Object$entries$_i[1];
|
|
3561
|
+
spacing(reg, root, props, root[0] === 'm');
|
|
3562
|
+
}
|
|
3563
|
+
}
|
|
3564
|
+
|
|
3565
|
+
// `px`/`py` expand to the physical left/right, top/bottom pair (not the logical
|
|
3566
|
+
// `padding-inline`) to match established output; `ps`/`pe` use the logical edges.
|
|
3567
|
+
var SPACING = {
|
|
3568
|
+
p: ['padding'],
|
|
3569
|
+
px: ['padding-left', 'padding-right'],
|
|
3570
|
+
py: ['padding-top', 'padding-bottom'],
|
|
3571
|
+
ps: ['padding-inline-start'],
|
|
3572
|
+
pe: ['padding-inline-end'],
|
|
3573
|
+
pt: ['padding-top'],
|
|
3574
|
+
pr: ['padding-right'],
|
|
3575
|
+
pb: ['padding-bottom'],
|
|
3576
|
+
pl: ['padding-left'],
|
|
3577
|
+
m: ['margin'],
|
|
3578
|
+
mx: ['margin-left', 'margin-right'],
|
|
3579
|
+
my: ['margin-top', 'margin-bottom'],
|
|
3580
|
+
ms: ['margin-inline-start'],
|
|
3581
|
+
me: ['margin-inline-end'],
|
|
3582
|
+
mt: ['margin-top'],
|
|
3583
|
+
mr: ['margin-right'],
|
|
3584
|
+
mb: ['margin-bottom'],
|
|
3585
|
+
ml: ['margin-left'],
|
|
3586
|
+
'scroll-m': ['scroll-margin'],
|
|
3587
|
+
'scroll-p': ['scroll-padding']
|
|
3588
|
+
};
|
|
3589
|
+
function spacing(reg, root, props, allowAuto) {
|
|
3590
|
+
reg.dynamicRule(root, function (_ref) {
|
|
3591
|
+
var value = _ref.value,
|
|
3592
|
+
negative = _ref.negative,
|
|
3593
|
+
theme = _ref.theme;
|
|
3594
|
+
if (allowAuto && (value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'auto') return props.map(function (p) {
|
|
3595
|
+
return decl(p, 'auto');
|
|
3596
|
+
});
|
|
3597
|
+
var v = sizeValue(value, theme, {
|
|
3598
|
+
negative: negative
|
|
3599
|
+
});
|
|
3600
|
+
return v ? props.map(function (p) {
|
|
3601
|
+
return decl(p, v);
|
|
3602
|
+
}) : null;
|
|
3603
|
+
});
|
|
3604
|
+
}
|
|
3605
|
+
|
|
3606
|
+
function registerTypography(reg) {
|
|
3607
|
+
// `text-` is overloaded: a colour token, a font-size token, or an arbitrary of
|
|
3608
|
+
// either kind. Alignment/overflow keywords (`text-center`, `text-ellipsis`) are
|
|
3609
|
+
// registered as statics below, which win over this functional root.
|
|
3610
|
+
reg.dynamicRule('text', function (_ref) {
|
|
3611
|
+
var value = _ref.value,
|
|
3612
|
+
modifier = _ref.modifier,
|
|
3613
|
+
theme = _ref.theme;
|
|
3614
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'named') {
|
|
3615
|
+
if (theme.resolve('color', value.value) || SPECIAL_COLORS[value.value]) {
|
|
3616
|
+
return [decl('color', colorValue(value, modifier, theme))];
|
|
3617
|
+
}
|
|
3618
|
+
var fs = theme.resolve('text', value.value);
|
|
3619
|
+
return fs ? [decl('font-size', fs)] : null;
|
|
3620
|
+
}
|
|
3621
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'arbitrary') {
|
|
3622
|
+
if (value.dataType === 'length') return [decl('font-size', value.value)];
|
|
3623
|
+
var c = colorValue(value, modifier, theme);
|
|
3624
|
+
return c ? [decl('color', c)] : null;
|
|
3625
|
+
}
|
|
3626
|
+
return null;
|
|
3627
|
+
});
|
|
3628
|
+
props(reg, 'text-align', {
|
|
3629
|
+
'text-left': 'left',
|
|
3630
|
+
'text-center': 'center',
|
|
3631
|
+
'text-right': 'right',
|
|
3632
|
+
'text-justify': 'justify',
|
|
3633
|
+
'text-start': 'start',
|
|
3634
|
+
'text-end': 'end'
|
|
3635
|
+
});
|
|
3636
|
+
props(reg, 'text-overflow', {
|
|
3637
|
+
truncate: 'ellipsis',
|
|
3638
|
+
'text-ellipsis': 'ellipsis',
|
|
3639
|
+
'text-clip': 'clip'
|
|
3640
|
+
});
|
|
3641
|
+
// `truncate` is the one that also clips and stops wrapping.
|
|
3642
|
+
reg.rule('truncate', [decl('overflow', 'hidden'), decl('text-overflow', 'ellipsis'), decl('white-space', 'nowrap')]);
|
|
3643
|
+
keywords(reg, 'font', 'font-weight', WEIGHTS);
|
|
3644
|
+
props(reg, 'font-family', {
|
|
3645
|
+
'font-sans': 'ui-sans-serif, system-ui, sans-serif',
|
|
3646
|
+
'font-serif': 'ui-serif, Georgia, serif',
|
|
3647
|
+
'font-mono': 'ui-monospace, SFMono-Regular, Menlo, monospace'
|
|
3648
|
+
});
|
|
3649
|
+
props(reg, 'font-style', {
|
|
3650
|
+
italic: 'italic',
|
|
3651
|
+
'not-italic': 'normal'
|
|
3652
|
+
});
|
|
3653
|
+
props(reg, 'text-decoration-line', {
|
|
3654
|
+
underline: 'underline',
|
|
3655
|
+
overline: 'overline',
|
|
3656
|
+
'line-through': 'line-through',
|
|
3657
|
+
'no-underline': 'none'
|
|
3658
|
+
});
|
|
3659
|
+
props(reg, 'text-transform', {
|
|
3660
|
+
uppercase: 'uppercase',
|
|
3661
|
+
lowercase: 'lowercase',
|
|
3662
|
+
capitalize: 'capitalize',
|
|
3663
|
+
'normal-case': 'none'
|
|
3664
|
+
});
|
|
3665
|
+
keywords(reg, 'whitespace', 'white-space', {
|
|
3666
|
+
normal: 'normal',
|
|
3667
|
+
nowrap: 'nowrap',
|
|
3668
|
+
pre: 'pre',
|
|
3669
|
+
'pre-line': 'pre-line',
|
|
3670
|
+
'pre-wrap': 'pre-wrap',
|
|
3671
|
+
'break-spaces': 'break-spaces'
|
|
3672
|
+
});
|
|
3673
|
+
statics(reg, {
|
|
3674
|
+
'break-normal': [decl('overflow-wrap', 'normal'), decl('word-break', 'normal')],
|
|
3675
|
+
'break-words': [decl('overflow-wrap', 'break-word')],
|
|
3676
|
+
'break-all': [decl('word-break', 'break-all')],
|
|
3677
|
+
'break-keep': [decl('word-break', 'keep-all')]
|
|
3678
|
+
});
|
|
3679
|
+
keywords(reg, 'list', 'list-style-type', {
|
|
3680
|
+
none: 'none',
|
|
3681
|
+
disc: 'disc',
|
|
3682
|
+
decimal: 'decimal'
|
|
3683
|
+
});
|
|
3684
|
+
keywords(reg, 'list', 'list-style-position', {
|
|
3685
|
+
inside: 'inside',
|
|
3686
|
+
outside: 'outside'
|
|
3687
|
+
});
|
|
3688
|
+
reg.dynamicRule('leading', function (_ref2) {
|
|
3689
|
+
var value = _ref2.value,
|
|
3690
|
+
theme = _ref2.theme;
|
|
3691
|
+
return resolveLeading(value, theme);
|
|
3692
|
+
});
|
|
3693
|
+
reg.dynamicRule('tracking', function (_ref3) {
|
|
3694
|
+
var value = _ref3.value;
|
|
3695
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'arbitrary') return [decl('letter-spacing', value.value)];
|
|
3696
|
+
var t = (value === null || value === void 0 ? void 0 : value.kind) === 'named' ? TRACKING[value.value] : null;
|
|
3697
|
+
return t ? [decl('letter-spacing', t)] : null;
|
|
3698
|
+
});
|
|
3699
|
+
}
|
|
3700
|
+
var WEIGHTS = {
|
|
3701
|
+
thin: '100',
|
|
3702
|
+
extralight: '200',
|
|
3703
|
+
light: '300',
|
|
3704
|
+
normal: '400',
|
|
3705
|
+
medium: '500',
|
|
3706
|
+
semibold: '600',
|
|
3707
|
+
bold: '700',
|
|
3708
|
+
extrabold: '800',
|
|
3709
|
+
black: '900'
|
|
3710
|
+
};
|
|
3711
|
+
var LEADING = {
|
|
3712
|
+
none: '1',
|
|
3713
|
+
tight: '1.25',
|
|
3714
|
+
snug: '1.375',
|
|
3715
|
+
normal: '1.5',
|
|
3716
|
+
relaxed: '1.625',
|
|
3717
|
+
loose: '2'
|
|
3718
|
+
};
|
|
3719
|
+
var TRACKING = {
|
|
3720
|
+
tighter: '-0.05em',
|
|
3721
|
+
tight: '-0.025em',
|
|
3722
|
+
normal: '0em',
|
|
3723
|
+
wide: '0.025em',
|
|
3724
|
+
wider: '0.05em',
|
|
3725
|
+
widest: '0.1em'
|
|
3726
|
+
};
|
|
3727
|
+
function resolveLeading(value, theme) {
|
|
3728
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'arbitrary') return [decl('line-height', value.value)];
|
|
3729
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'named') {
|
|
3730
|
+
if (LEADING[value.value]) return [decl('line-height', LEADING[value.value])];
|
|
3731
|
+
if (/^\d+$/.test(value.value) && theme.has('--spacing')) {
|
|
3732
|
+
return [decl('line-height', "calc(var(--spacing) * ".concat(value.value, ")"))];
|
|
3733
|
+
}
|
|
3734
|
+
}
|
|
3735
|
+
return null;
|
|
3736
|
+
}
|
|
3737
|
+
|
|
3738
|
+
function registerUtilities(reg) {
|
|
3739
|
+
registerLayout(reg);
|
|
3740
|
+
registerFlexGrid(reg);
|
|
3741
|
+
registerSpacing(reg);
|
|
3742
|
+
registerSizing(reg);
|
|
3743
|
+
registerTypography(reg);
|
|
3744
|
+
registerBackgrounds(reg);
|
|
3745
|
+
registerBorders(reg);
|
|
3746
|
+
registerEffects(reg);
|
|
3747
|
+
}
|
|
3748
|
+
|
|
3749
|
+
function registerVariants(reg) {
|
|
3750
|
+
for (var _i = 0, _Object$entries = Object.entries(PSEUDO); _i < _Object$entries.length; _i++) {
|
|
3751
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
3752
|
+
name = _Object$entries$_i[0],
|
|
3753
|
+
sel = _Object$entries$_i[1];
|
|
3754
|
+
reg.variant(name, {
|
|
3755
|
+
selector: sel
|
|
3756
|
+
});
|
|
3757
|
+
}
|
|
3758
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(PSEUDO_ELEMENT); _i2 < _Object$entries2.length; _i2++) {
|
|
3759
|
+
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
|
3760
|
+
_name = _Object$entries2$_i[0],
|
|
3761
|
+
_sel = _Object$entries2$_i[1];
|
|
3762
|
+
reg.variant(_name, {
|
|
3763
|
+
selector: _sel
|
|
3764
|
+
});
|
|
3765
|
+
}
|
|
3766
|
+
for (var _i3 = 0, _Object$entries3 = Object.entries(MEDIA); _i3 < _Object$entries3.length; _i3++) {
|
|
3767
|
+
var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
|
|
3768
|
+
_name2 = _Object$entries3$_i[0],
|
|
3769
|
+
params = _Object$entries3$_i[1];
|
|
3770
|
+
reg.variant(_name2, {
|
|
3771
|
+
atRule: {
|
|
3772
|
+
name: 'media',
|
|
3773
|
+
params: params
|
|
3774
|
+
}
|
|
3775
|
+
});
|
|
3776
|
+
}
|
|
3777
|
+
reg.variant('rtl', {
|
|
3778
|
+
selector: '&:where([dir="rtl"], [dir="rtl"] *)'
|
|
3779
|
+
});
|
|
3780
|
+
reg.variant('ltr', {
|
|
3781
|
+
selector: '&:where([dir="ltr"], [dir="ltr"] *)'
|
|
3782
|
+
});
|
|
3783
|
+
for (var _i4 = 0, _arr = ['sm', 'md', 'lg', 'xl', '2xl']; _i4 < _arr.length; _i4++) {
|
|
3784
|
+
var bp = _arr[_i4];
|
|
3785
|
+
var min = reg.theme.get("--breakpoint-".concat(bp));
|
|
3786
|
+
if (min) reg.variant(bp, {
|
|
3787
|
+
atRule: {
|
|
3788
|
+
name: 'media',
|
|
3789
|
+
params: "(min-width: ".concat(min, ")")
|
|
3790
|
+
}
|
|
3791
|
+
});
|
|
3792
|
+
}
|
|
3793
|
+
|
|
3794
|
+
// `max-md`, `min-lg` resolve the named breakpoint from the theme; `max-[600px]`
|
|
3795
|
+
// takes the width verbatim. `max-*` overrides the `max-w`/`max-h` utilities here
|
|
3796
|
+
// because it's a variant, not a utility.
|
|
3797
|
+
var width = function width(v) {
|
|
3798
|
+
var _reg$theme$get;
|
|
3799
|
+
var value = named(v);
|
|
3800
|
+
if (!value) return null;
|
|
3801
|
+
return v.kind === 'arbitrary' ? value : (_reg$theme$get = reg.theme.get("--breakpoint-".concat(value))) !== null && _reg$theme$get !== void 0 ? _reg$theme$get : null;
|
|
3802
|
+
};
|
|
3803
|
+
reg.dynamicVariant('min', function (v) {
|
|
3804
|
+
return mediaWidth('min-width', width(v));
|
|
3805
|
+
});
|
|
3806
|
+
reg.dynamicVariant('max', function (v) {
|
|
3807
|
+
return mediaWidth('max-width', width(v));
|
|
3808
|
+
});
|
|
3809
|
+
reg.dynamicVariant('group', function (v) {
|
|
3810
|
+
return relational(v, '.group', ' &');
|
|
3811
|
+
});
|
|
3812
|
+
reg.dynamicVariant('peer', function (v) {
|
|
3813
|
+
return relational(v, '.peer', ' ~ &');
|
|
3814
|
+
});
|
|
3815
|
+
reg.dynamicVariant('data', function (v) {
|
|
3816
|
+
return named(v) ? {
|
|
3817
|
+
selector: "&[data-".concat(named(v), "]")
|
|
3818
|
+
} : null;
|
|
3819
|
+
});
|
|
3820
|
+
reg.dynamicVariant('aria', function (v) {
|
|
3821
|
+
return named(v) ? {
|
|
3822
|
+
selector: "&[aria-".concat(named(v), "]")
|
|
3823
|
+
} : null;
|
|
3824
|
+
});
|
|
3825
|
+
reg.dynamicVariant('has', function (v) {
|
|
3826
|
+
return named(v) ? {
|
|
3827
|
+
selector: "&:has(".concat(named(v), ")")
|
|
3828
|
+
} : null;
|
|
3829
|
+
});
|
|
3830
|
+
reg.dynamicVariant('not', function (v) {
|
|
3831
|
+
return named(v) ? {
|
|
3832
|
+
selector: "&:not(".concat(named(v), ")")
|
|
3833
|
+
} : null;
|
|
3834
|
+
});
|
|
3835
|
+
reg.dynamicVariant('supports', function (v) {
|
|
3836
|
+
return named(v) ? {
|
|
3837
|
+
atRule: {
|
|
3838
|
+
name: 'supports',
|
|
3839
|
+
params: "(".concat(named(v), ")")
|
|
3840
|
+
}
|
|
3841
|
+
} : null;
|
|
3842
|
+
});
|
|
3843
|
+
}
|
|
3844
|
+
function mediaWidth(feature, value) {
|
|
3845
|
+
return value ? {
|
|
3846
|
+
atRule: {
|
|
3847
|
+
name: 'media',
|
|
3848
|
+
params: "(".concat(feature, ": ").concat(value, ")")
|
|
3849
|
+
}
|
|
3850
|
+
} : null;
|
|
3851
|
+
}
|
|
3852
|
+
var PSEUDO = {
|
|
3853
|
+
hover: '&:hover',
|
|
3854
|
+
focus: '&:focus',
|
|
3855
|
+
'focus-within': '&:focus-within',
|
|
3856
|
+
'focus-visible': '&:focus-visible',
|
|
3857
|
+
active: '&:active',
|
|
3858
|
+
visited: '&:visited',
|
|
3859
|
+
target: '&:target',
|
|
3860
|
+
disabled: '&:disabled',
|
|
3861
|
+
enabled: '&:enabled',
|
|
3862
|
+
checked: '&:checked',
|
|
3863
|
+
indeterminate: '&:indeterminate',
|
|
3864
|
+
"default": '&:default',
|
|
3865
|
+
required: '&:required',
|
|
3866
|
+
valid: '&:valid',
|
|
3867
|
+
invalid: '&:invalid',
|
|
3868
|
+
'read-only': '&:read-only',
|
|
3869
|
+
'placeholder-shown': '&:placeholder-shown',
|
|
3870
|
+
autofill: '&:autofill',
|
|
3871
|
+
empty: '&:empty',
|
|
3872
|
+
first: '&:first-child',
|
|
3873
|
+
last: '&:last-child',
|
|
3874
|
+
only: '&:only-child',
|
|
3875
|
+
odd: '&:nth-child(odd)',
|
|
3876
|
+
even: '&:nth-child(even)',
|
|
3877
|
+
'first-of-type': '&:first-of-type',
|
|
3878
|
+
'last-of-type': '&:last-of-type'
|
|
3879
|
+
};
|
|
3880
|
+
var PSEUDO_ELEMENT = {
|
|
3881
|
+
before: '&::before',
|
|
3882
|
+
after: '&::after',
|
|
3883
|
+
placeholder: '&::placeholder',
|
|
3884
|
+
selection: '&::selection',
|
|
3885
|
+
marker: '&::marker',
|
|
3886
|
+
file: '&::file-selector-button',
|
|
3887
|
+
backdrop: '&::backdrop',
|
|
3888
|
+
'first-line': '&::first-line',
|
|
3889
|
+
'first-letter': '&::first-letter'
|
|
3890
|
+
};
|
|
3891
|
+
var MEDIA = {
|
|
3892
|
+
dark: '(prefers-color-scheme: dark)',
|
|
3893
|
+
'motion-reduce': '(prefers-reduced-motion: reduce)',
|
|
3894
|
+
'motion-safe': '(prefers-reduced-motion: no-preference)',
|
|
3895
|
+
'contrast-more': '(prefers-contrast: more)',
|
|
3896
|
+
'contrast-less': '(prefers-contrast: less)',
|
|
3897
|
+
portrait: '(orientation: portrait)',
|
|
3898
|
+
landscape: '(orientation: landscape)',
|
|
3899
|
+
print: 'print'
|
|
3900
|
+
};
|
|
3901
|
+
function named(v) {
|
|
3902
|
+
return v ? v.value : null;
|
|
3903
|
+
}
|
|
3904
|
+
|
|
3905
|
+
// `group-hover` → `.group:hover &`; `group-[.foo]` → `.group.foo &`. A named value
|
|
3906
|
+
// is a pseudo-class, an arbitrary one is a raw selector fragment.
|
|
3907
|
+
function relational(v, base, tail) {
|
|
3908
|
+
var value = named(v);
|
|
3909
|
+
if (!value) return null;
|
|
3910
|
+
var cond = v.kind === 'arbitrary' ? value : ":".concat(value);
|
|
3911
|
+
return {
|
|
3912
|
+
selector: "".concat(base).concat(cond).concat(tail)
|
|
3913
|
+
};
|
|
3914
|
+
}
|
|
3915
|
+
|
|
3916
|
+
// The batteries-included registry: the default token theme plus the utility
|
|
3917
|
+
// families and variants. Projects extend it (`@utility`, `@theme`, JS config) or
|
|
3918
|
+
// build a bare `new Registry(theme)` and register their own.
|
|
3919
|
+
function createRegistry() {
|
|
3920
|
+
var reg = new Registry(defaultTheme());
|
|
3921
|
+
registerUtilities(reg);
|
|
3922
|
+
registerVariants(reg);
|
|
3923
|
+
return reg;
|
|
3924
|
+
}
|
|
3925
|
+
|
|
3926
|
+
// Pulls atom class strings out of arbitrary source (HTML, JSX, template
|
|
3927
|
+
// literals, …). It's deliberately permissive — anything class-shaped is emitted
|
|
3928
|
+
// and the compiler drops what it doesn't recognise. Runs inside `[...]` are kept
|
|
3929
|
+
// whole so arbitrary values and selectors survive; `(` `)` and quotes end a run
|
|
3930
|
+
// so classes inside `clsx('a', 'b')` are found individually.
|
|
3931
|
+
|
|
3932
|
+
var BOUNDARY = new Set([' ', '\t', '\n', '\r', '\f', '"', "'", '`', '<', '>', '=', '{', '}', ';', ',', '(', ')', '|', '\\']);
|
|
3933
|
+
function scanAtoms(source) {
|
|
3934
|
+
var found = new Set();
|
|
3935
|
+
var n = source.length;
|
|
3936
|
+
var i = 0;
|
|
3937
|
+
while (i < n) {
|
|
3938
|
+
if (BOUNDARY.has(source[i])) {
|
|
3939
|
+
i++;
|
|
3940
|
+
continue;
|
|
3941
|
+
}
|
|
3942
|
+
var j = i;
|
|
3943
|
+
var depth = 0;
|
|
3944
|
+
while (j < n) {
|
|
3945
|
+
var c = source[j];
|
|
3946
|
+
if (c === '[') depth++;else if (c === ']') {
|
|
3947
|
+
if (depth === 0) break;
|
|
3948
|
+
depth--;
|
|
3949
|
+
} else if (depth === 0 && BOUNDARY.has(c)) break;
|
|
3950
|
+
j++;
|
|
3951
|
+
}
|
|
3952
|
+
add(found, source.slice(i, j));
|
|
3953
|
+
i = j;
|
|
3954
|
+
}
|
|
3955
|
+
return _toConsumableArray(found);
|
|
3956
|
+
}
|
|
3957
|
+
function add(found, token) {
|
|
3958
|
+
// Trailing sentence/markup punctuation is never part of a class.
|
|
3959
|
+
var cleaned = token.replace(/[.,;:]+$/, '');
|
|
3960
|
+
if (cleaned && /[a-zA-Z]/.test(cleaned)) found.add(cleaned);
|
|
3961
|
+
}
|
|
3962
|
+
|
|
3963
|
+
// Reads `@source` directives from the input CSS: which files to scan for classes.
|
|
3964
|
+
// @source "../src/**/*.html"; — a glob or directory, relative to the CSS file
|
|
3965
|
+
// @source not "../legacy/**"; — exclude
|
|
3966
|
+
// @source inline("flex hidden"); — safelist literal classes, no file involved
|
|
3967
|
+
|
|
3968
|
+
function parseSources(css) {
|
|
3969
|
+
var patterns = [];
|
|
3970
|
+
var inline = [];
|
|
3971
|
+
var _iterator = _createForOfIteratorHelper(parseCss(css).children),
|
|
3972
|
+
_step;
|
|
3973
|
+
try {
|
|
3974
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
3975
|
+
var _node$preludeText;
|
|
3976
|
+
var node = _step.value;
|
|
3977
|
+
if (node.type !== 'atrule' || node.name !== 'source') continue;
|
|
3978
|
+
var raw = ((_node$preludeText = node.preludeText) !== null && _node$preludeText !== void 0 ? _node$preludeText : '').trim();
|
|
3979
|
+
if (!raw) continue;
|
|
3980
|
+
var negate = false;
|
|
3981
|
+
if (raw === 'not' || raw.startsWith('not ') || raw.startsWith('not"') || raw.startsWith("not'")) {
|
|
3982
|
+
negate = true;
|
|
3983
|
+
raw = raw.slice(3).trim();
|
|
3984
|
+
}
|
|
3985
|
+
if (raw.startsWith('inline(') && raw.endsWith(')')) {
|
|
3986
|
+
var _iterator2 = _createForOfIteratorHelper(scanAtoms(unquote(raw.slice(7, -1)))),
|
|
3987
|
+
_step2;
|
|
3988
|
+
try {
|
|
3989
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
3990
|
+
var c = _step2.value;
|
|
3991
|
+
inline.push(c);
|
|
3992
|
+
}
|
|
3993
|
+
} catch (err) {
|
|
3994
|
+
_iterator2.e(err);
|
|
3995
|
+
} finally {
|
|
3996
|
+
_iterator2.f();
|
|
3997
|
+
}
|
|
3998
|
+
continue;
|
|
3999
|
+
}
|
|
4000
|
+
var pattern = unquote(raw);
|
|
4001
|
+
if (pattern) patterns.push({
|
|
4002
|
+
pattern: pattern,
|
|
4003
|
+
negate: negate
|
|
4004
|
+
});
|
|
4005
|
+
}
|
|
4006
|
+
} catch (err) {
|
|
4007
|
+
_iterator.e(err);
|
|
4008
|
+
} finally {
|
|
4009
|
+
_iterator.f();
|
|
4010
|
+
}
|
|
4011
|
+
return {
|
|
4012
|
+
patterns: patterns,
|
|
4013
|
+
inline: inline
|
|
4014
|
+
};
|
|
4015
|
+
}
|
|
4016
|
+
function unquote(s) {
|
|
4017
|
+
var t = s.trim();
|
|
4018
|
+
return t.length >= 2 && (t[0] === '"' || t[0] === "'") && t[t.length - 1] === t[0] ? t.slice(1, -1) : t;
|
|
4019
|
+
}
|
|
4020
|
+
var GLOB_CHARS = /[*?{}[\]()!]/;
|
|
4021
|
+
var SOURCE_EXTS = 'html,js,jsx,ts,tsx,mjs,cjs,vue,svelte,astro,md,mdx,php,erb';
|
|
4022
|
+
var DEFAULT_IGNORE = ['**/node_modules/**', '**/.git/**', '**/dist/**'];
|
|
4023
|
+
|
|
4024
|
+
// Expands the parsed patterns to a de-duplicated list of absolute file paths,
|
|
4025
|
+
// relative to `base`. A bare directory path scans its source files recursively;
|
|
4026
|
+
// a plain file path or an explicit glob is honoured as written.
|
|
4027
|
+
function resolveSourceFiles(parsed, base) {
|
|
4028
|
+
var include = [];
|
|
4029
|
+
var ignore = [].concat(DEFAULT_IGNORE);
|
|
4030
|
+
var _iterator3 = _createForOfIteratorHelper(parsed.patterns),
|
|
4031
|
+
_step3;
|
|
4032
|
+
try {
|
|
4033
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
4034
|
+
var _step3$value = _step3.value,
|
|
4035
|
+
pattern = _step3$value.pattern,
|
|
4036
|
+
negate = _step3$value.negate;
|
|
4037
|
+
(negate ? ignore : include).push(expandBareDir(pattern, base));
|
|
4038
|
+
}
|
|
4039
|
+
} catch (err) {
|
|
4040
|
+
_iterator3.e(err);
|
|
4041
|
+
} finally {
|
|
4042
|
+
_iterator3.f();
|
|
4043
|
+
}
|
|
4044
|
+
if (include.length === 0) return [];
|
|
4045
|
+
return fg.sync(include, {
|
|
4046
|
+
cwd: base,
|
|
4047
|
+
ignore: ignore,
|
|
4048
|
+
absolute: true,
|
|
4049
|
+
dot: false,
|
|
4050
|
+
onlyFiles: true
|
|
4051
|
+
});
|
|
4052
|
+
}
|
|
4053
|
+
|
|
4054
|
+
// A pattern with no glob magic that points at a directory becomes `dir/**/*.{exts}`.
|
|
4055
|
+
function expandBareDir(pattern, base) {
|
|
4056
|
+
if (GLOB_CHARS.test(pattern)) return pattern;
|
|
4057
|
+
var abs = path.resolve(base, pattern);
|
|
4058
|
+
try {
|
|
4059
|
+
if (fs.statSync(abs).isDirectory()) return path.join(pattern, "**/*.{".concat(SOURCE_EXTS, "}"));
|
|
4060
|
+
} catch (_unused) {
|
|
4061
|
+
// Missing path: leave as-is so fast-glob simply matches nothing.
|
|
4062
|
+
}
|
|
4063
|
+
return pattern;
|
|
4064
|
+
}
|
|
4065
|
+
function scanSourceFiles(files) {
|
|
4066
|
+
var found = new Set();
|
|
4067
|
+
var _iterator4 = _createForOfIteratorHelper(files),
|
|
4068
|
+
_step4;
|
|
4069
|
+
try {
|
|
4070
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
4071
|
+
var file = _step4.value;
|
|
4072
|
+
var text = void 0;
|
|
4073
|
+
try {
|
|
4074
|
+
text = fs.readFileSync(file, 'utf8');
|
|
4075
|
+
} catch (_unused2) {
|
|
4076
|
+
continue;
|
|
4077
|
+
}
|
|
4078
|
+
var _iterator5 = _createForOfIteratorHelper(scanAtoms(text)),
|
|
4079
|
+
_step5;
|
|
4080
|
+
try {
|
|
4081
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
4082
|
+
var c = _step5.value;
|
|
4083
|
+
found.add(c);
|
|
4084
|
+
}
|
|
4085
|
+
} catch (err) {
|
|
4086
|
+
_iterator5.e(err);
|
|
4087
|
+
} finally {
|
|
4088
|
+
_iterator5.f();
|
|
4089
|
+
}
|
|
4090
|
+
}
|
|
4091
|
+
} catch (err) {
|
|
4092
|
+
_iterator4.e(err);
|
|
4093
|
+
} finally {
|
|
4094
|
+
_iterator4.f();
|
|
4095
|
+
}
|
|
4096
|
+
return _toConsumableArray(found);
|
|
4097
|
+
}
|
|
4098
|
+
|
|
4099
|
+
// Bridges a fluixi-css theme to the `--flx-ui-*` custom properties the Fluixi UI
|
|
4100
|
+
// components read (`@fluixi-ui/tokens`). Each bridge emits `--flx-ui-x: var(--src)`
|
|
4101
|
+
// so a fluixi-css theme *drives* the UI — change the theme, the components follow —
|
|
4102
|
+
// without copying any values across. A bridge is emitted only when its source
|
|
4103
|
+
// token exists, so the UI's own defaults stand in for anything the theme omits.
|
|
4104
|
+
|
|
4105
|
+
// UI space scale ↔ the `--spacing` base (space-4 = 1rem = 0.25rem × 4).
|
|
4106
|
+
var SPACE_STEPS = [0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24];
|
|
4107
|
+
|
|
4108
|
+
// UI font-size keys ↔ fluixi `--text-*` keys (the UI's `md` is fluixi's `base`).
|
|
4109
|
+
var FONT_SIZE = [['xs', 'xs'], ['sm', 'sm'], ['md', 'base'], ['lg', 'lg'], ['xl', 'xl'], ['2xl', '2xl'], ['3xl', '3xl'], ['4xl', '4xl']];
|
|
4110
|
+
var RADIUS = ['sm', 'md', 'lg', 'xl'];
|
|
4111
|
+
var SHADOW = ['sm', 'md', 'lg', 'xl'];
|
|
4112
|
+
var BREAKPOINT = ['sm', 'md', 'lg', 'xl', '2xl'];
|
|
4113
|
+
function uiTokenBridges(theme) {
|
|
4114
|
+
var out = [];
|
|
4115
|
+
var bridge = function bridge(flx, source) {
|
|
4116
|
+
if (theme.has(source)) out.push(decl("--flx-ui-".concat(flx), "var(".concat(source, ")")));
|
|
4117
|
+
};
|
|
4118
|
+
if (theme.has('--spacing')) {
|
|
4119
|
+
var _iterator = _createForOfIteratorHelper(SPACE_STEPS),
|
|
4120
|
+
_step;
|
|
4121
|
+
try {
|
|
4122
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
4123
|
+
var n = _step.value;
|
|
4124
|
+
out.push(decl("--flx-ui-space-".concat(n), n === 0 ? '0px' : "calc(var(--spacing) * ".concat(n, ")")));
|
|
4125
|
+
}
|
|
4126
|
+
} catch (err) {
|
|
4127
|
+
_iterator.e(err);
|
|
4128
|
+
} finally {
|
|
4129
|
+
_iterator.f();
|
|
4130
|
+
}
|
|
4131
|
+
}
|
|
4132
|
+
var _iterator2 = _createForOfIteratorHelper(RADIUS),
|
|
4133
|
+
_step2;
|
|
4134
|
+
try {
|
|
4135
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
4136
|
+
var k = _step2.value;
|
|
4137
|
+
bridge("radius-".concat(k), "--radius-".concat(k));
|
|
4138
|
+
}
|
|
4139
|
+
} catch (err) {
|
|
4140
|
+
_iterator2.e(err);
|
|
4141
|
+
} finally {
|
|
4142
|
+
_iterator2.f();
|
|
4143
|
+
}
|
|
4144
|
+
var _iterator3 = _createForOfIteratorHelper(FONT_SIZE),
|
|
4145
|
+
_step3;
|
|
4146
|
+
try {
|
|
4147
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
4148
|
+
var _step3$value = _slicedToArray(_step3.value, 2),
|
|
4149
|
+
flx = _step3$value[0],
|
|
4150
|
+
key = _step3$value[1];
|
|
4151
|
+
bridge("font-size-".concat(flx), "--text-".concat(key));
|
|
4152
|
+
}
|
|
4153
|
+
} catch (err) {
|
|
4154
|
+
_iterator3.e(err);
|
|
4155
|
+
} finally {
|
|
4156
|
+
_iterator3.f();
|
|
4157
|
+
}
|
|
4158
|
+
var _iterator4 = _createForOfIteratorHelper(SHADOW),
|
|
4159
|
+
_step4;
|
|
4160
|
+
try {
|
|
4161
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
4162
|
+
var _k = _step4.value;
|
|
4163
|
+
bridge("shadow-".concat(_k), "--shadow-".concat(_k));
|
|
4164
|
+
}
|
|
4165
|
+
} catch (err) {
|
|
4166
|
+
_iterator4.e(err);
|
|
4167
|
+
} finally {
|
|
4168
|
+
_iterator4.f();
|
|
4169
|
+
}
|
|
4170
|
+
var _iterator5 = _createForOfIteratorHelper(BREAKPOINT),
|
|
4171
|
+
_step5;
|
|
4172
|
+
try {
|
|
4173
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
4174
|
+
var _k2 = _step5.value;
|
|
4175
|
+
bridge("breakpoint-".concat(_k2), "--breakpoint-".concat(_k2));
|
|
4176
|
+
}
|
|
4177
|
+
|
|
4178
|
+
// The functional colour scales are opt-in: a project supplies a Radix-style
|
|
4179
|
+
// `--color-accent-1..12` / `--color-gray-1..12` in its theme and the UI's
|
|
4180
|
+
// semantic colours (`--flx-ui-color-primary`, …) follow. Absent them, the UI's
|
|
4181
|
+
// built-in scales stand.
|
|
4182
|
+
} catch (err) {
|
|
4183
|
+
_iterator5.e(err);
|
|
4184
|
+
} finally {
|
|
4185
|
+
_iterator5.f();
|
|
4186
|
+
}
|
|
4187
|
+
for (var i = 1; i <= 12; i++) {
|
|
4188
|
+
bridge("accent-".concat(i), "--color-accent-".concat(i));
|
|
4189
|
+
bridge("gray-".concat(i), "--color-gray-".concat(i));
|
|
4190
|
+
}
|
|
4191
|
+
return out;
|
|
4192
|
+
}
|
|
4193
|
+
|
|
4194
|
+
// The bridges as a `:root { … }` rule, ready to prepend to the compiled sheet.
|
|
4195
|
+
function emitUiTheme(theme) {
|
|
4196
|
+
var selector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ':root';
|
|
4197
|
+
return rule(selector, uiTokenBridges(theme));
|
|
4198
|
+
}
|
|
4199
|
+
|
|
4200
|
+
// Directives consumed to build the registry — dropped from the output.
|
|
4201
|
+
var CONSUMED = new Set(['theme', 'utility', 'custom-variant', 'source']);
|
|
4202
|
+
// The at-rule that marks where generated tokens + utilities are spliced in.
|
|
4203
|
+
var MARKER = 'fluixi';
|
|
4204
|
+
// Processes a whole stylesheet: the author's CSS passes through untouched (and
|
|
4205
|
+
// mapped back to source), the `@theme`/`@utility`/`@custom-variant`/`@source`
|
|
4206
|
+
// directives are consumed, and an `@fluixi;` marker is replaced by the generated
|
|
4207
|
+
// token `:root` + utilities. With no marker the generated block is appended.
|
|
4208
|
+
function transform(input) {
|
|
4209
|
+
var _options$registry, _options$classes, _options$from, _options$sources;
|
|
4210
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
4211
|
+
var reg = (_options$registry = options.registry) !== null && _options$registry !== void 0 ? _options$registry : createRegistry();
|
|
4212
|
+
loadTheme(input, reg.theme);
|
|
4213
|
+
loadDirectives(input, reg);
|
|
4214
|
+
var classes = new Set((_options$classes = options.classes) !== null && _options$classes !== void 0 ? _options$classes : []);
|
|
4215
|
+
var _iterator = _createForOfIteratorHelper((_options$sources = options.sources) !== null && _options$sources !== void 0 ? _options$sources : []),
|
|
4216
|
+
_step;
|
|
4217
|
+
try {
|
|
4218
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
4219
|
+
var s = _step.value;
|
|
4220
|
+
var _iterator6 = _createForOfIteratorHelper(scanAtoms(s)),
|
|
4221
|
+
_step6;
|
|
4222
|
+
try {
|
|
4223
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
4224
|
+
var _c = _step6.value;
|
|
4225
|
+
classes.add(_c);
|
|
4226
|
+
}
|
|
4227
|
+
} catch (err) {
|
|
4228
|
+
_iterator6.e(err);
|
|
4229
|
+
} finally {
|
|
4230
|
+
_iterator6.f();
|
|
4231
|
+
}
|
|
4232
|
+
}
|
|
4233
|
+
} catch (err) {
|
|
4234
|
+
_iterator.e(err);
|
|
4235
|
+
} finally {
|
|
4236
|
+
_iterator.f();
|
|
4237
|
+
}
|
|
4238
|
+
var parsed = parseSources(input);
|
|
4239
|
+
var _iterator2 = _createForOfIteratorHelper(parsed.inline),
|
|
4240
|
+
_step2;
|
|
4241
|
+
try {
|
|
4242
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
4243
|
+
var _c2 = _step2.value;
|
|
4244
|
+
classes.add(_c2);
|
|
4245
|
+
}
|
|
4246
|
+
} catch (err) {
|
|
4247
|
+
_iterator2.e(err);
|
|
4248
|
+
} finally {
|
|
4249
|
+
_iterator2.f();
|
|
4250
|
+
}
|
|
4251
|
+
var sources = [];
|
|
4252
|
+
if (parsed.patterns.length) {
|
|
4253
|
+
var _options$base;
|
|
4254
|
+
sources = resolveSourceFiles(parsed, (_options$base = options.base) !== null && _options$base !== void 0 ? _options$base : process.cwd());
|
|
4255
|
+
var _iterator3 = _createForOfIteratorHelper(scanSourceFiles(sources)),
|
|
4256
|
+
_step3;
|
|
4257
|
+
try {
|
|
4258
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
4259
|
+
var c = _step3.value;
|
|
4260
|
+
classes.add(c);
|
|
4261
|
+
}
|
|
4262
|
+
} catch (err) {
|
|
4263
|
+
_iterator3.e(err);
|
|
4264
|
+
} finally {
|
|
4265
|
+
_iterator3.f();
|
|
4266
|
+
}
|
|
4267
|
+
}
|
|
4268
|
+
var rules = [];
|
|
4269
|
+
var _iterator4 = _createForOfIteratorHelper(classes),
|
|
4270
|
+
_step4;
|
|
4271
|
+
try {
|
|
4272
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
4273
|
+
var cls = _step4.value;
|
|
4274
|
+
var atom = parseAtom(cls, reg);
|
|
4275
|
+
if (!atom) continue;
|
|
4276
|
+
var compiled = compileAtom(atom, reg);
|
|
4277
|
+
if (compiled) rules.push.apply(rules, _toConsumableArray(compiled));
|
|
4278
|
+
}
|
|
4279
|
+
} catch (err) {
|
|
4280
|
+
_iterator4.e(err);
|
|
4281
|
+
} finally {
|
|
4282
|
+
_iterator4.f();
|
|
4283
|
+
}
|
|
4284
|
+
var uiBlock = options.emitUiTokens ? emitUiTheme(reg.theme) : null;
|
|
4285
|
+
var generated = [];
|
|
4286
|
+
if (options.emitTokens !== false) {
|
|
4287
|
+
var used = collectVarRefs(rules);
|
|
4288
|
+
if (uiBlock) collectVarRefs([uiBlock], used);
|
|
4289
|
+
var tokens = emitTheme(reg.theme, ':root', used);
|
|
4290
|
+
if (tokens.nodes.length) generated.push(tokens);
|
|
4291
|
+
}
|
|
4292
|
+
if (uiBlock && uiBlock.nodes.length) generated.push(uiBlock);
|
|
4293
|
+
generated.push.apply(generated, rules);
|
|
4294
|
+
var from = (_options$from = options.from) !== null && _options$from !== void 0 ? _options$from : '<input>';
|
|
4295
|
+
var nodes = [];
|
|
4296
|
+
var injected = false;
|
|
4297
|
+
var _iterator5 = _createForOfIteratorHelper(parseCss(input).children),
|
|
4298
|
+
_step5;
|
|
4299
|
+
try {
|
|
4300
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
4301
|
+
var _node$loc, _node$loc2;
|
|
4302
|
+
var node = _step5.value;
|
|
4303
|
+
if (node.type === 'atrule' && node.name === MARKER) {
|
|
4304
|
+
if (!injected) {
|
|
4305
|
+
nodes.push.apply(nodes, generated);
|
|
4306
|
+
injected = true;
|
|
4307
|
+
}
|
|
4308
|
+
continue;
|
|
4309
|
+
}
|
|
4310
|
+
if (node.type === 'atrule' && node.name && CONSUMED.has(node.name)) continue;
|
|
4311
|
+
var start = (_node$loc = node.loc) === null || _node$loc === void 0 ? void 0 : _node$loc.start;
|
|
4312
|
+
var end = (_node$loc2 = node.loc) === null || _node$loc2 === void 0 ? void 0 : _node$loc2.end;
|
|
4313
|
+
if (start && end && typeof start.offset === 'number' && typeof end.offset === 'number') {
|
|
4314
|
+
nodes.push(raw(input.slice(start.offset, end.offset), {
|
|
4315
|
+
source: from,
|
|
4316
|
+
line: start.line,
|
|
4317
|
+
column: Math.max(0, start.column - 1)
|
|
4318
|
+
}));
|
|
4319
|
+
}
|
|
4320
|
+
}
|
|
4321
|
+
} catch (err) {
|
|
4322
|
+
_iterator5.e(err);
|
|
4323
|
+
} finally {
|
|
4324
|
+
_iterator5.f();
|
|
4325
|
+
}
|
|
4326
|
+
if (!injected) nodes.push.apply(nodes, generated);
|
|
4327
|
+
if (options.reset) nodes.unshift(raw(options.reset));
|
|
4328
|
+
if (options.sourceMap) {
|
|
4329
|
+
var _stringifyWithMap = stringifyWithMap(nodes, {
|
|
4330
|
+
minify: options.minify
|
|
4331
|
+
}),
|
|
4332
|
+
css = _stringifyWithMap.css,
|
|
4333
|
+
map = _stringifyWithMap.map;
|
|
4334
|
+
map.setSourceContent(from, input);
|
|
4335
|
+
var json = map.toJSON();
|
|
4336
|
+
json.file = from;
|
|
4337
|
+
return {
|
|
4338
|
+
css: css,
|
|
4339
|
+
map: json,
|
|
4340
|
+
classes: _toConsumableArray(classes),
|
|
4341
|
+
sources: sources,
|
|
4342
|
+
registry: reg
|
|
4343
|
+
};
|
|
4344
|
+
}
|
|
4345
|
+
return {
|
|
4346
|
+
css: stringify(nodes, {
|
|
4347
|
+
minify: options.minify
|
|
4348
|
+
}),
|
|
4349
|
+
classes: _toConsumableArray(classes),
|
|
4350
|
+
sources: sources,
|
|
4351
|
+
registry: reg
|
|
4352
|
+
};
|
|
4353
|
+
}
|
|
4354
|
+
|
|
4355
|
+
// Parse, compile and stringify a set of utility classes. Unknown or malformed
|
|
4356
|
+
// classes are skipped.
|
|
4357
|
+
function compileClasses(classes, reg, options) {
|
|
4358
|
+
var nodes = [];
|
|
4359
|
+
var _iterator = _createForOfIteratorHelper(classes),
|
|
4360
|
+
_step;
|
|
4361
|
+
try {
|
|
4362
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
4363
|
+
var cls = _step.value;
|
|
4364
|
+
var atom = parseAtom(cls, reg);
|
|
4365
|
+
if (!atom) continue;
|
|
4366
|
+
var compiled = compileAtom(atom, reg);
|
|
4367
|
+
if (compiled) nodes.push.apply(nodes, _toConsumableArray(compiled));
|
|
4368
|
+
}
|
|
4369
|
+
} catch (err) {
|
|
4370
|
+
_iterator.e(err);
|
|
4371
|
+
} finally {
|
|
4372
|
+
_iterator.f();
|
|
4373
|
+
}
|
|
4374
|
+
return stringify(nodes, options);
|
|
4375
|
+
}
|
|
4376
|
+
// The one-call entry: merge `@theme` tokens from `input`, gather classes (given
|
|
4377
|
+
// and/or scanned), and emit the token `:root` plus the rules they need.
|
|
4378
|
+
function compile(input) {
|
|
4379
|
+
var _options$registry, _options$classes, _options$sources;
|
|
4380
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
4381
|
+
var reg = (_options$registry = options.registry) !== null && _options$registry !== void 0 ? _options$registry : createRegistry();
|
|
4382
|
+
loadTheme(input, reg.theme);
|
|
4383
|
+
loadDirectives(input, reg);
|
|
4384
|
+
var classes = new Set((_options$classes = options.classes) !== null && _options$classes !== void 0 ? _options$classes : []);
|
|
4385
|
+
var _iterator2 = _createForOfIteratorHelper((_options$sources = options.sources) !== null && _options$sources !== void 0 ? _options$sources : []),
|
|
4386
|
+
_step2;
|
|
4387
|
+
try {
|
|
4388
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
4389
|
+
var source = _step2.value;
|
|
4390
|
+
var _iterator6 = _createForOfIteratorHelper(scanAtoms(source)),
|
|
4391
|
+
_step6;
|
|
4392
|
+
try {
|
|
4393
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
4394
|
+
var _c = _step6.value;
|
|
4395
|
+
classes.add(_c);
|
|
4396
|
+
}
|
|
4397
|
+
} catch (err) {
|
|
4398
|
+
_iterator6.e(err);
|
|
4399
|
+
} finally {
|
|
4400
|
+
_iterator6.f();
|
|
4401
|
+
}
|
|
4402
|
+
}
|
|
4403
|
+
|
|
4404
|
+
// `@source` directives pull classes from files on disk.
|
|
4405
|
+
} catch (err) {
|
|
4406
|
+
_iterator2.e(err);
|
|
4407
|
+
} finally {
|
|
4408
|
+
_iterator2.f();
|
|
4409
|
+
}
|
|
4410
|
+
var parsedSources = parseSources(input);
|
|
4411
|
+
var _iterator3 = _createForOfIteratorHelper(parsedSources.inline),
|
|
4412
|
+
_step3;
|
|
4413
|
+
try {
|
|
4414
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
4415
|
+
var _c2 = _step3.value;
|
|
4416
|
+
classes.add(_c2);
|
|
4417
|
+
}
|
|
4418
|
+
} catch (err) {
|
|
4419
|
+
_iterator3.e(err);
|
|
4420
|
+
} finally {
|
|
4421
|
+
_iterator3.f();
|
|
4422
|
+
}
|
|
4423
|
+
var sources = [];
|
|
4424
|
+
if (parsedSources.patterns.length) {
|
|
4425
|
+
var _options$base;
|
|
4426
|
+
sources = resolveSourceFiles(parsedSources, (_options$base = options.base) !== null && _options$base !== void 0 ? _options$base : process.cwd());
|
|
4427
|
+
var _iterator4 = _createForOfIteratorHelper(scanSourceFiles(sources)),
|
|
4428
|
+
_step4;
|
|
4429
|
+
try {
|
|
4430
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
4431
|
+
var c = _step4.value;
|
|
4432
|
+
classes.add(c);
|
|
4433
|
+
}
|
|
4434
|
+
} catch (err) {
|
|
4435
|
+
_iterator4.e(err);
|
|
4436
|
+
} finally {
|
|
4437
|
+
_iterator4.f();
|
|
4438
|
+
}
|
|
4439
|
+
}
|
|
4440
|
+
var rules = [];
|
|
4441
|
+
var _iterator5 = _createForOfIteratorHelper(classes),
|
|
4442
|
+
_step5;
|
|
4443
|
+
try {
|
|
4444
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
4445
|
+
var cls = _step5.value;
|
|
4446
|
+
var atom = parseAtom(cls, reg);
|
|
4447
|
+
if (!atom) continue;
|
|
4448
|
+
var compiled = compileAtom(atom, reg);
|
|
4449
|
+
if (compiled) rules.push.apply(rules, _toConsumableArray(compiled));
|
|
4450
|
+
}
|
|
4451
|
+
|
|
4452
|
+
// The `--flx-ui-*` bridge, if requested — its `var()` refs must survive the
|
|
4453
|
+
// token tree-shake, so fold them into the used set.
|
|
4454
|
+
} catch (err) {
|
|
4455
|
+
_iterator5.e(err);
|
|
4456
|
+
} finally {
|
|
4457
|
+
_iterator5.f();
|
|
4458
|
+
}
|
|
4459
|
+
var uiBlock = options.emitUiTokens ? emitUiTheme(reg.theme) : null;
|
|
4460
|
+
|
|
4461
|
+
// Emit only the tokens the compiled rules (and any UI bridge) actually reference.
|
|
4462
|
+
var nodes = [];
|
|
4463
|
+
if (options.emitTokens !== false) {
|
|
4464
|
+
var used = collectVarRefs(rules);
|
|
4465
|
+
if (uiBlock) collectVarRefs([uiBlock], used);
|
|
4466
|
+
var tokens = emitTheme(reg.theme, ':root', used);
|
|
4467
|
+
if (tokens.nodes.length) nodes.push(tokens);
|
|
4468
|
+
}
|
|
4469
|
+
if (uiBlock && uiBlock.nodes.length) nodes.push(uiBlock);
|
|
4470
|
+
nodes.push.apply(nodes, rules);
|
|
4471
|
+
return {
|
|
4472
|
+
css: stringify(nodes, {
|
|
4473
|
+
minify: options.minify
|
|
4474
|
+
}),
|
|
4475
|
+
classes: _toConsumableArray(classes),
|
|
4476
|
+
sources: sources,
|
|
4477
|
+
registry: reg
|
|
4478
|
+
};
|
|
4479
|
+
}
|
|
4480
|
+
|
|
4481
|
+
exports.Registry = Registry;
|
|
4482
|
+
exports.SPECIAL_COLORS = SPECIAL_COLORS;
|
|
4483
|
+
exports.Theme = Theme;
|
|
4484
|
+
exports.atRule = atRule;
|
|
4485
|
+
exports.collectVarRefs = collectVarRefs;
|
|
4486
|
+
exports.colorValue = colorValue;
|
|
4487
|
+
exports.compile = compile;
|
|
4488
|
+
exports.compileAtom = compileAtom;
|
|
4489
|
+
exports.compileClasses = compileClasses;
|
|
4490
|
+
exports.createRegistry = createRegistry;
|
|
4491
|
+
exports.decl = decl;
|
|
4492
|
+
exports.decodeUnderscores = decodeUnderscores;
|
|
4493
|
+
exports.defaultTheme = defaultTheme;
|
|
4494
|
+
exports.emitTheme = emitTheme;
|
|
4495
|
+
exports.emitUiTheme = emitUiTheme;
|
|
4496
|
+
exports.escapeClass = escapeClass;
|
|
4497
|
+
exports.keywords = keywords;
|
|
4498
|
+
exports.loadDirectives = loadDirectives;
|
|
4499
|
+
exports.loadTheme = loadTheme;
|
|
4500
|
+
exports.parseAtom = parseAtom;
|
|
4501
|
+
exports.parseSources = parseSources;
|
|
4502
|
+
exports.parseVariant = parseVariant;
|
|
4503
|
+
exports.props = props;
|
|
4504
|
+
exports.raw = raw;
|
|
4505
|
+
exports.registerUtilities = registerUtilities;
|
|
4506
|
+
exports.registerVariants = registerVariants;
|
|
4507
|
+
exports.resolveSourceFiles = resolveSourceFiles;
|
|
4508
|
+
exports.rule = rule;
|
|
4509
|
+
exports.scanAtoms = scanAtoms;
|
|
4510
|
+
exports.scanSourceFiles = scanSourceFiles;
|
|
4511
|
+
exports.sizeValue = sizeValue;
|
|
4512
|
+
exports.splitAtTopLevel = splitAtTopLevel;
|
|
4513
|
+
exports.statics = statics;
|
|
4514
|
+
exports.stringify = stringify;
|
|
4515
|
+
exports.stringifyWithMap = stringifyWithMap;
|
|
4516
|
+
exports.transform = transform;
|
|
4517
|
+
exports.uiTokenBridges = uiTokenBridges;
|
|
4518
|
+
//# sourceMappingURL=index.cjs.map
|