tempo-sdk 0.0.89 → 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/editor.js +1 -1
- package/dist/canvas/parser.js +1 -1
- package/dist/canvas/svelte.js +9 -1
- package/dist/canvas/svelte.js.map +1 -1
- 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-SLAZCXFE.js → chunk-FENUT2N2.js} +2 -2
- package/dist/{chunk-SLAZCXFE.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-X5ORR3FI.js → chunk-KQSOE4KZ.js} +7 -7
- package/dist/chunk-MU7S7NU7.js +183 -0
- package/dist/chunk-MU7S7NU7.js.map +1 -0
- package/dist/{chunk-GZ6KY7ZF.js → chunk-RZ3TG6MV.js} +2 -2
- package/dist/{chunk-GZ6KY7ZF.js.map → chunk-RZ3TG6MV.js.map} +1 -1
- package/dist/{chunk-3JR2JRSV.js → chunk-TWW2DL7E.js} +2 -2
- package/dist/{chunk-3JR2JRSV.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-X5ORR3FI.js.map → chunk-KQSOE4KZ.js.map} +0 -0
- /package/dist/{controls-reader-Z7OQWYWQ.js.map → controls-reader-5MFHYBZZ.js.map} +0 -0
package/dist/nuxt.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
TEMPO_VUE_ANNOTATION_PLUGIN_NAME,
|
|
4
4
|
TEMPO_WORKSPACE_NONCE_META_NAME,
|
|
5
5
|
readTempoWorkspaceNonce
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-RZ3TG6MV.js";
|
|
7
7
|
|
|
8
8
|
// nuxt.ts
|
|
9
9
|
import { existsSync as existsSync3, readFileSync as readFileSync8, realpathSync as realpathSync9 } from "fs";
|
|
@@ -63,14 +63,75 @@ function isWorkspaceRoot(dir) {
|
|
|
63
63
|
import { realpathSync, statSync as statSync2 } from "fs";
|
|
64
64
|
import { relative as relative2 } from "path";
|
|
65
65
|
|
|
66
|
+
// ../../modules/annotation/literal-expression.ts
|
|
67
|
+
function unwrapLiteralExpression(node) {
|
|
68
|
+
let current = node;
|
|
69
|
+
while ([
|
|
70
|
+
"ParenthesizedExpression",
|
|
71
|
+
"TSAsExpression",
|
|
72
|
+
"TSSatisfiesExpression",
|
|
73
|
+
"TSTypeAssertion",
|
|
74
|
+
"TSNonNullExpression",
|
|
75
|
+
"TSInstantiationExpression"
|
|
76
|
+
].includes(current.type)) {
|
|
77
|
+
const expression = current.expression;
|
|
78
|
+
if (!expression) break;
|
|
79
|
+
current = expression;
|
|
80
|
+
}
|
|
81
|
+
return current;
|
|
82
|
+
}
|
|
83
|
+
function readLiteralExpression(node) {
|
|
84
|
+
const value = unwrapLiteralExpression(node);
|
|
85
|
+
if (["Literal", "StringLiteral", "NumericLiteral", "BooleanLiteral"].includes(
|
|
86
|
+
value.type
|
|
87
|
+
)) {
|
|
88
|
+
if (typeof value.value === "string" || typeof value.value === "boolean")
|
|
89
|
+
return value.value;
|
|
90
|
+
if (typeof value.value === "number" && Number.isFinite(value.value))
|
|
91
|
+
return value.value;
|
|
92
|
+
}
|
|
93
|
+
if (value.type === "TemplateLiteral") {
|
|
94
|
+
const expressions = value.expressions;
|
|
95
|
+
const quasis = value.quasis;
|
|
96
|
+
if (expressions.length === 0 && quasis.length === 1 && typeof quasis[0]?.value.cooked === "string")
|
|
97
|
+
return quasis[0].value.cooked;
|
|
98
|
+
}
|
|
99
|
+
if (value.type === "UnaryExpression" && (value.operator === "-" || value.operator === "+")) {
|
|
100
|
+
const argument = readLiteralExpression(value.argument);
|
|
101
|
+
if (typeof argument === "number")
|
|
102
|
+
return value.operator === "-" ? -argument : argument;
|
|
103
|
+
}
|
|
104
|
+
if (value.type === "BinaryExpression" && ["+", "-", "*", "/"].includes(value.operator)) {
|
|
105
|
+
const left = readLiteralExpression(value.left);
|
|
106
|
+
const right = readLiteralExpression(value.right);
|
|
107
|
+
if (typeof left !== "number" || typeof right !== "number") return null;
|
|
108
|
+
const result = value.operator === "+" ? left + right : value.operator === "-" ? left - right : value.operator === "*" ? left * right : left / right;
|
|
109
|
+
return Number.isFinite(result) ? result : null;
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
function literalJsxChild(node) {
|
|
114
|
+
if (node.type !== "JSXExpressionContainer") return null;
|
|
115
|
+
const root = unwrapLiteralExpression(
|
|
116
|
+
node.expression
|
|
117
|
+
);
|
|
118
|
+
return root.type === "JSXElement" ? root : null;
|
|
119
|
+
}
|
|
120
|
+
function literalPropertyName(key, computed = false) {
|
|
121
|
+
if (!computed && key.type === "Identifier")
|
|
122
|
+
return typeof key.name === "string" ? key.name : null;
|
|
123
|
+
const value = readLiteralExpression(key);
|
|
124
|
+
return typeof value === "string" || typeof value === "number" ? String(value) : null;
|
|
125
|
+
}
|
|
126
|
+
|
|
66
127
|
// ../../modules/annotation/expression-facts.ts
|
|
67
128
|
var EXPRESSION_FACTS_ATTRIBUTE = "data-tempo-expr";
|
|
68
129
|
var DYNAMIC_SLOT_FACT = "#slot";
|
|
69
|
-
function expressionFacts(element, parentType) {
|
|
130
|
+
function expressionFacts(element, parentType, isStaticJsxChild = false) {
|
|
70
131
|
const opening = element.openingElement;
|
|
71
132
|
const attributes = opening.attributes;
|
|
72
133
|
const facts = [];
|
|
73
|
-
if (parentType !== "JSXElement" && parentType !== "JSXFragment")
|
|
134
|
+
if (!isStaticJsxChild && parentType !== "JSXElement" && parentType !== "JSXFragment")
|
|
74
135
|
facts.push(DYNAMIC_SLOT_FACT);
|
|
75
136
|
const last = /* @__PURE__ */ new Map();
|
|
76
137
|
attributes.forEach((attribute, index) => {
|
|
@@ -90,7 +151,9 @@ function expressionFacts(element, parentType) {
|
|
|
90
151
|
facts.push(...styleFacts(value));
|
|
91
152
|
continue;
|
|
92
153
|
}
|
|
93
|
-
if (overridden
|
|
154
|
+
if (overridden) facts.push(name);
|
|
155
|
+
else if (name === "className" && isClassHelperCall(value)) continue;
|
|
156
|
+
else if (!isLiteralValue(value)) facts.push(name);
|
|
94
157
|
}
|
|
95
158
|
if (facts.length > 0) return facts.join(" ");
|
|
96
159
|
return lastSpread >= 0 ? "" : void 0;
|
|
@@ -120,7 +183,9 @@ function styleFacts(value) {
|
|
|
120
183
|
const facts = [];
|
|
121
184
|
for (const [key, index] of last) {
|
|
122
185
|
const property = properties[index];
|
|
123
|
-
const overridden = properties.slice(index + 1).some(
|
|
186
|
+
const overridden = properties.slice(index + 1).some(
|
|
187
|
+
(later) => later.type === "SpreadElement" || later.computed && styleKey(later) === null
|
|
188
|
+
);
|
|
124
189
|
const literal = property.type !== "ObjectMethod" && !property.shorthand && isLiteral(property.value);
|
|
125
190
|
if (overridden || !literal) facts.push(`style.${key}`);
|
|
126
191
|
}
|
|
@@ -128,38 +193,31 @@ function styleFacts(value) {
|
|
|
128
193
|
}
|
|
129
194
|
function styleKey(property) {
|
|
130
195
|
const isProperty = property.type === "Property" || property.type === "ObjectProperty" || property.type === "ObjectMethod";
|
|
131
|
-
if (!isProperty
|
|
132
|
-
|
|
133
|
-
if (key.type === "Identifier") return key.name;
|
|
134
|
-
const isString = (key.type === "Literal" || key.type === "StringLiteral") && typeof key.value === "string";
|
|
135
|
-
return isString ? key.value : null;
|
|
196
|
+
if (!isProperty) return null;
|
|
197
|
+
return literalPropertyName(property.key, Boolean(property.computed));
|
|
136
198
|
}
|
|
137
199
|
function isLiteralValue(value) {
|
|
138
200
|
if (value.type === "Literal" || value.type === "StringLiteral") return true;
|
|
139
201
|
if (value.type !== "JSXExpressionContainer") return false;
|
|
140
202
|
return isLiteral(value.expression);
|
|
141
203
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
if (
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
204
|
+
var CLASS_HELPERS = /* @__PURE__ */ new Set(["cn", "clsx", "twMerge", "cx", "classNames"]);
|
|
205
|
+
function isClassHelperCall(value) {
|
|
206
|
+
if (value.type !== "JSXExpressionContainer") return false;
|
|
207
|
+
const call = value.expression;
|
|
208
|
+
if (call.type !== "CallExpression") return false;
|
|
209
|
+
const callee = call.callee;
|
|
210
|
+
if (callee.type !== "Identifier" || !CLASS_HELPERS.has(callee.name))
|
|
211
|
+
return false;
|
|
212
|
+
return call.arguments.every(
|
|
213
|
+
(argument) => (argument.type === "Literal" || argument.type === "StringLiteral") && typeof argument.value === "string" || argument.type === "TemplateLiteral" && argument.expressions.length === 0
|
|
214
|
+
);
|
|
153
215
|
}
|
|
154
|
-
function
|
|
155
|
-
|
|
156
|
-
return numeric && typeof node.value === "number" && Number.isFinite(node.value);
|
|
216
|
+
function isLiteral(node) {
|
|
217
|
+
return readLiteralExpression(node) !== null;
|
|
157
218
|
}
|
|
158
219
|
function unwrap(node) {
|
|
159
|
-
|
|
160
|
-
while (current.type === "ParenthesizedExpression")
|
|
161
|
-
current = current.expression;
|
|
162
|
-
return current;
|
|
220
|
+
return unwrapLiteralExpression(node);
|
|
163
221
|
}
|
|
164
222
|
|
|
165
223
|
// ../../modules/annotation/source-version.ts
|
|
@@ -252,7 +310,8 @@ function computeTempoAnnotatedProps(params) {
|
|
|
252
310
|
...info.parentType !== void 0 && !hasJsxAttribute(info, EXPRESSION_FACTS_ATTRIBUTE) ? {
|
|
253
311
|
[EXPRESSION_FACTS_ATTRIBUTE]: expressionFacts(
|
|
254
312
|
info.element,
|
|
255
|
-
info.parentType
|
|
313
|
+
info.parentType,
|
|
314
|
+
info.isStaticJsxChild
|
|
256
315
|
)
|
|
257
316
|
} : {}
|
|
258
317
|
};
|
|
@@ -1297,14 +1356,30 @@ var FRAGMENT_TAG_NAMES = /* @__PURE__ */ new Set(["Fragment", "React.Fragment"])
|
|
|
1297
1356
|
function annotateFile(source, filename, computeAnnotatedProps) {
|
|
1298
1357
|
const parseResult = parseSync3(filename, source);
|
|
1299
1358
|
const insertions = [];
|
|
1359
|
+
const staticChildren = /* @__PURE__ */ new WeakSet();
|
|
1360
|
+
const noteChildren = (node) => {
|
|
1361
|
+
for (const child of node.children) {
|
|
1362
|
+
const literal = literalJsxChild(child);
|
|
1363
|
+
if (literal) staticChildren.add(literal);
|
|
1364
|
+
}
|
|
1365
|
+
};
|
|
1300
1366
|
walk(parseResult.program, {
|
|
1367
|
+
JSXFragment(node) {
|
|
1368
|
+
noteChildren(node);
|
|
1369
|
+
},
|
|
1301
1370
|
JSXElement(node, parent) {
|
|
1302
1371
|
const element = node;
|
|
1372
|
+
noteChildren(element);
|
|
1303
1373
|
const tagName = getTagName(element.openingElement.name);
|
|
1304
1374
|
if (FRAGMENT_TAG_NAMES.has(tagName)) return;
|
|
1305
1375
|
const parentType = parent?.type ?? null;
|
|
1306
1376
|
const props = removeExistingProps(
|
|
1307
|
-
computeAnnotatedProps({
|
|
1377
|
+
computeAnnotatedProps({
|
|
1378
|
+
element,
|
|
1379
|
+
tagName,
|
|
1380
|
+
parentType,
|
|
1381
|
+
...staticChildren.has(element) ? { isStaticJsxChild: true } : {}
|
|
1382
|
+
}),
|
|
1308
1383
|
getExistingAttributeNames(element)
|
|
1309
1384
|
);
|
|
1310
1385
|
if (Object.keys(props).length === 0) return;
|
|
@@ -1328,7 +1403,11 @@ function annotateFile(source, filename, computeAnnotatedProps) {
|
|
|
1328
1403
|
lastPos = position;
|
|
1329
1404
|
}
|
|
1330
1405
|
chunks.push(source.slice(lastPos));
|
|
1331
|
-
return {
|
|
1406
|
+
return {
|
|
1407
|
+
annotatedSource: chunks.join(""),
|
|
1408
|
+
elementsAnnotated: insertions.length,
|
|
1409
|
+
parseResult
|
|
1410
|
+
};
|
|
1332
1411
|
}
|
|
1333
1412
|
|
|
1334
1413
|
// assets/parser.ts
|
|
@@ -2666,10 +2745,11 @@ function readStringAttribute(openingElement, name) {
|
|
|
2666
2745
|
attributeSpan: toSpan(attribute) ?? { start: 0, end: 0 }
|
|
2667
2746
|
};
|
|
2668
2747
|
}
|
|
2669
|
-
const expression = unwrapAttributeExpression(value);
|
|
2670
|
-
|
|
2748
|
+
const expression = unwrapTsExpression2(unwrapAttributeExpression(value));
|
|
2749
|
+
const fixed = expression?.type === "Literal" && typeof expression.value === "string" ? expression.value : expression?.type === "TemplateLiteral" && (expression.expressions?.length ?? 0) === 0 && expression.quasis?.length === 1 && typeof expression.quasis[0]?.value?.cooked === "string" ? expression.quasis[0].value.cooked : null;
|
|
2750
|
+
if (fixed !== null) {
|
|
2671
2751
|
return {
|
|
2672
|
-
value:
|
|
2752
|
+
value: fixed,
|
|
2673
2753
|
valueSpan: toSpan(expression) ?? toSpan(attribute) ?? { start: 0, end: 0 },
|
|
2674
2754
|
attributeSpan: toSpan(attribute) ?? { start: 0, end: 0 }
|
|
2675
2755
|
};
|
|
@@ -4235,6 +4315,8 @@ var SIMPLE_EXPRESSION_NODE = 4;
|
|
|
4235
4315
|
var INTERPOLATION_NODE = 5;
|
|
4236
4316
|
var ATTRIBUTE_NODE = 6;
|
|
4237
4317
|
var NATIVE_TAG = 0;
|
|
4318
|
+
var SVG_NAMESPACE = 1;
|
|
4319
|
+
var MATH_NAMESPACE = 2;
|
|
4238
4320
|
var COMPONENT_TAG = 1;
|
|
4239
4321
|
var STRUCTURAL_TEMPLATE_TAG = 3;
|
|
4240
4322
|
var BUILT_IN_COMPONENT_TAGS = /* @__PURE__ */ new Set([
|
|
@@ -4323,10 +4405,11 @@ function parseVueSource(source, filename = "Component.vue") {
|
|
|
4323
4405
|
openingEnd
|
|
4324
4406
|
);
|
|
4325
4407
|
const inVPre = parent !== null && (parent.vPre || parent.inVPre);
|
|
4326
|
-
const opensScope = kind === "
|
|
4408
|
+
const opensScope = kind === "dynamic-element" || isBuiltInComponent(child) || child.tag === "template" || vPre || hasDirective(child, SCOPE_DIRECTIVES);
|
|
4327
4409
|
const info = {
|
|
4328
4410
|
kind,
|
|
4329
4411
|
tagName: child.tag,
|
|
4412
|
+
namespace: child.ns === SVG_NAMESPACE ? "svg" : child.ns === MATH_NAMESPACE ? "mathml" : "html",
|
|
4330
4413
|
start,
|
|
4331
4414
|
end,
|
|
4332
4415
|
propsEnd,
|
|
@@ -4439,13 +4522,19 @@ function readProp(prop) {
|
|
|
4439
4522
|
if (prop.name === "bind") {
|
|
4440
4523
|
const arg = prop.arg;
|
|
4441
4524
|
const staticName = arg?.type === SIMPLE_EXPRESSION_NODE && arg.isStatic ? arg.content : null;
|
|
4525
|
+
const style = staticName === "style" ? boundStyleObject(prop) : void 0;
|
|
4526
|
+
const literal = staticName !== null && staticName !== "style" && staticName !== "class" ? boundLiteral(prop) : null;
|
|
4442
4527
|
return {
|
|
4443
4528
|
kind: "bind",
|
|
4444
4529
|
name: staticName,
|
|
4445
4530
|
objectBind: arg === void 0,
|
|
4446
4531
|
rawName,
|
|
4447
4532
|
...expression,
|
|
4448
|
-
...
|
|
4533
|
+
...literal ? { literal } : {},
|
|
4534
|
+
...style === void 0 ? {} : {
|
|
4535
|
+
styleKeys: style && style.entries.map((entry) => entry.key),
|
|
4536
|
+
styleObject: style
|
|
4537
|
+
},
|
|
4449
4538
|
start,
|
|
4450
4539
|
end
|
|
4451
4540
|
};
|
|
@@ -4459,33 +4548,93 @@ function readProp(prop) {
|
|
|
4459
4548
|
end
|
|
4460
4549
|
};
|
|
4461
4550
|
}
|
|
4462
|
-
function
|
|
4551
|
+
function boundStyleObject(prop) {
|
|
4463
4552
|
const exp = prop.exp;
|
|
4464
4553
|
if (!exp || exp.type !== SIMPLE_EXPRESSION_NODE) return null;
|
|
4465
4554
|
let ast = exp.ast;
|
|
4466
|
-
if (ast === void 0)
|
|
4467
|
-
try {
|
|
4468
|
-
const program = babelParse(`(${exp.content})`, {
|
|
4469
|
-
plugins: ["typescript"]
|
|
4470
|
-
}).program;
|
|
4471
|
-
const statement = program.body[0];
|
|
4472
|
-
ast = statement?.type === "ExpressionStatement" ? statement.expression : null;
|
|
4473
|
-
} catch {
|
|
4474
|
-
ast = null;
|
|
4475
|
-
}
|
|
4476
|
-
}
|
|
4555
|
+
if (ast === void 0) ast = parseWrapped(exp.content);
|
|
4477
4556
|
if (!ast) return null;
|
|
4478
|
-
const
|
|
4479
|
-
if (
|
|
4557
|
+
const object = unwrapTypeScript(ast);
|
|
4558
|
+
if (object.type !== "ObjectExpression") return null;
|
|
4480
4559
|
const keys = [];
|
|
4481
|
-
for (const property of
|
|
4560
|
+
for (const property of object.properties) {
|
|
4482
4561
|
if (property.type === "SpreadElement" || property.computed) return null;
|
|
4483
4562
|
if (property.key.type === "Identifier") keys.push(property.key.name);
|
|
4484
4563
|
else if (property.key.type === "StringLiteral")
|
|
4485
4564
|
keys.push(camelCaseStyleKey(property.key.value));
|
|
4486
4565
|
else return null;
|
|
4487
4566
|
}
|
|
4488
|
-
|
|
4567
|
+
const delimiter = prop.loc.source[exp.loc.start.offset - prop.loc.start.offset - 1];
|
|
4568
|
+
const quote = delimiter === '"' || delimiter === "'" ? delimiter : null;
|
|
4569
|
+
const raw = quote === null ? null : rawOffsets(exp.loc.source, exp.content);
|
|
4570
|
+
const at = (offset) => raw && typeof offset === "number" ? exp.loc.start.offset + raw[offset - 1] : null;
|
|
4571
|
+
const entries = object.properties.map((property, index) => {
|
|
4572
|
+
const value = property.type === "ObjectProperty" ? property.value : void 0;
|
|
4573
|
+
const literal = property.type === "ObjectProperty" && !property.shorthand && raw ? readLiteralExpression(
|
|
4574
|
+
property.value
|
|
4575
|
+
) : null;
|
|
4576
|
+
return {
|
|
4577
|
+
key: keys[index],
|
|
4578
|
+
literal: typeof literal === "string" || typeof literal === "number" ? literal : null,
|
|
4579
|
+
start: at(property.start),
|
|
4580
|
+
end: at(property.end),
|
|
4581
|
+
valueStart: at(value?.start),
|
|
4582
|
+
valueEnd: at(value?.end)
|
|
4583
|
+
};
|
|
4584
|
+
});
|
|
4585
|
+
return { start: at(object.start), end: at(object.end), quote, entries };
|
|
4586
|
+
}
|
|
4587
|
+
function boundLiteral(prop) {
|
|
4588
|
+
const exp = prop.exp;
|
|
4589
|
+
if (!exp || exp.type !== SIMPLE_EXPRESSION_NODE) return null;
|
|
4590
|
+
if (exp.content !== exp.loc.source) return null;
|
|
4591
|
+
const delimiter = prop.loc.source[exp.loc.start.offset - prop.loc.start.offset - 1];
|
|
4592
|
+
if (delimiter !== '"' && delimiter !== "'") return null;
|
|
4593
|
+
let ast = exp.ast;
|
|
4594
|
+
if (ast === void 0) ast = parseWrapped(exp.content);
|
|
4595
|
+
if (!ast) return null;
|
|
4596
|
+
const value = readLiteralExpression(
|
|
4597
|
+
ast
|
|
4598
|
+
);
|
|
4599
|
+
if (typeof value !== "string" && typeof value !== "number") return null;
|
|
4600
|
+
return {
|
|
4601
|
+
value,
|
|
4602
|
+
start: exp.loc.start.offset,
|
|
4603
|
+
end: exp.loc.end.offset,
|
|
4604
|
+
quote: delimiter
|
|
4605
|
+
};
|
|
4606
|
+
}
|
|
4607
|
+
var WRITTEN_ENTITIES = {
|
|
4608
|
+
""": '"',
|
|
4609
|
+
"'": "'",
|
|
4610
|
+
"<": "<",
|
|
4611
|
+
">": ">",
|
|
4612
|
+
"&": "&"
|
|
4613
|
+
};
|
|
4614
|
+
function rawOffsets(raw, decoded) {
|
|
4615
|
+
const offsets = [];
|
|
4616
|
+
let text = "";
|
|
4617
|
+
const reference = /&(?:quot|#39|lt|gt|amp);/y;
|
|
4618
|
+
for (let at = 0; at < raw.length; ) {
|
|
4619
|
+
reference.lastIndex = at;
|
|
4620
|
+
const entity = reference.exec(raw)?.[0];
|
|
4621
|
+
offsets.push(at);
|
|
4622
|
+
text += entity ? WRITTEN_ENTITIES[entity] : raw[at];
|
|
4623
|
+
at += entity ? entity.length : 1;
|
|
4624
|
+
}
|
|
4625
|
+
offsets.push(raw.length);
|
|
4626
|
+
return text === decoded ? offsets : null;
|
|
4627
|
+
}
|
|
4628
|
+
function parseWrapped(text) {
|
|
4629
|
+
try {
|
|
4630
|
+
const program = babelParse(`(${text})`, {
|
|
4631
|
+
plugins: ["typescript"]
|
|
4632
|
+
}).program;
|
|
4633
|
+
const statement = program.body[0];
|
|
4634
|
+
return statement?.type === "ExpressionStatement" ? statement.expression : null;
|
|
4635
|
+
} catch {
|
|
4636
|
+
return null;
|
|
4637
|
+
}
|
|
4489
4638
|
}
|
|
4490
4639
|
function vueTargetKind(node) {
|
|
4491
4640
|
if (node.tag === "template" || node.tag === "slot") return "special-element";
|
|
@@ -4762,6 +4911,28 @@ function camelize(name) {
|
|
|
4762
4911
|
return name.replace(/-(\w)/g, (_, char) => char.toUpperCase());
|
|
4763
4912
|
}
|
|
4764
4913
|
|
|
4914
|
+
// ../../modules/vue-editor/literal-attributes.ts
|
|
4915
|
+
var NOT_ATTRIBUTES = /* @__PURE__ */ new Set(["key", "ref", "ref_for", "ref_key", "is"]);
|
|
4916
|
+
function vueLiteralAttribute(target, name) {
|
|
4917
|
+
if (target.kind !== "native-element" || target.namespace !== "svg")
|
|
4918
|
+
return null;
|
|
4919
|
+
if (VUE_MERGED_PROP_NAMES.has(name.toLowerCase()) || NOT_ATTRIBUTES.has(name) || name.toLowerCase().startsWith("on"))
|
|
4920
|
+
return null;
|
|
4921
|
+
if (target.props.some(
|
|
4922
|
+
(prop) => prop.kind === "bind" && (prop.objectBind || prop.name === null)
|
|
4923
|
+
))
|
|
4924
|
+
return null;
|
|
4925
|
+
const named = target.props.filter(
|
|
4926
|
+
(prop) => (prop.kind === "attribute" || prop.kind === "bind") && prop.name?.toLowerCase() === name.toLowerCase()
|
|
4927
|
+
);
|
|
4928
|
+
const only = named.length === 1 ? named[0] : null;
|
|
4929
|
+
if (only?.kind !== "bind" || !only.literal || only.name !== name)
|
|
4930
|
+
return null;
|
|
4931
|
+
if (only.rawName !== `:${name}` && only.rawName !== `v-bind:${name}`)
|
|
4932
|
+
return null;
|
|
4933
|
+
return only;
|
|
4934
|
+
}
|
|
4935
|
+
|
|
4765
4936
|
// ../../modules/vue-editor/annotate.ts
|
|
4766
4937
|
var TEMPO_STAMP_NAMES = [
|
|
4767
4938
|
"data-tempo-filepath",
|
|
@@ -4929,9 +5100,15 @@ function authoredFacts(target, props, position) {
|
|
|
4929
5100
|
if (prop.name === null || !isRenderedName(prop.name)) return;
|
|
4930
5101
|
if (prop.kind === "bind") {
|
|
4931
5102
|
if (prop.name === "style" && Array.isArray(prop.styleKeys)) {
|
|
4932
|
-
|
|
5103
|
+
const writable = !canOverrideAnything && props.filter((entry) => entry.kind === "bind" && entry.name === "style").length === 1;
|
|
5104
|
+
const last = /* @__PURE__ */ new Map();
|
|
5105
|
+
for (const entry of writable ? prop.styleObject?.entries ?? [] : [])
|
|
5106
|
+
last.set(entry.key, entry.literal);
|
|
5107
|
+
for (const key of prop.styleKeys)
|
|
5108
|
+
if ((last.get(key) ?? null) === null) facts.add(`style.${key}`);
|
|
4933
5109
|
return;
|
|
4934
5110
|
}
|
|
5111
|
+
if (vueLiteralAttribute(target, prop.name)) return;
|
|
4935
5112
|
bound.add(prop.name);
|
|
4936
5113
|
facts.add(factName(prop.name));
|
|
4937
5114
|
return;
|