@czap/vite 0.1.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 (78) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -0
  3. package/dist/css-quantize.d.ts +53 -0
  4. package/dist/css-quantize.d.ts.map +1 -0
  5. package/dist/css-quantize.js +247 -0
  6. package/dist/css-quantize.js.map +1 -0
  7. package/dist/environments.d.ts +36 -0
  8. package/dist/environments.d.ts.map +1 -0
  9. package/dist/environments.js +67 -0
  10. package/dist/environments.js.map +1 -0
  11. package/dist/hmr.d.ts +37 -0
  12. package/dist/hmr.d.ts.map +1 -0
  13. package/dist/hmr.js +84 -0
  14. package/dist/hmr.js.map +1 -0
  15. package/dist/html-transform.d.ts +19 -0
  16. package/dist/html-transform.d.ts.map +1 -0
  17. package/dist/html-transform.js +54 -0
  18. package/dist/html-transform.js.map +1 -0
  19. package/dist/index.d.ts +51 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +43 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/normalize-css-eol.d.ts +7 -0
  24. package/dist/normalize-css-eol.d.ts.map +1 -0
  25. package/dist/normalize-css-eol.js +9 -0
  26. package/dist/normalize-css-eol.js.map +1 -0
  27. package/dist/plugin.d.ts +48 -0
  28. package/dist/plugin.d.ts.map +1 -0
  29. package/dist/plugin.js +404 -0
  30. package/dist/plugin.js.map +1 -0
  31. package/dist/primitive-resolve.d.ts +56 -0
  32. package/dist/primitive-resolve.d.ts.map +1 -0
  33. package/dist/primitive-resolve.js +71 -0
  34. package/dist/primitive-resolve.js.map +1 -0
  35. package/dist/resolve-fs.d.ts +13 -0
  36. package/dist/resolve-fs.d.ts.map +1 -0
  37. package/dist/resolve-fs.js +80 -0
  38. package/dist/resolve-fs.js.map +1 -0
  39. package/dist/resolve-utils.d.ts +20 -0
  40. package/dist/resolve-utils.d.ts.map +1 -0
  41. package/dist/resolve-utils.js +45 -0
  42. package/dist/resolve-utils.js.map +1 -0
  43. package/dist/style-transform.d.ts +49 -0
  44. package/dist/style-transform.d.ts.map +1 -0
  45. package/dist/style-transform.js +122 -0
  46. package/dist/style-transform.js.map +1 -0
  47. package/dist/theme-transform.d.ts +44 -0
  48. package/dist/theme-transform.d.ts.map +1 -0
  49. package/dist/theme-transform.js +85 -0
  50. package/dist/theme-transform.js.map +1 -0
  51. package/dist/token-transform.d.ts +42 -0
  52. package/dist/token-transform.d.ts.map +1 -0
  53. package/dist/token-transform.js +84 -0
  54. package/dist/token-transform.js.map +1 -0
  55. package/dist/virtual-modules.d.ts +55 -0
  56. package/dist/virtual-modules.d.ts.map +1 -0
  57. package/dist/virtual-modules.js +141 -0
  58. package/dist/virtual-modules.js.map +1 -0
  59. package/dist/wasm-resolve.d.ts +25 -0
  60. package/dist/wasm-resolve.d.ts.map +1 -0
  61. package/dist/wasm-resolve.js +36 -0
  62. package/dist/wasm-resolve.js.map +1 -0
  63. package/package.json +63 -0
  64. package/src/css-quantize.ts +294 -0
  65. package/src/environments.ts +98 -0
  66. package/src/hmr.ts +121 -0
  67. package/src/html-transform.ts +61 -0
  68. package/src/index.ts +71 -0
  69. package/src/normalize-css-eol.ts +8 -0
  70. package/src/plugin.ts +492 -0
  71. package/src/primitive-resolve.ts +106 -0
  72. package/src/resolve-fs.ts +82 -0
  73. package/src/resolve-utils.ts +54 -0
  74. package/src/style-transform.ts +157 -0
  75. package/src/theme-transform.ts +119 -0
  76. package/src/token-transform.ts +117 -0
  77. package/src/virtual-modules.ts +160 -0
  78. package/src/wasm-resolve.ts +54 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 Eassa Ayoub <eassa@heyoub.dev>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # @czap/vite
2
+
3
+ Vite 8 plugin: @token/@theme/@style/@quantize CSS transforms + HMR.
4
+
5
+ ## Docs
6
+
7
+ - [Naming & vocabulary](../../docs/GLOSSARY.md) — LiteShip, CZAP, `@czap/*`
8
+
9
+ - [API reference](https://github.com/heyoub/LiteShip/tree/main/docs/api/vite/) — generated from source TSDoc
10
+ - [Architecture index](https://github.com/heyoub/LiteShip/blob/main/docs/ARCHITECTURE.md)
11
+ - [ADRs](https://github.com/heyoub/LiteShip/tree/main/docs/adr/)
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ pnpm add @czap/vite
17
+ ```
18
+
19
+ ## Part of [LiteShip](https://github.com/heyoub/LiteShip#readme)
@@ -0,0 +1,53 @@
1
+ /**
2
+ * `@quantize` CSS block parser and compiler.
3
+ *
4
+ * Parses custom `@quantize boundaryName { state { prop: value } }` blocks
5
+ * from CSS source and compiles them into native `@container` queries using
6
+ * resolved `BoundaryDef` thresholds.
7
+ *
8
+ * @module
9
+ */
10
+ import type { Boundary } from '@czap/core';
11
+ /**
12
+ * A single parsed `@quantize` block: the boundary being quantised, the
13
+ * per-state property bag, and provenance info so HMR can emit
14
+ * source-mapped warnings.
15
+ */
16
+ export interface QuantizeBlock {
17
+ /** Boundary name referenced in the at-rule preamble. */
18
+ readonly boundaryName: string;
19
+ /** `{ stateName: { cssProp: value } }` mapping. */
20
+ readonly states: Record<string, Record<string, string>>;
21
+ /** Absolute path of the CSS source file. */
22
+ readonly sourceFile: string;
23
+ /** 1-based source line where the block begins. */
24
+ readonly line: number;
25
+ }
26
+ /**
27
+ * Parse every `@quantize` block from CSS source text.
28
+ *
29
+ * Grammar:
30
+ *
31
+ * ```css
32
+ * @quantize boundaryName {
33
+ * stateName {
34
+ * property: value;
35
+ * }
36
+ * }
37
+ * ```
38
+ *
39
+ * The outer `@quantize` and state-name matching is line-based for
40
+ * simplicity; property declarations inside state blocks use a
41
+ * character-level parser so that multi-line values (e.g.
42
+ * `linear-gradient` spread across lines) are collected correctly
43
+ * before being matched.
44
+ */
45
+ export declare function parseQuantizeBlocks(css: string, sourceFile: string): readonly QuantizeBlock[];
46
+ /**
47
+ * Compile a parsed {@link QuantizeBlock} plus its resolved
48
+ * {@link Boundary.Shape} into CSS `@container` query rules. Delegates
49
+ * to the canonical `CSSCompiler` to avoid duplicating threshold-to-query
50
+ * logic.
51
+ */
52
+ export declare function compileQuantizeBlock(block: QuantizeBlock, boundary: Boundary.Shape): string;
53
+ //# sourceMappingURL=css-quantize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-quantize.d.ts","sourceRoot":"","sources":["../src/css-quantize.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAQ3C;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,wDAAwD;IACxD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,mDAAmD;IACnD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACxD,4CAA4C;IAC5C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAsJD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,aAAa,EAAE,CA6E7F;AAMD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,CAAC,KAAK,GAAG,MAAM,CAG3F"}
@@ -0,0 +1,247 @@
1
+ /**
2
+ * `@quantize` CSS block parser and compiler.
3
+ *
4
+ * Parses custom `@quantize boundaryName { state { prop: value } }` blocks
5
+ * from CSS source and compiles them into native `@container` queries using
6
+ * resolved `BoundaryDef` thresholds.
7
+ *
8
+ * @module
9
+ */
10
+ import { CSSCompiler } from '@czap/compiler';
11
+ import { normalizeCssLineEndings } from './normalize-css-eol.js';
12
+ // ---------------------------------------------------------------------------
13
+ // Parser helpers
14
+ // ---------------------------------------------------------------------------
15
+ /**
16
+ * Parse all property declarations inside a state block starting at `pos`
17
+ * (the character immediately after the opening `{` of the state block).
18
+ *
19
+ * Uses character-level scanning so multi-line values -- e.g.
20
+ * background: linear-gradient(
21
+ * to bottom,
22
+ * red,
23
+ * blue
24
+ * );
25
+ * -- are collected as a single declaration before matching.
26
+ *
27
+ * Tracks paren depth so commas/semicolons inside functional notation
28
+ * (var(), calc(), linear-gradient(), etc.) are not treated as delimiters.
29
+ * Tracks brace depth so values containing braces (e.g. `var(--x, empty)`)
30
+ * do not prematurely close the state block.
31
+ *
32
+ * Returns the parsed properties and the position immediately after the
33
+ * closing `}` of the state block.
34
+ */
35
+ function parseStateDeclarations(css, pos) {
36
+ const props = {};
37
+ let braceDepth = 0;
38
+ while (pos < css.length) {
39
+ // Skip whitespace between declarations
40
+ while (pos < css.length && /\s/.test(css[pos]))
41
+ pos++;
42
+ if (pos >= css.length)
43
+ break;
44
+ const ch = css[pos];
45
+ // Skip block comments
46
+ if (ch === '/' && css[pos + 1] === '*') {
47
+ pos += 2;
48
+ while (pos < css.length - 1 && !(css[pos] === '*' && css[pos + 1] === '/'))
49
+ pos++;
50
+ pos += 2;
51
+ continue;
52
+ }
53
+ // Closing brace of the state block
54
+ if (ch === '}' && braceDepth === 0) {
55
+ pos++;
56
+ return { props, end: pos };
57
+ }
58
+ // Opening brace nested inside a value (e.g. var(--x, {}))
59
+ if (ch === '{') {
60
+ braceDepth++;
61
+ pos++;
62
+ continue;
63
+ }
64
+ if (ch === '}') {
65
+ braceDepth--;
66
+ pos++;
67
+ continue;
68
+ }
69
+ // Accumulate a full declaration: collect until `;` at paren-depth 0,
70
+ // or until `}` that closes this state block, whichever comes first.
71
+ let declBuf = '';
72
+ let parenDepth = 0;
73
+ while (pos < css.length) {
74
+ const dc = css[pos];
75
+ // Skip block comments inside declaration
76
+ if (dc === '/' && css[pos + 1] === '*') {
77
+ pos += 2;
78
+ while (pos < css.length - 1 && !(css[pos] === '*' && css[pos + 1] === '/'))
79
+ pos++;
80
+ pos += 2;
81
+ continue;
82
+ }
83
+ // Skip quoted strings
84
+ if (dc === '"' || dc === "'") {
85
+ const quote = dc;
86
+ declBuf += dc;
87
+ pos++;
88
+ while (pos < css.length && css[pos] !== quote) {
89
+ if (css[pos] === '\\') {
90
+ declBuf += css[pos];
91
+ pos++;
92
+ }
93
+ declBuf += css[pos];
94
+ pos++;
95
+ }
96
+ if (pos < css.length) {
97
+ declBuf += css[pos];
98
+ pos++;
99
+ }
100
+ continue;
101
+ }
102
+ if (dc === '(') {
103
+ parenDepth++;
104
+ declBuf += dc;
105
+ pos++;
106
+ continue;
107
+ }
108
+ if (dc === ')') {
109
+ parenDepth--;
110
+ declBuf += dc;
111
+ pos++;
112
+ continue;
113
+ }
114
+ // Semicolon at paren-depth 0 ends the declaration
115
+ if (dc === ';' && parenDepth === 0) {
116
+ pos++;
117
+ break;
118
+ }
119
+ // Unmatched `}` at paren-depth 0 closes the state block --
120
+ // do NOT consume it here; the outer loop will handle it.
121
+ if (dc === '}' && parenDepth === 0) {
122
+ break;
123
+ }
124
+ declBuf += dc;
125
+ pos++;
126
+ }
127
+ const decl = declBuf.trim();
128
+ if (decl.length === 0)
129
+ continue;
130
+ // Match `property-name: value` (property names are [a-zA-Z-][a-zA-Z0-9-]*)
131
+ const colonIdx = decl.indexOf(':');
132
+ if (colonIdx > 0) {
133
+ const propName = decl.slice(0, colonIdx).trim();
134
+ const propValue = decl.slice(colonIdx + 1).trim();
135
+ if (/^[a-zA-Z-][a-zA-Z0-9-]*$/.test(propName) && propValue.length > 0) {
136
+ props[propName] = propValue;
137
+ }
138
+ }
139
+ }
140
+ return { props, end: pos };
141
+ }
142
+ // ---------------------------------------------------------------------------
143
+ // Parser
144
+ // ---------------------------------------------------------------------------
145
+ /**
146
+ * Parse every `@quantize` block from CSS source text.
147
+ *
148
+ * Grammar:
149
+ *
150
+ * ```css
151
+ * @quantize boundaryName {
152
+ * stateName {
153
+ * property: value;
154
+ * }
155
+ * }
156
+ * ```
157
+ *
158
+ * The outer `@quantize` and state-name matching is line-based for
159
+ * simplicity; property declarations inside state blocks use a
160
+ * character-level parser so that multi-line values (e.g.
161
+ * `linear-gradient` spread across lines) are collected correctly
162
+ * before being matched.
163
+ */
164
+ export function parseQuantizeBlocks(css, sourceFile) {
165
+ const normalized = normalizeCssLineEndings(css);
166
+ const blocks = [];
167
+ const lines = normalized.split('\n');
168
+ let i = 0;
169
+ while (i < lines.length) {
170
+ const line = lines[i];
171
+ const atMatch = line.match(/^\s*@quantize\s+([a-zA-Z_][a-zA-Z0-9_-]*)\s*\{/);
172
+ if (atMatch) {
173
+ const boundaryName = atMatch[1];
174
+ const blockStartLine = i + 1; // 1-indexed
175
+ const states = {};
176
+ i++; // advance past @quantize line
177
+ let braceDepth = 1;
178
+ while (i < lines.length && braceDepth > 0) {
179
+ const currentLine = lines[i];
180
+ const trimmed = currentLine.trim();
181
+ if (braceDepth === 1) {
182
+ // Look for a state block opening: `stateName {`
183
+ const stateMatch = trimmed.match(/^([a-zA-Z_][a-zA-Z0-9_-]*)\s*\{/);
184
+ if (stateMatch) {
185
+ const stateName = stateMatch[1];
186
+ // Compute the character offset of the `{` that opens this state
187
+ // block inside the full CSS string so we can hand off to the
188
+ // character-level parser.
189
+ const lineOffset = normalized.split('\n').slice(0, i).join('\n').length + 1;
190
+ const openBrace = lineOffset + currentLine.indexOf('{') + 1;
191
+ const { props, end } = parseStateDeclarations(normalized, openBrace);
192
+ states[stateName] = props;
193
+ // Advance the line cursor to the line that contains `end`
194
+ let charCount = 0;
195
+ let lineIdx = 0;
196
+ for (const l of normalized.split('\n')) {
197
+ charCount += l.length + 1; // +1 for the '\n'
198
+ lineIdx++;
199
+ if (charCount >= end)
200
+ break;
201
+ }
202
+ i = lineIdx;
203
+ continue;
204
+ }
205
+ // Closing brace for the @quantize block
206
+ if (trimmed === '}') {
207
+ braceDepth--;
208
+ i++;
209
+ continue;
210
+ }
211
+ }
212
+ // Track nested braces outside of state blocks for robustness
213
+ for (const ch of trimmed) {
214
+ if (ch === '{')
215
+ braceDepth++;
216
+ if (ch === '}')
217
+ braceDepth--;
218
+ }
219
+ i++;
220
+ }
221
+ blocks.push({
222
+ boundaryName,
223
+ states,
224
+ sourceFile,
225
+ line: blockStartLine,
226
+ });
227
+ }
228
+ else {
229
+ i++;
230
+ }
231
+ }
232
+ return blocks;
233
+ }
234
+ // ---------------------------------------------------------------------------
235
+ // Compiler (delegates to @czap/compiler CSSCompiler)
236
+ // ---------------------------------------------------------------------------
237
+ /**
238
+ * Compile a parsed {@link QuantizeBlock} plus its resolved
239
+ * {@link Boundary.Shape} into CSS `@container` query rules. Delegates
240
+ * to the canonical `CSSCompiler` to avoid duplicating threshold-to-query
241
+ * logic.
242
+ */
243
+ export function compileQuantizeBlock(block, boundary) {
244
+ const result = CSSCompiler.compile(boundary, block.states);
245
+ return CSSCompiler.serialize(result);
246
+ }
247
+ //# sourceMappingURL=css-quantize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-quantize.js","sourceRoot":"","sources":["../src/css-quantize.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAsBjE,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAS,sBAAsB,CAAC,GAAW,EAAE,GAAW;IACtD,MAAM,KAAK,GAA2B,EAAE,CAAC;IACzC,IAAI,UAAU,GAAG,CAAC,CAAC;IAEnB,OAAO,GAAG,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;QACxB,uCAAuC;QACvC,OAAO,GAAG,GAAG,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC;YAAE,GAAG,EAAE,CAAC;QACvD,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM;YAAE,MAAM;QAE7B,MAAM,EAAE,GAAG,GAAG,CAAC,GAAG,CAAE,CAAC;QAErB,sBAAsB;QACtB,IAAI,EAAE,KAAK,GAAG,IAAI,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACvC,GAAG,IAAI,CAAC,CAAC;YACT,OAAO,GAAG,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC;gBAAE,GAAG,EAAE,CAAC;YAClF,GAAG,IAAI,CAAC,CAAC;YACT,SAAS;QACX,CAAC;QAED,mCAAmC;QACnC,IAAI,EAAE,KAAK,GAAG,IAAI,U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AAI,OAAO,KAAK,GAAG,EAAE,CAAC;wBACpB,UAAU,EAAE,CAAC;wBACb,CAAC,EAAE,CAAC;wBACJ,SAAS;oBACX,CAAC;gBACH,CAAC;gBAED,6DAA6D;gBAC7D,KAAK,MAAM,EAAE,IAAI,OAAO,EAAE,CAAC;oBACzB,IAAI,EAAE,KAAK,GAAG;wBAAE,UAAU,EAAE,CAAC;oBAC7B,IAAI,EAAE,KAAK,GAAG;wBAAE,UAAU,EAAE,CAAC;gBAC/B,CAAC;gBACD,CAAC,EAAE,CAAC;YACN,CAAC;YAED,MAAM,CAAC,IAAI,CAAC;gBACV,YAAY;gBACZ,MAAM;gBACN,UAAU;gBACV,IAAI,EAAE,cAAc;aACrB,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,CAAC,EAAE,CAAC;QACN,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,8EAA8E;AAC9E,qDAAqD;AACrD,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAoB,EAAE,QAAwB;IACjF,MAAM,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3D,OAAO,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Vite 8 Environment API configuration.
3
+ *
4
+ * Provides environment-specific resolve conditions and optimisation
5
+ * settings for browser, server, and shader build targets.
6
+ *
7
+ * @module
8
+ */
9
+ /** Named czap build environment. */
10
+ export type CzapEnvironmentName = 'browser' | 'server' | 'shader';
11
+ /**
12
+ * Subset of a Vite `Environment` config that czap touches: resolve
13
+ * conditions plus `optimizeDeps` include/exclude lists. Returned by
14
+ * {@link getEnvironmentConfig} and merged into the host Vite config
15
+ * via {@link buildEnvironments}.
16
+ */
17
+ export interface CzapEnvironmentConfig {
18
+ readonly resolve: {
19
+ readonly conditions: string[];
20
+ readonly extensions: string[];
21
+ };
22
+ readonly optimizeDeps: {
23
+ readonly include: string[];
24
+ readonly exclude: string[];
25
+ };
26
+ }
27
+ /**
28
+ * Get the Vite environment configuration for a specific czap target.
29
+ */
30
+ export declare function getEnvironmentConfig(name: CzapEnvironmentName): CzapEnvironmentConfig;
31
+ /**
32
+ * Build the Vite environments configuration object from a list of
33
+ * requested environment names.
34
+ */
35
+ export declare function buildEnvironments(names: readonly CzapEnvironmentName[]): Record<string, CzapEnvironmentConfig>;
36
+ //# sourceMappingURL=environments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environments.d.ts","sourceRoot":"","sources":["../src/environments.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,oCAAoC;AACpC,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAElE;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE;QAChB,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC;QAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC;KAC/B,CAAC;IACF,QAAQ,CAAC,YAAY,EAAE;QACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;QAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;KAC5B,CAAC;CACH;AAiDD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,mBAAmB,GAAG,qBAAqB,CAErF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,mBAAmB,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAM9G"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Vite 8 Environment API configuration.
3
+ *
4
+ * Provides environment-specific resolve conditions and optimisation
5
+ * settings for browser, server, and shader build targets.
6
+ *
7
+ * @module
8
+ */
9
+ // ---------------------------------------------------------------------------
10
+ // Environment Definitions
11
+ // ---------------------------------------------------------------------------
12
+ const BROWSER_ENV = {
13
+ resolve: {
14
+ conditions: ['browser', 'import', 'module', 'default'],
15
+ extensions: ['.ts', '.tsx', '.js', '.jsx', '.css'],
16
+ },
17
+ optimizeDeps: {
18
+ include: ['@czap/core', '@czap/detect'],
19
+ exclude: [],
20
+ },
21
+ };
22
+ const SERVER_ENV = {
23
+ resolve: {
24
+ conditions: ['node', 'import', 'module', 'default'],
25
+ extensions: ['.ts', '.tsx', '.js', '.jsx'],
26
+ },
27
+ optimizeDeps: {
28
+ include: [],
29
+ exclude: ['@czap/core', '@czap/detect'],
30
+ },
31
+ };
32
+ const SHADER_ENV = {
33
+ resolve: {
34
+ conditions: ['browser', 'import', 'module', 'default'],
35
+ extensions: ['.ts', '.js', '.glsl', '.wgsl', '.vert', '.frag'],
36
+ },
37
+ optimizeDeps: {
38
+ include: ['@czap/core'],
39
+ exclude: ['@czap/detect'],
40
+ },
41
+ };
42
+ const ENVIRONMENT_MAP = {
43
+ browser: BROWSER_ENV,
44
+ server: SERVER_ENV,
45
+ shader: SHADER_ENV,
46
+ };
47
+ // ---------------------------------------------------------------------------
48
+ // Public API
49
+ // ---------------------------------------------------------------------------
50
+ /**
51
+ * Get the Vite environment configuration for a specific czap target.
52
+ */
53
+ export function getEnvironmentConfig(name) {
54
+ return ENVIRONMENT_MAP[name];
55
+ }
56
+ /**
57
+ * Build the Vite environments configuration object from a list of
58
+ * requested environment names.
59
+ */
60
+ export function buildEnvironments(names) {
61
+ const result = {};
62
+ for (const name of names) {
63
+ result[name] = getEnvironmentConfig(name);
64
+ }
65
+ return result;
66
+ }
67
+ //# sourceMappingURL=environments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environments.js","sourceRoot":"","sources":["../src/environments.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA0BH,8EAA8E;AAC9E,0BAA0B;AAC1B,8EAA8E;AAE9E,MAAM,WAAW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qC;IACrE,MAAM,MAAM,GAA0C,EAAE,CAAC;IACzD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/dist/hmr.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ /**
2
+ * HMR handler for `czap:update` messages.
3
+ *
4
+ * Performs surgical DOM updates when `@quantize` CSS or shader
5
+ * uniforms change during development, avoiding full page reloads.
6
+ *
7
+ * @module
8
+ */
9
+ declare global {
10
+ interface HTMLCanvasElement {
11
+ /**
12
+ * czap runtime-attached WebGL program for HMR uniform updates.
13
+ * Set by the shader directive when a program is linked.
14
+ */
15
+ __czapProgram?: WebGLProgram;
16
+ }
17
+ }
18
+ /**
19
+ * Shape of the HMR payload the czap Vite plugin ships over the Vite
20
+ * dev-server WebSocket. Handled by {@link handleHMR} on the client.
21
+ */
22
+ export interface HMRPayload {
23
+ /** Message discriminator. Always `'czap:update'`. */
24
+ readonly type: 'czap:update';
25
+ /** Boundary id whose compiled output changed. */
26
+ readonly boundary: string;
27
+ /** New compiled CSS (omitted when only uniforms changed). */
28
+ readonly css?: string;
29
+ /** New shader-uniform values (omitted when only CSS changed). */
30
+ readonly uniforms?: Record<string, number>;
31
+ }
32
+ /**
33
+ * Handle a czap:update HMR payload.
34
+ * Dispatches to CSS replacement or shader uniform updates based on payload content.
35
+ */
36
+ export declare function handleHMR(payload: HMRPayload): void;
37
+ //# sourceMappingURL=hmr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmr.d.ts","sourceRoot":"","sources":["../src/hmr.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,iBAAiB;QACzB;;;WAGG;QACH,aAAa,CAAC,EAAE,YAAY,CAAC;KAC9B;CACF;AAMD;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,iDAAiD;IACjD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,6DAA6D;IAC7D,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5C;AAsED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAUnD"}
package/dist/hmr.js ADDED
@@ -0,0 +1,84 @@
1
+ /**
2
+ * HMR handler for `czap:update` messages.
3
+ *
4
+ * Performs surgical DOM updates when `@quantize` CSS or shader
5
+ * uniforms change during development, avoiding full page reloads.
6
+ *
7
+ * @module
8
+ */
9
+ // ---------------------------------------------------------------------------
10
+ // CSS Hot Update
11
+ // ---------------------------------------------------------------------------
12
+ /**
13
+ * Find or create a <style> element for a specific boundary's compiled CSS.
14
+ * Uses a data attribute for identification across HMR cycles.
15
+ */
16
+ function getOrCreateStyleElement(boundaryId) {
17
+ const selector = `style[data-czap-boundary="${boundaryId}"]`;
18
+ const existing = document.querySelector(selector);
19
+ if (existing instanceof HTMLStyleElement)
20
+ return existing;
21
+ const el = document.createElement('style');
22
+ el.setAttribute('data-czap-boundary', boundaryId);
23
+ document.head.appendChild(el);
24
+ return el;
25
+ }
26
+ /**
27
+ * Apply CSS updates by replacing the boundary's style element content.
28
+ */
29
+ function applyCSSUpdate(boundary, css) {
30
+ const el = getOrCreateStyleElement(boundary);
31
+ el.textContent = css;
32
+ }
33
+ // ---------------------------------------------------------------------------
34
+ // Shader Uniform Hot Update
35
+ // ---------------------------------------------------------------------------
36
+ /**
37
+ * Update shader uniform values on all canvases that have a czap-boundary
38
+ * attribute matching the boundary name.
39
+ *
40
+ * This works by dispatching a custom event that the czap runtime shader
41
+ * system listens for, passing the uniform map for in-place updates.
42
+ */
43
+ function applyUniformUpdate(boundary, uniforms) {
44
+ const event = new CustomEvent('czap:uniform-update', {
45
+ detail: { boundary, uniforms },
46
+ bubbles: true,
47
+ });
48
+ document.dispatchEvent(event);
49
+ // Direct update: find canvas elements with matching boundary data attribute
50
+ const canvases = Array.from(document.querySelectorAll(`canvas[data-czap-boundary="${boundary}"]`));
51
+ for (const canvas of canvases) {
52
+ const gl = canvas.getContext('webgl2') ?? canvas.getContext('webgl');
53
+ if (!gl)
54
+ continue;
55
+ // Look up the program stored on the canvas element via a custom property
56
+ const program = canvas.__czapProgram;
57
+ if (!program)
58
+ continue;
59
+ for (const [name, value] of Object.entries(uniforms)) {
60
+ const location = gl.getUniformLocation(program, name);
61
+ if (location !== null) {
62
+ gl.uniform1f(location, value);
63
+ }
64
+ }
65
+ }
66
+ }
67
+ // ---------------------------------------------------------------------------
68
+ // Public API
69
+ // ---------------------------------------------------------------------------
70
+ /**
71
+ * Handle a czap:update HMR payload.
72
+ * Dispatches to CSS replacement or shader uniform updates based on payload content.
73
+ */
74
+ export function handleHMR(payload) {
75
+ if (typeof document === 'undefined')
76
+ return;
77
+ if (payload.css !== undefined) {
78
+ applyCSSUpdate(payload.boundary, payload.css);
79
+ }
80
+ if (payload.uniforms !== undefined) {
81
+ applyUniformUpdate(payload.boundary, payload.uniforms);
82
+ }
83
+ }
84
+ //# sourceMappingURL=hmr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmr.js","sourceRoot":"","sources":["../src/hmr.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA+BH,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E;;;GAGG;AACH,SAAS,uBAAuB,CAAC,UAAkB;IACjD,MAAM,QAAQ,GAAG,6BAA6B,UAAU,IAAI,CAAC;IAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAClD,IAAI,QAAQ,YAAY,gBAAgB;QAAE,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C,QAAQ,CAAC,EAAE,CAAC;YACrD,MAAM,QAAQ,GAAG,EAAE,CAAC,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACtD,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;gBACtB,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,OAAmB;IAC3C,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAO;IAE5C,IAAI,OAAO,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QAC9B,cAAc,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QACnC,kBAAkB,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACzD,CAAC;AACH,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * HTML transform -- resolves `data-czap="name"` to boundary JSON.
3
+ *
4
+ * Scans HTML/Astro source for `data-czap="..."` attributes, resolves
5
+ * the named boundary via the existing boundary resolution infrastructure,
6
+ * and replaces with `data-czap-boundary='...'` containing serialized JSON.
7
+ *
8
+ * @module
9
+ */
10
+ /**
11
+ * Transform HTML source, replacing `data-czap="name"` with resolved boundary JSON.
12
+ *
13
+ * @param source - The HTML/Astro source string
14
+ * @param fromFile - The file path of the source (for resolution context)
15
+ * @param projectRoot - The project root directory
16
+ * @returns The transformed source, or the original if no transforms needed
17
+ */
18
+ export declare function transformHTML(source: string, fromFile: string, projectRoot: string): Promise<string>;
19
+ //# sourceMappingURL=html-transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-transform.d.ts","sourceRoot":"","sources":["../src/html-transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAoC1G"}