tempo-sdk 0.0.89 → 0.0.93

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 (82) hide show
  1. package/dist/assets/index.js +3 -3
  2. package/dist/astro/asset-preview-client.js +3 -3
  3. package/dist/astro.js +7 -7
  4. package/dist/canvas/astro.js +3 -3
  5. package/dist/canvas/editor.js +1 -1
  6. package/dist/canvas/index.js +157 -7
  7. package/dist/canvas/index.js.map +1 -1
  8. package/dist/canvas/interact-projection.js +4 -4
  9. package/dist/canvas/parser.js +1 -1
  10. package/dist/canvas/svelte.js +12 -4
  11. package/dist/canvas/svelte.js.map +1 -1
  12. package/dist/canvas/vue.js +3 -3
  13. package/dist/{chunk-DNERBE7A.js → chunk-3L4RRKC3.js} +17 -11
  14. package/dist/chunk-3L4RRKC3.js.map +1 -0
  15. package/dist/{chunk-2ZQMVAFM.js → chunk-6SOP4XU6.js} +98 -33
  16. package/dist/chunk-6SOP4XU6.js.map +1 -0
  17. package/dist/{chunk-Y72PIE3I.js → chunk-AFXE462X.js} +5 -4
  18. package/dist/{chunk-Y72PIE3I.js.map → chunk-AFXE462X.js.map} +1 -1
  19. package/dist/{chunk-DMT5MRMS.js → chunk-BQPKOVI5.js} +4 -3
  20. package/dist/{chunk-DMT5MRMS.js.map → chunk-BQPKOVI5.js.map} +1 -1
  21. package/dist/{chunk-I5MJ342V.js → chunk-CVUNZBRV.js} +3 -3
  22. package/dist/{chunk-H6OZIX2U.js → chunk-FGWGY3G3.js} +27 -3
  23. package/dist/chunk-FGWGY3G3.js.map +1 -0
  24. package/dist/{chunk-NXPP3CSM.js → chunk-FZVJVL3T.js} +2 -2
  25. package/dist/{chunk-GZ6KY7ZF.js → chunk-GHNHPVEI.js} +2 -2
  26. package/dist/{chunk-GZ6KY7ZF.js.map → chunk-GHNHPVEI.js.map} +1 -1
  27. package/dist/{chunk-3XEEVCM3.js → chunk-HNNZM2XM.js} +127 -66
  28. package/dist/chunk-HNNZM2XM.js.map +1 -0
  29. package/dist/{chunk-5M45Z7K6.js → chunk-LEBVQBDH.js} +83 -51
  30. package/dist/chunk-LEBVQBDH.js.map +1 -0
  31. package/dist/{chunk-X5ORR3FI.js → chunk-M7OOVEAR.js} +7 -7
  32. package/dist/chunk-MU7S7NU7.js +183 -0
  33. package/dist/chunk-MU7S7NU7.js.map +1 -0
  34. package/dist/{chunk-3JR2JRSV.js → chunk-N5MWY4H6.js} +2 -2
  35. package/dist/{chunk-3JR2JRSV.js.map → chunk-N5MWY4H6.js.map} +1 -1
  36. package/dist/{chunk-5VIBKVFO.js → chunk-U66QI3EN.js} +28 -18
  37. package/dist/chunk-U66QI3EN.js.map +1 -0
  38. package/dist/{chunk-XN2K7GED.js → chunk-XB6GU4CE.js} +32 -8
  39. package/dist/{chunk-XN2K7GED.js.map → chunk-XB6GU4CE.js.map} +1 -1
  40. package/dist/{chunk-SLAZCXFE.js → chunk-Y7EHQREO.js} +2 -2
  41. package/dist/{chunk-SLAZCXFE.js.map → chunk-Y7EHQREO.js.map} +1 -1
  42. package/dist/{controls-reader-Z7OQWYWQ.js → controls-reader-5MFHYBZZ.js} +4 -4
  43. package/dist/expo/plugin.cjs +97 -32
  44. package/dist/expo/plugin.cjs.map +1 -1
  45. package/dist/expo/plugin.js +1 -1
  46. package/dist/expo-babel-plugin.cjs +97 -32
  47. package/dist/expo-babel-plugin.cjs.map +1 -1
  48. package/dist/expo-babel-plugin.d.cts +2 -0
  49. package/dist/expo-babel-plugin.d.ts +2 -0
  50. package/dist/expo-babel-plugin.js +1 -1
  51. package/dist/index.d.ts +2 -0
  52. package/dist/index.js +6 -6
  53. package/dist/nextjs/plugin.cjs +1 -1
  54. package/dist/nextjs/plugin.cjs.map +1 -1
  55. package/dist/nextjs/plugin.js +1 -1
  56. package/dist/nextjs-loader.cjs +126 -37
  57. package/dist/nextjs-loader.cjs.map +1 -1
  58. package/dist/nextjs.cjs +1 -1
  59. package/dist/nextjs.cjs.map +1 -1
  60. package/dist/nextjs.d.cts +2 -0
  61. package/dist/nextjs.d.ts +2 -0
  62. package/dist/nextjs.js +1 -1
  63. package/dist/nuxt/runtime/identity.js +1 -1
  64. package/dist/nuxt.js +230 -53
  65. package/dist/nuxt.js.map +1 -1
  66. package/dist/svelte.js +99 -24
  67. package/dist/svelte.js.map +1 -1
  68. package/dist/vue.js +120 -22
  69. package/dist/vue.js.map +1 -1
  70. package/package.json +1 -1
  71. package/dist/chunk-2ZQMVAFM.js.map +0 -1
  72. package/dist/chunk-3XEEVCM3.js.map +0 -1
  73. package/dist/chunk-5M45Z7K6.js.map +0 -1
  74. package/dist/chunk-5VIBKVFO.js.map +0 -1
  75. package/dist/chunk-DNERBE7A.js.map +0 -1
  76. package/dist/chunk-H6BQZOAW.js +0 -121
  77. package/dist/chunk-H6BQZOAW.js.map +0 -1
  78. package/dist/chunk-H6OZIX2U.js.map +0 -1
  79. /package/dist/{chunk-I5MJ342V.js.map → chunk-CVUNZBRV.js.map} +0 -0
  80. /package/dist/{chunk-NXPP3CSM.js.map → chunk-FZVJVL3T.js.map} +0 -0
  81. /package/dist/{chunk-X5ORR3FI.js.map → chunk-M7OOVEAR.js.map} +0 -0
  82. /package/dist/{controls-reader-Z7OQWYWQ.js.map → controls-reader-5MFHYBZZ.js.map} +0 -0
package/dist/vue.js CHANGED
@@ -10,15 +10,16 @@ import {
10
10
  import {
11
11
  TEMPO_VUE_ANNOTATION_PLUGIN_NAME,
12
12
  createSdkFileMatcher
13
- } from "./chunk-3JR2JRSV.js";
13
+ } from "./chunk-N5MWY4H6.js";
14
14
  import {
15
15
  appendModuleVersionRecord
16
- } from "./chunk-DMT5MRMS.js";
16
+ } from "./chunk-BQPKOVI5.js";
17
17
  import {
18
18
  DYNAMIC_SLOT_FACT,
19
19
  EXPRESSION_FACTS_ATTRIBUTE,
20
+ readLiteralExpression,
20
21
  sourceVersionHash
21
- } from "./chunk-H6BQZOAW.js";
22
+ } from "./chunk-MU7S7NU7.js";
22
23
  import {
23
24
  TEMPO_VUE_INVOCATION_MARKER_PREFIX,
24
25
  TEMPO_VUE_SOURCE_REGISTRY_GLOBAL
@@ -51,6 +52,8 @@ var SIMPLE_EXPRESSION_NODE = 4;
51
52
  var INTERPOLATION_NODE = 5;
52
53
  var ATTRIBUTE_NODE = 6;
53
54
  var NATIVE_TAG = 0;
55
+ var SVG_NAMESPACE = 1;
56
+ var MATH_NAMESPACE = 2;
54
57
  var COMPONENT_TAG = 1;
55
58
  var STRUCTURAL_TEMPLATE_TAG = 3;
56
59
  var BUILT_IN_COMPONENT_TAGS = /* @__PURE__ */ new Set([
@@ -139,10 +142,11 @@ function parseVueSource(source, filename = "Component.vue") {
139
142
  openingEnd
140
143
  );
141
144
  const inVPre = parent !== null && (parent.vPre || parent.inVPre);
142
- const opensScope = kind === "component" || kind === "dynamic-element" || isBuiltInComponent(child) || child.tag === "template" || vPre || hasDirective(child, SCOPE_DIRECTIVES);
145
+ const opensScope = kind === "dynamic-element" || isBuiltInComponent(child) || child.tag === "template" || vPre || hasDirective(child, SCOPE_DIRECTIVES);
143
146
  const info = {
144
147
  kind,
145
148
  tagName: child.tag,
149
+ namespace: child.ns === SVG_NAMESPACE ? "svg" : child.ns === MATH_NAMESPACE ? "mathml" : "html",
146
150
  start,
147
151
  end,
148
152
  propsEnd,
@@ -255,13 +259,19 @@ function readProp(prop) {
255
259
  if (prop.name === "bind") {
256
260
  const arg = prop.arg;
257
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;
258
264
  return {
259
265
  kind: "bind",
260
266
  name: staticName,
261
267
  objectBind: arg === void 0,
262
268
  rawName,
263
269
  ...expression,
264
- ...staticName === "style" ? { styleKeys: boundStyleKeys(prop) } : {},
270
+ ...literal ? { literal } : {},
271
+ ...style === void 0 ? {} : {
272
+ styleKeys: style && style.entries.map((entry) => entry.key),
273
+ styleObject: style
274
+ },
265
275
  start,
266
276
  end
267
277
  };
@@ -275,33 +285,93 @@ function readProp(prop) {
275
285
  end
276
286
  };
277
287
  }
278
- function boundStyleKeys(prop) {
288
+ function boundStyleObject(prop) {
279
289
  const exp = prop.exp;
280
290
  if (!exp || exp.type !== SIMPLE_EXPRESSION_NODE) return null;
281
291
  let ast = exp.ast;
282
- if (ast === void 0) {
283
- try {
284
- const program = babelParse(`(${exp.content})`, {
285
- plugins: ["typescript"]
286
- }).program;
287
- const statement = program.body[0];
288
- ast = statement?.type === "ExpressionStatement" ? statement.expression : null;
289
- } catch {
290
- ast = null;
291
- }
292
- }
292
+ if (ast === void 0) ast = parseWrapped(exp.content);
293
293
  if (!ast) return null;
294
- const expression = unwrapTypeScript(ast);
295
- if (expression.type !== "ObjectExpression") return null;
294
+ const object = unwrapTypeScript(ast);
295
+ if (object.type !== "ObjectExpression") return null;
296
296
  const keys = [];
297
- for (const property of expression.properties) {
297
+ for (const property of object.properties) {
298
298
  if (property.type === "SpreadElement" || property.computed) return null;
299
299
  if (property.key.type === "Identifier") keys.push(property.key.name);
300
300
  else if (property.key.type === "StringLiteral")
301
301
  keys.push(camelCaseStyleKey(property.key.value));
302
302
  else return null;
303
303
  }
304
- return keys;
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
+ """: '"',
346
+ "'": "'",
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
+ }
305
375
  }
306
376
  function vueTargetKind(node) {
307
377
  if (node.tag === "template" || node.tag === "slot") return "special-element";
@@ -574,6 +644,28 @@ function camelize(name) {
574
644
  return name.replace(/-(\w)/g, (_, char) => char.toUpperCase());
575
645
  }
576
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
+
577
669
  // ../../modules/vue-editor/annotate.ts
578
670
  var TEMPO_STAMP_NAMES = [
579
671
  "data-tempo-filepath",
@@ -741,9 +833,15 @@ function authoredFacts(target, props, position) {
741
833
  if (prop.name === null || !isRenderedName(prop.name)) return;
742
834
  if (prop.kind === "bind") {
743
835
  if (prop.name === "style" && Array.isArray(prop.styleKeys)) {
744
- for (const key of prop.styleKeys) facts.add(`style.${key}`);
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}`);
745
842
  return;
746
843
  }
844
+ if (vueLiteralAttribute(target, prop.name)) return;
747
845
  bound.add(prop.name);
748
846
  facts.add(factName(prop.name));
749
847
  return;