@immense/vue-pom-generator 1.0.114 → 1.0.116
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 +17 -30
- package/dist/index.cjs +22 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +23 -23
- package/dist/index.mjs.map +1 -1
- package/dist/plugin/path-utils.d.ts +1 -0
- package/dist/plugin/path-utils.d.ts.map +1 -1
- package/dist/plugin/vue-plugin.d.ts.map +1 -1
- package/dist/transform.d.ts.map +1 -1
- package/dist/wrapper-contract.d.ts +12 -6
- package/dist/wrapper-contract.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { parse as parse$2, NodeTypes as NodeTypes$1 } from "@vue/compiler-dom";
|
|
|
10
10
|
import { parse as parse$1, compileScript } from "@vue/compiler-sfc";
|
|
11
11
|
import { Project, QuoteKind, NewLineKind, IndentationText, CodeBlockWriter, StructureKind, VariableDeclarationKind } from "ts-morph";
|
|
12
12
|
import { camelize } from "@vue/shared";
|
|
13
|
-
import { isIdentifier, isObjectPattern, isRestElement, isObjectProperty, isArrayExpression, isStringLiteral, isTemplateLiteral, isArrowFunctionExpression, isExpressionStatement, isAssignmentPattern, isMemberExpression, isOptionalMemberExpression, isCallExpression, isOptionalCallExpression, isAssignmentExpression, isObjectExpression, isFile, isBlockStatement, isLogicalExpression, isConditionalExpression, isSequenceExpression, isProgram, isArrayPattern, VISITOR_KEYS, isBooleanLiteral, isNumericLiteral, isNullLiteral,
|
|
13
|
+
import { isIdentifier, isObjectPattern, isRestElement, isObjectProperty, isArrayExpression, isStringLiteral, isTemplateLiteral, isArrowFunctionExpression, isExpressionStatement, isAssignmentPattern, isMemberExpression, isOptionalMemberExpression, isCallExpression, isOptionalCallExpression, isAssignmentExpression, isObjectExpression, isFile, isBlockStatement, isLogicalExpression, isConditionalExpression, isSequenceExpression, isProgram, isArrayPattern, VISITOR_KEYS, isBooleanLiteral, isNumericLiteral, isNullLiteral, isExpression, isTSAsExpression, isTSTypeAssertion, isTSNonNullExpression, isImportDeclaration, isImportSpecifier, isExportDefaultDeclaration, isVariableDeclaration, isFunctionDeclaration, isFunctionExpression, isReturnStatement, isForInStatement, isIfStatement } from "@babel/types";
|
|
14
14
|
import { createHash, randomUUID } from "node:crypto";
|
|
15
15
|
import { POM_ROUTER_GLOBAL_NAME } from "./router.mjs";
|
|
16
16
|
import { performance } from "node:perf_hooks";
|
|
@@ -4127,6 +4127,14 @@ function writeGeneratedOutputs(outDir, files, sharedFiles, projectRoot = path.di
|
|
|
4127
4127
|
writeFile(manifestPath, `${JSON.stringify(next, null, 2)}
|
|
4128
4128
|
`);
|
|
4129
4129
|
}
|
|
4130
|
+
function toPosixSlashes(value) {
|
|
4131
|
+
let out = "";
|
|
4132
|
+
for (let i = 0; i < value.length; i++) {
|
|
4133
|
+
const ch = value[i];
|
|
4134
|
+
out += ch === "\\" ? "/" : ch;
|
|
4135
|
+
}
|
|
4136
|
+
return out;
|
|
4137
|
+
}
|
|
4130
4138
|
function safeRealpath(value) {
|
|
4131
4139
|
try {
|
|
4132
4140
|
if (fs.existsSync(value)) {
|
|
@@ -4162,18 +4170,18 @@ function resolveComponentNameFromPath(options) {
|
|
|
4162
4170
|
const { projectRoot, viewsDirAbs, sourceDirs, extraRoots = [] } = options;
|
|
4163
4171
|
const cleanFilename = options.filename.includes("?") ? options.filename.substring(0, options.filename.indexOf("?")) : options.filename;
|
|
4164
4172
|
const absFilename = path.isAbsolute(cleanFilename) ? cleanFilename : path.resolve(projectRoot, cleanFilename);
|
|
4165
|
-
const normalizedAbsFilename = path.normalize(safeRealpath(absFilename));
|
|
4173
|
+
const normalizedAbsFilename = toPosixSlashes(path.normalize(safeRealpath(absFilename)));
|
|
4166
4174
|
const rootBases = [projectRoot, ...extraRoots.filter((r) => r !== projectRoot)];
|
|
4167
4175
|
const roots = [
|
|
4168
4176
|
viewsDirAbs,
|
|
4169
4177
|
...sourceDirs.flatMap((dir) => path.isAbsolute(dir) ? [dir] : rootBases.map((base) => path.resolve(base, dir)))
|
|
4170
4178
|
];
|
|
4171
|
-
const potentialRoots = Array.from(new Set(roots.map((r) => path.normalize(safeRealpath(r))))).sort((a, b) => b.length - a.length);
|
|
4179
|
+
const potentialRoots = Array.from(new Set(roots.map((r) => toPosixSlashes(path.normalize(safeRealpath(r)))))).sort((a, b) => b.length - a.length);
|
|
4172
4180
|
for (const root of potentialRoots) {
|
|
4173
|
-
if (normalizedAbsFilename.startsWith(root
|
|
4174
|
-
const rel = path.relative(root, normalizedAbsFilename);
|
|
4175
|
-
const parsed = path.parse(rel);
|
|
4176
|
-
const segments = path.join(parsed.dir, parsed.name);
|
|
4181
|
+
if (normalizedAbsFilename.startsWith(`${root}/`) || normalizedAbsFilename === root) {
|
|
4182
|
+
const rel = path.posix.relative(root, normalizedAbsFilename);
|
|
4183
|
+
const parsed = path.posix.parse(rel);
|
|
4184
|
+
const segments = path.posix.join(parsed.dir, parsed.name);
|
|
4177
4185
|
return toPascalCase(segments);
|
|
4178
4186
|
}
|
|
4179
4187
|
}
|
|
@@ -8988,9 +8996,8 @@ function analyzeWrapperContractFromSfc(options) {
|
|
|
8988
8996
|
role: null,
|
|
8989
8997
|
targetRoles: [],
|
|
8990
8998
|
forwardedTestIdTargetOffsets: /* @__PURE__ */ new Set(),
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
explicitlyForwardedTestIdTargetSfcOffsets: /* @__PURE__ */ new Set()
|
|
8999
|
+
attrsObjectNames: /* @__PURE__ */ new Set(),
|
|
9000
|
+
attrsFunctionNames: /* @__PURE__ */ new Set()
|
|
8994
9001
|
};
|
|
8995
9002
|
}
|
|
8996
9003
|
const scriptMetadata = analyzeScriptForwardingMetadata(
|
|
@@ -8999,7 +9006,6 @@ function analyzeWrapperContractFromSfc(options) {
|
|
|
8999
9006
|
);
|
|
9000
9007
|
const ast = parse$2(template, { comments: false });
|
|
9001
9008
|
const targets = /* @__PURE__ */ new Map();
|
|
9002
|
-
const explicitTargetOffsets = /* @__PURE__ */ new Set();
|
|
9003
9009
|
if (scriptMetadata.inheritAttrs) {
|
|
9004
9010
|
for (const element of getRenderedRootElements(ast)) {
|
|
9005
9011
|
targets.set(element.loc.start.offset, element);
|
|
@@ -9008,7 +9014,6 @@ function analyzeWrapperContractFromSfc(options) {
|
|
|
9008
9014
|
walkTemplate(ast, (element) => {
|
|
9009
9015
|
if (elementExplicitlyForwardsTestId(element, options.testIdAttribute, scriptMetadata)) {
|
|
9010
9016
|
targets.set(element.loc.start.offset, element);
|
|
9011
|
-
explicitTargetOffsets.add(element.loc.start.offset);
|
|
9012
9017
|
}
|
|
9013
9018
|
});
|
|
9014
9019
|
const targetRoles = [...targets.values()].map((element) => {
|
|
@@ -9023,17 +9028,12 @@ function analyzeWrapperContractFromSfc(options) {
|
|
|
9023
9028
|
});
|
|
9024
9029
|
const uniqueRoles = new Set(targetRoles);
|
|
9025
9030
|
const role = uniqueRoles.size === 1 && !uniqueRoles.has(null) ? targetRoles[0] ?? null : null;
|
|
9026
|
-
const templateContentStartOffset = descriptor.template?.loc.start.offset ?? 0;
|
|
9027
|
-
const toSfcOffsets = (offsets) => new Set(
|
|
9028
|
-
[...offsets].map((offset2) => offset2 + templateContentStartOffset)
|
|
9029
|
-
);
|
|
9030
9031
|
return {
|
|
9031
9032
|
role,
|
|
9032
9033
|
targetRoles,
|
|
9033
9034
|
forwardedTestIdTargetOffsets: new Set(targets.keys()),
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
explicitlyForwardedTestIdTargetSfcOffsets: toSfcOffsets(explicitTargetOffsets)
|
|
9035
|
+
attrsObjectNames: scriptMetadata.attrsObjectNames,
|
|
9036
|
+
attrsFunctionNames: scriptMetadata.attrsFunctionNames
|
|
9037
9037
|
};
|
|
9038
9038
|
}
|
|
9039
9039
|
function resolveWrapperContractForTag(options) {
|
|
@@ -9702,8 +9702,7 @@ function createTestIdTransform(componentName, componentHierarchyMap, nativeWrapp
|
|
|
9702
9702
|
}
|
|
9703
9703
|
}
|
|
9704
9704
|
const ownWrapperContract = getWrapperContract(componentName);
|
|
9705
|
-
const
|
|
9706
|
-
const isExplicitFallthroughTarget = ownWrapperContract?.explicitlyForwardedTestIdTargetOffsets.has(elementStartOffset) || ownWrapperContract?.explicitlyForwardedTestIdTargetSfcOffsets.has(elementStartOffset);
|
|
9705
|
+
const isExplicitFallthroughTarget = !!ownWrapperContract && elementExplicitlyForwardsTestId(element, testIdAttribute, ownWrapperContract);
|
|
9707
9706
|
if (!dependencies.isView && isExplicitFallthroughTarget) {
|
|
9708
9707
|
return;
|
|
9709
9708
|
}
|
|
@@ -10539,7 +10538,8 @@ function createVuePluginWithTestIds(options) {
|
|
|
10539
10538
|
runtimeNodeTransform
|
|
10540
10539
|
]
|
|
10541
10540
|
};
|
|
10542
|
-
const collectSource = async (code,
|
|
10541
|
+
const collectSource = async (code, rawPath) => {
|
|
10542
|
+
const cleanPath = toPosixSlashes(rawPath);
|
|
10543
10543
|
const componentName = getComponentNameFromPath(cleanPath);
|
|
10544
10544
|
loggerRef.current.debug(`Collecting metadata for ${cleanPath} (component: ${componentName})`);
|
|
10545
10545
|
const compilerSfc = await import("@vue/compiler-sfc");
|
|
@@ -10772,7 +10772,7 @@ function createDevProcessorPlugin(options) {
|
|
|
10772
10772
|
const { descriptor } = parse$1(source, { filename });
|
|
10773
10773
|
if (!descriptor.script && !descriptor.scriptSetup)
|
|
10774
10774
|
return { bindings: void 0, isScriptSetup: false };
|
|
10775
|
-
const scriptBlock = compileScript(descriptor, { id: filename });
|
|
10775
|
+
const scriptBlock = compileScript(descriptor, { id: toPosixSlashes(filename) });
|
|
10776
10776
|
return { bindings: scriptBlock.bindings, isScriptSetup: !!descriptor.scriptSetup };
|
|
10777
10777
|
} catch {
|
|
10778
10778
|
return { bindings: void 0, isScriptSetup: false };
|