@wyw-in-js/processor-utils 1.0.5 → 2.0.0-alpha.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.
Files changed (90) hide show
  1. package/esm/BaseProcessor.js +47 -68
  2. package/esm/BaseProcessor.js.map +1 -1
  3. package/esm/TaggedTemplateProcessor.js +32 -41
  4. package/esm/TaggedTemplateProcessor.js.map +1 -1
  5. package/esm/ast.js +72 -0
  6. package/esm/ast.js.map +1 -0
  7. package/esm/diagnostics.js +4 -0
  8. package/esm/diagnostics.js.map +1 -0
  9. package/esm/index.js +9 -7
  10. package/esm/index.js.map +1 -1
  11. package/esm/types.js +1 -1
  12. package/esm/types.js.map +1 -1
  13. package/esm/utils/buildSlug.js +2 -2
  14. package/esm/utils/buildSlug.js.map +1 -1
  15. package/esm/utils/getClassNameAndSlug.js +38 -41
  16. package/esm/utils/getClassNameAndSlug.js.map +1 -1
  17. package/esm/utils/getVariableName.js +7 -10
  18. package/esm/utils/getVariableName.js.map +1 -1
  19. package/esm/utils/stripLines.js +9 -11
  20. package/esm/utils/stripLines.js.map +1 -1
  21. package/esm/utils/templateProcessor.js +98 -118
  22. package/esm/utils/templateProcessor.js.map +1 -1
  23. package/esm/utils/throwIfInvalid.js +11 -12
  24. package/esm/utils/throwIfInvalid.js.map +1 -1
  25. package/esm/utils/toCSS.js +34 -43
  26. package/esm/utils/toCSS.js.map +1 -1
  27. package/esm/utils/toValidCSSIdentifier.js +2 -2
  28. package/esm/utils/toValidCSSIdentifier.js.map +1 -1
  29. package/esm/utils/types.js +1 -1
  30. package/esm/utils/types.js.map +1 -1
  31. package/esm/utils/units.js +79 -61
  32. package/esm/utils/units.js.map +1 -1
  33. package/esm/utils/validateParams.js +29 -39
  34. package/esm/utils/validateParams.js.map +1 -1
  35. package/package.json +15 -15
  36. package/types/BaseProcessor.d.ts +7 -13
  37. package/types/BaseProcessor.js +18 -20
  38. package/types/TaggedTemplateProcessor.d.ts +1 -1
  39. package/types/TaggedTemplateProcessor.js +9 -16
  40. package/types/ast.d.ts +95 -0
  41. package/types/ast.js +80 -0
  42. package/types/diagnostics.d.ts +9 -0
  43. package/types/diagnostics.js +3 -0
  44. package/types/index.d.ts +5 -1
  45. package/types/index.js +8 -29
  46. package/types/types.d.ts +9 -1
  47. package/types/types.js +1 -2
  48. package/types/utils/buildSlug.js +1 -4
  49. package/types/utils/getClassNameAndSlug.js +15 -18
  50. package/types/utils/getVariableName.js +1 -4
  51. package/types/utils/stripLines.js +1 -4
  52. package/types/utils/templateProcessor.d.ts +1 -1
  53. package/types/utils/templateProcessor.js +16 -55
  54. package/types/utils/throwIfInvalid.js +1 -3
  55. package/types/utils/toCSS.js +8 -13
  56. package/types/utils/toValidCSSIdentifier.js +1 -4
  57. package/types/utils/types.d.ts +4 -2
  58. package/types/utils/types.js +1 -2
  59. package/types/utils/units.js +2 -5
  60. package/types/utils/validateParams.js +2 -6
  61. package/lib/BaseProcessor.js +0 -78
  62. package/lib/BaseProcessor.js.map +0 -1
  63. package/lib/TaggedTemplateProcessor.js +0 -51
  64. package/lib/TaggedTemplateProcessor.js.map +0 -1
  65. package/lib/index.js +0 -67
  66. package/lib/index.js.map +0 -1
  67. package/lib/types.js +0 -2
  68. package/lib/types.js.map +0 -1
  69. package/lib/utils/buildSlug.js +0 -12
  70. package/lib/utils/buildSlug.js.map +0 -1
  71. package/lib/utils/getClassNameAndSlug.js +0 -50
  72. package/lib/utils/getClassNameAndSlug.js.map +0 -1
  73. package/lib/utils/getVariableName.js +0 -18
  74. package/lib/utils/getVariableName.js.map +0 -1
  75. package/lib/utils/stripLines.js +0 -22
  76. package/lib/utils/stripLines.js.map +0 -1
  77. package/lib/utils/templateProcessor.js +0 -129
  78. package/lib/utils/templateProcessor.js.map +0 -1
  79. package/lib/utils/throwIfInvalid.js +0 -35
  80. package/lib/utils/throwIfInvalid.js.map +0 -1
  81. package/lib/utils/toCSS.js +0 -58
  82. package/lib/utils/toCSS.js.map +0 -1
  83. package/lib/utils/toValidCSSIdentifier.js +0 -10
  84. package/lib/utils/toValidCSSIdentifier.js.map +0 -1
  85. package/lib/utils/types.js +0 -2
  86. package/lib/utils/types.js.map +0 -1
  87. package/lib/utils/units.js +0 -71
  88. package/lib/utils/units.js.map +0 -1
  89. package/lib/utils/validateParams.js +0 -54
  90. package/lib/utils/validateParams.js.map +0 -1
@@ -1,120 +1,100 @@
1
- /* eslint-disable no-continue */
2
- /**
3
- * This file handles transforming template literals to class names or styled components and generates CSS content.
4
- * It uses CSS code from template literals and evaluated values of lazy dependencies stored in ValueCache.
5
- */
6
-
7
- import { hasEvalMeta, ValueType } from '@wyw-in-js/shared';
8
- import { getVariableName } from './getVariableName';
9
- import stripLines from './stripLines';
10
- import throwIfInvalid from './throwIfInvalid';
11
- import toCSS, { isCSSable } from './toCSS';
12
- import { units } from './units';
13
-
1
+ import { hasEvalMeta, ValueType } from "@wyw-in-js/shared";
2
+ import { getVariableName } from "./getVariableName.js";
3
+ import stripLines from "./stripLines.js";
4
+ import throwIfInvalid from "./throwIfInvalid.js";
5
+ import toCSS, { isCSSable } from "./toCSS.js";
6
+ import { units } from "./units.js";
14
7
  // Match any valid CSS unit not immediately followed by an alphanumeric character or underscore.
15
- const unitRegex = new RegExp(`^(?:${units.join('|')})(?![a-zA-Z0-9_])`);
16
- export default function templateProcessor(tagProcessor, [...template], valueCache, variableNameConfig) {
17
- const sourceMapReplacements = [];
18
- // Check if the variable is referenced anywhere for basic DCE
19
- // Only works when it's assigned to a variable
20
- const {
21
- isReferenced
22
- } = tagProcessor;
23
-
24
- // Serialize the tagged template literal to a string
25
- let cssText = '';
26
- let item;
27
- // eslint-disable-next-line no-cond-assign
28
- while (item = template.shift()) {
29
- if ('type' in item) {
30
- // It's a template element
31
- cssText += item.value.cooked;
32
- continue;
33
- }
34
-
35
- // It's an expression
36
- const {
37
- ex
38
- } = item;
39
- const {
40
- end,
41
- start
42
- } = ex.loc;
43
- const beforeLength = cssText.length;
44
-
45
- // The location will be end of the current string to start of next string
46
- const next = template[0]; // template[0] is the next template element
47
- const loc = {
48
- start,
49
- end: next ? {
50
- line: next.loc.start.line,
51
- column: next.loc.start.column
52
- } : {
53
- line: end.line,
54
- column: end.column + 1
55
- }
56
- };
57
- const value = 'value' in item ? item.value : valueCache.get(item.ex.name);
58
-
59
- // Is it props based interpolation?
60
- if (item.kind === ValueType.FUNCTION || typeof value === 'function') {
61
- // Check if previous expression was a CSS variable that we replaced
62
- // If it has a unit after it, we need to move the unit into the interpolation
63
- // e.g. `var(--size)px` should actually be `var(--size)`
64
- // So we check if the current text starts with a unit, and add the unit to the previous interpolation
65
- // Another approach would be `calc(var(--size) * 1px), but some browsers don't support all units
66
- // https://bugzilla.mozilla.org/show_bug.cgi?id=956573
67
- const matches = next.value.cooked?.match(unitRegex);
68
- try {
69
- if (matches) {
70
- template.shift();
71
- const [unit] = matches;
72
- const varId = tagProcessor.addInterpolation(item.ex, cssText, item.source, unit);
73
- cssText += getVariableName(varId, variableNameConfig);
74
- cssText += next.value.cooked?.substring(unit?.length ?? 0) ?? '';
75
- } else {
76
- const varId = tagProcessor.addInterpolation(item.ex, cssText, item.source);
77
- cssText += getVariableName(varId, variableNameConfig);
78
- }
79
- } catch (e) {
80
- if (e instanceof Error) {
81
- throw item.buildCodeFrameError(e.message);
82
- }
83
- throw e;
84
- }
85
- } else {
86
- throwIfInvalid(tagProcessor.isValidValue.bind(tagProcessor), value, item, item.source);
87
- if (value !== undefined && typeof value !== 'function') {
88
- // Skip the blank string instead of throw ing an error
89
- if (value === '') {
90
- continue;
91
- }
92
- if (hasEvalMeta(value)) {
93
- // If it's a React component wrapped in styled, get the class name
94
- // Useful for interpolating components
95
- cssText += `.${value.__wyw_meta.className}`;
96
- } else if (isCSSable(value)) {
97
- // If it's a plain object or an array, convert it to a CSS string
98
- cssText += stripLines(loc, toCSS(value));
99
- } else {
100
- // For anything else, assume it'll be stringified
101
- cssText += stripLines(loc, value);
102
- }
103
- sourceMapReplacements.push({
104
- original: loc,
105
- length: cssText.length - beforeLength
106
- });
107
- }
108
- }
109
- }
110
- const rules = tagProcessor.extractRules(valueCache, cssText, tagProcessor.location);
111
-
112
- // tagProcessor.doRuntimeReplacement(classes);
113
- if (!isReferenced && !cssText.includes(':global')) {
114
- return null;
115
- }
116
-
117
- // eslint-disable-next-line no-param-reassign
118
- return [rules, sourceMapReplacements];
8
+ const unitRegex = new RegExp(`^(?:${units.join("|")})(?![a-zA-Z0-9_])`);
9
+ export default function templateProcessor(tagProcessor, [ ...template], valueCache, variableNameConfig) {
10
+ const sourceMapReplacements = [];
11
+ // Check if the variable is referenced anywhere for basic DCE
12
+ // Only works when it's assigned to a variable
13
+ const { isReferenced } = tagProcessor;
14
+ // Serialize the tagged template literal to a string
15
+ let cssText = "";
16
+ let item;
17
+ // eslint-disable-next-line no-cond-assign
18
+ while (item = template.shift()) {
19
+ if ("type" in item) {
20
+ // It's a template element
21
+ cssText += item.value.cooked;
22
+ continue;
23
+ }
24
+ // It's an expression
25
+ const { ex } = item;
26
+ const { end, start } = ex.loc;
27
+ const beforeLength = cssText.length;
28
+ // The location will be end of the current string to start of next string
29
+ const next = template[0];
30
+ const loc = {
31
+ start,
32
+ end: next ? {
33
+ line: next.loc.start.line,
34
+ column: next.loc.start.column
35
+ } : {
36
+ line: end.line,
37
+ column: end.column + 1
38
+ }
39
+ };
40
+ const value = "value" in item ? item.value : valueCache.get(item.ex.name);
41
+ // Is it props based interpolation?
42
+ if (item.kind === ValueType.FUNCTION || typeof value === "function") {
43
+ // Check if previous expression was a CSS variable that we replaced
44
+ // If it has a unit after it, we need to move the unit into the interpolation
45
+ // e.g. `var(--size)px` should actually be `var(--size)`
46
+ // So we check if the current text starts with a unit, and add the unit to the previous interpolation
47
+ // Another approach would be `calc(var(--size) * 1px), but some browsers don't support all units
48
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=956573
49
+ const matches = next.value.cooked?.match(unitRegex);
50
+ try {
51
+ if (matches) {
52
+ template.shift();
53
+ const [unit] = matches;
54
+ const varId = tagProcessor.addInterpolation(item.ex, cssText, item.source, unit);
55
+ cssText += getVariableName(varId, variableNameConfig);
56
+ cssText += next.value.cooked?.substring(unit?.length ?? 0) ?? "";
57
+ } else {
58
+ const varId = tagProcessor.addInterpolation(item.ex, cssText, item.source);
59
+ cssText += getVariableName(varId, variableNameConfig);
60
+ }
61
+ } catch (e) {
62
+ if (e instanceof Error) {
63
+ throw item.buildCodeFrameError(e.message);
64
+ }
65
+ throw e;
66
+ }
67
+ } else {
68
+ throwIfInvalid(tagProcessor.isValidValue.bind(tagProcessor), value, item, item.source);
69
+ if (value !== undefined && typeof value !== "function") {
70
+ // Skip the blank string instead of throw ing an error
71
+ if (value === "") {
72
+ continue;
73
+ }
74
+ if (hasEvalMeta(value)) {
75
+ // If it's a React component wrapped in styled, get the class name
76
+ // Useful for interpolating components
77
+ cssText += `.${value.__wyw_meta.className}`;
78
+ } else if (isCSSable(value)) {
79
+ // If it's a plain object or an array, convert it to a CSS string
80
+ cssText += stripLines(loc, toCSS(value));
81
+ } else {
82
+ // For anything else, assume it'll be stringified
83
+ cssText += stripLines(loc, value);
84
+ }
85
+ sourceMapReplacements.push({
86
+ original: loc,
87
+ length: cssText.length - beforeLength
88
+ });
89
+ }
90
+ }
91
+ }
92
+ const rules = tagProcessor.extractRules(valueCache, cssText, tagProcessor.location);
93
+ // tagProcessor.doRuntimeReplacement(classes);
94
+ if (!isReferenced && !cssText.includes(":global")) {
95
+ return null;
96
+ }
97
+ // eslint-disable-next-line no-param-reassign
98
+ return [rules, sourceMapReplacements];
119
99
  }
120
- //# sourceMappingURL=templateProcessor.js.map
100
+ //# sourceMappingURL=templateProcessor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"templateProcessor.js","names":["hasEvalMeta","ValueType","getVariableName","stripLines","throwIfInvalid","toCSS","isCSSable","units","unitRegex","RegExp","join","templateProcessor","tagProcessor","template","valueCache","variableNameConfig","sourceMapReplacements","isReferenced","cssText","item","shift","value","cooked","ex","end","start","loc","beforeLength","length","next","line","column","get","name","kind","FUNCTION","matches","match","unit","varId","addInterpolation","source","substring","e","Error","buildCodeFrameError","message","isValidValue","bind","undefined","__wyw_meta","className","push","original","rules","extractRules","location","includes"],"sources":["../../src/utils/templateProcessor.ts"],"sourcesContent":["/* eslint-disable no-continue */\n/**\n * This file handles transforming template literals to class names or styled components and generates CSS content.\n * It uses CSS code from template literals and evaluated values of lazy dependencies stored in ValueCache.\n */\n\nimport type { TemplateElement } from '@babel/types';\n\nimport type { ExpressionValue, Replacements } from '@wyw-in-js/shared';\nimport { hasEvalMeta, ValueType } from '@wyw-in-js/shared';\n\nimport type { TaggedTemplateProcessor } from '../TaggedTemplateProcessor';\nimport type { ValueCache, Rules } from '../types';\n\nimport { getVariableName } from './getVariableName';\nimport stripLines from './stripLines';\nimport throwIfInvalid from './throwIfInvalid';\nimport toCSS, { isCSSable } from './toCSS';\nimport type { IOptions } from './types';\nimport { units } from './units';\n\n// Match any valid CSS unit not immediately followed by an alphanumeric character or underscore.\nconst unitRegex = new RegExp(`^(?:${units.join('|')})(?![a-zA-Z0-9_])`);\n\nexport default function templateProcessor(\n tagProcessor: TaggedTemplateProcessor,\n [...template]: (TemplateElement | ExpressionValue)[],\n valueCache: ValueCache,\n variableNameConfig: IOptions['variableNameConfig'] | undefined\n): [rules: Rules, sourceMapReplacements: Replacements] | null {\n const sourceMapReplacements: Replacements = [];\n // Check if the variable is referenced anywhere for basic DCE\n // Only works when it's assigned to a variable\n const { isReferenced } = tagProcessor;\n\n // Serialize the tagged template literal to a string\n let cssText = '';\n\n let item: TemplateElement | ExpressionValue | undefined;\n // eslint-disable-next-line no-cond-assign\n while ((item = template.shift())) {\n if ('type' in item) {\n // It's a template element\n cssText += item.value.cooked;\n continue;\n }\n\n // It's an expression\n const { ex } = item;\n\n const { end, start } = ex.loc!;\n const beforeLength = cssText.length;\n\n // The location will be end of the current string to start of next string\n const next = template[0] as TemplateElement; // template[0] is the next template element\n const loc = {\n start,\n end: next\n ? { line: next.loc!.start.line, column: next.loc!.start.column }\n : { line: end.line, column: end.column + 1 },\n };\n\n const value = 'value' in item ? item.value : valueCache.get(item.ex.name);\n\n // Is it props based interpolation?\n if (item.kind === ValueType.FUNCTION || typeof value === 'function') {\n // Check if previous expression was a CSS variable that we replaced\n // If it has a unit after it, we need to move the unit into the interpolation\n // e.g. `var(--size)px` should actually be `var(--size)`\n // So we check if the current text starts with a unit, and add the unit to the previous interpolation\n // Another approach would be `calc(var(--size) * 1px), but some browsers don't support all units\n // https://bugzilla.mozilla.org/show_bug.cgi?id=956573\n const matches = next.value.cooked?.match(unitRegex);\n\n try {\n if (matches) {\n template.shift();\n const [unit] = matches;\n\n const varId = tagProcessor.addInterpolation(\n item.ex,\n cssText,\n item.source,\n unit\n );\n cssText += getVariableName(varId, variableNameConfig);\n\n cssText += next.value.cooked?.substring(unit?.length ?? 0) ?? '';\n } else {\n const varId = tagProcessor.addInterpolation(\n item.ex,\n cssText,\n item.source\n );\n cssText += getVariableName(varId, variableNameConfig);\n }\n } catch (e) {\n if (e instanceof Error) {\n throw item.buildCodeFrameError(e.message);\n }\n\n throw e;\n }\n } else {\n throwIfInvalid(\n tagProcessor.isValidValue.bind(tagProcessor),\n value,\n item,\n item.source\n );\n\n if (value !== undefined && typeof value !== 'function') {\n // Skip the blank string instead of throw ing an error\n if (value === '') {\n continue;\n }\n\n if (hasEvalMeta(value)) {\n // If it's a React component wrapped in styled, get the class name\n // Useful for interpolating components\n cssText += `.${value.__wyw_meta.className}`;\n } else if (isCSSable(value)) {\n // If it's a plain object or an array, convert it to a CSS string\n cssText += stripLines(loc, toCSS(value));\n } else {\n // For anything else, assume it'll be stringified\n cssText += stripLines(loc, value);\n }\n\n sourceMapReplacements.push({\n original: loc,\n length: cssText.length - beforeLength,\n });\n }\n }\n }\n\n const rules = tagProcessor.extractRules(\n valueCache,\n cssText,\n tagProcessor.location\n );\n\n // tagProcessor.doRuntimeReplacement(classes);\n if (!isReferenced && !cssText.includes(':global')) {\n return null;\n }\n\n // eslint-disable-next-line no-param-reassign\n return [rules, sourceMapReplacements];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAKA,SAASA,WAAW,EAAEC,SAAS,QAAQ,mBAAmB;AAK1D,SAASC,eAAe,QAAQ,mBAAmB;AACnD,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,cAAc,MAAM,kBAAkB;AAC7C,OAAOC,KAAK,IAAIC,SAAS,QAAQ,SAAS;AAE1C,SAASC,KAAK,QAAQ,SAAS;;AAE/B;AACA,MAAMC,SAAS,GAAG,IAAIC,MAAM,CAAC,OAAOF,KAAK,CAACG,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC;AAEvE,eAAe,SAASC,iBAAiBA,CACvCC,YAAqC,EACrC,CAAC,GAAGC,QAAQ,CAAwC,EACpDC,UAAsB,EACtBC,kBAA8D,EACF;EAC5D,MAAMC,qBAAmC,GAAG,EAAE;EAC9C;EACA;EACA,MAAM;IAAEC;EAAa,CAAC,GAAGL,YAAY;;EAErC;EACA,IAAIM,OAAO,GAAG,EAAE;EAEhB,IAAIC,IAAmD;EACvD;EACA,OAAQA,IAAI,GAAGN,QAAQ,CAACO,KAAK,CAAC,CAAC,EAAG;IAChC,IAAI,MAAM,IAAID,IAAI,EAAE;MAClB;MACAD,OAAO,IAAIC,IAAI,CAACE,KAAK,CAACC,MAAM;MAC5B;IACF;;IAEA;IACA,MAAM;MAAEC;IAAG,CAAC,GAAGJ,IAAI;IAEnB,MAAM;MAAEK,GAAG;MAAEC;IAAM,CAAC,GAAGF,EAAE,CAACG,GAAI;IAC9B,MAAMC,YAAY,GAAGT,OAAO,CAACU,MAAM;;IAEnC;IACA,MAAMC,IAAI,GAAGhB,QAAQ,CAAC,CAAC,CAAoB,CAAC,CAAC;IAC7C,MAAMa,GAAG,GAAG;MACVD,KAAK;MACLD,GAAG,EAAEK,IAAI,GACL;QAAEC,IAAI,EAAED,IAAI,CAACH,GAAG,C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mB;;YAEhD,GAAG;AACV,QAAI,aAAa,OAAO;AACtB,WAAM,KAAK,oBAAoB,EAAE,QAAQ;;AAG3C,UAAM;;SAEH;AACL,kBACE,aAAa,aAAa,KAAK,aAAa,EAC5C,OACA,MACA,KAAK,OACN;AAED,OAAI,UAAU,aAAa,OAAO,UAAU,YAAY;;AAEtD,QAAI,UAAU,IAAI;AAChB;;AAGF,QAAI,YAAY,MAAM,EAAE;;;AAGtB,gBAAW,IAAI,MAAM,WAAW;eACvB,UAAU,MAAM,EAAE;;AAE3B,gBAAW,WAAW,KAAK,MAAM,MAAM,CAAC;WACnC;;AAEL,gBAAW,WAAW,KAAK,MAAM;;AAGnC,0BAAsB,KAAK;KACzB,UAAU;KACV,QAAQ,QAAQ,SAAS;KAC1B,CAAC;;;;CAKR,MAAM,QAAQ,aAAa,aACzB,YACA,SACA,aAAa,SACd;;AAGD,KAAI,CAAC,gBAAgB,CAAC,QAAQ,SAAS,UAAU,EAAE;AACjD,SAAO;;;AAIT,QAAO,CAAC,OAAO,sBAAsB","names":[],"sources":["../../src/utils/templateProcessor.ts"],"version":3,"sourcesContent":["/* eslint-disable no-continue */\n/**\n * This file handles transforming template literals to class names or styled components and generates CSS content.\n * It uses CSS code from template literals and evaluated values of lazy dependencies stored in ValueCache.\n */\n\nimport type { ExpressionValue, Replacements } from '@wyw-in-js/shared';\nimport { hasEvalMeta, ValueType } from '@wyw-in-js/shared';\n\nimport type { TaggedTemplateProcessor } from '../TaggedTemplateProcessor';\nimport type { Expression, TemplateElement } from '../ast';\nimport type { ValueCache, Rules } from '../types';\n\nimport { getVariableName } from './getVariableName';\nimport stripLines from './stripLines';\nimport throwIfInvalid from './throwIfInvalid';\nimport toCSS, { isCSSable } from './toCSS';\nimport type { IOptions } from './types';\nimport { units } from './units';\n\n// Match any valid CSS unit not immediately followed by an alphanumeric character or underscore.\nconst unitRegex = new RegExp(`^(?:${units.join('|')})(?![a-zA-Z0-9_])`);\n\nexport default function templateProcessor(\n tagProcessor: TaggedTemplateProcessor,\n [...template]: (TemplateElement | ExpressionValue)[],\n valueCache: ValueCache,\n variableNameConfig: IOptions['variableNameConfig'] | undefined\n): [rules: Rules, sourceMapReplacements: Replacements] | null {\n const sourceMapReplacements: Replacements = [];\n // Check if the variable is referenced anywhere for basic DCE\n // Only works when it's assigned to a variable\n const { isReferenced } = tagProcessor;\n\n // Serialize the tagged template literal to a string\n let cssText = '';\n\n let item: TemplateElement | ExpressionValue | undefined;\n // eslint-disable-next-line no-cond-assign\n while ((item = template.shift())) {\n if ('type' in item) {\n // It's a template element\n cssText += item.value.cooked;\n continue;\n }\n\n // It's an expression\n const { ex } = item;\n\n const { end, start } = ex.loc!;\n const beforeLength = cssText.length;\n\n // The location will be end of the current string to start of next string\n const next = template[0] as TemplateElement; // template[0] is the next template element\n const loc = {\n start,\n end: next\n ? { line: next.loc!.start.line, column: next.loc!.start.column }\n : { line: end.line, column: end.column + 1 },\n };\n\n const value = 'value' in item ? item.value : valueCache.get(item.ex.name);\n\n // Is it props based interpolation?\n if (item.kind === ValueType.FUNCTION || typeof value === 'function') {\n // Check if previous expression was a CSS variable that we replaced\n // If it has a unit after it, we need to move the unit into the interpolation\n // e.g. `var(--size)px` should actually be `var(--size)`\n // So we check if the current text starts with a unit, and add the unit to the previous interpolation\n // Another approach would be `calc(var(--size) * 1px), but some browsers don't support all units\n // https://bugzilla.mozilla.org/show_bug.cgi?id=956573\n const matches = next.value.cooked?.match(unitRegex);\n\n try {\n if (matches) {\n template.shift();\n const [unit] = matches;\n\n const varId = tagProcessor.addInterpolation(\n item.ex as Expression,\n cssText,\n item.source,\n unit\n );\n cssText += getVariableName(varId, variableNameConfig);\n\n cssText += next.value.cooked?.substring(unit?.length ?? 0) ?? '';\n } else {\n const varId = tagProcessor.addInterpolation(\n item.ex as Expression,\n cssText,\n item.source\n );\n cssText += getVariableName(varId, variableNameConfig);\n }\n } catch (e) {\n if (e instanceof Error) {\n throw item.buildCodeFrameError(e.message);\n }\n\n throw e;\n }\n } else {\n throwIfInvalid(\n tagProcessor.isValidValue.bind(tagProcessor),\n value,\n item,\n item.source\n );\n\n if (value !== undefined && typeof value !== 'function') {\n // Skip the blank string instead of throw ing an error\n if (value === '') {\n continue;\n }\n\n if (hasEvalMeta(value)) {\n // If it's a React component wrapped in styled, get the class name\n // Useful for interpolating components\n cssText += `.${value.__wyw_meta.className}`;\n } else if (isCSSable(value)) {\n // If it's a plain object or an array, convert it to a CSS string\n cssText += stripLines(loc, toCSS(value));\n } else {\n // For anything else, assume it'll be stringified\n cssText += stripLines(loc, value);\n }\n\n sourceMapReplacements.push({\n original: loc,\n length: cssText.length - beforeLength,\n });\n }\n }\n }\n\n const rules = tagProcessor.extractRules(\n valueCache,\n cssText,\n tagProcessor.location\n );\n\n // tagProcessor.doRuntimeReplacement(classes);\n if (!isReferenced && !cssText.includes(':global')) {\n return null;\n }\n\n // eslint-disable-next-line no-param-reassign\n return [rules, sourceMapReplacements];\n}\n"],"file":"templateProcessor.js"}
@@ -1,10 +1,9 @@
1
- const isLikeError = value => typeof value === 'object' && value !== null && 'stack' in value && 'message' in value;
2
-
1
+ const isLikeError = (value) => typeof value === "object" && value !== null && "stack" in value && "message" in value;
3
2
  // Throw if we can't handle the interpolated value
4
3
  function throwIfInvalid(checker, value, ex, source) {
5
- // We can't use instanceof here so let's use duck typing
6
- if (isLikeError(value) && value.stack && value.message) {
7
- throw ex.buildCodeFrameError(`An error occurred when evaluating the expression:
4
+ // We can't use instanceof here so let's use duck typing
5
+ if (isLikeError(value) && value.stack && value.message) {
6
+ throw ex.buildCodeFrameError(`An error occurred when evaluating the expression:
8
7
 
9
8
  > ${value.message}.
10
9
 
@@ -18,12 +17,12 @@ function throwIfInvalid(checker, value, ex, source) {
18
17
  because it cannot be statically determined in which context you use them.
19
18
  That's why some variables may be not defined during evaluation.
20
19
  `);
21
- }
22
- if (checker(value)) {
23
- return;
24
- }
25
- const stringified = typeof value === 'object' ? JSON.stringify(value) : String(value);
26
- throw ex.buildCodeFrameError(`The expression evaluated to '${stringified}', which is probably a mistake. If you want it to be inserted into CSS, explicitly cast or transform the value to a string, e.g. - 'String(${source})'.`);
20
+ }
21
+ if (checker(value)) {
22
+ return;
23
+ }
24
+ const stringified = typeof value === "object" ? JSON.stringify(value) : String(value);
25
+ throw ex.buildCodeFrameError(`The expression evaluated to '${stringified}', which is probably a mistake. If you want it to be inserted into CSS, explicitly cast or transform the value to a string, e.g. - 'String(${source})'.`);
27
26
  }
28
27
  export default throwIfInvalid;
29
- //# sourceMappingURL=throwIfInvalid.js.map
28
+ //# sourceMappingURL=throwIfInvalid.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"throwIfInvalid.js","names":["isLikeError","value","throwIfInvalid","checker","ex","source","stack","message","buildCodeFrameError","stringified","JSON","stringify","String"],"sources":["../../src/utils/throwIfInvalid.ts"],"sourcesContent":["import type { BuildCodeFrameErrorFn } from '@wyw-in-js/shared';\n\nconst isLikeError = (value: unknown): value is Error =>\n typeof value === 'object' &&\n value !== null &&\n 'stack' in value &&\n 'message' in value;\n\n// Throw if we can't handle the interpolated value\nfunction throwIfInvalid<T>(\n checker: (value: unknown) => value is T,\n value: Error | unknown,\n ex: { buildCodeFrameError: BuildCodeFrameErrorFn },\n source: string\n): asserts value is T {\n // We can't use instanceof here so let's use duck typing\n if (isLikeError(value) && value.stack && value.message) {\n throw ex.buildCodeFrameError(\n `An error occurred when evaluating the expression:\n\n > ${value.message}.\n\n Make sure you are not using a browser or Node specific API and all the variables are available in static context.\n Linaria have to extract pieces of your code to resolve the interpolated values.\n Defining styled component or class will not work inside:\n - function,\n - class,\n - method,\n - loop,\n because it cannot be statically determined in which context you use them.\n That's why some variables may be not defined during evaluation.\n `\n );\n }\n\n if (checker(value)) {\n return;\n }\n\n const stringified =\n typeof value === 'object' ? JSON.stringify(value) : String(value);\n\n throw ex.buildCodeFrameError(\n `The expression evaluated to '${stringified}', which is probably a mistake. If you want it to be inserted into CSS, explicitly cast or transform the value to a string, e.g. - 'String(${source})'.`\n );\n}\n\nexport default throwIfInvalid;\n"],"mappings":"AAEA,MAAMA,WAAW,GAAIC,KAAc,IACjC,OAAOA,KAAK,KAAK,QAAQ,IACzBA,KAAK,KAAK,IAAI,IACd,OAAO,IAAIA,KAAK,IAChB,SAAS,IAAIA,KAAK;;AAEpB;AACA,SAASC,cAAcA,CACrBC,OAAuC,EACvCF,KAAsB,EACtBG,EAAkD,EAClDC,MAAc,EACM;EACpB;EACA,IAAIL,WAAW,CAACC,KAAK,CAAC,IAAIA,KAAK,CAACK,KAAK,IAAIL,KAAK,CAACM,OAAO,EAAE;IACtD,MAAMH,EAAE,CAACI,mBAAmB,CAC1B;AACN;AACA,MAAMP,KAAK,CAACM,OAAO;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OACI,CAAC;EACH;EAEA,IAAIJ,OAAO,CAACF,KAAK,CAAC,EAAE;IAClB;EACF;EAEA,MAAMQ,WAAW,GACf,OAAOR,KAAK,KAAK,QAAQ,GAAGS,IAAI,CAACC,SAAS,CAACV,KAAK,CAAC,GAAGW,MAAM,CAACX,KAAK,CAAC;EAEnE,MAAMG,EAAE,CAACI,mBAAmB,CAC1B,gCAAgCC,WAAW,8IAA8IJ,MAAM,KACjM,CAAC;AACH;AAEA,eAAeH,cAAc","ignoreList":[]}
1
+ {"mappings":"AAEA,MAAM,eAAe,UACnB,OAAO,UAAU,YACjB,UAAU,QACV,WAAW,SACX,aAAa;;AAGf,SAAS,eACP,SACA,OACA,IACA,QACoB;;AAEpB,KAAI,YAAY,MAAM,IAAI,MAAM,SAAS,MAAM,SAAS;AACtD,QAAM,GAAG,oBACP;;MAEA,MAAM,QAAQ;;;;;;;;;;;QAYf;;AAGH,KAAI,QAAQ,MAAM,EAAE;AAClB;;CAGF,MAAM,cACJ,OAAO,UAAU,WAAW,KAAK,UAAU,MAAM,GAAG,OAAO,MAAM;AAEnE,OAAM,GAAG,oBACP,gCAAgC,YAAY,6IAA6I,OAAO,KACjM;;AAGH,eAAe","names":[],"sources":["../../src/utils/throwIfInvalid.ts"],"version":3,"sourcesContent":["import type { BuildCodeFrameErrorFn } from '@wyw-in-js/shared';\n\nconst isLikeError = (value: unknown): value is Error =>\n typeof value === 'object' &&\n value !== null &&\n 'stack' in value &&\n 'message' in value;\n\n// Throw if we can't handle the interpolated value\nfunction throwIfInvalid<T>(\n checker: (value: unknown) => value is T,\n value: Error | unknown,\n ex: { buildCodeFrameError: BuildCodeFrameErrorFn },\n source: string\n): asserts value is T {\n // We can't use instanceof here so let's use duck typing\n if (isLikeError(value) && value.stack && value.message) {\n throw ex.buildCodeFrameError(\n `An error occurred when evaluating the expression:\n\n > ${value.message}.\n\n Make sure you are not using a browser or Node specific API and all the variables are available in static context.\n Linaria have to extract pieces of your code to resolve the interpolated values.\n Defining styled component or class will not work inside:\n - function,\n - class,\n - method,\n - loop,\n because it cannot be statically determined in which context you use them.\n That's why some variables may be not defined during evaluation.\n `\n );\n }\n\n if (checker(value)) {\n return;\n }\n\n const stringified =\n typeof value === 'object' ? JSON.stringify(value) : String(value);\n\n throw ex.buildCodeFrameError(\n `The expression evaluated to '${stringified}', which is probably a mistake. If you want it to be inserted into CSS, explicitly cast or transform the value to a string, e.g. - 'String(${source})'.`\n );\n}\n\nexport default throwIfInvalid;\n"],"file":"throwIfInvalid.js"}
@@ -1,50 +1,41 @@
1
- import { isBoxedPrimitive } from '@wyw-in-js/shared';
2
- import { unitless } from './units';
3
- const isCSSPropertyValue = o => {
4
- return isBoxedPrimitive(o) || typeof o === 'string' || typeof o === 'number' && Number.isFinite(o);
1
+ import { isBoxedPrimitive } from "@wyw-in-js/shared";
2
+ import { unitless } from "./units.js";
3
+ const isCSSPropertyValue = (o) => {
4
+ return isBoxedPrimitive(o) || typeof o === "string" || typeof o === "number" && Number.isFinite(o);
5
5
  };
6
- export const isCSSable = o => {
7
- if (isCSSPropertyValue(o)) {
8
- return true;
9
- }
10
- if (Array.isArray(o)) {
11
- return o.every(isCSSable);
12
- }
13
- if (typeof o === 'object') {
14
- return o !== null && Object.values(o).every(isCSSable);
15
- }
16
- return false;
6
+ export const isCSSable = (o) => {
7
+ if (isCSSPropertyValue(o)) {
8
+ return true;
9
+ }
10
+ if (Array.isArray(o)) {
11
+ return o.every(isCSSable);
12
+ }
13
+ if (typeof o === "object") {
14
+ return o !== null && Object.values(o).every(isCSSable);
15
+ }
16
+ return false;
17
17
  };
18
- const hyphenate = s => {
19
- if (s.startsWith('--')) {
20
- // It's a custom property which is already well formatted.
21
- return s;
22
- }
23
- return s
24
- // Hyphenate CSS property names from camelCase version from JS string
25
- .replace(/([A-Z])/g, (match, p1) => `-${p1.toLowerCase()}`)
26
- // Special case for `-ms` because in JS it starts with `ms` unlike `Webkit`
27
- .replace(/^ms-/, '-ms-');
18
+ const hyphenate = (s) => {
19
+ if (s.startsWith("--")) {
20
+ // It's a custom property which is already well formatted.
21
+ return s;
22
+ }
23
+ return s.replace(/([A-Z])/g, (match, p1) => `-${p1.toLowerCase()}`).replace(/^ms-/, "-ms-");
28
24
  };
29
-
30
25
  // Some tools such as polished.js output JS objects
31
26
  // To support them transparently, we convert JS objects to CSS strings
32
27
  export default function toCSS(o) {
33
- if (Array.isArray(o)) {
34
- return o.map(toCSS).join('\n');
35
- }
36
- if (isCSSPropertyValue(o)) {
37
- return o.valueOf().toString();
38
- }
39
- return Object.entries(o).filter(([, value]) =>
40
- // Ignore all falsy values except numbers
41
- typeof value === 'number' || value).map(([key, value]) => {
42
- if (!isCSSPropertyValue(value)) {
43
- return `${key} { ${toCSS(value)} }`;
44
- }
45
- return `${hyphenate(key)}: ${typeof value === 'number' && value !== 0 &&
46
- // Strip vendor prefixes when checking if the value is unitless
47
- !(key.replace(/^(Webkit|Moz|O|ms)([A-Z])(.+)$/, (match, p1, p2, p3) => `${p2.toLowerCase()}${p3}`) in unitless) ? `${value}px` : value};`;
48
- }).join(' ');
28
+ if (Array.isArray(o)) {
29
+ return o.map(toCSS).join("\n");
30
+ }
31
+ if (isCSSPropertyValue(o)) {
32
+ return o.valueOf().toString();
33
+ }
34
+ return Object.entries(o).filter(([, value]) => typeof value === "number" || value).map(([key, value]) => {
35
+ if (!isCSSPropertyValue(value)) {
36
+ return `${key} { ${toCSS(value)} }`;
37
+ }
38
+ return `${hyphenate(key)}: ${typeof value === "number" && value !== 0 && !(key.replace(/^(Webkit|Moz|O|ms)([A-Z])(.+)$/, (match, p1, p2, p3) => `${p2.toLowerCase()}${p3}`) in unitless) ? `${value}px` : value};`;
39
+ }).join(" ");
49
40
  }
50
- //# sourceMappingURL=toCSS.js.map
41
+ //# sourceMappingURL=toCSS.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"toCSS.js","names":["isBoxedPrimitive","unitless","isCSSPropertyValue","o","Number","isFinite","isCSSable","Array","isArray","every","Object","values","hyphenate","s","startsWith","replace","match","p1","toLowerCase","toCSS","map","join","valueOf","toString","entries","filter","value","key","p2","p3"],"sources":["../../src/utils/toCSS.ts"],"sourcesContent":["import { isBoxedPrimitive } from '@wyw-in-js/shared';\n\nimport type { CSSPropertyValue, CSSable } from '../types';\n\nimport { unitless } from './units';\n\nconst isCSSPropertyValue = (o: unknown): o is CSSPropertyValue => {\n return (\n isBoxedPrimitive(o) ||\n typeof o === 'string' ||\n (typeof o === 'number' && Number.isFinite(o))\n );\n};\n\nexport const isCSSable = (o: unknown): o is CSSable => {\n if (isCSSPropertyValue(o)) {\n return true;\n }\n\n if (Array.isArray(o)) {\n return o.every(isCSSable);\n }\n\n if (typeof o === 'object') {\n return o !== null && Object.values(o).every(isCSSable);\n }\n\n return false;\n};\n\nconst hyphenate = (s: string) => {\n if (s.startsWith('--')) {\n // It's a custom property which is already well formatted.\n return s;\n }\n return (\n s\n // Hyphenate CSS property names from camelCase version from JS string\n .replace(/([A-Z])/g, (match, p1) => `-${p1.toLowerCase()}`)\n // Special case for `-ms` because in JS it starts with `ms` unlike `Webkit`\n .replace(/^ms-/, '-ms-')\n );\n};\n\n// Some tools such as polished.js output JS objects\n// To support them transparently, we convert JS objects to CSS strings\nexport default function toCSS(o: CSSable): string {\n if (Array.isArray(o)) {\n return o.map(toCSS).join('\\n');\n }\n\n if (isCSSPropertyValue(o)) {\n return o.valueOf().toString();\n }\n\n return Object.entries(o)\n .filter(\n ([, value]) =>\n // Ignore all falsy values except numbers\n typeof value === 'number' || value\n )\n .map(([key, value]) => {\n if (!isCSSPropertyValue(value)) {\n return `${key} { ${toCSS(value)} }`;\n }\n\n return `${hyphenate(key)}: ${\n typeof value === 'number' &&\n value !== 0 &&\n // Strip vendor prefixes when checking if the value is unitless\n !(\n key.replace(\n /^(Webkit|Moz|O|ms)([A-Z])(.+)$/,\n (match, p1, p2, p3) => `${p2.toLowerCase()}${p3}`\n ) in unitless\n )\n ? `${value}px`\n : value\n };`;\n })\n .join(' ');\n}\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,mBAAmB;AAIpD,SAASC,QAAQ,QAAQ,SAAS;AAElC,MAAMC,kBAAkB,GAAIC,CAAU,IAA4B;EAChE,OACEH,gBAAgB,CAACG,CAAC,CAAC,IACnB,OAAOA,CAAC,KAAK,QAAQ,IACpB,OAAOA,CAAC,KAAK,QAAQ,IAAIC,MAAM,CAACC,QAAQ,CAACF,CAAC,CAAE;AAEjD,CAAC;AAED,OAAO,MAAMG,SAAS,GAAIH,CAAU,IAAmB;EACrD,IAAID,kBAAkB,CAACC,CAAC,CAAC,EAAE;IACzB,OAAO,IAAI;EACb;EAEA,IAAII,KAAK,CAACC,OAAO,CAACL,CAAC,CAAC,EAAE;IACpB,OAAOA,CAAC,CAACM,KAAK,CAACH,SAAS,CAAC;EAC3B;EAEA,IAAI,OAAOH,CAAC,KAAK,QAAQ,EAAE;IACzB,OAAOA,CAAC,KAAK,IAAI,IAAIO,MAAM,CAACC,MAAM,CAACR,CAAC,CAAC,CAACM,KAAK,CAACH,SAAS,CAAC;EACxD;EAEA,OAAO,KAAK;AACd,CAAC;AAED,MAAMM,SAAS,GAAIC,CAAS,IA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G,KAC9C,IAAI,YAEH,GAAG,MAAM,MACT,MACL;GACD,CACD,KAAK,IAAI","names":[],"sources":["../../src/utils/toCSS.ts"],"version":3,"sourcesContent":["import { isBoxedPrimitive } from '@wyw-in-js/shared';\n\nimport type { CSSPropertyValue, CSSable } from '../types';\n\nimport { unitless } from './units';\n\nconst isCSSPropertyValue = (o: unknown): o is CSSPropertyValue => {\n return (\n isBoxedPrimitive(o) ||\n typeof o === 'string' ||\n (typeof o === 'number' && Number.isFinite(o))\n );\n};\n\nexport const isCSSable = (o: unknown): o is CSSable => {\n if (isCSSPropertyValue(o)) {\n return true;\n }\n\n if (Array.isArray(o)) {\n return o.every(isCSSable);\n }\n\n if (typeof o === 'object') {\n return o !== null && Object.values(o).every(isCSSable);\n }\n\n return false;\n};\n\nconst hyphenate = (s: string) => {\n if (s.startsWith('--')) {\n // It's a custom property which is already well formatted.\n return s;\n }\n return (\n s\n // Hyphenate CSS property names from camelCase version from JS string\n .replace(/([A-Z])/g, (match, p1) => `-${p1.toLowerCase()}`)\n // Special case for `-ms` because in JS it starts with `ms` unlike `Webkit`\n .replace(/^ms-/, '-ms-')\n );\n};\n\n// Some tools such as polished.js output JS objects\n// To support them transparently, we convert JS objects to CSS strings\nexport default function toCSS(o: CSSable): string {\n if (Array.isArray(o)) {\n return o.map(toCSS).join('\\n');\n }\n\n if (isCSSPropertyValue(o)) {\n return o.valueOf().toString();\n }\n\n return Object.entries(o)\n .filter(\n ([, value]) =>\n // Ignore all falsy values except numbers\n typeof value === 'number' || value\n )\n .map(([key, value]) => {\n if (!isCSSPropertyValue(value)) {\n return `${key} { ${toCSS(value)} }`;\n }\n\n return `${hyphenate(key)}: ${\n typeof value === 'number' &&\n value !== 0 &&\n // Strip vendor prefixes when checking if the value is unitless\n !(\n key.replace(\n /^(Webkit|Moz|O|ms)([A-Z])(.+)$/,\n (match, p1, p2, p3) => `${p2.toLowerCase()}${p3}`\n ) in unitless\n )\n ? `${value}px`\n : value\n };`;\n })\n .join(' ');\n}\n"],"file":"toCSS.js"}
@@ -1,4 +1,4 @@
1
1
  export function toValidCSSIdentifier(s) {
2
- return s.replace(/[^-_a-z0-9\u00A0-\uFFFF]/gi, '_').replace(/^\d/, '_');
2
+ return s.replace(/[^-_a-z0-9\u00A0-\uFFFF]/gi, "_").replace(/^\d/, "_");
3
3
  }
4
- //# sourceMappingURL=toValidCSSIdentifier.js.map
4
+ //# sourceMappingURL=toValidCSSIdentifier.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"toValidCSSIdentifier.js","names":["toValidCSSIdentifier","s","replace"],"sources":["../../src/utils/toValidCSSIdentifier.ts"],"sourcesContent":["export function toValidCSSIdentifier(s: string) {\n return s.replace(/[^-_a-z0-9\\u00A0-\\uFFFF]/gi, '_').replace(/^\\d/, '_');\n}\n"],"mappings":"AAAA,OAAO,SAASA,oBAAoBA,CAACC,CAAS,EAAE;EAC9C,OAAOA,CAAC,CAACC,OAAO,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAACA,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;AACzE","ignoreList":[]}
1
+ {"mappings":"AAAA,OAAO,SAAS,qBAAqB,GAAW;AAC9C,QAAO,EAAE,QAAQ,8BAA8B,IAAI,CAAC,QAAQ,OAAO,IAAI","names":[],"sources":["../../src/utils/toValidCSSIdentifier.ts"],"version":3,"sourcesContent":["export function toValidCSSIdentifier(s: string) {\n return s.replace(/[^-_a-z0-9\\u00A0-\\uFFFF]/gi, '_').replace(/^\\d/, '_');\n}\n"],"file":"toValidCSSIdentifier.js"}
@@ -1,2 +1,2 @@
1
1
  export {};
2
- //# sourceMappingURL=types.js.map
2
+ //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/utils/types.ts"],"sourcesContent":["import type { TransformOptions } from '@babel/core';\n\nimport type { ClassNameFn, VariableNameFn } from '@wyw-in-js/shared';\n\nexport interface IOptions {\n classNameSlug?: string | ClassNameFn;\n displayName: boolean;\n extensions?: string[];\n variableNameConfig?: 'var' | 'dashes' | 'raw';\n variableNameSlug?: string | VariableNameFn;\n}\n\nexport type IFileContext = Pick<TransformOptions, 'root' | 'filename'>;\n"],"mappings":"","ignoreList":[]}
1
+ {"mappings":"","names":[],"sources":["../../src/utils/types.ts"],"version":3,"sourcesContent":["import type { ClassNameFn, VariableNameFn } from '@wyw-in-js/shared';\n\nexport interface IOptions {\n classNameSlug?: string | ClassNameFn;\n displayName: boolean;\n extensions?: string[];\n variableNameConfig?: 'var' | 'dashes' | 'raw';\n variableNameSlug?: string | VariableNameFn;\n}\n\nexport type IFileContext = {\n filename?: string | null;\n root?: string | null;\n};\n"],"file":"types.js"}
@@ -1,65 +1,83 @@
1
1
  // https://www.w3.org/TR/css-values-4/
2
2
  export const units = [
3
- // font relative lengths
4
- 'em', 'ex', 'cap', 'ch', 'ic', 'rem', 'lh', 'rlh',
5
- // viewport percentage lengths
6
- 'vw', 'vh', 'vi', 'vb', 'vmin', 'vmax',
7
- // absolute lengths
8
- 'cm', 'mm', 'Q', 'in', 'pc', 'pt', 'px',
9
- // angle units
10
- 'deg', 'grad', 'rad', 'turn',
11
- // duration units
12
- 's', 'ms',
13
- // frequency units
14
- 'Hz', 'kHz',
15
- // resolution units
16
- 'dpi', 'dpcm', 'dppx', 'x',
17
- // https://www.w3.org/TR/css-grid-1/#fr-unit
18
- 'fr',
19
- // percentages
20
- '%'];
3
+ "em",
4
+ "ex",
5
+ "cap",
6
+ "ch",
7
+ "ic",
8
+ "rem",
9
+ "lh",
10
+ "rlh",
11
+ "vw",
12
+ "vh",
13
+ "vi",
14
+ "vb",
15
+ "vmin",
16
+ "vmax",
17
+ "cm",
18
+ "mm",
19
+ "Q",
20
+ "in",
21
+ "pc",
22
+ "pt",
23
+ "px",
24
+ "deg",
25
+ "grad",
26
+ "rad",
27
+ "turn",
28
+ "s",
29
+ "ms",
30
+ "Hz",
31
+ "kHz",
32
+ "dpi",
33
+ "dpcm",
34
+ "dppx",
35
+ "x",
36
+ "fr",
37
+ "%"
38
+ ];
21
39
  export const unitless = {
22
- animationIterationCount: true,
23
- borderImageOutset: true,
24
- borderImageSlice: true,
25
- borderImageWidth: true,
26
- boxFlex: true,
27
- boxFlexGroup: true,
28
- boxOrdinalGroup: true,
29
- columnCount: true,
30
- columns: true,
31
- flex: true,
32
- flexGrow: true,
33
- flexPositive: true,
34
- flexShrink: true,
35
- flexNegative: true,
36
- flexOrder: true,
37
- gridRow: true,
38
- gridRowEnd: true,
39
- gridRowSpan: true,
40
- gridRowStart: true,
41
- gridColumn: true,
42
- gridColumnEnd: true,
43
- gridColumnSpan: true,
44
- gridColumnStart: true,
45
- fontWeight: true,
46
- lineClamp: true,
47
- lineHeight: true,
48
- opacity: true,
49
- order: true,
50
- orphans: true,
51
- tabSize: true,
52
- widows: true,
53
- zIndex: true,
54
- zoom: true,
55
- // SVG-related properties
56
- fillOpacity: true,
57
- floodOpacity: true,
58
- stopOpacity: true,
59
- strokeDasharray: true,
60
- strokeDashoffset: true,
61
- strokeMiterlimit: true,
62
- strokeOpacity: true,
63
- strokeWidth: true
40
+ animationIterationCount: true,
41
+ borderImageOutset: true,
42
+ borderImageSlice: true,
43
+ borderImageWidth: true,
44
+ boxFlex: true,
45
+ boxFlexGroup: true,
46
+ boxOrdinalGroup: true,
47
+ columnCount: true,
48
+ columns: true,
49
+ flex: true,
50
+ flexGrow: true,
51
+ flexPositive: true,
52
+ flexShrink: true,
53
+ flexNegative: true,
54
+ flexOrder: true,
55
+ gridRow: true,
56
+ gridRowEnd: true,
57
+ gridRowSpan: true,
58
+ gridRowStart: true,
59
+ gridColumn: true,
60
+ gridColumnEnd: true,
61
+ gridColumnSpan: true,
62
+ gridColumnStart: true,
63
+ fontWeight: true,
64
+ lineClamp: true,
65
+ lineHeight: true,
66
+ opacity: true,
67
+ order: true,
68
+ orphans: true,
69
+ tabSize: true,
70
+ widows: true,
71
+ zIndex: true,
72
+ zoom: true,
73
+ // SVG-related properties
74
+ fillOpacity: true,
75
+ floodOpacity: true,
76
+ stopOpacity: true,
77
+ strokeDasharray: true,
78
+ strokeDashoffset: true,
79
+ strokeMiterlimit: true,
80
+ strokeOpacity: true,
81
+ strokeWidth: true
64
82
  };
65
- //# sourceMappingURL=units.js.map
83
+ //# sourceMappingURL=units.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"units.js","names":["units","unitless","animationIterationCount","borderImageOutset","borderImageSlice","borderImageWidth","boxFlex","boxFlexGroup","boxOrdinalGroup","columnCount","columns","flex","flexGrow","flexPositive","flexShrink","flexNegative","flexOrder","gridRow","gridRowEnd","gridRowSpan","gridRowStart","gridColumn","gridColumnEnd","gridColumnSpan","gridColumnStart","fontWeight","lineClamp","lineHeight","opacity","order","orphans","tabSize","widows","zIndex","zoom","fillOpacity","floodOpacity","stopOpacity","strokeDasharray","strokeDashoffset","strokeMiterlimit","strokeOpacity","strokeWidth"],"sources":["../../src/utils/units.ts"],"sourcesContent":["// https://www.w3.org/TR/css-values-4/\nexport const units = [\n // font relative lengths\n 'em',\n 'ex',\n 'cap',\n 'ch',\n 'ic',\n 'rem',\n 'lh',\n 'rlh',\n\n // viewport percentage lengths\n 'vw',\n 'vh',\n 'vi',\n 'vb',\n 'vmin',\n 'vmax',\n\n // absolute lengths\n 'cm',\n 'mm',\n 'Q',\n 'in',\n 'pc',\n 'pt',\n 'px',\n\n // angle units\n 'deg',\n 'grad',\n 'rad',\n 'turn',\n\n // duration units\n 's',\n 'ms',\n\n // frequency units\n 'Hz',\n 'kHz',\n\n // resolution units\n 'dpi',\n 'dpcm',\n 'dppx',\n 'x',\n\n // https://www.w3.org/TR/css-grid-1/#fr-unit\n 'fr',\n\n // percentages\n '%',\n];\n\nexport const unitless = {\n animationIterationCount: true,\n borderImageOutset: true,\n borderImageSlice: true,\n borderImageWidth: true,\n boxFlex: true,\n boxFlexGroup: true,\n boxOrdinalGroup: true,\n columnCount: true,\n columns: true,\n flex: true,\n flexGrow: true,\n flexPositive: true,\n flexShrink: true,\n flexNegative: true,\n flexOrder: true,\n gridRow: true,\n gridRowEnd: true,\n gridRowSpan: true,\n gridRowStart: true,\n gridColumn: true,\n gridColumnEnd: true,\n gridColumnSpan: true,\n gridColumnStart: true,\n fontWeight: true,\n lineClamp: true,\n lineHeight: true,\n opacity: true,\n order: true,\n orphans: true,\n tabSize: true,\n widows: true,\n zIndex: true,\n zoom: true,\n\n // SVG-related properties\n fillOpacity: true,\n floodOpacity: true,\n stopOpacity: true,\n strokeDasharray: true,\n strokeDashoffset: true,\n strokeMiterlimit: true,\n strokeOpacity: true,\n strokeWidth: true,\n};\n"],"mappings":"AAAA;AACA,OAAO,MAAMA,KAAK,GAAG;AACnB;AACA,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,KAAK;AAEL;AACA,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,MAAM;AAEN;AACA,IAAI,EACJ,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI;AAEJ;AACA,KAAK,EACL,MAAM,EACN,KAAK,EACL,MAAM;AAEN;AACA,GAAG,EACH,IAAI;AAEJ;AACA,IAAI,EACJ,KAAK;AAEL;AACA,KAAK,EACL,MAAM,EACN,MAAM,EACN,GAAG;AAEH;AACA,IAAI;AAEJ;AACA,GAAG,CACJ;AAED,OAAO,MAAMC,QAAQ,GAAG;EACtBC,uBAAuB,EAAE,IAAI;EAC7BC,iBAAiB,EAAE,IAAI;EACvBC,gBAAgB,EAAE,IAAI;EACtBC,gBAAgB,EAAE,IAAI;EACtBC,OAAO,EAAE,IAAI;EACbC,YAAY,EAAE,IAAI;EAClBC,eAAe,EAAE,IAAI;EACrBC,WAAW,EAAE,IAAI;EACjBC,OAAO,EAAE,IAAI;EACbC,IAAI,EAAE,IAAI;EACVC,QAAQ,EAAE,IAAI;EACdC,YAAY,EAAE,IAAI;EAClBC,UAAU,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ACf,gBAAgB;CAChB,iBAAiB;CACjB,YAAY;CACZ,WAAW;CACX,YAAY;CACZ,SAAS;CACT,OAAO;CACP,SAAS;CACT,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,MAAM;;CAGN,aAAa;CACb,cAAc;CACd,aAAa;CACb,iBAAiB;CACjB,kBAAkB;CAClB,kBAAkB;CAClB,eAAe;CACf,aAAa;CACd","names":[],"sources":["../../src/utils/units.ts"],"version":3,"sourcesContent":["// https://www.w3.org/TR/css-values-4/\nexport const units = [\n // font relative lengths\n 'em',\n 'ex',\n 'cap',\n 'ch',\n 'ic',\n 'rem',\n 'lh',\n 'rlh',\n\n // viewport percentage lengths\n 'vw',\n 'vh',\n 'vi',\n 'vb',\n 'vmin',\n 'vmax',\n\n // absolute lengths\n 'cm',\n 'mm',\n 'Q',\n 'in',\n 'pc',\n 'pt',\n 'px',\n\n // angle units\n 'deg',\n 'grad',\n 'rad',\n 'turn',\n\n // duration units\n 's',\n 'ms',\n\n // frequency units\n 'Hz',\n 'kHz',\n\n // resolution units\n 'dpi',\n 'dpcm',\n 'dppx',\n 'x',\n\n // https://www.w3.org/TR/css-grid-1/#fr-unit\n 'fr',\n\n // percentages\n '%',\n];\n\nexport const unitless = {\n animationIterationCount: true,\n borderImageOutset: true,\n borderImageSlice: true,\n borderImageWidth: true,\n boxFlex: true,\n boxFlexGroup: true,\n boxOrdinalGroup: true,\n columnCount: true,\n columns: true,\n flex: true,\n flexGrow: true,\n flexPositive: true,\n flexShrink: true,\n flexNegative: true,\n flexOrder: true,\n gridRow: true,\n gridRowEnd: true,\n gridRowSpan: true,\n gridRowStart: true,\n gridColumn: true,\n gridColumnEnd: true,\n gridColumnSpan: true,\n gridColumnStart: true,\n fontWeight: true,\n lineClamp: true,\n lineHeight: true,\n opacity: true,\n order: true,\n orphans: true,\n tabSize: true,\n widows: true,\n zIndex: true,\n zoom: true,\n\n // SVG-related properties\n fillOpacity: true,\n floodOpacity: true,\n stopOpacity: true,\n strokeDasharray: true,\n strokeDashoffset: true,\n strokeMiterlimit: true,\n strokeOpacity: true,\n strokeWidth: true,\n};\n"],"file":"units.js"}