@tamagui/compiler-core 0.0.0-bootstrap.0 → 3.0.0-beta.643.1

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 (98) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +57 -1
  3. package/dist/cjs/ast.cjs +95 -0
  4. package/dist/cjs/contracts.cjs +62 -0
  5. package/dist/cjs/diagnostics.cjs +69 -0
  6. package/dist/cjs/evaluate.cjs +351 -0
  7. package/dist/cjs/graph.cjs +279 -0
  8. package/dist/cjs/hash.cjs +49 -0
  9. package/dist/cjs/index.cjs +44 -0
  10. package/dist/cjs/ir.cjs +33 -0
  11. package/dist/cjs/lower.cjs +225 -0
  12. package/dist/cjs/materialize.cjs +200 -0
  13. package/dist/cjs/normalize.cjs +622 -0
  14. package/dist/cjs/output.cjs +149 -0
  15. package/dist/cjs/planCache.cjs +224 -0
  16. package/dist/cjs/session.cjs +119 -0
  17. package/dist/cjs/yuku.cjs +159 -0
  18. package/dist/cjs/zero.cjs +387 -0
  19. package/dist/esm/ast.mjs +65 -0
  20. package/dist/esm/ast.mjs.map +1 -0
  21. package/dist/esm/contracts.mjs +34 -0
  22. package/dist/esm/contracts.mjs.map +1 -0
  23. package/dist/esm/diagnostics.mjs +44 -0
  24. package/dist/esm/diagnostics.mjs.map +1 -0
  25. package/dist/esm/evaluate.mjs +327 -0
  26. package/dist/esm/evaluate.mjs.map +1 -0
  27. package/dist/esm/graph.mjs +256 -0
  28. package/dist/esm/graph.mjs.map +1 -0
  29. package/dist/esm/hash.mjs +26 -0
  30. package/dist/esm/hash.mjs.map +1 -0
  31. package/dist/esm/index.mjs +30 -0
  32. package/dist/esm/ir.mjs +12 -0
  33. package/dist/esm/ir.mjs.map +1 -0
  34. package/dist/esm/lower.mjs +202 -0
  35. package/dist/esm/lower.mjs.map +1 -0
  36. package/dist/esm/materialize.mjs +179 -0
  37. package/dist/esm/materialize.mjs.map +1 -0
  38. package/dist/esm/normalize.mjs +596 -0
  39. package/dist/esm/normalize.mjs.map +1 -0
  40. package/dist/esm/output.mjs +119 -0
  41. package/dist/esm/output.mjs.map +1 -0
  42. package/dist/esm/planCache.mjs +194 -0
  43. package/dist/esm/planCache.mjs.map +1 -0
  44. package/dist/esm/session.mjs +99 -0
  45. package/dist/esm/session.mjs.map +1 -0
  46. package/dist/esm/yuku.mjs +136 -0
  47. package/dist/esm/yuku.mjs.map +1 -0
  48. package/dist/esm/zero.mjs +352 -0
  49. package/dist/esm/zero.mjs.map +1 -0
  50. package/package.json +42 -4
  51. package/src/ast.ts +86 -0
  52. package/src/contracts.ts +148 -0
  53. package/src/diagnostics.ts +96 -0
  54. package/src/evaluate.ts +497 -0
  55. package/src/graph.ts +347 -0
  56. package/src/hash.ts +36 -0
  57. package/src/index.ts +15 -0
  58. package/src/ir.ts +154 -0
  59. package/src/lower.ts +418 -0
  60. package/src/materialize.ts +330 -0
  61. package/src/normalize.ts +846 -0
  62. package/src/output.ts +175 -0
  63. package/src/planCache.ts +327 -0
  64. package/src/session.ts +172 -0
  65. package/src/yuku.ts +189 -0
  66. package/src/zero.ts +598 -0
  67. package/types/ast.d.ts +10 -0
  68. package/types/ast.d.ts.map +1 -0
  69. package/types/contracts.d.ts +97 -0
  70. package/types/contracts.d.ts.map +1 -0
  71. package/types/diagnostics.d.ts +31 -0
  72. package/types/diagnostics.d.ts.map +1 -0
  73. package/types/evaluate.d.ts +36 -0
  74. package/types/evaluate.d.ts.map +1 -0
  75. package/types/graph.d.ts +37 -0
  76. package/types/graph.d.ts.map +1 -0
  77. package/types/hash.d.ts +8 -0
  78. package/types/hash.d.ts.map +1 -0
  79. package/types/index.d.ts +16 -0
  80. package/types/index.d.ts.map +1 -0
  81. package/types/ir.d.ts +118 -0
  82. package/types/ir.d.ts.map +1 -0
  83. package/types/lower.d.ts +99 -0
  84. package/types/lower.d.ts.map +1 -0
  85. package/types/materialize.d.ts +104 -0
  86. package/types/materialize.d.ts.map +1 -0
  87. package/types/normalize.d.ts +8 -0
  88. package/types/normalize.d.ts.map +1 -0
  89. package/types/output.d.ts +32 -0
  90. package/types/output.d.ts.map +1 -0
  91. package/types/planCache.d.ts +113 -0
  92. package/types/planCache.d.ts.map +1 -0
  93. package/types/session.d.ts +44 -0
  94. package/types/session.d.ts.map +1 -0
  95. package/types/yuku.d.ts +4 -0
  96. package/types/yuku.d.ts.map +1 -0
  97. package/types/zero.d.ts +98 -0
  98. package/types/zero.d.ts.map +1 -0
@@ -0,0 +1,387 @@
1
+
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all) __defProp(target, name, {
8
+ get: all[name],
9
+ enumerable: true
10
+ });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ return to;
20
+ };
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+ var zero_exports = {};
23
+ __export(zero_exports, {
24
+ ZERO_ANIMATED_NUMBER_HOOKS: () => ZERO_ANIMATED_NUMBER_HOOKS,
25
+ ZERO_ANIMATED_NUMBER_MODULE: () => ZERO_ANIMATED_NUMBER_MODULE,
26
+ ZERO_DESIGN_STATE_APIS: () => ZERO_DESIGN_STATE_APIS,
27
+ ZERO_FAILURE_FOOTER: () => ZERO_FAILURE_FOOTER,
28
+ ZERO_PROVIDER_EXPORTS: () => ZERO_PROVIDER_EXPORTS,
29
+ ZERO_PROVIDER_MESSAGE: () => ZERO_PROVIDER_MESSAGE,
30
+ planZeroErasure: () => planZeroErasure,
31
+ zeroConfigDriverMessage: () => zeroConfigDriverMessage,
32
+ zeroIslandThemeMessage: () => zeroIslandThemeMessage,
33
+ zeroRuleMessage: () => zeroRuleMessage,
34
+ zeroSideEffectImportMessage: () => zeroSideEffectImportMessage,
35
+ zeroStaticIslandImportMessage: () => zeroStaticIslandImportMessage,
36
+ zeroThemeBoundaryMessage: () => zeroThemeBoundaryMessage,
37
+ zeroViolationsFromPlan: () => zeroViolationsFromPlan
38
+ });
39
+ module.exports = __toCommonJS(zero_exports);
40
+ var import_ast = require("./ast.cjs");
41
+ var import_diagnostics = require("./diagnostics.cjs");
42
+ var import_yuku = require("./yuku.cjs");
43
+ const ZERO_FAILURE_FOOTER = "Fix every site or move the owning module to a declared full-runtime island. Zero-runtime never retains one component as a fallback.";
44
+ const ZERO_DESIGN_STATE_APIS = /* @__PURE__ */ new Set([
45
+ "useMedia",
46
+ "useTheme",
47
+ "useThemeName",
48
+ "useProps",
49
+ "usePropsAndStyle",
50
+ "getConfig",
51
+ "getTokens",
52
+ "useTokens",
53
+ "getVariableValue",
54
+ "getToken",
55
+ "getTokenValue",
56
+ "useConfiguration",
57
+ "useAnimationDriver",
58
+ "updateTheme",
59
+ "addTheme",
60
+ "replaceTheme",
61
+ "forceUpdateThemes"
62
+ ]);
63
+ const ZERO_PROVIDER_EXPORTS = /* @__PURE__ */ new Set([
64
+ "TamaguiProvider",
65
+ "ThemeProvider",
66
+ "TamaguiRoot"
67
+ ]);
68
+ const ZERO_ANIMATED_NUMBER_HOOKS = /* @__PURE__ */ new Set([
69
+ "useAnimatedNumber",
70
+ "useAnimatedNumberStyle",
71
+ "useAnimatedNumbersStyle",
72
+ "useAnimatedNumberReaction"
73
+ ]);
74
+ const ZERO_ANIMATED_NUMBER_MODULE = "@tamagui/animations-css/animated-number";
75
+ function zeroRuleMessage(rule, params) {
76
+ const component = params.component ?? "this component";
77
+ switch (rule) {
78
+ case 1: return `Zero-runtime rule 1: ${component} cannot receive a prop spread because the compiler cannot prove it is style-free. Pass non-style props explicitly or move this module to a full-runtime island.`;
79
+ case 2: return `Zero-runtime rule 2: component expression ${params.expression ?? component} does not resolve to one literal lowerable host component. Use a literal Tamagui or html.* component, or move this module to a full-runtime island.`;
80
+ case 3: return `Zero-runtime rule 3: value for ${params.prop ?? "a style prop"} on ${component} cannot be lowered: ${params.detail ?? "the compiler could not evaluate it"}. Use a supported build-time value or move this module to a full-runtime island.`;
81
+ case 4: return `Zero-runtime rule 4: ${params.detail ?? component} requires runtime theme or config state. Theme names and modifier targets must be statically enumerable, Theme value props and config must be build-time data, and runtime mutation belongs in a full-runtime island.`;
82
+ case 5: return `Zero-runtime rule 5: ${params.detail ?? component} requires a component animation runtime. Use a static CSS transition or move this module to a full-runtime island.`;
83
+ case 6: return `Zero-runtime rule 6: ${component} does not lower to one host element with className and is island-only. Move this module to a declared full-runtime island.`;
84
+ case 7: return `Zero-runtime rule 7: ${params.api ?? component} reads Tamagui design state in JavaScript. Express the condition in CSS or move this module to a full-runtime island.`;
85
+ case 8: return `Zero-runtime rule 8: ${params.detail ?? "a module-level import"} defeats the zero-runtime graph. ${params.remediation ?? ""}`.trimEnd();
86
+ }
87
+ }
88
+ function zeroSideEffectImportMessage(specifier) {
89
+ return zeroRuleMessage(8, {
90
+ detail: `the bare side-effect import of "${specifier}", whose effects zero-runtime cannot prove or erase,`,
91
+ remediation: `Remove it, or import the values this module uses so the compiler can lower and erase them.`
92
+ });
93
+ }
94
+ function zeroStaticIslandImportMessage(specifier, islandId) {
95
+ return zeroRuleMessage(8, {
96
+ detail: `the static import of "${specifier}", which is declared as full-runtime island "${islandId}",`,
97
+ remediation: `Import the generated island loader instead; the island is a separately built entry and the zero graph never contains it.`
98
+ });
99
+ }
100
+ const ZERO_PROVIDER_MESSAGE = "[tamagui zero-runtime] Rule 4: TamaguiProvider is not used by a zero-runtime root. The bundler loads generated CSS and the compiler lowers static Theme nodes. Remove this provider or make this entry full-runtime.";
101
+ function zeroThemeBoundaryMessage(component, prop) {
102
+ return `[tamagui zero-runtime] Rule 4: ${component} uses ${prop}, which creates a runtime component theme boundary. Replace it with a static <Theme name="..."> wrapper (use name="inverse" for themeInverse) or move this module to a full-runtime island.`;
103
+ }
104
+ function zeroConfigDriverMessage(name, outputStyle) {
105
+ return `[tamagui zero-runtime] Rule 5: createTamagui animations must resolve to the CSS driver. Driver ${name} has outputStyle=${String(outputStyle)}. Remove it from the zero entry or move its consumers to a full-runtime island.`;
106
+ }
107
+ function zeroIslandThemeMessage(entry) {
108
+ return `[tamagui zero-runtime] Rule 4: island ${entry} has no statically resolved theme context at this mount. Place the island boundary under a compiler-visible static <Theme> or make this entry full-runtime.`;
109
+ }
110
+ function zeroViolationsFromPlan(plan) {
111
+ const violations = [];
112
+ for (const diagnostic of plan.diagnostics) {
113
+ if (!diagnostic.blocking) continue;
114
+ const rule = (0, import_diagnostics.zeroRuleForBailout)(diagnostic);
115
+ violations.push({
116
+ rule,
117
+ code: diagnostic.code,
118
+ span: diagnostic.span,
119
+ component: diagnostic.component,
120
+ message: diagnostic.zeroMessage ?? zeroRuleMessage(rule, {
121
+ component: diagnostic.component,
122
+ prop: diagnostic.prop,
123
+ detail: diagnostic.message
124
+ })
125
+ });
126
+ }
127
+ return violations;
128
+ }
129
+ function collectNameOccurrences(program) {
130
+ const occurrences = /* @__PURE__ */ new Map();
131
+ (0, import_ast.walkAst)(program, (node, parent, key) => {
132
+ if (node.type !== "Identifier" && node.type !== "JSXIdentifier") return;
133
+ const name = typeof node.name === "string" ? node.name : null;
134
+ if (!name) return;
135
+ if (parent) {
136
+ if (parent.type === "ImportSpecifier" || parent.type === "ImportDefaultSpecifier" || parent.type === "ImportNamespaceSpecifier" || parent.type === "ExportSpecifier") {
137
+ return;
138
+ }
139
+ if ((parent.type === "MemberExpression" || parent.type === "JSXMemberExpression" || parent.type === "OptionalMemberExpression") && key === "property" && !parent.computed) {
140
+ return;
141
+ }
142
+ if ((parent.type === "Property" || parent.type === "PropertyDefinition") && key === "key" && !parent.computed) {
143
+ return;
144
+ }
145
+ if (parent.type === "JSXAttribute" && key === "name") return;
146
+ if ((parent.type === "VariableDeclarator" || parent.type === "FunctionDeclaration" || parent.type === "ClassDeclaration") && key === "id") {
147
+ return;
148
+ }
149
+ }
150
+ const entry = {
151
+ start: node.start,
152
+ end: node.end,
153
+ parent: parent ?? null
154
+ };
155
+ const list = occurrences.get(name);
156
+ if (list) list.push(entry);
157
+ else occurrences.set(name, [entry]);
158
+ });
159
+ return occurrences;
160
+ }
161
+ function coversRange(outer, inner) {
162
+ return outer.start <= inner.start && outer.end >= inner.end;
163
+ }
164
+ function stringValueOf(node) {
165
+ return node && typeof node.value === "string" ? node.value : null;
166
+ }
167
+ function identifierNameOf(node) {
168
+ return node && node.type === "Identifier" && typeof node.name === "string" ? node.name : null;
169
+ }
170
+ function referenceExpression(source, reference) {
171
+ const parent = reference.parent;
172
+ const node = parent && (parent.type === "ConditionalExpression" || parent.type === "LogicalExpression" || parent.type === "CallExpression" || parent.type === "MemberExpression" || parent.type === "ArrayExpression") ? parent : reference;
173
+ const text = source.slice(node.start, node.end).replace(/\s+/g, " ").trim();
174
+ return text.length > 80 ? `${text.slice(0, 77)}...` : text;
175
+ }
176
+ function collectStyledDeclarators(program, styledLocals) {
177
+ const found = [];
178
+ for (const statement of (0, import_ast.childNodes)(program, "body")) {
179
+ const exported = statement.type === "ExportNamedDeclaration";
180
+ const declaration = exported ? (0, import_ast.childNode)(statement, "declaration") : statement;
181
+ if (!declaration || declaration.type !== "VariableDeclaration") continue;
182
+ const declarators = (0, import_ast.childNodes)(declaration, "declarations");
183
+ if (declarators.length !== 1) continue;
184
+ const declarator = declarators[0];
185
+ const name = identifierNameOf((0, import_ast.childNode)(declarator, "id"));
186
+ const init = (0, import_ast.childNode)(declarator, "init");
187
+ if (!name || !init || init.type !== "CallExpression") continue;
188
+ const callee = identifierNameOf((0, import_ast.childNode)(init, "callee"));
189
+ if (!callee || !styledLocals.has(callee)) continue;
190
+ found.push({
191
+ name,
192
+ declarator,
193
+ declaration: exported ? statement : declaration,
194
+ exported
195
+ });
196
+ }
197
+ return found;
198
+ }
199
+ function planZeroErasure(input) {
200
+ const { id, source, loweredEdits } = input;
201
+ const program = (0, import_yuku.parseModuleAst)(source, id);
202
+ const violations = [];
203
+ const span = (node) => ({
204
+ id,
205
+ start: node.start,
206
+ end: node.end
207
+ });
208
+ const bindings = [];
209
+ const tamaguiDeclarations = [];
210
+ for (const statement of (0, import_ast.childNodes)(program, "body")) {
211
+ if (statement.type !== "ImportDeclaration") continue;
212
+ if (statement.importKind === "type") continue;
213
+ const moduleSpecifier = stringValueOf((0, import_ast.childNode)(statement, "source"));
214
+ if (!moduleSpecifier) continue;
215
+ const islandId = input.islandIdFor(moduleSpecifier);
216
+ if (islandId) {
217
+ violations.push({
218
+ rule: 8,
219
+ code: "zero/static-island-import",
220
+ span: span(statement),
221
+ message: zeroStaticIslandImportMessage(moduleSpecifier, islandId)
222
+ });
223
+ continue;
224
+ }
225
+ if (!input.isTamaguiSpecifier(moduleSpecifier)) continue;
226
+ tamaguiDeclarations.push(statement);
227
+ const specifiers = (0, import_ast.childNodes)(statement, "specifiers");
228
+ if (specifiers.length === 0) {
229
+ violations.push({
230
+ rule: 8,
231
+ code: "zero/side-effect-import",
232
+ span: span(statement),
233
+ message: zeroSideEffectImportMessage(moduleSpecifier)
234
+ });
235
+ continue;
236
+ }
237
+ for (const specifier of specifiers) {
238
+ if (specifier.importKind === "type") continue;
239
+ const local = identifierNameOf((0, import_ast.childNode)(specifier, "local"));
240
+ if (!local) continue;
241
+ bindings.push({
242
+ local,
243
+ imported: identifierNameOf((0, import_ast.childNode)(specifier, "imported")) ?? local,
244
+ specifierNode: specifier,
245
+ declaration: statement,
246
+ moduleSpecifier
247
+ });
248
+ }
249
+ }
250
+ if (bindings.length === 0) {
251
+ return {
252
+ edits: [],
253
+ removedModules: [],
254
+ removedBindings: [],
255
+ erasedStyledDefinitions: [],
256
+ erasedExports: [],
257
+ rewrittenAnimatedNumberHooks: [],
258
+ liveBindings: [],
259
+ violations
260
+ };
261
+ }
262
+ const consumed = loweredEdits.filter((edit) => edit.end > edit.start).map((edit) => ({
263
+ start: edit.start,
264
+ end: edit.end
265
+ }));
266
+ const occurrences = collectNameOccurrences(program);
267
+ const referencesOf = (local) => occurrences.get(local) ?? [];
268
+ const isConsumed = (reference) => consumed.some((range) => coversRange(range, reference));
269
+ const styledLocals = new Set(bindings.filter((binding) => binding.imported === "styled").map((b) => b.local));
270
+ const erasedStyledDefinitions = [];
271
+ const erasedExports = [];
272
+ const styledEdits = [];
273
+ for (const definition of collectStyledDeclarators(program, styledLocals)) {
274
+ const references = referencesOf(definition.name);
275
+ if (references.length === 0) continue;
276
+ if (!references.every(isConsumed)) continue;
277
+ styledEdits.push({
278
+ start: definition.declaration.start,
279
+ end: definition.declaration.end,
280
+ content: "",
281
+ origin: span(definition.declaration)
282
+ });
283
+ consumed.push({
284
+ start: definition.declaration.start,
285
+ end: definition.declaration.end
286
+ });
287
+ erasedStyledDefinitions.push(definition.name);
288
+ if (definition.exported) erasedExports.push(definition.name);
289
+ }
290
+ const animatedNumberBindings = bindings.filter((binding) => ZERO_ANIMATED_NUMBER_HOOKS.has(binding.imported) && referencesOf(binding.local).some((reference) => !isConsumed(reference)));
291
+ const rewrittenAnimatedNumberHooks = animatedNumberBindings.map((binding) => binding.imported);
292
+ const animatedNumberSpecifiers = new Set(animatedNumberBindings.map((binding) => binding.specifierNode));
293
+ const leafImportEdits = [];
294
+ for (const declaration of tamaguiDeclarations) {
295
+ const rewritten = animatedNumberBindings.filter((binding) => binding.declaration === declaration);
296
+ if (rewritten.length === 0) continue;
297
+ leafImportEdits.push({
298
+ start: declaration.start,
299
+ end: declaration.start,
300
+ content: `import { ${rewritten.map((binding) => binding.imported === binding.local ? binding.imported : `${binding.imported} as ${binding.local}`).join(", ")} } from ${JSON.stringify(ZERO_ANIMATED_NUMBER_MODULE)};
301
+ `,
302
+ origin: span(declaration)
303
+ });
304
+ }
305
+ const deadBindings = new Set(animatedNumberSpecifiers);
306
+ const removedBindings = [];
307
+ const liveBindings = [];
308
+ for (const binding of bindings) {
309
+ if (animatedNumberSpecifiers.has(binding.specifierNode)) continue;
310
+ const references = referencesOf(binding.local);
311
+ if (references.length > 0 && !references.every(isConsumed)) {
312
+ liveBindings.push(binding);
313
+ continue;
314
+ }
315
+ deadBindings.add(binding.specifierNode);
316
+ removedBindings.push(binding.local);
317
+ }
318
+ const edits = [...styledEdits, ...leafImportEdits];
319
+ const removedModules = [];
320
+ for (const declaration of tamaguiDeclarations) {
321
+ const specifiers = (0, import_ast.childNodes)(declaration, "specifiers").filter((specifier) => specifier.importKind !== "type");
322
+ if (specifiers.length === 0) continue;
323
+ const dead = specifiers.filter((specifier) => deadBindings.has(specifier));
324
+ if (dead.length === 0) continue;
325
+ if (dead.length === specifiers.length) {
326
+ edits.push({
327
+ start: declaration.start,
328
+ end: declaration.end,
329
+ content: "",
330
+ origin: span(declaration)
331
+ });
332
+ removedModules.push(stringValueOf((0, import_ast.childNode)(declaration, "source")));
333
+ continue;
334
+ }
335
+ const survivors = specifiers.filter((specifier) => !deadBindings.has(specifier));
336
+ const braceStart = specifiers[0].start;
337
+ const braceEnd = specifiers[specifiers.length - 1].end;
338
+ edits.push({
339
+ start: braceStart,
340
+ end: braceEnd,
341
+ content: survivors.map((specifier) => source.slice(specifier.start, specifier.end)).join(", "),
342
+ origin: span({
343
+ start: braceStart,
344
+ end: braceEnd
345
+ })
346
+ });
347
+ }
348
+ for (const binding of liveBindings) {
349
+ const live = referencesOf(binding.local).filter((reference) => !isConsumed(reference))[0];
350
+ if (ZERO_DESIGN_STATE_APIS.has(binding.imported)) {
351
+ violations.push({
352
+ rule: 7,
353
+ code: "zero/design-state-read",
354
+ span: span(live),
355
+ message: zeroRuleMessage(7, { api: binding.imported })
356
+ });
357
+ continue;
358
+ }
359
+ if (ZERO_PROVIDER_EXPORTS.has(binding.imported)) {
360
+ violations.push({
361
+ rule: 4,
362
+ code: "zero/runtime-provider",
363
+ span: span(live),
364
+ component: binding.imported,
365
+ message: ZERO_PROVIDER_MESSAGE
366
+ });
367
+ continue;
368
+ }
369
+ violations.push({
370
+ rule: 2,
371
+ code: "zero/live-tamagui-reference",
372
+ span: span(live),
373
+ component: binding.local,
374
+ message: zeroRuleMessage(2, { expression: referenceExpression(source, live) })
375
+ });
376
+ }
377
+ return {
378
+ edits,
379
+ removedModules,
380
+ removedBindings,
381
+ erasedStyledDefinitions,
382
+ erasedExports,
383
+ rewrittenAnimatedNumberHooks,
384
+ liveBindings: liveBindings.map((binding) => binding.local),
385
+ violations
386
+ };
387
+ }
@@ -0,0 +1,65 @@
1
+ const ignoredKeys = /* @__PURE__ */ new Set([
2
+ "loc",
3
+ "range",
4
+ "parent",
5
+ "comments",
6
+ "tokens"
7
+ ]);
8
+ function isAstNode(value) {
9
+ return typeof value === "object" && value !== null && typeof value.type === "string" && typeof value.start === "number" && typeof value.end === "number";
10
+ }
11
+ function walkAst(node, visitor, parent = null, key = null) {
12
+ visitor(node, parent, key);
13
+ for (const [childKey, value] of Object.entries(node)) {
14
+ if (ignoredKeys.has(childKey)) continue;
15
+ if (isAstNode(value)) {
16
+ walkAst(value, visitor, node, childKey);
17
+ } else if (Array.isArray(value)) {
18
+ for (const child of value) {
19
+ if (isAstNode(child)) {
20
+ walkAst(child, visitor, node, childKey);
21
+ }
22
+ }
23
+ }
24
+ }
25
+ }
26
+ function findAstNode(root, predicate) {
27
+ let found = null;
28
+ walkAst(root, (node, parent, key) => {
29
+ if (!found && predicate(node, parent, key)) {
30
+ found = node;
31
+ }
32
+ });
33
+ return found;
34
+ }
35
+ function childNode(node, key) {
36
+ const value = node[key];
37
+ return isAstNode(value) ? value : null;
38
+ }
39
+ function childNodes(node, key) {
40
+ const value = node[key];
41
+ return Array.isArray(value) ? value.filter(isAstNode) : [];
42
+ }
43
+ function identifierName(node) {
44
+ if (!node || node.type !== "Identifier" && node.type !== "JSXIdentifier") return null;
45
+ return typeof node.name === "string" ? node.name : null;
46
+ }
47
+ function literalValue(node) {
48
+ if (!node) return void 0;
49
+ if (node.type === "Literal" || node.type.endsWith("Literal")) {
50
+ return node.value;
51
+ }
52
+ return void 0;
53
+ }
54
+ function unwrapExpression(node) {
55
+ let current = node;
56
+ while (current.type === "TSAsExpression" || current.type === "TSSatisfiesExpression" || current.type === "TSNonNullExpression" || current.type === "ParenthesizedExpression") {
57
+ const expression = childNode(current, "expression");
58
+ if (!expression) break;
59
+ current = expression;
60
+ }
61
+ return current;
62
+ }
63
+
64
+ export { childNode, childNodes, findAstNode, identifierName, isAstNode, literalValue, unwrapExpression, walkAst };
65
+ //# sourceMappingURL=ast.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast.js","names":[],"sources":["esm/ast.js"],"sourcesContent":["const ignoredKeys = /* @__PURE__ */ new Set([\"loc\", \"range\", \"parent\", \"comments\", \"tokens\"]);\nfunction isAstNode(value) {\n return typeof value === \"object\" && value !== null && typeof value.type === \"string\" && typeof value.start === \"number\" && typeof value.end === \"number\";\n}\nfunction walkAst(node, visitor, parent = null, key = null) {\n visitor(node, parent, key);\n for (const [childKey, value] of Object.entries(node)) {\n if (ignoredKeys.has(childKey)) continue;\n if (isAstNode(value)) {\n walkAst(value, visitor, node, childKey);\n } else if (Array.isArray(value)) {\n for (const child of value) {\n if (isAstNode(child)) {\n walkAst(child, visitor, node, childKey);\n }\n }\n }\n }\n}\nfunction findAstNode(root, predicate) {\n let found = null;\n walkAst(root, (node, parent, key) => {\n if (!found && predicate(node, parent, key)) {\n found = node;\n }\n });\n return found;\n}\nfunction childNode(node, key) {\n const value = node[key];\n return isAstNode(value) ? value : null;\n}\nfunction childNodes(node, key) {\n const value = node[key];\n return Array.isArray(value) ? value.filter(isAstNode) : [];\n}\nfunction identifierName(node) {\n if (!node || node.type !== \"Identifier\" && node.type !== \"JSXIdentifier\") return null;\n return typeof node.name === \"string\" ? node.name : null;\n}\nfunction literalValue(node) {\n if (!node) return void 0;\n if (node.type === \"Literal\" || node.type.endsWith(\"Literal\")) {\n return node.value;\n }\n return void 0;\n}\nfunction unwrapExpression(node) {\n let current = node;\n while (current.type === \"TSAsExpression\" || current.type === \"TSSatisfiesExpression\" || current.type === \"TSNonNullExpression\" || current.type === \"ParenthesizedExpression\") {\n const expression = childNode(current, \"expression\");\n if (!expression) break;\n current = expression;\n }\n return current;\n}\nexport {\n childNode,\n childNodes,\n findAstNode,\n identifierName,\n isAstNode,\n literalValue,\n unwrapExpression,\n walkAst\n};\n//# sourceMappingURL=ast.js.map\n"],"mappings":";AAAA,MAAM,8BAA8B,IAAI,IAAI;CAAC;CAAO;CAAS;CAAU;CAAY;AAAQ,CAAC;AAC5F,SAAS,UAAU,OAAO;CACxB,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,OAAO,MAAM,SAAS,YAAY,OAAO,MAAM,UAAU,YAAY,OAAO,MAAM,QAAQ;AAClJ;AACA,SAAS,QAAQ,MAAM,SAAS,SAAS,MAAM,MAAM,MAAM;CACzD,QAAQ,MAAM,QAAQ,GAAG;CACzB,KAAK,MAAM,CAAC,UAAU,UAAU,OAAO,QAAQ,IAAI,GAAG;EACpD,IAAI,YAAY,IAAI,QAAQ,GAAG;EAC/B,IAAI,UAAU,KAAK,GAAG;GACpB,QAAQ,OAAO,SAAS,MAAM,QAAQ;EACxC,OAAO,IAAI,MAAM,QAAQ,KAAK,GAAG;GAC/B,KAAK,MAAM,SAAS,OAAO;IACzB,IAAI,UAAU,KAAK,GAAG;KACpB,QAAQ,OAAO,SAAS,MAAM,QAAQ;IACxC;GACF;EACF;CACF;AACF;AACA,SAAS,YAAY,MAAM,WAAW;CACpC,IAAI,QAAQ;CACZ,QAAQ,OAAO,MAAM,QAAQ,QAAQ;EACnC,IAAI,CAAC,SAAS,UAAU,MAAM,QAAQ,GAAG,GAAG;GAC1C,QAAQ;EACV;CACF,CAAC;CACD,OAAO;AACT;AACA,SAAS,UAAU,MAAM,KAAK;CAC5B,MAAM,QAAQ,KAAK;CACnB,OAAO,UAAU,KAAK,IAAI,QAAQ;AACpC;AACA,SAAS,WAAW,MAAM,KAAK;CAC7B,MAAM,QAAQ,KAAK;CACnB,OAAO,MAAM,QAAQ,KAAK,IAAI,MAAM,OAAO,SAAS,IAAI,CAAC;AAC3D;AACA,SAAS,eAAe,MAAM;CAC5B,IAAI,CAAC,QAAQ,KAAK,SAAS,gBAAgB,KAAK,SAAS,iBAAiB,OAAO;CACjF,OAAO,OAAO,KAAK,SAAS,WAAW,KAAK,OAAO;AACrD;AACA,SAAS,aAAa,MAAM;CAC1B,IAAI,CAAC,MAAM,OAAO,KAAK;CACvB,IAAI,KAAK,SAAS,aAAa,KAAK,KAAK,SAAS,SAAS,GAAG;EAC5D,OAAO,KAAK;CACd;CACA,OAAO,KAAK;AACd;AACA,SAAS,iBAAiB,MAAM;CAC9B,IAAI,UAAU;CACd,OAAO,QAAQ,SAAS,oBAAoB,QAAQ,SAAS,2BAA2B,QAAQ,SAAS,yBAAyB,QAAQ,SAAS,2BAA2B;EAC5K,MAAM,aAAa,UAAU,SAAS,YAAY;EAClD,IAAI,CAAC,YAAY;EACjB,UAAU;CACZ;CACA,OAAO;AACT"}
@@ -0,0 +1,34 @@
1
+ function resolutionKey(importer, specifier) {
2
+ return `${importer}\0${specifier}`;
3
+ }
4
+ function resolveFromHost(resolutions, specifier, importer) {
5
+ return resolutions.get(resolutionKey(importer, specifier)) ?? null;
6
+ }
7
+ function resolvedModuleId(id) {
8
+ const isAbsolute = id.startsWith("/") || id.startsWith("\\") || id.startsWith("\0") || /^[A-Za-z]:[\\/]/.test(id) || /^[A-Za-z][A-Za-z\d+.-]*:\/\//.test(id);
9
+ if (!isAbsolute) {
10
+ throw new Error(`Host module id must be canonical and already resolved: ${id}`);
11
+ }
12
+ return id;
13
+ }
14
+ function expressionReference(id, node) {
15
+ return {
16
+ kind: "expression",
17
+ id,
18
+ start: node.start,
19
+ end: node.end
20
+ };
21
+ }
22
+ function spanOf(id, node) {
23
+ return {
24
+ id,
25
+ start: node.start,
26
+ end: node.end
27
+ };
28
+ }
29
+ function textOfSpan(source, span) {
30
+ return source.slice(span.start, span.end);
31
+ }
32
+
33
+ export { expressionReference, resolutionKey, resolveFromHost, resolvedModuleId, spanOf, textOfSpan };
34
+ //# sourceMappingURL=contracts.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.js","names":[],"sources":["esm/contracts.js"],"sourcesContent":["function resolutionKey(importer, specifier) {\n return `${importer}\\0${specifier}`;\n}\nfunction resolveFromHost(resolutions, specifier, importer) {\n return resolutions.get(resolutionKey(importer, specifier)) ?? null;\n}\nfunction resolvedModuleId(id) {\n const isAbsolute = id.startsWith(\"/\") || id.startsWith(\"\\\\\") || id.startsWith(\"\\0\") || /^[A-Za-z]:[\\\\/]/.test(id) || /^[A-Za-z][A-Za-z\\d+.-]*:\\/\\//.test(id);\n if (!isAbsolute) {\n throw new Error(`Host module id must be canonical and already resolved: ${id}`);\n }\n return id;\n}\nfunction expressionReference(id, node) {\n return { kind: \"expression\", id, start: node.start, end: node.end };\n}\nfunction spanOf(id, node) {\n return { id, start: node.start, end: node.end };\n}\nfunction textOfSpan(source, span) {\n return source.slice(span.start, span.end);\n}\nexport {\n expressionReference,\n resolutionKey,\n resolveFromHost,\n resolvedModuleId,\n spanOf,\n textOfSpan\n};\n//# sourceMappingURL=contracts.js.map\n"],"mappings":";AAAA,SAAS,cAAc,UAAU,WAAW;CAC1C,OAAO,GAAG,SAAS,IAAI;AACzB;AACA,SAAS,gBAAgB,aAAa,WAAW,UAAU;CACzD,OAAO,YAAY,IAAI,cAAc,UAAU,SAAS,CAAC,KAAK;AAChE;AACA,SAAS,iBAAiB,IAAI;CAC5B,MAAM,aAAa,GAAG,WAAW,GAAG,KAAK,GAAG,WAAW,IAAI,KAAK,GAAG,WAAW,IAAI,KAAK,kBAAkB,KAAK,EAAE,KAAK,+BAA+B,KAAK,EAAE;CAC3J,IAAI,CAAC,YAAY;EACf,MAAM,IAAI,MAAM,0DAA0D,IAAI;CAChF;CACA,OAAO;AACT;AACA,SAAS,oBAAoB,IAAI,MAAM;CACrC,OAAO;EAAE,MAAM;EAAc;EAAI,OAAO,KAAK;EAAO,KAAK,KAAK;CAAI;AACpE;AACA,SAAS,OAAO,IAAI,MAAM;CACxB,OAAO;EAAE;EAAI,OAAO,KAAK;EAAO,KAAK,KAAK;CAAI;AAChD;AACA,SAAS,WAAW,QAAQ,MAAM;CAChC,OAAO,OAAO,MAAM,KAAK,OAAO,KAAK,GAAG;AAC1C"}
@@ -0,0 +1,44 @@
1
+ const ZERO_RULE_BY_CODE = {
2
+ "local/invalid-element-call": 2,
3
+ "local/unsupported-element-name": 2,
4
+ "local/unsupported-prop-key": 3,
5
+ "local/unsupported-child": 3,
6
+ "local/unsupported-expression": 3,
7
+ "local/unsupported-styled-definition": 3,
8
+ "local/dynamic-style-value": 3,
9
+ "local/unsafe-style-spread": 1,
10
+ "local/unsupported-target": 6,
11
+ "local/style-resolution-failed": 3,
12
+ "local/overlapping-edit": 6,
13
+ "local/non-object-spread": 1,
14
+ "local/static-evaluation-cycle": 3,
15
+ "local/parse-error": 3,
16
+ "linked/unresolved-component-binding": 2,
17
+ "linked/unresolved-binding": 2,
18
+ "linked/missing-initializer": 3,
19
+ "linked/unresolved-import": 2,
20
+ "linked/unresolved-component-config": 2
21
+ };
22
+ function zeroRuleForBailout(reason) {
23
+ return reason.zeroRule ?? ZERO_RULE_BY_CODE[reason.code];
24
+ }
25
+ function localBailout(code, span, message) {
26
+ return {
27
+ code,
28
+ kind: "local",
29
+ message,
30
+ span
31
+ };
32
+ }
33
+ function linkedBailout(code, span, message, dependencyId) {
34
+ return {
35
+ code,
36
+ kind: "linked",
37
+ message,
38
+ span,
39
+ dependencyId
40
+ };
41
+ }
42
+
43
+ export { linkedBailout, localBailout, zeroRuleForBailout };
44
+ //# sourceMappingURL=diagnostics.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.js","names":[],"sources":["esm/diagnostics.js"],"sourcesContent":["const ZERO_RULE_BY_CODE = {\n \"local/invalid-element-call\": 2,\n \"local/unsupported-element-name\": 2,\n \"local/unsupported-prop-key\": 3,\n \"local/unsupported-child\": 3,\n \"local/unsupported-expression\": 3,\n \"local/unsupported-styled-definition\": 3,\n \"local/dynamic-style-value\": 3,\n \"local/unsafe-style-spread\": 1,\n \"local/unsupported-target\": 6,\n \"local/style-resolution-failed\": 3,\n \"local/overlapping-edit\": 6,\n \"local/non-object-spread\": 1,\n \"local/static-evaluation-cycle\": 3,\n \"local/parse-error\": 3,\n \"linked/unresolved-component-binding\": 2,\n \"linked/unresolved-binding\": 2,\n \"linked/missing-initializer\": 3,\n \"linked/unresolved-import\": 2,\n \"linked/unresolved-component-config\": 2\n};\nfunction zeroRuleForBailout(reason) {\n return reason.zeroRule ?? ZERO_RULE_BY_CODE[reason.code];\n}\nfunction localBailout(code, span, message) {\n return { code, kind: \"local\", message, span };\n}\nfunction linkedBailout(code, span, message, dependencyId) {\n return { code, kind: \"linked\", message, span, dependencyId };\n}\nexport {\n linkedBailout,\n localBailout,\n zeroRuleForBailout\n};\n//# sourceMappingURL=diagnostics.js.map\n"],"mappings":";AAAA,MAAM,oBAAoB;CACxB,8BAA8B;CAC9B,kCAAkC;CAClC,8BAA8B;CAC9B,2BAA2B;CAC3B,gCAAgC;CAChC,uCAAuC;CACvC,6BAA6B;CAC7B,6BAA6B;CAC7B,4BAA4B;CAC5B,iCAAiC;CACjC,0BAA0B;CAC1B,2BAA2B;CAC3B,iCAAiC;CACjC,qBAAqB;CACrB,uCAAuC;CACvC,6BAA6B;CAC7B,8BAA8B;CAC9B,4BAA4B;CAC5B,sCAAsC;AACxC;AACA,SAAS,mBAAmB,QAAQ;CAClC,OAAO,OAAO,YAAY,kBAAkB,OAAO;AACrD;AACA,SAAS,aAAa,MAAM,MAAM,SAAS;CACzC,OAAO;EAAE;EAAM,MAAM;EAAS;EAAS;CAAK;AAC9C;AACA,SAAS,cAAc,MAAM,MAAM,SAAS,cAAc;CACxD,OAAO;EAAE;EAAM,MAAM;EAAU;EAAS;EAAM;CAAa;AAC7D"}