@dazl/shorthands-opener 4.2.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 (237) hide show
  1. package/README.md +3 -0
  2. package/dist/compounds/compound-css-data.d.ts +22 -0
  3. package/dist/compounds/compound-css-data.d.ts.map +1 -0
  4. package/dist/compounds/compound-css-data.js +2 -0
  5. package/dist/compounds/compound-css-data.js.map +1 -0
  6. package/dist/compounds/compound-mapper.d.ts +4 -0
  7. package/dist/compounds/compound-mapper.d.ts.map +1 -0
  8. package/dist/compounds/compound-mapper.js +10 -0
  9. package/dist/compounds/compound-mapper.js.map +1 -0
  10. package/dist/compounds/compound-parser-utils.d.ts +3 -0
  11. package/dist/compounds/compound-parser-utils.d.ts.map +1 -0
  12. package/dist/compounds/compound-parser-utils.js +33 -0
  13. package/dist/compounds/compound-parser-utils.js.map +1 -0
  14. package/dist/compounds/compound-types.d.ts +26 -0
  15. package/dist/compounds/compound-types.d.ts.map +1 -0
  16. package/dist/compounds/compound-types.js +2 -0
  17. package/dist/compounds/compound-types.js.map +1 -0
  18. package/dist/compounds/compound-value-parsers.d.ts +6 -0
  19. package/dist/compounds/compound-value-parsers.d.ts.map +1 -0
  20. package/dist/compounds/compound-value-parsers.js +5 -0
  21. package/dist/compounds/compound-value-parsers.js.map +1 -0
  22. package/dist/compounds/index.d.ts +6 -0
  23. package/dist/compounds/index.d.ts.map +1 -0
  24. package/dist/compounds/index.js +6 -0
  25. package/dist/compounds/index.js.map +1 -0
  26. package/dist/compounds/parsers/index.d.ts +2 -0
  27. package/dist/compounds/parsers/index.d.ts.map +1 -0
  28. package/dist/compounds/parsers/index.js +2 -0
  29. package/dist/compounds/parsers/index.js.map +1 -0
  30. package/dist/compounds/parsers/shadow-compound.d.ts +5 -0
  31. package/dist/compounds/parsers/shadow-compound.d.ts.map +1 -0
  32. package/dist/compounds/parsers/shadow-compound.js +39 -0
  33. package/dist/compounds/parsers/shadow-compound.js.map +1 -0
  34. package/dist/css-data-types/data-types-consts.d.ts +212 -0
  35. package/dist/css-data-types/data-types-consts.d.ts.map +1 -0
  36. package/dist/css-data-types/data-types-consts.js +790 -0
  37. package/dist/css-data-types/data-types-consts.js.map +1 -0
  38. package/dist/css-data-types/data-types-predicates.d.ts +32 -0
  39. package/dist/css-data-types/data-types-predicates.d.ts.map +1 -0
  40. package/dist/css-data-types/data-types-predicates.js +353 -0
  41. package/dist/css-data-types/data-types-predicates.js.map +1 -0
  42. package/dist/css-data-types/data-types-state-machines.d.ts +14 -0
  43. package/dist/css-data-types/data-types-state-machines.d.ts.map +1 -0
  44. package/dist/css-data-types/data-types-state-machines.js +129 -0
  45. package/dist/css-data-types/data-types-state-machines.js.map +1 -0
  46. package/dist/css-data-types/data-types-types.d.ts +26 -0
  47. package/dist/css-data-types/data-types-types.d.ts.map +1 -0
  48. package/dist/css-data-types/data-types-types.js +2 -0
  49. package/dist/css-data-types/data-types-types.js.map +1 -0
  50. package/dist/css-data-types/data-types-utils.d.ts +31 -0
  51. package/dist/css-data-types/data-types-utils.d.ts.map +1 -0
  52. package/dist/css-data-types/data-types-utils.js +176 -0
  53. package/dist/css-data-types/data-types-utils.js.map +1 -0
  54. package/dist/css-data-types/data-types.d.ts +64 -0
  55. package/dist/css-data-types/data-types.d.ts.map +1 -0
  56. package/dist/css-data-types/data-types.js +304 -0
  57. package/dist/css-data-types/data-types.js.map +1 -0
  58. package/dist/css-data-types/index.d.ts +7 -0
  59. package/dist/css-data-types/index.d.ts.map +1 -0
  60. package/dist/css-data-types/index.js +7 -0
  61. package/dist/css-data-types/index.js.map +1 -0
  62. package/dist/index.d.ts +5 -0
  63. package/dist/index.d.ts.map +1 -0
  64. package/dist/index.js +5 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/shorthands/index.d.ts +8 -0
  67. package/dist/shorthands/index.d.ts.map +1 -0
  68. package/dist/shorthands/index.js +8 -0
  69. package/dist/shorthands/index.js.map +1 -0
  70. package/dist/shorthands/openers/background-position-shorthand.d.ts +5 -0
  71. package/dist/shorthands/openers/background-position-shorthand.d.ts.map +1 -0
  72. package/dist/shorthands/openers/background-position-shorthand.js +173 -0
  73. package/dist/shorthands/openers/background-position-shorthand.js.map +1 -0
  74. package/dist/shorthands/openers/background-shorthand.d.ts +5 -0
  75. package/dist/shorthands/openers/background-shorthand.d.ts.map +1 -0
  76. package/dist/shorthands/openers/background-shorthand.js +88 -0
  77. package/dist/shorthands/openers/background-shorthand.js.map +1 -0
  78. package/dist/shorthands/openers/border-image-shorthand.d.ts +5 -0
  79. package/dist/shorthands/openers/border-image-shorthand.d.ts.map +1 -0
  80. package/dist/shorthands/openers/border-image-shorthand.js +16 -0
  81. package/dist/shorthands/openers/border-image-shorthand.js.map +1 -0
  82. package/dist/shorthands/openers/border-radius-shorthand.d.ts +5 -0
  83. package/dist/shorthands/openers/border-radius-shorthand.d.ts.map +1 -0
  84. package/dist/shorthands/openers/border-radius-shorthand.js +61 -0
  85. package/dist/shorthands/openers/border-radius-shorthand.js.map +1 -0
  86. package/dist/shorthands/openers/border-shorthand.d.ts +20 -0
  87. package/dist/shorthands/openers/border-shorthand.d.ts.map +1 -0
  88. package/dist/shorthands/openers/border-shorthand.js +90 -0
  89. package/dist/shorthands/openers/border-shorthand.js.map +1 -0
  90. package/dist/shorthands/openers/flex-flow-shorthand.d.ts +5 -0
  91. package/dist/shorthands/openers/flex-flow-shorthand.d.ts.map +1 -0
  92. package/dist/shorthands/openers/flex-flow-shorthand.js +13 -0
  93. package/dist/shorthands/openers/flex-flow-shorthand.js.map +1 -0
  94. package/dist/shorthands/openers/flex-shorthand.d.ts +5 -0
  95. package/dist/shorthands/openers/flex-shorthand.d.ts.map +1 -0
  96. package/dist/shorthands/openers/flex-shorthand.js +55 -0
  97. package/dist/shorthands/openers/flex-shorthand.js.map +1 -0
  98. package/dist/shorthands/openers/font-shorthand.d.ts +5 -0
  99. package/dist/shorthands/openers/font-shorthand.d.ts.map +1 -0
  100. package/dist/shorthands/openers/font-shorthand.js +60 -0
  101. package/dist/shorthands/openers/font-shorthand.js.map +1 -0
  102. package/dist/shorthands/openers/gap-shorthand.d.ts +5 -0
  103. package/dist/shorthands/openers/gap-shorthand.d.ts.map +1 -0
  104. package/dist/shorthands/openers/gap-shorthand.js +28 -0
  105. package/dist/shorthands/openers/gap-shorthand.js.map +1 -0
  106. package/dist/shorthands/openers/grid-axis-shorthand.d.ts +6 -0
  107. package/dist/shorthands/openers/grid-axis-shorthand.d.ts.map +1 -0
  108. package/dist/shorthands/openers/grid-axis-shorthand.js +36 -0
  109. package/dist/shorthands/openers/grid-axis-shorthand.js.map +1 -0
  110. package/dist/shorthands/openers/grid-gap-shorthand.d.ts +5 -0
  111. package/dist/shorthands/openers/grid-gap-shorthand.d.ts.map +1 -0
  112. package/dist/shorthands/openers/grid-gap-shorthand.js +21 -0
  113. package/dist/shorthands/openers/grid-gap-shorthand.js.map +1 -0
  114. package/dist/shorthands/openers/grid-shorthand.d.ts +8 -0
  115. package/dist/shorthands/openers/grid-shorthand.d.ts.map +1 -0
  116. package/dist/shorthands/openers/grid-shorthand.js +145 -0
  117. package/dist/shorthands/openers/grid-shorthand.js.map +1 -0
  118. package/dist/shorthands/openers/grid-template-shorthand.d.ts +10 -0
  119. package/dist/shorthands/openers/grid-template-shorthand.d.ts.map +1 -0
  120. package/dist/shorthands/openers/grid-template-shorthand.js +113 -0
  121. package/dist/shorthands/openers/grid-template-shorthand.js.map +1 -0
  122. package/dist/shorthands/openers/index.d.ts +22 -0
  123. package/dist/shorthands/openers/index.d.ts.map +1 -0
  124. package/dist/shorthands/openers/index.js +22 -0
  125. package/dist/shorthands/openers/index.js.map +1 -0
  126. package/dist/shorthands/openers/list-style-shorthand.d.ts +5 -0
  127. package/dist/shorthands/openers/list-style-shorthand.d.ts.map +1 -0
  128. package/dist/shorthands/openers/list-style-shorthand.js +15 -0
  129. package/dist/shorthands/openers/list-style-shorthand.js.map +1 -0
  130. package/dist/shorthands/openers/margin-shorthand.d.ts +5 -0
  131. package/dist/shorthands/openers/margin-shorthand.d.ts.map +1 -0
  132. package/dist/shorthands/openers/margin-shorthand.js +11 -0
  133. package/dist/shorthands/openers/margin-shorthand.js.map +1 -0
  134. package/dist/shorthands/openers/outline-shorthand.d.ts +5 -0
  135. package/dist/shorthands/openers/outline-shorthand.d.ts.map +1 -0
  136. package/dist/shorthands/openers/outline-shorthand.js +14 -0
  137. package/dist/shorthands/openers/outline-shorthand.js.map +1 -0
  138. package/dist/shorthands/openers/overflow-shorthand.d.ts +5 -0
  139. package/dist/shorthands/openers/overflow-shorthand.d.ts.map +1 -0
  140. package/dist/shorthands/openers/overflow-shorthand.js +21 -0
  141. package/dist/shorthands/openers/overflow-shorthand.js.map +1 -0
  142. package/dist/shorthands/openers/padding-shorthand.d.ts +5 -0
  143. package/dist/shorthands/openers/padding-shorthand.d.ts.map +1 -0
  144. package/dist/shorthands/openers/padding-shorthand.js +11 -0
  145. package/dist/shorthands/openers/padding-shorthand.js.map +1 -0
  146. package/dist/shorthands/openers/place-content-shorthand.d.ts +5 -0
  147. package/dist/shorthands/openers/place-content-shorthand.d.ts.map +1 -0
  148. package/dist/shorthands/openers/place-content-shorthand.js +29 -0
  149. package/dist/shorthands/openers/place-content-shorthand.js.map +1 -0
  150. package/dist/shorthands/openers/place-items-shorthand.d.ts +5 -0
  151. package/dist/shorthands/openers/place-items-shorthand.d.ts.map +1 -0
  152. package/dist/shorthands/openers/place-items-shorthand.js +23 -0
  153. package/dist/shorthands/openers/place-items-shorthand.js.map +1 -0
  154. package/dist/shorthands/openers/text-decoration-shorthand.d.ts +5 -0
  155. package/dist/shorthands/openers/text-decoration-shorthand.d.ts.map +1 -0
  156. package/dist/shorthands/openers/text-decoration-shorthand.js +14 -0
  157. package/dist/shorthands/openers/text-decoration-shorthand.js.map +1 -0
  158. package/dist/shorthands/shorthand-css-data.d.ts +120 -0
  159. package/dist/shorthands/shorthand-css-data.d.ts.map +1 -0
  160. package/dist/shorthands/shorthand-css-data.js +48 -0
  161. package/dist/shorthands/shorthand-css-data.js.map +1 -0
  162. package/dist/shorthands/shorthand-mapper.d.ts +6 -0
  163. package/dist/shorthands/shorthand-mapper.d.ts.map +1 -0
  164. package/dist/shorthands/shorthand-mapper.js +72 -0
  165. package/dist/shorthands/shorthand-mapper.js.map +1 -0
  166. package/dist/shorthands/shorthand-parser-errors.d.ts +25 -0
  167. package/dist/shorthands/shorthand-parser-errors.d.ts.map +1 -0
  168. package/dist/shorthands/shorthand-parser-errors.js +41 -0
  169. package/dist/shorthands/shorthand-parser-errors.js.map +1 -0
  170. package/dist/shorthands/shorthand-parser-utils.d.ts +24 -0
  171. package/dist/shorthands/shorthand-parser-utils.d.ts.map +1 -0
  172. package/dist/shorthands/shorthand-parser-utils.js +398 -0
  173. package/dist/shorthands/shorthand-parser-utils.js.map +1 -0
  174. package/dist/shorthands/shorthand-types.d.ts +64 -0
  175. package/dist/shorthands/shorthand-types.d.ts.map +1 -0
  176. package/dist/shorthands/shorthand-types.js +2 -0
  177. package/dist/shorthands/shorthand-types.js.map +1 -0
  178. package/dist/shorthands/shorthands-ast-evaluation.d.ts +5 -0
  179. package/dist/shorthands/shorthands-ast-evaluation.d.ts.map +1 -0
  180. package/dist/shorthands/shorthands-ast-evaluation.js +19 -0
  181. package/dist/shorthands/shorthands-ast-evaluation.js.map +1 -0
  182. package/dist/tokenizers/css-value-tokenizer.d.ts +43 -0
  183. package/dist/tokenizers/css-value-tokenizer.d.ts.map +1 -0
  184. package/dist/tokenizers/css-value-tokenizer.js +154 -0
  185. package/dist/tokenizers/css-value-tokenizer.js.map +1 -0
  186. package/dist/tokenizers/index.d.ts +2 -0
  187. package/dist/tokenizers/index.d.ts.map +1 -0
  188. package/dist/tokenizers/index.js +2 -0
  189. package/dist/tokenizers/index.js.map +1 -0
  190. package/package.json +54 -0
  191. package/src/compounds/compound-css-data.ts +24 -0
  192. package/src/compounds/compound-mapper.ts +21 -0
  193. package/src/compounds/compound-parser-utils.ts +47 -0
  194. package/src/compounds/compound-types.ts +35 -0
  195. package/src/compounds/compound-value-parsers.ts +12 -0
  196. package/src/compounds/index.ts +5 -0
  197. package/src/compounds/parsers/index.ts +1 -0
  198. package/src/compounds/parsers/shadow-compound.ts +56 -0
  199. package/src/css-data-types/data-types-consts.ts +877 -0
  200. package/src/css-data-types/data-types-predicates.ts +477 -0
  201. package/src/css-data-types/data-types-state-machines.ts +169 -0
  202. package/src/css-data-types/data-types-types.ts +43 -0
  203. package/src/css-data-types/data-types-utils.ts +258 -0
  204. package/src/css-data-types/data-types.ts +435 -0
  205. package/src/css-data-types/index.ts +6 -0
  206. package/src/index.ts +4 -0
  207. package/src/shorthands/index.ts +7 -0
  208. package/src/shorthands/openers/background-position-shorthand.ts +180 -0
  209. package/src/shorthands/openers/background-shorthand.ts +161 -0
  210. package/src/shorthands/openers/border-image-shorthand.ts +35 -0
  211. package/src/shorthands/openers/border-radius-shorthand.ts +93 -0
  212. package/src/shorthands/openers/border-shorthand.ts +198 -0
  213. package/src/shorthands/openers/flex-flow-shorthand.ts +24 -0
  214. package/src/shorthands/openers/flex-shorthand.ts +79 -0
  215. package/src/shorthands/openers/font-shorthand.ts +85 -0
  216. package/src/shorthands/openers/gap-shorthand.ts +47 -0
  217. package/src/shorthands/openers/grid-axis-shorthand.ts +61 -0
  218. package/src/shorthands/openers/grid-gap-shorthand.ts +40 -0
  219. package/src/shorthands/openers/grid-shorthand.ts +260 -0
  220. package/src/shorthands/openers/grid-template-shorthand.ts +176 -0
  221. package/src/shorthands/openers/index.ts +21 -0
  222. package/src/shorthands/openers/list-style-shorthand.ts +33 -0
  223. package/src/shorthands/openers/margin-shorthand.ts +20 -0
  224. package/src/shorthands/openers/outline-shorthand.ts +27 -0
  225. package/src/shorthands/openers/overflow-shorthand.ts +40 -0
  226. package/src/shorthands/openers/padding-shorthand.ts +21 -0
  227. package/src/shorthands/openers/place-content-shorthand.ts +49 -0
  228. package/src/shorthands/openers/place-items-shorthand.ts +43 -0
  229. package/src/shorthands/openers/text-decoration-shorthand.ts +27 -0
  230. package/src/shorthands/shorthand-css-data.ts +210 -0
  231. package/src/shorthands/shorthand-mapper.ts +157 -0
  232. package/src/shorthands/shorthand-parser-errors.ts +47 -0
  233. package/src/shorthands/shorthand-parser-utils.ts +602 -0
  234. package/src/shorthands/shorthand-types.ts +107 -0
  235. package/src/shorthands/shorthands-ast-evaluation.ts +38 -0
  236. package/src/tokenizers/css-value-tokenizer.ts +220 -0
  237. package/src/tokenizers/index.ts +1 -0
@@ -0,0 +1,64 @@
1
+ import type { CSSCodeAst } from '../tokenizers/index.js';
2
+ import type { AstItem, DataType } from '../css-data-types/index.js';
3
+ export type CSSAstNode<V> = CSSCodeAst | V;
4
+ export interface ParseShorthandAPI<V> {
5
+ isExpression: (item: CSSAstNode<V>) => item is V;
6
+ getValue: (item: V) => CSSCodeAst[];
7
+ toString: (item: V) => string;
8
+ }
9
+ export interface EvaluatedAst<V> extends AstItem {
10
+ origin?: V;
11
+ /**
12
+ * When values are omitted from a CSS shorthand form,
13
+ * each “missing” sub-property is assigned its initial value.
14
+ * `isImplicit` specifies if the AST node represents such an implicit initial value.
15
+ */
16
+ isImplicit?: boolean;
17
+ }
18
+ export type AstEvaluator<V, T> = (ast: CSSAstNode<V>[], api: ParseShorthandAPI<V>) => T[];
19
+ export interface DataTypeMatch {
20
+ matchAmount: number;
21
+ matchIndex: number;
22
+ }
23
+ export type OpenedShorthandValue<V> = EvaluatedAst<V> | EvaluatedAst<V>[];
24
+ export type OpenedShorthand<V, T extends string = string, R = OpenedShorthandValue<V>> = Record<T, R>;
25
+ export type SimpleOpenedShorthand<V, T extends string = string> = OpenedShorthand<V, T, EvaluatedAst<V>>;
26
+ type GenericShorthandOpener<S, V, T extends string = string, R = OpenedShorthand<V, T>> = (shortHand: S[], api: ParseShorthandAPI<V>, shallow?: boolean) => R;
27
+ export type ShorthandOpener<V, T extends string = string, R = OpenedShorthand<V, T>> = GenericShorthandOpener<CSSAstNode<V>, V, T, R>;
28
+ export type SimpleShorthandOpener<V, T extends string = string> = ShorthandOpener<V, T, SimpleOpenedShorthand<V, T>>;
29
+ export type ShorthandOpenerInner<V, T extends string = string, R = OpenedShorthand<V, T>> = GenericShorthandOpener<EvaluatedAst<V>, V, T, R>;
30
+ export type SimpleShorthandOpenerInner<V, T extends string = string> = ShorthandOpenerInner<V, T, SimpleOpenedShorthand<V, T>>;
31
+ export type FullShorthandOpener<V, T extends string = string> = (astNodes: EvaluatedAst<V>[], api: ParseShorthandAPI<V>, parts: ShorthandPart<V, T>[], shallow?: boolean) => OpenedShorthand<V, T>;
32
+ export interface UnorderedListShorthandOptions {
33
+ shallow?: boolean;
34
+ commonValue?: string;
35
+ }
36
+ export type BeforeOpenerCheck<V> = (astNodes: EvaluatedAst<V>[]) => void;
37
+ export interface BasicPart {
38
+ prop: string;
39
+ dataType: DataType;
40
+ mandatory?: boolean;
41
+ }
42
+ export interface ShorthandPart<V, T extends string = string> extends BasicPart {
43
+ beforeOpenerCheck?: BeforeOpenerCheck<V>;
44
+ partOpener?: SimpleShorthandOpenerInner<V, T>;
45
+ openedProps?: T[];
46
+ multipleItems?: boolean;
47
+ multipleSplit?: boolean;
48
+ }
49
+ export interface ShorthandOpenerData<V, T extends string = string> {
50
+ prop: string;
51
+ singleKeywordPart?: ShorthandPart<V, T>;
52
+ parts: ShorthandPart<V, T>[];
53
+ shorthandOpener: FullShorthandOpener<V, T>;
54
+ }
55
+ export type GetShorthandOpener<T extends string> = <V>() => ShorthandOpener<V, T>;
56
+ export type GetSimpleShorthandOpener<T extends string> = <V>() => SimpleShorthandOpener<V, T>;
57
+ export type ShorthandCloserTemplate<T extends string> = {
58
+ strings: TemplateStringsArray | string[];
59
+ keys: T[];
60
+ };
61
+ export type ShorthandCloser<V, T extends string = string, R = SimpleOpenedShorthand<V, T>> = (opened: R, api: ParseShorthandAPI<V>, detachExpressions?: boolean, shallow?: boolean) => CSSAstNode<V>[];
62
+ export type GetShorthandCloser<T extends string> = <V>() => ShorthandCloser<V, T>;
63
+ export {};
64
+ //# sourceMappingURL=shorthand-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shorthand-types.d.ts","sourceRoot":"","sources":["../../src/shorthands/shorthand-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEpE,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,UAAU,GAAG,CAAC,CAAC;AAE3C,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAChC,YAAY,EAAE,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;IACjD,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,UAAU,EAAE,CAAC;IACpC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,YAAY,CAAC,CAAC,CAAE,SAAQ,OAAO;IAC5C,MAAM,CAAC,EAAE,CAAC,CAAC;IACX;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;AAE1F,MAAM,WAAW,aAAa;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1E,MAAM,MAAM,eAAe,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,oBAA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,EAAE,CAAC,CAAC,EAAE,CAAC;IAC7B,eAAe,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAC9C;AAED,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,CAAC,OAAO,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAClF,MAAM,MAAM,wBAAwB,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,CAAC,OAAO,qBAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE9F,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,MAAM,IAAI;IACpD,OAAO,EAAE,oBAAoB,GAAG,MAAM,EAAE,CAAC;IACzC,IAAI,EAAE,CAAC,EAAE,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,qBAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CACzF,MAAM,EAAE,CAAC,EACT,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC,EACzB,iBAAiB,CAAC,EAAE,OAAO,EAC3B,OAAO,CAAC,EAAE,OAAO,KAChB,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;AAErB,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,CAAC,OAAO,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=shorthand-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shorthand-types.js","sourceRoot":"","sources":["../../src/shorthands/shorthand-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { CSSCodeAst } from '../tokenizers/index.js';
2
+ import type { CSSAstNode, ParseShorthandAPI, EvaluatedAst } from './shorthand-types.js';
3
+ export declare const codeToEvaluatedAst: <V>(ast: CSSCodeAst[]) => EvaluatedAst<V>[];
4
+ export declare const evaluateAst: <V>(ast: CSSAstNode<V>[], api: ParseShorthandAPI<V>) => EvaluatedAst<V>[];
5
+ //# sourceMappingURL=shorthands-ast-evaluation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shorthands-ast-evaluation.d.ts","sourceRoot":"","sources":["../../src/shorthands/shorthands-ast-evaluation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,YAAY,EAAgB,MAAM,sBAAsB,CAAC;AA4BtG,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAE,KAAK,UAAU,EAAE,KAAG,YAAY,CAAC,CAAC,CAAC,EACvB,CAAC;AAGnD,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,iBAAiB,CAAC,CAAC,CAAC,KAAG,YAAY,CAAC,CAAC,CAAC,EAIjF,CAAC"}
@@ -0,0 +1,19 @@
1
+ const createEvaluateAst = (handleExpression, handleNonExpression) => (ast, api) => {
2
+ const res = [];
3
+ for (const node of ast) {
4
+ if (api.isExpression(node)) {
5
+ res.push(...handleExpression(node, api));
6
+ }
7
+ else {
8
+ res.push(handleNonExpression(node));
9
+ }
10
+ }
11
+ return res;
12
+ };
13
+ const evaluateExpression = (node, api) => evaluateAstInner(api.getValue(node), api);
14
+ const evaluateAstInner = (ast, api) => createEvaluateAst((node, api) => evaluateExpression(node, api), (node) => node)(ast, api);
15
+ const evaluateCodeNode = (value) => ({ value });
16
+ export const codeToEvaluatedAst = (ast) => ast.map((value) => evaluateCodeNode(value));
17
+ // TODO: Always have origin to values that don't come from an initial value (that are specified directly)
18
+ export const evaluateAst = (ast, api) => createEvaluateAst((origin, api) => evaluateExpression(origin, api).map((value) => ({ value, origin })), evaluateCodeNode)(ast, api);
19
+ //# sourceMappingURL=shorthands-ast-evaluation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shorthands-ast-evaluation.js","sourceRoot":"","sources":["../../src/shorthands/shorthands-ast-evaluation.ts"],"names":[],"mappings":"AAGA,MAAM,iBAAiB,GACnB,CACI,gBAA6D,EAC7D,mBAA4C,EAC1B,EAAE,CACxB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;IACT,MAAM,GAAG,GAAQ,EAAE,CAAC;IACpB,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;QACrB,IAAI,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,GAAG,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;QAC7C,CAAC;aAAM,CAAC;YACJ,GAAG,CAAC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC;QACxC,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC,CAAC;AAEN,MAAM,kBAAkB,GAAG,CAAI,IAAO,EAAE,GAAyB,EAAE,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AAEhH,MAAM,gBAAgB,GAAG,CAAI,GAAiB,EAAE,GAAyB,EAAgB,EAAE,CACvF,iBAAiB,CACb,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,kBAAkB,CAAC,IAAI,EAAE,GAAG,CAAC,EAC5C,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CACjB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAEhB,MAAM,gBAAgB,GAAG,CAAI,KAAiB,EAAmB,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AAChF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAI,GAAiB,EAAqB,EAAE,CAC1E,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,gBAAgB,CAAI,KAAK,CAAC,CAAC,CAAC;AAEnD,yGAAyG;AACzG,MAAM,CAAC,MAAM,WAAW,GAAG,CAAI,GAAoB,EAAE,GAAyB,EAAqB,EAAE,CACjG,iBAAiB,CACb,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,kBAAkB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,EACpF,gBAAgB,CACnB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { type Token, type Descriptors } from '@tokey/core';
2
+ export type { Descriptors };
3
+ export type Delimiters = '(' | ')' | ',' | '/';
4
+ export type SeparatorTokens = 'line-comment' | 'multi-comment' | 'space';
5
+ export type CSSValueCodeToken = Token<Descriptors | Delimiters>;
6
+ export type CSSSeparatorTokens = Token<SeparatorTokens>;
7
+ export type CSSCodeAst = StringNode | MethodCall | TextNode | CommaNode | SlashNode;
8
+ export interface ASTNode<Types = Descriptors> {
9
+ type: Types;
10
+ text: string;
11
+ start: number;
12
+ end: number;
13
+ before: CSSSeparatorTokens[];
14
+ after: CSSSeparatorTokens[];
15
+ }
16
+ export interface MethodCall extends ASTNode<'call'> {
17
+ name: string;
18
+ args: CSSCodeAst[];
19
+ }
20
+ export interface StringNode extends ASTNode<'string'> {
21
+ }
22
+ export interface TextNode extends ASTNode<'text'> {
23
+ }
24
+ export interface CommaNode extends ASTNode<','> {
25
+ }
26
+ export interface SlashNode extends ASTNode<'/'> {
27
+ }
28
+ export declare const DEFAULT_POSITION = -1;
29
+ export declare const URL_CALL_TOKEN = "url";
30
+ export declare const isSeparatorToken: (token: CSSValueCodeToken) => token is CSSSeparatorTokens;
31
+ export declare const isCSSCodeAst: (ast: unknown) => ast is CSSCodeAst;
32
+ export declare function createCssValueAST(source: string, parseLineComments?: boolean): CSSCodeAst[];
33
+ export interface NodePositions {
34
+ beforeStart: number;
35
+ beforeEnd: number;
36
+ start: number;
37
+ end: number;
38
+ }
39
+ export declare const getNodePositions: (text: string, pos?: number, spaceBefore?: string) => NodePositions;
40
+ export declare const valueTextNode: (text: string, pos?: number, spaceBefore?: string) => TextNode;
41
+ export declare const getTokensText: (tokens: CSSSeparatorTokens[]) => string;
42
+ export declare const getFullText: (ast: CSSCodeAst) => string;
43
+ //# sourceMappingURL=css-value-tokenizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-value-tokenizer.d.ts","sourceRoot":"","sources":["../../src/tokenizers/css-value-tokenizer.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,KAAK,KAAK,EACV,KAAK,WAAW,EAUnB,MAAM,aAAa,CAAC;AAErB,YAAY,EAAE,WAAW,EAAE,CAAC;AAC5B,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAC/C,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,eAAe,GAAG,OAAO,CAAC;AACzE,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,GAAG,UAAU,CAAC,CAAC;AAChE,MAAM,MAAM,kBAAkB,GAAG,KAAK,CAAC,eAAe,CAAC,CAAC;AACxD,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;AACpF,MAAM,WAAW,OAAO,CAAC,KAAK,GAAG,WAAW;IACxC,IAAI,EAAE,KAAK,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,KAAK,EAAE,kBAAkB,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,UAAW,SAAQ,OAAO,CAAC,MAAM,CAAC;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,UAAW,SAAQ,OAAO,CAAC,QAAQ,CAAC;CAAG;AACxD,MAAM,WAAW,QAAS,SAAQ,OAAO,CAAC,MAAM,CAAC;CAAG;AACpD,MAAM,WAAW,SAAU,SAAQ,OAAO,CAAC,GAAG,CAAC;CAAG;AAClD,MAAM,WAAW,SAAU,SAAQ,OAAO,CAAC,GAAG,CAAC;CAAG;AAElD,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,cAAc,QAAQ,CAAC;AAEpC,eAAO,MAAM,gBAAgB,GAAI,OAAO,iBAAiB,KAAG,KAAK,IAAI,kBAGpE,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,KAAK,OAAO,KAAG,GAAG,IAAI,UAWlD,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,iBAAiB,UAAQ,GAAG,UAAU,EAAE,CAczF;AAsGD,MAAM,WAAW,aAAa;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,EAAE,MAAM,MAAM,EAAE,cAAc,MAAM,KAAG,aAKlF,CAAC;AAEH,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,EAAE,MAAM,MAAM,EAAE,cAAc,MAAM,KAAG,QAmBhF,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,QAAQ,kBAAkB,EAAE,KAAG,MAE5D,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,KAAK,UAAU,KAAG,MAE7C,CAAC"}
@@ -0,0 +1,154 @@
1
+ /* eslint-disable @typescript-eslint/no-empty-object-type */
2
+ import { tokenize, isStringDelimiter, isWhitespace, getJSCommentStartType, getMultilineCommentStartType, isCommentEnd, createToken, getText, getUnclosedComment, } from '@tokey/core';
3
+ export const DEFAULT_POSITION = -1;
4
+ export const URL_CALL_TOKEN = 'url';
5
+ export const isSeparatorToken = (token) => {
6
+ const { type } = token;
7
+ return type === 'line-comment' || type === 'multi-comment' || type === 'space';
8
+ };
9
+ export const isCSSCodeAst = (ast) => {
10
+ const node = ast;
11
+ return (node.text !== undefined &&
12
+ node.type !== undefined &&
13
+ (node.type === 'string' ||
14
+ node.type === 'call' ||
15
+ node.type === 'text' ||
16
+ node.type === ',' ||
17
+ node.type === '/'));
18
+ };
19
+ export function createCssValueAST(source, parseLineComments = false) {
20
+ return parseDeclValueTokens(source, tokenize(source, {
21
+ isDelimiter,
22
+ isStringDelimiter,
23
+ isWhitespace,
24
+ shouldAddToken,
25
+ createToken,
26
+ getCommentStartType: parseLineComments ? getJSCommentStartType : getMultilineCommentStartType,
27
+ isCommentEnd,
28
+ getUnclosedComment,
29
+ })).ast;
30
+ }
31
+ const isDelimiter = (char) => char === '(' || char === ')' || char === ',' || char === '/';
32
+ const shouldAddToken = () => true;
33
+ function parseDeclValueTokens(source, tokens, startAtIdx = 0) {
34
+ const ast = [];
35
+ let before = [];
36
+ for (let i = startAtIdx; i < tokens.length; i++) {
37
+ const token = tokens[i];
38
+ if (token.type === ')') {
39
+ const lastAst = ast[ast.length - 1];
40
+ if (lastAst && before.length) {
41
+ lastAst.after = before;
42
+ before = [];
43
+ }
44
+ return {
45
+ ast,
46
+ stoppedAtIdx: i,
47
+ };
48
+ }
49
+ else if (isSeparatorToken(token)) {
50
+ before.push(token);
51
+ }
52
+ else if (token.type === 'text' && tokens[i + 1]?.type === '(') {
53
+ const res = parseDeclValueTokens(source, tokens, i + 2);
54
+ const methodText = getText(tokens, i, res.stoppedAtIdx + 1, source);
55
+ i = res.stoppedAtIdx;
56
+ res.ast = getUrlTokensAst(token, res.ast);
57
+ ast.push({
58
+ type: 'call',
59
+ text: methodText,
60
+ start: token.start,
61
+ end: token.start + methodText.length,
62
+ before,
63
+ after: [],
64
+ name: token.value,
65
+ args: res.ast,
66
+ });
67
+ before = [];
68
+ }
69
+ else {
70
+ ast.push({
71
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
72
+ type: token.type, // eslint-disable-line @typescript-eslint/no-explicit-any
73
+ text: token.value,
74
+ start: token.start,
75
+ end: token.end,
76
+ before,
77
+ after: [],
78
+ });
79
+ before = [];
80
+ }
81
+ }
82
+ return {
83
+ ast,
84
+ stoppedAtIdx: tokens.length,
85
+ };
86
+ }
87
+ function getUrlTokensAst(token, ast) {
88
+ if (token.value !== URL_CALL_TOKEN || ast.length === 0) {
89
+ return ast;
90
+ }
91
+ const pushFixedTextNodeToFixedAst = () => {
92
+ if (fixedTextNode) {
93
+ fixedTextNode.end = fixedTextNode.start + fixedTextNode.text.length;
94
+ fixedAst.push(fixedTextNode);
95
+ fixedTextNode = null;
96
+ }
97
+ };
98
+ let fixedTextNode = null;
99
+ const fixedAst = [];
100
+ for (const node of ast) {
101
+ if (node.type === '/' || node.type === 'text') {
102
+ if (!fixedTextNode) {
103
+ fixedTextNode = {
104
+ type: 'text',
105
+ text: '',
106
+ before: node.before,
107
+ after: [],
108
+ start: node.start,
109
+ end: DEFAULT_POSITION,
110
+ };
111
+ }
112
+ fixedTextNode.text += node.text;
113
+ }
114
+ else {
115
+ pushFixedTextNodeToFixedAst();
116
+ fixedAst.push(node);
117
+ }
118
+ }
119
+ pushFixedTextNodeToFixedAst();
120
+ return fixedAst;
121
+ }
122
+ export const getNodePositions = (text, pos, spaceBefore) => ({
123
+ beforeStart: !spaceBefore || pos === undefined ? DEFAULT_POSITION : pos - spaceBefore.length,
124
+ beforeEnd: !spaceBefore || pos === undefined ? DEFAULT_POSITION : pos,
125
+ start: pos === undefined ? DEFAULT_POSITION : pos,
126
+ end: pos === undefined ? DEFAULT_POSITION : pos + text.length,
127
+ });
128
+ export const valueTextNode = (text, pos, spaceBefore) => {
129
+ const { start, end, beforeEnd, beforeStart } = getNodePositions(text, pos, spaceBefore);
130
+ return {
131
+ type: 'text',
132
+ start,
133
+ end,
134
+ before: spaceBefore
135
+ ? [
136
+ {
137
+ type: 'space',
138
+ start: beforeStart,
139
+ end: beforeEnd,
140
+ value: spaceBefore,
141
+ },
142
+ ]
143
+ : [],
144
+ after: [],
145
+ text,
146
+ };
147
+ };
148
+ export const getTokensText = (tokens) => {
149
+ return tokens.map((token) => token.value).join('');
150
+ };
151
+ export const getFullText = (ast) => {
152
+ return getTokensText(ast.before) + ast.text + getTokensText(ast.after);
153
+ };
154
+ //# sourceMappingURL=css-value-tokenizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-value-tokenizer.js","sourceRoot":"","sources":["../../src/tokenizers/css-value-tokenizer.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAE5D,OAAO,EAGH,QAAQ,EACR,iBAAiB,EACjB,YAAY,EACZ,qBAAqB,EACrB,4BAA4B,EAC5B,YAAY,EACZ,WAAW,EACX,OAAO,EACP,kBAAkB,GACrB,MAAM,aAAa,CAAC;AA2BrB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,CAAC;AACnC,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC;AAEpC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAwB,EAA+B,EAAE;IACtF,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IACvB,OAAO,IAAI,KAAK,cAAc,IAAI,IAAI,KAAK,eAAe,IAAI,IAAI,KAAK,OAAO,CAAC;AACnF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAY,EAAqB,EAAE;IAC5D,MAAM,IAAI,GAAG,GAAiB,CAAC;IAC/B,OAAO,CACH,IAAI,CAAC,IAAI,KAAK,SAAS;QACvB,IAAI,CAAC,IAAI,KAAK,SAAS;QACvB,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ;YACnB,IAAI,CAAC,IAAI,KAAK,MAAM;YACp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AClE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAe,EAAU,EAAE;IACnD,OAAO,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAC3E,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './css-value-tokenizer.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tokenizers/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './css-value-tokenizer.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tokenizers/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@dazl/shorthands-opener",
3
+ "version": "4.2.0",
4
+ "type": "module",
5
+ "description": "A library used to open CSS shorthands",
6
+ "exports": "./dist/index.js",
7
+ "license": "UNLICENSED",
8
+ "scripts": {
9
+ "clean": "rimraf ./dist",
10
+ "prebuild": "npm run clean",
11
+ "build": "tsc -p tsconfig.build.json",
12
+ "pretest": "npm run typecheck && npm run lint",
13
+ "test": "mocha \"./test/**/*.spec.ts\"",
14
+ "lint": "eslint",
15
+ "typecheck": "tsc --noEmit",
16
+ "prettify": "prettier . --write",
17
+ "prepack": "npm run build"
18
+ },
19
+ "dependencies": {
20
+ "@tokey/core": "^1.4.0",
21
+ "tslib": "^2.8.1"
22
+ },
23
+ "devDependencies": {
24
+ "@ts-tools/esm": "^6.1.0",
25
+ "@types/chai": "^5.2.2",
26
+ "@types/mocha": "^10.0.10",
27
+ "chai": "^6.0.1",
28
+ "eslint": "^9.34.0",
29
+ "eslint-config-prettier": "^10.1.8",
30
+ "eslint-plugin-no-only-tests": "^3.3.0",
31
+ "mocha": "^11.7.1",
32
+ "prettier": "^3.6.2",
33
+ "rimraf": "^6.0.1",
34
+ "typescript": "~5.9.2",
35
+ "typescript-eslint": "^8.41.0"
36
+ },
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/dazl-dev/shorthands-opener.git"
40
+ },
41
+ "files": [
42
+ "dist",
43
+ "src"
44
+ ],
45
+ "keywords": [],
46
+ "author": "Dazl",
47
+ "bugs": {
48
+ "url": "https://github.com/dazl-dev/shorthands-opener/issues"
49
+ },
50
+ "homepage": "https://github.com/dazl-dev/shorthands-opener",
51
+ "publishConfig": {
52
+ "access": "restricted"
53
+ }
54
+ }
@@ -0,0 +1,24 @@
1
+ import type { Dimension } from '../css-data-types/index.js';
2
+
3
+ export type BoxShadowMap = {
4
+ 'box-shadow'?: string;
5
+ inset: boolean;
6
+ 'offset-x': Dimension;
7
+ 'offset-y': Dimension;
8
+ 'blur-radius': Dimension;
9
+ 'spread-radius': Dimension;
10
+ color: string;
11
+ };
12
+
13
+ export type TextShadowMap = {
14
+ 'text-shadow'?: string;
15
+ 'offset-x': Dimension;
16
+ 'offset-y': Dimension;
17
+ 'blur-radius': Dimension;
18
+ color: string;
19
+ };
20
+
21
+ export type CompoundsTypeMap = {
22
+ 'box-shadow': BoxShadowMap;
23
+ 'text-shadow': TextShadowMap;
24
+ };
@@ -0,0 +1,21 @@
1
+ import type { CompoundParser, GetCompoundParser } from './compound-types.js';
2
+ import type { CompoundsTypeMap } from './compound-css-data.js';
3
+
4
+ import { parseBoxShadowCompound, parseTextShadowCompound } from './parsers/index.js';
5
+
6
+ type CompoundMapToParser<M> = {
7
+ [K in keyof M]: GetCompoundParser<M[K]>;
8
+ };
9
+ type CompoundParsersMap = CompoundMapToParser<CompoundsTypeMap>;
10
+
11
+ const compoundParsersMap: CompoundParsersMap = {
12
+ 'box-shadow': parseBoxShadowCompound,
13
+ 'text-shadow': parseTextShadowCompound,
14
+ };
15
+
16
+ export const getCompoundParser = <V, T extends keyof CompoundsTypeMap>(
17
+ prop: T,
18
+ ): CompoundParser<V, CompoundsTypeMap[T]> => {
19
+ const getParser = compoundParsersMap[prop] as GetCompoundParser<CompoundsTypeMap[T]>;
20
+ return getParser<V>();
21
+ };
@@ -0,0 +1,47 @@
1
+ import type {
2
+ ParsedCompoundValue,
3
+ ParsedCompound,
4
+ CompoundParser,
5
+ ParseMap,
6
+ CompoundParserData,
7
+ } from './compound-types.js';
8
+ import { type ShorthandPart, createShorthandOpener } from '../shorthands/index.js';
9
+
10
+ const setParsedCompoundValue = <V, M>(
11
+ parseMap: ParseMap<M>,
12
+ node: ParsedCompoundValue<V, M[keyof M]>,
13
+ prop: string,
14
+ ) => {
15
+ if (!Array.isArray(node)) {
16
+ node.parsedValue = parseMap[prop]!(node.value.text, prop);
17
+ return;
18
+ }
19
+ for (const innerNode of node) {
20
+ setParsedCompoundValue(parseMap, innerNode, prop);
21
+ }
22
+ };
23
+
24
+ export const createCompoundParser =
25
+ <V, M>({ prop, singleKeywordPart, parts, shorthandOpener }: CompoundParserData<V, M>): CompoundParser<V, M> =>
26
+ (compound, api) => {
27
+ const parseMap: ParseMap<M> = {};
28
+ if (singleKeywordPart) {
29
+ parseMap[singleKeywordPart.prop] = singleKeywordPart.parser;
30
+ }
31
+ for (const part of parts) {
32
+ parseMap[part.prop] = part.parser;
33
+ }
34
+ const openCompoundAsShorthand = createShorthandOpener<V, string>({
35
+ prop,
36
+ singleKeywordPart,
37
+ parts: parts as ShorthandPart<V>[],
38
+ shorthandOpener,
39
+ });
40
+ const opened = openCompoundAsShorthand(compound, api);
41
+ const parsed = { ...opened } as ParsedCompound<V, M>;
42
+ const props = Object.keys(opened) as Array<keyof M>;
43
+ for (const prop of props) {
44
+ setParsedCompoundValue(parseMap, parsed[prop], prop as string);
45
+ }
46
+ return parsed;
47
+ };
@@ -0,0 +1,35 @@
1
+ import type {
2
+ CSSAstNode,
3
+ ParseShorthandAPI,
4
+ EvaluatedAst,
5
+ FullShorthandOpener,
6
+ BasicPart,
7
+ } from '../shorthands/index.js';
8
+
9
+ export interface ParsedCompoundAst<V, T> extends EvaluatedAst<V> {
10
+ parsedValue: T;
11
+ }
12
+
13
+ export type ParsedCompoundValue<V, T> = ParsedCompoundAst<V, T> | ParsedCompoundAst<V, T>[];
14
+
15
+ export type ParsedCompound<V, M> = { [K in keyof M]: ParsedCompoundValue<V, M[K]> };
16
+ export type LayeredParsedCompound<V, M> = { [K in keyof M]: ParsedCompoundAst<V, M[K]>[] };
17
+
18
+ export type CompoundParser<V, M> = (compound: CSSAstNode<V>[], api: ParseShorthandAPI<V>) => ParsedCompound<V, M>;
19
+
20
+ export type CompoundValueParser<M> = (text: string, prop: string) => M[keyof M];
21
+ export type TypedCompoundValueParser<T> = CompoundValueParser<Record<string, T>>;
22
+ export type ParseMap<M> = Record<string, CompoundValueParser<M>>;
23
+
24
+ export interface CompoundPart<M> extends BasicPart {
25
+ parser: CompoundValueParser<M>;
26
+ }
27
+
28
+ export interface CompoundParserData<V, M, T extends string = string> {
29
+ prop: string;
30
+ singleKeywordPart?: CompoundPart<M>;
31
+ parts: CompoundPart<M>[];
32
+ shorthandOpener: FullShorthandOpener<V, T>;
33
+ }
34
+
35
+ export type GetCompoundParser<M> = <V>() => CompoundParser<V, M>;
@@ -0,0 +1,12 @@
1
+ import type { TypedCompoundValueParser } from './compound-types.js';
2
+ import { type KeywordsMap, type Dimension, parseDimension, EMPTY_DIMENSION } from '../css-data-types/index.js';
3
+
4
+ export const identityCompoundValueParser: TypedCompoundValueParser<string> = (text) => text;
5
+
6
+ export const keywordsCompoundValueParser =
7
+ (keywords: string | KeywordsMap): TypedCompoundValueParser<boolean> =>
8
+ (text) =>
9
+ typeof keywords === 'string' ? text === keywords : keywords.has(text);
10
+
11
+ export const dimensionCompoundValueParser: TypedCompoundValueParser<Dimension> = (text) =>
12
+ parseDimension(text) ?? EMPTY_DIMENSION;
@@ -0,0 +1,5 @@
1
+ export * from './compound-css-data.js';
2
+ export * from './compound-types.js';
3
+ export * from './compound-parser-utils.js';
4
+ export * from './compound-mapper.js';
5
+ export * from './parsers/index.js';
@@ -0,0 +1 @@
1
+ export * from './shadow-compound.js';
@@ -0,0 +1,56 @@
1
+ import type { BoxShadowMap, TextShadowMap } from '../compound-css-data.js';
2
+ import type { GetCompoundParser } from '../compound-types.js';
3
+ import {
4
+ lengthDataType,
5
+ colorDataType,
6
+ insetDataType,
7
+ shadowSingleValueDataType,
8
+ INSET_KEYWORD,
9
+ } from '../../css-data-types/index.js';
10
+ import { unorderedListShorthandOpener, layersShorthandOpener } from '../../shorthands/index.js';
11
+ import { createCompoundParser } from '../compound-parser-utils.js';
12
+ import {
13
+ identityCompoundValueParser,
14
+ keywordsCompoundValueParser,
15
+ dimensionCompoundValueParser,
16
+ } from '../compound-value-parsers.js';
17
+
18
+ // box-shadow
19
+ export const parseBoxShadowCompound: GetCompoundParser<BoxShadowMap> = <V>() =>
20
+ createCompoundParser<V, BoxShadowMap>({
21
+ prop: 'box-shadow',
22
+ singleKeywordPart: {
23
+ prop: 'box-shadow',
24
+ dataType: shadowSingleValueDataType,
25
+ parser: identityCompoundValueParser,
26
+ },
27
+ parts: [
28
+ { prop: 'inset', dataType: insetDataType, parser: keywordsCompoundValueParser(INSET_KEYWORD) },
29
+ { prop: 'offset-x', dataType: lengthDataType, parser: dimensionCompoundValueParser, mandatory: true },
30
+ { prop: 'offset-y', dataType: lengthDataType, parser: dimensionCompoundValueParser, mandatory: true },
31
+ { prop: 'blur-radius', dataType: lengthDataType, parser: dimensionCompoundValueParser },
32
+ { prop: 'spread-radius', dataType: lengthDataType, parser: dimensionCompoundValueParser },
33
+ { prop: 'color', dataType: colorDataType, parser: identityCompoundValueParser },
34
+ ],
35
+ shorthandOpener: (astNodes, api, parts) =>
36
+ layersShorthandOpener('box-shadow', unorderedListShorthandOpener(parts), parts)(astNodes, api),
37
+ });
38
+
39
+ // text-shadow
40
+ export const parseTextShadowCompound: GetCompoundParser<TextShadowMap> = <V>() =>
41
+ createCompoundParser<V, TextShadowMap>({
42
+ prop: 'text-shadow',
43
+ singleKeywordPart: {
44
+ prop: 'text-shadow',
45
+ dataType: shadowSingleValueDataType,
46
+ parser: identityCompoundValueParser,
47
+ },
48
+ parts: [
49
+ { prop: 'offset-x', dataType: lengthDataType, parser: dimensionCompoundValueParser, mandatory: true },
50
+ { prop: 'offset-y', dataType: lengthDataType, parser: dimensionCompoundValueParser, mandatory: true },
51
+ { prop: 'blur-radius', dataType: lengthDataType, parser: dimensionCompoundValueParser },
52
+ { prop: 'color', dataType: colorDataType, parser: (text) => text },
53
+ ],
54
+ shorthandOpener: (astNodes, api, parts) =>
55
+ layersShorthandOpener('text-shadow', unorderedListShorthandOpener(parts), parts)(astNodes, api),
56
+ });