@immense/vue-pom-generator 1.0.108 → 1.0.110
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/RELEASE_NOTES.md +19 -37
- package/dist/compiler/babel-guards.d.ts +85 -0
- package/dist/compiler/babel-guards.d.ts.map +1 -0
- package/dist/index.cjs +176 -302
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +176 -302
- package/dist/index.mjs.map +1 -1
- package/dist/plugin/runtime/annotator/client.d.ts +1 -1
- package/dist/plugin/runtime/annotator/client.d.ts.map +1 -1
- package/dist/plugin/runtime/annotator/styles.d.ts +1 -1
- package/dist/plugin/runtime/annotator/styles.d.ts.map +1 -1
- package/dist/routing/to-directive.d.ts.map +1 -1
- package/dist/tests/annotator-keyboard.test.d.ts +2 -0
- package/dist/tests/annotator-keyboard.test.d.ts.map +1 -0
- package/dist/tests/annotator-preview.test.d.ts +2 -0
- package/dist/tests/annotator-preview.test.d.ts.map +1 -0
- package/dist/tests/helpers/ast-queries.d.ts +10 -0
- package/dist/tests/helpers/ast-queries.d.ts.map +1 -0
- package/dist/tests/helpers/component-deps.d.ts +3 -0
- package/dist/tests/helpers/component-deps.d.ts.map +1 -0
- package/dist/transform.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/plugin/runtime/annotator/client.ts +23 -137
- package/plugin/runtime/annotator/styles.ts +43 -26
package/dist/index.cjs
CHANGED
|
@@ -1099,6 +1099,96 @@ function collectAccessibilityReviewWarnings(manifest) {
|
|
|
1099
1099
|
}
|
|
1100
1100
|
return warnings;
|
|
1101
1101
|
}
|
|
1102
|
+
const isNodeType = (node, type) => {
|
|
1103
|
+
return node !== null && node.type === type;
|
|
1104
|
+
};
|
|
1105
|
+
const isIdentifierNode = (node) => {
|
|
1106
|
+
return isNodeType(node, "Identifier") && typeof node.name === "string";
|
|
1107
|
+
};
|
|
1108
|
+
const isStringLiteralNode = (node) => {
|
|
1109
|
+
return isNodeType(node, "StringLiteral") && typeof node.value === "string";
|
|
1110
|
+
};
|
|
1111
|
+
const isBooleanLiteralNode = (node) => {
|
|
1112
|
+
return isNodeType(node, "BooleanLiteral") && typeof node.value === "boolean";
|
|
1113
|
+
};
|
|
1114
|
+
const isNumericLiteralNode = (node) => {
|
|
1115
|
+
return isNodeType(node, "NumericLiteral") && typeof node.value === "number";
|
|
1116
|
+
};
|
|
1117
|
+
const isNullLiteralNode = (node) => {
|
|
1118
|
+
return isNodeType(node, "NullLiteral");
|
|
1119
|
+
};
|
|
1120
|
+
const isMemberExpressionNode = (node) => {
|
|
1121
|
+
if (!isNodeType(node, "MemberExpression"))
|
|
1122
|
+
return false;
|
|
1123
|
+
const n = node;
|
|
1124
|
+
return typeof n.computed === "boolean" && typeof n.object === "object" && n.object !== null && typeof n.property === "object" && n.property !== null;
|
|
1125
|
+
};
|
|
1126
|
+
const isCallExpressionNode = (node) => {
|
|
1127
|
+
if (!isNodeType(node, "CallExpression"))
|
|
1128
|
+
return false;
|
|
1129
|
+
const n = node;
|
|
1130
|
+
return typeof n.callee === "object" && n.callee !== null && Array.isArray(n.arguments);
|
|
1131
|
+
};
|
|
1132
|
+
const isAwaitExpressionNode = (node) => {
|
|
1133
|
+
if (!isNodeType(node, "AwaitExpression"))
|
|
1134
|
+
return false;
|
|
1135
|
+
const n = node;
|
|
1136
|
+
return typeof n.argument === "object" && n.argument !== null;
|
|
1137
|
+
};
|
|
1138
|
+
const isAssignmentExpressionNode = (node) => {
|
|
1139
|
+
if (!isNodeType(node, "AssignmentExpression"))
|
|
1140
|
+
return false;
|
|
1141
|
+
const n = node;
|
|
1142
|
+
return typeof n.left === "object" && n.left !== null && typeof n.right === "object" && n.right !== null;
|
|
1143
|
+
};
|
|
1144
|
+
const isArrowFunctionExpressionNode = (node) => {
|
|
1145
|
+
if (!isNodeType(node, "ArrowFunctionExpression"))
|
|
1146
|
+
return false;
|
|
1147
|
+
const n = node;
|
|
1148
|
+
return typeof n.body === "object" && n.body !== null;
|
|
1149
|
+
};
|
|
1150
|
+
const isBlockStatementNode = (node) => {
|
|
1151
|
+
if (!isNodeType(node, "BlockStatement"))
|
|
1152
|
+
return false;
|
|
1153
|
+
const n = node;
|
|
1154
|
+
return Array.isArray(n.body);
|
|
1155
|
+
};
|
|
1156
|
+
const isExpressionStatementNode = (node) => {
|
|
1157
|
+
if (!isNodeType(node, "ExpressionStatement"))
|
|
1158
|
+
return false;
|
|
1159
|
+
const n = node;
|
|
1160
|
+
return typeof n.expression === "object" && n.expression !== null;
|
|
1161
|
+
};
|
|
1162
|
+
const isReturnStatementNode = (node) => {
|
|
1163
|
+
if (!isNodeType(node, "ReturnStatement"))
|
|
1164
|
+
return false;
|
|
1165
|
+
const n = node;
|
|
1166
|
+
return typeof n.argument === "object" || n.argument === null;
|
|
1167
|
+
};
|
|
1168
|
+
const isObjectExpressionNode = (node) => {
|
|
1169
|
+
if (!isNodeType(node, "ObjectExpression"))
|
|
1170
|
+
return false;
|
|
1171
|
+
const n = node;
|
|
1172
|
+
return Array.isArray(n.properties);
|
|
1173
|
+
};
|
|
1174
|
+
const isObjectPropertyNode = (node) => {
|
|
1175
|
+
if (!isNodeType(node, "ObjectProperty"))
|
|
1176
|
+
return false;
|
|
1177
|
+
const n = node;
|
|
1178
|
+
return typeof n.computed === "boolean" && typeof n.key === "object" && n.key !== null && typeof n.value === "object" && n.value !== null;
|
|
1179
|
+
};
|
|
1180
|
+
const isObjectPropertyNodeShallow = (node) => {
|
|
1181
|
+
if (!isNodeType(node, "ObjectProperty"))
|
|
1182
|
+
return false;
|
|
1183
|
+
const n = node;
|
|
1184
|
+
return typeof n.key === "object" && n.key !== null && typeof n.value === "object" && n.value !== null;
|
|
1185
|
+
};
|
|
1186
|
+
const isLogicalExpressionNode = (node) => {
|
|
1187
|
+
if (!isNodeType(node, "LogicalExpression"))
|
|
1188
|
+
return false;
|
|
1189
|
+
const n = node;
|
|
1190
|
+
return typeof n.operator === "string" && typeof n.left === "object" && n.left !== null && typeof n.right === "object" && n.right !== null;
|
|
1191
|
+
};
|
|
1102
1192
|
function isSimpleExpressionNode(value) {
|
|
1103
1193
|
return value !== null && "type" in value && value.type === compilerCore.NodeTypes.SIMPLE_EXPRESSION;
|
|
1104
1194
|
}
|
|
@@ -1137,27 +1227,6 @@ function buildPlaceholderParams(keys) {
|
|
|
1137
1227
|
params[k] = "__placeholder__";
|
|
1138
1228
|
return params;
|
|
1139
1229
|
}
|
|
1140
|
-
const isNodeType = (node, type) => {
|
|
1141
|
-
return node !== null && node.type === type;
|
|
1142
|
-
};
|
|
1143
|
-
const isStringLiteralNode = (node) => {
|
|
1144
|
-
return isNodeType(node, "StringLiteral") && typeof node.value === "string";
|
|
1145
|
-
};
|
|
1146
|
-
const isIdentifierNode = (node) => {
|
|
1147
|
-
return isNodeType(node, "Identifier") && typeof node.name === "string";
|
|
1148
|
-
};
|
|
1149
|
-
const isObjectPropertyNode = (node) => {
|
|
1150
|
-
if (!isNodeType(node, "ObjectProperty"))
|
|
1151
|
-
return false;
|
|
1152
|
-
const n = node;
|
|
1153
|
-
return typeof n.key === "object" && n.key !== null && typeof n.value === "object" && n.value !== null;
|
|
1154
|
-
};
|
|
1155
|
-
const isObjectExpressionNode = (node) => {
|
|
1156
|
-
if (!isNodeType(node, "ObjectExpression"))
|
|
1157
|
-
return false;
|
|
1158
|
-
const n = node;
|
|
1159
|
-
return Array.isArray(n.properties);
|
|
1160
|
-
};
|
|
1161
1230
|
function materializeResolvedRouteTarget(target, paramKeys) {
|
|
1162
1231
|
if (typeof target === "string")
|
|
1163
1232
|
return target;
|
|
@@ -2170,103 +2239,19 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2170
2239
|
preferExistingAst: false
|
|
2171
2240
|
});
|
|
2172
2241
|
const fallbackExpr = transformedSource !== authorSource ? tryParseBabelExpressionFromSource(authorSource, ["typescript", "jsx"]) : null;
|
|
2173
|
-
const isNodeType2 = (node2, type) => {
|
|
2174
|
-
return node2 !== null && node2.type === type;
|
|
2175
|
-
};
|
|
2176
|
-
const isIdentifierNode2 = (node2) => {
|
|
2177
|
-
return isNodeType2(node2, "Identifier") && typeof node2.name === "string";
|
|
2178
|
-
};
|
|
2179
|
-
const isStringLiteralNode2 = (node2) => {
|
|
2180
|
-
return isNodeType2(node2, "StringLiteral") && typeof node2.value === "string";
|
|
2181
|
-
};
|
|
2182
|
-
const isBooleanLiteralNode = (node2) => {
|
|
2183
|
-
return isNodeType2(node2, "BooleanLiteral") && typeof node2.value === "boolean";
|
|
2184
|
-
};
|
|
2185
|
-
const isNumericLiteralNode = (node2) => {
|
|
2186
|
-
return isNodeType2(node2, "NumericLiteral") && typeof node2.value === "number";
|
|
2187
|
-
};
|
|
2188
|
-
const isNullLiteralNode = (node2) => {
|
|
2189
|
-
return isNodeType2(node2, "NullLiteral");
|
|
2190
|
-
};
|
|
2191
|
-
const isMemberExpressionNode = (node2) => {
|
|
2192
|
-
if (!isNodeType2(node2, "MemberExpression"))
|
|
2193
|
-
return false;
|
|
2194
|
-
const n = node2;
|
|
2195
|
-
return typeof n.computed === "boolean" && typeof n.object === "object" && n.object !== null && typeof n.property === "object" && n.property !== null;
|
|
2196
|
-
};
|
|
2197
|
-
const isCallExpressionNode = (node2) => {
|
|
2198
|
-
if (!isNodeType2(node2, "CallExpression"))
|
|
2199
|
-
return false;
|
|
2200
|
-
const n = node2;
|
|
2201
|
-
return typeof n.callee === "object" && n.callee !== null && Array.isArray(n.arguments);
|
|
2202
|
-
};
|
|
2203
|
-
const isAwaitExpressionNode = (node2) => {
|
|
2204
|
-
if (!isNodeType2(node2, "AwaitExpression"))
|
|
2205
|
-
return false;
|
|
2206
|
-
const n = node2;
|
|
2207
|
-
return typeof n.argument === "object" && n.argument !== null;
|
|
2208
|
-
};
|
|
2209
|
-
const isAssignmentExpressionNode = (node2) => {
|
|
2210
|
-
if (!isNodeType2(node2, "AssignmentExpression"))
|
|
2211
|
-
return false;
|
|
2212
|
-
const n = node2;
|
|
2213
|
-
return typeof n.left === "object" && n.left !== null && typeof n.right === "object" && n.right !== null;
|
|
2214
|
-
};
|
|
2215
|
-
const isArrowFunctionExpressionNode = (node2) => {
|
|
2216
|
-
if (!isNodeType2(node2, "ArrowFunctionExpression"))
|
|
2217
|
-
return false;
|
|
2218
|
-
const n = node2;
|
|
2219
|
-
return typeof n.body === "object" && n.body !== null;
|
|
2220
|
-
};
|
|
2221
|
-
const isBlockStatementNode = (node2) => {
|
|
2222
|
-
if (!isNodeType2(node2, "BlockStatement"))
|
|
2223
|
-
return false;
|
|
2224
|
-
const n = node2;
|
|
2225
|
-
return Array.isArray(n.body);
|
|
2226
|
-
};
|
|
2227
|
-
const isExpressionStatementNode = (node2) => {
|
|
2228
|
-
if (!isNodeType2(node2, "ExpressionStatement"))
|
|
2229
|
-
return false;
|
|
2230
|
-
const n = node2;
|
|
2231
|
-
return typeof n.expression === "object" && n.expression !== null;
|
|
2232
|
-
};
|
|
2233
|
-
const isReturnStatementNode = (node2) => {
|
|
2234
|
-
if (!isNodeType2(node2, "ReturnStatement"))
|
|
2235
|
-
return false;
|
|
2236
|
-
const n = node2;
|
|
2237
|
-
return typeof n.argument === "object" || n.argument === null;
|
|
2238
|
-
};
|
|
2239
|
-
const isObjectExpressionNode2 = (node2) => {
|
|
2240
|
-
if (!isNodeType2(node2, "ObjectExpression"))
|
|
2241
|
-
return false;
|
|
2242
|
-
const n = node2;
|
|
2243
|
-
return Array.isArray(n.properties);
|
|
2244
|
-
};
|
|
2245
|
-
const isObjectPropertyNode2 = (node2) => {
|
|
2246
|
-
if (!isNodeType2(node2, "ObjectProperty"))
|
|
2247
|
-
return false;
|
|
2248
|
-
const n = node2;
|
|
2249
|
-
return typeof n.computed === "boolean" && typeof n.key === "object" && n.key !== null && typeof n.value === "object" && n.value !== null;
|
|
2250
|
-
};
|
|
2251
|
-
const isLogicalExpressionNode = (node2) => {
|
|
2252
|
-
if (!isNodeType2(node2, "LogicalExpression"))
|
|
2253
|
-
return false;
|
|
2254
|
-
const n = node2;
|
|
2255
|
-
return typeof n.operator === "string" && typeof n.left === "object" && n.left !== null && typeof n.right === "object" && n.right !== null;
|
|
2256
|
-
};
|
|
2257
2242
|
const getLastIdentifierFromMemberChain = (node2) => {
|
|
2258
2243
|
if (!node2)
|
|
2259
2244
|
return null;
|
|
2260
|
-
if (
|
|
2245
|
+
if (isIdentifierNode(node2))
|
|
2261
2246
|
return node2.name;
|
|
2262
2247
|
if (isMemberExpressionNode(node2)) {
|
|
2263
2248
|
const prop = node2.property;
|
|
2264
2249
|
if (node2.computed === false) {
|
|
2265
|
-
if (
|
|
2250
|
+
if (isIdentifierNode(prop))
|
|
2266
2251
|
return prop.name;
|
|
2267
2252
|
}
|
|
2268
2253
|
if (node2.computed === true) {
|
|
2269
|
-
if (
|
|
2254
|
+
if (isStringLiteralNode(prop))
|
|
2270
2255
|
return prop.value;
|
|
2271
2256
|
}
|
|
2272
2257
|
}
|
|
@@ -2276,7 +2261,7 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2276
2261
|
if (!node2) {
|
|
2277
2262
|
return null;
|
|
2278
2263
|
}
|
|
2279
|
-
if (
|
|
2264
|
+
if (isIdentifierNode(node2)) {
|
|
2280
2265
|
return node2.name;
|
|
2281
2266
|
}
|
|
2282
2267
|
if (isMemberExpressionNode(node2)) {
|
|
@@ -2288,11 +2273,11 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2288
2273
|
if (!lhs) {
|
|
2289
2274
|
return null;
|
|
2290
2275
|
}
|
|
2291
|
-
if (
|
|
2276
|
+
if (isIdentifierNode(lhs)) {
|
|
2292
2277
|
return lhs.name;
|
|
2293
2278
|
}
|
|
2294
2279
|
if (isMemberExpressionNode(lhs)) {
|
|
2295
|
-
if (lhs.computed === false &&
|
|
2280
|
+
if (lhs.computed === false && isIdentifierNode(lhs.property) && lhs.property.name === "value") {
|
|
2296
2281
|
return getLastIdentifierFromMemberChain(lhs.object);
|
|
2297
2282
|
}
|
|
2298
2283
|
return getLastIdentifierFromMemberChain(lhs);
|
|
@@ -2300,7 +2285,7 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2300
2285
|
return null;
|
|
2301
2286
|
};
|
|
2302
2287
|
const isTemplateLiteralNode = (node2) => {
|
|
2303
|
-
if (!
|
|
2288
|
+
if (!isNodeType(node2, "TemplateLiteral")) {
|
|
2304
2289
|
return false;
|
|
2305
2290
|
}
|
|
2306
2291
|
const n = node2;
|
|
@@ -2319,7 +2304,7 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2319
2304
|
if (isNullLiteralNode(arg)) {
|
|
2320
2305
|
return "Null";
|
|
2321
2306
|
}
|
|
2322
|
-
if (
|
|
2307
|
+
if (isStringLiteralNode(arg)) {
|
|
2323
2308
|
const cleaned = (arg.value ?? "").trim();
|
|
2324
2309
|
if (!cleaned) {
|
|
2325
2310
|
return null;
|
|
@@ -2345,7 +2330,7 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2345
2330
|
return toPascalCase(stableName.slice(0, 24));
|
|
2346
2331
|
}
|
|
2347
2332
|
}
|
|
2348
|
-
if (
|
|
2333
|
+
if (isIdentifierNode(arg)) {
|
|
2349
2334
|
const firstChar = arg.name.charAt(0);
|
|
2350
2335
|
const isUpperAlpha = firstChar !== "" && firstChar === firstChar.toUpperCase() && firstChar !== firstChar.toLowerCase();
|
|
2351
2336
|
if (isUpperAlpha) {
|
|
@@ -2357,7 +2342,7 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2357
2342
|
const getStableSuffixFromCall = (call) => {
|
|
2358
2343
|
const args = call.arguments ?? [];
|
|
2359
2344
|
const first = args.length > 0 ? args[0] : null;
|
|
2360
|
-
if (!
|
|
2345
|
+
if (!isObjectExpressionNode(first)) {
|
|
2361
2346
|
const parts2 = [];
|
|
2362
2347
|
for (const arg of args.slice(0, 4)) {
|
|
2363
2348
|
const w = stableWordFromValue(arg ?? null);
|
|
@@ -2376,20 +2361,20 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2376
2361
|
}
|
|
2377
2362
|
const parts = [];
|
|
2378
2363
|
for (const prop of first.properties ?? []) {
|
|
2379
|
-
if (!
|
|
2364
|
+
if (!isObjectPropertyNode(prop)) {
|
|
2380
2365
|
continue;
|
|
2381
2366
|
}
|
|
2382
2367
|
if (prop.computed) {
|
|
2383
2368
|
continue;
|
|
2384
2369
|
}
|
|
2385
|
-
const keyName =
|
|
2370
|
+
const keyName = isIdentifierNode(prop.key) ? prop.key.name : isStringLiteralNode(prop.key) ? prop.key.value : null;
|
|
2386
2371
|
if (!keyName) {
|
|
2387
2372
|
continue;
|
|
2388
2373
|
}
|
|
2389
2374
|
let valueWord = null;
|
|
2390
2375
|
if (isBooleanLiteralNode(prop.value)) {
|
|
2391
2376
|
valueWord = prop.value.value ? "True" : "False";
|
|
2392
|
-
} else if (
|
|
2377
|
+
} else if (isStringLiteralNode(prop.value)) {
|
|
2393
2378
|
const cleaned = (prop.value.value ?? "").trim();
|
|
2394
2379
|
if (cleaned) {
|
|
2395
2380
|
valueWord = toPascalCase(cleaned.slice(0, 24));
|
|
@@ -2489,7 +2474,7 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2489
2474
|
return null;
|
|
2490
2475
|
};
|
|
2491
2476
|
const isVueRefValueAccess = (candidate) => {
|
|
2492
|
-
return isMemberExpressionNode(candidate) && candidate.computed === false &&
|
|
2477
|
+
return isMemberExpressionNode(candidate) && candidate.computed === false && isIdentifierNode(candidate.property) && candidate.property.name === "value";
|
|
2493
2478
|
};
|
|
2494
2479
|
const transformedSemanticName = resolveSemanticName(expr);
|
|
2495
2480
|
const fallbackSemanticName = resolveSemanticName(fallbackExpr);
|
|
@@ -2625,36 +2610,15 @@ function toDirectiveObjectFieldNameValue(node) {
|
|
|
2625
2610
|
if (!expr) {
|
|
2626
2611
|
return null;
|
|
2627
2612
|
}
|
|
2628
|
-
|
|
2629
|
-
return n !== null && n.type === type;
|
|
2630
|
-
};
|
|
2631
|
-
const isStringLiteralNode2 = (n) => {
|
|
2632
|
-
return isNodeType2(n, "StringLiteral") && typeof n.value === "string";
|
|
2633
|
-
};
|
|
2634
|
-
const isIdentifierNode2 = (n) => {
|
|
2635
|
-
return isNodeType2(n, "Identifier") && typeof n.name === "string";
|
|
2636
|
-
};
|
|
2637
|
-
const isObjectPropertyNode2 = (n) => {
|
|
2638
|
-
if (!isNodeType2(n, "ObjectProperty"))
|
|
2639
|
-
return false;
|
|
2640
|
-
const nn = n;
|
|
2641
|
-
return typeof nn.key === "object" && nn.key !== null && typeof nn.value === "object" && nn.value !== null;
|
|
2642
|
-
};
|
|
2643
|
-
const isObjectExpressionNode2 = (n) => {
|
|
2644
|
-
if (!isNodeType2(n, "ObjectExpression"))
|
|
2645
|
-
return false;
|
|
2646
|
-
const nn = n;
|
|
2647
|
-
return Array.isArray(nn.properties);
|
|
2648
|
-
};
|
|
2649
|
-
if (!isObjectExpressionNode2(expr))
|
|
2613
|
+
if (!isObjectExpressionNode(expr))
|
|
2650
2614
|
return null;
|
|
2651
2615
|
const nameProp = expr.properties.find((p) => {
|
|
2652
|
-
if (!
|
|
2616
|
+
if (!isObjectPropertyNodeShallow(p))
|
|
2653
2617
|
return false;
|
|
2654
2618
|
const key = p.key;
|
|
2655
|
-
return
|
|
2619
|
+
return isIdentifierNode(key) && key.name === "name" || isStringLiteralNode(key) && key.value === "name";
|
|
2656
2620
|
});
|
|
2657
|
-
if (!nameProp || !
|
|
2621
|
+
if (!nameProp || !isObjectPropertyNodeShallow(nameProp) || !isStringLiteralNode(nameProp.value))
|
|
2658
2622
|
return null;
|
|
2659
2623
|
return toPascalCase(nameProp.value.value);
|
|
2660
2624
|
}
|
|
@@ -9347,26 +9311,17 @@ function tryExtractStableHintFromConditionalExpressionSource(source) {
|
|
|
9347
9311
|
};
|
|
9348
9312
|
try {
|
|
9349
9313
|
const expr = parser.parseExpression(src, { plugins: ["typescript"] });
|
|
9350
|
-
const isNodeType2 = (n, type) => {
|
|
9351
|
-
return n !== null && n.type === type;
|
|
9352
|
-
};
|
|
9353
|
-
const isStringLiteralNode2 = (n) => {
|
|
9354
|
-
return isNodeType2(n, "StringLiteral") && typeof n.value === "string";
|
|
9355
|
-
};
|
|
9356
|
-
const isIdentifierNode2 = (n) => {
|
|
9357
|
-
return isNodeType2(n, "Identifier") && typeof n.name === "string";
|
|
9358
|
-
};
|
|
9359
9314
|
const results = [];
|
|
9360
9315
|
const walk = (n) => {
|
|
9361
9316
|
if (!n)
|
|
9362
9317
|
return;
|
|
9363
|
-
if (
|
|
9318
|
+
if (isStringLiteralNode(n)) {
|
|
9364
9319
|
const v = (n.value ?? "").trim();
|
|
9365
9320
|
if (isIdentifierish(v)) {
|
|
9366
9321
|
results.push(v);
|
|
9367
9322
|
}
|
|
9368
9323
|
}
|
|
9369
|
-
if (
|
|
9324
|
+
if (isIdentifierNode(n)) {
|
|
9370
9325
|
const v = (n.name ?? "").trim();
|
|
9371
9326
|
if (isIdentifierish(v)) {
|
|
9372
9327
|
results.push(v);
|
|
@@ -11994,6 +11949,20 @@ const ANNOTATOR_STYLES = `
|
|
|
11994
11949
|
max-width: min(320px, calc(100vw - 24px));
|
|
11995
11950
|
}
|
|
11996
11951
|
|
|
11952
|
+
.vpg-annotator-panel--preview {
|
|
11953
|
+
min-width: min(720px, calc(100vw - 24px));
|
|
11954
|
+
max-width: min(940px, calc(100vw - 24px));
|
|
11955
|
+
}
|
|
11956
|
+
|
|
11957
|
+
.vpg-annotator-panel--preview .vpg-annotator-textarea {
|
|
11958
|
+
height: min(52vh, 440px);
|
|
11959
|
+
resize: vertical;
|
|
11960
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
11961
|
+
white-space: pre;
|
|
11962
|
+
overflow: auto;
|
|
11963
|
+
}
|
|
11964
|
+
|
|
11965
|
+
|
|
11997
11966
|
.vpg-annotator-arrow {
|
|
11998
11967
|
position: absolute;
|
|
11999
11968
|
z-index: 0;
|
|
@@ -12108,18 +12077,6 @@ const ANNOTATOR_STYLES = `
|
|
|
12108
12077
|
margin-top: 12px;
|
|
12109
12078
|
}
|
|
12110
12079
|
|
|
12111
|
-
.vpg-annotator-shortcuts {
|
|
12112
|
-
display: grid;
|
|
12113
|
-
gap: 8px;
|
|
12114
|
-
}
|
|
12115
|
-
|
|
12116
|
-
.vpg-annotator-shortcut-row {
|
|
12117
|
-
display: flex;
|
|
12118
|
-
align-items: center;
|
|
12119
|
-
justify-content: space-between;
|
|
12120
|
-
gap: 12px;
|
|
12121
|
-
}
|
|
12122
|
-
|
|
12123
12080
|
.vpg-annotator-label {
|
|
12124
12081
|
font-size: 12px;
|
|
12125
12082
|
font-weight: 600;
|
|
@@ -12135,20 +12092,6 @@ const ANNOTATOR_STYLES = `
|
|
|
12135
12092
|
padding: 8px 10px;
|
|
12136
12093
|
}
|
|
12137
12094
|
|
|
12138
|
-
.vpg-annotator-kbd {
|
|
12139
|
-
min-width: 32px;
|
|
12140
|
-
padding: 4px 8px;
|
|
12141
|
-
border: 1px solid var(--vpg-annotator-border);
|
|
12142
|
-
border-radius: var(--vpg-annotator-radius);
|
|
12143
|
-
background: rgba(15, 23, 42, 0.72);
|
|
12144
|
-
color: var(--vpg-annotator-text);
|
|
12145
|
-
font: inherit;
|
|
12146
|
-
font-size: 11px;
|
|
12147
|
-
font-weight: 700;
|
|
12148
|
-
line-height: 1;
|
|
12149
|
-
text-align: center;
|
|
12150
|
-
}
|
|
12151
|
-
|
|
12152
12095
|
.vpg-annotator-highlight {
|
|
12153
12096
|
position: fixed;
|
|
12154
12097
|
z-index: 2147483646;
|
|
@@ -12180,6 +12123,7 @@ const ANNOTATOR_STYLES = `
|
|
|
12180
12123
|
inset: 0;
|
|
12181
12124
|
z-index: 2147483645;
|
|
12182
12125
|
background: transparent;
|
|
12126
|
+
cursor: crosshair;
|
|
12183
12127
|
}
|
|
12184
12128
|
|
|
12185
12129
|
.vpg-annotator-marker {
|
|
@@ -12212,6 +12156,34 @@ const ANNOTATOR_STYLES = `
|
|
|
12212
12156
|
font-size: 12px;
|
|
12213
12157
|
font-weight: 600;
|
|
12214
12158
|
}
|
|
12159
|
+
|
|
12160
|
+
.vpg-annotator-heading-row {
|
|
12161
|
+
display: flex;
|
|
12162
|
+
align-items: center;
|
|
12163
|
+
justify-content: space-between;
|
|
12164
|
+
gap: 8px;
|
|
12165
|
+
}
|
|
12166
|
+
|
|
12167
|
+
.vpg-annotator-heading-row .vpg-annotator-heading {
|
|
12168
|
+
margin-bottom: 4px;
|
|
12169
|
+
}
|
|
12170
|
+
|
|
12171
|
+
.vpg-annotator-panel-close {
|
|
12172
|
+
margin-left: auto;
|
|
12173
|
+
background: transparent;
|
|
12174
|
+
border: none;
|
|
12175
|
+
color: var(--vpg-annotator-text-soft);
|
|
12176
|
+
font-size: 16px;
|
|
12177
|
+
line-height: 1;
|
|
12178
|
+
padding: 2px 6px;
|
|
12179
|
+
cursor: pointer;
|
|
12180
|
+
border-radius: var(--vpg-annotator-radius);
|
|
12181
|
+
}
|
|
12182
|
+
|
|
12183
|
+
.vpg-annotator-panel-close:hover {
|
|
12184
|
+
color: var(--vpg-annotator-text);
|
|
12185
|
+
background: var(--vpg-annotator-bg-soft);
|
|
12186
|
+
}
|
|
12215
12187
|
`;
|
|
12216
12188
|
const ignoredComponentNamePattern = /^(?:items\[\d+\]\.template|template|anonymous|slot|transition|transition-group)$/i;
|
|
12217
12189
|
function getDirectVueInstances(element) {
|
|
@@ -12370,35 +12342,15 @@ const TOOLBAR_POSITION_STORAGE_KEY = "vpg-annotator-toolbar-position";
|
|
|
12370
12342
|
const RUNTIME_GUARD = "__VUE_POM_GENERATOR_ANNOTATOR_RUNTIME__";
|
|
12371
12343
|
const TOOLBAR_ICON_MARKUP = {
|
|
12372
12344
|
drag: '<svg viewBox="0 0 16 16"><path d="M5 3h1v1H5zM10 3h1v1h-1zM5 7h1v1H5zM10 7h1v1h-1zM5 11h1v1H5zM10 11h1v1h-1z" fill="currentColor" stroke="none" /></svg>',
|
|
12373
|
-
inspect: '<svg viewBox="0 0 16 16"><path d="M8
|
|
12345
|
+
inspect: '<svg viewBox="0 0 16 16"><circle cx="8" cy="8" r="4.5"/><path d="M8 1v2.5M8 12.5v2.5M1 8h2.5M12.5 8h2.5"/><circle cx="8" cy="8" r="0.9" fill="currentColor" stroke="none"/></svg>',
|
|
12374
12346
|
preview: '<svg viewBox="0 0 16 16"><path d="M1.5 8s2.4-4 6.5-4 6.5 4 6.5 4-2.4 4-6.5 4-6.5-4-6.5-4Z"/><circle cx="8" cy="8" r="1.8"/></svg>',
|
|
12375
12347
|
copy: '<svg viewBox="0 0 16 16"><path d="M6 2.5h6.5v9H6z"/><path d="M3.5 5.5H5v6.5h5.5v1.5h-7z"/></svg>',
|
|
12376
12348
|
clear: '<svg viewBox="0 0 16 16"><path d="M2.5 4.5h11"/><path d="M6 2.5h4"/><path d="M5 4.5v8"/><path d="M8 4.5v8"/><path d="M11 4.5v8"/><path d="M4 4.5h8l-.6 9H4.6z"/></svg>',
|
|
12377
12349
|
settings: '<svg viewBox="0 0 16 16"><path d="M8 2.2l1 .6 1.2-.2.8 1 .9.7-.3 1.2.5 1-.5 1 .3 1.2-.9.7-.8 1-1.2-.2-1 .6-1-.6-1.2.2-.8-1-.9-.7.3-1.2-.5-1 .5-1-.3-1.2.9-.7.8-1 1.2.2z"/><circle cx="8" cy="8" r="2.2"/></svg>'
|
|
12378
12350
|
};
|
|
12379
|
-
const SHORTCUT_LABELS = {
|
|
12380
|
-
select: "S",
|
|
12381
|
-
preview: "P",
|
|
12382
|
-
copy: "C",
|
|
12383
|
-
clear: "X",
|
|
12384
|
-
settings: ",",
|
|
12385
|
-
cancel: "Esc"
|
|
12386
|
-
};
|
|
12387
|
-
function formatShortcutTitle(label, shortcut) {
|
|
12388
|
-
return shortcut ? `${label} (${shortcut})` : label;
|
|
12389
|
-
}
|
|
12390
12351
|
function isInsideAnnotatorTree(node) {
|
|
12391
12352
|
return node instanceof Element && !!node.closest(`[${ANNOTATOR_ROOT_ATTR}]`);
|
|
12392
12353
|
}
|
|
12393
|
-
function isEditableTarget(node) {
|
|
12394
|
-
if (!(node instanceof Element)) {
|
|
12395
|
-
return false;
|
|
12396
|
-
}
|
|
12397
|
-
if (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement || node instanceof HTMLSelectElement) {
|
|
12398
|
-
return true;
|
|
12399
|
-
}
|
|
12400
|
-
return node.closest('[contenteditable=""], [contenteditable="true"]') !== null;
|
|
12401
|
-
}
|
|
12402
12354
|
function getElementSummary(element) {
|
|
12403
12355
|
const testId = element.getAttribute("data-testid");
|
|
12404
12356
|
if (testId) {
|
|
@@ -12463,10 +12415,7 @@ function createButtonBase(label, onClick, options = {}) {
|
|
|
12463
12415
|
button.className = `vpg-annotator-btn${options.primary ? " vpg-annotator-btn--primary" : ""}`;
|
|
12464
12416
|
button.setAttribute(ANNOTATOR_ROOT_ATTR, "");
|
|
12465
12417
|
button.setAttribute("aria-label", label);
|
|
12466
|
-
button.title =
|
|
12467
|
-
if (options.shortcut) {
|
|
12468
|
-
button.setAttribute("aria-keyshortcuts", options.shortcut);
|
|
12469
|
-
}
|
|
12418
|
+
button.title = label;
|
|
12470
12419
|
if (options.pressed) {
|
|
12471
12420
|
button.setAttribute("aria-pressed", "true");
|
|
12472
12421
|
}
|
|
@@ -12606,23 +12555,18 @@ class AnnotatorRuntime {
|
|
|
12606
12555
|
count.textContent = `${this.annotations.length} annotation${this.annotations.length === 1 ? "" : "s"}`;
|
|
12607
12556
|
const selectButton = createIconButton(this.inspectMode ? "Stop selecting" : "Select element", "inspect", () => {
|
|
12608
12557
|
this.setInspectMode(!this.inspectMode);
|
|
12609
|
-
}, { primary: this.inspectMode, pressed: this.inspectMode
|
|
12558
|
+
}, { primary: this.inspectMode, pressed: this.inspectMode });
|
|
12610
12559
|
const previewButton = createIconButton("Preview annotations", "preview", () => this.openPreview(), {
|
|
12611
|
-
disabled: this.annotations.length === 0
|
|
12612
|
-
shortcut: SHORTCUT_LABELS.preview
|
|
12560
|
+
disabled: this.annotations.length === 0
|
|
12613
12561
|
});
|
|
12614
12562
|
this.previewButton = previewButton;
|
|
12615
12563
|
const copyButton = createIconButton("Copy annotations", "copy", () => this.copyAnnotations(), {
|
|
12616
|
-
disabled: this.annotations.length === 0
|
|
12617
|
-
shortcut: SHORTCUT_LABELS.copy
|
|
12564
|
+
disabled: this.annotations.length === 0
|
|
12618
12565
|
});
|
|
12619
12566
|
const clearButton = createIconButton("Clear annotations", "clear", () => this.clearAnnotations(), {
|
|
12620
|
-
disabled: this.annotations.length === 0
|
|
12621
|
-
shortcut: SHORTCUT_LABELS.clear
|
|
12622
|
-
});
|
|
12623
|
-
const settingsButton = createIconButton("Annotator settings", "settings", () => this.openSettings(), {
|
|
12624
|
-
shortcut: SHORTCUT_LABELS.settings
|
|
12567
|
+
disabled: this.annotations.length === 0
|
|
12625
12568
|
});
|
|
12569
|
+
const settingsButton = createIconButton("Annotator settings", "settings", () => this.openSettings());
|
|
12626
12570
|
this.settingsButton = settingsButton;
|
|
12627
12571
|
this.toolbarEl.append(handle, selectButton, previewButton, copyButton, clearButton, settingsButton, count);
|
|
12628
12572
|
this.applyToolbarPosition();
|
|
@@ -12653,7 +12597,6 @@ class AnnotatorRuntime {
|
|
|
12653
12597
|
this.renderMarkers();
|
|
12654
12598
|
this.applyToolbarPosition();
|
|
12655
12599
|
});
|
|
12656
|
-
window.addEventListener("keydown", (event) => this.onWindowKeyDown(event), true);
|
|
12657
12600
|
}
|
|
12658
12601
|
loadSettings() {
|
|
12659
12602
|
try {
|
|
@@ -12780,60 +12723,6 @@ class AnnotatorRuntime {
|
|
|
12780
12723
|
window.addEventListener("pointercancel", onPointerUp);
|
|
12781
12724
|
});
|
|
12782
12725
|
}
|
|
12783
|
-
onWindowKeyDown(event) {
|
|
12784
|
-
if (event.defaultPrevented || event.metaKey || event.ctrlKey || event.altKey) {
|
|
12785
|
-
return;
|
|
12786
|
-
}
|
|
12787
|
-
if (event.key === "Escape") {
|
|
12788
|
-
if (!this.inspectMode && !this.currentPanelEl) {
|
|
12789
|
-
return;
|
|
12790
|
-
}
|
|
12791
|
-
event.preventDefault();
|
|
12792
|
-
if (this.inspectMode) {
|
|
12793
|
-
this.setInspectMode(false);
|
|
12794
|
-
} else {
|
|
12795
|
-
this.closePanel();
|
|
12796
|
-
}
|
|
12797
|
-
return;
|
|
12798
|
-
}
|
|
12799
|
-
if (isEditableTarget(event.target)) {
|
|
12800
|
-
return;
|
|
12801
|
-
}
|
|
12802
|
-
const key = event.key.toLowerCase();
|
|
12803
|
-
if (key === SHORTCUT_LABELS.select.toLowerCase()) {
|
|
12804
|
-
event.preventDefault();
|
|
12805
|
-
this.setInspectMode(!this.inspectMode);
|
|
12806
|
-
return;
|
|
12807
|
-
}
|
|
12808
|
-
if (key === SHORTCUT_LABELS.preview.toLowerCase()) {
|
|
12809
|
-
if (!this.annotations.length) {
|
|
12810
|
-
return;
|
|
12811
|
-
}
|
|
12812
|
-
event.preventDefault();
|
|
12813
|
-
this.openPreview();
|
|
12814
|
-
return;
|
|
12815
|
-
}
|
|
12816
|
-
if (key === SHORTCUT_LABELS.copy.toLowerCase()) {
|
|
12817
|
-
if (!this.annotations.length) {
|
|
12818
|
-
return;
|
|
12819
|
-
}
|
|
12820
|
-
event.preventDefault();
|
|
12821
|
-
void this.copyAnnotations();
|
|
12822
|
-
return;
|
|
12823
|
-
}
|
|
12824
|
-
if (key === SHORTCUT_LABELS.clear.toLowerCase()) {
|
|
12825
|
-
if (!this.annotations.length) {
|
|
12826
|
-
return;
|
|
12827
|
-
}
|
|
12828
|
-
event.preventDefault();
|
|
12829
|
-
this.clearAnnotations();
|
|
12830
|
-
return;
|
|
12831
|
-
}
|
|
12832
|
-
if (event.key === SHORTCUT_LABELS.settings) {
|
|
12833
|
-
event.preventDefault();
|
|
12834
|
-
this.openSettings();
|
|
12835
|
-
}
|
|
12836
|
-
}
|
|
12837
12726
|
setInspectMode(next) {
|
|
12838
12727
|
this.inspectMode = next;
|
|
12839
12728
|
this.shieldEl.hidden = !next;
|
|
@@ -13018,11 +12907,21 @@ class AnnotatorRuntime {
|
|
|
13018
12907
|
this.editingAnnotationId = annotation.id;
|
|
13019
12908
|
this.openInputForDraft(reference);
|
|
13020
12909
|
}
|
|
12910
|
+
createPanelCloseButton(ariaLabel) {
|
|
12911
|
+
const closeButton = document.createElement("button");
|
|
12912
|
+
closeButton.type = "button";
|
|
12913
|
+
closeButton.className = "vpg-annotator-panel-close";
|
|
12914
|
+
closeButton.setAttribute(ANNOTATOR_ROOT_ATTR, "");
|
|
12915
|
+
closeButton.setAttribute("aria-label", ariaLabel);
|
|
12916
|
+
closeButton.textContent = "×";
|
|
12917
|
+
closeButton.addEventListener("click", () => this.closePanel());
|
|
12918
|
+
return closeButton;
|
|
12919
|
+
}
|
|
13021
12920
|
openPreview() {
|
|
13022
12921
|
if (!this.previewButton || this.annotations.length === 0) {
|
|
13023
12922
|
return;
|
|
13024
12923
|
}
|
|
13025
|
-
const { panel, body, arrowEl } = this.createPanelBase("vpg-annotator-panel");
|
|
12924
|
+
const { panel, body, arrowEl } = this.createPanelBase("vpg-annotator-panel vpg-annotator-panel--preview");
|
|
13026
12925
|
const title = document.createElement("div");
|
|
13027
12926
|
title.className = "vpg-annotator-heading";
|
|
13028
12927
|
title.textContent = "Annotation preview";
|
|
@@ -13033,7 +12932,10 @@ class AnnotatorRuntime {
|
|
|
13033
12932
|
textarea.className = "vpg-annotator-textarea";
|
|
13034
12933
|
textarea.readOnly = true;
|
|
13035
12934
|
textarea.value = formatAnnotations(this.annotations, this.settings.outputDetail, window.location.href);
|
|
13036
|
-
|
|
12935
|
+
const headerRow = document.createElement("div");
|
|
12936
|
+
headerRow.className = "vpg-annotator-heading-row";
|
|
12937
|
+
headerRow.append(title, this.createPanelCloseButton("Close preview"));
|
|
12938
|
+
body.append(headerRow, subtitle, textarea);
|
|
13037
12939
|
this.showPanel(panel, () => this.attachFloating(this.previewButton, panel, arrowEl, "top-start", ["top-start", "left-start", "top-end", "left-end"]));
|
|
13038
12940
|
}
|
|
13039
12941
|
openSettings() {
|
|
@@ -13072,35 +12974,7 @@ class AnnotatorRuntime {
|
|
|
13072
12974
|
this.saveSettings();
|
|
13073
12975
|
});
|
|
13074
12976
|
showComponentField.append(showComponentCopy, showComponentCheckbox);
|
|
13075
|
-
|
|
13076
|
-
shortcutsField.className = "vpg-annotator-field";
|
|
13077
|
-
const shortcutsLabel = document.createElement("div");
|
|
13078
|
-
shortcutsLabel.className = "vpg-annotator-label";
|
|
13079
|
-
shortcutsLabel.textContent = "Keyboard shortcuts";
|
|
13080
|
-
const shortcutsList = document.createElement("div");
|
|
13081
|
-
shortcutsList.className = "vpg-annotator-shortcuts";
|
|
13082
|
-
for (const [shortcut, description] of [
|
|
13083
|
-
[SHORTCUT_LABELS.select, "Toggle selection mode"],
|
|
13084
|
-
[SHORTCUT_LABELS.preview, "Open preview"],
|
|
13085
|
-
[SHORTCUT_LABELS.copy, "Copy annotations"],
|
|
13086
|
-
[SHORTCUT_LABELS.clear, "Clear annotations"],
|
|
13087
|
-
[SHORTCUT_LABELS.settings, "Open settings"],
|
|
13088
|
-
[SHORTCUT_LABELS.cancel, "Close panel / cancel selection"]
|
|
13089
|
-
]) {
|
|
13090
|
-
const row = document.createElement("div");
|
|
13091
|
-
row.className = "vpg-annotator-shortcut-row";
|
|
13092
|
-
const text = document.createElement("span");
|
|
13093
|
-
text.className = "vpg-annotator-subtle";
|
|
13094
|
-
text.textContent = description;
|
|
13095
|
-
const kbd = document.createElement("kbd");
|
|
13096
|
-
kbd.className = "vpg-annotator-kbd";
|
|
13097
|
-
kbd.setAttribute(ANNOTATOR_ROOT_ATTR, "");
|
|
13098
|
-
kbd.textContent = shortcut;
|
|
13099
|
-
row.append(text, kbd);
|
|
13100
|
-
shortcutsList.appendChild(row);
|
|
13101
|
-
}
|
|
13102
|
-
shortcutsField.append(shortcutsLabel, shortcutsList);
|
|
13103
|
-
body.append(title, detailField, showComponentField, shortcutsField);
|
|
12977
|
+
body.append(title, detailField, showComponentField);
|
|
13104
12978
|
this.showPanel(panel, () => this.attachFloating(this.settingsButton, panel, arrowEl, "top-start", ["top-start", "left-start", "top-end", "left-end"]));
|
|
13105
12979
|
}
|
|
13106
12980
|
disposeCurrentPanel() {
|