@vizejs/nuxt 0.289.0 → 0.291.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 +25 -11
  2. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -534,6 +534,28 @@ function normalizeMuseaBasePath(basePath) {
534
534
  return normalized ? `/${normalized}` : "/";
535
535
  }
536
536
  //#endregion
537
+ //#region src/bridge-fast-path.ts
538
+ const VUE_CLIENT_RUNTIME_IMPORT = "vue/dist/vue.runtime.esm-bundler.js";
539
+ const COMPONENT_BRIDGE_RE = /(?:_?resolveComponent\s*\(|from\s+(["'])#components\1)/;
540
+ const I18N_BRIDGE_RE = /\b(?:\$t|\$rt|\$d|\$n|\$tm|\$te)\s*\(/;
541
+ const STABLE_KEY_BRIDGE_RE = /\b(?:useFetch|useLazyFetch)\s*\(|\/\*\s*nuxt-injected\s*\*\//;
542
+ function hasComponentBridgeInput(code) {
543
+ return COMPONENT_BRIDGE_RE.test(code);
544
+ }
545
+ function hasI18nBridgeInput(code) {
546
+ return I18N_BRIDGE_RE.test(code);
547
+ }
548
+ function hasStableKeyBridgeInput(code) {
549
+ return STABLE_KEY_BRIDGE_RE.test(code);
550
+ }
551
+ function rewriteBareVueImportsToClientRuntime(code) {
552
+ return code.replace(/(\bfrom\s*)(["'])vue\2/g, (_, prefix, quote) => {
553
+ return `${prefix}${quote}${VUE_CLIENT_RUNTIME_IMPORT}${quote}`;
554
+ }).replace(/(\bimport\s*)(["'])vue\2/g, (_, prefix, quote) => {
555
+ return `${prefix}${quote}${VUE_CLIENT_RUNTIME_IMPORT}${quote}`;
556
+ });
557
+ }
558
+ //#endregion
537
559
  //#region src/utils.ts
538
560
  const NUXT_OG_IMAGE_RENDERER_SFC_EXCLUDE = /\.takumi\.vue(?:\?|$)/;
539
561
  function normalizeUrlPrefix(value) {
@@ -871,7 +893,6 @@ const VUE_RUNTIME_DEDUPE = [
871
893
  "@vue/runtime-dom",
872
894
  "@vue/shared"
873
895
  ];
874
- const VUE_CLIENT_RUNTIME_IMPORT = "vue/dist/vue.runtime.esm-bundler.js";
875
896
  const moduleMeta = {
876
897
  name: "@vizejs/nuxt",
877
898
  configKey: "vize"
@@ -952,13 +973,6 @@ function isViteSsrTransform(args) {
952
973
  const options = args[0];
953
974
  return typeof options === "object" && options !== null && "ssr" in options && options.ssr === true;
954
975
  }
955
- function rewriteBareVueImportsToClientRuntime(code) {
956
- return code.replace(/(\bfrom\s*)(["'])vue\2/g, (_, prefix, quote) => {
957
- return `${prefix}${quote}${VUE_CLIENT_RUNTIME_IMPORT}${quote}`;
958
- }).replace(/(\bimport\s*)(["'])vue\2/g, (_, prefix, quote) => {
959
- return `${prefix}${quote}${VUE_CLIENT_RUNTIME_IMPORT}${quote}`;
960
- });
961
- }
962
976
  function normalizeNuxtKeyedTransformResult(id, result) {
963
977
  if (!isVizeVirtualVueModuleId(id) || result == null) return result;
964
978
  if (typeof result === "string") return normalizeNuxtInjectedKeysForVizeVirtualModule(result, id);
@@ -1089,7 +1103,7 @@ async function setupVizeNuxtModule(options, nuxt) {
1089
1103
  if (!isVizeGeneratedVueModuleId(id) && !isVizeJsxModuleId(id)) return;
1090
1104
  let result = code;
1091
1105
  let changed = false;
1092
- if (nuxtComponentResolver) {
1106
+ if (nuxtComponentResolver && hasComponentBridgeInput(result)) {
1093
1107
  const nextComponentResult = injectNuxtComponentImports(result, (name) => {
1094
1108
  return nuxtComponentResolver.resolve(name);
1095
1109
  });
@@ -1098,7 +1112,7 @@ async function setupVizeNuxtModule(options, nuxt) {
1098
1112
  changed = true;
1099
1113
  }
1100
1114
  }
1101
- if (bridgeOptions.i18n) {
1115
+ if (bridgeOptions.i18n && hasI18nBridgeInput(result)) {
1102
1116
  const nextResult = injectNuxtI18nHelpers(result, id);
1103
1117
  if (nextResult !== result) {
1104
1118
  result = nextResult;
@@ -1120,7 +1134,7 @@ async function setupVizeNuxtModule(options, nuxt) {
1120
1134
  changed = true;
1121
1135
  }
1122
1136
  }
1123
- if (bridgeOptions.stableInjectedKeys) {
1137
+ if (bridgeOptions.stableInjectedKeys && hasStableKeyBridgeInput(result)) {
1124
1138
  const stableKeyResult = stabilizeNuxtInjectedKeysForVizeVirtualModule(result, id);
1125
1139
  if (stableKeyResult !== result) {
1126
1140
  result = stableKeyResult;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/nuxt",
3
- "version": "0.289.0",
3
+ "version": "0.291.0",
4
4
  "description": "Nuxt module for Vize - compiler, musea gallery, linter, and type checker",
5
5
  "keywords": [
6
6
  "compiler",
@@ -42,9 +42,9 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@nuxt/kit": "3.11.2",
45
- "@vizejs/vite-plugin": "0.289.0",
46
- "@vizejs/vite-plugin-musea": "0.289.0",
47
- "vize": "0.289.0"
45
+ "@vizejs/vite-plugin": "0.291.0",
46
+ "@vizejs/vite-plugin-musea": "0.291.0",
47
+ "vize": "0.291.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "typescript": "6.0.3",