@vizejs/nuxt 0.497.0 → 0.499.0

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.
Files changed (2) hide show
  1. package/dist/index.mjs +29 -3
  2. package/package.json +7 -7
package/dist/index.mjs CHANGED
@@ -439,6 +439,29 @@ function collectPatternBindingNames(pattern, locals) {
439
439
  }
440
440
  for (const child of getChildNodes(pattern)) collectPatternBindingNames(child, locals);
441
441
  }
442
+ function collectDirectBindingNames(scope, locals) {
443
+ const statements = Array.isArray(scope.body) ? scope.body : [];
444
+ for (const statement of statements) {
445
+ if (!isNode(statement)) continue;
446
+ if (statement.type === "VariableDeclaration") {
447
+ const declarations = Array.isArray(statement.declarations) ? statement.declarations : [];
448
+ for (const declaration of declarations) if (isNode(declaration) && isNode(declaration.id)) collectPatternBindingNames(declaration.id, locals);
449
+ continue;
450
+ }
451
+ if (statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") {
452
+ const name = getNodeName(isNode(statement.id) ? statement.id : null);
453
+ if (name) locals.add(name);
454
+ continue;
455
+ }
456
+ if (statement.type === "ImportDeclaration") {
457
+ const specifiers = Array.isArray(statement.specifiers) ? statement.specifiers : [];
458
+ for (const specifier of specifiers) {
459
+ const name = isNode(specifier) ? getNodeName(isNode(specifier.local) ? specifier.local : null) : null;
460
+ if (name) locals.add(name);
461
+ }
462
+ }
463
+ }
464
+ }
442
465
  function findExistingUseI18nDestructure(setupBody) {
443
466
  const statements = Array.isArray(setupBody.body) ? setupBody.body : [];
444
467
  for (const statement of statements) {
@@ -458,13 +481,13 @@ function findExistingUseI18nDestructure(setupBody) {
458
481
  }
459
482
  return null;
460
483
  }
461
- function collectUsedI18nSpecifiers(setupBody) {
484
+ function collectUsedI18nSpecifiers(setupBody, authoredBindings) {
462
485
  const used = /* @__PURE__ */ new Map();
463
486
  walkNode(setupBody, (node) => {
464
487
  if (node.type !== "CallExpression") return;
465
488
  const fnName = getNodeName(isNode(node.callee) ? node.callee : null);
466
489
  const callStart = getNodeStart(node);
467
- if (!fnName || callStart == null || !I18N_HELPER_LOCALS.has(fnName)) return;
490
+ if (!fnName || callStart == null || !I18N_HELPER_LOCALS.has(fnName) || authoredBindings.has(fnName)) return;
468
491
  if (!used.has(fnName)) used.set(fnName, callStart);
469
492
  });
470
493
  const helpers = Array.from(used.entries()).sort((a, b) => a[1] - b[1]);
@@ -480,7 +503,10 @@ function injectNuxtI18nHelpers(code, id = DEFAULT_PARSE_ID) {
480
503
  const setupBodyStart = setupBody ? getNodeStart(setupBody) : null;
481
504
  if (!setupBody || setupBodyStart == null) return code;
482
505
  const insertAt = setupBodyStart + 1;
483
- const { firstUseIndex, specifiers: usedSpecifiers } = collectUsedI18nSpecifiers(setupBody);
506
+ const authoredBindings = /* @__PURE__ */ new Set();
507
+ collectDirectBindingNames(program, authoredBindings);
508
+ collectDirectBindingNames(setupBody, authoredBindings);
509
+ const { firstUseIndex, specifiers: usedSpecifiers } = collectUsedI18nSpecifiers(setupBody, authoredBindings);
484
510
  if (usedSpecifiers.length === 0) return code;
485
511
  const existing = findExistingUseI18nDestructure(setupBody);
486
512
  if (existing) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/nuxt",
3
- "version": "0.497.0",
3
+ "version": "0.499.0",
4
4
  "description": "Nuxt module for Vize - compiler, musea gallery, linter, and type checker",
5
5
  "keywords": [
6
6
  "compiler",
@@ -49,12 +49,12 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@nuxt/kit": "3.11.2",
52
- "@vizejs/native": "0.497.0",
53
- "@vizejs/nuxt-lint-config": "0.497.0",
54
- "@vizejs/vite-plugin": "0.497.0",
55
- "@vizejs/vite-plugin-musea": "0.497.0",
56
- "oxlint-plugin-vize": "0.497.0",
57
- "vize": "0.497.0"
52
+ "@vizejs/native": "0.499.0",
53
+ "@vizejs/nuxt-lint-config": "0.499.0",
54
+ "@vizejs/vite-plugin": "0.499.0",
55
+ "@vizejs/vite-plugin-musea": "0.499.0",
56
+ "oxlint-plugin-vize": "0.499.0",
57
+ "vize": "0.499.0"
58
58
  },
59
59
  "devDependencies": {
60
60
  "jiti-nuxt2": "npm:jiti@1.21.7",