@immense/vue-pom-generator 1.0.76 → 1.0.78
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 +49 -39
- package/dist/index.cjs +94 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +95 -11
- package/dist/index.mjs.map +1 -1
- package/dist/plugin/create-vue-pom-generator-plugins.d.ts.map +1 -1
- package/dist/plugin/internal/build-plugin.d.ts +1 -0
- package/dist/plugin/internal/build-plugin.d.ts.map +1 -1
- package/dist/plugin/internal/dev-plugin.d.ts.map +1 -1
- package/dist/plugin/internal-plugins.d.ts +1 -0
- package/dist/plugin/internal-plugins.d.ts.map +1 -1
- package/dist/plugin/vue-plugin.d.ts +2 -0
- package/dist/plugin/vue-plugin.d.ts.map +1 -1
- package/dist/transform.d.ts +11 -0
- package/dist/transform.d.ts.map +1 -1
- package/dist/utils.d.ts +16 -0
- package/dist/utils.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { parse as parse$1, compileScript } from "@vue/compiler-sfc";
|
|
|
9
9
|
import { parseExpression, parse } from "@babel/parser";
|
|
10
10
|
import { NodeTypes, stringifyExpression, ConstantTypes, createSimpleExpression, ElementTypes } from "@vue/compiler-core";
|
|
11
11
|
import { Project, QuoteKind, NewLineKind, IndentationText, CodeBlockWriter, StructureKind, VariableDeclarationKind } from "ts-morph";
|
|
12
|
-
import { isArrayExpression, isStringLiteral, isTemplateLiteral, isMemberExpression, isOptionalMemberExpression, isCallExpression, isOptionalCallExpression, isAssignmentExpression,
|
|
12
|
+
import { isIdentifier, isObjectPattern, isRestElement, isObjectProperty, isArrayExpression, isStringLiteral, isTemplateLiteral, isArrowFunctionExpression, isExpressionStatement, isAssignmentPattern, isMemberExpression, isOptionalMemberExpression, isCallExpression, isOptionalCallExpression, isAssignmentExpression, isObjectExpression, isFile, isBlockStatement, isLogicalExpression, isConditionalExpression, isSequenceExpression, isProgram, VISITOR_KEYS, isBooleanLiteral, isNumericLiteral, isNullLiteral } from "@babel/types";
|
|
13
13
|
import { performance } from "node:perf_hooks";
|
|
14
14
|
import vue from "@vitejs/plugin-vue";
|
|
15
15
|
import { autoUpdate, computePosition, offset, autoPlacement, shift, arrow } from "@floating-ui/dom";
|
|
@@ -1478,6 +1478,31 @@ function tryGetTemplateSlotScopeKeyInfo(expression) {
|
|
|
1478
1478
|
const candidateExpression = bindingNode ? tryGetSlotScopeKeyCandidate(bindingNode)?.expression ?? null : null;
|
|
1479
1479
|
return candidateExpression ? toResolvedKeyInfo(candidateExpression) : null;
|
|
1480
1480
|
}
|
|
1481
|
+
function tryExtractSlotScopeVariableNames(expression) {
|
|
1482
|
+
const bindingNode = tryGetTemplateSlotScopeBindingNode(expression);
|
|
1483
|
+
if (!bindingNode) {
|
|
1484
|
+
return [];
|
|
1485
|
+
}
|
|
1486
|
+
if (isIdentifier(bindingNode)) {
|
|
1487
|
+
return [bindingNode.name];
|
|
1488
|
+
}
|
|
1489
|
+
if (!isObjectPattern(bindingNode)) {
|
|
1490
|
+
return [];
|
|
1491
|
+
}
|
|
1492
|
+
const names = [];
|
|
1493
|
+
for (const property of bindingNode.properties) {
|
|
1494
|
+
if (isRestElement(property)) {
|
|
1495
|
+
const argName = tryGetBindingIdentifierName(property.argument);
|
|
1496
|
+
if (argName) names.push(argName);
|
|
1497
|
+
} else if (isObjectProperty(property)) {
|
|
1498
|
+
const bindingName = tryGetBindingIdentifierName(property.value) ?? tryGetBindingIdentifierName(property.key);
|
|
1499
|
+
if (bindingName) {
|
|
1500
|
+
names.push(bindingName);
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
return names;
|
|
1505
|
+
}
|
|
1481
1506
|
function nodeHasToDirective(node) {
|
|
1482
1507
|
const toDirective = findDirectiveByName(node, "bind", "to");
|
|
1483
1508
|
if (toDirective?.exp) {
|
|
@@ -1660,12 +1685,21 @@ function getStaticIdOrNameHint(node) {
|
|
|
1660
1685
|
return identifier;
|
|
1661
1686
|
}
|
|
1662
1687
|
function getContainedInSlotDataKeyInfo(node, hierarchyMap2) {
|
|
1688
|
+
const templateNode = getContainedInSlotTemplateNode(node, hierarchyMap2);
|
|
1689
|
+
if (templateNode) {
|
|
1690
|
+
const slotScopeExpression = findTemplateSlotScopeExpression(templateNode);
|
|
1691
|
+
if (slotScopeExpression) {
|
|
1692
|
+
return tryGetTemplateSlotScopeKeyInfo(slotScopeExpression);
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
return null;
|
|
1696
|
+
}
|
|
1697
|
+
function getContainedInSlotTemplateNode(node, hierarchyMap2) {
|
|
1663
1698
|
let parent = getParent(hierarchyMap2, node);
|
|
1664
1699
|
while (parent) {
|
|
1665
1700
|
if (parent.type === NodeTypes.ELEMENT && parent.tag === "template") {
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
return tryGetTemplateSlotScopeKeyInfo(slotScopeExpression);
|
|
1701
|
+
if (findTemplateSlotScopeExpression(parent)) {
|
|
1702
|
+
return parent;
|
|
1669
1703
|
}
|
|
1670
1704
|
}
|
|
1671
1705
|
parent = getParent(hierarchyMap2, parent);
|
|
@@ -7218,6 +7252,7 @@ function createTestIdTransform(componentName, componentHierarchyMap, nativeWrapp
|
|
|
7218
7252
|
const vueFilesPathMap = options.vueFilesPathMap;
|
|
7219
7253
|
const wrapperSearchRoots = options.wrapperSearchRoots ?? [];
|
|
7220
7254
|
const annotatorMetadata = options.annotatorMetadata ?? null;
|
|
7255
|
+
const crossFileKeyRegistry = options.crossFileKeyRegistry;
|
|
7221
7256
|
const safeRealpath2 = (p) => {
|
|
7222
7257
|
try {
|
|
7223
7258
|
return fs.existsSync(p) ? fs.realpathSync(p) : p;
|
|
@@ -7316,7 +7351,8 @@ function createTestIdTransform(componentName, componentHierarchyMap, nativeWrapp
|
|
|
7316
7351
|
(p) => p.type === NodeTypes.DIRECTIVE && p.name === "bind" && p.arg?.type === NodeTypes.SIMPLE_EXPRESSION && p.arg.content === testIdAttribute && !!p.exp
|
|
7317
7352
|
);
|
|
7318
7353
|
}
|
|
7319
|
-
const
|
|
7354
|
+
const grandParent = context.grandParent;
|
|
7355
|
+
const parentElement = !parentIsRoot && context?.parent?.type === NodeTypes.ELEMENT ? context.parent : !parentIsRoot && grandParent?.type === NodeTypes.ELEMENT ? grandParent : null;
|
|
7320
7356
|
hierarchyMap.set(element, parentElement);
|
|
7321
7357
|
const normalizeFilePath = (filePath) => path.normalize(safeRealpath2(path.resolve(filePath)));
|
|
7322
7358
|
const normalizedFilePath = normalizeFilePath(context.filename);
|
|
@@ -7346,6 +7382,31 @@ function createTestIdTransform(componentName, componentHierarchyMap, nativeWrapp
|
|
|
7346
7382
|
};
|
|
7347
7383
|
if (isComponentLikeTag(element.tag)) {
|
|
7348
7384
|
dependencies.usedComponentSet.add(element.tag);
|
|
7385
|
+
if (crossFileKeyRegistry && context.scopes.vSlot > 0) {
|
|
7386
|
+
const findSlotTemplate = () => {
|
|
7387
|
+
const gp = context.grandParent;
|
|
7388
|
+
if (gp?.type === NodeTypes.ELEMENT && gp.tag === "template") {
|
|
7389
|
+
return gp;
|
|
7390
|
+
}
|
|
7391
|
+
return getContainedInSlotTemplateNode(element, hierarchyMap);
|
|
7392
|
+
};
|
|
7393
|
+
const slotTemplate = findSlotTemplate();
|
|
7394
|
+
if (slotTemplate) {
|
|
7395
|
+
const slotScopeExpression = findTemplateSlotScopeExpression(slotTemplate);
|
|
7396
|
+
if (slotScopeExpression) {
|
|
7397
|
+
const slotVarNames = tryExtractSlotScopeVariableNames(slotScopeExpression);
|
|
7398
|
+
if (slotVarNames.length > 0) {
|
|
7399
|
+
for (const prop of element.props) {
|
|
7400
|
+
if (prop.type === NodeTypes.DIRECTIVE && prop.name === "bind" && prop.arg?.type === NodeTypes.SIMPLE_EXPRESSION && prop.exp?.type === NodeTypes.SIMPLE_EXPRESSION && slotVarNames.includes(prop.exp.content)) {
|
|
7401
|
+
const propName = prop.arg.content;
|
|
7402
|
+
crossFileKeyRegistry.set(element.tag, propName);
|
|
7403
|
+
break;
|
|
7404
|
+
}
|
|
7405
|
+
}
|
|
7406
|
+
}
|
|
7407
|
+
}
|
|
7408
|
+
}
|
|
7409
|
+
}
|
|
7349
7410
|
}
|
|
7350
7411
|
if (!nativeWrappers[element.tag]) {
|
|
7351
7412
|
const inferred = tryInferNativeWrapperRoleFromSfc(element.tag, vueFilesPathMap, wrapperSearchRoots);
|
|
@@ -7364,7 +7425,18 @@ function createTestIdTransform(componentName, componentHierarchyMap, nativeWrapp
|
|
|
7364
7425
|
if (vForKeyInfo) {
|
|
7365
7426
|
return vForKeyInfo;
|
|
7366
7427
|
}
|
|
7367
|
-
|
|
7428
|
+
const slotKeyInfo = getContainedInSlotDataKeyInfo(element, hierarchyMap);
|
|
7429
|
+
if (slotKeyInfo) {
|
|
7430
|
+
return slotKeyInfo;
|
|
7431
|
+
}
|
|
7432
|
+
if (crossFileKeyRegistry) {
|
|
7433
|
+
const propName = crossFileKeyRegistry.get(componentName);
|
|
7434
|
+
if (propName) {
|
|
7435
|
+
const fallbackExpr = buildSlotScopeFallbackKeyExpression(propName);
|
|
7436
|
+
return toResolvedKeyInfo(fallbackExpr, fallbackExpr);
|
|
7437
|
+
}
|
|
7438
|
+
}
|
|
7439
|
+
return null;
|
|
7368
7440
|
};
|
|
7369
7441
|
const bestKeyInfo = getBestAvailableKeyInfo();
|
|
7370
7442
|
const bestKeyPlaceholder = bestKeyInfo?.selectorFragment ?? null;
|
|
@@ -7712,6 +7784,7 @@ function isLessRich(candidate, previous) {
|
|
|
7712
7784
|
function createBuildProcessorPlugin(options) {
|
|
7713
7785
|
const {
|
|
7714
7786
|
componentHierarchyMap,
|
|
7787
|
+
crossFileKeyRegistry,
|
|
7715
7788
|
vueFilesPathMap,
|
|
7716
7789
|
getPageDirs,
|
|
7717
7790
|
getComponentDirs,
|
|
@@ -7854,7 +7927,8 @@ function createBuildProcessorPlugin(options) {
|
|
|
7854
7927
|
missingSemanticNameBehavior,
|
|
7855
7928
|
warn: (message) => loggerRef.current.warn(message),
|
|
7856
7929
|
vueFilesPathMap,
|
|
7857
|
-
wrapperSearchRoots: getWrapperSearchRoots()
|
|
7930
|
+
wrapperSearchRoots: getWrapperSearchRoots(),
|
|
7931
|
+
crossFileKeyRegistry
|
|
7858
7932
|
}
|
|
7859
7933
|
)
|
|
7860
7934
|
]
|
|
@@ -8177,6 +8251,7 @@ function createDevProcessorPlugin(options) {
|
|
|
8177
8251
|
}
|
|
8178
8252
|
const { bindings: bindingMetadata, isScriptSetup } = getScriptInfo(sfc, absolutePath);
|
|
8179
8253
|
const provisionalHierarchy = /* @__PURE__ */ new Map();
|
|
8254
|
+
const provisionalKeyRegistry = /* @__PURE__ */ new Map();
|
|
8180
8255
|
const provisionalVuePathMap = new Map(targetVuePathMap);
|
|
8181
8256
|
provisionalVuePathMap.set(componentName, absolutePath);
|
|
8182
8257
|
compilerDom.compile(template, {
|
|
@@ -8204,7 +8279,8 @@ function createDevProcessorPlugin(options) {
|
|
|
8204
8279
|
testIdAttribute,
|
|
8205
8280
|
warn: (message) => loggerRef.current.warn(message),
|
|
8206
8281
|
vueFilesPathMap: provisionalVuePathMap,
|
|
8207
|
-
wrapperSearchRoots: getWrapperSearchRoots()
|
|
8282
|
+
wrapperSearchRoots: getWrapperSearchRoots(),
|
|
8283
|
+
crossFileKeyRegistry: provisionalKeyRegistry
|
|
8208
8284
|
}
|
|
8209
8285
|
)
|
|
8210
8286
|
]
|
|
@@ -8728,6 +8804,7 @@ ${code}`,
|
|
|
8728
8804
|
function createInternalPlugins(options) {
|
|
8729
8805
|
const {
|
|
8730
8806
|
componentHierarchyMap,
|
|
8807
|
+
crossFileKeyRegistry,
|
|
8731
8808
|
elementMetadata,
|
|
8732
8809
|
vueFilesPathMap,
|
|
8733
8810
|
nativeWrappers,
|
|
@@ -8783,6 +8860,7 @@ function createInternalPlugins(options) {
|
|
|
8783
8860
|
const normalizedBasePagePath = path.posix.normalize(basePageClassPath);
|
|
8784
8861
|
const tsProcessor = createBuildProcessorPlugin({
|
|
8785
8862
|
componentHierarchyMap,
|
|
8863
|
+
crossFileKeyRegistry,
|
|
8786
8864
|
vueFilesPathMap,
|
|
8787
8865
|
getPageDirs,
|
|
8788
8866
|
getComponentDirs,
|
|
@@ -9008,6 +9086,7 @@ function createVuePluginWithTestIds(options) {
|
|
|
9008
9086
|
elementMetadata,
|
|
9009
9087
|
semanticNameMap,
|
|
9010
9088
|
componentHierarchyMap,
|
|
9089
|
+
crossFileKeyRegistry,
|
|
9011
9090
|
vueFilesPathMap,
|
|
9012
9091
|
excludedComponents,
|
|
9013
9092
|
getViewsDirAbs,
|
|
@@ -9077,7 +9156,8 @@ function createVuePluginWithTestIds(options) {
|
|
|
9077
9156
|
warn: (message) => loggerRef.current.warn(message),
|
|
9078
9157
|
vueFilesPathMap,
|
|
9079
9158
|
wrapperSearchRoots: getWrapperSearchRoots(),
|
|
9080
|
-
annotatorMetadata
|
|
9159
|
+
annotatorMetadata,
|
|
9160
|
+
crossFileKeyRegistry
|
|
9081
9161
|
}
|
|
9082
9162
|
)
|
|
9083
9163
|
);
|
|
@@ -9133,7 +9213,8 @@ function createVuePluginWithTestIds(options) {
|
|
|
9133
9213
|
warn: (message) => loggerRef.current.warn(message),
|
|
9134
9214
|
vueFilesPathMap,
|
|
9135
9215
|
wrapperSearchRoots: getWrapperSearchRoots(),
|
|
9136
|
-
annotatorMetadata
|
|
9216
|
+
annotatorMetadata,
|
|
9217
|
+
crossFileKeyRegistry
|
|
9137
9218
|
}
|
|
9138
9219
|
);
|
|
9139
9220
|
perFileTransform.set(componentName, transform);
|
|
@@ -9377,6 +9458,7 @@ function getSharedGeneratorState(key) {
|
|
|
9377
9458
|
elementMetadata: /* @__PURE__ */ new Map(),
|
|
9378
9459
|
semanticNameMap: /* @__PURE__ */ new Map(),
|
|
9379
9460
|
componentHierarchyMap: /* @__PURE__ */ new Map(),
|
|
9461
|
+
crossFileKeyRegistry: /* @__PURE__ */ new Map(),
|
|
9380
9462
|
vueFilesPathMap: /* @__PURE__ */ new Map()
|
|
9381
9463
|
};
|
|
9382
9464
|
sharedGeneratorStateRegistry.set(key, state);
|
|
@@ -9591,7 +9673,7 @@ function createVuePomGeneratorPlugins(options = {}) {
|
|
|
9591
9673
|
};
|
|
9592
9674
|
const getViewsDirAbs = () => resolveFromProjectRoot(projectRootRef.current, getViewsDir());
|
|
9593
9675
|
const getWrapperSearchRootsAbs = () => getWrapperSearchRoots().map((root) => resolveFromProjectRoot(projectRootRef.current, root));
|
|
9594
|
-
const { elementMetadata, semanticNameMap, componentHierarchyMap, vueFilesPathMap } = sharedState;
|
|
9676
|
+
const { elementMetadata, semanticNameMap, componentHierarchyMap, crossFileKeyRegistry, vueFilesPathMap } = sharedState;
|
|
9595
9677
|
const { metadataCollectorPlugin, internalVuePlugin, templateCompilerOptions } = createVuePluginWithTestIds({
|
|
9596
9678
|
vueOptions,
|
|
9597
9679
|
existingIdBehavior: resolvedGenerationOptions.existingIdBehavior,
|
|
@@ -9601,6 +9683,7 @@ function createVuePomGeneratorPlugins(options = {}) {
|
|
|
9601
9683
|
elementMetadata,
|
|
9602
9684
|
semanticNameMap,
|
|
9603
9685
|
componentHierarchyMap,
|
|
9686
|
+
crossFileKeyRegistry,
|
|
9604
9687
|
vueFilesPathMap,
|
|
9605
9688
|
excludedComponents,
|
|
9606
9689
|
getViewsDirAbs,
|
|
@@ -9618,6 +9701,7 @@ function createVuePomGeneratorPlugins(options = {}) {
|
|
|
9618
9701
|
templateCompilerOptionsForResolvedPlugin = templateCompilerOptions;
|
|
9619
9702
|
const internalPlugins = createInternalPlugins({
|
|
9620
9703
|
componentHierarchyMap,
|
|
9704
|
+
crossFileKeyRegistry,
|
|
9621
9705
|
elementMetadata,
|
|
9622
9706
|
vueFilesPathMap,
|
|
9623
9707
|
nativeWrappers,
|