tempo-sdk 0.0.87 → 0.0.92
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.
- package/dist/astro.js +7 -7
- package/dist/canvas/astro.js +1 -1
- package/dist/canvas/editor.js +1 -1
- package/dist/canvas/index.js +2 -2
- package/dist/canvas/interact-projection.js +1 -1
- package/dist/canvas/parser.js +1 -1
- package/dist/canvas/svelte.js +10 -2
- package/dist/canvas/svelte.js.map +1 -1
- package/dist/canvas/vue.js +1 -1
- package/dist/{chunk-RQ54RXOY.js → chunk-3XEEVCM3.js} +36 -12
- package/dist/chunk-3XEEVCM3.js.map +1 -0
- package/dist/{chunk-2ZQMVAFM.js → chunk-6SOP4XU6.js} +98 -33
- package/dist/chunk-6SOP4XU6.js.map +1 -0
- package/dist/{chunk-Y72PIE3I.js → chunk-AFXE462X.js} +5 -4
- package/dist/{chunk-Y72PIE3I.js.map → chunk-AFXE462X.js.map} +1 -1
- package/dist/{chunk-DMT5MRMS.js → chunk-BQPKOVI5.js} +4 -3
- package/dist/{chunk-DMT5MRMS.js.map → chunk-BQPKOVI5.js.map} +1 -1
- package/dist/{chunk-PTL3UFIF.js → chunk-FENUT2N2.js} +2 -2
- package/dist/{chunk-PTL3UFIF.js.map → chunk-FENUT2N2.js.map} +1 -1
- package/dist/{chunk-H6OZIX2U.js → chunk-FGWGY3G3.js} +27 -3
- package/dist/chunk-FGWGY3G3.js.map +1 -0
- package/dist/{chunk-CXGAJRK7.js → chunk-KQSOE4KZ.js} +7 -7
- package/dist/chunk-MU7S7NU7.js +183 -0
- package/dist/chunk-MU7S7NU7.js.map +1 -0
- package/dist/{chunk-PPIIUCX5.js → chunk-NXPP3CSM.js} +5 -4
- package/dist/chunk-NXPP3CSM.js.map +1 -0
- package/dist/{chunk-GVH7HUMT.js → chunk-RZ3TG6MV.js} +2 -2
- package/dist/{chunk-GVH7HUMT.js.map → chunk-RZ3TG6MV.js.map} +1 -1
- package/dist/{chunk-AUG3ZWTR.js → chunk-TWW2DL7E.js} +2 -2
- package/dist/{chunk-AUG3ZWTR.js.map → chunk-TWW2DL7E.js.map} +1 -1
- package/dist/{chunk-5VIBKVFO.js → chunk-U66QI3EN.js} +28 -18
- package/dist/chunk-U66QI3EN.js.map +1 -0
- package/dist/{controls-reader-Z7OQWYWQ.js → controls-reader-5MFHYBZZ.js} +4 -4
- package/dist/expo/plugin.cjs +97 -32
- package/dist/expo/plugin.cjs.map +1 -1
- package/dist/expo/plugin.js +1 -1
- package/dist/expo-babel-plugin.cjs +97 -32
- package/dist/expo-babel-plugin.cjs.map +1 -1
- package/dist/expo-babel-plugin.d.cts +2 -0
- package/dist/expo-babel-plugin.d.ts +2 -0
- package/dist/expo-babel-plugin.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -6
- package/dist/nextjs/plugin.cjs +1 -1
- package/dist/nextjs/plugin.cjs.map +1 -1
- package/dist/nextjs/plugin.js +1 -1
- package/dist/nextjs-loader.cjs +126 -37
- package/dist/nextjs-loader.cjs.map +1 -1
- package/dist/nextjs.cjs +1 -1
- package/dist/nextjs.cjs.map +1 -1
- package/dist/nextjs.d.cts +2 -0
- package/dist/nextjs.d.ts +2 -0
- package/dist/nextjs.js +1 -1
- package/dist/nuxt/runtime/identity.js +1 -1
- package/dist/nuxt.js +230 -53
- package/dist/nuxt.js.map +1 -1
- package/dist/svelte.js +99 -24
- package/dist/svelte.js.map +1 -1
- package/dist/vue.js +120 -22
- package/dist/vue.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-2ZQMVAFM.js.map +0 -1
- package/dist/chunk-5VIBKVFO.js.map +0 -1
- package/dist/chunk-H6BQZOAW.js +0 -121
- package/dist/chunk-H6BQZOAW.js.map +0 -1
- package/dist/chunk-H6OZIX2U.js.map +0 -1
- package/dist/chunk-PPIIUCX5.js.map +0 -1
- package/dist/chunk-RQ54RXOY.js.map +0 -1
- /package/dist/{chunk-CXGAJRK7.js.map → chunk-KQSOE4KZ.js.map} +0 -0
- /package/dist/{controls-reader-Z7OQWYWQ.js.map → controls-reader-5MFHYBZZ.js.map} +0 -0
package/dist/svelte.js
CHANGED
|
@@ -10,17 +10,30 @@ import {
|
|
|
10
10
|
} from "./chunk-JVVHU3A7.js";
|
|
11
11
|
import {
|
|
12
12
|
appendModuleVersionRecord
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-BQPKOVI5.js";
|
|
14
14
|
import {
|
|
15
|
+
readLiteralExpression,
|
|
15
16
|
sourceVersionHash
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-MU7S7NU7.js";
|
|
17
18
|
|
|
18
19
|
// svelte.ts
|
|
19
20
|
import { readFileSync } from "fs";
|
|
20
21
|
import { resolve } from "path";
|
|
21
22
|
|
|
22
23
|
// ../../modules/svelte-editor/compiler.ts
|
|
23
|
-
import
|
|
24
|
+
import * as SvelteCompiler from "svelte/compiler";
|
|
25
|
+
|
|
26
|
+
// ../../modules/svelte-editor/byte-order-mark.ts
|
|
27
|
+
function withoutByteOrderMark(source) {
|
|
28
|
+
return source.charCodeAt(0) === 65279 ? ` ${source.slice(1)}` : source;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// ../../modules/svelte-editor/compiler.ts
|
|
32
|
+
var compile2 = (source, options) => SvelteCompiler.compile(withoutByteOrderMark(source), options);
|
|
33
|
+
var parse2 = ((source, options) => SvelteCompiler.parse(
|
|
34
|
+
withoutByteOrderMark(source),
|
|
35
|
+
options
|
|
36
|
+
));
|
|
24
37
|
|
|
25
38
|
// ../../modules/svelte-editor/escape.ts
|
|
26
39
|
function escapeSvelteAttributeValue(value, quote) {
|
|
@@ -181,6 +194,50 @@ function walk(ast, { enter, leave }) {
|
|
|
181
194
|
return instance.visit(ast, null);
|
|
182
195
|
}
|
|
183
196
|
|
|
197
|
+
// ../../modules/svelte-editor/literal-attributes.ts
|
|
198
|
+
function literalMustacheAttribute(attribute) {
|
|
199
|
+
const name = attribute.name.toLowerCase();
|
|
200
|
+
if (name === "class" || name === "style" || name.startsWith("on"))
|
|
201
|
+
return null;
|
|
202
|
+
const tag = Array.isArray(attribute.value) ? attribute.value.length === 1 ? attribute.value[0] : void 0 : attribute.value === true ? void 0 : attribute.value;
|
|
203
|
+
if (tag?.type !== "ExpressionTag") return null;
|
|
204
|
+
const expression = tag.expression;
|
|
205
|
+
const value = readLiteralExpression(expression);
|
|
206
|
+
if (typeof value !== "string" && typeof value !== "number") return null;
|
|
207
|
+
return {
|
|
208
|
+
value,
|
|
209
|
+
rendered: String(value),
|
|
210
|
+
expression: { start: expression.start, end: expression.end },
|
|
211
|
+
quoted: Array.isArray(attribute.value)
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// ../../modules/svelte-editor/style-directives.ts
|
|
216
|
+
function normalizeProperty(property) {
|
|
217
|
+
const trimmed = property.trim();
|
|
218
|
+
return trimmed.startsWith("--") ? trimmed : trimmed.toLowerCase();
|
|
219
|
+
}
|
|
220
|
+
function styleDirectives(attributes) {
|
|
221
|
+
return attributes.filter(
|
|
222
|
+
(attribute) => attribute.type === "StyleDirective"
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
function literalStyleDirective(source, directive, siblings) {
|
|
226
|
+
if (directive.modifiers.length > 0) return null;
|
|
227
|
+
if (siblings.some(
|
|
228
|
+
(other) => other !== directive && normalizeProperty(other.name) === normalizeProperty(directive.name)
|
|
229
|
+
))
|
|
230
|
+
return null;
|
|
231
|
+
const value = directive.value;
|
|
232
|
+
if (!Array.isArray(value) || value.length !== 1) return null;
|
|
233
|
+
const text = value[0];
|
|
234
|
+
if (text.type !== "Text") return null;
|
|
235
|
+
const quote = source[text.start - 1];
|
|
236
|
+
if (quote !== '"' && quote !== "'" || source[text.end] !== quote || text.end + 1 !== directive.end)
|
|
237
|
+
return null;
|
|
238
|
+
return { value: text.data, start: text.start, end: text.end, quote };
|
|
239
|
+
}
|
|
240
|
+
|
|
184
241
|
// ../../modules/svelte-editor/parse.ts
|
|
185
242
|
function parseSvelteSourceInternal(source, filename, validation = "compiler") {
|
|
186
243
|
const cacheKey = `${validation}\0${filename}\0${source}`;
|
|
@@ -192,10 +249,11 @@ function parseSvelteSourceInternal(source, filename, validation = "compiler") {
|
|
|
192
249
|
}
|
|
193
250
|
try {
|
|
194
251
|
if (validation === "compiler") {
|
|
195
|
-
|
|
252
|
+
compile2(source, { filename, generate: false });
|
|
196
253
|
}
|
|
197
|
-
const ast =
|
|
254
|
+
const ast = parse2(source, { filename, modern: true });
|
|
198
255
|
const elements = /* @__PURE__ */ new Map();
|
|
256
|
+
const invocations = /* @__PURE__ */ new Map();
|
|
199
257
|
const targets = /* @__PURE__ */ new Map();
|
|
200
258
|
const targetNodes = /* @__PURE__ */ new Map();
|
|
201
259
|
const elementStack = [];
|
|
@@ -208,7 +266,7 @@ function parseSvelteSourceInternal(source, filename, validation = "compiler") {
|
|
|
208
266
|
if (svelteNode.type === "Fragment") {
|
|
209
267
|
const fragment = node;
|
|
210
268
|
const owner = parent;
|
|
211
|
-
const inherits = owner?.type === "RegularElement" && !owner.attributes.some(
|
|
269
|
+
const inherits = (owner?.type === "RegularElement" || owner?.type === "Component" || owner?.type === "SvelteComponent") && !owner.attributes.some(
|
|
212
270
|
(attribute) => attribute.type === "LetDirective"
|
|
213
271
|
) && !fragment.nodes.some(
|
|
214
272
|
(child) => child.type === "ConstTag" || child.type === "SnippetBlock"
|
|
@@ -222,6 +280,7 @@ function parseSvelteSourceInternal(source, filename, validation = "compiler") {
|
|
|
222
280
|
);
|
|
223
281
|
}
|
|
224
282
|
const target = toTargetInfo(
|
|
283
|
+
source,
|
|
225
284
|
node
|
|
226
285
|
);
|
|
227
286
|
if (target) {
|
|
@@ -233,7 +292,8 @@ function parseSvelteSourceInternal(source, filename, validation = "compiler") {
|
|
|
233
292
|
node
|
|
234
293
|
);
|
|
235
294
|
}
|
|
236
|
-
if (svelteNode.type !== "RegularElement")
|
|
295
|
+
if (svelteNode.type !== "RegularElement" && svelteNode.type !== "Component")
|
|
296
|
+
return;
|
|
237
297
|
const element = node;
|
|
238
298
|
const parentFragment = parent;
|
|
239
299
|
if (parentFragment.type !== "Fragment") {
|
|
@@ -245,12 +305,13 @@ function parseSvelteSourceInternal(source, filename, validation = "compiler") {
|
|
|
245
305
|
if (opening.kind === "invalid") {
|
|
246
306
|
throw new Error(opening.message);
|
|
247
307
|
}
|
|
248
|
-
|
|
308
|
+
const into = svelteNode.type === "Component" ? invocations : elements;
|
|
309
|
+
if (into.has(element.start)) {
|
|
249
310
|
throw new Error(
|
|
250
311
|
`multiple native elements start at UTF-16 offset ${element.start}`
|
|
251
312
|
);
|
|
252
313
|
}
|
|
253
|
-
|
|
314
|
+
into.set(element.start, {
|
|
254
315
|
node: element,
|
|
255
316
|
tagName: element.name,
|
|
256
317
|
start: element.start,
|
|
@@ -262,7 +323,8 @@ function parseSvelteSourceInternal(source, filename, validation = "compiler") {
|
|
|
262
323
|
parentElementStart: elementStack[elementStack.length - 1]?.start ?? null,
|
|
263
324
|
parentFragment,
|
|
264
325
|
parentFragmentOwnerType: fragmentOwnerTypes.get(parentFragment) ?? null,
|
|
265
|
-
|
|
326
|
+
// An invocation runs another component's code with its props.
|
|
327
|
+
containsDynamicTemplateSyntax: svelteNode.type === "Component" || containsDynamicSyntax(element),
|
|
266
328
|
attributeNames: element.attributes.filter(
|
|
267
329
|
(attribute) => attribute.type === "Attribute"
|
|
268
330
|
).map((attribute) => attribute.name),
|
|
@@ -273,7 +335,7 @@ function parseSvelteSourceInternal(source, filename, validation = "compiler") {
|
|
|
273
335
|
(attribute) => attribute.type !== "Attribute" && attribute.type !== "SpreadAttribute"
|
|
274
336
|
).map((attribute) => attribute.type)
|
|
275
337
|
});
|
|
276
|
-
elementStack.push(element);
|
|
338
|
+
if (svelteNode.type === "RegularElement") elementStack.push(element);
|
|
277
339
|
},
|
|
278
340
|
leave(node) {
|
|
279
341
|
const svelteNode = node;
|
|
@@ -284,6 +346,7 @@ function parseSvelteSourceInternal(source, filename, validation = "compiler") {
|
|
|
284
346
|
const result = {
|
|
285
347
|
kind: "ok",
|
|
286
348
|
elements,
|
|
349
|
+
invocations,
|
|
287
350
|
templateScopes,
|
|
288
351
|
targets,
|
|
289
352
|
targetNodes
|
|
@@ -296,14 +359,14 @@ function parseSvelteSourceInternal(source, filename, validation = "compiler") {
|
|
|
296
359
|
return result;
|
|
297
360
|
}
|
|
298
361
|
}
|
|
299
|
-
function toTargetInfo(node) {
|
|
362
|
+
function toTargetInfo(source, node) {
|
|
300
363
|
if (node.type === "RegularElement") {
|
|
301
364
|
return {
|
|
302
365
|
kind: "native-element",
|
|
303
366
|
tagName: node.name ?? "",
|
|
304
367
|
start: node.start,
|
|
305
368
|
end: node.end,
|
|
306
|
-
...targetAttributeFacts(node.attributes ?? [])
|
|
369
|
+
...targetAttributeFacts(source, node.attributes ?? [], true)
|
|
307
370
|
};
|
|
308
371
|
}
|
|
309
372
|
if (node.type === "Component") {
|
|
@@ -312,7 +375,7 @@ function toTargetInfo(node) {
|
|
|
312
375
|
tagName: node.name ?? "",
|
|
313
376
|
start: node.start,
|
|
314
377
|
end: node.end,
|
|
315
|
-
...targetAttributeFacts(node.attributes ?? [])
|
|
378
|
+
...targetAttributeFacts(source, node.attributes ?? [])
|
|
316
379
|
};
|
|
317
380
|
}
|
|
318
381
|
if (node.type === "SvelteComponent") {
|
|
@@ -321,7 +384,7 @@ function toTargetInfo(node) {
|
|
|
321
384
|
tagName: node.name ?? node.type,
|
|
322
385
|
start: node.start,
|
|
323
386
|
end: node.end,
|
|
324
|
-
...targetAttributeFacts(node.attributes ?? [])
|
|
387
|
+
...targetAttributeFacts(source, node.attributes ?? [])
|
|
325
388
|
};
|
|
326
389
|
}
|
|
327
390
|
if (node.type === "SvelteElement") {
|
|
@@ -330,7 +393,7 @@ function toTargetInfo(node) {
|
|
|
330
393
|
tagName: node.name ?? node.type,
|
|
331
394
|
start: node.start,
|
|
332
395
|
end: node.end,
|
|
333
|
-
...targetAttributeFacts(node.attributes ?? [])
|
|
396
|
+
...targetAttributeFacts(source, node.attributes ?? [])
|
|
334
397
|
};
|
|
335
398
|
}
|
|
336
399
|
if (node.type === "SlotElement" || node.type === "TitleElement" || node.type === "SvelteBody" || node.type === "SvelteBoundary" || node.type === "SvelteDocument" || node.type === "SvelteFragment" || node.type === "SvelteHead" || node.type === "SvelteSelf" || node.type === "SvelteWindow") {
|
|
@@ -343,10 +406,17 @@ function toTargetInfo(node) {
|
|
|
343
406
|
}
|
|
344
407
|
return null;
|
|
345
408
|
}
|
|
346
|
-
function targetAttributeFacts(attributes) {
|
|
409
|
+
function targetAttributeFacts(source, attributes, native = false) {
|
|
410
|
+
const directives = styleDirectives(attributes);
|
|
411
|
+
const literalMustaches = native && !attributes.some((attribute) => attribute.type === "SpreadAttribute");
|
|
347
412
|
const staticAttributes = {};
|
|
348
413
|
for (const attribute of attributes) {
|
|
349
414
|
if (attribute.type !== "Attribute") continue;
|
|
415
|
+
const literal = literalMustaches ? literalMustacheAttribute(attribute) : null;
|
|
416
|
+
if (literal) {
|
|
417
|
+
staticAttributes[attribute.name] = literal.rendered;
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
350
420
|
if (attribute.value === true) {
|
|
351
421
|
staticAttributes[attribute.name] = true;
|
|
352
422
|
continue;
|
|
@@ -365,7 +435,14 @@ function targetAttributeFacts(attributes) {
|
|
|
365
435
|
directiveTypes: attributes.filter(
|
|
366
436
|
(attribute) => attribute.type !== "Attribute" && attribute.type !== "SpreadAttribute"
|
|
367
437
|
).map((attribute) => attribute.type),
|
|
368
|
-
staticAttributes
|
|
438
|
+
staticAttributes,
|
|
439
|
+
styleDirectives: directives.map((directive) => {
|
|
440
|
+
const literal = literalStyleDirective(source, directive, directives);
|
|
441
|
+
return {
|
|
442
|
+
name: directive.name,
|
|
443
|
+
...literal ? { literal: literal.value } : {}
|
|
444
|
+
};
|
|
445
|
+
})
|
|
369
446
|
};
|
|
370
447
|
}
|
|
371
448
|
var PARSE_CACHE_LIMIT = 16;
|
|
@@ -525,9 +602,10 @@ function annotateSvelteSource(options) {
|
|
|
525
602
|
})
|
|
526
603
|
});
|
|
527
604
|
}
|
|
605
|
+
const markupStart = inputSource.charCodeAt(0) === 65279 ? 1 : 0;
|
|
528
606
|
const startEdit = {
|
|
529
|
-
start:
|
|
530
|
-
end:
|
|
607
|
+
start: markupStart,
|
|
608
|
+
end: markupStart,
|
|
531
609
|
replacement: `{@html '<!--${TEMPO_SVELTE_SOURCE_REGISTRY_ATTRIBUTE}-->'}`
|
|
532
610
|
};
|
|
533
611
|
const annotationEdits = [startEdit, ...edits];
|
|
@@ -558,7 +636,7 @@ function annotateSvelteSource(options) {
|
|
|
558
636
|
const code = applyStringEdits(inputSource, transformEdits);
|
|
559
637
|
try {
|
|
560
638
|
if (validation === "compiler") {
|
|
561
|
-
|
|
639
|
+
compile2(code, { filename: options.filename, generate: false });
|
|
562
640
|
} else {
|
|
563
641
|
const parsedOutput = parseSvelteSourceInternal(
|
|
564
642
|
code,
|
|
@@ -781,9 +859,6 @@ function serializeAnnotations(metadata) {
|
|
|
781
859
|
).join("");
|
|
782
860
|
}
|
|
783
861
|
|
|
784
|
-
// ../../modules/svelte-editor/markup-transfer.ts
|
|
785
|
-
import { parse as parse2 } from "svelte/compiler";
|
|
786
|
-
|
|
787
862
|
// svelte.ts
|
|
788
863
|
var MODULE_SCRIPT = /<script\b[^>]*\b(?:module\b|context\s*=\s*["']module["'])[^>]*>/;
|
|
789
864
|
function tempoSveltePreprocess(options = {}) {
|