@immense/vue-pom-generator 1.0.40 → 1.0.42
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 -19
- package/class-generation/index.ts +1 -1
- package/dist/class-generation/index.d.ts +1 -1
- package/dist/class-generation/index.d.ts.map +1 -1
- package/dist/index.cjs +100 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +100 -79
- package/dist/index.mjs.map +1 -1
- package/dist/plugin/create-vue-pom-generator-plugins.d.ts.map +1 -1
- package/dist/plugin/support/build-plugin.d.ts +1 -1
- package/dist/plugin/support/build-plugin.d.ts.map +1 -1
- package/dist/plugin/support/dev-plugin.d.ts +3 -2
- package/dist/plugin/support/dev-plugin.d.ts.map +1 -1
- package/dist/plugin/support-plugins.d.ts +3 -2
- package/dist/plugin/support-plugins.d.ts.map +1 -1
- package/dist/tests/dev-plugin-options.test.d.ts +2 -0
- package/dist/tests/dev-plugin-options.test.d.ts.map +1 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -698,14 +698,16 @@ function nodeHasForDirective(node) {
|
|
|
698
698
|
function getKeyDirective(node) {
|
|
699
699
|
return findDirectiveByName(node, "bind", "key") ?? null;
|
|
700
700
|
}
|
|
701
|
-
function getKeyDirectiveValue(node,
|
|
701
|
+
function getKeyDirectiveValue(node, _context = null) {
|
|
702
702
|
const keyDirective = getKeyDirective(node);
|
|
703
|
-
|
|
704
|
-
if (
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
703
|
+
const rawSource = keyDirective?.exp?.loc.source?.trim();
|
|
704
|
+
if (rawSource) {
|
|
705
|
+
return `\${${rawSource}}`;
|
|
706
|
+
}
|
|
707
|
+
if (keyDirective?.exp) {
|
|
708
|
+
const value = stringifyExpression(keyDirective.exp);
|
|
709
|
+
if (value)
|
|
710
|
+
return `\${${value}}`;
|
|
709
711
|
}
|
|
710
712
|
return null;
|
|
711
713
|
}
|
|
@@ -5967,6 +5969,7 @@ function createDevProcessorPlugin(options) {
|
|
|
5967
5969
|
customPomDir,
|
|
5968
5970
|
customPomImportAliases,
|
|
5969
5971
|
customPomImportNameCollisionBehavior,
|
|
5972
|
+
nameCollisionBehavior = "suffix",
|
|
5970
5973
|
testIdAttribute,
|
|
5971
5974
|
routerAwarePoms,
|
|
5972
5975
|
resolvedRouterEntry,
|
|
@@ -5993,7 +5996,7 @@ function createDevProcessorPlugin(options) {
|
|
|
5993
5996
|
return;
|
|
5994
5997
|
scheduleVueFileRegen(ctx.file, "hmr");
|
|
5995
5998
|
},
|
|
5996
|
-
configureServer(server) {
|
|
5999
|
+
async configureServer(server) {
|
|
5997
6000
|
const getViewsDirAbs = () => path.isAbsolute(viewsDir) ? viewsDir : path.resolve(projectRootRef.current, viewsDir);
|
|
5998
6001
|
const routerInitPromise = (async () => {
|
|
5999
6002
|
if (!routerAwarePoms) {
|
|
@@ -6070,8 +6073,8 @@ function createDevProcessorPlugin(options) {
|
|
|
6070
6073
|
}
|
|
6071
6074
|
return out;
|
|
6072
6075
|
};
|
|
6073
|
-
|
|
6074
|
-
|
|
6076
|
+
let snapshotHierarchy = /* @__PURE__ */ new Map();
|
|
6077
|
+
let snapshotVuePathMap = /* @__PURE__ */ new Map();
|
|
6075
6078
|
const filePathToComponentName = /* @__PURE__ */ new Map();
|
|
6076
6079
|
const getComponentNameForFile = (filePath) => {
|
|
6077
6080
|
const normalized = path.resolve(filePath);
|
|
@@ -6088,12 +6091,12 @@ function createDevProcessorPlugin(options) {
|
|
|
6088
6091
|
filePathToComponentName.set(normalized, name);
|
|
6089
6092
|
return name;
|
|
6090
6093
|
};
|
|
6091
|
-
const compileVueFileIntoSnapshot = (filePath) => {
|
|
6094
|
+
const compileVueFileIntoSnapshot = (filePath, targetHierarchy = snapshotHierarchy, targetVuePathMap = snapshotVuePathMap) => {
|
|
6092
6095
|
const started = performance.now();
|
|
6093
6096
|
const absolutePath = path.resolve(filePath);
|
|
6094
6097
|
const componentName = getComponentNameForFile(absolutePath);
|
|
6095
|
-
|
|
6096
|
-
|
|
6098
|
+
targetVuePathMap.set(componentName, absolutePath);
|
|
6099
|
+
targetHierarchy.delete(componentName);
|
|
6097
6100
|
let sfc = "";
|
|
6098
6101
|
try {
|
|
6099
6102
|
sfc = fs.readFileSync(absolutePath, "utf8");
|
|
@@ -6103,29 +6106,33 @@ function createDevProcessorPlugin(options) {
|
|
|
6103
6106
|
const template = extractTemplateFromSfc(sfc, absolutePath);
|
|
6104
6107
|
if (!template.trim())
|
|
6105
6108
|
return { componentName, ms: performance.now() - started, compiled: true };
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6109
|
+
compilerDom.compile(template, {
|
|
6110
|
+
filename: absolutePath,
|
|
6111
|
+
prefixIdentifiers: true,
|
|
6112
|
+
nodeTransforms: [
|
|
6113
|
+
createTestIdTransform(
|
|
6114
|
+
componentName,
|
|
6115
|
+
targetHierarchy,
|
|
6116
|
+
nativeWrappers,
|
|
6117
|
+
excludedComponents,
|
|
6118
|
+
getViewsDirAbs(),
|
|
6119
|
+
{
|
|
6120
|
+
existingIdBehavior: "preserve",
|
|
6121
|
+
nameCollisionBehavior,
|
|
6122
|
+
testIdAttribute,
|
|
6123
|
+
warn: (message) => loggerRef.current.warn(message),
|
|
6124
|
+
vueFilesPathMap: targetVuePathMap,
|
|
6125
|
+
wrapperSearchRoots: getWrapperSearchRoots()
|
|
6126
|
+
}
|
|
6127
|
+
)
|
|
6128
|
+
]
|
|
6129
|
+
});
|
|
6123
6130
|
return { componentName, ms: performance.now() - started, compiled: true };
|
|
6124
6131
|
};
|
|
6125
6132
|
const fullRebuildSnapshotFromFilesystem = () => {
|
|
6126
6133
|
const t0 = performance.now();
|
|
6127
|
-
|
|
6128
|
-
|
|
6134
|
+
const nextHierarchy = /* @__PURE__ */ new Map();
|
|
6135
|
+
const nextVuePathMap = /* @__PURE__ */ new Map();
|
|
6129
6136
|
filePathToComponentName.clear();
|
|
6130
6137
|
let totalVueFiles = 0;
|
|
6131
6138
|
let compiledCount = 0;
|
|
@@ -6136,11 +6143,13 @@ function createDevProcessorPlugin(options) {
|
|
|
6136
6143
|
const vueFiles = walkFilesRecursive(absDir);
|
|
6137
6144
|
totalVueFiles += vueFiles.length;
|
|
6138
6145
|
for (const file of vueFiles) {
|
|
6139
|
-
const res = compileVueFileIntoSnapshot(file);
|
|
6146
|
+
const res = compileVueFileIntoSnapshot(file, nextHierarchy, nextVuePathMap);
|
|
6140
6147
|
if (res.compiled)
|
|
6141
6148
|
compiledCount++;
|
|
6142
6149
|
}
|
|
6143
6150
|
}
|
|
6151
|
+
snapshotHierarchy = nextHierarchy;
|
|
6152
|
+
snapshotVuePathMap = nextVuePathMap;
|
|
6144
6153
|
const t1 = performance.now();
|
|
6145
6154
|
logInfo(`initial scan: found ${totalVueFiles} .vue files in ${scanDirs.join(", ")}`);
|
|
6146
6155
|
logInfo(`initial compile: ${compiledCount}/${totalVueFiles} files in ${formatMs(t1 - t0)} (components=${snapshotHierarchy.size})`);
|
|
@@ -6157,6 +6166,8 @@ function createDevProcessorPlugin(options) {
|
|
|
6157
6166
|
customPomDir,
|
|
6158
6167
|
customPomImportAliases,
|
|
6159
6168
|
customPomImportNameCollisionBehavior,
|
|
6169
|
+
viewsDir,
|
|
6170
|
+
scanDirs,
|
|
6160
6171
|
testIdAttribute,
|
|
6161
6172
|
vueRouterFluentChaining: routerAwarePoms,
|
|
6162
6173
|
routerEntry: resolvedRouterEntry,
|
|
@@ -6165,6 +6176,10 @@ function createDevProcessorPlugin(options) {
|
|
|
6165
6176
|
const t1 = performance.now();
|
|
6166
6177
|
logInfo(`generate(${reason}): components=${snapshotHierarchy.size} in ${formatMs(t1 - t0)}`);
|
|
6167
6178
|
};
|
|
6179
|
+
let timer = null;
|
|
6180
|
+
let maxWaitTimer = null;
|
|
6181
|
+
const pendingChangedVueFiles = /* @__PURE__ */ new Set();
|
|
6182
|
+
const pendingDeletedComponents = /* @__PURE__ */ new Set();
|
|
6168
6183
|
const initialBuildPromise = (async () => {
|
|
6169
6184
|
const t0 = performance.now();
|
|
6170
6185
|
await routerInitPromise;
|
|
@@ -6173,13 +6188,44 @@ function createDevProcessorPlugin(options) {
|
|
|
6173
6188
|
const t1 = performance.now();
|
|
6174
6189
|
logInfo(`startup total: ${formatMs(t1 - t0)}`);
|
|
6175
6190
|
})();
|
|
6191
|
+
const logGenerationError = (reason, message) => {
|
|
6192
|
+
server.config.logger.error(`[vue-pom-generator] dev generation failed during ${reason}: ${message}`);
|
|
6193
|
+
};
|
|
6194
|
+
const regenerateFromPending = async (reason) => {
|
|
6195
|
+
const t0 = performance.now();
|
|
6196
|
+
await initialBuildPromise;
|
|
6197
|
+
const nextHierarchy = new Map(snapshotHierarchy);
|
|
6198
|
+
const nextVuePathMap = new Map(snapshotVuePathMap);
|
|
6199
|
+
for (const componentName of pendingDeletedComponents) {
|
|
6200
|
+
nextHierarchy.delete(componentName);
|
|
6201
|
+
nextVuePathMap.delete(componentName);
|
|
6202
|
+
}
|
|
6203
|
+
const files = Array.from(pendingChangedVueFiles);
|
|
6204
|
+
const deletedCount = pendingDeletedComponents.size;
|
|
6205
|
+
pendingChangedVueFiles.clear();
|
|
6206
|
+
pendingDeletedComponents.clear();
|
|
6207
|
+
let compileMs = 0;
|
|
6208
|
+
for (const f of files) {
|
|
6209
|
+
const res = compileVueFileIntoSnapshot(f, nextHierarchy, nextVuePathMap);
|
|
6210
|
+
compileMs += res.ms;
|
|
6211
|
+
}
|
|
6212
|
+
snapshotHierarchy = nextHierarchy;
|
|
6213
|
+
snapshotVuePathMap = nextVuePathMap;
|
|
6214
|
+
const t1 = performance.now();
|
|
6215
|
+
generateAggregatedFromSnapshot(reason);
|
|
6216
|
+
const t2 = performance.now();
|
|
6217
|
+
return {
|
|
6218
|
+
files,
|
|
6219
|
+
deletedCount,
|
|
6220
|
+
compileMs,
|
|
6221
|
+
preGenerateMs: t1 - t0,
|
|
6222
|
+
generateMs: t2 - t1,
|
|
6223
|
+
totalMs: t2 - t0
|
|
6224
|
+
};
|
|
6225
|
+
};
|
|
6176
6226
|
const watchedVueGlobs = scanDirs.map((dir) => path.resolve(projectRootRef.current, dir, "**", "*.vue"));
|
|
6177
6227
|
const watchedPluginGlob = path.resolve(projectRootRef.current, "vite-plugins", "vue-pom-generator", "**", "*.ts");
|
|
6178
6228
|
server.watcher.add([...watchedVueGlobs, watchedPluginGlob, basePageClassPath]);
|
|
6179
|
-
let timer = null;
|
|
6180
|
-
let maxWaitTimer = null;
|
|
6181
|
-
const pendingChangedVueFiles = /* @__PURE__ */ new Set();
|
|
6182
|
-
const pendingDeletedComponents = /* @__PURE__ */ new Set();
|
|
6183
6229
|
scheduleVueFileRegenLocal = (filePath, source) => {
|
|
6184
6230
|
pendingChangedVueFiles.add(filePath);
|
|
6185
6231
|
logDebug(`queued(${source}): files=${pendingChangedVueFiles.size} deleted=${pendingDeletedComponents.size}`);
|
|
@@ -6196,29 +6242,14 @@ function createDevProcessorPlugin(options) {
|
|
|
6196
6242
|
timer = null;
|
|
6197
6243
|
}
|
|
6198
6244
|
maxWaitTimer = null;
|
|
6199
|
-
void (
|
|
6200
|
-
const t0 = performance.now();
|
|
6201
|
-
await initialBuildPromise;
|
|
6202
|
-
for (const componentName of pendingDeletedComponents) {
|
|
6203
|
-
snapshotHierarchy.delete(componentName);
|
|
6204
|
-
snapshotVuePathMap.delete(componentName);
|
|
6205
|
-
}
|
|
6206
|
-
const files = Array.from(pendingChangedVueFiles);
|
|
6207
|
-
const deletedCount = pendingDeletedComponents.size;
|
|
6208
|
-
pendingChangedVueFiles.clear();
|
|
6209
|
-
pendingDeletedComponents.clear();
|
|
6210
|
-
let compileMs = 0;
|
|
6211
|
-
for (const f of files) {
|
|
6212
|
-
const res = compileVueFileIntoSnapshot(f);
|
|
6213
|
-
compileMs += res.ms;
|
|
6214
|
-
}
|
|
6215
|
-
const t1 = performance.now();
|
|
6216
|
-
generateAggregatedFromSnapshot("max-wait");
|
|
6217
|
-
const t2 = performance.now();
|
|
6245
|
+
void regenerateFromPending("max-wait").then(({ files, deletedCount, compileMs, preGenerateMs, generateMs, totalMs }) => {
|
|
6218
6246
|
logInfo(
|
|
6219
|
-
`max-wait: files=${files.length} deleted=${deletedCount} compile=${formatMs(compileMs)} wall=${formatMs(
|
|
6247
|
+
`max-wait: files=${files.length} deleted=${deletedCount} compile=${formatMs(compileMs)} wall=${formatMs(preGenerateMs)} gen=${formatMs(generateMs)} total=${formatMs(totalMs)}`
|
|
6220
6248
|
);
|
|
6221
|
-
})()
|
|
6249
|
+
}).catch((error) => {
|
|
6250
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
6251
|
+
logGenerationError("max-wait", message);
|
|
6252
|
+
});
|
|
6222
6253
|
}, MAX_WAIT_MS);
|
|
6223
6254
|
}
|
|
6224
6255
|
if (wasEmpty) {
|
|
@@ -6234,31 +6265,17 @@ function createDevProcessorPlugin(options) {
|
|
|
6234
6265
|
clearTimeout(maxWaitTimer);
|
|
6235
6266
|
maxWaitTimer = null;
|
|
6236
6267
|
}
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
await initialBuildPromise;
|
|
6240
|
-
for (const componentName of pendingDeletedComponents) {
|
|
6241
|
-
snapshotHierarchy.delete(componentName);
|
|
6242
|
-
snapshotVuePathMap.delete(componentName);
|
|
6243
|
-
}
|
|
6244
|
-
const files = Array.from(pendingChangedVueFiles);
|
|
6245
|
-
const deletedCount = pendingDeletedComponents.size;
|
|
6246
|
-
pendingChangedVueFiles.clear();
|
|
6247
|
-
pendingDeletedComponents.clear();
|
|
6248
|
-
let compileMs = 0;
|
|
6249
|
-
for (const f of files) {
|
|
6250
|
-
const res = compileVueFileIntoSnapshot(f);
|
|
6251
|
-
compileMs += res.ms;
|
|
6252
|
-
}
|
|
6253
|
-
const t1 = performance.now();
|
|
6254
|
-
generateAggregatedFromSnapshot(files.length || deletedCount ? "batched" : "noop");
|
|
6255
|
-
const t2 = performance.now();
|
|
6268
|
+
const reason = pendingChangedVueFiles.size || pendingDeletedComponents.size ? "batched" : "noop";
|
|
6269
|
+
void regenerateFromPending(reason).then(({ files, deletedCount, compileMs, preGenerateMs, generateMs, totalMs }) => {
|
|
6256
6270
|
if (files.length || deletedCount) {
|
|
6257
6271
|
logInfo(
|
|
6258
|
-
`batched: files=${files.length} deleted=${deletedCount} compile=${formatMs(compileMs)} wall=${formatMs(
|
|
6272
|
+
`batched: files=${files.length} deleted=${deletedCount} compile=${formatMs(compileMs)} wall=${formatMs(preGenerateMs)} gen=${formatMs(generateMs)} total=${formatMs(totalMs)}`
|
|
6259
6273
|
);
|
|
6260
6274
|
}
|
|
6261
|
-
})()
|
|
6275
|
+
}).catch((error) => {
|
|
6276
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
6277
|
+
logGenerationError(reason, message);
|
|
6278
|
+
});
|
|
6262
6279
|
}, 75);
|
|
6263
6280
|
}
|
|
6264
6281
|
server.watcher.on("change", async (changedPath) => {
|
|
@@ -6310,6 +6327,7 @@ function createDevProcessorPlugin(options) {
|
|
|
6310
6327
|
});
|
|
6311
6328
|
setTimeout(() => {
|
|
6312
6329
|
}, 250);
|
|
6330
|
+
await initialBuildPromise;
|
|
6313
6331
|
}
|
|
6314
6332
|
};
|
|
6315
6333
|
}
|
|
@@ -6340,6 +6358,7 @@ function createSupportPlugins(options) {
|
|
|
6340
6358
|
viewsDir,
|
|
6341
6359
|
scanDirs,
|
|
6342
6360
|
getWrapperSearchRoots,
|
|
6361
|
+
nameCollisionBehavior = "suffix",
|
|
6343
6362
|
outDir,
|
|
6344
6363
|
emitLanguages,
|
|
6345
6364
|
csharp,
|
|
@@ -6416,6 +6435,7 @@ function createSupportPlugins(options) {
|
|
|
6416
6435
|
customPomDir,
|
|
6417
6436
|
customPomImportAliases,
|
|
6418
6437
|
customPomImportNameCollisionBehavior,
|
|
6438
|
+
nameCollisionBehavior,
|
|
6419
6439
|
testIdAttribute,
|
|
6420
6440
|
routerAwarePoms,
|
|
6421
6441
|
routerType,
|
|
@@ -6996,6 +7016,7 @@ function createVuePomGeneratorPlugins(options = {}) {
|
|
|
6996
7016
|
viewsDir,
|
|
6997
7017
|
scanDirs,
|
|
6998
7018
|
getWrapperSearchRoots: getWrapperSearchRootsAbs,
|
|
7019
|
+
nameCollisionBehavior,
|
|
6999
7020
|
outDir,
|
|
7000
7021
|
emitLanguages,
|
|
7001
7022
|
csharp,
|