@immense/vue-pom-generator 1.0.50 → 1.0.52

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/dist/index.mjs CHANGED
@@ -728,7 +728,14 @@ function getTemplateSlotScope(node) {
728
728
  return null;
729
729
  }
730
730
  function isSimpleScopeIdentifier(value) {
731
- return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(value);
731
+ if (!value) {
732
+ return false;
733
+ }
734
+ try {
735
+ return isIdentifier(parseExpression(value, { plugins: ["typescript"] }));
736
+ } catch {
737
+ return false;
738
+ }
732
739
  }
733
740
  function buildSlotScopeFallbackKeyExpression(identifier) {
734
741
  return `${identifier}.key ?? ${identifier}.data?.id ?? ${identifier}.id ?? ${identifier}.value ?? ${identifier}`;
@@ -748,6 +755,29 @@ function tryGetBindingIdentifierName(node) {
748
755
  }
749
756
  return null;
750
757
  }
758
+ function splitNullishCoalescingExpression(expr) {
759
+ const ast = parseExpression(expr, { plugins: ["typescript"] });
760
+ const toSourceText = (node) => {
761
+ if (node.start == null || node.end == null) {
762
+ throw new Error("[vue-pom-generator] Unable to recover source for nullish-coalescing expression.");
763
+ }
764
+ return expr.slice(node.start, node.end).trim();
765
+ };
766
+ const parts = [];
767
+ const visit = (node) => {
768
+ if (isLogicalExpression(node) && node.operator === "??") {
769
+ visit(node.left);
770
+ visit(node.right);
771
+ return;
772
+ }
773
+ const candidate = toSourceText(node);
774
+ if (candidate) {
775
+ parts.push(candidate);
776
+ }
777
+ };
778
+ visit(ast);
779
+ return parts;
780
+ }
751
781
  function getSlotScopeObjectPropertyKeyName(node) {
752
782
  if (isIdentifier(node)) {
753
783
  return node.name;
@@ -2004,7 +2034,7 @@ function applyResolvedDataTestId(args) {
2004
2034
  if (!expr) {
2005
2035
  return [];
2006
2036
  }
2007
- return expr.split("??").map((part) => part.trim()).filter(Boolean);
2037
+ return splitNullishCoalescingExpression(expr);
2008
2038
  };
2009
2039
  let dataTestId = args.preferredGeneratedValue;
2010
2040
  let fromExisting = false;
@@ -7947,6 +7977,26 @@ function createVuePomGeneratorPlugins(options = {}) {
7947
7977
  const loggerRef = {
7948
7978
  current: createLogger({ verbosity })
7949
7979
  };
7980
+ const getViewsDirAbs = () => resolveFromProjectRoot(projectRootRef.current, viewsDir);
7981
+ const getWrapperSearchRootsAbs = () => wrapperSearchRoots.map((root) => resolveFromProjectRoot(projectRootRef.current, root));
7982
+ const { componentTestIds, elementMetadata, semanticNameMap, componentHierarchyMap, vueFilesPathMap } = sharedState;
7983
+ const { metadataCollectorPlugin, internalVuePlugin, templateCompilerOptions } = createVuePluginWithTestIds({
7984
+ vueOptions,
7985
+ existingIdBehavior,
7986
+ nameCollisionBehavior,
7987
+ nativeWrappers,
7988
+ elementMetadata,
7989
+ semanticNameMap,
7990
+ componentHierarchyMap,
7991
+ vueFilesPathMap,
7992
+ excludedComponents,
7993
+ getViewsDirAbs,
7994
+ testIdAttribute,
7995
+ loggerRef,
7996
+ scanDirs,
7997
+ getWrapperSearchRoots: getWrapperSearchRootsAbs,
7998
+ getProjectRoot: () => projectRootRef.current
7999
+ });
7950
8000
  const configPlugin = {
7951
8001
  name: "vue-pom-generator-config",
7952
8002
  enforce: "pre",
@@ -7972,26 +8022,6 @@ function createVuePomGeneratorPlugins(options = {}) {
7972
8022
  loggerRef.current.info(`Active plugins: ${(config.plugins ?? []).map((p) => p.name).filter((n) => n.includes("vue-pom")).join(", ")}`);
7973
8023
  }
7974
8024
  };
7975
- const getViewsDirAbs = () => resolveFromProjectRoot(projectRootRef.current, viewsDir);
7976
- const getWrapperSearchRootsAbs = () => wrapperSearchRoots.map((root) => resolveFromProjectRoot(projectRootRef.current, root));
7977
- const { componentTestIds, elementMetadata, semanticNameMap, componentHierarchyMap, vueFilesPathMap } = sharedState;
7978
- const { metadataCollectorPlugin, internalVuePlugin, templateCompilerOptions } = createVuePluginWithTestIds({
7979
- vueOptions,
7980
- existingIdBehavior,
7981
- nameCollisionBehavior,
7982
- nativeWrappers,
7983
- elementMetadata,
7984
- semanticNameMap,
7985
- componentHierarchyMap,
7986
- vueFilesPathMap,
7987
- excludedComponents,
7988
- getViewsDirAbs,
7989
- testIdAttribute,
7990
- loggerRef,
7991
- scanDirs,
7992
- getWrapperSearchRoots: getWrapperSearchRootsAbs,
7993
- getProjectRoot: () => projectRootRef.current
7994
- });
7995
8025
  const routerAwarePoms = typeof routerEntry === "string" && routerEntry.trim().length > 0 || routerType === "nuxt";
7996
8026
  const supportPlugins = createSupportPlugins({
7997
8027
  componentTestIds,