@immense/vue-pom-generator 1.0.102 → 1.0.104

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 CHANGED
@@ -1,34 +1,17 @@
1
+ The window query shows only #67 (and boundary case #66, which is already part of v1.0.103 since it's
2
+ absent from the compare range). Let me verify the previous tag/release to confirm.
3
+
1
4
  Highlights
2
5
 
3
- - The annotator overlay can now be mounted in configured builds (vite build), not just vite serve
4
- (#65).
5
- - Browser-only safety: the annotator client is explicitly excluded from SSR builds, and SSR
6
- transforms are skipped.
7
- - New packed smoke checks verify the overlay ships in browser bundles, that no Node-only generator
8
- code leaks into them, and that SSR builds stay clean.
6
+ - Scoped leaf POMs are now constructible: generated classes for leaf components reached through
7
+ scoped slots can be instantiated without errors (#67)
9
8
 
10
9
  Changes
11
10
 
12
- Runtime annotator
13
-
14
- - Changed the annotator UI plugin's apply logic so it runs during vite serve or any non-SSR vite
15
- build, instead of the previous serve-only restriction (#65).
16
- - Skipped the annotator transform for SSR requests (transformOptions?.ssr) so the browser-only
17
- client never reaches server bundles (#65).
18
- - Updated option documentation: runtime.annotator and runtime.annotator.ui are no longer described
19
- as dev-only; both vite serve and vite build inject the same browser-side overlay when enabled (#65).
20
-
21
- Documentation
22
-
23
- - Added an "Annotator overlay" section to the README showing how to enable metadata + UI together
24
- in the Vite config, and how to keep it out of production via conditional config (#65).
25
-
26
- Tooling / CI
11
+ Fixed
27
12
 
28
- - Extended the packed smoke check to enable runtime.annotator and assert on built output: the
29
- vpg-annotator-toolbar client must be present in browser assets, Node-only code (createRequire) must
30
- be absent, and an SSR build (vite build --ssr) must neither include the client nor fail to evaluate
31
- its emitted entry (#65).
13
+ - Made scoped leaf POM classes constructible during class generation, so instances of leaf
14
+ components under scoped slots can be created from generated code (#67)
32
15
 
33
16
  Breaking Changes
34
17
 
@@ -36,12 +19,10 @@ None.
36
19
 
37
20
  Pull Requests Included
38
21
 
39
- - #65 fix: mount annotator in configured builds —
40
- ]8;id=md-ba7lo3;https://github.com/immense/vue-pom-generator/pull/65https://github.com/immense/vue-pom-generator/pull/65]8;;
22
+ - #67 — fix: make scoped leaf POMs constructible (]8;id=md-bu6t21;https://github.com/immense/vue-pom-generator/pull/67#67]8;;]8;;) by @dkattan]8;;
41
23
 
42
24
  Testing
43
25
 
44
- - Packed smoke check extended with new assertions: annotator client present in the browser build,
45
- no Node-only generator code in the client, and the SSR build excludes the annotator and evaluates
46
- cleanly.
26
+ - Added a constructibility case to tests/semantic-component-instances.test.ts, alongside the fix in
27
+ class-generation/index.ts (2 files changed, +22/−17).
47
28
 
@@ -2553,12 +2553,20 @@ function prepareViewObjectModelClass(
2553
2553
  const members: TypeScriptClassMember[] = [];
2554
2554
  if (isView && (componentRefsForInstances.size > 0 || attachmentsForThisClass.length > 0 || widgetInstances.length > 0)) {
2555
2555
  members.push(...getComponentInstances(directComponentInstances, projectedComponentInstances, attachmentsForThisClass, widgetInstances));
2556
- members.push(getConstructor(directComponentInstances, attachmentsForThisClass, widgetInstances, { testIdAttribute }));
2557
2556
  }
2558
2557
  if (!isView && (componentRefsForInstances.size > 0 || attachmentsForThisClass.length > 0)) {
2559
2558
  members.push(...getComponentInstances(directComponentInstances, projectedComponentInstances, attachmentsForThisClass));
2560
- members.push(getConstructor(directComponentInstances, attachmentsForThisClass, [], { testIdAttribute }));
2561
2559
  }
2560
+ // Every generated POM can be nested and therefore must accept the locator
2561
+ // passed by its parent's semantic component-instance accessor. Leaf POMs have
2562
+ // no child declarations, but omitting their constructor makes them inherit
2563
+ // BasePage's (page, BasePageOptions) signature and rejects (page, Locator).
2564
+ members.push(getConstructor(
2565
+ directComponentInstances,
2566
+ attachmentsForThisClass,
2567
+ isView ? widgetInstances : [],
2568
+ { testIdAttribute },
2569
+ ));
2562
2570
 
2563
2571
  members.push(
2564
2572
  ...getAttachmentPassthroughMethods(componentName, dependencies, attachmentsForThisClass, reservedAttachmentPassthroughNames),
@@ -2618,15 +2626,12 @@ function generateViewObjectModelContent(
2618
2626
  const basePageImport = path.relative(fromAbs, toAbs).replace(/\\/g, "/");
2619
2627
  const basePageImportNoExt = stripExtension(basePageImport).replace(/\\/g, "/");
2620
2628
  const basePageImportSpecifier = basePageImportNoExt.startsWith(".") ? basePageImportNoExt : `./${basePageImportNoExt}`;
2621
- // Generated POM constructors take Playwright's full `Page` (not the narrowed `PwPage`):
2629
+ // Every generated POM constructor takes Playwright's full `Page` (not the narrowed `PwPage`)
2630
+ // and an optional root locator so any POM, including a leaf, can be nested safely:
2622
2631
  // `BasePage` widens `page` to the full `Page` for subclasses, so generated POMs construct
2623
2632
  // each other with `new Child(this.page)` where `this.page` is `Page`. Importing the
2624
2633
  // standard `Page` from `@playwright/test` keeps the narrowed types internal to the vendored
2625
2634
  // runtime — they never surface in generated output.
2626
- const needsPlaywrightPageImport = prepared.isView
2627
- || prepared.attachmentsForThisClass.length > 0
2628
- || prepared.componentRefsForInstances.size > 0
2629
- || prepared.widgetInstances.length > 0;
2630
2635
  const customPomImportSpecifiersByClass = options.customPomImportSpecifiersByClass ?? {};
2631
2636
 
2632
2637
  const customImports = Array.from(
@@ -2692,16 +2697,14 @@ function generateViewObjectModelContent(
2692
2697
 
2693
2698
  const prefixText = `${buildFilePrefix({ eslintDisableSortImports: true })}${doc}\n`;
2694
2699
  return renderSourceFile(`${prepared.className}.ts`, (sourceFile) => {
2695
- if (needsPlaywrightPageImport) {
2696
- addNamedImport(sourceFile, {
2697
- moduleSpecifier: "@playwright/test",
2698
- isTypeOnly: true,
2699
- namedImports: [
2700
- { name: "Locator", alias: "PwLocator" },
2701
- { name: "Page", alias: "PwPage" },
2702
- ],
2703
- });
2704
- }
2700
+ addNamedImport(sourceFile, {
2701
+ moduleSpecifier: "@playwright/test",
2702
+ isTypeOnly: true,
2703
+ namedImports: [
2704
+ { name: "Locator", alias: "PwLocator" },
2705
+ { name: "Page", alias: "PwPage" },
2706
+ ],
2707
+ });
2705
2708
 
2706
2709
  addNamedImport(sourceFile, {
2707
2710
  moduleSpecifier: basePageImportSpecifier,
package/dist/index.cjs CHANGED
@@ -6946,12 +6946,16 @@ Fix: give direct and slot-projected instances distinct accessible names or seman
6946
6946
  const members = [];
6947
6947
  if (isView && (componentRefsForInstances.size > 0 || attachmentsForThisClass.length > 0 || widgetInstances.length > 0)) {
6948
6948
  members.push(...getComponentInstances(directComponentInstances, projectedComponentInstances, attachmentsForThisClass, widgetInstances));
6949
- members.push(getConstructor(directComponentInstances, attachmentsForThisClass, widgetInstances, { testIdAttribute }));
6950
6949
  }
6951
6950
  if (!isView && (componentRefsForInstances.size > 0 || attachmentsForThisClass.length > 0)) {
6952
6951
  members.push(...getComponentInstances(directComponentInstances, projectedComponentInstances, attachmentsForThisClass));
6953
- members.push(getConstructor(directComponentInstances, attachmentsForThisClass, [], { testIdAttribute }));
6954
6952
  }
6953
+ members.push(getConstructor(
6954
+ directComponentInstances,
6955
+ attachmentsForThisClass,
6956
+ isView ? widgetInstances : [],
6957
+ { testIdAttribute }
6958
+ ));
6955
6959
  members.push(
6956
6960
  ...getAttachmentPassthroughMethods(componentName, dependencies, attachmentsForThisClass, reservedAttachmentPassthroughNames)
6957
6961
  );
@@ -6996,7 +7000,6 @@ function generateViewObjectModelContent(componentName, dependencies, componentHi
6996
7000
  const basePageImport = path.relative(fromAbs, toAbs).replace(/\\/g, "/");
6997
7001
  const basePageImportNoExt = stripExtension(basePageImport).replace(/\\/g, "/");
6998
7002
  const basePageImportSpecifier = basePageImportNoExt.startsWith(".") ? basePageImportNoExt : `./${basePageImportNoExt}`;
6999
- const needsPlaywrightPageImport = prepared.isView || prepared.attachmentsForThisClass.length > 0 || prepared.componentRefsForInstances.size > 0 || prepared.widgetInstances.length > 0;
7000
7003
  const customPomImportSpecifiersByClass = options.customPomImportSpecifiersByClass ?? {};
7001
7004
  const customImports = Array.from(
7002
7005
  /* @__PURE__ */ new Set([
@@ -7048,16 +7051,14 @@ function generateViewObjectModelContent(componentName, dependencies, componentHi
7048
7051
  const prefixText = `${buildFilePrefix({ eslintDisableSortImports: true })}${doc}
7049
7052
  `;
7050
7053
  return renderSourceFile(`${prepared.className}.ts`, (sourceFile) => {
7051
- if (needsPlaywrightPageImport) {
7052
- addNamedImport(sourceFile, {
7053
- moduleSpecifier: "@playwright/test",
7054
- isTypeOnly: true,
7055
- namedImports: [
7056
- { name: "Locator", alias: "PwLocator" },
7057
- { name: "Page", alias: "PwPage" }
7058
- ]
7059
- });
7060
- }
7054
+ addNamedImport(sourceFile, {
7055
+ moduleSpecifier: "@playwright/test",
7056
+ isTypeOnly: true,
7057
+ namedImports: [
7058
+ { name: "Locator", alias: "PwLocator" },
7059
+ { name: "Page", alias: "PwPage" }
7060
+ ]
7061
+ });
7061
7062
  addNamedImport(sourceFile, {
7062
7063
  moduleSpecifier: basePageImportSpecifier,
7063
7064
  namedImports: ["BasePage", "Fluent"]
@@ -11032,17 +11033,20 @@ ${code}`,
11032
11033
  map: null
11033
11034
  };
11034
11035
  },
11035
- transformIndexHtml() {
11036
- if (!options.enabled) {
11037
- return void 0;
11036
+ transformIndexHtml: {
11037
+ order: "pre",
11038
+ handler() {
11039
+ if (!options.enabled) {
11040
+ return void 0;
11041
+ }
11042
+ const tag = {
11043
+ tag: "script",
11044
+ attrs: { type: "module" },
11045
+ children: `import ${JSON.stringify(ANNOTATOR_CLIENT_VIRTUAL_ID)};`,
11046
+ injectTo: "body"
11047
+ };
11048
+ return [tag];
11038
11049
  }
11039
- const tag = {
11040
- tag: "script",
11041
- attrs: { type: "module" },
11042
- children: `import ${JSON.stringify(ANNOTATOR_CLIENT_VIRTUAL_ID)};`,
11043
- injectTo: "body"
11044
- };
11045
- return [tag];
11046
11050
  }
11047
11051
  };
11048
11052
  }