praxis-kit 3.1.1 → 4.0.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.
@@ -1,13 +1,185 @@
1
- // ../vite-plugin/src/ast.ts
1
+ // ../../plugins/vite/src/ast.ts
2
2
  import ts from "typescript";
3
+
4
+ // ../../lib/primitive/src/utils/iterate.ts
5
+ function find(iterable, callback) {
6
+ for (const value of iterable) {
7
+ const result = callback(value);
8
+ if (result != null) {
9
+ return result;
10
+ }
11
+ }
12
+ return null;
13
+ }
14
+ function some(iterable, predicate) {
15
+ for (const value of iterable) {
16
+ if (predicate(value)) return true;
17
+ }
18
+ return false;
19
+ }
20
+ function every(iterable, predicate) {
21
+ let index = 0;
22
+ for (const value of iterable) {
23
+ if (!predicate(value, index++)) {
24
+ return false;
25
+ }
26
+ }
27
+ return true;
28
+ }
29
+ function* filter(iterable, predicate) {
30
+ let index = 0;
31
+ for (const value of iterable) {
32
+ if (predicate(value, index++)) {
33
+ yield value;
34
+ }
35
+ }
36
+ }
37
+ function* map(iterable, callback) {
38
+ let index = 0;
39
+ for (const value of iterable) {
40
+ yield callback(value, index++);
41
+ }
42
+ }
43
+ function forEach(iterable, callback) {
44
+ let index = 0;
45
+ for (const value of iterable) {
46
+ callback(value, index++);
47
+ }
48
+ }
49
+ function reduce(iterable, initial, callback) {
50
+ let accumulator = initial;
51
+ let index = 0;
52
+ for (const value of iterable) {
53
+ accumulator = callback(accumulator, value, index++);
54
+ }
55
+ return accumulator;
56
+ }
57
+ function collect(iterable, callback) {
58
+ const result = {};
59
+ let index = 0;
60
+ for (const value of iterable) {
61
+ const entry = callback(value, index++);
62
+ if (entry === null) {
63
+ return null;
64
+ }
65
+ result[entry[0]] = entry[1];
66
+ }
67
+ return result;
68
+ }
69
+ function findLast(value, callback) {
70
+ for (let index = value.length - 1; index >= 0; index--) {
71
+ const result = callback(value[index], index);
72
+ if (result != null) {
73
+ return result;
74
+ }
75
+ }
76
+ return null;
77
+ }
78
+ function* items(collection) {
79
+ for (let i = 0; i < collection.length; i++) {
80
+ const item = collection.item(i);
81
+ if (item !== null) {
82
+ yield item;
83
+ }
84
+ }
85
+ }
86
+ function nodeList(list) {
87
+ return {
88
+ *[Symbol.iterator]() {
89
+ for (let i = 0; i < list.length; i++) {
90
+ const node = list.item(i);
91
+ if (node !== null) {
92
+ yield node;
93
+ }
94
+ }
95
+ }
96
+ };
97
+ }
98
+ function mapEntries(m) {
99
+ return m.entries();
100
+ }
101
+ function set(s) {
102
+ return s.values();
103
+ }
104
+ function hasOwn(object, key) {
105
+ return Object.hasOwn(object, key);
106
+ }
107
+ function* entries(object) {
108
+ for (const key in object) {
109
+ if (!hasOwn(object, key)) continue;
110
+ yield [key, object[key]];
111
+ }
112
+ }
113
+ function* keys(object) {
114
+ for (const [key] of entries(object)) {
115
+ yield key;
116
+ }
117
+ }
118
+ function* values(object) {
119
+ for (const [, value] of entries(object)) {
120
+ yield value;
121
+ }
122
+ }
123
+ function mapValues(object, callback) {
124
+ const result = {};
125
+ for (const [key, value] of entries(object)) {
126
+ result[key] = callback(value, key);
127
+ }
128
+ return result;
129
+ }
130
+ function forEachEntry(object, callback) {
131
+ for (const [key, value] of entries(object)) {
132
+ callback(key, value);
133
+ }
134
+ }
135
+ function forEachKey(object, callback) {
136
+ for (const key of keys(object)) {
137
+ callback(key);
138
+ }
139
+ }
140
+ function forEachValue(object, callback) {
141
+ for (const value of values(object)) {
142
+ callback(value);
143
+ }
144
+ }
145
+ function forEachSet(s, callback) {
146
+ for (const value of s) {
147
+ callback(value);
148
+ }
149
+ }
150
+ var iterate = Object.freeze({
151
+ entries,
152
+ filter,
153
+ find,
154
+ findLast,
155
+ forEach,
156
+ forEachEntry,
157
+ forEachKey,
158
+ forEachSet,
159
+ forEachValue,
160
+ items,
161
+ keys,
162
+ map,
163
+ mapEntries,
164
+ mapValues,
165
+ nodeList,
166
+ reduce,
167
+ collect,
168
+ set,
169
+ some,
170
+ every,
171
+ values
172
+ });
173
+
174
+ // ../../plugins/vite/src/ast.ts
3
175
  function getProperty(obj, key) {
4
- for (const prop of obj.properties) {
5
- if (!ts.isPropertyAssignment(prop)) continue;
6
- const name = prop.name;
176
+ return iterate.find(obj.properties, (prop) => {
177
+ if (!ts.isPropertyAssignment(prop)) return null;
178
+ const { name } = prop;
7
179
  if ((ts.isIdentifier(name) || ts.isStringLiteral(name)) && name.text === key)
8
180
  return prop.initializer;
9
- }
10
- return void 0;
181
+ return null;
182
+ }) ?? void 0;
11
183
  }
12
184
  function asObject(node) {
13
185
  if (!node) return void 0;
@@ -35,15 +207,26 @@ function firstObjectArg(call) {
35
207
  const [first] = call.arguments;
36
208
  return first && ts.isObjectLiteralExpression(first) ? first : void 0;
37
209
  }
38
- function walk(node, visitor) {
39
- visitor(node);
40
- ts.forEachChild(node, (child) => walk(child, visitor));
210
+ function* walk(node) {
211
+ yield node;
212
+ const children = [];
213
+ ts.forEachChild(node, (child) => {
214
+ children.push(child);
215
+ });
216
+ for (const child of children) {
217
+ yield* walk(child);
218
+ }
219
+ }
220
+ function walkEach(node, visitor) {
221
+ for (const child of walk(node)) {
222
+ visitor(child);
223
+ }
41
224
  }
42
225
  function parseSource(filename, code) {
43
226
  return ts.createSourceFile(filename, code, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
44
227
  }
45
228
 
46
- // ../vite-plugin/src/class-extract.ts
229
+ // ../../plugins/vite/src/class-extract.ts
47
230
  import ts2 from "typescript";
48
231
  var MAX_COMBINATIONS = 512;
49
232
  function asString(node) {
@@ -53,12 +236,14 @@ function asStringOrStringArray(node) {
53
236
  if (!node) return void 0;
54
237
  if (ts2.isStringLiteral(node)) return node.text;
55
238
  if (ts2.isArrayLiteralExpression(node)) {
56
- const items = [];
57
- for (const elem of node.elements) {
58
- if (!ts2.isStringLiteral(elem)) return void 0;
59
- items.push(elem.text);
60
- }
61
- return items;
239
+ const items2 = [];
240
+ const allStrings = iterate.every(node.elements, (elem) => {
241
+ if (!ts2.isStringLiteral(elem)) return false;
242
+ items2.push(elem.text);
243
+ return true;
244
+ });
245
+ if (!allStrings) return void 0;
246
+ return items2;
62
247
  }
63
248
  return void 0;
64
249
  }
@@ -70,67 +255,67 @@ function propKey(prop) {
70
255
  function extractVariantMap(stylingObj) {
71
256
  const variantsObj = asObject(getProperty(stylingObj, "variants"));
72
257
  if (!variantsObj) return null;
73
- const result = {};
74
- for (const prop of variantsObj.properties) {
258
+ return iterate.collect(variantsObj.properties, (prop) => {
75
259
  const key = propKey(prop);
76
260
  if (!key || !ts2.isPropertyAssignment(prop)) return null;
77
261
  const valuesObj = asObject(prop.initializer);
78
262
  if (!valuesObj) return null;
79
- const values = {};
80
- for (const vp of valuesObj.properties) {
263
+ const values2 = iterate.collect(valuesObj.properties, (vp) => {
81
264
  const vk = propKey(vp);
82
265
  if (!vk || !ts2.isPropertyAssignment(vp)) return null;
83
- const v = asStringOrStringArray(vp.initializer);
84
- if (v === void 0) return null;
85
- values[vk] = v;
86
- }
87
- result[key] = values;
88
- }
89
- return result;
266
+ const value = asStringOrStringArray(vp.initializer);
267
+ if (value === void 0) return null;
268
+ return [vk, value];
269
+ });
270
+ if (!values2) return null;
271
+ return [key, values2];
272
+ });
90
273
  }
91
274
  function extractDefaults(stylingObj) {
92
275
  const defaultsObj = asObject(getProperty(stylingObj, "defaults"));
93
276
  if (!defaultsObj) return {};
94
- const result = {};
95
- for (const prop of defaultsObj.properties) {
277
+ return iterate.collect(defaultsObj.properties, (prop) => {
96
278
  const key = propKey(prop);
97
- if (!key || !ts2.isPropertyAssignment(prop)) return {};
98
- const v = asString(prop.initializer);
99
- if (v === void 0) return {};
100
- result[key] = v;
101
- }
102
- return result;
279
+ if (!key || !ts2.isPropertyAssignment(prop)) return null;
280
+ const value = asString(prop.initializer);
281
+ if (value === void 0) return null;
282
+ return [key, value];
283
+ }) ?? {};
103
284
  }
104
285
  function extractCompounds(stylingObj) {
105
286
  const compoundsArr = asArray(getProperty(stylingObj, "compounds"));
106
287
  if (!compoundsArr) return [];
107
288
  const result = [];
108
- for (const elem of compoundsArr.elements) {
289
+ const resultReturned = iterate.every(compoundsArr.elements, (elem) => {
109
290
  const obj = asObject(elem);
110
- if (!obj) return null;
291
+ if (!obj) return false;
111
292
  const cls = asStringOrStringArray(getProperty(obj, "class"));
112
- if (cls === void 0) return null;
293
+ if (cls === void 0) return false;
113
294
  const conditions = {};
114
- for (const cp of obj.properties) {
295
+ const keyOrVNotDefined = iterate.every(obj.properties, (cp) => {
115
296
  const key = propKey(cp);
116
- if (!key || !ts2.isPropertyAssignment(cp)) return null;
117
- if (key === "class") continue;
297
+ if (!key || !ts2.isPropertyAssignment(cp)) return false;
298
+ if (key === "class") return true;
118
299
  const v = asStringOrStringArray(cp.initializer);
119
- if (v === void 0) return null;
300
+ if (v === void 0) return false;
120
301
  conditions[key] = v;
121
- }
302
+ return true;
303
+ });
304
+ if (!keyOrVNotDefined) return false;
122
305
  result.push({ conditions, cls });
123
- }
124
- return result;
306
+ return true;
307
+ });
308
+ return resultReturned ? result : null;
125
309
  }
126
310
  function enumerateCombinations(variantMap) {
127
- const keys = Object.keys(variantMap);
128
- if (keys.length === 0) return [{}];
311
+ const keys2 = Object.keys(variantMap);
312
+ if (keys2.length === 0) return [{}];
129
313
  let total = 1;
130
- for (const key of keys) {
314
+ const totalUnderMaxLimit = iterate.every(keys2, (key) => {
131
315
  total *= Object.keys(variantMap[key]).length + 1;
132
- if (total > MAX_COMBINATIONS) return null;
133
- }
316
+ return total <= MAX_COMBINATIONS;
317
+ });
318
+ if (!totalUnderMaxLimit) return null;
134
319
  function rec(remaining) {
135
320
  if (remaining.length === 0) return [{}];
136
321
  const first = remaining[0];
@@ -138,15 +323,15 @@ function enumerateCombinations(variantMap) {
138
323
  const restCombos = rec(rest);
139
324
  const valueKeys = Object.keys(variantMap[first]);
140
325
  const out = [];
141
- for (const combo of restCombos) {
326
+ iterate.forEach(restCombos, (combo) => {
142
327
  out.push(combo);
143
- for (const v of valueKeys) {
328
+ iterate.forEach(valueKeys, (v) => {
144
329
  out.push({ [first]: v, ...combo });
145
- }
146
- }
330
+ });
331
+ });
147
332
  return out;
148
333
  }
149
- return rec(keys);
334
+ return rec(keys2);
150
335
  }
151
336
  function buildCacheKey(props) {
152
337
  const parts = Object.keys(props).sort().map((k) => `${k}:s:${props[k]}`);
@@ -156,35 +341,24 @@ function computeClasses(config, props) {
156
341
  const { variantMap, defaults, compounds } = config;
157
342
  const effective = { ...defaults, ...props };
158
343
  const classes = [];
159
- for (const [key, values] of Object.entries(variantMap)) {
344
+ iterate.forEachEntry(variantMap, (key, values2) => {
160
345
  const v = effective[key];
161
- if (v === void 0) continue;
162
- const cls = values[v];
163
- if (cls === void 0) continue;
346
+ if (v === void 0) return;
347
+ const cls = values2[v];
348
+ if (cls === void 0) return;
164
349
  if (Array.isArray(cls)) classes.push(...cls);
165
350
  else classes.push(cls);
166
- }
167
- for (const { conditions, cls } of compounds) {
168
- let ok = true;
169
- for (const [key, cond] of Object.entries(conditions)) {
170
- const v = effective[key];
171
- if (Array.isArray(cond)) {
172
- if (v === void 0 || !cond.includes(v)) {
173
- ok = false;
174
- break;
175
- }
176
- } else {
177
- if (v !== cond) {
178
- ok = false;
179
- break;
180
- }
181
- }
182
- }
351
+ });
352
+ iterate.forEach(compounds, ({ conditions, cls }) => {
353
+ const ok = iterate.every(iterate.entries(conditions), ([key, cond]) => {
354
+ const value = effective[key];
355
+ return Array.isArray(cond) ? value !== void 0 && cond.includes(value) : value === cond;
356
+ });
183
357
  if (ok) {
184
358
  if (Array.isArray(cls)) classes.push(...cls);
185
359
  else classes.push(cls);
186
360
  }
187
- }
361
+ });
188
362
  return classes.filter(Boolean).join(" ");
189
363
  }
190
364
  function buildPrecomputedClasses(stylingObj) {
@@ -197,11 +371,10 @@ function buildPrecomputedClasses(stylingObj) {
197
371
  const combos = enumerateCombinations(variantMap);
198
372
  if (!combos) return null;
199
373
  const config = { variantMap, defaults, compounds };
200
- const map = {};
201
- for (const combo of combos) {
202
- map[buildCacheKey(combo)] = computeClasses(config, combo);
203
- }
204
- return map;
374
+ return iterate.collect(
375
+ combos,
376
+ (combo) => [buildCacheKey(combo), computeClasses(config, combo)]
377
+ );
205
378
  }
206
379
  function createClassExtractTransformer(factory, calleeNames, onInjected) {
207
380
  return (context) => {
@@ -213,13 +386,16 @@ function createClassExtractTransformer(factory, calleeNames, onInjected) {
213
386
  const stylingNode = getProperty(arg, "styling");
214
387
  const stylingObj = asObject(stylingNode);
215
388
  if (!stylingObj) return ts2.visitEachChild(node, visit, context);
216
- const map = buildPrecomputedClasses(stylingObj);
217
- if (!map) return ts2.visitEachChild(node, visit, context);
389
+ const map2 = buildPrecomputedClasses(stylingObj);
390
+ if (!map2) return ts2.visitEachChild(node, visit, context);
218
391
  onInjected();
219
- const mapProps = Object.entries(map).map(
220
- ([k, v]) => factory.createPropertyAssignment(
221
- factory.createStringLiteral(k),
222
- factory.createStringLiteral(v)
392
+ const mapProps = Array.from(
393
+ iterate.map(
394
+ iterate.entries(map2),
395
+ ([key, value]) => factory.createPropertyAssignment(
396
+ factory.createStringLiteral(key),
397
+ factory.createStringLiteral(value)
398
+ )
223
399
  )
224
400
  );
225
401
  const mapLiteral = factory.createObjectLiteralExpression(mapProps, true);
@@ -247,12 +423,10 @@ function createClassExtractTransformer(factory, calleeNames, onInjected) {
247
423
  };
248
424
  }
249
425
  function injectPrecomputedClasses(source, calleeNames) {
250
- let hasVariants = false;
251
- walk(source, (n) => {
252
- if (hasVariants) return;
253
- if (ts2.isPropertyAssignment(n) && (ts2.isIdentifier(n.name) || ts2.isStringLiteral(n.name)) && n.name.text === "variants")
254
- hasVariants = true;
255
- });
426
+ const hasVariants = iterate.some(
427
+ walk(source),
428
+ (node) => ts2.isPropertyAssignment(node) && (ts2.isIdentifier(node.name) || ts2.isStringLiteral(node.name)) && node.name.text === "variants"
429
+ );
256
430
  if (!hasVariants) return null;
257
431
  let didInject = false;
258
432
  const result = ts2.transform(
@@ -274,7 +448,7 @@ function injectPrecomputedClasses(source, calleeNames) {
274
448
  return output;
275
449
  }
276
450
 
277
- // ../vite-plugin/src/collect.ts
451
+ // ../../plugins/vite/src/collect.ts
278
452
  import ts3 from "typescript";
279
453
  function extractBound(element) {
280
454
  const obj = asObject(element);
@@ -310,11 +484,12 @@ function cardinalityMax(c) {
310
484
  return c.kind === "bounded" ? c.max : Infinity;
311
485
  }
312
486
  function processVariableStatement(node, calleeNames, out) {
313
- for (const decl of node.declarationList.declarations) {
314
- if (!decl.initializer || !ts3.isCallExpression(decl.initializer)) continue;
315
- if (!isFactoryCall(decl.initializer, calleeNames)) continue;
316
- const arg = firstObjectArg(decl.initializer);
317
- if (!arg) continue;
487
+ iterate.forEach(node.declarationList.declarations, (decl) => {
488
+ const { initializer, name } = decl;
489
+ if (!initializer || !ts3.isCallExpression(initializer)) return;
490
+ if (!isFactoryCall(initializer, calleeNames)) return;
491
+ const arg = firstObjectArg(initializer);
492
+ if (!arg) return;
318
493
  const tagNode = getProperty(arg, "tag");
319
494
  const defaultTag = tagNode && ts3.isStringLiteral(tagNode) ? tagNode.text : void 0;
320
495
  const enforcementProp = getProperty(arg, "enforcement");
@@ -326,21 +501,21 @@ function processVariableStatement(node, calleeNames, out) {
326
501
  const childrenArr = asArray(childrenProp);
327
502
  const rules = [];
328
503
  if (childrenArr) {
329
- for (const element of childrenArr.elements) {
504
+ iterate.forEach(childrenArr.elements, (element) => {
330
505
  const bound = extractBound(element);
331
506
  if (bound) rules.push(bound);
332
- }
507
+ });
333
508
  }
334
- if (rules.length === 0 && !hasAriaRules && !defaultTag) continue;
509
+ if (rules.length === 0 && !hasAriaRules && !defaultTag) return;
335
510
  let totalMin = 0;
336
511
  let totalMax = 0;
337
- for (const rule of rules) {
512
+ iterate.forEach(rules, (rule) => {
338
513
  totalMin += cardinalityMin(rule.cardinality);
339
514
  const max = cardinalityMax(rule.cardinality);
340
515
  totalMax = totalMax === Infinity || max === Infinity ? Infinity : totalMax + max;
341
- }
342
- const componentName = ts3.isIdentifier(decl.name) ? decl.name.text : void 0;
343
- if (!componentName) continue;
516
+ });
517
+ const componentName = ts3.isIdentifier(name) ? name.text : void 0;
518
+ if (!componentName) return;
344
519
  out.push({
345
520
  name: componentName,
346
521
  rules,
@@ -349,11 +524,11 @@ function processVariableStatement(node, calleeNames, out) {
349
524
  ...defaultTag !== void 0 && { defaultTag },
350
525
  hasAriaRules
351
526
  });
352
- }
527
+ });
353
528
  }
354
529
  function collectConstraints(source, calleeNames) {
355
530
  const constraints = [];
356
- walk(source, (node) => {
531
+ walkEach(source, (node) => {
357
532
  if (ts3.isVariableStatement(node)) processVariableStatement(node, calleeNames, constraints);
358
533
  });
359
534
  return constraints;
@@ -361,7 +536,7 @@ function collectConstraints(source, calleeNames) {
361
536
  function collectFileDeclarations(source, calleeNames) {
362
537
  const constraints = [];
363
538
  const importSpecifiers = /* @__PURE__ */ new Map();
364
- walk(source, (node) => {
539
+ walkEach(source, (node) => {
365
540
  if (ts3.isVariableStatement(node)) {
366
541
  processVariableStatement(node, calleeNames, constraints);
367
542
  } else if (ts3.isImportDeclaration(node)) {
@@ -370,57 +545,62 @@ function collectFileDeclarations(source, calleeNames) {
370
545
  const namedBindings = node.importClause?.namedBindings;
371
546
  if (!namedBindings || !ts3.isNamedImports(namedBindings)) return;
372
547
  const specifier = spec.text;
373
- for (const el of namedBindings.elements) {
374
- if (el.isTypeOnly) continue;
375
- const localName = el.name.text;
376
- const importedName = el.propertyName?.text ?? localName;
548
+ iterate.forEach(namedBindings.elements, ({ isTypeOnly, name, propertyName }) => {
549
+ if (isTypeOnly) return;
550
+ const localName = name.text;
551
+ const importedName = propertyName?.text ?? localName;
377
552
  importSpecifiers.set(localName, { importedName, specifier });
378
- }
553
+ });
379
554
  }
380
555
  });
381
556
  return { constraints, importSpecifiers };
382
557
  }
383
558
 
384
- // ../vite-plugin/src/compound-prune.ts
559
+ // ../../plugins/vite/src/compound-prune.ts
385
560
  import ts4 from "typescript";
386
561
  function extractVariantMap2(stylingObj) {
387
562
  const result = /* @__PURE__ */ new Map();
388
563
  const variantsObj = asObject(getProperty(stylingObj, "variants"));
389
564
  if (!variantsObj) return result;
390
- for (const prop of variantsObj.properties) {
391
- if (!ts4.isPropertyAssignment(prop)) continue;
392
- const key = ts4.isIdentifier(prop.name) || ts4.isStringLiteral(prop.name) ? prop.name.text : void 0;
393
- if (!key) continue;
565
+ iterate.forEach(variantsObj.properties, (prop) => {
566
+ if (!ts4.isPropertyAssignment(prop)) return;
567
+ const { name } = prop;
568
+ const key = ts4.isIdentifier(name) || ts4.isStringLiteral(name) ? name.text : void 0;
569
+ if (!key) return;
394
570
  const valuesObj = asObject(prop.initializer);
395
- if (!valuesObj) continue;
571
+ if (!valuesObj) return;
396
572
  const valid = /* @__PURE__ */ new Set();
397
- for (const vp of valuesObj.properties) {
398
- if (!ts4.isPropertyAssignment(vp)) continue;
399
- const vk = ts4.isIdentifier(vp.name) || ts4.isStringLiteral(vp.name) ? vp.name.text : void 0;
573
+ iterate.forEach(valuesObj.properties, (vp) => {
574
+ if (!ts4.isPropertyAssignment(vp)) return;
575
+ const { name: name2 } = vp;
576
+ const vk = ts4.isIdentifier(name2) || ts4.isStringLiteral(name2) ? name2.text : void 0;
400
577
  if (vk) valid.add(vk);
401
- }
578
+ });
402
579
  result.set(key, valid);
403
- }
580
+ });
404
581
  return result;
405
582
  }
406
583
  function isDeadCompound(entry, variantMap) {
407
- for (const prop of entry.properties) {
408
- if (!ts4.isPropertyAssignment(prop)) continue;
409
- const key = ts4.isIdentifier(prop.name) || ts4.isStringLiteral(prop.name) ? prop.name.text : void 0;
410
- if (!key || key === "class") continue;
584
+ return iterate.find(entry.properties, (prop) => {
585
+ if (!ts4.isPropertyAssignment(prop)) return null;
586
+ const { name } = prop;
587
+ const key = ts4.isIdentifier(name) || ts4.isStringLiteral(name) ? name.text : void 0;
588
+ if (!key || key === "class") return null;
411
589
  const validValues = variantMap.get(key);
412
590
  if (!validValues) return true;
413
- const val = prop.initializer;
591
+ const { initializer: val } = prop;
414
592
  if (ts4.isStringLiteral(val)) {
415
593
  if (!validValues.has(val.text)) return true;
416
594
  } else if (ts4.isArrayLiteralExpression(val)) {
417
595
  const allLiterals = val.elements.every(ts4.isStringLiteral);
418
- if (!allLiterals) continue;
419
- const hasAnyValid = val.elements.some((e) => ts4.isStringLiteral(e) && validValues.has(e.text));
596
+ if (!allLiterals) return null;
597
+ const hasAnyValid = val.elements.some(
598
+ (e) => ts4.isStringLiteral(e) && validValues.has(e.text)
599
+ );
420
600
  if (!hasAnyValid) return true;
421
601
  }
422
- }
423
- return false;
602
+ return null;
603
+ }) ?? false;
424
604
  }
425
605
  function createCompoundPruner(factory, calleeNames, onPruned) {
426
606
  return (context) => {
@@ -470,7 +650,7 @@ function createCompoundPruner(factory, calleeNames, onPruned) {
470
650
  }
471
651
  function pruneDeadCompounds(source, calleeNames) {
472
652
  let hasCompounds = false;
473
- walk(source, (n) => {
653
+ walkEach(source, (n) => {
474
654
  if (hasCompounds) return;
475
655
  if (ts4.isPropertyAssignment(n)) {
476
656
  const key = ts4.isIdentifier(n.name) || ts4.isStringLiteral(n.name) ? n.name.text : void 0;
@@ -498,13 +678,36 @@ function pruneDeadCompounds(source, calleeNames) {
498
678
  return output;
499
679
  }
500
680
 
501
- // ../vite-plugin/src/constants.ts
502
- var DEFAULT_CALLEE_NAMES = ["createPolymorphicComponent", "createContractComponent"];
681
+ // ../../plugins/vite/src/constants.ts
682
+ var DEFAULT_CALLEE_NAMES = ["createContractComponent", "createPolymorphicComponent"];
503
683
  var JSX_EXTS = /* @__PURE__ */ new Set(["tsx", "jsx"]);
504
684
  var ALL_EXTS = /* @__PURE__ */ new Set(["ts", "tsx", "js", "jsx"]);
505
685
 
506
- // ../vite-plugin/src/diagnose.ts
686
+ // ../../plugins/vite/src/diagnose.ts
507
687
  import ts5 from "typescript";
688
+
689
+ // ../../plugins/vite/src/vite-diagnostics.ts
690
+ var ViteDiagnostics = {
691
+ cardinalityViolation(name, totalMin, totalMax, receivedMin, receivedMax) {
692
+ const rangeText = totalMax === Infinity ? `at least ${totalMin}` : totalMin === totalMax ? `exactly ${totalMin}` : `${totalMin}\u2013${totalMax}`;
693
+ const childWord = totalMax === 1 && totalMin === 1 ? "child" : "children";
694
+ const receivedText = receivedMin === receivedMax ? `${receivedMin}` : `${receivedMin}\u2013${receivedMax}`;
695
+ return {
696
+ code: "LINT5015" /* LintCardinalityViolation */,
697
+ category: 9 /* Lint */,
698
+ message: `<${name}> expects ${rangeText} ${childWord} but received ${receivedText}.`
699
+ };
700
+ },
701
+ ariaTagOverride(tagName, asValue, defaultTag) {
702
+ return {
703
+ code: "LINT5016" /* LintAriaTagOverride */,
704
+ category: 9 /* Lint */,
705
+ message: `<${tagName} as="${asValue}"> changes the element type from '${defaultTag}' \u2014 ARIA enforcement rules may not apply as expected.`
706
+ };
707
+ }
708
+ };
709
+
710
+ // ../../plugins/vite/src/diagnose.ts
508
711
  function analyzeJsxSites(source, constraints, severity) {
509
712
  const byName = new Map(constraints.filter((c) => c.rules.length > 0).map((c) => [c.name, c]));
510
713
  const byNameAria = new Map(
@@ -512,7 +715,7 @@ function analyzeJsxSites(source, constraints, severity) {
512
715
  );
513
716
  const diagnostics = [];
514
717
  const usages = [];
515
- walk(source, (node) => {
718
+ walkEach(source, (node) => {
516
719
  let tagName;
517
720
  let attributes;
518
721
  let count;
@@ -533,11 +736,14 @@ function analyzeJsxSites(source, constraints, severity) {
533
736
  const c = byName.get(tagName);
534
737
  if (c && (count.max < c.totalMin || count.min > c.totalMax)) {
535
738
  const { line, character } = getPos();
536
- const { totalMin, totalMax, name } = c;
537
- const rangeText = totalMax === Infinity ? `at least ${totalMin}` : totalMin === totalMax ? `exactly ${totalMin}` : `${totalMin}\u2013${totalMax}`;
538
- const receivedText = count.min === count.max ? `${count.min}` : `${count.min}\u2013${count.max}`;
539
739
  diagnostics.push({
540
- message: `<${name}> expects ${rangeText} ${totalMax === 1 && totalMin === 1 ? "child" : "children"} but received ${receivedText}.`,
740
+ diagnostic: ViteDiagnostics.cardinalityViolation(
741
+ c.name,
742
+ c.totalMin,
743
+ c.totalMax,
744
+ count.min,
745
+ count.max
746
+ ),
541
747
  line: line + 1,
542
748
  col: character + 1,
543
749
  severity
@@ -547,26 +753,27 @@ function analyzeJsxSites(source, constraints, severity) {
547
753
  if (attributes) {
548
754
  const c = byNameAria.get(tagName);
549
755
  if (c) {
550
- for (const attr of attributes.properties) {
551
- if (!ts5.isJsxAttribute(attr)) continue;
552
- const attrName = ts5.isIdentifier(attr.name) ? attr.name.text : void 0;
553
- if (attrName !== "as" || !attr.initializer) continue;
756
+ iterate.forEach(attributes.properties, (attr) => {
757
+ if (!ts5.isJsxAttribute(attr)) return;
758
+ const { initializer, name } = attr;
759
+ const attrName = ts5.isIdentifier(name) ? name.text : void 0;
760
+ if (attrName !== "as" || !initializer) return;
554
761
  let asValue;
555
- if (ts5.isStringLiteral(attr.initializer)) {
556
- asValue = attr.initializer.text;
557
- } else if (ts5.isJsxExpression(attr.initializer) && attr.initializer.expression !== void 0 && ts5.isStringLiteral(attr.initializer.expression)) {
558
- asValue = attr.initializer.expression.text;
762
+ if (ts5.isStringLiteral(initializer)) {
763
+ asValue = initializer.text;
764
+ } else if (ts5.isJsxExpression(initializer) && initializer.expression !== void 0 && ts5.isStringLiteral(initializer.expression)) {
765
+ asValue = initializer.expression.text;
559
766
  }
560
767
  if (asValue !== void 0 && asValue !== c.defaultTag) {
561
768
  const { line, character } = getPos();
562
769
  diagnostics.push({
563
- message: `<${tagName} as="${asValue}"> changes the element type from '${c.defaultTag}' \u2014 ARIA enforcement rules may not apply as expected.`,
770
+ diagnostic: ViteDiagnostics.ariaTagOverride(tagName, asValue, c.defaultTag),
564
771
  line: line + 1,
565
772
  col: character + 1,
566
773
  severity
567
774
  });
568
775
  }
569
- }
776
+ });
570
777
  }
571
778
  }
572
779
  if (/^[A-Z]/.test(tagName)) {
@@ -646,7 +853,7 @@ function diagnoseUsages(source, constraints, severity) {
646
853
  if (constraints.length === 0) return [];
647
854
  const byName = new Map(constraints.filter((c) => c.rules.length > 0).map((c) => [c.name, c]));
648
855
  const diagnostics = [];
649
- walk(source, (node) => {
856
+ walkEach(source, (node) => {
650
857
  let tagName;
651
858
  let count;
652
859
  if (ts5.isJsxElement(node)) {
@@ -664,10 +871,14 @@ function diagnoseUsages(source, constraints, severity) {
664
871
  const { totalMin, totalMax, name } = constraint;
665
872
  if (count.max < totalMin || count.min > totalMax) {
666
873
  const { line, character } = source.getLineAndCharacterOfPosition(node.getStart(source));
667
- const rangeText = totalMax === Infinity ? `at least ${totalMin}` : totalMin === totalMax ? `exactly ${totalMin}` : `${totalMin}\u2013${totalMax}`;
668
- const receivedText = count.min === count.max ? `${count.min}` : `${count.min}\u2013${count.max}`;
669
874
  diagnostics.push({
670
- message: `<${name}> expects ${rangeText} ${totalMax === 1 && totalMin === 1 ? "child" : "children"} but received ${receivedText}.`,
875
+ diagnostic: ViteDiagnostics.cardinalityViolation(
876
+ name,
877
+ totalMin,
878
+ totalMax,
879
+ count.min,
880
+ count.max
881
+ ),
671
882
  line: line + 1,
672
883
  col: character + 1,
673
884
  severity
@@ -677,11 +888,34 @@ function diagnoseUsages(source, constraints, severity) {
677
888
  return diagnostics;
678
889
  }
679
890
 
680
- // ../vite-plugin/src/registry.ts
891
+ // ../../plugins/vite/src/imports.ts
892
+ import ts6 from "typescript";
893
+ function extractImportSpecifiers(source) {
894
+ const result = /* @__PURE__ */ new Map();
895
+ walkEach(source, (node) => {
896
+ if (!ts6.isImportDeclaration(node)) return;
897
+ const moduleSpecifier = node.moduleSpecifier;
898
+ if (!ts6.isStringLiteral(moduleSpecifier)) return;
899
+ const specifier = moduleSpecifier.text;
900
+ const namedBindings = node.importClause?.namedBindings;
901
+ if (!namedBindings || !ts6.isNamedImports(namedBindings)) return;
902
+ iterate.forEach(namedBindings.elements, (element) => {
903
+ const { isTypeOnly, name, propertyName } = element;
904
+ if (isTypeOnly) return;
905
+ const { text: localName } = name;
906
+ const importedName = propertyName?.text ?? localName;
907
+ result.set(localName, { importedName, specifier });
908
+ });
909
+ });
910
+ return result;
911
+ }
912
+
913
+ // ../../plugins/vite/src/registry.ts
681
914
  var ConstraintRegistry = class {
682
915
  constraints = /* @__PURE__ */ new Map();
683
916
  importMap = /* @__PURE__ */ new Map();
684
917
  pending = /* @__PURE__ */ new Map();
918
+ /** Records the component constraints declared in a source file, keyed by component name. */
685
919
  registerConstraints(fileId, cs) {
686
920
  this.constraints.set(fileId, new Map(cs.map((c) => [c.name, c])));
687
921
  }
@@ -689,6 +923,7 @@ var ConstraintRegistry = class {
689
923
  registerImports(fileId, resolvedImports) {
690
924
  this.importMap.set(fileId, resolvedImports);
691
925
  }
926
+ /** Queues a JSX usage site whose constraint lives in another file for deferred cross-file validation at buildEnd. */
692
927
  addPendingUsage(fileId, usage) {
693
928
  let list = this.pending.get(fileId);
694
929
  if (!list) {
@@ -708,72 +943,70 @@ var ConstraintRegistry = class {
708
943
  /** Returns cardinality violations across all pending cross-file usages. */
709
944
  diagnostics(severity) {
710
945
  const result = [];
711
- for (const [fileId, usages] of this.pending) {
712
- for (const usage of usages) {
713
- if (usage.count === void 0) continue;
714
- const constraint = this.resolveConstraint(fileId, usage.tagName);
715
- if (!constraint) continue;
946
+ iterate.forEach(this.pending, ([fileId, usages]) => {
947
+ iterate.forEach(usages, ({ col, count, line, tagName }) => {
948
+ if (count === void 0) return;
949
+ const constraint = this.resolveConstraint(fileId, tagName);
950
+ if (!constraint) return;
716
951
  const { totalMin, totalMax, name } = constraint;
717
- if (usage.count.max >= totalMin && usage.count.min <= totalMax) continue;
718
- const rangeText = totalMax === Infinity ? `at least ${totalMin}` : totalMin === totalMax ? `exactly ${totalMin}` : `${totalMin}\u2013${totalMax}`;
719
- const childWord = totalMax === 1 && totalMin === 1 ? "child" : "children";
720
- const receivedText = usage.count.min === usage.count.max ? `${usage.count.min}` : `${usage.count.min}\u2013${usage.count.max}`;
952
+ const { min, max } = count;
953
+ if (max >= totalMin && min <= totalMax) return;
721
954
  result.push({
722
955
  fileId,
723
- message: `<${name}> expects ${rangeText} ${childWord} but received ${receivedText}.`,
724
- line: usage.line,
725
- col: usage.col,
956
+ diagnostic: ViteDiagnostics.cardinalityViolation(name, totalMin, totalMax, min, max),
957
+ line,
958
+ col,
726
959
  severity
727
960
  });
728
- }
729
- }
961
+ });
962
+ });
730
963
  return result;
731
964
  }
732
965
  };
733
966
 
734
- // ../vite-plugin/src/slot-transform.ts
735
- import ts6 from "typescript";
967
+ // ../../plugins/vite/src/slot-transform.ts
968
+ import ts7 from "typescript";
736
969
  function isUpperCase(s) {
737
970
  return s.charCodeAt(0) >= 65 && s.charCodeAt(0) <= 90;
738
971
  }
739
972
  function jsxAttrName(attr) {
740
- return ts6.isIdentifier(attr.name) ? attr.name.text : "";
973
+ return ts7.isIdentifier(attr.name) ? attr.name.text : "";
741
974
  }
742
975
  function getStaticClassName(child) {
743
- const attrs = ts6.isJsxElement(child) ? child.openingElement.attributes.properties : child.attributes.properties;
976
+ const attrs = ts7.isJsxElement(child) ? child.openingElement.attributes.properties : child.attributes.properties;
744
977
  for (const attr of attrs) {
745
- if (!ts6.isJsxAttribute(attr) || jsxAttrName(attr) !== "className") continue;
978
+ if (!ts7.isJsxAttribute(attr) || jsxAttrName(attr) !== "className") continue;
746
979
  const init = attr.initializer;
747
980
  if (!init) return { absent: false, value: "" };
748
- if (ts6.isStringLiteral(init)) return { absent: false, value: init.text };
749
- if (ts6.isJsxExpression(init) && init.expression !== void 0 && ts6.isStringLiteral(init.expression))
981
+ if (ts7.isStringLiteral(init)) return { absent: false, value: init.text };
982
+ if (ts7.isJsxExpression(init) && init.expression !== void 0 && ts7.isStringLiteral(init.expression))
750
983
  return { absent: false, value: init.expression.text };
751
984
  return null;
752
985
  }
753
986
  return { absent: true };
754
987
  }
755
988
  function getStyleInfo(child) {
756
- const attrs = ts6.isJsxElement(child) ? child.openingElement.attributes.properties : child.attributes.properties;
989
+ const attrs = ts7.isJsxElement(child) ? child.openingElement.attributes.properties : child.attributes.properties;
757
990
  for (const attr of attrs) {
758
- if (!ts6.isJsxAttribute(attr) || jsxAttrName(attr) !== "style") continue;
991
+ if (!ts7.isJsxAttribute(attr) || jsxAttrName(attr) !== "style") continue;
759
992
  const init = attr.initializer;
760
- if (!init || ts6.isStringLiteral(init)) return null;
761
- if (ts6.isJsxExpression(init) && init.expression !== void 0)
993
+ if (!init || ts7.isStringLiteral(init)) return null;
994
+ if (ts7.isJsxExpression(init) && init.expression !== void 0)
762
995
  return { absent: false, expr: init.expression };
763
996
  return null;
764
997
  }
765
998
  return { absent: true };
766
999
  }
767
1000
  function getEventHandlers(child) {
768
- const attrs = ts6.isJsxElement(child) ? child.openingElement.attributes.properties : child.attributes.properties;
1001
+ const attrs = ts7.isJsxElement(child) ? child.openingElement.attributes.properties : child.attributes.properties;
769
1002
  const handlers = [];
770
1003
  for (const attr of attrs) {
771
- if (!ts6.isJsxAttribute(attr)) continue;
1004
+ if (!ts7.isJsxAttribute(attr)) continue;
772
1005
  const name = jsxAttrName(attr);
773
1006
  if (!/^on[A-Z]/.test(name)) continue;
774
1007
  const init = attr.initializer;
775
1008
  if (!init) return null;
776
- if (ts6.isJsxExpression(init) && init.expression !== void 0) {
1009
+ if (ts7.isJsxExpression(init) && init.expression !== void 0) {
777
1010
  handlers.push({ name, expr: init.expression });
778
1011
  continue;
779
1012
  }
@@ -783,10 +1016,10 @@ function getEventHandlers(child) {
783
1016
  }
784
1017
  function hasAsChild(opening) {
785
1018
  for (const attr of opening.attributes.properties) {
786
- if (!ts6.isJsxAttribute(attr)) continue;
1019
+ if (!ts7.isJsxAttribute(attr)) continue;
787
1020
  if (jsxAttrName(attr) !== "asChild") continue;
788
1021
  if (attr.initializer === void 0) return true;
789
- if (ts6.isJsxExpression(attr.initializer) && attr.initializer.expression !== void 0 && attr.initializer.expression.kind === ts6.SyntaxKind.TrueKeyword)
1022
+ if (ts7.isJsxExpression(attr.initializer) && attr.initializer.expression !== void 0 && attr.initializer.expression.kind === ts7.SyntaxKind.TrueKeyword)
790
1023
  return true;
791
1024
  }
792
1025
  return false;
@@ -794,12 +1027,12 @@ function hasAsChild(opening) {
794
1027
  function getSingleElementChild(node) {
795
1028
  const meaningful = [];
796
1029
  for (const child of node.children) {
797
- if (ts6.isJsxText(child)) {
1030
+ if (ts7.isJsxText(child)) {
798
1031
  if (child.text.trim().length > 0) return void 0;
799
1032
  continue;
800
1033
  }
801
- if (ts6.isJsxExpression(child)) return void 0;
802
- if (ts6.isJsxElement(child) || ts6.isJsxSelfClosingElement(child)) {
1034
+ if (ts7.isJsxExpression(child)) return void 0;
1035
+ if (ts7.isJsxElement(child) || ts7.isJsxSelfClosingElement(child)) {
803
1036
  meaningful.push(child);
804
1037
  continue;
805
1038
  }
@@ -808,26 +1041,26 @@ function getSingleElementChild(node) {
808
1041
  return meaningful.length === 1 ? meaningful[0] : void 0;
809
1042
  }
810
1043
  function getTagName(child) {
811
- const tag = ts6.isJsxElement(child) ? child.openingElement.tagName : child.tagName;
812
- return ts6.isIdentifier(tag) ? tag.text : void 0;
1044
+ const tag = ts7.isJsxElement(child) ? child.openingElement.tagName : child.tagName;
1045
+ return ts7.isIdentifier(tag) ? tag.text : void 0;
813
1046
  }
814
1047
  function buildTransformedAttributes(factory, original, child, tagName, clsResult, styleInfo, handlers) {
815
1048
  const parentAttrs = original.attributes.properties.filter(
816
- (attr) => !(ts6.isJsxAttribute(attr) && jsxAttrName(attr) === "asChild")
1049
+ (attr) => !(ts7.isJsxAttribute(attr) && jsxAttrName(attr) === "asChild")
817
1050
  );
818
1051
  const hasStaticCls = !clsResult.absent;
819
1052
  const hasStyle = !styleInfo.absent;
820
- const handlerNames = new Set(handlers.map((h) => h.name));
821
- const childOpeningAttrs = (ts6.isJsxElement(child) ? child.openingElement.attributes.properties : child.attributes.properties).filter(
822
- (attr) => !(ts6.isJsxAttribute(attr) && (jsxAttrName(attr) === "ref" || hasStaticCls && jsxAttrName(attr) === "className" || hasStyle && jsxAttrName(attr) === "style" || handlerNames.has(jsxAttrName(attr))))
1053
+ const handlerNames = new Set(iterate.map(handlers, (h) => h.name));
1054
+ const childOpeningAttrs = (ts7.isJsxElement(child) ? child.openingElement.attributes.properties : child.attributes.properties).filter(
1055
+ (attr) => !(ts7.isJsxAttribute(attr) && (jsxAttrName(attr) === "ref" || hasStaticCls && jsxAttrName(attr) === "className" || hasStyle && jsxAttrName(attr) === "style" || handlerNames.has(jsxAttrName(attr))))
823
1056
  );
824
- const childContent = ts6.isJsxElement(child) ? child.children : void 0;
1057
+ const childContent = ts7.isJsxElement(child) ? child.children : void 0;
825
1058
  const spreadProp = factory.createJsxSpreadAttribute(factory.createIdentifier("_p"));
826
1059
  const extraAttrs = [];
827
1060
  if (hasStaticCls && clsResult.value !== "") {
828
1061
  const mergedExpr = factory.createBinaryExpression(
829
1062
  factory.createPropertyAccessExpression(factory.createIdentifier("_p"), "className"),
830
- ts6.SyntaxKind.PlusToken,
1063
+ ts7.SyntaxKind.PlusToken,
831
1064
  factory.createStringLiteral(` ${clsResult.value}`)
832
1065
  );
833
1066
  extraAttrs.push(
@@ -843,7 +1076,7 @@ function buildTransformedAttributes(factory, original, child, tagName, clsResult
843
1076
  factory.createPropertyAccessExpression(factory.createIdentifier("_p"), "style")
844
1077
  );
845
1078
  let mergedStyleObj;
846
- if (ts6.isObjectLiteralExpression(styleExpr)) {
1079
+ if (ts7.isObjectLiteralExpression(styleExpr)) {
847
1080
  mergedStyleObj = factory.createObjectLiteralExpression(
848
1081
  [pStyleSpread, ...styleExpr.properties],
849
1082
  false
@@ -871,7 +1104,7 @@ function buildTransformedAttributes(factory, original, child, tagName, clsResult
871
1104
  const callParent = factory.createExpressionStatement(
872
1105
  factory.createCallChain(
873
1106
  factory.createPropertyAccessExpression(factory.createIdentifier("_p"), name),
874
- factory.createToken(ts6.SyntaxKind.QuestionDotToken),
1107
+ factory.createToken(ts7.SyntaxKind.QuestionDotToken),
875
1108
  void 0,
876
1109
  [factory.createIdentifier("_e")]
877
1110
  )
@@ -881,7 +1114,7 @@ function buildTransformedAttributes(factory, original, child, tagName, clsResult
881
1114
  void 0,
882
1115
  [eParam],
883
1116
  void 0,
884
- factory.createToken(ts6.SyntaxKind.EqualsGreaterThanToken),
1117
+ factory.createToken(ts7.SyntaxKind.EqualsGreaterThanToken),
885
1118
  factory.createBlock([callChild, callParent], true)
886
1119
  );
887
1120
  extraAttrs.push(
@@ -896,7 +1129,7 @@ function buildTransformedAttributes(factory, original, child, tagName, clsResult
896
1129
  spreadProp,
897
1130
  ...extraAttrs
898
1131
  ]);
899
- const childElement = ts6.isJsxElement(child) ? factory.createJsxElement(
1132
+ const childElement = ts7.isJsxElement(child) ? factory.createJsxElement(
900
1133
  factory.createJsxOpeningElement(
901
1134
  factory.createIdentifier(tagName),
902
1135
  void 0,
@@ -914,7 +1147,7 @@ function buildTransformedAttributes(factory, original, child, tagName, clsResult
914
1147
  void 0,
915
1148
  [factory.createParameterDeclaration(void 0, void 0, "_p")],
916
1149
  void 0,
917
- factory.createToken(ts6.SyntaxKind.EqualsGreaterThanToken),
1150
+ factory.createToken(ts7.SyntaxKind.EqualsGreaterThanToken),
918
1151
  factory.createParenthesizedExpression(childElement)
919
1152
  );
920
1153
  const renderAttr = factory.createJsxAttribute(
@@ -926,23 +1159,23 @@ function buildTransformedAttributes(factory, original, child, tagName, clsResult
926
1159
  function createAsChildTransformer(factory) {
927
1160
  return (context) => {
928
1161
  function visit(node) {
929
- if (!ts6.isJsxElement(node)) return ts6.visitEachChild(node, visit, context);
1162
+ if (!ts7.isJsxElement(node)) return ts7.visitEachChild(node, visit, context);
930
1163
  const opening = node.openingElement;
931
- const tagName = ts6.isIdentifier(opening.tagName) ? opening.tagName.text : void 0;
1164
+ const tagName = ts7.isIdentifier(opening.tagName) ? opening.tagName.text : void 0;
932
1165
  if (!tagName || !isUpperCase(tagName)) {
933
- return ts6.visitEachChild(node, visit, context);
1166
+ return ts7.visitEachChild(node, visit, context);
934
1167
  }
935
- if (!hasAsChild(opening)) return ts6.visitEachChild(node, visit, context);
1168
+ if (!hasAsChild(opening)) return ts7.visitEachChild(node, visit, context);
936
1169
  const child = getSingleElementChild(node);
937
- if (!child) return ts6.visitEachChild(node, visit, context);
1170
+ if (!child) return ts7.visitEachChild(node, visit, context);
938
1171
  const clsResult = getStaticClassName(child);
939
- if (clsResult === null) return ts6.visitEachChild(node, visit, context);
1172
+ if (clsResult === null) return ts7.visitEachChild(node, visit, context);
940
1173
  const styleInfo = getStyleInfo(child);
941
- if (styleInfo === null) return ts6.visitEachChild(node, visit, context);
1174
+ if (styleInfo === null) return ts7.visitEachChild(node, visit, context);
942
1175
  const handlers = getEventHandlers(child);
943
- if (handlers === null) return ts6.visitEachChild(node, visit, context);
1176
+ if (handlers === null) return ts7.visitEachChild(node, visit, context);
944
1177
  const childTag = getTagName(child);
945
- if (!childTag) return ts6.visitEachChild(node, visit, context);
1178
+ if (!childTag) return ts7.visitEachChild(node, visit, context);
946
1179
  const newAttrs = buildTransformedAttributes(
947
1180
  factory,
948
1181
  opening,
@@ -954,43 +1187,42 @@ function createAsChildTransformer(factory) {
954
1187
  );
955
1188
  return factory.createJsxSelfClosingElement(opening.tagName, opening.typeArguments, newAttrs);
956
1189
  }
957
- return (sourceFile) => ts6.visitEachChild(sourceFile, visit, context);
1190
+ return (sourceFile) => ts7.visitEachChild(sourceFile, visit, context);
958
1191
  };
959
1192
  }
960
1193
  function transformAsChild(source) {
961
- let hasAny = false;
962
- walk(source, (n) => {
963
- if (hasAny) return;
964
- if (ts6.isJsxAttribute(n) && jsxAttrName(n) === "asChild") hasAny = true;
965
- });
1194
+ const hasAny = iterate.some(
1195
+ walk(source),
1196
+ (node) => ts7.isJsxAttribute(node) && jsxAttrName(node) === "asChild"
1197
+ );
966
1198
  if (!hasAny) return null;
967
- const result = ts6.transform(source, [createAsChildTransformer(ts6.factory)], {
968
- jsx: ts6.JsxEmit.Preserve,
969
- target: ts6.ScriptTarget.Latest
1199
+ const result = ts7.transform(source, [createAsChildTransformer(ts7.factory)], {
1200
+ jsx: ts7.JsxEmit.Preserve,
1201
+ target: ts7.ScriptTarget.Latest
970
1202
  });
971
- const printer = ts6.createPrinter({ newLine: ts6.NewLineKind.LineFeed, removeComments: false });
1203
+ const printer = ts7.createPrinter({ newLine: ts7.NewLineKind.LineFeed, removeComments: false });
972
1204
  const output = printer.printFile(result.transformed[0]);
973
1205
  result.dispose();
974
1206
  return output;
975
1207
  }
976
1208
 
977
- // ../vite-plugin/src/static-compose.ts
978
- import ts7 from "typescript";
1209
+ // ../../plugins/vite/src/static-compose.ts
1210
+ import ts8 from "typescript";
979
1211
  function asStringLiteral(node) {
980
- return node !== void 0 && ts7.isStringLiteral(node) ? node.text : void 0;
1212
+ return node !== void 0 && ts8.isStringLiteral(node) ? node.text : void 0;
981
1213
  }
982
1214
  function extractStaticComponents(source, calleeNames) {
983
1215
  const result = /* @__PURE__ */ new Map();
984
- walk(source, (node) => {
985
- if (!ts7.isVariableDeclaration(node)) return;
986
- if (!ts7.isIdentifier(node.name)) return;
1216
+ walkEach(source, (node) => {
1217
+ if (!ts8.isVariableDeclaration(node)) return;
1218
+ if (!ts8.isIdentifier(node.name)) return;
987
1219
  const varName = node.name.text;
988
1220
  const init = node.initializer;
989
1221
  if (!init) return;
990
1222
  let call;
991
- if (ts7.isCallExpression(init) && isFactoryCall(init, calleeNames)) {
1223
+ if (ts8.isCallExpression(init) && isFactoryCall(init, calleeNames)) {
992
1224
  call = init;
993
- } else if (ts7.isAsExpression(init) && ts7.isCallExpression(init.expression) && isFactoryCall(init.expression, calleeNames)) {
1225
+ } else if (ts8.isAsExpression(init) && ts8.isCallExpression(init.expression) && isFactoryCall(init.expression, calleeNames)) {
994
1226
  call = init.expression;
995
1227
  }
996
1228
  if (!call) return;
@@ -1003,23 +1235,29 @@ function extractStaticComponents(source, calleeNames) {
1003
1235
  const precomputedNode = asObject(getProperty(stylingObj, "precomputedClasses"));
1004
1236
  if (!precomputedNode) return;
1005
1237
  const precomputedClasses = {};
1006
- for (const prop of precomputedNode.properties) {
1007
- if (!ts7.isPropertyAssignment(prop)) return;
1008
- const key = ts7.isStringLiteral(prop.name) ? prop.name.text : void 0;
1009
- const val = asStringLiteral(prop.initializer);
1010
- if (key === void 0 || val === void 0) return;
1011
- precomputedClasses[key] = val;
1012
- }
1238
+ const isNotPrecomputed = iterate.find(
1239
+ precomputedNode.properties,
1240
+ (prop) => {
1241
+ if (!ts8.isPropertyAssignment(prop)) return true;
1242
+ const { initializer, name } = prop;
1243
+ const key = ts8.isStringLiteral(name) ? name.text : void 0;
1244
+ const val = asStringLiteral(initializer);
1245
+ if (key === void 0 || val === void 0) return true;
1246
+ precomputedClasses[key] = val;
1247
+ return null;
1248
+ }
1249
+ );
1250
+ if (isNotPrecomputed) return;
1013
1251
  if (getProperty(arg, "defaults") !== void 0) return;
1014
1252
  if (getProperty(arg, "enforcement") !== void 0) return;
1015
1253
  const variantKeys = /* @__PURE__ */ new Set();
1016
1254
  const variantsObj = asObject(getProperty(stylingObj, "variants"));
1017
1255
  if (variantsObj) {
1018
- for (const prop of variantsObj.properties) {
1019
- if (ts7.isPropertyAssignment(prop) && (ts7.isIdentifier(prop.name) || ts7.isStringLiteral(prop.name))) {
1256
+ iterate.forEach(variantsObj.properties, (prop) => {
1257
+ if (ts8.isPropertyAssignment(prop) && (ts8.isIdentifier(prop.name) || ts8.isStringLiteral(prop.name))) {
1020
1258
  variantKeys.add(prop.name.text);
1021
1259
  }
1022
- }
1260
+ });
1023
1261
  }
1024
1262
  result.set(varName, { defaultTag, variantKeys, precomputedClasses });
1025
1263
  });
@@ -1027,13 +1265,13 @@ function extractStaticComponents(source, calleeNames) {
1027
1265
  }
1028
1266
  function readAttrValue(attrs, name) {
1029
1267
  for (const attr of attrs) {
1030
- if (!ts7.isJsxAttribute(attr)) continue;
1031
- if (!(ts7.isIdentifier(attr.name) && attr.name.text === name)) continue;
1268
+ if (!ts8.isJsxAttribute(attr)) continue;
1269
+ if (!(ts8.isIdentifier(attr.name) && attr.name.text === name)) continue;
1032
1270
  const init = attr.initializer;
1033
1271
  if (!init) return { kind: "string", value: "" };
1034
- if (ts7.isStringLiteral(init)) return { kind: "string", value: init.text };
1035
- if (ts7.isJsxExpression(init) && init.expression !== void 0) {
1036
- if (ts7.isStringLiteral(init.expression))
1272
+ if (ts8.isStringLiteral(init)) return { kind: "string", value: init.text };
1273
+ if (ts8.isJsxExpression(init) && init.expression !== void 0) {
1274
+ if (ts8.isStringLiteral(init.expression))
1037
1275
  return { kind: "string", value: init.expression.text };
1038
1276
  return { kind: "dynamic" };
1039
1277
  }
@@ -1044,21 +1282,21 @@ function readAttrValue(attrs, name) {
1044
1282
  function createStaticCompositionTransformer(factory, components, onInlined) {
1045
1283
  return (context) => {
1046
1284
  function visit(node) {
1047
- const isSelfClose = ts7.isJsxSelfClosingElement(node);
1048
- const isOpen = ts7.isJsxElement(node);
1049
- if (!isSelfClose && !isOpen) return ts7.visitEachChild(node, visit, context);
1285
+ const isSelfClose = ts8.isJsxSelfClosingElement(node);
1286
+ const isOpen = ts8.isJsxElement(node);
1287
+ if (!isSelfClose && !isOpen) return ts8.visitEachChild(node, visit, context);
1050
1288
  const tagNode = isOpen ? node.openingElement.tagName : node.tagName;
1051
- if (!ts7.isIdentifier(tagNode)) return ts7.visitEachChild(node, visit, context);
1289
+ if (!ts8.isIdentifier(tagNode)) return ts8.visitEachChild(node, visit, context);
1052
1290
  const info = components.get(tagNode.text);
1053
- if (!info) return ts7.visitEachChild(node, visit, context);
1291
+ if (!info) return ts8.visitEachChild(node, visit, context);
1054
1292
  const attrList = isOpen ? node.openingElement.attributes.properties : node.attributes.properties;
1055
- if (attrList.some(ts7.isJsxSpreadAttribute)) return ts7.visitEachChild(node, visit, context);
1293
+ if (attrList.some(ts8.isJsxSpreadAttribute)) return ts8.visitEachChild(node, visit, context);
1056
1294
  if (readAttrValue(attrList, "asChild").kind !== "absent")
1057
- return ts7.visitEachChild(node, visit, context);
1295
+ return ts8.visitEachChild(node, visit, context);
1058
1296
  if (readAttrValue(attrList, "render").kind !== "absent")
1059
- return ts7.visitEachChild(node, visit, context);
1297
+ return ts8.visitEachChild(node, visit, context);
1060
1298
  const asVal = readAttrValue(attrList, "as");
1061
- if (asVal.kind === "dynamic") return ts7.visitEachChild(node, visit, context);
1299
+ if (asVal.kind === "dynamic") return ts8.visitEachChild(node, visit, context);
1062
1300
  const outputTag = asVal.kind === "string" ? asVal.value : info.defaultTag;
1063
1301
  const variantProps = {};
1064
1302
  for (const propName of info.variantKeys) {
@@ -1068,13 +1306,13 @@ function createStaticCompositionTransformer(factory, components, onInlined) {
1068
1306
  variantProps[propName] = val.value;
1069
1307
  continue;
1070
1308
  }
1071
- return ts7.visitEachChild(node, visit, context);
1309
+ return ts8.visitEachChild(node, visit, context);
1072
1310
  }
1073
1311
  const cacheKey = buildCacheKey(variantProps);
1074
1312
  const baseClass = info.precomputedClasses[cacheKey];
1075
- if (baseClass === void 0) return ts7.visitEachChild(node, visit, context);
1313
+ if (baseClass === void 0) return ts8.visitEachChild(node, visit, context);
1076
1314
  const clsVal = readAttrValue(attrList, "className");
1077
- if (clsVal.kind === "dynamic") return ts7.visitEachChild(node, visit, context);
1315
+ if (clsVal.kind === "dynamic") return ts8.visitEachChild(node, visit, context);
1078
1316
  const finalClass = clsVal.kind === "string" && clsVal.value ? `${baseClass} ${clsVal.value}` : baseClass;
1079
1317
  const strip = /* @__PURE__ */ new Set([...info.variantKeys, "as", "asChild", "render", "className"]);
1080
1318
  const outputAttrs = [
@@ -1084,9 +1322,9 @@ function createStaticCompositionTransformer(factory, components, onInlined) {
1084
1322
  )
1085
1323
  ];
1086
1324
  for (const attr of attrList) {
1087
- if (ts7.isJsxSpreadAttribute(attr)) continue;
1088
- if (!ts7.isJsxAttribute(attr)) continue;
1089
- const name = ts7.isIdentifier(attr.name) ? attr.name.text : "";
1325
+ if (ts8.isJsxSpreadAttribute(attr)) continue;
1326
+ if (!ts8.isJsxAttribute(attr)) continue;
1327
+ const name = ts8.isIdentifier(attr.name) ? attr.name.text : "";
1090
1328
  if (strip.has(name)) continue;
1091
1329
  outputAttrs.push(attr);
1092
1330
  }
@@ -1097,14 +1335,14 @@ function createStaticCompositionTransformer(factory, components, onInlined) {
1097
1335
  return factory.createJsxSelfClosingElement(outputTagIdent, void 0, newAttrs);
1098
1336
  }
1099
1337
  const openNode = node;
1100
- const visitedChildren = openNode.children.map((c) => ts7.visitNode(c, visit));
1338
+ const visitedChildren = openNode.children.map((c) => ts8.visitNode(c, visit));
1101
1339
  return factory.createJsxElement(
1102
1340
  factory.createJsxOpeningElement(outputTagIdent, void 0, newAttrs),
1103
1341
  visitedChildren,
1104
1342
  factory.createJsxClosingElement(outputTagIdent)
1105
1343
  );
1106
1344
  }
1107
- return (sourceFile) => ts7.visitEachChild(sourceFile, visit, context);
1345
+ return (sourceFile) => ts8.visitEachChild(sourceFile, visit, context);
1108
1346
  };
1109
1347
  }
1110
1348
  function composeStatically(source, calleeNames, importedComponents = /* @__PURE__ */ new Map()) {
@@ -1113,55 +1351,34 @@ function composeStatically(source, calleeNames, importedComponents = /* @__PURE_
1113
1351
  if (components.size === 0) return null;
1114
1352
  const componentNames = new Set(components.keys());
1115
1353
  let hasEligibleTag = false;
1116
- walk(source, (n) => {
1354
+ walkEach(source, (n) => {
1117
1355
  if (hasEligibleTag) return;
1118
- const tagNode = ts7.isJsxElement(n) ? n.openingElement.tagName : ts7.isJsxSelfClosingElement(n) ? n.tagName : void 0;
1119
- if (tagNode && ts7.isIdentifier(tagNode) && componentNames.has(tagNode.text))
1356
+ const tagNode = ts8.isJsxElement(n) ? n.openingElement.tagName : ts8.isJsxSelfClosingElement(n) ? n.tagName : void 0;
1357
+ if (tagNode && ts8.isIdentifier(tagNode) && componentNames.has(tagNode.text))
1120
1358
  hasEligibleTag = true;
1121
1359
  });
1122
1360
  if (!hasEligibleTag) return null;
1123
1361
  let didInline = false;
1124
- const transformResult = ts7.transform(
1362
+ const transformResult = ts8.transform(
1125
1363
  source,
1126
1364
  [
1127
- createStaticCompositionTransformer(ts7.factory, components, () => {
1365
+ createStaticCompositionTransformer(ts8.factory, components, () => {
1128
1366
  didInline = true;
1129
1367
  })
1130
1368
  ],
1131
- { jsx: ts7.JsxEmit.Preserve, target: ts7.ScriptTarget.Latest }
1369
+ { jsx: ts8.JsxEmit.Preserve, target: ts8.ScriptTarget.Latest }
1132
1370
  );
1133
1371
  if (!didInline) {
1134
1372
  transformResult.dispose();
1135
1373
  return null;
1136
1374
  }
1137
- const printer = ts7.createPrinter({ newLine: ts7.NewLineKind.LineFeed, removeComments: false });
1375
+ const printer = ts8.createPrinter({ newLine: ts8.NewLineKind.LineFeed, removeComments: false });
1138
1376
  const output = printer.printFile(transformResult.transformed[0]);
1139
1377
  transformResult.dispose();
1140
1378
  return output;
1141
1379
  }
1142
1380
 
1143
- // ../vite-plugin/src/imports.ts
1144
- import ts8 from "typescript";
1145
- function extractImportSpecifiers(source) {
1146
- const result = /* @__PURE__ */ new Map();
1147
- walk(source, (node) => {
1148
- if (!ts8.isImportDeclaration(node)) return;
1149
- const moduleSpecifier = node.moduleSpecifier;
1150
- if (!ts8.isStringLiteral(moduleSpecifier)) return;
1151
- const specifier = moduleSpecifier.text;
1152
- const namedBindings = node.importClause?.namedBindings;
1153
- if (!namedBindings || !ts8.isNamedImports(namedBindings)) return;
1154
- for (const element of namedBindings.elements) {
1155
- if (element.isTypeOnly) continue;
1156
- const localName = element.name.text;
1157
- const importedName = element.propertyName?.text ?? localName;
1158
- result.set(localName, { importedName, specifier });
1159
- }
1160
- });
1161
- return result;
1162
- }
1163
-
1164
- // ../vite-plugin/src/analyze.ts
1381
+ // ../../plugins/vite/src/analyze.ts
1165
1382
  function analyze(code, filename, options) {
1166
1383
  const ext = filename.split(".").pop() ?? "";
1167
1384
  if (!JSX_EXTS.has(ext)) return [];
@@ -1172,7 +1389,7 @@ function analyze(code, filename, options) {
1172
1389
  return diagnoseUsages(source, constraints, severity);
1173
1390
  }
1174
1391
 
1175
- // ../vite-plugin/src/design-tokens.ts
1392
+ // ../../plugins/vite/src/design-tokens.ts
1176
1393
  import { writeFileSync } from "fs";
1177
1394
  import { resolve } from "path";
1178
1395
  import ts9 from "typescript";
@@ -1183,7 +1400,9 @@ function collectStringValues(node, out) {
1183
1400
  return;
1184
1401
  }
1185
1402
  if (ts9.isArrayLiteralExpression(node)) {
1186
- for (const elem of node.elements) collectStringValues(elem, out);
1403
+ iterate.forEach(node.elements, (elem) => {
1404
+ collectStringValues(elem, out);
1405
+ });
1187
1406
  }
1188
1407
  }
1189
1408
  function extractStylingTokens(stylingObj) {
@@ -1194,30 +1413,30 @@ function extractStylingTokens(stylingObj) {
1194
1413
  collectStringValues(getProperty(stylingObj, "base"), base);
1195
1414
  const variantsObj = asObject(getProperty(stylingObj, "variants"));
1196
1415
  if (variantsObj) {
1197
- for (const dimProp of variantsObj.properties) {
1198
- if (!ts9.isPropertyAssignment(dimProp)) continue;
1416
+ iterate.forEach(variantsObj.properties, (dimProp) => {
1417
+ if (!ts9.isPropertyAssignment(dimProp)) return;
1199
1418
  const valuesObj = asObject(dimProp.initializer);
1200
- if (!valuesObj) continue;
1201
- for (const vp of valuesObj.properties) {
1202
- if (!ts9.isPropertyAssignment(vp)) continue;
1419
+ if (!valuesObj) return;
1420
+ iterate.forEach(valuesObj.properties, (vp) => {
1421
+ if (!ts9.isPropertyAssignment(vp)) return;
1203
1422
  collectStringValues(vp.initializer, variantClasses);
1204
- }
1205
- }
1423
+ });
1424
+ });
1206
1425
  }
1207
1426
  const compoundsArr = asArray(getProperty(stylingObj, "compounds"));
1208
1427
  if (compoundsArr) {
1209
- for (const elem of compoundsArr.elements) {
1428
+ iterate.forEach(compoundsArr.elements, (elem) => {
1210
1429
  const obj = asObject(elem);
1211
- if (!obj) continue;
1430
+ if (!obj) return;
1212
1431
  collectStringValues(getProperty(obj, "class"), compoundClasses);
1213
- }
1432
+ });
1214
1433
  }
1215
1434
  const tagsObj = asObject(getProperty(stylingObj, "tags"));
1216
1435
  if (tagsObj) {
1217
- for (const tp of tagsObj.properties) {
1218
- if (!ts9.isPropertyAssignment(tp)) continue;
1436
+ iterate.forEach(tagsObj.properties, (tp) => {
1437
+ if (!ts9.isPropertyAssignment(tp)) return;
1219
1438
  collectStringValues(tp.initializer, tagClasses);
1220
- }
1439
+ });
1221
1440
  }
1222
1441
  return { base, variantClasses, compoundClasses, tagClasses };
1223
1442
  }
@@ -1225,18 +1444,19 @@ function collectFileTokens(source, calleeNames) {
1225
1444
  const result = /* @__PURE__ */ new Map();
1226
1445
  ts9.forEachChild(source, (stmt) => {
1227
1446
  if (!ts9.isVariableStatement(stmt)) return;
1228
- for (const decl of stmt.declarationList.declarations) {
1229
- if (!decl.initializer || !ts9.isCallExpression(decl.initializer)) continue;
1230
- if (!isFactoryCall(decl.initializer, calleeNames)) continue;
1231
- const arg = firstObjectArg(decl.initializer);
1232
- if (!arg) continue;
1447
+ iterate.forEach(stmt.declarationList.declarations, (decl) => {
1448
+ const { initializer, name } = decl;
1449
+ if (!initializer || !ts9.isCallExpression(initializer)) return;
1450
+ if (!isFactoryCall(initializer, calleeNames)) return;
1451
+ const arg = firstObjectArg(initializer);
1452
+ if (!arg) return;
1233
1453
  const stylingNode = getProperty(arg, "styling");
1234
1454
  const stylingObj = asObject(stylingNode);
1235
- if (!stylingObj) continue;
1236
- const name = ts9.isIdentifier(decl.name) ? decl.name.text : void 0;
1237
- if (!name) continue;
1238
- result.set(name, extractStylingTokens(stylingObj));
1239
- }
1455
+ if (!stylingObj) return;
1456
+ const definedName = ts9.isIdentifier(name) ? name.text : void 0;
1457
+ if (!definedName) return;
1458
+ result.set(definedName, extractStylingTokens(stylingObj));
1459
+ });
1240
1460
  });
1241
1461
  return result;
1242
1462
  }
@@ -1252,19 +1472,17 @@ function mergeTokens(existing, incoming) {
1252
1472
  function buildManifest(allTokens) {
1253
1473
  const components = {};
1254
1474
  const seen = /* @__PURE__ */ new Set();
1255
- for (const [name, tokens] of allTokens) {
1475
+ iterate.forEach(allTokens, ([name, tokens]) => {
1256
1476
  components[name] = tokens;
1257
- for (const cls of [
1258
- ...tokens.base,
1259
- ...tokens.variantClasses,
1260
- ...tokens.compoundClasses,
1261
- ...tokens.tagClasses
1262
- ]) {
1263
- for (const part of cls.split(/\s+/)) {
1264
- if (part) seen.add(part);
1477
+ iterate.forEach(
1478
+ [...tokens.base, ...tokens.variantClasses, ...tokens.compoundClasses, ...tokens.tagClasses],
1479
+ (cls) => {
1480
+ iterate.forEach(cls.split(/\s+/), (part) => {
1481
+ if (part) seen.add(part);
1482
+ });
1265
1483
  }
1266
- }
1267
- }
1484
+ );
1485
+ });
1268
1486
  return {
1269
1487
  components,
1270
1488
  allClasses: [...seen].sort()
@@ -1280,9 +1498,9 @@ function designTokensPlugin(options) {
1280
1498
  const ext = id.split(".").pop() ?? "";
1281
1499
  if (!ALL_EXTS.has(ext)) return null;
1282
1500
  const source = parseSource(id, code);
1283
- for (const [name, tokens] of collectFileTokens(source, calleeNames)) {
1501
+ iterate.forEach(collectFileTokens(source, calleeNames), ([name, tokens]) => {
1284
1502
  accumulated.set(name, mergeTokens(accumulated.get(name), tokens));
1285
- }
1503
+ });
1286
1504
  return null;
1287
1505
  },
1288
1506
  writeBundle() {
@@ -1294,7 +1512,7 @@ function designTokensPlugin(options) {
1294
1512
  };
1295
1513
  }
1296
1514
 
1297
- // ../vite-plugin/src/index.ts
1515
+ // ../../plugins/vite/src/index.ts
1298
1516
  function contractPlugin(options) {
1299
1517
  const registry = new ConstraintRegistry();
1300
1518
  const calleeNames = new Set(options?.calleeNames ?? DEFAULT_CALLEE_NAMES);
@@ -1308,14 +1526,14 @@ function contractPlugin(options) {
1308
1526
  const { constraints, importSpecifiers } = collectFileDeclarations(source, calleeNames);
1309
1527
  registry.registerConstraints(id, constraints);
1310
1528
  const { diagnostics, usages: allUsages } = analyzeJsxSites(source, constraints, severity);
1311
- for (const d of diagnostics) {
1312
- const loc = { file: id, line: d.line, column: d.col };
1313
- if (d.severity === "error") {
1314
- this.error({ message: d.message, loc });
1529
+ iterate.forEach(diagnostics, ({ col, diagnostic, line, severity: severity2 }) => {
1530
+ const loc = { file: id, line, column: col };
1531
+ if (severity2 === "error") {
1532
+ this.error({ message: diagnostic.message, loc });
1315
1533
  } else {
1316
- this.warn({ message: d.message, loc });
1534
+ this.warn({ message: diagnostic.message, loc });
1317
1535
  }
1318
- }
1536
+ });
1319
1537
  const localNames = new Set(constraints.map((c) => c.name));
1320
1538
  const importedTagsInUse = new Set(
1321
1539
  allUsages.filter((u) => !localNames.has(u.tagName) && importSpecifiers.has(u.tagName)).map((u) => u.tagName)
@@ -1328,22 +1546,25 @@ function contractPlugin(options) {
1328
1546
  if (resolved) resolvedImports.set(localName, resolved.id);
1329
1547
  }
1330
1548
  registry.registerImports(id, resolvedImports);
1331
- for (const usage of allUsages) {
1549
+ iterate.forEach(allUsages, (usage) => {
1332
1550
  if (importedTagsInUse.has(usage.tagName)) {
1333
1551
  registry.addPendingUsage(id, usage);
1334
1552
  }
1335
- }
1553
+ });
1336
1554
  }
1337
1555
  },
1338
1556
  buildEnd() {
1339
- for (const d of registry.diagnostics(severity)) {
1340
- const loc = { file: d.fileId, line: d.line, column: d.col };
1341
- if (d.severity === "error") {
1342
- this.error({ message: d.message, loc });
1343
- } else {
1344
- this.warn({ message: d.message, loc });
1557
+ iterate.forEach(
1558
+ registry.diagnostics(severity),
1559
+ ({ col, diagnostic, fileId, line, severity: severity2 }) => {
1560
+ const loc = { file: fileId, line, column: col };
1561
+ if (severity2 === "error") {
1562
+ this.error({ message: diagnostic.message, loc });
1563
+ } else {
1564
+ this.warn({ message: diagnostic.message, loc });
1565
+ }
1345
1566
  }
1346
- }
1567
+ );
1347
1568
  }
1348
1569
  };
1349
1570
  }