zyzz 0.0.3 → 0.0.6

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 (273) hide show
  1. package/README.md +34 -19
  2. package/dist/Config.d.ts +16 -167
  3. package/dist/Config.d.ts.map +1 -1
  4. package/dist/Config.js +7 -246
  5. package/dist/Config.js.map +1 -1
  6. package/dist/Style.d.ts +15 -12
  7. package/dist/Style.d.ts.map +1 -1
  8. package/dist/Style.js +51 -26
  9. package/dist/Style.js.map +1 -1
  10. package/dist/Vars.d.ts +114 -0
  11. package/dist/Vars.d.ts.map +1 -0
  12. package/dist/Vars.js +42 -0
  13. package/dist/Vars.js.map +1 -0
  14. package/dist/babel/index.d.ts +2 -0
  15. package/dist/babel/index.d.ts.map +1 -1
  16. package/dist/babel/index.js +10 -1
  17. package/dist/babel/index.js.map +1 -1
  18. package/dist/compiler/Graph.d.ts +2 -0
  19. package/dist/compiler/Graph.d.ts.map +1 -1
  20. package/dist/compiler/Graph.js +30 -9
  21. package/dist/compiler/Graph.js.map +1 -1
  22. package/dist/compiler/Native.d.ts +5 -5
  23. package/dist/compiler/Native.d.ts.map +1 -1
  24. package/dist/compiler/Native.js +21 -21
  25. package/dist/compiler/Native.js.map +1 -1
  26. package/dist/compiler/Source.d.ts +8 -6
  27. package/dist/compiler/Source.d.ts.map +1 -1
  28. package/dist/compiler/Source.js +52 -16
  29. package/dist/compiler/Source.js.map +1 -1
  30. package/dist/compiler/Transform.d.ts +1 -1
  31. package/dist/compiler/Transform.d.ts.map +1 -1
  32. package/dist/compiler/Transform.js +58 -22
  33. package/dist/compiler/Transform.js.map +1 -1
  34. package/dist/compiler/internal/Compositions.d.ts +5 -0
  35. package/dist/compiler/internal/Compositions.d.ts.map +1 -1
  36. package/dist/compiler/internal/Compositions.js +22 -3
  37. package/dist/compiler/internal/Compositions.js.map +1 -1
  38. package/dist/compiler/internal/Configurations.d.ts.map +1 -1
  39. package/dist/compiler/internal/Configurations.js +73 -12
  40. package/dist/compiler/internal/Configurations.js.map +1 -1
  41. package/dist/compiler/internal/Contract.d.ts +1 -1
  42. package/dist/compiler/internal/Contract.d.ts.map +1 -1
  43. package/dist/compiler/internal/Contract.js +155 -13
  44. package/dist/compiler/internal/Contract.js.map +1 -1
  45. package/dist/compiler/internal/Contributions.d.ts +1 -1
  46. package/dist/compiler/internal/Contributions.d.ts.map +1 -1
  47. package/dist/compiler/internal/Contributions.js +6 -4
  48. package/dist/compiler/internal/Contributions.js.map +1 -1
  49. package/dist/compiler/internal/Dynamic.js +1 -1
  50. package/dist/compiler/internal/Dynamic.js.map +1 -1
  51. package/dist/compiler/internal/Expression.d.ts +3 -0
  52. package/dist/compiler/internal/Expression.d.ts.map +1 -1
  53. package/dist/compiler/internal/Expression.js +21 -0
  54. package/dist/compiler/internal/Expression.js.map +1 -1
  55. package/dist/compiler/internal/Identifiers.d.ts +1 -1
  56. package/dist/compiler/internal/Identifiers.d.ts.map +1 -1
  57. package/dist/compiler/internal/Identifiers.js +2 -2
  58. package/dist/compiler/internal/Identifiers.js.map +1 -1
  59. package/dist/compiler/internal/NativeBindings.d.ts +1 -1
  60. package/dist/compiler/internal/NativeBindings.d.ts.map +1 -1
  61. package/dist/compiler/internal/NativeBindings.js +3 -3
  62. package/dist/compiler/internal/NativeBindings.js.map +1 -1
  63. package/dist/compiler/internal/PackedStyles.d.ts +1 -1
  64. package/dist/compiler/internal/PackedStyles.d.ts.map +1 -1
  65. package/dist/compiler/internal/PackedStyles.js +15 -25
  66. package/dist/compiler/internal/PackedStyles.js.map +1 -1
  67. package/dist/compiler/internal/Recipes.js +1 -1
  68. package/dist/compiler/internal/Recipes.js.map +1 -1
  69. package/dist/compiler/internal/Selectors.js +1 -1
  70. package/dist/compiler/internal/Selectors.js.map +1 -1
  71. package/dist/compiler/internal/Static.d.ts.map +1 -1
  72. package/dist/compiler/internal/Static.js +2 -0
  73. package/dist/compiler/internal/Static.js.map +1 -1
  74. package/dist/compiler/internal/Themes.d.ts +12 -3
  75. package/dist/compiler/internal/Themes.d.ts.map +1 -1
  76. package/dist/compiler/internal/Themes.js +192 -52
  77. package/dist/compiler/internal/Themes.js.map +1 -1
  78. package/dist/compiler/internal/{Variables.d.ts → Vars.d.ts} +1 -1
  79. package/dist/compiler/internal/Vars.d.ts.map +1 -0
  80. package/dist/compiler/internal/{Variables.js → Vars.js} +3 -3
  81. package/dist/compiler/internal/Vars.js.map +1 -0
  82. package/dist/default.d.ts +147 -2562
  83. package/dist/default.d.ts.map +1 -1
  84. package/dist/default.js +85 -80
  85. package/dist/default.js.map +2 -2
  86. package/dist/default.js.zyzz.json +1 -1
  87. package/dist/esbuild/index.d.ts +3 -0
  88. package/dist/esbuild/index.d.ts.map +1 -0
  89. package/dist/esbuild/index.js +5 -0
  90. package/dist/esbuild/index.js.map +1 -0
  91. package/dist/index.d.ts +4 -4
  92. package/dist/index.d.ts.map +1 -1
  93. package/dist/index.js +4 -4
  94. package/dist/index.js.map +1 -1
  95. package/dist/internal/Authoring.d.ts +1 -1
  96. package/dist/internal/Authoring.d.ts.map +1 -1
  97. package/dist/internal/Authoring.js +4 -4
  98. package/dist/internal/Authoring.js.map +1 -1
  99. package/dist/internal/Binding.d.ts +1 -1
  100. package/dist/internal/Binding.d.ts.map +1 -1
  101. package/dist/internal/Completion.d.ts +19 -0
  102. package/dist/internal/Completion.d.ts.map +1 -0
  103. package/dist/internal/Completion.js +2 -0
  104. package/dist/internal/Completion.js.map +1 -0
  105. package/dist/internal/Condition.d.ts +3 -1
  106. package/dist/internal/Condition.d.ts.map +1 -1
  107. package/dist/internal/Condition.js.map +1 -1
  108. package/dist/internal/Configuration.d.ts +248 -0
  109. package/dist/internal/Configuration.d.ts.map +1 -0
  110. package/dist/internal/Configuration.js +343 -0
  111. package/dist/internal/Configuration.js.map +1 -0
  112. package/dist/{Theme.d.ts → internal/Theme.d.ts} +15 -13
  113. package/dist/internal/Theme.d.ts.map +1 -0
  114. package/dist/{Theme.js → internal/Theme.js} +39 -12
  115. package/dist/internal/Theme.js.map +1 -0
  116. package/dist/internal/Token.d.ts +46 -16
  117. package/dist/internal/Token.d.ts.map +1 -1
  118. package/dist/internal/Token.js +89 -5
  119. package/dist/internal/Token.js.map +1 -1
  120. package/dist/internal/Typography.d.ts +13 -5
  121. package/dist/internal/Typography.d.ts.map +1 -1
  122. package/dist/internal/Typography.js +42 -6
  123. package/dist/internal/Typography.js.map +1 -1
  124. package/dist/internal/Value.d.ts +6 -1
  125. package/dist/internal/Value.d.ts.map +1 -1
  126. package/dist/internal/Value.js.map +1 -1
  127. package/dist/internal/VariableSets.d.ts +20 -0
  128. package/dist/internal/VariableSets.d.ts.map +1 -0
  129. package/dist/internal/VariableSets.js +317 -0
  130. package/dist/internal/VariableSets.js.map +1 -0
  131. package/dist/next/index.d.ts +8 -3
  132. package/dist/next/index.d.ts.map +1 -1
  133. package/dist/next/index.js +21 -10
  134. package/dist/next/index.js.map +1 -1
  135. package/dist/next/loader.d.ts +1 -0
  136. package/dist/next/loader.d.ts.map +1 -1
  137. package/dist/next/loader.js +25 -6
  138. package/dist/next/loader.js.map +1 -1
  139. package/dist/node/Host.d.ts.map +1 -1
  140. package/dist/node/Host.js +1 -1
  141. package/dist/node/Host.js.map +1 -1
  142. package/dist/node/Reset.d.ts +3 -0
  143. package/dist/node/Reset.d.ts.map +1 -0
  144. package/dist/node/Reset.js +7 -0
  145. package/dist/node/Reset.js.map +1 -0
  146. package/dist/react-native/Host.d.ts +2 -2
  147. package/dist/react-native/Host.d.ts.map +1 -1
  148. package/dist/react-native/Host.js +4 -4
  149. package/dist/react-native/Host.js.map +1 -1
  150. package/dist/react-native/StyleSheet.d.ts +9 -8
  151. package/dist/react-native/StyleSheet.d.ts.map +1 -1
  152. package/dist/react-native/StyleSheet.js +29 -23
  153. package/dist/react-native/StyleSheet.js.map +1 -1
  154. package/dist/react-native/Variants.d.ts +3 -3
  155. package/dist/react-native/Variants.d.ts.map +1 -1
  156. package/dist/react-native/Variants.js +2 -2
  157. package/dist/react-native/react.d.ts +1 -1
  158. package/dist/react-native/react.d.ts.map +1 -1
  159. package/dist/react-native/react.js +5 -5
  160. package/dist/react-native/react.js.map +1 -1
  161. package/dist/rollup/index.d.ts +3 -0
  162. package/dist/rollup/index.d.ts.map +1 -0
  163. package/dist/rollup/index.js +5 -0
  164. package/dist/rollup/index.js.map +1 -0
  165. package/dist/runtime/Appearance.d.ts +7 -7
  166. package/dist/runtime/Appearance.d.ts.map +1 -1
  167. package/dist/runtime/Appearance.js +15 -15
  168. package/dist/runtime/Appearance.js.map +1 -1
  169. package/dist/runtime/Dynamic.d.ts.map +1 -1
  170. package/dist/runtime/Dynamic.js +4 -1
  171. package/dist/runtime/Dynamic.js.map +1 -1
  172. package/dist/runtime/NativeContext.d.ts +4 -4
  173. package/dist/runtime/NativeContext.d.ts.map +1 -1
  174. package/dist/runtime/NativeContext.js +5 -5
  175. package/dist/runtime/NativeContext.js.map +1 -1
  176. package/dist/runtime/NativeDynamic.d.ts +1 -1
  177. package/dist/runtime/NativeDynamic.d.ts.map +1 -1
  178. package/dist/runtime/NativeDynamic.js.map +1 -1
  179. package/dist/runtime/Props.d.ts +1 -1
  180. package/dist/runtime/Props.js +3 -3
  181. package/dist/runtime/Props.js.map +1 -1
  182. package/dist/runtime/Selection.d.ts +14 -10
  183. package/dist/runtime/Selection.d.ts.map +1 -1
  184. package/dist/runtime/Selection.js +19 -18
  185. package/dist/runtime/Selection.js.map +1 -1
  186. package/dist/styleFunction.d.ts +14 -14
  187. package/dist/styleFunction.d.ts.map +1 -1
  188. package/dist/styleFunction.js.map +1 -1
  189. package/dist/unplugin/index.d.ts +22 -0
  190. package/dist/unplugin/index.d.ts.map +1 -0
  191. package/dist/unplugin/index.js +500 -0
  192. package/dist/unplugin/index.js.map +1 -0
  193. package/dist/variants.d.ts +3 -3
  194. package/dist/variants.d.ts.map +1 -1
  195. package/dist/variants.js.map +1 -1
  196. package/dist/vite/index.d.ts +2 -0
  197. package/dist/vite/index.d.ts.map +1 -1
  198. package/dist/vite/index.js +44 -12
  199. package/dist/vite/index.js.map +1 -1
  200. package/dist/web/Css.d.ts +4 -3
  201. package/dist/web/Css.d.ts.map +1 -1
  202. package/dist/web/Css.js +4 -4
  203. package/dist/web/Css.js.map +1 -1
  204. package/dist/web/internal/Themes.d.ts +3 -2
  205. package/dist/web/internal/Themes.d.ts.map +1 -1
  206. package/dist/web/internal/Themes.js +42 -6
  207. package/dist/web/internal/Themes.js.map +1 -1
  208. package/dist/webpack/index.d.ts +3 -0
  209. package/dist/webpack/index.d.ts.map +1 -0
  210. package/dist/webpack/index.js +5 -0
  211. package/dist/webpack/index.js.map +1 -0
  212. package/package.json +23 -2
  213. package/src/Config.ts +43 -685
  214. package/src/Style.ts +97 -34
  215. package/src/Vars.ts +299 -0
  216. package/src/babel/index.ts +23 -1
  217. package/src/compiler/Graph.ts +36 -9
  218. package/src/compiler/Native.ts +29 -32
  219. package/src/compiler/Source.ts +64 -22
  220. package/src/compiler/Transform.ts +73 -23
  221. package/src/compiler/internal/Compositions.ts +36 -3
  222. package/src/compiler/internal/Configurations.ts +83 -11
  223. package/src/compiler/internal/Contract.ts +207 -15
  224. package/src/compiler/internal/Contributions.ts +6 -3
  225. package/src/compiler/internal/Dynamic.ts +1 -1
  226. package/src/compiler/internal/Expression.ts +26 -0
  227. package/src/compiler/internal/Identifiers.ts +2 -1
  228. package/src/compiler/internal/NativeBindings.ts +3 -3
  229. package/src/compiler/internal/PackedStyles.ts +22 -26
  230. package/src/compiler/internal/Recipes.ts +1 -1
  231. package/src/compiler/internal/Selectors.ts +1 -1
  232. package/src/compiler/internal/Static.ts +1 -0
  233. package/src/compiler/internal/Themes.ts +266 -57
  234. package/src/compiler/internal/{Variables.ts → Vars.ts} +2 -2
  235. package/src/default.ts +173 -154
  236. package/src/esbuild/index.ts +5 -0
  237. package/src/index.ts +4 -4
  238. package/src/internal/Authoring.ts +5 -7
  239. package/src/internal/Binding.ts +1 -1
  240. package/src/internal/Completion.ts +42 -0
  241. package/src/internal/Condition.ts +31 -1
  242. package/src/internal/Configuration.ts +970 -0
  243. package/src/{Theme.ts → internal/Theme.ts} +75 -20
  244. package/src/internal/Token.ts +258 -85
  245. package/src/internal/Typography.ts +71 -16
  246. package/src/internal/Value.ts +45 -26
  247. package/src/internal/VariableSets.ts +458 -0
  248. package/src/next/index.ts +34 -12
  249. package/src/next/loader.ts +35 -6
  250. package/src/node/Host.ts +1 -2
  251. package/src/node/Reset.ts +7 -0
  252. package/src/react-native/Host.ts +6 -6
  253. package/src/react-native/StyleSheet.ts +49 -42
  254. package/src/react-native/Variants.ts +3 -3
  255. package/src/react-native/react.ts +6 -6
  256. package/src/rollup/index.ts +5 -0
  257. package/src/runtime/Appearance.ts +20 -20
  258. package/src/runtime/Dynamic.ts +4 -1
  259. package/src/runtime/NativeContext.ts +8 -8
  260. package/src/runtime/NativeDynamic.ts +2 -4
  261. package/src/runtime/Props.ts +3 -3
  262. package/src/runtime/Selection.ts +44 -33
  263. package/src/styleFunction.ts +22 -19
  264. package/src/unplugin/index.ts +604 -0
  265. package/src/variants.ts +7 -5
  266. package/src/vite/index.ts +48 -18
  267. package/src/web/Css.ts +10 -7
  268. package/src/web/internal/Themes.ts +52 -9
  269. package/src/webpack/index.ts +5 -0
  270. package/dist/Theme.d.ts.map +0 -1
  271. package/dist/Theme.js.map +0 -1
  272. package/dist/compiler/internal/Variables.d.ts.map +0 -1
  273. package/dist/compiler/internal/Variables.js.map +0 -1
@@ -1,15 +1,15 @@
1
1
  import type * as Binding from './internal/Binding.js';
2
+ import type * as Completion from './internal/Completion.js';
2
3
  import type * as Literal from './internal/Literal.js';
3
4
  import type * as Style from './Style.js';
4
- /** Restricts callback hints to inferred declarations instead of expanding every property grammar. */
5
- type CompletionProperties<styles = Record<string, unknown>> = {
6
- readonly [property in keyof typeof Literal.rules & keyof styles]?: Literal.Properties[property] | (string & {}) | number | object;
7
- };
8
5
  type Keys<value> = value extends unknown ? keyof value : never;
6
+ type InlineProperties<properties extends string> = {
7
+ readonly [property in properties]?: string | number | undefined;
8
+ };
9
9
  type VariableOptions<input> = input extends {
10
- readonly variables: infer variables;
10
+ readonly vars: infer variables;
11
11
  } ? {
12
- readonly variables: {
12
+ readonly vars: {
13
13
  readonly [key in keyof variables]: string extends key ? variables[key] : key extends `--${string}` ? variables[key] : never;
14
14
  };
15
15
  } : unknown;
@@ -20,8 +20,8 @@ type VariableOptions<input> = input extends {
20
20
  * @throws {Error} When a definition needs an explicit identity and none is supplied.
21
21
  */
22
22
  export declare function style(): style.ReturnType;
23
- export declare function style<const values extends Record<string, string | number>, const styles extends Record<string, unknown>, const callback extends (...args: never[]) => unknown>(styles: callback & ((values: values) => styles & NoInfer<Style.Accepted<styles, {}, true> & Binding.Checked<styles>>) & CompletionProperties<NoInfer<styles>>, ...options: Parameters<callback> extends [Record<string, string | number>] ? values extends Binding.Inputs<values> ? [options?: style.DefinitionOptions] : [invalid: never, unavailable: never] : [invalid: never, unavailable: never]): style.Dynamic<values>;
24
- export declare function style<const styles extends Record<string, unknown>>(styles: styles & NoInfer<Style.Accepted<styles, {}, true>> & CompletionProperties, options?: style.DefinitionOptions): style.ReturnType;
23
+ export declare function style<const values extends Record<string, string | number>, const styles extends Record<string, unknown>, const callback extends (...args: never[]) => unknown>(styles: callback & ((values: values) => styles & NoInfer<Style.Accepted<styles, {}, true> & Binding.Checked<styles>>) & Completion.Properties<{}, NoInfer<styles>>, ...options: Parameters<callback> extends [Record<string, string | number>] ? values extends Binding.Inputs<values> ? [options?: style.DefinitionOptions] : [invalid: never, unavailable: never] : [invalid: never, unavailable: never]): style.Dynamic<values>;
24
+ export declare function style<const styles extends Record<string, unknown>>(styles: styles & NoInfer<Style.Accepted<styles, {}, true>> & Completion.Properties, options?: style.DefinitionOptions): style.ReturnType;
25
25
  /** Compile-time brand identifying callable style definitions. */
26
26
  declare const identity: unique symbol;
27
27
  type Reference = {
@@ -34,17 +34,17 @@ export declare namespace style {
34
34
  readonly id?: string | undefined;
35
35
  };
36
36
  /** Callable compiled bindings with required scalar inputs and styling overrides. */
37
- type Dynamic<values, output extends Output = 'react'> = Reference & (<const input extends values & Options>(input: input & VariableOptions<input> & Record<Exclude<keyof input, keyof values | keyof Options>, never>) => Props<output>);
37
+ type Dynamic<values, output extends Output = 'react'> = Reference & (<const input extends values & Options<output>>(input: input & VariableOptions<input> & Record<Exclude<keyof input, keyof values | keyof Options>, never>) => Props<output>);
38
38
  /** Failure from executing source without a transform. */
39
39
  type ErrorType = Error;
40
40
  /** Styling overrides consumed by a transformed definition. */
41
- type Options = {
41
+ type Options<output extends Output = 'react'> = {
42
42
  /** External class names appended to the generated classes. */
43
43
  readonly className?: string | undefined;
44
- /** Literal inline styling overrides. */
45
- readonly style?: Literal.Properties | undefined;
44
+ /** Inline overrides. React accepts scalar values, while HTML requires CSS units. */
45
+ readonly style?: (output extends 'html' ? Literal.Properties : InlineProperties<keyof typeof Literal.rules> | InlineProperties<keyof Literal.Properties>) | undefined;
46
46
  /** Inline custom-property assignments, merged before explicit style overrides. */
47
- readonly variables?: Readonly<Record<`--${string}`, string | number | undefined>> | undefined;
47
+ readonly vars?: Readonly<Record<`--${string}`, string | number | undefined>> | undefined;
48
48
  };
49
49
  /** Props produced by a transformed web definition. */
50
50
  type Output = 'html' | 'react';
@@ -59,7 +59,7 @@ export declare namespace style {
59
59
  readonly style?: Readonly<Record<string, string | number | undefined>> | undefined;
60
60
  };
61
61
  /** Callable definition; source rewriting supplies its implementation. */
62
- type ReturnType<output extends Output = 'react'> = Reference & (<const options extends Options = Options>(options?: options & VariableOptions<options> & Record<Exclude<Keys<options>, keyof Options>, never>) => Props<output>);
62
+ type ReturnType<output extends Output = 'react'> = Reference & (<const options extends Options<output> = Options<output>>(options?: options & VariableOptions<options> & Record<Exclude<Keys<options>, keyof Options>, never>) => Props<output>);
63
63
  }
64
64
  /** Executed authoring source has not been rewritten. */
65
65
  export declare class MissingTransformError extends Error {
@@ -1 +1 @@
1
- {"version":3,"file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D,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,qEAAqE;IACrE,cAIC;IACD,yCAAyC;IAChC,IAAI,SAAgC;CAC9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"styleFunction.js","sourceRoot":"","sources":["../src/styleFunction.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,SAAS,MAAM,yBAAyB,CAAA;AA6DpD,MAAM,UAAU,KAAK,CACnB,MAAgB,EAChB,OAAO,GAA4B,EAAE;IAErC,OAAO,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAC1C,CAAC;AAyDD,wDAAwD;AACxD,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C,qEAAqE;IACrE;QACE,KAAK,CACH,yIAAyI,CAC1I,CAAA;IACH,CAAC;IACD,yCAAyC;IAChC,IAAI,GAAG,6BAA6B,CAAA;CAC9C"}
1
+ {"version":3,"file":"styleFunction.js","sourceRoot":"","sources":["../src/styleFunction.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,SAAS,MAAM,yBAAyB,CAAA;AA0DpD,MAAM,UAAU,KAAK,CACnB,MAAgB,EAChB,OAAO,GAA4B,EAAE;IAErC,OAAO,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAC1C,CAAC;AA+DD,wDAAwD;AACxD,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C,qEAAqE;IACrE;QACE,KAAK,CACH,yIAAyI,CAC1I,CAAA;IACH,CAAC;IACD,yCAAyC;IAChC,IAAI,GAAG,6BAA6B,CAAA;CAC9C"}
@@ -0,0 +1,22 @@
1
+ import * as Vite from '../vite/index.js';
2
+ /** Portable build configuration. Vite uses the options from `zyzz/vite` instead. */
3
+ export type Options = {
4
+ /** Rewrite authoring calls. Defaults to true. */
5
+ readonly compiler?: boolean | undefined;
6
+ /** Include the CSS reset. Defaults to false. */
7
+ readonly reset?: boolean | undefined;
8
+ /** Source directory scanned for modules and global contributions. Defaults to the working directory. */
9
+ readonly root?: string | undefined;
10
+ };
11
+ /** Bundler factories. Vite retains its native CSS delivery and environment-specific HMR. */
12
+ export declare const zyzz: {
13
+ /** Creates an esbuild plugin that emits stylesheets and watches source directories. */
14
+ esbuild: (options?: Options | undefined) => import("unplugin").EsbuildPlugin;
15
+ /** Creates a Rollup plugin with dependency-aware cached transforms. */
16
+ rollup: (options?: Options | undefined) => import("unplugin").RollupPlugin<any>;
17
+ /** Creates the existing Vite plugin with automatic CSS delivery and HMR. */
18
+ vite: typeof Vite.zyzz;
19
+ /** Creates a Webpack plugin that compiles before language loaders. */
20
+ webpack: (options?: Options | undefined) => import("webpack").WebpackPluginInstance;
21
+ };
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/unplugin/index.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAA;AAExC,oFAAoF;AACpF,MAAM,MAAM,OAAO,GAAG;IACpB,iDAAiD;IACjD,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IACvC,gDAAgD;IAChD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IACpC,wGAAwG;IACxG,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACnC,CAAA;AAgjBD,4FAA4F;AAC5F,eAAO,MAAM,IAAI;IACf,uFAAuF;IACvF,OAAO;IACP,uEAAuE;IACvE,MAAM;IACN,4EAA4E;IAC5E,IAAI;IACJ,sEAAsE;IACtE,OAAO;CACR,CAAA"}
@@ -0,0 +1,500 @@
1
+ /** Connects the static compiler to portable bundler hooks and the Vite adapter. @module */
2
+ import * as Mapping from '@jridgewell/gen-mapping';
3
+ import * as Crypto from 'node:crypto';
4
+ import * as Fs from 'node:fs/promises';
5
+ import * as Path from 'node:path';
6
+ import * as Reset from '../node/Reset.js';
7
+ import * as Parser from 'oxc-parser';
8
+ import { createUnplugin } from 'unplugin';
9
+ import * as Graph from '../compiler/Graph.js';
10
+ import * as AtRules from '../compiler/internal/AtRules.js';
11
+ import * as Catalogs from '../compiler/internal/Catalogs.js';
12
+ import * as Contract from '../compiler/internal/Contract.js';
13
+ import * as Vite from '../vite/index.js';
14
+ const excludedPattern = /\.(?:d|test|test-d|bench|bench-d)\.[cm]?[jt]sx?$/;
15
+ const sourcePattern = /\.[cm]?[jt]sx?$/;
16
+ const portable = createUnplugin((options = {}, meta) => {
17
+ const root = Path.resolve(options.root ?? process.cwd());
18
+ const compiler = Graph.create();
19
+ let graph;
20
+ let pending;
21
+ let files = new Set();
22
+ let directories = new Set();
23
+ let sources = new Map();
24
+ let assets = new Map();
25
+ let css = '';
26
+ let cssMap = '';
27
+ let script = '';
28
+ function identity(file) {
29
+ return `app/${Path.relative(root, file).split(Path.sep).join('/')}`;
30
+ }
31
+ function emit(context) {
32
+ if (!graph)
33
+ return;
34
+ for (const [fileName, source] of assets)
35
+ context.emitFile({
36
+ type: 'asset',
37
+ fileName,
38
+ source: Uint8Array.from(source),
39
+ });
40
+ context.emitFile({
41
+ type: 'asset',
42
+ fileName: 'zyzz.css',
43
+ source: `${css}/*# sourceMappingURL=zyzz.css.map */\n`,
44
+ });
45
+ context.emitFile({
46
+ type: 'asset',
47
+ fileName: 'zyzz.css.map',
48
+ source: cssMap,
49
+ });
50
+ context.emitFile({
51
+ type: 'asset',
52
+ fileName: 'zyzz.js',
53
+ source: script || '/* No saved theme selections. */\n',
54
+ });
55
+ }
56
+ function transform(code, id) {
57
+ const output = graph?.modules[identity(id)];
58
+ if (!output)
59
+ return;
60
+ if (code !== sources.get(id))
61
+ throw new Error(`Zyzz must run before source transforms: ${id}`);
62
+ return {
63
+ code: output.code,
64
+ map: JSON.stringify({
65
+ ...output.map,
66
+ sources: output.map.sources.map((source) => source?.startsWith('app/')
67
+ ? Path.join(root, source.slice(4))
68
+ : source),
69
+ }),
70
+ };
71
+ }
72
+ return {
73
+ buildEnd: meta.framework === 'webpack'
74
+ ? undefined
75
+ : function () {
76
+ emit(this);
77
+ },
78
+ async buildStart() {
79
+ pending = (async () => {
80
+ graph = undefined;
81
+ files = new Set();
82
+ directories = new Set();
83
+ sources = new Map();
84
+ assets = new Map();
85
+ const modules = Object.create(null);
86
+ const imports = Object.create(null);
87
+ const contracts = Object.create(null);
88
+ async function scan(directory) {
89
+ directories.add(directory);
90
+ const entries = await Fs.readdir(directory, { withFileTypes: true });
91
+ for (const entry of entries.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)) {
92
+ if (entry.name.startsWith('.') ||
93
+ [
94
+ 'node_modules',
95
+ 'dist',
96
+ 'build',
97
+ 'coverage',
98
+ 'test',
99
+ 'tests',
100
+ '__tests__',
101
+ 'fixtures',
102
+ '__fixtures__',
103
+ ].includes(entry.name))
104
+ continue;
105
+ const file = Path.join(directory, entry.name);
106
+ if (entry.isDirectory())
107
+ await scan(file);
108
+ else if (entry.isFile() &&
109
+ sourcePattern.test(file) &&
110
+ !excludedPattern.test(file)) {
111
+ const source = await Fs.readFile(file, 'utf8');
112
+ files.add(file);
113
+ sources.set(file, source);
114
+ modules[identity(file)] = source;
115
+ }
116
+ }
117
+ }
118
+ const resolve = async (specifier, importer) => {
119
+ if ('resolve' in this && typeof this.resolve === 'function') {
120
+ const result = await this.resolve(specifier, importer);
121
+ return result && !result.external ? result.id : undefined;
122
+ }
123
+ const native = this.getNativeBuildContext?.();
124
+ if (native?.framework === 'esbuild') {
125
+ const result = await native.build.resolve(specifier, {
126
+ importer,
127
+ kind: 'import-statement',
128
+ resolveDir: Path.dirname(importer),
129
+ });
130
+ if (result.errors.length)
131
+ throw new Error(result.errors.map((error) => error.text).join('\n'));
132
+ return result.external ? undefined : result.path;
133
+ }
134
+ if (native?.framework === 'webpack') {
135
+ const resolver = native.compiler.resolverFactory.get('normal', {
136
+ dependencyType: 'esm',
137
+ });
138
+ return new Promise((accept, reject) => {
139
+ resolver.resolve({}, Path.dirname(importer), specifier, {}, (error, result) => {
140
+ if (error)
141
+ reject(error);
142
+ else
143
+ accept(result || undefined);
144
+ });
145
+ });
146
+ }
147
+ throw new Error('The bundler does not expose module resolution.');
148
+ };
149
+ async function contract(file, required = false) {
150
+ if (Object.hasOwn(contracts, file))
151
+ return true;
152
+ const sidecar = `${file}.zyzz.json`;
153
+ files.add(sidecar);
154
+ try {
155
+ contracts[file] = await Fs.readFile(sidecar, 'utf8');
156
+ }
157
+ catch (error) {
158
+ if (!required &&
159
+ error.code === 'ENOENT')
160
+ return false;
161
+ throw error;
162
+ }
163
+ const metadata = Contract.read(contracts[file], new Map(), file);
164
+ for (const section of metadata.stylesheets) {
165
+ let owner = file;
166
+ for (const specifier of section.dependency ?? []) {
167
+ const target = await resolve(specifier, owner);
168
+ if (!target)
169
+ throw new Error(`Unable to resolve packed stylesheet dependency: ${specifier}`);
170
+ (imports[owner] ??= Object.create(null))[specifier] = target;
171
+ await contract(target, true);
172
+ owner = target;
173
+ }
174
+ }
175
+ return true;
176
+ }
177
+ await scan(root);
178
+ for (const [file, source] of sources) {
179
+ const links = (imports[identity(file)] = Object.create(null));
180
+ for (const node of Parser.parseSync(file, source, {
181
+ sourceType: 'module',
182
+ }).program.body) {
183
+ if ((node.type !== 'ImportDeclaration' &&
184
+ node.type !== 'ExportNamedDeclaration' &&
185
+ node.type !== 'ExportAllDeclaration') ||
186
+ !node.source)
187
+ continue;
188
+ if (node.type === 'ImportDeclaration'
189
+ ? node.importKind === 'type'
190
+ : node.exportKind === 'type')
191
+ continue;
192
+ if ('specifiers' in node &&
193
+ node.specifiers.length &&
194
+ node.specifiers.every((specifier) => specifier.type === 'ImportSpecifier'
195
+ ? specifier.importKind === 'type'
196
+ : specifier.type === 'ExportSpecifier' &&
197
+ specifier.exportKind === 'type'))
198
+ continue;
199
+ const specifier = node.source.value;
200
+ links[specifier] = null;
201
+ if (specifier === 'zyzz' ||
202
+ (specifier.startsWith('zyzz/') &&
203
+ specifier !== 'zyzz/default') ||
204
+ /^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(specifier) ||
205
+ specifier.includes('?'))
206
+ continue;
207
+ const target = await resolve(specifier, file);
208
+ if (!target || !sourcePattern.test(target))
209
+ continue;
210
+ files.add(target);
211
+ if (sources.has(target))
212
+ links[specifier] = identity(target);
213
+ else if (await contract(target))
214
+ links[specifier] = target;
215
+ }
216
+ }
217
+ const result = compiler.compile({
218
+ compiler: options.compiler,
219
+ reset: options.reset ? Reset.read() : undefined,
220
+ contracts,
221
+ imports,
222
+ modules,
223
+ });
224
+ const copied = new Map();
225
+ const owners = new Map();
226
+ async function owner(id) {
227
+ if (id.startsWith('app/'))
228
+ return Fs.realpath(root);
229
+ const cached = owners.get(id);
230
+ if (cached)
231
+ return cached;
232
+ let directory = Path.dirname(id);
233
+ for (;;) {
234
+ try {
235
+ await Fs.access(Path.join(directory, 'package.json'));
236
+ const real = await Fs.realpath(directory);
237
+ owners.set(id, real);
238
+ return real;
239
+ }
240
+ catch (error) {
241
+ if (error.code !== 'ENOENT')
242
+ throw error;
243
+ const parent = Path.dirname(directory);
244
+ if (parent === directory)
245
+ throw new Error('Packed assets require an owning package.json.');
246
+ directory = parent;
247
+ }
248
+ }
249
+ }
250
+ async function copy(file, boundary) {
251
+ const real = await Fs.realpath(file);
252
+ if (!inside(boundary, real))
253
+ throw new Error('Asset path escapes its owning package.');
254
+ files.add(real);
255
+ const cached = copied.get(real);
256
+ if (cached)
257
+ return cached;
258
+ const content = await Fs.readFile(real);
259
+ const name = `zyzz-assets/${Crypto.hash('sha256', real + '\0' + content.toString('base64')).slice(0, 16)}${Path.extname(real)}`;
260
+ copied.set(real, name);
261
+ if (real.endsWith('.css')) {
262
+ const processed = await stylesheet(content.toString(), undefined, real, boundary, Path.posix.dirname(name));
263
+ assets.set(name, processed.code);
264
+ }
265
+ else
266
+ assets.set(name, content);
267
+ return name;
268
+ }
269
+ async function stylesheet(source, map, file, boundary, outputDirectory = '.', targets) {
270
+ const urls = new Set();
271
+ AtRules.transform({
272
+ code: Buffer.from(source),
273
+ filename: file,
274
+ visitor: {
275
+ Rule(rule) {
276
+ if (rule.type === 'import')
277
+ urls.add(rule.value.url);
278
+ },
279
+ Url(url) {
280
+ urls.add(url.url);
281
+ },
282
+ },
283
+ });
284
+ const replacements = new Map();
285
+ for (const url of urls) {
286
+ const target = targets?.[url];
287
+ if (!target &&
288
+ (!url || /^(?:[a-z][a-z\d+.-]*:|[/?#])/i.test(url)))
289
+ continue;
290
+ const raw = (target ?? url).split(/[?#]/)[0];
291
+ const path = (() => {
292
+ if (!target)
293
+ return Path.resolve(Path.dirname(file), decodeURIComponent(raw));
294
+ if (raw.startsWith('app/'))
295
+ return Path.join(root, decodeURIComponent(raw.slice(4)));
296
+ return decodeURIComponent(raw);
297
+ })();
298
+ const assetOwner = target
299
+ ? await owner(result.sharedAssetOwners?.[url] ?? 'app/')
300
+ : boundary;
301
+ const name = await copy(path, assetOwner);
302
+ replacements.set(url, Path.posix.relative(outputDirectory, name) +
303
+ (target ?? url).slice(raw.length));
304
+ }
305
+ return AtRules.transform({
306
+ code: Buffer.from(source),
307
+ filename: file,
308
+ ...(map === undefined
309
+ ? {}
310
+ : { inputSourceMap: map, sourceMap: true }),
311
+ visitor: {
312
+ Rule(rule) {
313
+ if (rule.type !== 'import')
314
+ return;
315
+ const url = replacements.get(rule.value.url);
316
+ if (url)
317
+ return AtRules.relocateImport(rule.value, url);
318
+ },
319
+ Url(url) {
320
+ const target = replacements.get(url.url);
321
+ if (target)
322
+ return { ...url, url: target };
323
+ },
324
+ },
325
+ });
326
+ }
327
+ const shared = await stylesheet(result.sharedCss ?? '', JSON.stringify(result.sharedCssMap ??
328
+ Mapping.toEncodedMap(new Mapping.GenMapping())), Path.join(root, 'zyzz.css'), await Fs.realpath(root), '.', result.sharedAssets);
329
+ const chunks = [
330
+ {
331
+ code: Buffer.from(shared.code).toString(),
332
+ map: Buffer.from(shared.map).toString(),
333
+ },
334
+ ];
335
+ const seen = new Set();
336
+ async function visit(id) {
337
+ if (seen.has(id))
338
+ return;
339
+ seen.add(id);
340
+ for (const dependency of result.dependencies[id] ?? [])
341
+ await visit(dependency);
342
+ const output = result.modules[id];
343
+ if (output) {
344
+ const processed = await stylesheet(output.css, JSON.stringify(output.cssMap), Path.join(root, id.slice(4)), await Fs.realpath(root));
345
+ chunks.push({
346
+ code: Buffer.from(processed.code).toString(),
347
+ map: Buffer.from(processed.map).toString(),
348
+ });
349
+ }
350
+ }
351
+ const ids = Object.keys(result.modules);
352
+ const imported = new Set(Object.values(result.dependencies).flat());
353
+ for (const id of ids)
354
+ if (!imported.has(id))
355
+ await visit(id);
356
+ for (const id of ids)
357
+ await visit(id);
358
+ const map = new Mapping.GenMapping({ file: 'zyzz.css' });
359
+ let line = 0;
360
+ css = '';
361
+ for (const chunk of chunks) {
362
+ if (!chunk.code)
363
+ continue;
364
+ const traced = Mapping.fromMap(chunk.map);
365
+ for (const mapping of Mapping.allMappings(traced)) {
366
+ const generated = {
367
+ line: mapping.generated.line + line,
368
+ column: mapping.generated.column,
369
+ };
370
+ if (mapping.source !== undefined &&
371
+ mapping.original !== undefined) {
372
+ const location = {
373
+ generated,
374
+ original: mapping.original,
375
+ source: mapping.source.startsWith('app/')
376
+ ? Path.join(root, mapping.source.slice(4))
377
+ : mapping.source,
378
+ };
379
+ if (mapping.name === undefined)
380
+ Mapping.addMapping(map, location);
381
+ else
382
+ Mapping.addMapping(map, { ...location, name: mapping.name });
383
+ }
384
+ else
385
+ Mapping.addMapping(map, { generated });
386
+ }
387
+ const encoded = Mapping.toEncodedMap(traced);
388
+ encoded.sources.forEach((source, index) => {
389
+ if (source !== null)
390
+ Mapping.setSourceContent(map, source.startsWith('app/')
391
+ ? Path.join(root, source.slice(4))
392
+ : source, encoded.sourcesContent?.[index] ?? null);
393
+ });
394
+ css += chunk.code + '\n';
395
+ line += chunk.code.split('\n').length;
396
+ }
397
+ cssMap = JSON.stringify(Mapping.toEncodedMap(map));
398
+ script = Catalogs.scripts(Object.values({ ...contracts, ...result.contracts }).flatMap(Catalogs.read)).join('\n');
399
+ graph = result;
400
+ if (meta.framework === 'webpack')
401
+ emit(this);
402
+ if (meta.framework === 'rollup')
403
+ for (const file of [...files, ...directories])
404
+ this.addWatchFile(file);
405
+ })();
406
+ await pending;
407
+ },
408
+ enforce: 'pre',
409
+ esbuild: {
410
+ config(options) {
411
+ if (!options.outdir || options.write === false)
412
+ throw new Error('Zyzz requires esbuild outdir and write: true to emit CSS assets.');
413
+ options.outdir = Path.resolve(options.absWorkingDir ?? process.cwd(), options.outdir);
414
+ },
415
+ setup(build) {
416
+ // Unplugin forwards watchFiles but not watchDirs from its transform hook.
417
+ build.onLoad({ filter: sourcePattern }, async ({ path }) => {
418
+ await pending;
419
+ if (!sources.has(path))
420
+ return;
421
+ const output = transform(await Fs.readFile(path, 'utf8'), path);
422
+ if (!output)
423
+ return;
424
+ return {
425
+ contents: `${output.code}\n//# sourceMappingURL=data:application/json;base64,${Buffer.from(output.map).toString('base64')}`,
426
+ loader: (() => {
427
+ if (path.endsWith('.tsx'))
428
+ return 'tsx';
429
+ if (path.endsWith('.jsx'))
430
+ return 'jsx';
431
+ if (/\.[cm]?ts$/.test(path))
432
+ return 'ts';
433
+ return 'js';
434
+ })(),
435
+ resolveDir: Path.dirname(path),
436
+ watchDirs: [...directories],
437
+ watchFiles: [...files],
438
+ };
439
+ });
440
+ },
441
+ },
442
+ name: 'zyzz',
443
+ rollup: {
444
+ shouldTransformCachedModule() {
445
+ return true;
446
+ },
447
+ },
448
+ transform: {
449
+ filter: {
450
+ id: {
451
+ include: sourcePattern,
452
+ exclude: /(?:^|[/\\])node_modules[/\\]|\.(?:d|test|test-d|bench|bench-d)\.[cm]?[jt]sx?$/,
453
+ },
454
+ },
455
+ async handler(code, id) {
456
+ await pending;
457
+ const output = transform(code, id);
458
+ if (!output)
459
+ return;
460
+ for (const file of files)
461
+ this.addWatchFile(file);
462
+ const native = this.getNativeBuildContext?.();
463
+ for (const directory of directories) {
464
+ if (native?.framework === 'webpack')
465
+ native.loaderContext?.addContextDependency(directory);
466
+ else if (meta.framework === 'rollup')
467
+ this.addWatchFile(directory);
468
+ }
469
+ return output;
470
+ },
471
+ },
472
+ webpack(compiler) {
473
+ compiler.hooks.watchRun.tap('zyzz', () => {
474
+ // Directory invalidations must also discard cached source reads before the graph and loaders rebuild.
475
+ for (const file of compiler.modifiedFiles ?? [])
476
+ if (directories.has(file))
477
+ compiler.inputFileSystem?.purge?.(file);
478
+ });
479
+ },
480
+ };
481
+ });
482
+ /** Bundler factories. Vite retains its native CSS delivery and environment-specific HMR. */
483
+ export const zyzz = {
484
+ /** Creates an esbuild plugin that emits stylesheets and watches source directories. */
485
+ esbuild: portable.esbuild,
486
+ /** Creates a Rollup plugin with dependency-aware cached transforms. */
487
+ rollup: portable.rollup,
488
+ /** Creates the existing Vite plugin with automatic CSS delivery and HMR. */
489
+ vite: Vite.zyzz,
490
+ /** Creates a Webpack plugin that compiles before language loaders. */
491
+ webpack: portable.webpack,
492
+ };
493
+ function inside(parent, child) {
494
+ const relative = Path.relative(parent, child);
495
+ return (relative === '' ||
496
+ (relative !== '..' &&
497
+ !relative.startsWith(`..${Path.sep}`) &&
498
+ !Path.isAbsolute(relative)));
499
+ }
500
+ //# sourceMappingURL=index.js.map