@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.mjs
CHANGED
|
@@ -1058,6 +1058,96 @@ function collectAccessibilityReviewWarnings(manifest) {
|
|
|
1058
1058
|
}
|
|
1059
1059
|
return warnings;
|
|
1060
1060
|
}
|
|
1061
|
+
const isNodeType = (node, type) => {
|
|
1062
|
+
return node !== null && node.type === type;
|
|
1063
|
+
};
|
|
1064
|
+
const isIdentifierNode = (node) => {
|
|
1065
|
+
return isNodeType(node, "Identifier") && typeof node.name === "string";
|
|
1066
|
+
};
|
|
1067
|
+
const isStringLiteralNode = (node) => {
|
|
1068
|
+
return isNodeType(node, "StringLiteral") && typeof node.value === "string";
|
|
1069
|
+
};
|
|
1070
|
+
const isBooleanLiteralNode = (node) => {
|
|
1071
|
+
return isNodeType(node, "BooleanLiteral") && typeof node.value === "boolean";
|
|
1072
|
+
};
|
|
1073
|
+
const isNumericLiteralNode = (node) => {
|
|
1074
|
+
return isNodeType(node, "NumericLiteral") && typeof node.value === "number";
|
|
1075
|
+
};
|
|
1076
|
+
const isNullLiteralNode = (node) => {
|
|
1077
|
+
return isNodeType(node, "NullLiteral");
|
|
1078
|
+
};
|
|
1079
|
+
const isMemberExpressionNode = (node) => {
|
|
1080
|
+
if (!isNodeType(node, "MemberExpression"))
|
|
1081
|
+
return false;
|
|
1082
|
+
const n = node;
|
|
1083
|
+
return typeof n.computed === "boolean" && typeof n.object === "object" && n.object !== null && typeof n.property === "object" && n.property !== null;
|
|
1084
|
+
};
|
|
1085
|
+
const isCallExpressionNode = (node) => {
|
|
1086
|
+
if (!isNodeType(node, "CallExpression"))
|
|
1087
|
+
return false;
|
|
1088
|
+
const n = node;
|
|
1089
|
+
return typeof n.callee === "object" && n.callee !== null && Array.isArray(n.arguments);
|
|
1090
|
+
};
|
|
1091
|
+
const isAwaitExpressionNode = (node) => {
|
|
1092
|
+
if (!isNodeType(node, "AwaitExpression"))
|
|
1093
|
+
return false;
|
|
1094
|
+
const n = node;
|
|
1095
|
+
return typeof n.argument === "object" && n.argument !== null;
|
|
1096
|
+
};
|
|
1097
|
+
const isAssignmentExpressionNode = (node) => {
|
|
1098
|
+
if (!isNodeType(node, "AssignmentExpression"))
|
|
1099
|
+
return false;
|
|
1100
|
+
const n = node;
|
|
1101
|
+
return typeof n.left === "object" && n.left !== null && typeof n.right === "object" && n.right !== null;
|
|
1102
|
+
};
|
|
1103
|
+
const isArrowFunctionExpressionNode = (node) => {
|
|
1104
|
+
if (!isNodeType(node, "ArrowFunctionExpression"))
|
|
1105
|
+
return false;
|
|
1106
|
+
const n = node;
|
|
1107
|
+
return typeof n.body === "object" && n.body !== null;
|
|
1108
|
+
};
|
|
1109
|
+
const isBlockStatementNode = (node) => {
|
|
1110
|
+
if (!isNodeType(node, "BlockStatement"))
|
|
1111
|
+
return false;
|
|
1112
|
+
const n = node;
|
|
1113
|
+
return Array.isArray(n.body);
|
|
1114
|
+
};
|
|
1115
|
+
const isExpressionStatementNode = (node) => {
|
|
1116
|
+
if (!isNodeType(node, "ExpressionStatement"))
|
|
1117
|
+
return false;
|
|
1118
|
+
const n = node;
|
|
1119
|
+
return typeof n.expression === "object" && n.expression !== null;
|
|
1120
|
+
};
|
|
1121
|
+
const isReturnStatementNode = (node) => {
|
|
1122
|
+
if (!isNodeType(node, "ReturnStatement"))
|
|
1123
|
+
return false;
|
|
1124
|
+
const n = node;
|
|
1125
|
+
return typeof n.argument === "object" || n.argument === null;
|
|
1126
|
+
};
|
|
1127
|
+
const isObjectExpressionNode = (node) => {
|
|
1128
|
+
if (!isNodeType(node, "ObjectExpression"))
|
|
1129
|
+
return false;
|
|
1130
|
+
const n = node;
|
|
1131
|
+
return Array.isArray(n.properties);
|
|
1132
|
+
};
|
|
1133
|
+
const isObjectPropertyNode = (node) => {
|
|
1134
|
+
if (!isNodeType(node, "ObjectProperty"))
|
|
1135
|
+
return false;
|
|
1136
|
+
const n = node;
|
|
1137
|
+
return typeof n.computed === "boolean" && typeof n.key === "object" && n.key !== null && typeof n.value === "object" && n.value !== null;
|
|
1138
|
+
};
|
|
1139
|
+
const isObjectPropertyNodeShallow = (node) => {
|
|
1140
|
+
if (!isNodeType(node, "ObjectProperty"))
|
|
1141
|
+
return false;
|
|
1142
|
+
const n = node;
|
|
1143
|
+
return typeof n.key === "object" && n.key !== null && typeof n.value === "object" && n.value !== null;
|
|
1144
|
+
};
|
|
1145
|
+
const isLogicalExpressionNode = (node) => {
|
|
1146
|
+
if (!isNodeType(node, "LogicalExpression"))
|
|
1147
|
+
return false;
|
|
1148
|
+
const n = node;
|
|
1149
|
+
return typeof n.operator === "string" && typeof n.left === "object" && n.left !== null && typeof n.right === "object" && n.right !== null;
|
|
1150
|
+
};
|
|
1061
1151
|
function isSimpleExpressionNode(value) {
|
|
1062
1152
|
return value !== null && "type" in value && value.type === NodeTypes.SIMPLE_EXPRESSION;
|
|
1063
1153
|
}
|
|
@@ -1096,27 +1186,6 @@ function buildPlaceholderParams(keys) {
|
|
|
1096
1186
|
params[k] = "__placeholder__";
|
|
1097
1187
|
return params;
|
|
1098
1188
|
}
|
|
1099
|
-
const isNodeType = (node, type) => {
|
|
1100
|
-
return node !== null && node.type === type;
|
|
1101
|
-
};
|
|
1102
|
-
const isStringLiteralNode = (node) => {
|
|
1103
|
-
return isNodeType(node, "StringLiteral") && typeof node.value === "string";
|
|
1104
|
-
};
|
|
1105
|
-
const isIdentifierNode = (node) => {
|
|
1106
|
-
return isNodeType(node, "Identifier") && typeof node.name === "string";
|
|
1107
|
-
};
|
|
1108
|
-
const isObjectPropertyNode = (node) => {
|
|
1109
|
-
if (!isNodeType(node, "ObjectProperty"))
|
|
1110
|
-
return false;
|
|
1111
|
-
const n = node;
|
|
1112
|
-
return typeof n.key === "object" && n.key !== null && typeof n.value === "object" && n.value !== null;
|
|
1113
|
-
};
|
|
1114
|
-
const isObjectExpressionNode = (node) => {
|
|
1115
|
-
if (!isNodeType(node, "ObjectExpression"))
|
|
1116
|
-
return false;
|
|
1117
|
-
const n = node;
|
|
1118
|
-
return Array.isArray(n.properties);
|
|
1119
|
-
};
|
|
1120
1189
|
function materializeResolvedRouteTarget(target, paramKeys) {
|
|
1121
1190
|
if (typeof target === "string")
|
|
1122
1191
|
return target;
|
|
@@ -2129,103 +2198,19 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2129
2198
|
preferExistingAst: false
|
|
2130
2199
|
});
|
|
2131
2200
|
const fallbackExpr = transformedSource !== authorSource ? tryParseBabelExpressionFromSource(authorSource, ["typescript", "jsx"]) : null;
|
|
2132
|
-
const isNodeType2 = (node2, type) => {
|
|
2133
|
-
return node2 !== null && node2.type === type;
|
|
2134
|
-
};
|
|
2135
|
-
const isIdentifierNode2 = (node2) => {
|
|
2136
|
-
return isNodeType2(node2, "Identifier") && typeof node2.name === "string";
|
|
2137
|
-
};
|
|
2138
|
-
const isStringLiteralNode2 = (node2) => {
|
|
2139
|
-
return isNodeType2(node2, "StringLiteral") && typeof node2.value === "string";
|
|
2140
|
-
};
|
|
2141
|
-
const isBooleanLiteralNode = (node2) => {
|
|
2142
|
-
return isNodeType2(node2, "BooleanLiteral") && typeof node2.value === "boolean";
|
|
2143
|
-
};
|
|
2144
|
-
const isNumericLiteralNode = (node2) => {
|
|
2145
|
-
return isNodeType2(node2, "NumericLiteral") && typeof node2.value === "number";
|
|
2146
|
-
};
|
|
2147
|
-
const isNullLiteralNode = (node2) => {
|
|
2148
|
-
return isNodeType2(node2, "NullLiteral");
|
|
2149
|
-
};
|
|
2150
|
-
const isMemberExpressionNode = (node2) => {
|
|
2151
|
-
if (!isNodeType2(node2, "MemberExpression"))
|
|
2152
|
-
return false;
|
|
2153
|
-
const n = node2;
|
|
2154
|
-
return typeof n.computed === "boolean" && typeof n.object === "object" && n.object !== null && typeof n.property === "object" && n.property !== null;
|
|
2155
|
-
};
|
|
2156
|
-
const isCallExpressionNode = (node2) => {
|
|
2157
|
-
if (!isNodeType2(node2, "CallExpression"))
|
|
2158
|
-
return false;
|
|
2159
|
-
const n = node2;
|
|
2160
|
-
return typeof n.callee === "object" && n.callee !== null && Array.isArray(n.arguments);
|
|
2161
|
-
};
|
|
2162
|
-
const isAwaitExpressionNode = (node2) => {
|
|
2163
|
-
if (!isNodeType2(node2, "AwaitExpression"))
|
|
2164
|
-
return false;
|
|
2165
|
-
const n = node2;
|
|
2166
|
-
return typeof n.argument === "object" && n.argument !== null;
|
|
2167
|
-
};
|
|
2168
|
-
const isAssignmentExpressionNode = (node2) => {
|
|
2169
|
-
if (!isNodeType2(node2, "AssignmentExpression"))
|
|
2170
|
-
return false;
|
|
2171
|
-
const n = node2;
|
|
2172
|
-
return typeof n.left === "object" && n.left !== null && typeof n.right === "object" && n.right !== null;
|
|
2173
|
-
};
|
|
2174
|
-
const isArrowFunctionExpressionNode = (node2) => {
|
|
2175
|
-
if (!isNodeType2(node2, "ArrowFunctionExpression"))
|
|
2176
|
-
return false;
|
|
2177
|
-
const n = node2;
|
|
2178
|
-
return typeof n.body === "object" && n.body !== null;
|
|
2179
|
-
};
|
|
2180
|
-
const isBlockStatementNode = (node2) => {
|
|
2181
|
-
if (!isNodeType2(node2, "BlockStatement"))
|
|
2182
|
-
return false;
|
|
2183
|
-
const n = node2;
|
|
2184
|
-
return Array.isArray(n.body);
|
|
2185
|
-
};
|
|
2186
|
-
const isExpressionStatementNode = (node2) => {
|
|
2187
|
-
if (!isNodeType2(node2, "ExpressionStatement"))
|
|
2188
|
-
return false;
|
|
2189
|
-
const n = node2;
|
|
2190
|
-
return typeof n.expression === "object" && n.expression !== null;
|
|
2191
|
-
};
|
|
2192
|
-
const isReturnStatementNode = (node2) => {
|
|
2193
|
-
if (!isNodeType2(node2, "ReturnStatement"))
|
|
2194
|
-
return false;
|
|
2195
|
-
const n = node2;
|
|
2196
|
-
return typeof n.argument === "object" || n.argument === null;
|
|
2197
|
-
};
|
|
2198
|
-
const isObjectExpressionNode2 = (node2) => {
|
|
2199
|
-
if (!isNodeType2(node2, "ObjectExpression"))
|
|
2200
|
-
return false;
|
|
2201
|
-
const n = node2;
|
|
2202
|
-
return Array.isArray(n.properties);
|
|
2203
|
-
};
|
|
2204
|
-
const isObjectPropertyNode2 = (node2) => {
|
|
2205
|
-
if (!isNodeType2(node2, "ObjectProperty"))
|
|
2206
|
-
return false;
|
|
2207
|
-
const n = node2;
|
|
2208
|
-
return typeof n.computed === "boolean" && typeof n.key === "object" && n.key !== null && typeof n.value === "object" && n.value !== null;
|
|
2209
|
-
};
|
|
2210
|
-
const isLogicalExpressionNode = (node2) => {
|
|
2211
|
-
if (!isNodeType2(node2, "LogicalExpression"))
|
|
2212
|
-
return false;
|
|
2213
|
-
const n = node2;
|
|
2214
|
-
return typeof n.operator === "string" && typeof n.left === "object" && n.left !== null && typeof n.right === "object" && n.right !== null;
|
|
2215
|
-
};
|
|
2216
2201
|
const getLastIdentifierFromMemberChain = (node2) => {
|
|
2217
2202
|
if (!node2)
|
|
2218
2203
|
return null;
|
|
2219
|
-
if (
|
|
2204
|
+
if (isIdentifierNode(node2))
|
|
2220
2205
|
return node2.name;
|
|
2221
2206
|
if (isMemberExpressionNode(node2)) {
|
|
2222
2207
|
const prop = node2.property;
|
|
2223
2208
|
if (node2.computed === false) {
|
|
2224
|
-
if (
|
|
2209
|
+
if (isIdentifierNode(prop))
|
|
2225
2210
|
return prop.name;
|
|
2226
2211
|
}
|
|
2227
2212
|
if (node2.computed === true) {
|
|
2228
|
-
if (
|
|
2213
|
+
if (isStringLiteralNode(prop))
|
|
2229
2214
|
return prop.value;
|
|
2230
2215
|
}
|
|
2231
2216
|
}
|
|
@@ -2235,7 +2220,7 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2235
2220
|
if (!node2) {
|
|
2236
2221
|
return null;
|
|
2237
2222
|
}
|
|
2238
|
-
if (
|
|
2223
|
+
if (isIdentifierNode(node2)) {
|
|
2239
2224
|
return node2.name;
|
|
2240
2225
|
}
|
|
2241
2226
|
if (isMemberExpressionNode(node2)) {
|
|
@@ -2247,11 +2232,11 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2247
2232
|
if (!lhs) {
|
|
2248
2233
|
return null;
|
|
2249
2234
|
}
|
|
2250
|
-
if (
|
|
2235
|
+
if (isIdentifierNode(lhs)) {
|
|
2251
2236
|
return lhs.name;
|
|
2252
2237
|
}
|
|
2253
2238
|
if (isMemberExpressionNode(lhs)) {
|
|
2254
|
-
if (lhs.computed === false &&
|
|
2239
|
+
if (lhs.computed === false && isIdentifierNode(lhs.property) && lhs.property.name === "value") {
|
|
2255
2240
|
return getLastIdentifierFromMemberChain(lhs.object);
|
|
2256
2241
|
}
|
|
2257
2242
|
return getLastIdentifierFromMemberChain(lhs);
|
|
@@ -2259,7 +2244,7 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2259
2244
|
return null;
|
|
2260
2245
|
};
|
|
2261
2246
|
const isTemplateLiteralNode = (node2) => {
|
|
2262
|
-
if (!
|
|
2247
|
+
if (!isNodeType(node2, "TemplateLiteral")) {
|
|
2263
2248
|
return false;
|
|
2264
2249
|
}
|
|
2265
2250
|
const n = node2;
|
|
@@ -2278,7 +2263,7 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2278
2263
|
if (isNullLiteralNode(arg)) {
|
|
2279
2264
|
return "Null";
|
|
2280
2265
|
}
|
|
2281
|
-
if (
|
|
2266
|
+
if (isStringLiteralNode(arg)) {
|
|
2282
2267
|
const cleaned = (arg.value ?? "").trim();
|
|
2283
2268
|
if (!cleaned) {
|
|
2284
2269
|
return null;
|
|
@@ -2304,7 +2289,7 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2304
2289
|
return toPascalCase(stableName.slice(0, 24));
|
|
2305
2290
|
}
|
|
2306
2291
|
}
|
|
2307
|
-
if (
|
|
2292
|
+
if (isIdentifierNode(arg)) {
|
|
2308
2293
|
const firstChar = arg.name.charAt(0);
|
|
2309
2294
|
const isUpperAlpha = firstChar !== "" && firstChar === firstChar.toUpperCase() && firstChar !== firstChar.toLowerCase();
|
|
2310
2295
|
if (isUpperAlpha) {
|
|
@@ -2316,7 +2301,7 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2316
2301
|
const getStableSuffixFromCall = (call) => {
|
|
2317
2302
|
const args = call.arguments ?? [];
|
|
2318
2303
|
const first = args.length > 0 ? args[0] : null;
|
|
2319
|
-
if (!
|
|
2304
|
+
if (!isObjectExpressionNode(first)) {
|
|
2320
2305
|
const parts2 = [];
|
|
2321
2306
|
for (const arg of args.slice(0, 4)) {
|
|
2322
2307
|
const w = stableWordFromValue(arg ?? null);
|
|
@@ -2335,20 +2320,20 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2335
2320
|
}
|
|
2336
2321
|
const parts = [];
|
|
2337
2322
|
for (const prop of first.properties ?? []) {
|
|
2338
|
-
if (!
|
|
2323
|
+
if (!isObjectPropertyNode(prop)) {
|
|
2339
2324
|
continue;
|
|
2340
2325
|
}
|
|
2341
2326
|
if (prop.computed) {
|
|
2342
2327
|
continue;
|
|
2343
2328
|
}
|
|
2344
|
-
const keyName =
|
|
2329
|
+
const keyName = isIdentifierNode(prop.key) ? prop.key.name : isStringLiteralNode(prop.key) ? prop.key.value : null;
|
|
2345
2330
|
if (!keyName) {
|
|
2346
2331
|
continue;
|
|
2347
2332
|
}
|
|
2348
2333
|
let valueWord = null;
|
|
2349
2334
|
if (isBooleanLiteralNode(prop.value)) {
|
|
2350
2335
|
valueWord = prop.value.value ? "True" : "False";
|
|
2351
|
-
} else if (
|
|
2336
|
+
} else if (isStringLiteralNode(prop.value)) {
|
|
2352
2337
|
const cleaned = (prop.value.value ?? "").trim();
|
|
2353
2338
|
if (cleaned) {
|
|
2354
2339
|
valueWord = toPascalCase(cleaned.slice(0, 24));
|
|
@@ -2448,7 +2433,7 @@ function nodeHandlerAttributeInfo(node) {
|
|
|
2448
2433
|
return null;
|
|
2449
2434
|
};
|
|
2450
2435
|
const isVueRefValueAccess = (candidate) => {
|
|
2451
|
-
return isMemberExpressionNode(candidate) && candidate.computed === false &&
|
|
2436
|
+
return isMemberExpressionNode(candidate) && candidate.computed === false && isIdentifierNode(candidate.property) && candidate.property.name === "value";
|
|
2452
2437
|
};
|
|
2453
2438
|
const transformedSemanticName = resolveSemanticName(expr);
|
|
2454
2439
|
const fallbackSemanticName = resolveSemanticName(fallbackExpr);
|
|
@@ -2584,36 +2569,15 @@ function toDirectiveObjectFieldNameValue(node) {
|
|
|
2584
2569
|
if (!expr) {
|
|
2585
2570
|
return null;
|
|
2586
2571
|
}
|
|
2587
|
-
|
|
2588
|
-
return n !== null && n.type === type;
|
|
2589
|
-
};
|
|
2590
|
-
const isStringLiteralNode2 = (n) => {
|
|
2591
|
-
return isNodeType2(n, "StringLiteral") && typeof n.value === "string";
|
|
2592
|
-
};
|
|
2593
|
-
const isIdentifierNode2 = (n) => {
|
|
2594
|
-
return isNodeType2(n, "Identifier") && typeof n.name === "string";
|
|
2595
|
-
};
|
|
2596
|
-
const isObjectPropertyNode2 = (n) => {
|
|
2597
|
-
if (!isNodeType2(n, "ObjectProperty"))
|
|
2598
|
-
return false;
|
|
2599
|
-
const nn = n;
|
|
2600
|
-
return typeof nn.key === "object" && nn.key !== null && typeof nn.value === "object" && nn.value !== null;
|
|
2601
|
-
};
|
|
2602
|
-
const isObjectExpressionNode2 = (n) => {
|
|
2603
|
-
if (!isNodeType2(n, "ObjectExpression"))
|
|
2604
|
-
return false;
|
|
2605
|
-
const nn = n;
|
|
2606
|
-
return Array.isArray(nn.properties);
|
|
2607
|
-
};
|
|
2608
|
-
if (!isObjectExpressionNode2(expr))
|
|
2572
|
+
if (!isObjectExpressionNode(expr))
|
|
2609
2573
|
return null;
|
|
2610
2574
|
const nameProp = expr.properties.find((p) => {
|
|
2611
|
-
if (!
|
|
2575
|
+
if (!isObjectPropertyNodeShallow(p))
|
|
2612
2576
|
return false;
|
|
2613
2577
|
const key = p.key;
|
|
2614
|
-
return
|
|
2578
|
+
return isIdentifierNode(key) && key.name === "name" || isStringLiteralNode(key) && key.value === "name";
|
|
2615
2579
|
});
|
|
2616
|
-
if (!nameProp || !
|
|
2580
|
+
if (!nameProp || !isObjectPropertyNodeShallow(nameProp) || !isStringLiteralNode(nameProp.value))
|
|
2617
2581
|
return null;
|
|
2618
2582
|
return toPascalCase(nameProp.value.value);
|
|
2619
2583
|
}
|
|
@@ -9306,26 +9270,17 @@ function tryExtractStableHintFromConditionalExpressionSource(source) {
|
|
|
9306
9270
|
};
|
|
9307
9271
|
try {
|
|
9308
9272
|
const expr = parseExpression(src, { plugins: ["typescript"] });
|
|
9309
|
-
const isNodeType2 = (n, type) => {
|
|
9310
|
-
return n !== null && n.type === type;
|
|
9311
|
-
};
|
|
9312
|
-
const isStringLiteralNode2 = (n) => {
|
|
9313
|
-
return isNodeType2(n, "StringLiteral") && typeof n.value === "string";
|
|
9314
|
-
};
|
|
9315
|
-
const isIdentifierNode2 = (n) => {
|
|
9316
|
-
return isNodeType2(n, "Identifier") && typeof n.name === "string";
|
|
9317
|
-
};
|
|
9318
9273
|
const results = [];
|
|
9319
9274
|
const walk = (n) => {
|
|
9320
9275
|
if (!n)
|
|
9321
9276
|
return;
|
|
9322
|
-
if (
|
|
9277
|
+
if (isStringLiteralNode(n)) {
|
|
9323
9278
|
const v = (n.value ?? "").trim();
|
|
9324
9279
|
if (isIdentifierish(v)) {
|
|
9325
9280
|
results.push(v);
|
|
9326
9281
|
}
|
|
9327
9282
|
}
|
|
9328
|
-
if (
|
|
9283
|
+
if (isIdentifierNode(n)) {
|
|
9329
9284
|
const v = (n.name ?? "").trim();
|
|
9330
9285
|
if (isIdentifierish(v)) {
|
|
9331
9286
|
results.push(v);
|
|
@@ -11953,6 +11908,20 @@ const ANNOTATOR_STYLES = `
|
|
|
11953
11908
|
max-width: min(320px, calc(100vw - 24px));
|
|
11954
11909
|
}
|
|
11955
11910
|
|
|
11911
|
+
.vpg-annotator-panel--preview {
|
|
11912
|
+
min-width: min(720px, calc(100vw - 24px));
|
|
11913
|
+
max-width: min(940px, calc(100vw - 24px));
|
|
11914
|
+
}
|
|
11915
|
+
|
|
11916
|
+
.vpg-annotator-panel--preview .vpg-annotator-textarea {
|
|
11917
|
+
height: min(52vh, 440px);
|
|
11918
|
+
resize: vertical;
|
|
11919
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
11920
|
+
white-space: pre;
|
|
11921
|
+
overflow: auto;
|
|
11922
|
+
}
|
|
11923
|
+
|
|
11924
|
+
|
|
11956
11925
|
.vpg-annotator-arrow {
|
|
11957
11926
|
position: absolute;
|
|
11958
11927
|
z-index: 0;
|
|
@@ -12067,18 +12036,6 @@ const ANNOTATOR_STYLES = `
|
|
|
12067
12036
|
margin-top: 12px;
|
|
12068
12037
|
}
|
|
12069
12038
|
|
|
12070
|
-
.vpg-annotator-shortcuts {
|
|
12071
|
-
display: grid;
|
|
12072
|
-
gap: 8px;
|
|
12073
|
-
}
|
|
12074
|
-
|
|
12075
|
-
.vpg-annotator-shortcut-row {
|
|
12076
|
-
display: flex;
|
|
12077
|
-
align-items: center;
|
|
12078
|
-
justify-content: space-between;
|
|
12079
|
-
gap: 12px;
|
|
12080
|
-
}
|
|
12081
|
-
|
|
12082
12039
|
.vpg-annotator-label {
|
|
12083
12040
|
font-size: 12px;
|
|
12084
12041
|
font-weight: 600;
|
|
@@ -12094,20 +12051,6 @@ const ANNOTATOR_STYLES = `
|
|
|
12094
12051
|
padding: 8px 10px;
|
|
12095
12052
|
}
|
|
12096
12053
|
|
|
12097
|
-
.vpg-annotator-kbd {
|
|
12098
|
-
min-width: 32px;
|
|
12099
|
-
padding: 4px 8px;
|
|
12100
|
-
border: 1px solid var(--vpg-annotator-border);
|
|
12101
|
-
border-radius: var(--vpg-annotator-radius);
|
|
12102
|
-
background: rgba(15, 23, 42, 0.72);
|
|
12103
|
-
color: var(--vpg-annotator-text);
|
|
12104
|
-
font: inherit;
|
|
12105
|
-
font-size: 11px;
|
|
12106
|
-
font-weight: 700;
|
|
12107
|
-
line-height: 1;
|
|
12108
|
-
text-align: center;
|
|
12109
|
-
}
|
|
12110
|
-
|
|
12111
12054
|
.vpg-annotator-highlight {
|
|
12112
12055
|
position: fixed;
|
|
12113
12056
|
z-index: 2147483646;
|
|
@@ -12139,6 +12082,7 @@ const ANNOTATOR_STYLES = `
|
|
|
12139
12082
|
inset: 0;
|
|
12140
12083
|
z-index: 2147483645;
|
|
12141
12084
|
background: transparent;
|
|
12085
|
+
cursor: crosshair;
|
|
12142
12086
|
}
|
|
12143
12087
|
|
|
12144
12088
|
.vpg-annotator-marker {
|
|
@@ -12171,6 +12115,34 @@ const ANNOTATOR_STYLES = `
|
|
|
12171
12115
|
font-size: 12px;
|
|
12172
12116
|
font-weight: 600;
|
|
12173
12117
|
}
|
|
12118
|
+
|
|
12119
|
+
.vpg-annotator-heading-row {
|
|
12120
|
+
display: flex;
|
|
12121
|
+
align-items: center;
|
|
12122
|
+
justify-content: space-between;
|
|
12123
|
+
gap: 8px;
|
|
12124
|
+
}
|
|
12125
|
+
|
|
12126
|
+
.vpg-annotator-heading-row .vpg-annotator-heading {
|
|
12127
|
+
margin-bottom: 4px;
|
|
12128
|
+
}
|
|
12129
|
+
|
|
12130
|
+
.vpg-annotator-panel-close {
|
|
12131
|
+
margin-left: auto;
|
|
12132
|
+
background: transparent;
|
|
12133
|
+
border: none;
|
|
12134
|
+
color: var(--vpg-annotator-text-soft);
|
|
12135
|
+
font-size: 16px;
|
|
12136
|
+
line-height: 1;
|
|
12137
|
+
padding: 2px 6px;
|
|
12138
|
+
cursor: pointer;
|
|
12139
|
+
border-radius: var(--vpg-annotator-radius);
|
|
12140
|
+
}
|
|
12141
|
+
|
|
12142
|
+
.vpg-annotator-panel-close:hover {
|
|
12143
|
+
color: var(--vpg-annotator-text);
|
|
12144
|
+
background: var(--vpg-annotator-bg-soft);
|
|
12145
|
+
}
|
|
12174
12146
|
`;
|
|
12175
12147
|
const ignoredComponentNamePattern = /^(?:items\[\d+\]\.template|template|anonymous|slot|transition|transition-group)$/i;
|
|
12176
12148
|
function getDirectVueInstances(element) {
|
|
@@ -12329,35 +12301,15 @@ const TOOLBAR_POSITION_STORAGE_KEY = "vpg-annotator-toolbar-position";
|
|
|
12329
12301
|
const RUNTIME_GUARD = "__VUE_POM_GENERATOR_ANNOTATOR_RUNTIME__";
|
|
12330
12302
|
const TOOLBAR_ICON_MARKUP = {
|
|
12331
12303
|
drag: '<svg viewBox="0 0 16 16"><path d="M5 3h1v1H5zM10 3h1v1h-1zM5 7h1v1H5zM10 7h1v1h-1zM5 11h1v1H5zM10 11h1v1h-1z" fill="currentColor" stroke="none" /></svg>',
|
|
12332
|
-
inspect: '<svg viewBox="0 0 16 16"><path d="M8
|
|
12304
|
+
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>',
|
|
12333
12305
|
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>',
|
|
12334
12306
|
copy: '<svg viewBox="0 0 16 16"><path d="M6 2.5h6.5v9H6z"/><path d="M3.5 5.5H5v6.5h5.5v1.5h-7z"/></svg>',
|
|
12335
12307
|
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>',
|
|
12336
12308
|
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>'
|
|
12337
12309
|
};
|
|
12338
|
-
const SHORTCUT_LABELS = {
|
|
12339
|
-
select: "S",
|
|
12340
|
-
preview: "P",
|
|
12341
|
-
copy: "C",
|
|
12342
|
-
clear: "X",
|
|
12343
|
-
settings: ",",
|
|
12344
|
-
cancel: "Esc"
|
|
12345
|
-
};
|
|
12346
|
-
function formatShortcutTitle(label, shortcut) {
|
|
12347
|
-
return shortcut ? `${label} (${shortcut})` : label;
|
|
12348
|
-
}
|
|
12349
12310
|
function isInsideAnnotatorTree(node) {
|
|
12350
12311
|
return node instanceof Element && !!node.closest(`[${ANNOTATOR_ROOT_ATTR}]`);
|
|
12351
12312
|
}
|
|
12352
|
-
function isEditableTarget(node) {
|
|
12353
|
-
if (!(node instanceof Element)) {
|
|
12354
|
-
return false;
|
|
12355
|
-
}
|
|
12356
|
-
if (node instanceof HTMLInputElement || node instanceof HTMLTextAreaElement || node instanceof HTMLSelectElement) {
|
|
12357
|
-
return true;
|
|
12358
|
-
}
|
|
12359
|
-
return node.closest('[contenteditable=""], [contenteditable="true"]') !== null;
|
|
12360
|
-
}
|
|
12361
12313
|
function getElementSummary(element) {
|
|
12362
12314
|
const testId = element.getAttribute("data-testid");
|
|
12363
12315
|
if (testId) {
|
|
@@ -12422,10 +12374,7 @@ function createButtonBase(label, onClick, options = {}) {
|
|
|
12422
12374
|
button.className = `vpg-annotator-btn${options.primary ? " vpg-annotator-btn--primary" : ""}`;
|
|
12423
12375
|
button.setAttribute(ANNOTATOR_ROOT_ATTR, "");
|
|
12424
12376
|
button.setAttribute("aria-label", label);
|
|
12425
|
-
button.title =
|
|
12426
|
-
if (options.shortcut) {
|
|
12427
|
-
button.setAttribute("aria-keyshortcuts", options.shortcut);
|
|
12428
|
-
}
|
|
12377
|
+
button.title = label;
|
|
12429
12378
|
if (options.pressed) {
|
|
12430
12379
|
button.setAttribute("aria-pressed", "true");
|
|
12431
12380
|
}
|
|
@@ -12565,23 +12514,18 @@ class AnnotatorRuntime {
|
|
|
12565
12514
|
count.textContent = `${this.annotations.length} annotation${this.annotations.length === 1 ? "" : "s"}`;
|
|
12566
12515
|
const selectButton = createIconButton(this.inspectMode ? "Stop selecting" : "Select element", "inspect", () => {
|
|
12567
12516
|
this.setInspectMode(!this.inspectMode);
|
|
12568
|
-
}, { primary: this.inspectMode, pressed: this.inspectMode
|
|
12517
|
+
}, { primary: this.inspectMode, pressed: this.inspectMode });
|
|
12569
12518
|
const previewButton = createIconButton("Preview annotations", "preview", () => this.openPreview(), {
|
|
12570
|
-
disabled: this.annotations.length === 0
|
|
12571
|
-
shortcut: SHORTCUT_LABELS.preview
|
|
12519
|
+
disabled: this.annotations.length === 0
|
|
12572
12520
|
});
|
|
12573
12521
|
this.previewButton = previewButton;
|
|
12574
12522
|
const copyButton = createIconButton("Copy annotations", "copy", () => this.copyAnnotations(), {
|
|
12575
|
-
disabled: this.annotations.length === 0
|
|
12576
|
-
shortcut: SHORTCUT_LABELS.copy
|
|
12523
|
+
disabled: this.annotations.length === 0
|
|
12577
12524
|
});
|
|
12578
12525
|
const clearButton = createIconButton("Clear annotations", "clear", () => this.clearAnnotations(), {
|
|
12579
|
-
disabled: this.annotations.length === 0
|
|
12580
|
-
shortcut: SHORTCUT_LABELS.clear
|
|
12581
|
-
});
|
|
12582
|
-
const settingsButton = createIconButton("Annotator settings", "settings", () => this.openSettings(), {
|
|
12583
|
-
shortcut: SHORTCUT_LABELS.settings
|
|
12526
|
+
disabled: this.annotations.length === 0
|
|
12584
12527
|
});
|
|
12528
|
+
const settingsButton = createIconButton("Annotator settings", "settings", () => this.openSettings());
|
|
12585
12529
|
this.settingsButton = settingsButton;
|
|
12586
12530
|
this.toolbarEl.append(handle, selectButton, previewButton, copyButton, clearButton, settingsButton, count);
|
|
12587
12531
|
this.applyToolbarPosition();
|
|
@@ -12612,7 +12556,6 @@ class AnnotatorRuntime {
|
|
|
12612
12556
|
this.renderMarkers();
|
|
12613
12557
|
this.applyToolbarPosition();
|
|
12614
12558
|
});
|
|
12615
|
-
window.addEventListener("keydown", (event) => this.onWindowKeyDown(event), true);
|
|
12616
12559
|
}
|
|
12617
12560
|
loadSettings() {
|
|
12618
12561
|
try {
|
|
@@ -12739,60 +12682,6 @@ class AnnotatorRuntime {
|
|
|
12739
12682
|
window.addEventListener("pointercancel", onPointerUp);
|
|
12740
12683
|
});
|
|
12741
12684
|
}
|
|
12742
|
-
onWindowKeyDown(event) {
|
|
12743
|
-
if (event.defaultPrevented || event.metaKey || event.ctrlKey || event.altKey) {
|
|
12744
|
-
return;
|
|
12745
|
-
}
|
|
12746
|
-
if (event.key === "Escape") {
|
|
12747
|
-
if (!this.inspectMode && !this.currentPanelEl) {
|
|
12748
|
-
return;
|
|
12749
|
-
}
|
|
12750
|
-
event.preventDefault();
|
|
12751
|
-
if (this.inspectMode) {
|
|
12752
|
-
this.setInspectMode(false);
|
|
12753
|
-
} else {
|
|
12754
|
-
this.closePanel();
|
|
12755
|
-
}
|
|
12756
|
-
return;
|
|
12757
|
-
}
|
|
12758
|
-
if (isEditableTarget(event.target)) {
|
|
12759
|
-
return;
|
|
12760
|
-
}
|
|
12761
|
-
const key = event.key.toLowerCase();
|
|
12762
|
-
if (key === SHORTCUT_LABELS.select.toLowerCase()) {
|
|
12763
|
-
event.preventDefault();
|
|
12764
|
-
this.setInspectMode(!this.inspectMode);
|
|
12765
|
-
return;
|
|
12766
|
-
}
|
|
12767
|
-
if (key === SHORTCUT_LABELS.preview.toLowerCase()) {
|
|
12768
|
-
if (!this.annotations.length) {
|
|
12769
|
-
return;
|
|
12770
|
-
}
|
|
12771
|
-
event.preventDefault();
|
|
12772
|
-
this.openPreview();
|
|
12773
|
-
return;
|
|
12774
|
-
}
|
|
12775
|
-
if (key === SHORTCUT_LABELS.copy.toLowerCase()) {
|
|
12776
|
-
if (!this.annotations.length) {
|
|
12777
|
-
return;
|
|
12778
|
-
}
|
|
12779
|
-
event.preventDefault();
|
|
12780
|
-
void this.copyAnnotations();
|
|
12781
|
-
return;
|
|
12782
|
-
}
|
|
12783
|
-
if (key === SHORTCUT_LABELS.clear.toLowerCase()) {
|
|
12784
|
-
if (!this.annotations.length) {
|
|
12785
|
-
return;
|
|
12786
|
-
}
|
|
12787
|
-
event.preventDefault();
|
|
12788
|
-
this.clearAnnotations();
|
|
12789
|
-
return;
|
|
12790
|
-
}
|
|
12791
|
-
if (event.key === SHORTCUT_LABELS.settings) {
|
|
12792
|
-
event.preventDefault();
|
|
12793
|
-
this.openSettings();
|
|
12794
|
-
}
|
|
12795
|
-
}
|
|
12796
12685
|
setInspectMode(next) {
|
|
12797
12686
|
this.inspectMode = next;
|
|
12798
12687
|
this.shieldEl.hidden = !next;
|
|
@@ -12977,11 +12866,21 @@ class AnnotatorRuntime {
|
|
|
12977
12866
|
this.editingAnnotationId = annotation.id;
|
|
12978
12867
|
this.openInputForDraft(reference);
|
|
12979
12868
|
}
|
|
12869
|
+
createPanelCloseButton(ariaLabel) {
|
|
12870
|
+
const closeButton = document.createElement("button");
|
|
12871
|
+
closeButton.type = "button";
|
|
12872
|
+
closeButton.className = "vpg-annotator-panel-close";
|
|
12873
|
+
closeButton.setAttribute(ANNOTATOR_ROOT_ATTR, "");
|
|
12874
|
+
closeButton.setAttribute("aria-label", ariaLabel);
|
|
12875
|
+
closeButton.textContent = "×";
|
|
12876
|
+
closeButton.addEventListener("click", () => this.closePanel());
|
|
12877
|
+
return closeButton;
|
|
12878
|
+
}
|
|
12980
12879
|
openPreview() {
|
|
12981
12880
|
if (!this.previewButton || this.annotations.length === 0) {
|
|
12982
12881
|
return;
|
|
12983
12882
|
}
|
|
12984
|
-
const { panel, body, arrowEl } = this.createPanelBase("vpg-annotator-panel");
|
|
12883
|
+
const { panel, body, arrowEl } = this.createPanelBase("vpg-annotator-panel vpg-annotator-panel--preview");
|
|
12985
12884
|
const title = document.createElement("div");
|
|
12986
12885
|
title.className = "vpg-annotator-heading";
|
|
12987
12886
|
title.textContent = "Annotation preview";
|
|
@@ -12992,7 +12891,10 @@ class AnnotatorRuntime {
|
|
|
12992
12891
|
textarea.className = "vpg-annotator-textarea";
|
|
12993
12892
|
textarea.readOnly = true;
|
|
12994
12893
|
textarea.value = formatAnnotations(this.annotations, this.settings.outputDetail, window.location.href);
|
|
12995
|
-
|
|
12894
|
+
const headerRow = document.createElement("div");
|
|
12895
|
+
headerRow.className = "vpg-annotator-heading-row";
|
|
12896
|
+
headerRow.append(title, this.createPanelCloseButton("Close preview"));
|
|
12897
|
+
body.append(headerRow, subtitle, textarea);
|
|
12996
12898
|
this.showPanel(panel, () => this.attachFloating(this.previewButton, panel, arrowEl, "top-start", ["top-start", "left-start", "top-end", "left-end"]));
|
|
12997
12899
|
}
|
|
12998
12900
|
openSettings() {
|
|
@@ -13031,35 +12933,7 @@ class AnnotatorRuntime {
|
|
|
13031
12933
|
this.saveSettings();
|
|
13032
12934
|
});
|
|
13033
12935
|
showComponentField.append(showComponentCopy, showComponentCheckbox);
|
|
13034
|
-
|
|
13035
|
-
shortcutsField.className = "vpg-annotator-field";
|
|
13036
|
-
const shortcutsLabel = document.createElement("div");
|
|
13037
|
-
shortcutsLabel.className = "vpg-annotator-label";
|
|
13038
|
-
shortcutsLabel.textContent = "Keyboard shortcuts";
|
|
13039
|
-
const shortcutsList = document.createElement("div");
|
|
13040
|
-
shortcutsList.className = "vpg-annotator-shortcuts";
|
|
13041
|
-
for (const [shortcut, description] of [
|
|
13042
|
-
[SHORTCUT_LABELS.select, "Toggle selection mode"],
|
|
13043
|
-
[SHORTCUT_LABELS.preview, "Open preview"],
|
|
13044
|
-
[SHORTCUT_LABELS.copy, "Copy annotations"],
|
|
13045
|
-
[SHORTCUT_LABELS.clear, "Clear annotations"],
|
|
13046
|
-
[SHORTCUT_LABELS.settings, "Open settings"],
|
|
13047
|
-
[SHORTCUT_LABELS.cancel, "Close panel / cancel selection"]
|
|
13048
|
-
]) {
|
|
13049
|
-
const row = document.createElement("div");
|
|
13050
|
-
row.className = "vpg-annotator-shortcut-row";
|
|
13051
|
-
const text = document.createElement("span");
|
|
13052
|
-
text.className = "vpg-annotator-subtle";
|
|
13053
|
-
text.textContent = description;
|
|
13054
|
-
const kbd = document.createElement("kbd");
|
|
13055
|
-
kbd.className = "vpg-annotator-kbd";
|
|
13056
|
-
kbd.setAttribute(ANNOTATOR_ROOT_ATTR, "");
|
|
13057
|
-
kbd.textContent = shortcut;
|
|
13058
|
-
row.append(text, kbd);
|
|
13059
|
-
shortcutsList.appendChild(row);
|
|
13060
|
-
}
|
|
13061
|
-
shortcutsField.append(shortcutsLabel, shortcutsList);
|
|
13062
|
-
body.append(title, detailField, showComponentField, shortcutsField);
|
|
12936
|
+
body.append(title, detailField, showComponentField);
|
|
13063
12937
|
this.showPanel(panel, () => this.attachFloating(this.settingsButton, panel, arrowEl, "top-start", ["top-start", "left-start", "top-end", "left-end"]));
|
|
13064
12938
|
}
|
|
13065
12939
|
disposeCurrentPanel() {
|