@immense/vue-pom-generator 1.0.20 → 1.0.21
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/README.md +7 -2
- package/RELEASE_NOTES.md +24 -33
- package/dist/index.cjs +132 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +132 -16
- 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 +2 -1
- package/dist/plugin/support/build-plugin.d.ts.map +1 -1
- package/dist/plugin/support/dev-plugin.d.ts +2 -1
- package/dist/plugin/support/dev-plugin.d.ts.map +1 -1
- package/dist/plugin/support-plugins.d.ts +2 -1
- package/dist/plugin/support-plugins.d.ts.map +1 -1
- package/dist/plugin/types.d.ts +11 -4
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/router-introspection.d.ts +6 -2
- package/dist/router-introspection.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -105,7 +105,10 @@ export default defineConfig(() => {
|
|
|
105
105
|
// For standard Vue apps:
|
|
106
106
|
entry: "src/router.ts",
|
|
107
107
|
moduleShims: {
|
|
108
|
-
"@/config/app-insights":
|
|
108
|
+
"@/config/app-insights": {
|
|
109
|
+
getAppInsights: () => null,
|
|
110
|
+
},
|
|
111
|
+
"@/store/pinia/app-alert-store": ["useAppAlertsStore"],
|
|
109
112
|
},
|
|
110
113
|
// For Nuxt apps (file-based routing):
|
|
111
114
|
// type: "nuxt"
|
|
@@ -146,7 +149,9 @@ Controls router introspection for `:to` analysis and navigation helper generatio
|
|
|
146
149
|
|
|
147
150
|
- `entry: string`: For standard Vue apps, where router introspection loads your Vue Router definition from. This file must export a **default router factory function** (e.g. `export default makeRouter`).
|
|
148
151
|
- `type: "vue-router" | "nuxt"`: The introspection provider. Defaults to `"vue-router"`. Use `"nuxt"` for file-based routing discovery (e.g. `app/pages` or `pages`).
|
|
149
|
-
- `moduleShims: Record<string, string
|
|
152
|
+
- `moduleShims: Record<string, string[] | Record<string, fn>>`: Optional module-source -> shim definition map used only while introspecting the router.
|
|
153
|
+
- Use `string[]` for no-op exported functions (e.g. `["useAppAlertsStore"]`).
|
|
154
|
+
- Use `Record<string, fn>` for explicit exported function implementations (e.g. `{ getAppInsights: () => null }`).
|
|
150
155
|
|
|
151
156
|
### `generation.playwright.fixtures: boolean | string | { outDir?: string }`
|
|
152
157
|
|
package/RELEASE_NOTES.md
CHANGED
|
@@ -1,41 +1,31 @@
|
|
|
1
|
-
●
|
|
2
|
-
the plugin system.
|
|
3
|
-
|
|
4
|
-
● Now let me check the README changes to understand what was documented:
|
|
5
|
-
|
|
6
|
-
● Perfect! Now I have all the information I need. Let me generate the release notes:
|
|
7
|
-
|
|
1
|
+
● ```markdown
|
|
8
2
|
## Highlights
|
|
9
3
|
|
|
10
|
-
- Added
|
|
11
|
-
|
|
12
|
-
- Enhanced router introspection
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
- Expanded test coverage for router introspection and plugin options validation
|
|
4
|
+
- Added support for typed router module shims, enabling better TypeScript integration with Vue
|
|
5
|
+
Router
|
|
6
|
+
- Enhanced router introspection capabilities with 150+ lines of new functionality
|
|
7
|
+
- Expanded test coverage for router introspection and options handling
|
|
8
|
+
- Improved plugin system with updated type definitions
|
|
16
9
|
|
|
17
10
|
## Changes
|
|
18
11
|
|
|
19
|
-
**Router
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
variants)
|
|
24
|
-
- Enhanced `parseRouterFileFromCwd()` to accept and normalize `moduleShims` configuration
|
|
12
|
+
**Router & TypeScript**
|
|
13
|
+
- Implemented typed router module shim support
|
|
14
|
+
- Enhanced router introspection logic with improved type inference
|
|
15
|
+
- Updated plugin types to accommodate router module shims
|
|
25
16
|
|
|
26
17
|
**Plugin System**
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
- Enhanced plugin validation to check shim configuration structure
|
|
18
|
+
- Updated `create-vue-pom-generator-plugins.ts` with new plugin configuration
|
|
19
|
+
- Modified support plugins (build, dev) for typed router compatibility
|
|
20
|
+
- Enhanced plugin type definitions
|
|
31
21
|
|
|
32
|
-
**Documentation**
|
|
33
|
-
- Added
|
|
34
|
-
-
|
|
22
|
+
**Testing & Documentation**
|
|
23
|
+
- Added new test cases for router introspection (50+ lines)
|
|
24
|
+
- Expanded options test coverage
|
|
25
|
+
- Updated README with latest usage information
|
|
35
26
|
|
|
36
|
-
**
|
|
37
|
-
-
|
|
38
|
-
- Enhanced `options.test.ts` with validation tests for router configuration
|
|
27
|
+
**Dependencies**
|
|
28
|
+
- Version bump to 1.0.21
|
|
39
29
|
|
|
40
30
|
## Breaking Changes
|
|
41
31
|
|
|
@@ -43,11 +33,12 @@
|
|
|
43
33
|
|
|
44
34
|
## Pull Requests Included
|
|
45
35
|
|
|
46
|
-
- #1
|
|
36
|
+
- [#1](https://github.com/immense/vue-pom-generator/pull/1) Add PR release-notes preview
|
|
37
|
+
comments (@dkattan)
|
|
47
38
|
|
|
48
39
|
## Testing
|
|
49
40
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
Comprehensive test coverage added for router introspection functionality and options handling.
|
|
42
|
+
All tests passing.
|
|
43
|
+
```
|
|
53
44
|
|
package/dist/index.cjs
CHANGED
|
@@ -2348,21 +2348,101 @@ function debugLog(message) {
|
|
|
2348
2348
|
console.log(`[vue-pom-generator][router-introspection] ${message}`);
|
|
2349
2349
|
}
|
|
2350
2350
|
}
|
|
2351
|
+
function isAsciiLetterCode(code) {
|
|
2352
|
+
return code >= 65 && code <= 90 || code >= 97 && code <= 122;
|
|
2353
|
+
}
|
|
2354
|
+
function isAsciiDigitCode(code) {
|
|
2355
|
+
return code >= 48 && code <= 57;
|
|
2356
|
+
}
|
|
2357
|
+
function isIdentifierStartCode(code) {
|
|
2358
|
+
return code === 95 || code === 36 || isAsciiLetterCode(code);
|
|
2359
|
+
}
|
|
2360
|
+
function isIdentifierPartCode(code) {
|
|
2361
|
+
return isIdentifierStartCode(code) || isAsciiDigitCode(code);
|
|
2362
|
+
}
|
|
2363
|
+
function isValidJsIdentifier(name) {
|
|
2364
|
+
if (!name.length)
|
|
2365
|
+
return false;
|
|
2366
|
+
const first = name.charCodeAt(0);
|
|
2367
|
+
if (!isIdentifierStartCode(first))
|
|
2368
|
+
return false;
|
|
2369
|
+
for (let i = 1; i < name.length; i++) {
|
|
2370
|
+
if (!isIdentifierPartCode(name.charCodeAt(i)))
|
|
2371
|
+
return false;
|
|
2372
|
+
}
|
|
2373
|
+
return true;
|
|
2374
|
+
}
|
|
2375
|
+
function assertValidNamedExportName(exportName, moduleSource) {
|
|
2376
|
+
if (exportName === "default")
|
|
2377
|
+
return;
|
|
2378
|
+
if (!isValidJsIdentifier(exportName)) {
|
|
2379
|
+
throw new TypeError(`[vue-pom-generator] router moduleShims[${JSON.stringify(moduleSource)}] contains invalid export name ${JSON.stringify(exportName)}.`);
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
function createNoopShimFunction() {
|
|
2383
|
+
let value;
|
|
2384
|
+
const base = (() => value);
|
|
2385
|
+
value = new Proxy(base, {
|
|
2386
|
+
apply() {
|
|
2387
|
+
return value;
|
|
2388
|
+
},
|
|
2389
|
+
get() {
|
|
2390
|
+
return value;
|
|
2391
|
+
}
|
|
2392
|
+
});
|
|
2393
|
+
return value;
|
|
2394
|
+
}
|
|
2351
2395
|
function normalizeRouterIntrospectionModuleShims(moduleShims) {
|
|
2352
2396
|
if (!moduleShims)
|
|
2353
2397
|
return {};
|
|
2354
2398
|
if (typeof moduleShims !== "object" || Array.isArray(moduleShims)) {
|
|
2355
|
-
throw new TypeError("[vue-pom-generator] router moduleShims must be an object map of module source ->
|
|
2399
|
+
throw new TypeError("[vue-pom-generator] router moduleShims must be an object map of module source -> shim definition.");
|
|
2356
2400
|
}
|
|
2357
2401
|
const normalized = {};
|
|
2358
|
-
for (const [moduleSource,
|
|
2402
|
+
for (const [moduleSource, shimDefinition] of Object.entries(moduleShims)) {
|
|
2359
2403
|
if (!moduleSource.trim()) {
|
|
2360
2404
|
throw new TypeError("[vue-pom-generator] router moduleShims contains an empty module source key.");
|
|
2361
2405
|
}
|
|
2362
|
-
if (
|
|
2363
|
-
|
|
2406
|
+
if (Array.isArray(shimDefinition)) {
|
|
2407
|
+
if (!shimDefinition.length) {
|
|
2408
|
+
throw new TypeError(`[vue-pom-generator] router moduleShims[${JSON.stringify(moduleSource)}] must contain at least one export name.`);
|
|
2409
|
+
}
|
|
2410
|
+
const exports2 = {};
|
|
2411
|
+
for (const exportName of shimDefinition) {
|
|
2412
|
+
if (!exportName.trim()) {
|
|
2413
|
+
throw new TypeError(`[vue-pom-generator] router moduleShims[${JSON.stringify(moduleSource)}] contains an empty export name.`);
|
|
2414
|
+
}
|
|
2415
|
+
if (exportName === "*") {
|
|
2416
|
+
throw new TypeError(`[vue-pom-generator] router moduleShims[${JSON.stringify(moduleSource)}] does not support '*' export wildcard.`);
|
|
2417
|
+
}
|
|
2418
|
+
assertValidNamedExportName(exportName, moduleSource);
|
|
2419
|
+
exports2[exportName] = createNoopShimFunction();
|
|
2420
|
+
}
|
|
2421
|
+
normalized[moduleSource] = exports2;
|
|
2422
|
+
continue;
|
|
2423
|
+
}
|
|
2424
|
+
if (!shimDefinition || typeof shimDefinition !== "object") {
|
|
2425
|
+
throw new TypeError(`[vue-pom-generator] router moduleShims[${JSON.stringify(moduleSource)}] must be a string[] or export->function map.`);
|
|
2426
|
+
}
|
|
2427
|
+
const entries = Object.entries(shimDefinition);
|
|
2428
|
+
if (!entries.length) {
|
|
2429
|
+
throw new TypeError(`[vue-pom-generator] router moduleShims[${JSON.stringify(moduleSource)}] must contain at least one export.`);
|
|
2430
|
+
}
|
|
2431
|
+
const exports$1 = {};
|
|
2432
|
+
for (const [exportName, shimValue] of entries) {
|
|
2433
|
+
if (!exportName.trim()) {
|
|
2434
|
+
throw new TypeError(`[vue-pom-generator] router moduleShims[${JSON.stringify(moduleSource)}] contains an empty export name.`);
|
|
2435
|
+
}
|
|
2436
|
+
if (exportName === "*") {
|
|
2437
|
+
throw new TypeError(`[vue-pom-generator] router moduleShims[${JSON.stringify(moduleSource)}] does not support '*' export wildcard.`);
|
|
2438
|
+
}
|
|
2439
|
+
assertValidNamedExportName(exportName, moduleSource);
|
|
2440
|
+
if (typeof shimValue !== "function") {
|
|
2441
|
+
throw new TypeError(`[vue-pom-generator] router moduleShims[${JSON.stringify(moduleSource)}][${JSON.stringify(exportName)}] must be a function.`);
|
|
2442
|
+
}
|
|
2443
|
+
exports$1[exportName] = shimValue;
|
|
2364
2444
|
}
|
|
2365
|
-
normalized[moduleSource] =
|
|
2445
|
+
normalized[moduleSource] = exports$1;
|
|
2366
2446
|
}
|
|
2367
2447
|
return normalized;
|
|
2368
2448
|
}
|
|
@@ -2371,12 +2451,12 @@ function createRouterIntrospectionVueStubPlugin(options) {
|
|
|
2371
2451
|
const projectRoot = path.dirname(routerEntryAbs);
|
|
2372
2452
|
const shimVirtualIdPrefix = "\0vue-testid-router-introspection-shim:";
|
|
2373
2453
|
const shimVirtualIdsBySource = /* @__PURE__ */ new Map();
|
|
2374
|
-
const
|
|
2454
|
+
const shimExportsByVirtualId = /* @__PURE__ */ new Map();
|
|
2375
2455
|
const addShimMatcher = (source, virtualId) => {
|
|
2376
2456
|
shimVirtualIdsBySource.set(source, virtualId);
|
|
2377
2457
|
shimVirtualIdsBySource.set(path.posix.normalize(source), virtualId);
|
|
2378
2458
|
};
|
|
2379
|
-
for (const [moduleSource,
|
|
2459
|
+
for (const [moduleSource, shimExports] of Object.entries(options.moduleShims ?? {})) {
|
|
2380
2460
|
const virtualId = `${shimVirtualIdPrefix}${encodeURIComponent(moduleSource)}`;
|
|
2381
2461
|
addShimMatcher(moduleSource, virtualId);
|
|
2382
2462
|
if (moduleSource.startsWith("@/")) {
|
|
@@ -2389,7 +2469,7 @@ function createRouterIntrospectionVueStubPlugin(options) {
|
|
|
2389
2469
|
addShimMatcher(`${absoluteNoExt}.mjs`, virtualId);
|
|
2390
2470
|
addShimMatcher(`${absoluteNoExt}.cjs`, virtualId);
|
|
2391
2471
|
}
|
|
2392
|
-
|
|
2472
|
+
shimExportsByVirtualId.set(virtualId, shimExports);
|
|
2393
2473
|
}
|
|
2394
2474
|
return {
|
|
2395
2475
|
name: "vue-testid-router-introspection-vue-stub",
|
|
@@ -2403,9 +2483,25 @@ function createRouterIntrospectionVueStubPlugin(options) {
|
|
|
2403
2483
|
load(id) {
|
|
2404
2484
|
const queryIndex = id.indexOf("?");
|
|
2405
2485
|
const cleanId = queryIndex === -1 ? id : id.slice(0, queryIndex);
|
|
2406
|
-
const
|
|
2407
|
-
if (
|
|
2408
|
-
|
|
2486
|
+
const shimExports = shimExportsByVirtualId.get(cleanId);
|
|
2487
|
+
if (shimExports) {
|
|
2488
|
+
const globalRegistry = globalThis;
|
|
2489
|
+
if (!globalRegistry.__VUE_TESTID_ROUTER_INTROSPECTION_SHIMS__)
|
|
2490
|
+
globalRegistry.__VUE_TESTID_ROUTER_INTROSPECTION_SHIMS__ = {};
|
|
2491
|
+
globalRegistry.__VUE_TESTID_ROUTER_INTROSPECTION_SHIMS__[cleanId] = shimExports;
|
|
2492
|
+
const sortedExportNames = Object.keys(shimExports).sort((a, b) => a.localeCompare(b));
|
|
2493
|
+
const lines = [
|
|
2494
|
+
`const __shim = globalThis.__VUE_TESTID_ROUTER_INTROSPECTION_SHIMS__[${JSON.stringify(cleanId)}];`
|
|
2495
|
+
];
|
|
2496
|
+
for (const exportName of sortedExportNames) {
|
|
2497
|
+
if (exportName === "default")
|
|
2498
|
+
continue;
|
|
2499
|
+
lines.push(`export const ${exportName} = __shim[${JSON.stringify(exportName)}];`);
|
|
2500
|
+
}
|
|
2501
|
+
if (sortedExportNames.includes("default"))
|
|
2502
|
+
lines.push(`export default __shim[${JSON.stringify("default")}];`);
|
|
2503
|
+
return lines.join("\n");
|
|
2504
|
+
}
|
|
2409
2505
|
if (cleanId.startsWith("\0"))
|
|
2410
2506
|
return null;
|
|
2411
2507
|
if (cleanId.startsWith("node:") || cleanId.startsWith("virtual:") || cleanId.startsWith("vite:") || cleanId.startsWith("/@id/")) {
|
|
@@ -5476,12 +5572,32 @@ function assertNonEmptyString(value, name) {
|
|
|
5476
5572
|
throw new Error(`${name} must be a non-empty string.`);
|
|
5477
5573
|
}
|
|
5478
5574
|
}
|
|
5479
|
-
function
|
|
5575
|
+
function assertRouterModuleShims(value, name) {
|
|
5480
5576
|
if (!value)
|
|
5481
5577
|
return;
|
|
5482
|
-
for (const [
|
|
5483
|
-
assertNonEmptyString(
|
|
5484
|
-
|
|
5578
|
+
for (const [moduleSource, shimDefinition] of Object.entries(value)) {
|
|
5579
|
+
assertNonEmptyString(moduleSource, `${name} key`);
|
|
5580
|
+
if (Array.isArray(shimDefinition)) {
|
|
5581
|
+
if (!shimDefinition.length)
|
|
5582
|
+
throw new TypeError(`${name}[${JSON.stringify(moduleSource)}] must contain at least one export name.`);
|
|
5583
|
+
for (const exportName of shimDefinition) {
|
|
5584
|
+
assertNonEmptyString(exportName, `${name}[${JSON.stringify(moduleSource)}] export`);
|
|
5585
|
+
if (exportName === "*")
|
|
5586
|
+
throw new TypeError(`${name}[${JSON.stringify(moduleSource)}] does not support '*' export wildcard.`);
|
|
5587
|
+
}
|
|
5588
|
+
continue;
|
|
5589
|
+
}
|
|
5590
|
+
const entries = Object.entries(shimDefinition);
|
|
5591
|
+
if (!entries.length)
|
|
5592
|
+
throw new TypeError(`${name}[${JSON.stringify(moduleSource)}] must contain at least one export.`);
|
|
5593
|
+
for (const [exportName, shimValue] of entries) {
|
|
5594
|
+
assertNonEmptyString(exportName, `${name}[${JSON.stringify(moduleSource)}] export`);
|
|
5595
|
+
if (exportName === "*")
|
|
5596
|
+
throw new TypeError(`${name}[${JSON.stringify(moduleSource)}] does not support '*' export wildcard.`);
|
|
5597
|
+
if (typeof shimValue !== "function") {
|
|
5598
|
+
throw new TypeError(`${name}[${JSON.stringify(moduleSource)}][${JSON.stringify(exportName)}] must be a function.`);
|
|
5599
|
+
}
|
|
5600
|
+
}
|
|
5485
5601
|
}
|
|
5486
5602
|
}
|
|
5487
5603
|
function resolveFromProjectRoot(projectRoot, maybePath) {
|
|
@@ -5527,7 +5643,7 @@ function createVuePomGeneratorPlugins(options = {}) {
|
|
|
5527
5643
|
assertNonEmptyString(viewsDir, "[vue-pom-generator] injection.viewsDir");
|
|
5528
5644
|
if (generationEnabled) {
|
|
5529
5645
|
assertNonEmptyString(outDir, "[vue-pom-generator] generation.outDir");
|
|
5530
|
-
|
|
5646
|
+
assertRouterModuleShims(routerModuleShims, "[vue-pom-generator] generation.router.moduleShims");
|
|
5531
5647
|
if (generationOptions?.router && routerType === "vue-router") {
|
|
5532
5648
|
assertNonEmptyString(routerEntry, "[vue-pom-generator] generation.router.entry");
|
|
5533
5649
|
}
|