tempo-sdk 0.0.99 → 0.0.102

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 (170) hide show
  1. package/README.md +3 -403
  2. package/dist/assets/editor.d.ts +43 -65
  3. package/dist/assets/editor.js +1 -573
  4. package/dist/assets/index.d.ts +11 -61
  5. package/dist/assets/index.js +1 -338
  6. package/dist/assets/parser.d.ts +68 -78
  7. package/dist/assets/parser.js +1 -33
  8. package/dist/astro/asset-preview-client.d.ts +3 -2
  9. package/dist/astro/asset-preview-client.js +1 -93
  10. package/dist/astro/controls.d.ts +1 -3
  11. package/dist/astro/controls.js +1 -7
  12. package/dist/astro/document-client.d.ts +5 -6
  13. package/dist/astro/document-client.js +1 -78
  14. package/dist/astro/runtime.d.ts +23 -11
  15. package/dist/astro/runtime.js +1 -86
  16. package/dist/astro.d.ts +19 -13
  17. package/dist/astro.js +1 -818
  18. package/dist/canvas/astro-contract.d.ts +0 -3
  19. package/dist/canvas/astro-contract.js +1 -9
  20. package/dist/canvas/astro.d.ts +3 -4
  21. package/dist/canvas/astro.js +1 -42
  22. package/dist/canvas/editor.d.ts +187 -183
  23. package/dist/canvas/editor.js +1 -1094
  24. package/dist/canvas/flutter-preview.d.ts +0 -1
  25. package/dist/canvas/flutter-preview.js +1 -9
  26. package/dist/canvas/index.d.ts +46 -100
  27. package/dist/canvas/index.js +1 -3926
  28. package/dist/canvas/interact-projection.d.ts +7 -5
  29. package/dist/canvas/interact-projection.js +1 -12
  30. package/dist/canvas/parser.d.ts +10 -303
  31. package/dist/canvas/parser.js +1 -30
  32. package/dist/canvas/svelte.d.ts +6 -7
  33. package/dist/canvas/svelte.js +1 -91
  34. package/dist/canvas/vue.d.ts +9 -49
  35. package/dist/canvas/vue.js +1 -264
  36. package/dist/chunk-CXCUJCXD.js +1 -0
  37. package/dist/chunk-FH6TMWFA.js +1 -0
  38. package/dist/chunk-FL7FSJSL.js +1 -0
  39. package/dist/chunk-GQIOB5SV.js +1 -0
  40. package/dist/chunk-HBQ7FFH7.js +1 -0
  41. package/dist/chunk-JRJOWLCN.js +1 -0
  42. package/dist/chunk-LJCBFTMP.js +1 -0
  43. package/dist/chunk-M3GN2KUH.js +1 -0
  44. package/dist/chunk-MPIHFFML.js +1 -0
  45. package/dist/chunk-T5TY3U2H.js +1 -0
  46. package/dist/chunk-XO2BSHWM.js +1 -0
  47. package/dist/chunk-XUSV3KOD.js +1 -0
  48. package/dist/chunk-ZXBMP6RV.js +1 -0
  49. package/dist/{controls-uCaQ3CNX.d.ts → controls-DKslABtM.d.ts} +0 -3
  50. package/dist/expo/plugin.cjs +1 -1928
  51. package/dist/expo/plugin.js +1 -8
  52. package/dist/expo-babel-plugin.cjs +1 -1928
  53. package/dist/expo-babel-plugin.d.cts +46 -40
  54. package/dist/expo-babel-plugin.d.ts +46 -40
  55. package/dist/expo-babel-plugin.js +1 -8
  56. package/dist/flutter-preview-path.d.ts +23 -7
  57. package/dist/flutter-preview-path.js +1 -16
  58. package/dist/index.d.ts +33 -45
  59. package/dist/index.js +1 -20
  60. package/dist/nextjs/plugin.cjs +1 -413
  61. package/dist/nextjs/plugin.js +1 -7
  62. package/dist/nextjs-loader.cjs +1 -2277
  63. package/dist/nextjs.cjs +1 -484
  64. package/dist/nextjs.d.cts +2 -58
  65. package/dist/nextjs.d.ts +2 -58
  66. package/dist/nextjs.js +1 -17
  67. package/dist/nuxt/runtime/identity.d.ts +2 -4
  68. package/dist/nuxt/runtime/identity.js +1 -18
  69. package/dist/nuxt.d.ts +31 -92
  70. package/dist/nuxt.js +1 -5854
  71. package/dist/{page-DwLnOM5d.d.ts → page-Bc8PekIX.d.ts} +1 -5
  72. package/dist/parser.d-MO5ciJ5n.d.ts +236 -0
  73. package/dist/{storyboard-CMJVBSXn.d.ts → storyboard.contract.d-UQ4MUYN5.d.ts} +3 -25
  74. package/dist/svelte.d.ts +8 -18
  75. package/dist/svelte.js +1 -917
  76. package/dist/types-CfUgM2w4.d.ts +57 -0
  77. package/dist/v1-client-compat-n0E0XxuX.d.ts +5 -0
  78. package/dist/vue.d.ts +17 -58
  79. package/dist/vue.js +1 -1501
  80. package/package.json +12 -62
  81. package/dist/assets/editor.js.map +0 -1
  82. package/dist/assets/index.js.map +0 -1
  83. package/dist/assets/parser.js.map +0 -1
  84. package/dist/astro/asset-preview-client.js.map +0 -1
  85. package/dist/astro/controls.js.map +0 -1
  86. package/dist/astro/document-client.js.map +0 -1
  87. package/dist/astro/runtime.js.map +0 -1
  88. package/dist/astro.js.map +0 -1
  89. package/dist/canvas/astro-contract.js.map +0 -1
  90. package/dist/canvas/astro.js.map +0 -1
  91. package/dist/canvas/editor.js.map +0 -1
  92. package/dist/canvas/flutter-preview.js.map +0 -1
  93. package/dist/canvas/index.js.map +0 -1
  94. package/dist/canvas/interact-projection.js.map +0 -1
  95. package/dist/canvas/parser.js.map +0 -1
  96. package/dist/canvas/svelte.js.map +0 -1
  97. package/dist/canvas/vue.js.map +0 -1
  98. package/dist/chunk-27WT3XUG.js +0 -455
  99. package/dist/chunk-27WT3XUG.js.map +0 -1
  100. package/dist/chunk-5HIIF354.js +0 -67
  101. package/dist/chunk-5HIIF354.js.map +0 -1
  102. package/dist/chunk-65B52AR7.js +0 -11
  103. package/dist/chunk-65B52AR7.js.map +0 -1
  104. package/dist/chunk-6HYKKP5N.js +0 -2658
  105. package/dist/chunk-6HYKKP5N.js.map +0 -1
  106. package/dist/chunk-6SOP4XU6.js +0 -1891
  107. package/dist/chunk-6SOP4XU6.js.map +0 -1
  108. package/dist/chunk-AFXE462X.js +0 -1253
  109. package/dist/chunk-AFXE462X.js.map +0 -1
  110. package/dist/chunk-BQPKOVI5.js +0 -115
  111. package/dist/chunk-BQPKOVI5.js.map +0 -1
  112. package/dist/chunk-CYDF4LYJ.js +0 -342
  113. package/dist/chunk-CYDF4LYJ.js.map +0 -1
  114. package/dist/chunk-CYQE3TLC.js +0 -37
  115. package/dist/chunk-CYQE3TLC.js.map +0 -1
  116. package/dist/chunk-DI2ZFAWL.js +0 -14
  117. package/dist/chunk-DI2ZFAWL.js.map +0 -1
  118. package/dist/chunk-EGRHWZRV.js +0 -1
  119. package/dist/chunk-EGRHWZRV.js.map +0 -1
  120. package/dist/chunk-FGWGY3G3.js +0 -157
  121. package/dist/chunk-FGWGY3G3.js.map +0 -1
  122. package/dist/chunk-HOBTDB6G.js +0 -112
  123. package/dist/chunk-HOBTDB6G.js.map +0 -1
  124. package/dist/chunk-I7VF4ZOV.js +0 -630
  125. package/dist/chunk-I7VF4ZOV.js.map +0 -1
  126. package/dist/chunk-JVVHU3A7.js +0 -1077
  127. package/dist/chunk-JVVHU3A7.js.map +0 -1
  128. package/dist/chunk-MIXQVPDH.js +0 -8606
  129. package/dist/chunk-MIXQVPDH.js.map +0 -1
  130. package/dist/chunk-MU7S7NU7.js +0 -183
  131. package/dist/chunk-MU7S7NU7.js.map +0 -1
  132. package/dist/chunk-OX2YKYSL.js +0 -13
  133. package/dist/chunk-OX2YKYSL.js.map +0 -1
  134. package/dist/chunk-PYAJHLXO.js +0 -903
  135. package/dist/chunk-PYAJHLXO.js.map +0 -1
  136. package/dist/chunk-SGN7BDRE.js +0 -16
  137. package/dist/chunk-SGN7BDRE.js.map +0 -1
  138. package/dist/chunk-SGTGDLOX.js +0 -285
  139. package/dist/chunk-SGTGDLOX.js.map +0 -1
  140. package/dist/chunk-T364NBR3.js +0 -1440
  141. package/dist/chunk-T364NBR3.js.map +0 -1
  142. package/dist/chunk-U66QI3EN.js +0 -1524
  143. package/dist/chunk-U66QI3EN.js.map +0 -1
  144. package/dist/chunk-WTXOWQ7N.js +0 -47
  145. package/dist/chunk-WTXOWQ7N.js.map +0 -1
  146. package/dist/chunk-X5DJKVBT.js +0 -1308
  147. package/dist/chunk-X5DJKVBT.js.map +0 -1
  148. package/dist/chunk-ZT7HJ6YU.js +0 -38
  149. package/dist/chunk-ZT7HJ6YU.js.map +0 -1
  150. package/dist/chunk-ZW26VZHX.js +0 -3169
  151. package/dist/chunk-ZW26VZHX.js.map +0 -1
  152. package/dist/controls-reader-5MFHYBZZ.js +0 -192
  153. package/dist/controls-reader-5MFHYBZZ.js.map +0 -1
  154. package/dist/expo/plugin.cjs.map +0 -1
  155. package/dist/expo/plugin.js.map +0 -1
  156. package/dist/expo-babel-plugin.cjs.map +0 -1
  157. package/dist/expo-babel-plugin.js.map +0 -1
  158. package/dist/flutter-preview-path.js.map +0 -1
  159. package/dist/index.js.map +0 -1
  160. package/dist/nextjs/plugin.cjs.map +0 -1
  161. package/dist/nextjs/plugin.js.map +0 -1
  162. package/dist/nextjs-loader.cjs.map +0 -1
  163. package/dist/nextjs.cjs.map +0 -1
  164. package/dist/nextjs.js.map +0 -1
  165. package/dist/nuxt/runtime/identity.js.map +0 -1
  166. package/dist/nuxt.js.map +0 -1
  167. package/dist/svelte.js.map +0 -1
  168. package/dist/types-C8OIU-kc.d.ts +0 -106
  169. package/dist/v1-client-compat-qxaXEDm_.d.ts +0 -23
  170. package/dist/vue.js.map +0 -1
package/dist/vue.js CHANGED
@@ -1,1501 +1 @@
1
- import {
2
- defaultSourceRoot,
3
- readModifiedTs,
4
- resolveAnnotationIdentity
5
- } from "./chunk-HOBTDB6G.js";
6
- import "./chunk-EGRHWZRV.js";
7
- import {
8
- MagicString
9
- } from "./chunk-JVVHU3A7.js";
10
- import {
11
- TEMPO_VUE_ANNOTATION_PLUGIN_NAME,
12
- createSdkFileMatcher
13
- } from "./chunk-CYDF4LYJ.js";
14
- import {
15
- appendModuleVersionRecord
16
- } from "./chunk-BQPKOVI5.js";
17
- import {
18
- DYNAMIC_SLOT_FACT,
19
- EXPRESSION_FACTS_ATTRIBUTE,
20
- readLiteralExpression,
21
- sourceVersionHash
22
- } from "./chunk-MU7S7NU7.js";
23
- import {
24
- TEMPO_VUE_INVOCATION_MARKER_PREFIX,
25
- TEMPO_VUE_SOURCE_REGISTRY_GLOBAL
26
- } from "./chunk-SGN7BDRE.js";
27
-
28
- // vue.ts
29
- import { readFileSync } from "fs";
30
- import { isAbsolute as isAbsolute2, relative as relative2, resolve as resolve2 } from "path";
31
-
32
- // ../../modules/vue-editor/escape.ts
33
- function escapeVueAttributeValue(value, quote = '"') {
34
- const escaped = value.split("&").join("&amp;").split('"').join("&quot;").split("<").join("&lt;").split(">").join("&gt;");
35
- return quote === "'" ? escaped.split("'").join("&#39;") : escaped;
36
- }
37
-
38
- // ../../modules/annotation/style-keys.ts
39
- function camelCaseStyleKey(property) {
40
- if (property.startsWith("--")) return property;
41
- return property.replace(/^-ms-/, "ms-").replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
42
- }
43
-
44
- // ../../modules/vue-editor/compiler.ts
45
- import { babelParse, compileTemplate, parse } from "vue/compiler-sfc";
46
-
47
- // ../../modules/vue-editor/parse.ts
48
- var ELEMENT_NODE = 1;
49
- var TEXT_NODE = 2;
50
- var COMMENT_NODE = 3;
51
- var SIMPLE_EXPRESSION_NODE = 4;
52
- var INTERPOLATION_NODE = 5;
53
- var ATTRIBUTE_NODE = 6;
54
- var NATIVE_TAG = 0;
55
- var SVG_NAMESPACE = 1;
56
- var MATH_NAMESPACE = 2;
57
- var COMPONENT_TAG = 1;
58
- var STRUCTURAL_TEMPLATE_TAG = 3;
59
- var BUILT_IN_COMPONENT_TAGS = /* @__PURE__ */ new Set([
60
- "Teleport",
61
- "teleport",
62
- "KeepAlive",
63
- "keep-alive",
64
- "Transition",
65
- "transition",
66
- "TransitionGroup",
67
- "transition-group",
68
- "Suspense",
69
- "suspense",
70
- "BaseTransition",
71
- "base-transition"
72
- ]);
73
- var DYNAMIC_COMPONENT_TAGS = /* @__PURE__ */ new Set(["component", "Component"]);
74
- var STRUCTURAL_DIRECTIVES = /* @__PURE__ */ new Set(["if", "else-if", "else", "for"]);
75
- var CHAIN_OPENING_DIRECTIVES = /* @__PURE__ */ new Set(["if", "else-if"]);
76
- var CHAIN_CONTINUING_DIRECTIVES = /* @__PURE__ */ new Set(["else-if", "else"]);
77
- var LIST_DIRECTIVE = /* @__PURE__ */ new Set(["for"]);
78
- var SLOT_DIRECTIVE = /* @__PURE__ */ new Set(["slot"]);
79
- var SCOPE_DIRECTIVES = /* @__PURE__ */ new Set(["if", "else-if", "else", "for", "slot"]);
80
- var VUE_MERGED_PROP_NAMES = /* @__PURE__ */ new Set([
81
- "class",
82
- "style"
83
- ]);
84
- function parseVueSource(source, filename = "Component.vue") {
85
- const { descriptor, errors } = parse(source, {
86
- filename,
87
- sourceMap: false
88
- });
89
- if (errors.length > 0) {
90
- return {
91
- kind: "invalid",
92
- code: "invalid_vue",
93
- message: errors.map((error) => error.message).join("\n")
94
- };
95
- }
96
- const template = descriptor.template;
97
- if (template?.src) {
98
- return {
99
- kind: "unsupported",
100
- code: "unsupported_template",
101
- message: `<template src="${template.src}"> is outside this file, so its offsets cannot describe it`
102
- };
103
- }
104
- if (template?.lang && template.lang !== "html") {
105
- return {
106
- kind: "unsupported",
107
- code: "unsupported_template",
108
- message: `<template lang="${template.lang}"> offsets would describe the generated HTML, not this file`
109
- };
110
- }
111
- if (template && !template.ast) {
112
- return {
113
- kind: "unsupported",
114
- code: "unsupported_template",
115
- message: "the template has no parsed AST"
116
- };
117
- }
118
- const targets = /* @__PURE__ */ new Map();
119
- let templateBindsAttrs = false;
120
- const visit = (children, parent, parentNode) => {
121
- let allStatic = true;
122
- for (const child of children) {
123
- if (child.type === INTERPOLATION_NODE) allStatic = false;
124
- if (child.type !== ELEMENT_NODE) continue;
125
- const props = child.props.map(readProp);
126
- if (props.some(
127
- (prop) => prop.kind === "bind" && /\$attrs\b/.test(prop.expression ?? "")
128
- )) {
129
- templateBindsAttrs = true;
130
- }
131
- const start = child.loc.start.offset;
132
- const end = child.loc.end.offset;
133
- const propsEnd = props.length > 0 ? Math.max(...props.map((prop) => prop.end)) : start + 1 + child.tag.length;
134
- const openingEnd = source.indexOf(">", propsEnd) + 1;
135
- const selfClosing = child.isSelfClosing === true;
136
- const hasClosingTag = !selfClosing && end > openingEnd;
137
- const kind = vueTargetKind(child);
138
- const vPre = carriesVPre(
139
- source,
140
- start + 1 + child.tag.length,
141
- props,
142
- openingEnd
143
- );
144
- const inVPre = parent !== null && (parent.vPre || parent.inVPre);
145
- const opensScope = kind === "dynamic-element" || isBuiltInComponent(child) || child.tag === "template" || vPre || hasDirective(child, SCOPE_DIRECTIVES);
146
- const info = {
147
- kind,
148
- tagName: child.tag,
149
- namespace: child.ns === SVG_NAMESPACE ? "svg" : child.ns === MATH_NAMESPACE ? "mathml" : "html",
150
- start,
151
- end,
152
- propsEnd,
153
- props,
154
- dynamicSlot: carriesStructuralDirective(child) || ownsDynamicSlot(parentNode),
155
- expressionSlot: hasDirective(child, LIST_DIRECTIVE) || ownsDynamicSlot(parentNode),
156
- parentStart: parent?.start ?? null,
157
- openingEnd,
158
- selfClosing,
159
- // The closing tag is the last `</` of the element's own bytes, even
160
- // in a <textarea> whose text may hold one.
161
- childrenStart: hasClosingTag ? openingEnd : null,
162
- childrenEnd: hasClosingTag ? start + child.loc.source.lastIndexOf("</") : null,
163
- vPre,
164
- inVPre,
165
- opensScope,
166
- scopeOwner: parent === null ? -1 : parent.opensScope ? parent.start : parent.scopeOwner,
167
- staticSubtree: false
168
- };
169
- targets.set(start, info);
170
- const childrenStatic = visit(child.children, info, child);
171
- const ownStatic = !vPre && props.every((prop) => prop.kind === "attribute") && (kind === "native-element" || child.tag === "template");
172
- info.staticSubtree = ownStatic && childrenStatic;
173
- if (!info.staticSubtree) allStatic = false;
174
- }
175
- return allStatic;
176
- };
177
- if (template?.ast) visit(template.ast.children, null, null);
178
- const setupBody = descriptor.scriptSetup ? parseScriptBody(descriptor.scriptSetup) : null;
179
- return {
180
- kind: "ok",
181
- template: template ? {
182
- contentStart: template.loc.start.offset,
183
- contentEnd: template.loc.end.offset
184
- } : null,
185
- targets,
186
- rootFallthrough: readRootFallthrough({
187
- descriptor,
188
- setupBody,
189
- templateBindsAttrs
190
- }),
191
- script: readScriptFacts(descriptor, setupBody)
192
- };
193
- }
194
- function carriesVPre(source, tagNameEnd, props, openingEnd) {
195
- const written = /(?:^|[\s/])v-pre(?=[\s/=>]|$)/;
196
- let cursor = tagNameEnd;
197
- for (const prop of [...props].sort((a, b) => a.start - b.start)) {
198
- if (written.test(source.slice(cursor, prop.start))) return true;
199
- cursor = prop.end;
200
- }
201
- return written.test(source.slice(cursor, openingEnd));
202
- }
203
- function isBuiltInComponent(node) {
204
- return node.tagType === COMPONENT_TAG && BUILT_IN_COMPONENT_TAGS.has(node.tag);
205
- }
206
- function blockFacts(block) {
207
- return {
208
- contentStart: block.loc.start.offset,
209
- contentEnd: block.loc.end.offset,
210
- lang: block.lang ?? null,
211
- src: block.src ?? null
212
- };
213
- }
214
- function readScriptFacts(descriptor, setupBody) {
215
- const setup = descriptor.scriptSetup;
216
- const imports = [];
217
- for (const statement of setupBody ?? []) {
218
- if (statement.type !== "ImportDeclaration") continue;
219
- if (statement.importKind === "type") continue;
220
- for (const specifier of statement.specifiers) {
221
- if (specifier.type === "ImportSpecifier" && specifier.importKind === "type")
222
- continue;
223
- imports.push({
224
- local: specifier.local.name,
225
- source: statement.source.value,
226
- kind: specifier.type === "ImportDefaultSpecifier" ? "default" : specifier.type === "ImportNamespaceSpecifier" ? "namespace" : "named"
227
- });
228
- }
229
- }
230
- return {
231
- setup: setup ? { ...blockFacts(setup), imports } : null,
232
- classic: descriptor.script ? blockFacts(descriptor.script) : null
233
- };
234
- }
235
- function readProp(prop) {
236
- const start = prop.loc.start.offset;
237
- const end = prop.loc.end.offset;
238
- if (prop.type === ATTRIBUTE_NODE) {
239
- const valueLoc = prop.value?.loc;
240
- const delimiter = valueLoc?.source[0];
241
- const quote = delimiter === '"' || delimiter === "'" ? delimiter : null;
242
- return {
243
- kind: "attribute",
244
- name: prop.name,
245
- value: prop.value ? prop.value.content : true,
246
- start,
247
- end,
248
- valueStart: valueLoc ? valueLoc.start.offset + (quote ? 1 : 0) : null,
249
- valueEnd: valueLoc ? valueLoc.end.offset - (quote ? 1 : 0) : null,
250
- quote
251
- };
252
- }
253
- const rawName = prop.rawName ?? prop.loc.source.split("=")[0].trim();
254
- const decoded = prop.exp?.type === SIMPLE_EXPRESSION_NODE ? prop.exp.content : void 0;
255
- const expression = prop.exp === void 0 ? {} : {
256
- expression: prop.exp.loc.source,
257
- ...decoded !== void 0 && decoded !== prop.exp.loc.source ? { decodedExpression: decoded } : {}
258
- };
259
- if (prop.name === "bind") {
260
- const arg = prop.arg;
261
- const staticName = arg?.type === SIMPLE_EXPRESSION_NODE && arg.isStatic ? arg.content : null;
262
- const style = staticName === "style" ? boundStyleObject(prop) : void 0;
263
- const literal = staticName !== null && staticName !== "style" && staticName !== "class" ? boundLiteral(prop) : null;
264
- return {
265
- kind: "bind",
266
- name: staticName,
267
- objectBind: arg === void 0,
268
- rawName,
269
- ...expression,
270
- ...literal ? { literal } : {},
271
- ...style === void 0 ? {} : {
272
- styleKeys: style && style.entries.map((entry) => entry.key),
273
- styleObject: style
274
- },
275
- start,
276
- end
277
- };
278
- }
279
- return {
280
- kind: "directive",
281
- name: prop.name,
282
- rawName,
283
- ...expression,
284
- start,
285
- end
286
- };
287
- }
288
- function boundStyleObject(prop) {
289
- const exp = prop.exp;
290
- if (!exp || exp.type !== SIMPLE_EXPRESSION_NODE) return null;
291
- let ast = exp.ast;
292
- if (ast === void 0) ast = parseWrapped(exp.content);
293
- if (!ast) return null;
294
- const object = unwrapTypeScript(ast);
295
- if (object.type !== "ObjectExpression") return null;
296
- const keys = [];
297
- for (const property of object.properties) {
298
- if (property.type === "SpreadElement" || property.computed) return null;
299
- if (property.key.type === "Identifier") keys.push(property.key.name);
300
- else if (property.key.type === "StringLiteral")
301
- keys.push(camelCaseStyleKey(property.key.value));
302
- else return null;
303
- }
304
- const delimiter = prop.loc.source[exp.loc.start.offset - prop.loc.start.offset - 1];
305
- const quote = delimiter === '"' || delimiter === "'" ? delimiter : null;
306
- const raw = quote === null ? null : rawOffsets(exp.loc.source, exp.content);
307
- const at = (offset) => raw && typeof offset === "number" ? exp.loc.start.offset + raw[offset - 1] : null;
308
- const entries = object.properties.map((property, index) => {
309
- const value = property.type === "ObjectProperty" ? property.value : void 0;
310
- const literal = property.type === "ObjectProperty" && !property.shorthand && raw ? readLiteralExpression(
311
- property.value
312
- ) : null;
313
- return {
314
- key: keys[index],
315
- literal: typeof literal === "string" || typeof literal === "number" ? literal : null,
316
- start: at(property.start),
317
- end: at(property.end),
318
- valueStart: at(value?.start),
319
- valueEnd: at(value?.end)
320
- };
321
- });
322
- return { start: at(object.start), end: at(object.end), quote, entries };
323
- }
324
- function boundLiteral(prop) {
325
- const exp = prop.exp;
326
- if (!exp || exp.type !== SIMPLE_EXPRESSION_NODE) return null;
327
- if (exp.content !== exp.loc.source) return null;
328
- const delimiter = prop.loc.source[exp.loc.start.offset - prop.loc.start.offset - 1];
329
- if (delimiter !== '"' && delimiter !== "'") return null;
330
- let ast = exp.ast;
331
- if (ast === void 0) ast = parseWrapped(exp.content);
332
- if (!ast) return null;
333
- const value = readLiteralExpression(
334
- ast
335
- );
336
- if (typeof value !== "string" && typeof value !== "number") return null;
337
- return {
338
- value,
339
- start: exp.loc.start.offset,
340
- end: exp.loc.end.offset,
341
- quote: delimiter
342
- };
343
- }
344
- var WRITTEN_ENTITIES = {
345
- "&quot;": '"',
346
- "&#39;": "'",
347
- "&lt;": "<",
348
- "&gt;": ">",
349
- "&amp;": "&"
350
- };
351
- function rawOffsets(raw, decoded) {
352
- const offsets = [];
353
- let text = "";
354
- const reference = /&(?:quot|#39|lt|gt|amp);/y;
355
- for (let at = 0; at < raw.length; ) {
356
- reference.lastIndex = at;
357
- const entity = reference.exec(raw)?.[0];
358
- offsets.push(at);
359
- text += entity ? WRITTEN_ENTITIES[entity] : raw[at];
360
- at += entity ? entity.length : 1;
361
- }
362
- offsets.push(raw.length);
363
- return text === decoded ? offsets : null;
364
- }
365
- function parseWrapped(text) {
366
- try {
367
- const program = babelParse(`(${text})`, {
368
- plugins: ["typescript"]
369
- }).program;
370
- const statement = program.body[0];
371
- return statement?.type === "ExpressionStatement" ? statement.expression : null;
372
- } catch {
373
- return null;
374
- }
375
- }
376
- function vueTargetKind(node) {
377
- if (node.tag === "template" || node.tag === "slot") return "special-element";
378
- if (node.tagType === NATIVE_TAG) return "native-element";
379
- if (node.tagType !== COMPONENT_TAG) return "special-element";
380
- if (BUILT_IN_COMPONENT_TAGS.has(node.tag)) return "special-element";
381
- if (DYNAMIC_COMPONENT_TAGS.has(node.tag)) return "dynamic-element";
382
- return "component";
383
- }
384
- function hasDirective(node, names) {
385
- return node.props.some(
386
- (prop) => prop.type !== ATTRIBUTE_NODE && names.has(prop.name)
387
- );
388
- }
389
- function carriesStructuralDirective(node) {
390
- return hasDirective(node, STRUCTURAL_DIRECTIVES);
391
- }
392
- function ownsDynamicSlot(parent) {
393
- if (!parent) return false;
394
- if (parent.tagType === STRUCTURAL_TEMPLATE_TAG) return true;
395
- return parent.tagType === COMPONENT_TAG && hasDirective(parent, SLOT_DIRECTIVE);
396
- }
397
- function readRootFallthrough(options) {
398
- const inheritAttrs = readInheritAttrs(options.descriptor, options.setupBody);
399
- if (inheritAttrs === "unknown") return "unknown";
400
- if (options.templateBindsAttrs) return "explicit-attrs";
401
- if (inheritAttrs === false) return "inherit-attrs-false";
402
- const ast = options.descriptor.template?.ast;
403
- if (!ast) return "unknown";
404
- return classifyTemplateRoots(ast.children);
405
- }
406
- function classifyTemplateRoots(children) {
407
- const groups = [];
408
- let chainOpen = false;
409
- for (const child of children) {
410
- const isComment = child.type === COMMENT_NODE;
411
- const isBlankText = child.type === TEXT_NODE && child.content.trim() === "";
412
- if (isComment || isBlankText) continue;
413
- const element = child.type === ELEMENT_NODE ? child : null;
414
- const continuesChain = chainOpen && element !== null && hasDirective(element, CHAIN_CONTINUING_DIRECTIVES);
415
- const lastGroup = groups[groups.length - 1];
416
- if (continuesChain && lastGroup) lastGroup.push(child);
417
- else groups.push([child]);
418
- chainOpen = element !== null && hasDirective(element, CHAIN_OPENING_DIRECTIVES);
419
- }
420
- const [only, ...others] = groups;
421
- if (!only) return "unknown";
422
- if (others.length > 0) return "multi-root";
423
- const branches = only.map(classifyRootBranch);
424
- if (branches.includes("list")) return "multi-root";
425
- if (branches.every((branch) => branch === "element")) return "single-element";
426
- if (branches.every((branch) => branch === "component"))
427
- return "single-component";
428
- return "unknown";
429
- }
430
- function classifyRootBranch(node) {
431
- if (node.type !== ELEMENT_NODE) return "other";
432
- if (hasDirective(node, LIST_DIRECTIVE)) return "list";
433
- const kind = vueTargetKind(node);
434
- if (kind === "native-element") return "element";
435
- if (kind === "component") return "component";
436
- return "other";
437
- }
438
- function readInheritAttrs(descriptor, setupBody) {
439
- const fromSetup = descriptor.scriptSetup ? readScriptInheritAttrs(setupBody, defineOptionsArgument) : "absent";
440
- if (fromSetup !== "absent") return fromSetup;
441
- const fromOptions = descriptor.script ? readScriptInheritAttrs(
442
- parseScriptBody(descriptor.script),
443
- defaultExportOptions
444
- ) : "absent";
445
- return fromOptions === "absent" ? true : fromOptions;
446
- }
447
- function parseScriptBody(block) {
448
- if (block.src) return null;
449
- try {
450
- return babelParse(block.content, {
451
- sourceType: "module",
452
- plugins: babelPluginsFor(block.lang)
453
- }).program.body;
454
- } catch {
455
- return null;
456
- }
457
- }
458
- function readScriptInheritAttrs(body, findOptions) {
459
- if (body === null) return "unknown";
460
- const options = findOptions(body);
461
- if (options === "absent" || options === "unknown") return options;
462
- return readObjectInheritAttrs(options);
463
- }
464
- function babelPluginsFor(lang) {
465
- if (lang === "ts") return ["typescript"];
466
- if (lang === "tsx") return ["typescript", "jsx"];
467
- if (lang === "jsx") return ["jsx"];
468
- return [];
469
- }
470
- function defineOptionsArgument(body) {
471
- let found = "absent";
472
- for (const statement of body) {
473
- if (statement.type !== "ExpressionStatement") continue;
474
- const call = unwrapTypeScript(statement.expression);
475
- if (call.type !== "CallExpression") continue;
476
- if (call.callee.type !== "Identifier") continue;
477
- if (call.callee.name !== "defineOptions") continue;
478
- const argument = call.arguments[0];
479
- const options = argument && argument.type !== "SpreadElement" ? unwrapTypeScript(argument) : null;
480
- found = options?.type === "ObjectExpression" ? options : "unknown";
481
- }
482
- return found;
483
- }
484
- function defaultExportOptions(body) {
485
- for (const statement of body) {
486
- if (statement.type === "ExportNamedDeclaration") {
487
- const reExportsDefault = statement.specifiers.some(
488
- (specifier) => specifier.exported.type === "Identifier" && specifier.exported.name === "default"
489
- );
490
- if (reExportsDefault) return "unknown";
491
- continue;
492
- }
493
- if (statement.type !== "ExportDefaultDeclaration") continue;
494
- const declaration = statement.declaration;
495
- if (!isExpression(declaration)) return "unknown";
496
- const exported = unwrapTypeScript(declaration);
497
- if (exported.type === "ObjectExpression") return exported;
498
- const options = defineComponentArgument(exported);
499
- return options ?? "unknown";
500
- }
501
- return "absent";
502
- }
503
- function defineComponentArgument(expression) {
504
- if (expression.type !== "CallExpression") return null;
505
- const callee = expression.callee;
506
- const calleeName = callee.type === "Identifier" ? callee.name : callee.type === "MemberExpression" && !callee.computed && callee.property.type === "Identifier" ? callee.property.name : null;
507
- if (calleeName !== "defineComponent") return null;
508
- const argument = expression.arguments[0];
509
- if (!argument || argument.type === "SpreadElement") return null;
510
- const options = unwrapTypeScript(argument);
511
- return options.type === "ObjectExpression" ? options : null;
512
- }
513
- function readObjectInheritAttrs(options) {
514
- let fact = "absent";
515
- let inherits = false;
516
- for (const property of options.properties) {
517
- if (property.type === "SpreadElement" || property.computed) {
518
- fact = "unknown";
519
- continue;
520
- }
521
- const key = property.key.type === "Identifier" ? property.key.name : property.key.type === "StringLiteral" ? property.key.value : null;
522
- if (key === "extends" || key === "mixins") inherits = true;
523
- if (key !== "inheritAttrs") continue;
524
- fact = property.type === "ObjectProperty" && property.value.type === "BooleanLiteral" ? property.value.value : "unknown";
525
- }
526
- if (fact === "absent" && inherits) return "unknown";
527
- return fact;
528
- }
529
- function isExpression(node) {
530
- return node.type !== "FunctionDeclaration" && node.type !== "ClassDeclaration" && node.type !== "TSDeclareFunction" && node.type !== "TSInterfaceDeclaration" && node.type !== "TSTypeAliasDeclaration" && node.type !== "TSEnumDeclaration" && node.type !== "TSModuleDeclaration";
531
- }
532
- function unwrapTypeScript(expression) {
533
- let current = expression;
534
- while (current.type === "TSAsExpression" || current.type === "TSSatisfiesExpression" || current.type === "TSTypeAssertion" || current.type === "TSNonNullExpression" || current.type === "ParenthesizedExpression") {
535
- current = current.expression;
536
- }
537
- return current;
538
- }
539
-
540
- // ../../modules/vue-editor/component-props.ts
541
- import { babelParse as babelParse2 } from "vue/compiler-sfc";
542
- var NOT_PROPS = /* @__PURE__ */ new Set([
543
- "key",
544
- "ref",
545
- "ref_for",
546
- "ref_key",
547
- "is",
548
- "class",
549
- "style",
550
- "slot"
551
- ]);
552
- function readVuePassedProps(source, props) {
553
- const result = {
554
- props: /* @__PURE__ */ Object.create(null)
555
- };
556
- for (const prop of props) {
557
- if (opensEverything(prop)) {
558
- const spread = source.slice(prop.start, prop.end);
559
- result.spread = result.spread ? `${result.spread} ${spread}` : spread;
560
- for (const name2 of Object.keys(result.props))
561
- result.props[name2] = { expression: result.spread };
562
- continue;
563
- }
564
- const passed = passedProp(prop);
565
- if (!passed) continue;
566
- const name = camelize(passed.written);
567
- result.props[name] = passed.value === void 0 ? { expression: expressionText(prop) } : { value: passed.value };
568
- }
569
- return result;
570
- }
571
- function opensEverything(prop) {
572
- return prop.kind === "bind" && (prop.objectBind || prop.name === null);
573
- }
574
- function passedProp(prop) {
575
- if (prop.kind === "attribute")
576
- return NOT_PROPS.has(prop.name) ? null : { prop, written: prop.name, value: prop.value };
577
- if (prop.kind === "bind") {
578
- if (prop.name === null || NOT_PROPS.has(prop.name)) return null;
579
- return {
580
- prop,
581
- written: prop.name,
582
- value: prop.expression === void 0 ? void 0 : literalValue(prop.decodedExpression ?? prop.expression)
583
- };
584
- }
585
- if (prop.name !== "model") return null;
586
- const argument = /^v-model(?::([^.\s[]+))?/.exec(prop.rawName);
587
- if (!argument) return null;
588
- return { prop, written: argument[1] ?? "modelValue", value: void 0 };
589
- }
590
- function expressionText(prop) {
591
- if (prop.kind !== "attribute" && prop.expression !== void 0)
592
- return prop.decodedExpression ?? prop.expression;
593
- if (prop.kind === "attribute") return prop.name;
594
- return prop.kind === "bind" && prop.name !== null ? camelize(prop.name) : prop.rawName;
595
- }
596
- function literalValue(expression) {
597
- let node;
598
- try {
599
- const statement = babelParse2(`(${expression})`, {
600
- sourceType: "module"
601
- }).program.body[0];
602
- node = statement?.type === "ExpressionStatement" ? statement.expression : void 0;
603
- } catch {
604
- return void 0;
605
- }
606
- return node ? literalOf(node) : void 0;
607
- }
608
- function literalOf(node) {
609
- switch (node.type) {
610
- case "StringLiteral":
611
- case "BooleanLiteral":
612
- return node.value;
613
- case "NumericLiteral":
614
- return Number.isFinite(node.value) ? node.value : void 0;
615
- case "NullLiteral":
616
- return null;
617
- case "TemplateLiteral":
618
- return node.expressions.length === 0 ? node.quasis[0]?.value.cooked ?? void 0 : void 0;
619
- case "UnaryExpression":
620
- return node.operator === "-" && node.argument.type === "NumericLiteral" ? -node.argument.value : void 0;
621
- case "ArrayExpression": {
622
- const values = node.elements.map(
623
- (element) => element && element.type !== "SpreadElement" ? literalOf(element) : void 0
624
- );
625
- return values.includes(void 0) ? void 0 : values;
626
- }
627
- case "ObjectExpression": {
628
- const object = /* @__PURE__ */ Object.create(null);
629
- for (const property of node.properties) {
630
- if (property.type !== "ObjectProperty" || property.computed)
631
- return void 0;
632
- const key = property.key.type === "Identifier" ? property.key.name : property.key.type === "StringLiteral" ? property.key.value : null;
633
- const value = literalOf(property.value);
634
- if (key === null || value === void 0) return void 0;
635
- object[key] = value;
636
- }
637
- return object;
638
- }
639
- default:
640
- return void 0;
641
- }
642
- }
643
- function camelize(name) {
644
- return name.replace(/-(\w)/g, (_, char) => char.toUpperCase());
645
- }
646
-
647
- // ../../modules/vue-editor/literal-attributes.ts
648
- var NOT_ATTRIBUTES = /* @__PURE__ */ new Set(["key", "ref", "ref_for", "ref_key", "is"]);
649
- function vueLiteralAttribute(target, name) {
650
- if (target.kind !== "native-element" || target.namespace !== "svg")
651
- return null;
652
- if (VUE_MERGED_PROP_NAMES.has(name.toLowerCase()) || NOT_ATTRIBUTES.has(name) || name.toLowerCase().startsWith("on"))
653
- return null;
654
- if (target.props.some(
655
- (prop) => prop.kind === "bind" && (prop.objectBind || prop.name === null)
656
- ))
657
- return null;
658
- const named = target.props.filter(
659
- (prop) => (prop.kind === "attribute" || prop.kind === "bind") && prop.name?.toLowerCase() === name.toLowerCase()
660
- );
661
- const only = named.length === 1 ? named[0] : null;
662
- if (only?.kind !== "bind" || !only.literal || only.name !== name)
663
- return null;
664
- if (only.rawName !== `:${name}` && only.rawName !== `v-bind:${name}`)
665
- return null;
666
- return only;
667
- }
668
-
669
- // ../../modules/vue-editor/annotate.ts
670
- var TEMPO_STAMP_NAMES = [
671
- "data-tempo-filepath",
672
- "data-tempo-position",
673
- "data-tempo-modifiedts",
674
- "data-tempo-source-version"
675
- ];
676
- var TEMPO_ANNOTATION_NAMES = /* @__PURE__ */ new Set([
677
- ...TEMPO_STAMP_NAMES,
678
- EXPRESSION_FACTS_ATTRIBUTE
679
- ]);
680
- var INVOCATION_MARKER_SPELLINGS = [
681
- "@vue:before-mount",
682
- "v-on:vue:before-mount",
683
- "@vue:beforeMount",
684
- "v-on:vue:beforeMount"
685
- ];
686
- var INVOCATION_MARKER_EXPRESSION = /^function __tempo_c(\d+)\(\)\{\}$/;
687
- var UNRENDERED_PROP_NAMES = /* @__PURE__ */ new Set(["key", "ref", "ref_for", "ref_key"]);
688
- function annotateVueSource(options) {
689
- if (!options.filepath || !options.filename || !Number.isSafeInteger(options.modifiedTs) || options.modifiedTs < 0 || options.sourceVersion === "") {
690
- return refused(
691
- "invalid_metadata",
692
- "filename, filepath, a non-negative integer modifiedTs, and a non-empty sourceVersion are required"
693
- );
694
- }
695
- const parsed = parseVueSource(options.source, options.filename);
696
- if (parsed.kind === "invalid")
697
- return refused("invalid_source", parsed.message);
698
- if (parsed.kind === "unsupported")
699
- return refused("unsupported_template", parsed.message);
700
- const existing = /* @__PURE__ */ new Map();
701
- for (const target of parsed.targets.values()) {
702
- const read = readExistingAnnotation(options.source, target);
703
- if (read === null) continue;
704
- if (read.kind === "refused") return read;
705
- existing.set(target.start, read);
706
- }
707
- const removals = [...existing.values()].map((read) => read.removal);
708
- const baseOffset = (offset) => offset - removals.filter((removal) => removal.end <= offset).reduce((total, removal) => total + removal.end - removal.start, 0);
709
- const version = options.sourceVersion ?? sourceVersionHash(removeRanges(options.source, removals));
710
- const edits = [];
711
- const hosts = [];
712
- const components = [];
713
- const skippedExistingAnnotations = [];
714
- let elementsAnnotated = 0;
715
- for (const target of parsed.targets.values()) {
716
- const isHost = target.kind === "native-element";
717
- const isInvocation = target.kind === "component" || target.kind === "dynamic-element";
718
- if (!isHost && !isInvocation) continue;
719
- const position = baseOffset(target.start);
720
- const isAnnotation = isHost ? isStampProp : isMarkerProp;
721
- const authored = target.props.filter((prop) => !isAnnotation(prop));
722
- const facts = authoredFacts(target, authored, position);
723
- const prior = existing.get(target.start);
724
- if (isHost) {
725
- const metadata = {
726
- filepath: options.filepath,
727
- position,
728
- modifiedTs: options.modifiedTs,
729
- sourceVersion: version
730
- };
731
- hosts.push({ kind: "host", ...facts.record });
732
- if (prior) {
733
- const matches = prior.kind === "stamps" && sameStampMetadata(prior.metadata, metadata) && prior.expressions === facts.expressions;
734
- if (!matches) return identityConflict(target.start);
735
- skippedExistingAnnotations.push(position);
736
- continue;
737
- }
738
- edits.push({
739
- start: target.propsEnd,
740
- end: target.propsEnd,
741
- replacement: serializeStamps(metadata, facts.expressions)
742
- });
743
- elementsAnnotated += 1;
744
- continue;
745
- }
746
- const spelling = markerSpellingFor(authored);
747
- if (spelling === null) continue;
748
- const literalProps = literalPropsOf(options.source, authored);
749
- components.push({
750
- kind: "component",
751
- ...facts.record,
752
- ...facts.locked,
753
- expressions: facts.expressions,
754
- ...literalProps ? { literalProps } : {}
755
- });
756
- if (prior) {
757
- const matches = prior.kind === "marker" && prior.position === position && prior.spelling === spelling;
758
- if (!matches) return identityConflict(target.start);
759
- skippedExistingAnnotations.push(position);
760
- continue;
761
- }
762
- edits.push({
763
- start: target.propsEnd,
764
- end: target.propsEnd,
765
- replacement: serializeMarker(spelling, position)
766
- });
767
- }
768
- const magic = new MagicString(options.source);
769
- for (const edit of edits) magic.appendLeft(edit.start, edit.replacement);
770
- const code = magic.toString();
771
- const reparsed = parseVueSource(code, options.filename);
772
- if (reparsed.kind !== "ok" || reparsed.targets.size !== parsed.targets.size) {
773
- return refused(
774
- "invalid_output",
775
- reparsed.kind === "ok" ? "annotation changed the template's tag structure" : reparsed.message
776
- );
777
- }
778
- return {
779
- kind: "ok",
780
- code,
781
- map: magic.generateMap({
782
- source: options.filename,
783
- includeContent: true,
784
- hires: true
785
- }),
786
- edits,
787
- elementsAnnotated,
788
- skippedExistingAnnotations,
789
- sourceVersion: version,
790
- registry: {
791
- filename: options.filename,
792
- filepath: options.filepath,
793
- modifiedTs: options.modifiedTs,
794
- sourceVersion: version,
795
- components,
796
- hosts,
797
- rootFallthrough: parsed.rootFallthrough
798
- }
799
- };
800
- }
801
- function literalPropsOf(source, props) {
802
- const passing = props.filter(
803
- (prop) => !(prop.kind === "attribute" && prop.name.startsWith("data-tempo-"))
804
- );
805
- const literals = Object.entries(readVuePassedProps(source, passing).props).filter(([, passed]) => "value" in passed).map(([name, passed]) => [name, passed.value]);
806
- return literals.length > 0 ? Object.fromEntries(literals) : void 0;
807
- }
808
- function appendVueSourceRegistryRecord(source, registry) {
809
- const registryObject = `(globalThis.${TEMPO_VUE_SOURCE_REGISTRY_GLOBAL} || (globalThis.${TEMPO_VUE_SOURCE_REGISTRY_GLOBAL} = {}))`;
810
- return `${source}
811
- ;typeof window !== "undefined" && (${registryObject}[${JSON.stringify(registry.filepath)}] = ${JSON.stringify(registry)});
812
- `;
813
- }
814
- function authoredFacts(target, props, position) {
815
- const lastObjectBind = lastIndexWhere(
816
- props,
817
- (prop) => prop.kind === "bind" && prop.objectBind
818
- );
819
- const lastComputedName = lastIndexWhere(
820
- props,
821
- (prop) => prop.kind === "bind" && prop.name === null && !prop.objectBind
822
- );
823
- const canOverrideAnything = lastObjectBind >= 0 || lastComputedName >= 0;
824
- const facts = /* @__PURE__ */ new Set();
825
- if (target.expressionSlot) facts.add(DYNAMIC_SLOT_FACT);
826
- const literals = /* @__PURE__ */ new Map();
827
- const bound = /* @__PURE__ */ new Set();
828
- props.forEach((prop, index) => {
829
- if (prop.kind === "directive") {
830
- if (prop.name !== "for") facts.add(prop.rawName);
831
- return;
832
- }
833
- if (prop.name === null || !isRenderedName(prop.name)) return;
834
- if (prop.kind === "bind") {
835
- if (prop.name === "style" && Array.isArray(prop.styleKeys)) {
836
- const writable = !canOverrideAnything && props.filter((entry) => entry.kind === "bind" && entry.name === "style").length === 1;
837
- const last = /* @__PURE__ */ new Map();
838
- for (const entry of writable ? prop.styleObject?.entries ?? [] : [])
839
- last.set(entry.key, entry.literal);
840
- for (const key of prop.styleKeys)
841
- if ((last.get(key) ?? null) === null) facts.add(`style.${key}`);
842
- return;
843
- }
844
- if (vueLiteralAttribute(target, prop.name)) return;
845
- bound.add(prop.name);
846
- facts.add(factName(prop.name));
847
- return;
848
- }
849
- literals.set(prop.name, prop.value);
850
- const overriddenByObject = index < lastObjectBind && !VUE_MERGED_PROP_NAMES.has(prop.name);
851
- const overriddenByComputedName = index < lastComputedName;
852
- if (overriddenByObject || overriddenByComputedName)
853
- facts.add(factName(prop.name));
854
- });
855
- const className = literals.get("class");
856
- const style = literals.get("style");
857
- const lock = target.props.find(
858
- (prop) => prop.kind === "attribute" && prop.name === "data-tempo-locked"
859
- );
860
- const lockValue = lock?.kind === "attribute" ? lock.value : void 0;
861
- const expressions = [...facts].join(" ");
862
- return {
863
- record: {
864
- name: target.tagName,
865
- position,
866
- ...typeof className === "string" ? { className } : {},
867
- ...typeof style === "string" ? { style } : {},
868
- supportsClassName: !canOverrideAnything && !bound.has("class") && (className === void 0 || typeof className === "string"),
869
- supportsStyle: !canOverrideAnything && !bound.has("style") && (style === void 0 || typeof style === "string")
870
- },
871
- // An object bind or computed name gets a stamp even with no fact, as a
872
- // JSX spread does: what it sets is unknown until runtime.
873
- expressions: expressions || canOverrideAnything ? expressions : void 0,
874
- locked: lockValue === true || lockValue === "true" || lockValue === "" ? { locked: true } : lockValue === "false" ? { locked: false } : {}
875
- };
876
- }
877
- function lastIndexWhere(items, predicate) {
878
- for (let index = items.length - 1; index >= 0; index--) {
879
- if (predicate(items[index])) return index;
880
- }
881
- return -1;
882
- }
883
- function isRenderedName(name) {
884
- return !UNRENDERED_PROP_NAMES.has(name) && !name.startsWith("data-tempo-");
885
- }
886
- function factName(name) {
887
- return name === "class" ? "className" : name;
888
- }
889
- function isStampProp(prop) {
890
- return prop.kind !== "directive" && prop.name !== null && TEMPO_ANNOTATION_NAMES.has(prop.name);
891
- }
892
- function isMarkerProp(prop) {
893
- return prop.kind === "directive" && INVOCATION_MARKER_SPELLINGS.includes(prop.rawName) && INVOCATION_MARKER_EXPRESSION.test(prop.expression ?? "");
894
- }
895
- function markerSpellingFor(authored) {
896
- const taken = new Set(
897
- authored.flatMap(
898
- (prop) => prop.kind === "attribute" ? [] : [prop.rawName]
899
- )
900
- );
901
- return INVOCATION_MARKER_SPELLINGS.find((spelling) => !taken.has(spelling)) ?? null;
902
- }
903
- function readExistingAnnotation(source, target) {
904
- if (target.kind === "native-element")
905
- return readExistingStamps(source, target);
906
- if (target.kind === "component" || target.kind === "dynamic-element")
907
- return readExistingMarker(source, target);
908
- return null;
909
- }
910
- function readExistingStamps(source, target) {
911
- const annotation = target.props.filter(isStampProp);
912
- if (annotation.length === 0) return null;
913
- const expectedNames = [
914
- ...TEMPO_STAMP_NAMES,
915
- ...annotation.length > TEMPO_STAMP_NAMES.length ? [EXPRESSION_FACTS_ATTRIBUTE] : []
916
- ];
917
- const trailing = target.props.slice(-annotation.length);
918
- const values = trailing.map(
919
- (prop) => prop.kind === "attribute" && typeof prop.value === "string" ? prop.value : null
920
- );
921
- const wellFormed = annotation.length === expectedNames.length && trailing.every(
922
- (prop, index) => prop === annotation[index] && prop.kind === "attribute" && prop.name === expectedNames[index] && values[index] !== null
923
- );
924
- if (!wellFormed) return annotationConflict(target.start);
925
- const [filepath, positionText, modifiedText, sourceVersion, expressions] = values;
926
- const position = Number(positionText);
927
- const modifiedTs = Number(modifiedText);
928
- const first = trailing[0];
929
- const last = trailing[trailing.length - 1];
930
- if (!filepath || !sourceVersion || !Number.isSafeInteger(position) || position < 0 || !Number.isSafeInteger(modifiedTs) || modifiedTs < 0) {
931
- return annotationConflict(target.start);
932
- }
933
- const metadata = { filepath, position, modifiedTs, sourceVersion };
934
- const removal = { start: first.start - 1, end: last.end, replacement: "" };
935
- const written = source.slice(removal.start, removal.end);
936
- if (written !== serializeStamps(metadata, expressions))
937
- return annotationConflict(target.start);
938
- return { kind: "stamps", metadata, expressions, removal };
939
- }
940
- function readExistingMarker(source, target) {
941
- const markers = target.props.filter(isMarkerProp);
942
- if (markers.length === 0) return null;
943
- const marker = markers[0];
944
- if (markers.length > 1 || marker !== target.props[target.props.length - 1] || marker.kind !== "directive") {
945
- return annotationConflict(target.start);
946
- }
947
- const position = Number(
948
- INVOCATION_MARKER_EXPRESSION.exec(marker.expression ?? "")?.[1]
949
- );
950
- const removal = { start: marker.start - 1, end: marker.end, replacement: "" };
951
- if (source.slice(removal.start, removal.end) !== serializeMarker(marker.rawName, position))
952
- return annotationConflict(target.start);
953
- return { kind: "marker", spelling: marker.rawName, position, removal };
954
- }
955
- function sameStampMetadata(a, b) {
956
- return a.filepath === b.filepath && a.position === b.position && a.modifiedTs === b.modifiedTs && a.sourceVersion === b.sourceVersion;
957
- }
958
- function serializeStamps(metadata, expressions) {
959
- const values = [
960
- ["data-tempo-filepath", metadata.filepath],
961
- ["data-tempo-position", String(metadata.position)],
962
- ["data-tempo-modifiedts", String(metadata.modifiedTs)],
963
- ["data-tempo-source-version", metadata.sourceVersion],
964
- ...expressions === void 0 ? [] : [[EXPRESSION_FACTS_ATTRIBUTE, expressions]]
965
- ];
966
- return values.map(([name, value]) => ` ${name}="${escapeVueAttributeValue(value)}"`).join("");
967
- }
968
- function serializeMarker(spelling, position) {
969
- return ` ${spelling}="function ${TEMPO_VUE_INVOCATION_MARKER_PREFIX}${position}(){}"`;
970
- }
971
- function removeRanges(source, ranges) {
972
- let result = "";
973
- let cursor = 0;
974
- for (const range of ranges) {
975
- result += source.slice(cursor, range.start);
976
- cursor = range.end;
977
- }
978
- return result + source.slice(cursor);
979
- }
980
- function refused(code, message) {
981
- return { kind: "refused", code, message };
982
- }
983
- function annotationConflict(offset) {
984
- return refused(
985
- "annotation_conflict",
986
- `tag at UTF-16 offset ${offset} has partial, dynamic, reordered, or conflicting Tempo annotations`
987
- );
988
- }
989
- function identityConflict(offset) {
990
- return refused(
991
- "annotation_conflict",
992
- `existing Tempo annotation at UTF-16 offset ${offset} does not exactly match the recovered source identity`
993
- );
994
- }
995
-
996
- // ../../modules/vue-editor/transfer.ts
997
- import {
998
- babelParse as babelParse3,
999
- compileScript,
1000
- extractIdentifiers,
1001
- parse as parseSfc,
1002
- walkIdentifiers
1003
- } from "vue/compiler-sfc";
1004
- var TEMPLATE_GLOBALS = new Set(
1005
- "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error,Symbol".split(",")
1006
- );
1007
-
1008
- // ../../modules/vue-editor/copy.ts
1009
- import { parse as parseSfc2 } from "vue/compiler-sfc";
1010
-
1011
- // app-vite-plugins.ts
1012
- import { existsSync, realpathSync } from "fs";
1013
- import { isAbsolute, join, relative, resolve } from "path";
1014
- var TEMPO_APP_VITE_PLUGINS_ENDPOINT = "/__tempo/app-vite-plugins";
1015
- var VITE_CONFIG_FILES = [
1016
- "vite.config.js",
1017
- "vite.config.mjs",
1018
- "vite.config.ts",
1019
- "vite.config.cjs",
1020
- "vite.config.mts",
1021
- "vite.config.cts"
1022
- ];
1023
- var DROPPED_APP_PLUGINS = [
1024
- {
1025
- // Route-board setup adds them to the app config; the host runs its own
1026
- // copies with host roots.
1027
- names: [
1028
- "tempo-annotate",
1029
- "tempo-vue-source-annotation",
1030
- "tempo-vue-source-records"
1031
- ],
1032
- reason: "Tempo's own plugin, which the host already runs"
1033
- },
1034
- {
1035
- names: [
1036
- "vite:react",
1037
- "@vitejs/plugin-react",
1038
- "vite-tsconfig-paths",
1039
- "@tailwindcss/vite"
1040
- ],
1041
- reason: "the host runs its own copy"
1042
- },
1043
- {
1044
- // Its config hook takes `.tsx` from the React JSX transform that the
1045
- // canvas files need. Vue JSX components are unsupported on the canvas.
1046
- names: ["vite:vue-jsx"],
1047
- reason: "Vue JSX would take .tsx canvas files from React"
1048
- },
1049
- {
1050
- // An overlay injected into the host page, template rewrites after
1051
- // Tempo's stamps, hooks wrapped around every plugin, lint findings
1052
- // turned into board errors.
1053
- names: [
1054
- "vite-plugin-vue-devtools",
1055
- "vite-plugin-vue-inspector",
1056
- "vite-plugin-inspect",
1057
- "vite-plugin-checker",
1058
- "vite:eslint",
1059
- "vite-plugin-eslint",
1060
- "vite-plugin-stylelint"
1061
- ],
1062
- reason: "a dev tool"
1063
- },
1064
- {
1065
- names: ["vite:html", "vite-plugin-html", "vite-plugin-pwa"],
1066
- reason: "serves the app's index.html or service worker"
1067
- },
1068
- {
1069
- // Tempo connects to the host over HTTP.
1070
- names: ["vite:basic-ssl", "vite:mkcert", "vite-plugin-mkcert"],
1071
- reason: "switches the server to HTTPS"
1072
- }
1073
- ];
1074
- var SETUP_HOOKS = /* @__PURE__ */ new Set([
1075
- "config",
1076
- "configResolved",
1077
- "configureServer",
1078
- "buildStart"
1079
- ]);
1080
- var ROOT_VIEW_HOOKS = /* @__PURE__ */ new Set(["config", "configResolved"]);
1081
- var CANVAS_MODULE = /\.canvas\.[jt]sx$/;
1082
- async function loadAppVitePlugins(options) {
1083
- const appRoot = resolve(options.appRoot);
1084
- const configFile = findViteConfigFile(appRoot);
1085
- const report = {
1086
- configFile,
1087
- status: "missing",
1088
- plugins: [],
1089
- disabled: []
1090
- };
1091
- if (!configFile) {
1092
- return [
1093
- createHostSettingsPlugin(report, null, []),
1094
- options.compiler.fallback()
1095
- ];
1096
- }
1097
- let loaded;
1098
- try {
1099
- loaded = await loadAppConfig(configFile, appRoot);
1100
- } catch (error) {
1101
- report.status = "failed";
1102
- report.error = errorMessage(error);
1103
- console.warn(
1104
- `[tempo] Could not load the app's Vite config ${configFile}; component boards render without the app's Vite plugins until it loads: ${report.error}`
1105
- );
1106
- return [
1107
- createHostSettingsPlugin(report, null, [configFile]),
1108
- options.compiler.fallback()
1109
- ];
1110
- }
1111
- report.status = "loaded";
1112
- const appViteRoot = resolve(appRoot, loaded.config.root ?? ".");
1113
- const isTempoOwned = createTempoOwnedModuleMatcher(options.hostRoot);
1114
- const adopted = [];
1115
- let hasCompiler = false;
1116
- for (const plugin of loaded.plugins) {
1117
- const name = plugin.name ?? "";
1118
- const dropReason = droppedReason(name, options.exclude ?? []);
1119
- if (dropReason) {
1120
- report.plugins.push({ name, kept: false, reason: dropReason });
1121
- continue;
1122
- }
1123
- report.plugins.push({ name, kept: true });
1124
- const isCompiler = name === options.compiler.name;
1125
- hasCompiler || (hasCompiler = isCompiler);
1126
- adopted.push(
1127
- adoptAppPlugin(plugin, {
1128
- rootView: isCompiler ? null : appViteRoot,
1129
- isTempoOwned,
1130
- report
1131
- })
1132
- );
1133
- }
1134
- return [
1135
- createHostSettingsPlugin(
1136
- report,
1137
- hostSettingsFromAppConfig(loaded.config, appViteRoot),
1138
- [configFile, ...loaded.dependencies]
1139
- ),
1140
- ...hasCompiler ? [] : [options.compiler.fallback()],
1141
- ...adopted
1142
- ];
1143
- }
1144
- function findViteConfigFile(appRoot) {
1145
- for (const name of VITE_CONFIG_FILES) {
1146
- const file = join(appRoot, name);
1147
- if (existsSync(file)) return file;
1148
- }
1149
- return null;
1150
- }
1151
- var appConfigLoads = Promise.resolve();
1152
- function loadAppConfig(configFile, appRoot) {
1153
- const load = appConfigLoads.then(
1154
- () => loadAppConfigFromAppFolder(configFile, appRoot)
1155
- );
1156
- appConfigLoads = load.catch(() => void 0);
1157
- return load;
1158
- }
1159
- async function loadAppConfigFromAppFolder(configFile, appRoot) {
1160
- const vite = await import("vite");
1161
- const env = {
1162
- command: "serve",
1163
- mode: "development",
1164
- isSsrBuild: false,
1165
- isPreview: false
1166
- };
1167
- const hostCwd = process.cwd();
1168
- process.chdir(appRoot);
1169
- try {
1170
- const loaded = await vite.loadConfigFromFile(
1171
- env,
1172
- configFile,
1173
- appRoot,
1174
- "silent"
1175
- );
1176
- if (!loaded) throw new Error(`${configFile} produced no config`);
1177
- const plugins = await flattenPluginOption(loaded.config.plugins);
1178
- return {
1179
- config: loaded.config,
1180
- plugins,
1181
- // Relative to the working directory the bundler ran in: the app folder.
1182
- dependencies: loaded.dependencies.map((file) => resolve(appRoot, file))
1183
- };
1184
- } finally {
1185
- process.chdir(hostCwd);
1186
- }
1187
- }
1188
- async function flattenPluginOption(option) {
1189
- const value = await option;
1190
- if (!value) return [];
1191
- if (Array.isArray(value)) {
1192
- const nested = await Promise.all(value.map(flattenPluginOption));
1193
- return nested.flat();
1194
- }
1195
- return [value];
1196
- }
1197
- function droppedReason(name, exclude) {
1198
- const matches = (prefix) => prefix !== "" && name.startsWith(prefix);
1199
- for (const rule of DROPPED_APP_PLUGINS) {
1200
- if (rule.names.some(matches)) return rule.reason;
1201
- }
1202
- if (exclude.some(matches)) return "listed in exclude";
1203
- return null;
1204
- }
1205
- function createTempoOwnedModuleMatcher(hostRoot) {
1206
- const resolvedRoot = resolve(hostRoot);
1207
- const roots = [resolvedRoot, realPathOrSelf(resolvedRoot)];
1208
- return (id) => {
1209
- const file = id.split("?", 1)[0] ?? id;
1210
- return CANVAS_MODULE.test(file) || roots.some((root) => isWithin(root, file));
1211
- };
1212
- }
1213
- function realPathOrSelf(path) {
1214
- try {
1215
- return realpathSync(path);
1216
- } catch {
1217
- return path;
1218
- }
1219
- }
1220
- function isWithin(directory, file) {
1221
- const relativePath = relative(directory, file);
1222
- return relativePath === "" || !relativePath.startsWith("..") && !isAbsolute(relativePath);
1223
- }
1224
- function adoptAppPlugin(plugin, scope) {
1225
- delete plugin.transformIndexHtml;
1226
- let disabled = false;
1227
- const disable = (hook, error) => {
1228
- disabled = true;
1229
- const message = errorMessage(error);
1230
- scope.report.disabled.push({ name: plugin.name, hook, error: message });
1231
- console.warn(
1232
- `[tempo] Disabled the app's Vite plugin "${plugin.name}": its ${hook} hook threw: ${message}`
1233
- );
1234
- };
1235
- const hooks = plugin;
1236
- for (const key of Object.keys(hooks)) {
1237
- if (key === "apply") continue;
1238
- const hook = hooks[key];
1239
- const handler = hookHandler(hook);
1240
- if (!handler) continue;
1241
- const appViteRoot = ROOT_VIEW_HOOKS.has(key) ? scope.rootView : null;
1242
- const isSetupHook = SETUP_HOOKS.has(key);
1243
- const wrapped = function(...args) {
1244
- if (disabled) return void 0;
1245
- if (key === "transform" && scope.isTempoOwned(String(args[1]))) {
1246
- return void 0;
1247
- }
1248
- let rootView;
1249
- if (appViteRoot !== null) {
1250
- rootView = withRoot(args[0], appViteRoot);
1251
- args[0] = rootView;
1252
- }
1253
- const keepHostRoot = (result) => key === "config" && rootView ? withoutRoot(result, rootView) : result;
1254
- if (!isSetupHook) return handler.apply(this, args);
1255
- try {
1256
- const result = handler.apply(this, args);
1257
- if (!isPromiseLike(result)) return keepHostRoot(result);
1258
- return Promise.resolve(result).then(
1259
- keepHostRoot,
1260
- (error) => disable(key, error)
1261
- );
1262
- } catch (error) {
1263
- disable(key, error);
1264
- return void 0;
1265
- }
1266
- };
1267
- hooks[key] = typeof hook === "function" ? wrapped : { ...hook, handler: wrapped };
1268
- }
1269
- return plugin;
1270
- }
1271
- function hookHandler(hook) {
1272
- if (typeof hook === "function") return hook;
1273
- if (hook && typeof hook === "object" && "handler" in hook) {
1274
- const { handler } = hook;
1275
- if (typeof handler === "function") return handler;
1276
- }
1277
- return null;
1278
- }
1279
- function withRoot(config, root) {
1280
- if (!config || typeof config !== "object") return config;
1281
- return new Proxy(config, {
1282
- get: (target, key) => key === "root" ? root : Reflect.get(target, key)
1283
- });
1284
- }
1285
- function withoutRoot(result, rootView) {
1286
- if (result === rootView) return void 0;
1287
- if (!result || typeof result !== "object" || !("root" in result)) {
1288
- return result;
1289
- }
1290
- const { root: _appRoot, ...rest } = result;
1291
- return rest;
1292
- }
1293
- function createHostSettingsPlugin(report, settings, dependencies) {
1294
- return {
1295
- name: "tempo-app-vite-config",
1296
- config: () => settings ?? void 0,
1297
- configResolved(config) {
1298
- for (const file of dependencies) {
1299
- const normalized = resolve(file).replace(/\\/g, "/");
1300
- if (!config.configFileDependencies.includes(normalized)) {
1301
- config.configFileDependencies.push(normalized);
1302
- }
1303
- }
1304
- },
1305
- configureServer(server) {
1306
- server.middlewares.use(TEMPO_APP_VITE_PLUGINS_ENDPOINT, (_req, res) => {
1307
- res.statusCode = 200;
1308
- res.setHeader("Cache-Control", "no-store");
1309
- res.setHeader("Content-Type", "application/json; charset=utf-8");
1310
- res.end(JSON.stringify(report));
1311
- });
1312
- }
1313
- };
1314
- }
1315
- function hostSettingsFromAppConfig(app, appViteRoot) {
1316
- const settings = {
1317
- // `import.meta.env.VITE_*` from the app's `.env` files. Vite reads a
1318
- // relative envDir from the root, which here is the app's.
1319
- envDir: app.envDir === false ? false : resolve(appViteRoot, app.envDir ?? ".")
1320
- };
1321
- if (app.envPrefix) settings.envPrefix = app.envPrefix;
1322
- if (app.define) settings.define = app.define;
1323
- if (app.assetsInclude) settings.assetsInclude = app.assetsInclude;
1324
- const resolveSettings = {};
1325
- if (app.resolve?.alias) {
1326
- resolveSettings.alias = withAbsoluteAliases(app.resolve.alias, appViteRoot);
1327
- }
1328
- if (app.resolve?.extensions) {
1329
- resolveSettings.extensions = app.resolve.extensions;
1330
- }
1331
- if (Object.keys(resolveSettings).length > 0) {
1332
- settings.resolve = resolveSettings;
1333
- }
1334
- const cssSettings = {};
1335
- if (app.css?.preprocessorOptions) {
1336
- cssSettings.preprocessorOptions = app.css.preprocessorOptions;
1337
- }
1338
- if (app.css?.modules) cssSettings.modules = app.css.modules;
1339
- if (Object.keys(cssSettings).length > 0) settings.css = cssSettings;
1340
- return settings;
1341
- }
1342
- function withAbsoluteAliases(alias, appViteRoot) {
1343
- const absolute = (replacement) => {
1344
- const appRelative = join(appViteRoot, replacement);
1345
- const isRootRelative = replacement.startsWith("/") && !existsSync(replacement) && existsSync(appRelative);
1346
- return isRootRelative ? appRelative.replace(/\\/g, "/") : replacement;
1347
- };
1348
- if (Array.isArray(alias)) {
1349
- return alias.map((entry) => ({
1350
- ...entry,
1351
- replacement: absolute(entry.replacement)
1352
- }));
1353
- }
1354
- return Object.fromEntries(
1355
- Object.entries(alias).map(
1356
- ([find, replacement]) => [find, absolute(replacement)]
1357
- )
1358
- );
1359
- }
1360
- function isPromiseLike(value) {
1361
- return !!value && typeof value === "object" && typeof value.then === "function";
1362
- }
1363
- function errorMessage(error) {
1364
- return error instanceof Error ? error.message : String(error);
1365
- }
1366
-
1367
- // vue.ts
1368
- var VUE_MAIN_MODULE = /\.vue$/;
1369
- function tempoVuePlugin(options = {}) {
1370
- const root = resolve2(options.root ?? process.cwd());
1371
- const sourceRoot = resolve2(options.sourceRoot ?? defaultSourceRoot(root));
1372
- const enabled = options.enabled ?? Boolean(process.env.TEMPO);
1373
- const excludedDirectories = (options.exclude ?? []).map(
1374
- (directory) => resolve2(directory)
1375
- );
1376
- const isSdkFile = createSdkFileMatcher();
1377
- const annotatedModules = /* @__PURE__ */ new Map();
1378
- const warned = /* @__PURE__ */ new Set();
1379
- const identityFor = (id) => {
1380
- if (!enabled || id.startsWith("\0") || !VUE_MAIN_MODULE.test(id)) {
1381
- return null;
1382
- }
1383
- const identity = resolveAnnotationIdentity(id, { root, sourceRoot });
1384
- if (!identity || isSdkFile(identity.absoluteFilename)) return null;
1385
- if (isUnderAny(identity.absoluteFilename, excludedDirectories)) return null;
1386
- return identity;
1387
- };
1388
- return [
1389
- {
1390
- name: TEMPO_VUE_ANNOTATION_PLUGIN_NAME,
1391
- enforce: "pre",
1392
- // Read by tempoVitePlugin() to report the `vueSourceAnnotation`
1393
- // identity capability: present and enabled means `.vue` files are
1394
- // stamped on this server.
1395
- api: { enabled },
1396
- transform: {
1397
- order: "pre",
1398
- filter: { id: VUE_MAIN_MODULE },
1399
- handler(code, id) {
1400
- annotatedModules.delete(id);
1401
- const identity = identityFor(id);
1402
- if (!identity) return void 0;
1403
- let raw;
1404
- try {
1405
- raw = readFileSync(identity.absoluteFilename, "utf8");
1406
- } catch {
1407
- return void 0;
1408
- }
1409
- const warnOnce = (reason, message) => {
1410
- const key = `${id}\0${reason}`;
1411
- if (warned.has(key)) return;
1412
- warned.add(key);
1413
- this.warn(
1414
- `Tempo did not annotate ${identity.filepath}: ${message}`
1415
- );
1416
- };
1417
- if (code !== raw) {
1418
- warnOnce(
1419
- "drift",
1420
- "an earlier Vite plugin changed the source; put tempoVuePlugin() first"
1421
- );
1422
- return void 0;
1423
- }
1424
- const result = annotateVueSource({
1425
- source: code,
1426
- filename: id,
1427
- filepath: identity.filepath,
1428
- modifiedTs: readModifiedTs(identity.absoluteFilename),
1429
- sourceVersion: sourceVersionHash(raw)
1430
- });
1431
- if (result.kind === "refused") {
1432
- if (result.code !== "invalid_source") {
1433
- warnOnce(result.code, `${result.code}: ${result.message}`);
1434
- }
1435
- return void 0;
1436
- }
1437
- annotatedModules.set(id, result.registry);
1438
- if (result.edits.length === 0) return void 0;
1439
- return { code: result.code, map: result.map };
1440
- }
1441
- }
1442
- },
1443
- {
1444
- name: "tempo-vue-source-records",
1445
- enforce: "post",
1446
- hotUpdate: {
1447
- order: "post",
1448
- handler(context) {
1449
- if (context.type !== "update" || this.environment.config.consumer !== "client" || !identityFor(context.file))
1450
- return;
1451
- if (!annotatedModules.has(context.file)) return;
1452
- const modules = this.environment.moduleGraph.getModulesByFile(
1453
- context.file
1454
- );
1455
- const stamped = [...modules ?? []].filter(
1456
- (module) => module.id === context.file || module.id?.startsWith(`${context.file}?vue&type=template`)
1457
- );
1458
- if (stamped.length)
1459
- return [.../* @__PURE__ */ new Set([...context.modules, ...stamped])];
1460
- }
1461
- },
1462
- transform: {
1463
- filter: { id: VUE_MAIN_MODULE },
1464
- handler(code, id) {
1465
- const registry = annotatedModules.get(id);
1466
- if (!registry) return void 0;
1467
- const withRegistry = appendVueSourceRegistryRecord(code, registry);
1468
- return {
1469
- code: appendModuleVersionRecord(
1470
- withRegistry,
1471
- registry.filepath,
1472
- registry.modifiedTs,
1473
- registry.sourceVersion
1474
- ),
1475
- // Appended after the last line: no mapping moves.
1476
- map: null
1477
- };
1478
- }
1479
- }
1480
- }
1481
- ];
1482
- }
1483
- function tempoVueAppPlugins(options) {
1484
- return loadAppVitePlugins({
1485
- hostRoot: options.root,
1486
- appRoot: options.appRoot,
1487
- compiler: { name: "vite:vue", fallback: options.vue },
1488
- exclude: options.exclude
1489
- });
1490
- }
1491
- function isUnderAny(file, directories) {
1492
- return directories.some((directory) => {
1493
- const relativePath = relative2(directory, file);
1494
- return relativePath === "" || !relativePath.startsWith("..") && !isAbsolute2(relativePath);
1495
- });
1496
- }
1497
- export {
1498
- tempoVueAppPlugins,
1499
- tempoVuePlugin
1500
- };
1501
- //# sourceMappingURL=vue.js.map
1
+ import{a as t}from"./chunk-ZXBMP6RV.js";import{a as o}from"./chunk-XUSV3KOD.js";var n=o(function(e={}){return e.enabled??!!process.env.TEMPO?t("vue",e.root).tempoVuePlugin(e):[{name:"tempo-vue-source-annotation",enforce:"pre",api:{enabled:!1},transform:{order:"pre",handler:o(()=>{},"handler")}},{name:"tempo-vue-source-records",enforce:"post",transform:{order:"post",handler:o(()=>{},"handler")}}]},"tempoVuePlugin"),p=o(function(e){return t("vue",e.root).tempoVueAppPlugins(e)},"tempoVueAppPlugins");export{p as tempoVueAppPlugins,n as tempoVuePlugin};