@nuxt/bridge-edge 3.0.0-27447057.13dd2b9 → 3.0.0-27449775.cff2f37
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/chunks/module.mjs +917 -231
- package/dist/chunks/module2.mjs +1 -1
- package/dist/chunks/vite.mjs +1 -0
- package/dist/module.mjs +1 -0
- package/package.json +6 -5
package/dist/chunks/module.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire } from 'module';
|
|
2
|
-
import { useNuxt, addPluginTemplate, resolveModule, extendWebpackConfig, addTemplate, resolveAlias, addVitePlugin, addWebpackPlugin, resolveFiles, defineNuxtModule, installModule, isNuxt3, addPlugin, nuxtCtx, checkNuxtCompatibility } from '@nuxt/kit';
|
|
3
|
-
import fs, { existsSync, readdirSync, statSync, promises } from 'fs';
|
|
2
|
+
import { useNuxt, addPluginTemplate, resolveModule as resolveModule$1, extendWebpackConfig, addTemplate, resolveAlias, addVitePlugin, addWebpackPlugin, resolveFiles, defineNuxtModule, logger, installModule, isNuxt3, addPlugin, nuxtCtx, checkNuxtCompatibility } from '@nuxt/kit';
|
|
3
|
+
import fs, { existsSync, readdirSync, statSync, promises, readFileSync } from 'fs';
|
|
4
4
|
import fetch from 'node-fetch';
|
|
5
5
|
import fse from 'fs-extra';
|
|
6
6
|
import { joinURL, stringifyQuery, withoutTrailingSlash, parseURL, parseQuery } from 'ufo';
|
|
@@ -8,7 +8,8 @@ import { dirname, join as join$1, resolve, isAbsolute, relative, parse as parse$
|
|
|
8
8
|
import { getNitroContext, resolveMiddleware, scanMiddleware, writeTypes, build, prepare, generate, wpfs, createDevServer } from '@nuxt/nitro';
|
|
9
9
|
import { fileURLToPath } from 'url';
|
|
10
10
|
import { join } from 'path';
|
|
11
|
-
import { genDynamicImport, genString
|
|
11
|
+
import { genDynamicImport, genString } from 'knitwork';
|
|
12
|
+
import { generateTypes, resolveSchema } from 'untyped';
|
|
12
13
|
import escapeRE from 'escape-string-regexp';
|
|
13
14
|
import crypto from 'crypto';
|
|
14
15
|
import { createUnplugin } from 'unplugin';
|
|
@@ -19,7 +20,7 @@ import { promisify } from 'util';
|
|
|
19
20
|
import defu from 'defu';
|
|
20
21
|
import enhancedResolve from 'enhanced-resolve';
|
|
21
22
|
import * as CompositionApi from '@vue/composition-api';
|
|
22
|
-
import { findExports } from 'mlly';
|
|
23
|
+
import { detectSyntax, findStaticImports, parseStaticImport, findExports } from 'mlly';
|
|
23
24
|
import { camelCase } from 'scule';
|
|
24
25
|
import scriptSetupPlugin from 'unplugin-vue2-script-setup/nuxt';
|
|
25
26
|
|
|
@@ -386,6 +387,21 @@ const schemaTemplate = {
|
|
|
386
387
|
" interface NuxtConfig {",
|
|
387
388
|
...moduleInfo.filter(Boolean).map((meta) => ` [${genString(meta.configKey)}]?: typeof ${genDynamicImport(meta.importName, { wrapper: false })}.default extends NuxtModule<infer O> ? Partial<O> : Record<string, any>`),
|
|
388
389
|
" }",
|
|
390
|
+
generateTypes(resolveSchema(nuxt.options.publicRuntimeConfig), {
|
|
391
|
+
interfaceName: "PublicRuntimeConfig",
|
|
392
|
+
addExport: false,
|
|
393
|
+
addDefaults: false,
|
|
394
|
+
allowExtraKeys: false,
|
|
395
|
+
indentation: 2
|
|
396
|
+
}),
|
|
397
|
+
generateTypes(resolveSchema(nuxt.options.privateRuntimeConfig), {
|
|
398
|
+
interfaceName: "PrivateRuntimeConfig",
|
|
399
|
+
addExport: false,
|
|
400
|
+
addDefaults: false,
|
|
401
|
+
indentation: 2,
|
|
402
|
+
allowExtraKeys: false,
|
|
403
|
+
defaultDescrption: "This value is only accessible from server-side."
|
|
404
|
+
}),
|
|
389
405
|
"}"
|
|
390
406
|
].join("\n");
|
|
391
407
|
}
|
|
@@ -402,8 +418,8 @@ function setupAppBridge(_options) {
|
|
|
402
418
|
builder.bundleBuilder.build = () => Promise.resolve(builder.bundleBuilder);
|
|
403
419
|
});
|
|
404
420
|
}
|
|
405
|
-
const vue2ESM = resolveModule("vue/dist/vue.runtime.esm.js", { paths: nuxt.options.modulesDir });
|
|
406
|
-
const vue2CJS = resolveModule("vue/dist/vue.runtime.common.js", { paths: nuxt.options.modulesDir });
|
|
421
|
+
const vue2ESM = resolveModule$1("vue/dist/vue.runtime.esm.js", { paths: nuxt.options.modulesDir });
|
|
422
|
+
const vue2CJS = resolveModule$1("vue/dist/vue.runtime.common.js", { paths: nuxt.options.modulesDir });
|
|
407
423
|
nuxt.options.alias.vue2 = vue2ESM;
|
|
408
424
|
nuxt.options.build.transpile.push("vue");
|
|
409
425
|
extendWebpackConfig((config) => {
|
|
@@ -644,35 +660,14 @@ function setupBetterResolve() {
|
|
|
644
660
|
});
|
|
645
661
|
}
|
|
646
662
|
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
map[autoImport.from] = /* @__PURE__ */ new Set();
|
|
653
|
-
}
|
|
654
|
-
map[autoImport.from].add(autoImport.name === autoImport.as ? autoImport.name : autoImport.name + aliasKeyword + autoImport.as);
|
|
655
|
-
}
|
|
656
|
-
return map;
|
|
657
|
-
}
|
|
658
|
-
function toImports(autoImports, isCJS = false) {
|
|
659
|
-
const map = toImportModuleMap(autoImports, isCJS);
|
|
660
|
-
if (isCJS) {
|
|
661
|
-
return Object.entries(map).map(([name, imports]) => `const { ${Array.from(imports).join(", ")} } = require(${genString(name)});`).join("\n");
|
|
662
|
-
} else {
|
|
663
|
-
return Object.entries(map).map(([name, imports]) => genImport(name, Array.from(imports))).join("\n");
|
|
663
|
+
const _require = createRequire(import.meta.url);
|
|
664
|
+
|
|
665
|
+
function resolveModule(name, options) {
|
|
666
|
+
try {
|
|
667
|
+
return _require.resolve(name, options)
|
|
664
668
|
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
const map = toImportModuleMap(autoImports, false);
|
|
668
|
-
return Object.entries(map).map(([name, imports]) => genExport(name, Array.from(imports))).join("\n");
|
|
669
|
-
}
|
|
670
|
-
function filterInPlace(arr, predicate) {
|
|
671
|
-
let i = arr.length;
|
|
672
|
-
while (i--) {
|
|
673
|
-
if (!predicate(arr[i])) {
|
|
674
|
-
arr.splice(i, 1);
|
|
675
|
-
}
|
|
669
|
+
catch (e) {
|
|
670
|
+
return undefined
|
|
676
671
|
}
|
|
677
672
|
}
|
|
678
673
|
|
|
@@ -690,17 +685,721 @@ const quotesRE = [
|
|
|
690
685
|
/(["'])((?:\\\1|(?!\1)|.|\r)*?)\1/gm,
|
|
691
686
|
/([`])((?:\\\1|(?!\1)|.|\n|\r)*?)\1/gm
|
|
692
687
|
];
|
|
688
|
+
function defineUnimportPreset(preset) {
|
|
689
|
+
return preset;
|
|
690
|
+
}
|
|
693
691
|
function stripCommentsAndStrings(code) {
|
|
694
692
|
return code.replace(multilineCommentsRE, "").replace(singlelineCommentsRE, "").replace(templateLiteralRE, "` + $1 + `").replace(quotesRE[0], '""').replace(quotesRE[1], "``");
|
|
695
693
|
}
|
|
696
|
-
|
|
694
|
+
function toImports(imports, isCJS = false) {
|
|
695
|
+
const map = toImportModuleMap(imports);
|
|
696
|
+
return Object.entries(map).flatMap(([name, importSet]) => {
|
|
697
|
+
const entries = [];
|
|
698
|
+
const imports2 = Array.from(importSet).filter((i) => {
|
|
699
|
+
if (i.name === "default") {
|
|
700
|
+
entries.push(isCJS ? `const { default: ${i.as} } = require('${name}');` : `import ${i.as} from '${name}';`);
|
|
701
|
+
return false;
|
|
702
|
+
} else if (i.name === "*") {
|
|
703
|
+
entries.push(isCJS ? `const ${i.as} = require('${name}');` : `import * as ${i.as} from '${name}';`);
|
|
704
|
+
return false;
|
|
705
|
+
}
|
|
706
|
+
return true;
|
|
707
|
+
});
|
|
708
|
+
if (imports2.length) {
|
|
709
|
+
const importsAs = imports2.map((i) => stringifyImportAlias(i, isCJS));
|
|
710
|
+
entries.push(isCJS ? `const { ${importsAs.join(", ")} } = require('${name}');` : `import { ${importsAs.join(", ")} } from '${name}';`);
|
|
711
|
+
}
|
|
712
|
+
return entries;
|
|
713
|
+
}).join("\n");
|
|
714
|
+
}
|
|
715
|
+
function dedupeImports(imports, warn) {
|
|
716
|
+
const map = /* @__PURE__ */ new Map();
|
|
717
|
+
const indexToRemove = /* @__PURE__ */ new Set();
|
|
718
|
+
imports.forEach((i, idx) => {
|
|
719
|
+
const name = i.as || i.name;
|
|
720
|
+
if (!map.has(name)) {
|
|
721
|
+
map.set(name, idx);
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
const other = imports[map.get(name)];
|
|
725
|
+
const diff = (other.priority || 1) - (i.priority || 1);
|
|
726
|
+
if (diff === 0) {
|
|
727
|
+
warn(`Duplicated imports "${name}", the one from "${other.from}" has been ignored`);
|
|
728
|
+
}
|
|
729
|
+
if (diff <= 0) {
|
|
730
|
+
indexToRemove.add(map.get(name));
|
|
731
|
+
map.set(name, idx);
|
|
732
|
+
} else {
|
|
733
|
+
indexToRemove.add(idx);
|
|
734
|
+
}
|
|
735
|
+
});
|
|
736
|
+
return imports.filter((_, idx) => !indexToRemove.has(idx));
|
|
737
|
+
}
|
|
738
|
+
function toExports(imports) {
|
|
739
|
+
const map = toImportModuleMap(imports);
|
|
740
|
+
return Object.entries(map).flatMap(([name, imports2]) => {
|
|
741
|
+
const entries = [];
|
|
742
|
+
const filtered = Array.from(imports2).filter((i) => {
|
|
743
|
+
if (i.name === "*") {
|
|
744
|
+
entries.push(`export * as ${i.as} from '${name}';`);
|
|
745
|
+
return false;
|
|
746
|
+
}
|
|
747
|
+
return true;
|
|
748
|
+
});
|
|
749
|
+
if (filtered.length) {
|
|
750
|
+
entries.push(`export { ${filtered.map((i) => stringifyImportAlias(i, false)).join(", ")} } from '${name}';`);
|
|
751
|
+
}
|
|
752
|
+
return entries;
|
|
753
|
+
}).join("\n");
|
|
754
|
+
}
|
|
755
|
+
function toTypeDeclrationItems(imports, resolvePath) {
|
|
756
|
+
return imports.map((i) => {
|
|
757
|
+
const from = resolvePath?.(i) || i.from;
|
|
758
|
+
return `const ${i.as}: typeof import('${from}')${i.name !== "*" ? `['${i.name}']` : ""}`;
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
function toTypeDeclrationFile(imports, resolvePath) {
|
|
762
|
+
const items = toTypeDeclrationItems(imports, resolvePath);
|
|
763
|
+
return "declare global {\n" + items.map((i) => " " + i).join("\n") + "\n}\nexport default {}";
|
|
764
|
+
}
|
|
765
|
+
function stringifyImportAlias(item, isCJS = false) {
|
|
766
|
+
return item.as === void 0 || item.name === item.as ? item.name : isCJS ? `${item.name}: ${item.as}` : `${item.name} as ${item.as}`;
|
|
767
|
+
}
|
|
768
|
+
function toImportModuleMap(imports) {
|
|
769
|
+
const map = {};
|
|
770
|
+
for (const _import of imports) {
|
|
771
|
+
if (!map[_import.from]) {
|
|
772
|
+
map[_import.from] = /* @__PURE__ */ new Set();
|
|
773
|
+
}
|
|
774
|
+
map[_import.from].add(_import);
|
|
775
|
+
}
|
|
776
|
+
return map;
|
|
777
|
+
}
|
|
778
|
+
function addImportToCode(code, imports, isCJS = false, mergeExisting = false) {
|
|
779
|
+
let newImports = [];
|
|
780
|
+
const s = new MagicString(code);
|
|
781
|
+
if (mergeExisting && !isCJS) {
|
|
782
|
+
const existing = findStaticImports(code).map((i) => parseStaticImport(i));
|
|
783
|
+
const map = /* @__PURE__ */ new Map();
|
|
784
|
+
imports.forEach((i) => {
|
|
785
|
+
const target = existing.find((e) => e.specifier === i.from && e.imports.startsWith("{"));
|
|
786
|
+
if (!target) {
|
|
787
|
+
return newImports.push(i);
|
|
788
|
+
}
|
|
789
|
+
if (!map.has(target)) {
|
|
790
|
+
map.set(target, []);
|
|
791
|
+
}
|
|
792
|
+
map.get(target).push(i);
|
|
793
|
+
});
|
|
794
|
+
for (const [target, items] of map.entries()) {
|
|
795
|
+
const strings = items.map((i) => stringifyImportAlias(i) + ", ");
|
|
796
|
+
s.appendLeft(target.start + target.code.match(/^\s*import\s*{/)[0].length, " " + strings.join("").trim());
|
|
797
|
+
}
|
|
798
|
+
} else {
|
|
799
|
+
newImports = imports;
|
|
800
|
+
}
|
|
801
|
+
const newEntries = toImports(newImports, isCJS);
|
|
802
|
+
if (newEntries) {
|
|
803
|
+
s.prepend(newEntries);
|
|
804
|
+
}
|
|
805
|
+
return {
|
|
806
|
+
s,
|
|
807
|
+
code: s.toString()
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
function normalizeImports(imports) {
|
|
811
|
+
for (const _import of imports) {
|
|
812
|
+
_import.as = _import.as || _import.name;
|
|
813
|
+
}
|
|
814
|
+
return imports;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
const pinia = defineUnimportPreset({
|
|
818
|
+
from: "pinia",
|
|
819
|
+
imports: [
|
|
820
|
+
"acceptHMRUpdate",
|
|
821
|
+
"createPinia",
|
|
822
|
+
"defineStore",
|
|
823
|
+
"getActivePinia",
|
|
824
|
+
"mapActions",
|
|
825
|
+
"mapGetters",
|
|
826
|
+
"mapState",
|
|
827
|
+
"mapStores",
|
|
828
|
+
"mapWritableState",
|
|
829
|
+
"setActivePinia",
|
|
830
|
+
"setMapStoreSuffix",
|
|
831
|
+
"storeToRefs"
|
|
832
|
+
]
|
|
833
|
+
});
|
|
834
|
+
|
|
835
|
+
const preact = defineUnimportPreset({
|
|
836
|
+
from: "preact",
|
|
837
|
+
imports: [
|
|
838
|
+
"useState",
|
|
839
|
+
"useCallback",
|
|
840
|
+
"useMemo",
|
|
841
|
+
"useEffect",
|
|
842
|
+
"useRef",
|
|
843
|
+
"useContext",
|
|
844
|
+
"useReducer"
|
|
845
|
+
]
|
|
846
|
+
});
|
|
847
|
+
|
|
848
|
+
const quasar = defineUnimportPreset({
|
|
849
|
+
from: "quasar",
|
|
850
|
+
imports: [
|
|
851
|
+
"useQuasar",
|
|
852
|
+
"useDialogPluginComponent",
|
|
853
|
+
"useFormChild",
|
|
854
|
+
"useMeta"
|
|
855
|
+
]
|
|
856
|
+
});
|
|
857
|
+
|
|
858
|
+
const react = defineUnimportPreset({
|
|
859
|
+
from: "react",
|
|
860
|
+
imports: [
|
|
861
|
+
"useState",
|
|
862
|
+
"useCallback",
|
|
863
|
+
"useMemo",
|
|
864
|
+
"useEffect",
|
|
865
|
+
"useRef",
|
|
866
|
+
"useContext",
|
|
867
|
+
"useReducer"
|
|
868
|
+
]
|
|
869
|
+
});
|
|
870
|
+
|
|
871
|
+
const ReactRouterHooks = [
|
|
872
|
+
"useOutletContext",
|
|
873
|
+
"useHref",
|
|
874
|
+
"useInRouterContext",
|
|
875
|
+
"useLocation",
|
|
876
|
+
"useNavigationType",
|
|
877
|
+
"useNavigate",
|
|
878
|
+
"useOutlet",
|
|
879
|
+
"useParams",
|
|
880
|
+
"useResolvedPath",
|
|
881
|
+
"useRoutes"
|
|
882
|
+
];
|
|
883
|
+
const reactRouter = defineUnimportPreset({
|
|
884
|
+
from: "react-router",
|
|
885
|
+
imports: [
|
|
886
|
+
...ReactRouterHooks
|
|
887
|
+
]
|
|
888
|
+
});
|
|
889
|
+
|
|
890
|
+
const reactRouterDom = defineUnimportPreset({
|
|
891
|
+
from: "react-router-dom",
|
|
892
|
+
imports: [
|
|
893
|
+
...ReactRouterHooks,
|
|
894
|
+
"useLinkClickHandler",
|
|
895
|
+
"useSearchParams",
|
|
896
|
+
"Link",
|
|
897
|
+
"NavLink",
|
|
898
|
+
"Navigate",
|
|
899
|
+
"Outlet",
|
|
900
|
+
"Route",
|
|
901
|
+
"Routes"
|
|
902
|
+
]
|
|
903
|
+
});
|
|
904
|
+
|
|
905
|
+
const svelteAnimate = defineUnimportPreset({
|
|
906
|
+
from: "svelte/animate",
|
|
907
|
+
imports: [
|
|
908
|
+
"flip"
|
|
909
|
+
]
|
|
910
|
+
});
|
|
911
|
+
const svelteEasing = defineUnimportPreset({
|
|
912
|
+
from: "svelte/easing",
|
|
913
|
+
imports: [
|
|
914
|
+
"back",
|
|
915
|
+
"bounce",
|
|
916
|
+
"circ",
|
|
917
|
+
"cubic",
|
|
918
|
+
"elastic",
|
|
919
|
+
"expo",
|
|
920
|
+
"quad",
|
|
921
|
+
"quart",
|
|
922
|
+
"quint",
|
|
923
|
+
"sine"
|
|
924
|
+
].reduce((acc, e) => {
|
|
925
|
+
acc.push(`${e}In`, `${e}Out`, `${e}InOut`);
|
|
926
|
+
return acc;
|
|
927
|
+
}, ["linear"])
|
|
928
|
+
});
|
|
929
|
+
const svelteStore = defineUnimportPreset({
|
|
930
|
+
from: "svelte/store",
|
|
931
|
+
imports: [
|
|
932
|
+
"writable",
|
|
933
|
+
"readable",
|
|
934
|
+
"derived",
|
|
935
|
+
"get"
|
|
936
|
+
]
|
|
937
|
+
});
|
|
938
|
+
const svelteMotion = defineUnimportPreset({
|
|
939
|
+
from: "svelte/motion",
|
|
940
|
+
imports: [
|
|
941
|
+
"tweened",
|
|
942
|
+
"spring"
|
|
943
|
+
]
|
|
944
|
+
});
|
|
945
|
+
const svelteTransition = defineUnimportPreset({
|
|
946
|
+
from: "svelte/transition",
|
|
947
|
+
imports: [
|
|
948
|
+
"fade",
|
|
949
|
+
"blur",
|
|
950
|
+
"fly",
|
|
951
|
+
"slide",
|
|
952
|
+
"scale",
|
|
953
|
+
"draw",
|
|
954
|
+
"crossfade"
|
|
955
|
+
]
|
|
956
|
+
});
|
|
957
|
+
const svelte = defineUnimportPreset({
|
|
958
|
+
from: "svelte",
|
|
959
|
+
imports: [
|
|
960
|
+
"onMount",
|
|
961
|
+
"beforeUpdate",
|
|
962
|
+
"afterUpdate",
|
|
963
|
+
"onDestroy",
|
|
964
|
+
"tick",
|
|
965
|
+
"setContext",
|
|
966
|
+
"getContext",
|
|
967
|
+
"hasContext",
|
|
968
|
+
"getAllContexts",
|
|
969
|
+
"createEventDispatcher"
|
|
970
|
+
]
|
|
971
|
+
});
|
|
972
|
+
|
|
973
|
+
const veeValidate = defineUnimportPreset({
|
|
974
|
+
from: "vee-validate",
|
|
975
|
+
imports: [
|
|
976
|
+
"validate",
|
|
977
|
+
"defineRule",
|
|
978
|
+
"configure",
|
|
979
|
+
"useField",
|
|
980
|
+
"useForm",
|
|
981
|
+
"useFieldArray",
|
|
982
|
+
"useResetForm",
|
|
983
|
+
"useIsFieldDirty",
|
|
984
|
+
"useIsFieldTouched",
|
|
985
|
+
"useIsFieldValid",
|
|
986
|
+
"useIsSubmitting",
|
|
987
|
+
"useValidateField",
|
|
988
|
+
"useIsFormDirty",
|
|
989
|
+
"useIsFormTouched",
|
|
990
|
+
"useIsFormValid",
|
|
991
|
+
"useValidateForm",
|
|
992
|
+
"useSubmitCount",
|
|
993
|
+
"useFieldValue",
|
|
994
|
+
"useFormValues",
|
|
995
|
+
"useFormErrors",
|
|
996
|
+
"useFieldError",
|
|
997
|
+
"useSubmitForm",
|
|
998
|
+
"FormContextKey",
|
|
999
|
+
"FieldContextKey"
|
|
1000
|
+
]
|
|
1001
|
+
});
|
|
1002
|
+
|
|
1003
|
+
const vitepress = defineUnimportPreset({
|
|
1004
|
+
from: "vitepress",
|
|
1005
|
+
imports: [
|
|
1006
|
+
"useData",
|
|
1007
|
+
"useRoute",
|
|
1008
|
+
"useRouter",
|
|
1009
|
+
"withBase"
|
|
1010
|
+
]
|
|
1011
|
+
});
|
|
1012
|
+
|
|
1013
|
+
const CommonCompositionAPI = [
|
|
1014
|
+
"onActivated",
|
|
1015
|
+
"onBeforeMount",
|
|
1016
|
+
"onBeforeUnmount",
|
|
1017
|
+
"onBeforeUpdate",
|
|
1018
|
+
"onErrorCaptured",
|
|
1019
|
+
"onDeactivated",
|
|
1020
|
+
"onMounted",
|
|
1021
|
+
"onServerPrefetch",
|
|
1022
|
+
"onUnmounted",
|
|
1023
|
+
"onUpdated",
|
|
1024
|
+
"useAttrs",
|
|
1025
|
+
"useSlots",
|
|
1026
|
+
"computed",
|
|
1027
|
+
"customRef",
|
|
1028
|
+
"isReadonly",
|
|
1029
|
+
"isRef",
|
|
1030
|
+
"markRaw",
|
|
1031
|
+
"reactive",
|
|
1032
|
+
"readonly",
|
|
1033
|
+
"ref",
|
|
1034
|
+
"shallowReactive",
|
|
1035
|
+
"shallowReadonly",
|
|
1036
|
+
"shallowRef",
|
|
1037
|
+
"triggerRef",
|
|
1038
|
+
"toRaw",
|
|
1039
|
+
"toRef",
|
|
1040
|
+
"toRefs",
|
|
1041
|
+
"unref",
|
|
1042
|
+
"watch",
|
|
1043
|
+
"watchEffect",
|
|
1044
|
+
"defineComponent",
|
|
1045
|
+
"defineAsyncComponent",
|
|
1046
|
+
"getCurrentInstance",
|
|
1047
|
+
"h",
|
|
1048
|
+
"inject",
|
|
1049
|
+
"nextTick",
|
|
1050
|
+
"provide",
|
|
1051
|
+
"useCssModule",
|
|
1052
|
+
"createApp",
|
|
1053
|
+
"effectScope",
|
|
1054
|
+
"EffectScope",
|
|
1055
|
+
"getCurrentScope",
|
|
1056
|
+
"onScopeDispose"
|
|
1057
|
+
];
|
|
1058
|
+
const vue = defineUnimportPreset({
|
|
1059
|
+
from: "vue",
|
|
1060
|
+
imports: [
|
|
1061
|
+
...CommonCompositionAPI,
|
|
1062
|
+
"onRenderTracked",
|
|
1063
|
+
"onRenderTriggered",
|
|
1064
|
+
"resolveComponent",
|
|
1065
|
+
"useCssVars"
|
|
1066
|
+
]
|
|
1067
|
+
});
|
|
1068
|
+
|
|
1069
|
+
const vueDemi = defineUnimportPreset({
|
|
1070
|
+
from: "vue-demi",
|
|
1071
|
+
imports: CommonCompositionAPI
|
|
1072
|
+
});
|
|
1073
|
+
|
|
1074
|
+
const vueI18n = defineUnimportPreset({
|
|
1075
|
+
from: "vue-i18n",
|
|
1076
|
+
imports: [
|
|
1077
|
+
"useI18n"
|
|
1078
|
+
]
|
|
1079
|
+
});
|
|
1080
|
+
|
|
1081
|
+
const vueRouter = defineUnimportPreset({
|
|
1082
|
+
from: "vue-router",
|
|
1083
|
+
imports: [
|
|
1084
|
+
"useRouter",
|
|
1085
|
+
"useRoute"
|
|
1086
|
+
]
|
|
1087
|
+
});
|
|
1088
|
+
|
|
1089
|
+
const vueCompositionApi = defineUnimportPreset({
|
|
1090
|
+
from: "@vue/composition-api",
|
|
1091
|
+
imports: CommonCompositionAPI
|
|
1092
|
+
});
|
|
1093
|
+
|
|
1094
|
+
let _cache;
|
|
1095
|
+
const vueuseCore = () => {
|
|
1096
|
+
const excluded = ["toRefs", "utils"];
|
|
1097
|
+
if (!_cache) {
|
|
1098
|
+
try {
|
|
1099
|
+
const path = resolveModule("@vueuse/core/indexes.json");
|
|
1100
|
+
const indexesJson = JSON.parse(readFileSync(path, "utf-8"));
|
|
1101
|
+
_cache = defineUnimportPreset({
|
|
1102
|
+
from: "@vueuse/core",
|
|
1103
|
+
imports: indexesJson.functions.filter((i) => ["core", "shared"].includes(i.package)).map((i) => i.name).filter((i) => i && i.length >= 4 && !excluded.includes(i))
|
|
1104
|
+
});
|
|
1105
|
+
} catch (error) {
|
|
1106
|
+
console.error(error);
|
|
1107
|
+
throw new Error("[auto-import] failed to load @vueuse/core, have you installed it?");
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
return _cache;
|
|
1111
|
+
};
|
|
1112
|
+
|
|
1113
|
+
const vueuseHead = defineUnimportPreset({
|
|
1114
|
+
from: "@vueuse/head",
|
|
1115
|
+
imports: [
|
|
1116
|
+
"useHead"
|
|
1117
|
+
]
|
|
1118
|
+
});
|
|
1119
|
+
|
|
1120
|
+
const vuex = defineUnimportPreset({
|
|
1121
|
+
from: "vuex",
|
|
1122
|
+
imports: [
|
|
1123
|
+
"createStore",
|
|
1124
|
+
"createLogger",
|
|
1125
|
+
"mapState",
|
|
1126
|
+
"mapGetters",
|
|
1127
|
+
"mapActions",
|
|
1128
|
+
"mapMutations",
|
|
1129
|
+
"createNamespacedHelpers",
|
|
1130
|
+
"useStore"
|
|
1131
|
+
]
|
|
1132
|
+
});
|
|
1133
|
+
|
|
1134
|
+
const vitest = defineUnimportPreset({
|
|
1135
|
+
from: "vitest",
|
|
1136
|
+
imports: [
|
|
1137
|
+
"suite",
|
|
1138
|
+
"test",
|
|
1139
|
+
"describe",
|
|
1140
|
+
"it",
|
|
1141
|
+
"chai",
|
|
1142
|
+
"expect",
|
|
1143
|
+
"assert",
|
|
1144
|
+
"vitest",
|
|
1145
|
+
"vi",
|
|
1146
|
+
"beforeAll",
|
|
1147
|
+
"afterAll",
|
|
1148
|
+
"beforeEach",
|
|
1149
|
+
"afterEach"
|
|
1150
|
+
]
|
|
1151
|
+
});
|
|
1152
|
+
|
|
1153
|
+
const uniApp = defineUnimportPreset({
|
|
1154
|
+
from: "@dcloudio/uni-app",
|
|
1155
|
+
imports: [
|
|
1156
|
+
"onAddToFavorites",
|
|
1157
|
+
"onBackPress",
|
|
1158
|
+
"onError",
|
|
1159
|
+
"onHide",
|
|
1160
|
+
"onLaunch",
|
|
1161
|
+
"onLoad",
|
|
1162
|
+
"onNavigationBarButtonTap",
|
|
1163
|
+
"onNavigationBarSearchInputChanged",
|
|
1164
|
+
"onNavigationBarSearchInputClicked",
|
|
1165
|
+
"onNavigationBarSearchInputConfirmed",
|
|
1166
|
+
"onNavigationBarSearchInputFocusChanged",
|
|
1167
|
+
"onPageNotFound",
|
|
1168
|
+
"onPageScroll",
|
|
1169
|
+
"onPullDownRefresh",
|
|
1170
|
+
"onReachBottom",
|
|
1171
|
+
"onReady",
|
|
1172
|
+
"onResize",
|
|
1173
|
+
"onShareAppMessage",
|
|
1174
|
+
"onShareTimeline",
|
|
1175
|
+
"onShow",
|
|
1176
|
+
"onTabItemTap",
|
|
1177
|
+
"onThemeChange",
|
|
1178
|
+
"onUnhandledRejection",
|
|
1179
|
+
"onUnload"
|
|
1180
|
+
]
|
|
1181
|
+
});
|
|
1182
|
+
|
|
1183
|
+
const solid = defineUnimportPreset({
|
|
1184
|
+
from: "solid-js",
|
|
1185
|
+
imports: [
|
|
1186
|
+
"createSignal",
|
|
1187
|
+
"createEffect",
|
|
1188
|
+
"createMemo",
|
|
1189
|
+
"createResource",
|
|
1190
|
+
"onMount",
|
|
1191
|
+
"onCleanup",
|
|
1192
|
+
"onError",
|
|
1193
|
+
"untrack",
|
|
1194
|
+
"batch",
|
|
1195
|
+
"on",
|
|
1196
|
+
"createRoot",
|
|
1197
|
+
"mergeProps",
|
|
1198
|
+
"splitProps",
|
|
1199
|
+
"useTransition",
|
|
1200
|
+
"observable",
|
|
1201
|
+
"mapArray",
|
|
1202
|
+
"indexArray",
|
|
1203
|
+
"createContext",
|
|
1204
|
+
"useContext",
|
|
1205
|
+
"children",
|
|
1206
|
+
"lazy",
|
|
1207
|
+
"createDeferred",
|
|
1208
|
+
"createRenderEffect",
|
|
1209
|
+
"createSelector",
|
|
1210
|
+
"For",
|
|
1211
|
+
"Show",
|
|
1212
|
+
"Switch",
|
|
1213
|
+
"Match",
|
|
1214
|
+
"Index",
|
|
1215
|
+
"ErrorBoundary",
|
|
1216
|
+
"Suspense",
|
|
1217
|
+
"SuspenseList"
|
|
1218
|
+
]
|
|
1219
|
+
});
|
|
1220
|
+
const solidStore = defineUnimportPreset({
|
|
1221
|
+
from: "solid-js/store",
|
|
1222
|
+
imports: [
|
|
1223
|
+
"createStore",
|
|
1224
|
+
"produce",
|
|
1225
|
+
"reconcile",
|
|
1226
|
+
"createMutable"
|
|
1227
|
+
]
|
|
1228
|
+
});
|
|
1229
|
+
const solidWeb = defineUnimportPreset({
|
|
1230
|
+
from: "solid-js/web",
|
|
1231
|
+
imports: [
|
|
1232
|
+
"Dynamic",
|
|
1233
|
+
"hydrate",
|
|
1234
|
+
"render",
|
|
1235
|
+
"renderToString",
|
|
1236
|
+
"renderToStringAsync",
|
|
1237
|
+
"renderToStream",
|
|
1238
|
+
"isServer",
|
|
1239
|
+
"Portal"
|
|
1240
|
+
]
|
|
1241
|
+
});
|
|
1242
|
+
const solid$1 = defineUnimportPreset({
|
|
1243
|
+
from: "solid-js",
|
|
1244
|
+
imports: [
|
|
1245
|
+
solid,
|
|
1246
|
+
solidStore,
|
|
1247
|
+
solidWeb
|
|
1248
|
+
]
|
|
1249
|
+
});
|
|
1250
|
+
|
|
1251
|
+
const solidAppRouter = defineUnimportPreset({
|
|
1252
|
+
from: "solid-app-router",
|
|
1253
|
+
imports: [
|
|
1254
|
+
"Link",
|
|
1255
|
+
"NavLink",
|
|
1256
|
+
"Navigate",
|
|
1257
|
+
"Outlet",
|
|
1258
|
+
"Route",
|
|
1259
|
+
"Router",
|
|
1260
|
+
"Routes",
|
|
1261
|
+
"_mergeSearchString",
|
|
1262
|
+
"createIntegration",
|
|
1263
|
+
"hashIntegration",
|
|
1264
|
+
"normalizeIntegration",
|
|
1265
|
+
"pathIntegration",
|
|
1266
|
+
"staticIntegration",
|
|
1267
|
+
"useHref",
|
|
1268
|
+
"useIsRouting",
|
|
1269
|
+
"useLocation",
|
|
1270
|
+
"useMatch",
|
|
1271
|
+
"useNavigate",
|
|
1272
|
+
"useParams",
|
|
1273
|
+
"useResolvedPath",
|
|
1274
|
+
"useRouteData",
|
|
1275
|
+
"useRoutes",
|
|
1276
|
+
"useSearchParams"
|
|
1277
|
+
]
|
|
1278
|
+
});
|
|
1279
|
+
|
|
1280
|
+
const builtinPresets = {
|
|
1281
|
+
"@vue/composition-api": vueCompositionApi,
|
|
1282
|
+
"@vueuse/core": vueuseCore,
|
|
1283
|
+
"@vueuse/head": vueuseHead,
|
|
1284
|
+
pinia,
|
|
1285
|
+
preact,
|
|
1286
|
+
quasar,
|
|
1287
|
+
react,
|
|
1288
|
+
"react-router": reactRouter,
|
|
1289
|
+
"react-router-dom": reactRouterDom,
|
|
1290
|
+
svelte,
|
|
1291
|
+
"svelte/animate": svelteAnimate,
|
|
1292
|
+
"svelte/easing": svelteEasing,
|
|
1293
|
+
"svelte/motion": svelteMotion,
|
|
1294
|
+
"svelte/store": svelteStore,
|
|
1295
|
+
"svelte/transition": svelteTransition,
|
|
1296
|
+
"vee-validate": veeValidate,
|
|
1297
|
+
vitepress,
|
|
1298
|
+
"vue-demi": vueDemi,
|
|
1299
|
+
"vue-i18n": vueI18n,
|
|
1300
|
+
"vue-router": vueRouter,
|
|
1301
|
+
vue,
|
|
1302
|
+
vuex,
|
|
1303
|
+
vitest,
|
|
1304
|
+
"uni-app": uniApp,
|
|
1305
|
+
"solid-js": solid$1,
|
|
1306
|
+
"solid-app-router": solidAppRouter
|
|
1307
|
+
};
|
|
1308
|
+
|
|
1309
|
+
function resolvePreset(preset) {
|
|
1310
|
+
const imports = [];
|
|
1311
|
+
for (const _import of preset.imports) {
|
|
1312
|
+
if (typeof _import === "string") {
|
|
1313
|
+
imports.push({ name: _import, as: _import, from: preset.from });
|
|
1314
|
+
} else if (Array.isArray(_import)) {
|
|
1315
|
+
imports.push({ name: _import[0], as: _import[1] || _import[0], from: _import[2] || preset.from });
|
|
1316
|
+
} else if (_import.imports) {
|
|
1317
|
+
imports.push(...resolvePreset(_import));
|
|
1318
|
+
} else {
|
|
1319
|
+
imports.push({ from: preset.from, ..._import });
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
return imports;
|
|
1323
|
+
}
|
|
1324
|
+
function resolveBuiltinPresets(presets) {
|
|
1325
|
+
return presets.flatMap((p) => {
|
|
1326
|
+
let preset = typeof p === "string" ? builtinPresets[p] : p;
|
|
1327
|
+
if (typeof preset === "function") {
|
|
1328
|
+
preset = preset();
|
|
1329
|
+
}
|
|
1330
|
+
return resolvePreset(preset);
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
function createUnimport(opts) {
|
|
1335
|
+
let _combinedImports;
|
|
1336
|
+
const ctx = {
|
|
1337
|
+
staticImports: [].concat(opts.imports).filter(Boolean),
|
|
1338
|
+
dynamicImports: [],
|
|
1339
|
+
get imports() {
|
|
1340
|
+
if (!_combinedImports) {
|
|
1341
|
+
_combinedImports = reload();
|
|
1342
|
+
}
|
|
1343
|
+
return _combinedImports;
|
|
1344
|
+
},
|
|
1345
|
+
map: /* @__PURE__ */ new Map(),
|
|
1346
|
+
matchRE: /__never__/g
|
|
1347
|
+
};
|
|
1348
|
+
ctx.staticImports.push(...resolveBuiltinPresets(opts.presets || []));
|
|
1349
|
+
function reload() {
|
|
1350
|
+
const imports = normalizeImports(dedupeImports([...ctx.staticImports, ...ctx.dynamicImports], opts.warn || console.warn));
|
|
1351
|
+
ctx.matchRE = new RegExp(`(?:\\b|^)(${imports.map((i) => escapeRE(i.as)).join("|")})(?:\\b|\\()`, "g");
|
|
1352
|
+
ctx.map.clear();
|
|
1353
|
+
for (const _import of imports) {
|
|
1354
|
+
ctx.map.set(_import.as, _import);
|
|
1355
|
+
}
|
|
1356
|
+
return imports;
|
|
1357
|
+
}
|
|
1358
|
+
async function modifyDynamicImports(fn) {
|
|
1359
|
+
await fn(ctx.dynamicImports);
|
|
1360
|
+
_combinedImports = void 0;
|
|
1361
|
+
}
|
|
1362
|
+
reload();
|
|
1363
|
+
return {
|
|
1364
|
+
modifyDynamicImports,
|
|
1365
|
+
getImports: () => ctx.imports,
|
|
1366
|
+
detectImports: (code) => detectImports(code, ctx),
|
|
1367
|
+
injectImports: (code, mergeExisting) => injectImports(code, ctx, mergeExisting),
|
|
1368
|
+
toExports: () => toExports(ctx.imports),
|
|
1369
|
+
generateTypeDecarations: (pathResolver) => toTypeDeclrationFile(ctx.imports, pathResolver)
|
|
1370
|
+
};
|
|
1371
|
+
}
|
|
1372
|
+
async function detectImports(code, ctx) {
|
|
1373
|
+
const strippedCode = stripCommentsAndStrings(code);
|
|
1374
|
+
const isCJSContext = detectSyntax(strippedCode).hasCJS;
|
|
1375
|
+
const matched = new Set(Array.from(strippedCode.matchAll(ctx.matchRE)).map((i) => i[1]));
|
|
1376
|
+
for (const regex of excludeRE) {
|
|
1377
|
+
Array.from(strippedCode.matchAll(regex)).flatMap((i) => [
|
|
1378
|
+
...i[1]?.split(separatorRE) || [],
|
|
1379
|
+
...i[2]?.split(separatorRE) || []
|
|
1380
|
+
]).map((i) => i.replace(importAsRE, "").trim()).forEach((i) => matched.delete(i));
|
|
1381
|
+
}
|
|
1382
|
+
const matchedImports = Array.from(matched).map((name) => ctx.map.get(name)).filter(Boolean);
|
|
1383
|
+
return {
|
|
1384
|
+
strippedCode,
|
|
1385
|
+
isCJSContext,
|
|
1386
|
+
matchedImports
|
|
1387
|
+
};
|
|
1388
|
+
}
|
|
1389
|
+
async function injectImports(code, ctx, mergeExisting) {
|
|
1390
|
+
const { isCJSContext, matchedImports } = await detectImports(code, ctx);
|
|
1391
|
+
return addImportToCode(code, matchedImports, isCJSContext, mergeExisting);
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
const TransformPlugin = createUnplugin(({ ctx, options }) => {
|
|
697
1395
|
return {
|
|
698
1396
|
name: "nuxt:auto-imports-transform",
|
|
699
1397
|
enforce: "post",
|
|
700
1398
|
transformInclude(id) {
|
|
701
1399
|
const { pathname, search } = parseURL(id);
|
|
702
1400
|
const { type, macro } = parseQuery(search);
|
|
703
|
-
|
|
1401
|
+
const exclude = options.transform?.exclude || [/[\\/]node_modules[\\/]/];
|
|
1402
|
+
if (exclude.some((pattern) => id.match(pattern))) {
|
|
704
1403
|
return false;
|
|
705
1404
|
}
|
|
706
1405
|
if (pathname.endsWith(".vue") && (type === "template" || type === "script" || macro || !search)) {
|
|
@@ -710,153 +1409,153 @@ const TransformPlugin = createUnplugin((ctx) => {
|
|
|
710
1409
|
return true;
|
|
711
1410
|
}
|
|
712
1411
|
},
|
|
713
|
-
transform(
|
|
714
|
-
const
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
Array.from(stripped.matchAll(regex)).flatMap((i) => [
|
|
718
|
-
...i[1]?.split(separatorRE) || [],
|
|
719
|
-
...i[2]?.split(separatorRE) || []
|
|
720
|
-
]).map((i) => i.replace(importAsRE, "").trim()).forEach((i) => matched.delete(i));
|
|
721
|
-
}
|
|
722
|
-
if (!matched.size) {
|
|
723
|
-
return null;
|
|
1412
|
+
async transform(_code, id) {
|
|
1413
|
+
const { code, s } = await ctx.injectImports(_code);
|
|
1414
|
+
if (code === _code) {
|
|
1415
|
+
return;
|
|
724
1416
|
}
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
1417
|
+
return {
|
|
1418
|
+
code,
|
|
1419
|
+
map: s.generateMap({ source: id, includeContent: true })
|
|
1420
|
+
};
|
|
729
1421
|
}
|
|
730
1422
|
};
|
|
731
1423
|
});
|
|
732
1424
|
|
|
733
|
-
const
|
|
734
|
-
{
|
|
735
|
-
from: "#app",
|
|
736
|
-
names: [
|
|
737
|
-
"useAsyncData",
|
|
738
|
-
"useLazyAsyncData",
|
|
739
|
-
"defineNuxtComponent",
|
|
740
|
-
"useNuxtApp",
|
|
741
|
-
"defineNuxtPlugin",
|
|
742
|
-
"useRuntimeConfig",
|
|
743
|
-
"useState",
|
|
744
|
-
"useFetch",
|
|
745
|
-
"useLazyFetch",
|
|
746
|
-
"useCookie",
|
|
747
|
-
"useRequestHeaders",
|
|
748
|
-
"useRouter",
|
|
749
|
-
"useRoute",
|
|
750
|
-
"defineNuxtRouteMiddleware",
|
|
751
|
-
"navigateTo",
|
|
752
|
-
"abortNavigation",
|
|
753
|
-
"addRouteMiddleware"
|
|
754
|
-
]
|
|
755
|
-
},
|
|
756
|
-
{
|
|
1425
|
+
const commonPresets = [
|
|
1426
|
+
defineUnimportPreset({
|
|
757
1427
|
from: "#meta",
|
|
758
|
-
|
|
1428
|
+
imports: [
|
|
759
1429
|
"useMeta"
|
|
760
1430
|
]
|
|
761
|
-
},
|
|
762
|
-
{
|
|
1431
|
+
}),
|
|
1432
|
+
defineUnimportPreset({
|
|
763
1433
|
from: "vue-demi",
|
|
764
|
-
|
|
1434
|
+
imports: [
|
|
765
1435
|
"isVue2",
|
|
766
1436
|
"isVue3"
|
|
767
1437
|
]
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
1438
|
+
})
|
|
1439
|
+
];
|
|
1440
|
+
const appPreset = defineUnimportPreset({
|
|
1441
|
+
from: "#app",
|
|
1442
|
+
imports: [
|
|
1443
|
+
"useAsyncData",
|
|
1444
|
+
"useLazyAsyncData",
|
|
1445
|
+
"defineNuxtComponent",
|
|
1446
|
+
"useNuxtApp",
|
|
1447
|
+
"defineNuxtPlugin",
|
|
1448
|
+
"useRuntimeConfig",
|
|
1449
|
+
"useState",
|
|
1450
|
+
"useFetch",
|
|
1451
|
+
"useLazyFetch",
|
|
1452
|
+
"useCookie",
|
|
1453
|
+
"useRequestHeaders",
|
|
1454
|
+
"useRouter",
|
|
1455
|
+
"useRoute",
|
|
1456
|
+
"defineNuxtRouteMiddleware",
|
|
1457
|
+
"navigateTo",
|
|
1458
|
+
"abortNavigation",
|
|
1459
|
+
"addRouteMiddleware"
|
|
1460
|
+
]
|
|
1461
|
+
});
|
|
1462
|
+
const vuePreset = defineUnimportPreset({
|
|
1463
|
+
from: "vue",
|
|
1464
|
+
imports: [
|
|
1465
|
+
"withCtx",
|
|
1466
|
+
"withDirectives",
|
|
1467
|
+
"withKeys",
|
|
1468
|
+
"withMemo",
|
|
1469
|
+
"withModifiers",
|
|
1470
|
+
"withScopeId",
|
|
1471
|
+
"onActivated",
|
|
1472
|
+
"onBeforeMount",
|
|
1473
|
+
"onBeforeUnmount",
|
|
1474
|
+
"onBeforeUpdate",
|
|
1475
|
+
"onDeactivated",
|
|
1476
|
+
"onErrorCaptured",
|
|
1477
|
+
"onMounted",
|
|
1478
|
+
"onRenderTracked",
|
|
1479
|
+
"onRenderTriggered",
|
|
1480
|
+
"onServerPrefetch",
|
|
1481
|
+
"onUnmounted",
|
|
1482
|
+
"onUpdated",
|
|
1483
|
+
"computed",
|
|
1484
|
+
"customRef",
|
|
1485
|
+
"isProxy",
|
|
1486
|
+
"isReactive",
|
|
1487
|
+
"isReadonly",
|
|
1488
|
+
"isRef",
|
|
1489
|
+
"markRaw",
|
|
1490
|
+
"proxyRefs",
|
|
1491
|
+
"reactive",
|
|
1492
|
+
"readonly",
|
|
1493
|
+
"ref",
|
|
1494
|
+
"shallowReactive",
|
|
1495
|
+
"shallowReadonly",
|
|
1496
|
+
"shallowRef",
|
|
1497
|
+
"toRaw",
|
|
1498
|
+
"toRef",
|
|
1499
|
+
"toRefs",
|
|
1500
|
+
"triggerRef",
|
|
1501
|
+
"unref",
|
|
1502
|
+
"watch",
|
|
1503
|
+
"watchEffect",
|
|
1504
|
+
"isShallow",
|
|
1505
|
+
"effect",
|
|
1506
|
+
"effectScope",
|
|
1507
|
+
"getCurrentScope",
|
|
1508
|
+
"onScopeDispose",
|
|
1509
|
+
"defineComponent",
|
|
1510
|
+
"defineAsyncComponent",
|
|
1511
|
+
"getCurrentInstance",
|
|
1512
|
+
"h",
|
|
1513
|
+
"inject",
|
|
1514
|
+
"nextTick",
|
|
1515
|
+
"provide",
|
|
1516
|
+
"useAttrs",
|
|
1517
|
+
"useCssModule",
|
|
1518
|
+
"useCssVars",
|
|
1519
|
+
"useSlots",
|
|
1520
|
+
"useTransitionState"
|
|
1521
|
+
]
|
|
1522
|
+
});
|
|
1523
|
+
const defaultPresets = [
|
|
1524
|
+
...commonPresets,
|
|
1525
|
+
appPreset,
|
|
1526
|
+
vuePreset
|
|
830
1527
|
];
|
|
831
1528
|
|
|
832
|
-
async function scanForComposables(dir,
|
|
1529
|
+
async function scanForComposables(dir, ctx) {
|
|
833
1530
|
const performScan = async (entry) => {
|
|
834
1531
|
const files = await resolveFiles(entry, [
|
|
835
1532
|
"*.{ts,js,mjs,cjs,mts,cts}",
|
|
836
1533
|
"*/index.{ts,js,mjs,cjs,mts,cts}"
|
|
837
1534
|
]);
|
|
838
|
-
await
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
name
|
|
1535
|
+
await ctx.modifyDynamicImports(async (dynamicImports) => {
|
|
1536
|
+
await Promise.all(files.map(async (path) => {
|
|
1537
|
+
filterInPlace(dynamicImports, (i) => i.from !== path);
|
|
1538
|
+
const code = await promises.readFile(path, "utf-8");
|
|
1539
|
+
const exports = findExports(code);
|
|
1540
|
+
const defaultExport = exports.find((i) => i.type === "default");
|
|
1541
|
+
if (defaultExport) {
|
|
1542
|
+
let name = parse$1(path).name;
|
|
1543
|
+
if (name === "index") {
|
|
1544
|
+
name = parse$1(path.split("/").slice(0, -1).join("/")).name;
|
|
1545
|
+
}
|
|
1546
|
+
dynamicImports.push({ name: "default", as: camelCase(name), from: path });
|
|
847
1547
|
}
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
1548
|
+
for (const exp of exports) {
|
|
1549
|
+
if (exp.type === "named") {
|
|
1550
|
+
for (const name of exp.names) {
|
|
1551
|
+
dynamicImports.push({ name, as: name, from: path });
|
|
1552
|
+
}
|
|
1553
|
+
} else if (exp.type === "declaration") {
|
|
1554
|
+
dynamicImports.push({ name: exp.name, as: exp.name, from: path });
|
|
854
1555
|
}
|
|
855
|
-
} else if (exp.type === "declaration") {
|
|
856
|
-
autoImports.push({ name: exp.name, as: exp.name, from: path });
|
|
857
1556
|
}
|
|
858
|
-
}
|
|
859
|
-
})
|
|
1557
|
+
}));
|
|
1558
|
+
});
|
|
860
1559
|
};
|
|
861
1560
|
for (const entry of Array.isArray(dir) ? dir : [dir]) {
|
|
862
1561
|
if (!existsSync(entry)) {
|
|
@@ -865,34 +1564,13 @@ async function scanForComposables(dir, autoImports) {
|
|
|
865
1564
|
await performScan(entry);
|
|
866
1565
|
}
|
|
867
1566
|
}
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
matchRE: /__never__/,
|
|
874
|
-
transform: {
|
|
875
|
-
exclude: opts.transform.exclude || [/node_modules/]
|
|
876
|
-
}
|
|
877
|
-
};
|
|
878
|
-
}
|
|
879
|
-
function updateAutoImportContext(ctx) {
|
|
880
|
-
const usedNames = /* @__PURE__ */ new Set();
|
|
881
|
-
for (const autoImport of ctx.autoImports) {
|
|
882
|
-
if (usedNames.has(autoImport.as)) {
|
|
883
|
-
autoImport.disabled = true;
|
|
884
|
-
console.warn(`Disabling duplicate auto import '${autoImport.as}' (imported from '${autoImport.from}')`);
|
|
885
|
-
} else {
|
|
886
|
-
usedNames.add(autoImport.as);
|
|
1567
|
+
function filterInPlace(arr, predicate) {
|
|
1568
|
+
let i = arr.length;
|
|
1569
|
+
while (i--) {
|
|
1570
|
+
if (!predicate(arr[i])) {
|
|
1571
|
+
arr.splice(i, 1);
|
|
887
1572
|
}
|
|
888
1573
|
}
|
|
889
|
-
ctx.autoImports = ctx.autoImports.filter((i) => i.disabled !== true);
|
|
890
|
-
ctx.matchRE = new RegExp(`\\b(${ctx.autoImports.map((i) => escapeRE(i.as)).join("|")})\\b`, "g");
|
|
891
|
-
ctx.map.clear();
|
|
892
|
-
for (const autoImport of ctx.autoImports) {
|
|
893
|
-
ctx.map.set(autoImport.as, autoImport);
|
|
894
|
-
}
|
|
895
|
-
return ctx;
|
|
896
1574
|
}
|
|
897
1575
|
|
|
898
1576
|
const autoImports = defineNuxtModule({
|
|
@@ -901,35 +1579,51 @@ const autoImports = defineNuxtModule({
|
|
|
901
1579
|
configKey: "autoImports"
|
|
902
1580
|
},
|
|
903
1581
|
defaults: {
|
|
904
|
-
|
|
1582
|
+
presets: defaultPresets,
|
|
905
1583
|
global: false,
|
|
1584
|
+
imports: [],
|
|
906
1585
|
dirs: [],
|
|
907
1586
|
transform: {
|
|
908
1587
|
exclude: void 0
|
|
909
1588
|
}
|
|
910
1589
|
},
|
|
911
1590
|
async setup(options, nuxt) {
|
|
912
|
-
await nuxt.callHook("autoImports:sources", options.
|
|
913
|
-
options.
|
|
914
|
-
|
|
1591
|
+
await nuxt.callHook("autoImports:sources", options.presets);
|
|
1592
|
+
options.presets.forEach((i) => {
|
|
1593
|
+
if (typeof i !== "string" && i.names && !i.imports) {
|
|
1594
|
+
i.imports = i.names;
|
|
1595
|
+
logger.warn("auto-imports: presets.names is deprecated, use presets.imports instead");
|
|
1596
|
+
}
|
|
1597
|
+
});
|
|
1598
|
+
const ctx = createUnimport({
|
|
1599
|
+
presets: defaultPresets,
|
|
1600
|
+
imports: options.imports
|
|
1601
|
+
});
|
|
915
1602
|
let composablesDirs = [
|
|
916
1603
|
join$1(nuxt.options.srcDir, "composables"),
|
|
917
1604
|
...options.dirs
|
|
918
1605
|
];
|
|
1606
|
+
for (const layer of nuxt.options._extends) {
|
|
1607
|
+
composablesDirs.push(resolve(layer.config.srcDir, "composables"));
|
|
1608
|
+
for (const dir of layer.config.autoImports?.dirs ?? []) {
|
|
1609
|
+
composablesDirs.push(resolve(layer.config.srcDir, dir));
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
919
1612
|
await nuxt.callHook("autoImports:dirs", composablesDirs);
|
|
920
1613
|
composablesDirs = composablesDirs.map((dir) => normalize(dir));
|
|
921
1614
|
addTemplate({
|
|
922
1615
|
filename: "imports.mjs",
|
|
923
|
-
getContents: () => toExports(
|
|
1616
|
+
getContents: () => ctx.toExports()
|
|
924
1617
|
});
|
|
925
1618
|
nuxt.options.alias["#imports"] = join$1(nuxt.options.buildDir, "imports");
|
|
926
1619
|
if (nuxt.options.dev && options.global) {
|
|
927
1620
|
addPluginTemplate({
|
|
928
1621
|
filename: "auto-imports.mjs",
|
|
929
1622
|
getContents: () => {
|
|
930
|
-
const imports =
|
|
931
|
-
const
|
|
932
|
-
|
|
1623
|
+
const imports = ctx.getImports();
|
|
1624
|
+
const importStatement = toImports(imports);
|
|
1625
|
+
const globalThisSet = imports.map((i) => `globalThis.${i.as} = ${i.as};`).join("\n");
|
|
1626
|
+
return `${importStatement}
|
|
933
1627
|
|
|
934
1628
|
${globalThisSet}
|
|
935
1629
|
|
|
@@ -937,14 +1631,14 @@ export default () => {};`;
|
|
|
937
1631
|
}
|
|
938
1632
|
});
|
|
939
1633
|
} else {
|
|
940
|
-
addVitePlugin(TransformPlugin.vite(ctx));
|
|
941
|
-
addWebpackPlugin(TransformPlugin.webpack(ctx));
|
|
1634
|
+
addVitePlugin(TransformPlugin.vite({ ctx, options }));
|
|
1635
|
+
addWebpackPlugin(TransformPlugin.webpack({ ctx, options }));
|
|
942
1636
|
}
|
|
943
1637
|
const regenerateAutoImports = async () => {
|
|
944
|
-
|
|
945
|
-
await
|
|
946
|
-
|
|
947
|
-
|
|
1638
|
+
await scanForComposables(composablesDirs, ctx);
|
|
1639
|
+
await ctx.modifyDynamicImports(async (imports) => {
|
|
1640
|
+
await nuxt.callHook("autoImports:extend", imports);
|
|
1641
|
+
});
|
|
948
1642
|
};
|
|
949
1643
|
await regenerateAutoImports();
|
|
950
1644
|
addDeclarationTemplates(ctx);
|
|
@@ -967,56 +1661,47 @@ function addDeclarationTemplates(ctx) {
|
|
|
967
1661
|
const nuxt = useNuxt();
|
|
968
1662
|
const stripExtension = (path) => path.replace(/\.[a-z]+$/, "");
|
|
969
1663
|
const resolved = {};
|
|
970
|
-
const r = (
|
|
971
|
-
if (resolved[
|
|
972
|
-
return resolved[
|
|
1664
|
+
const r = ({ from }) => {
|
|
1665
|
+
if (resolved[from]) {
|
|
1666
|
+
return resolved[from];
|
|
973
1667
|
}
|
|
974
|
-
let path = resolveAlias(
|
|
1668
|
+
let path = resolveAlias(from);
|
|
975
1669
|
if (isAbsolute(path)) {
|
|
976
1670
|
path = relative(join$1(nuxt.options.buildDir, "types"), path);
|
|
977
1671
|
}
|
|
978
1672
|
path = stripExtension(path);
|
|
979
|
-
resolved[
|
|
1673
|
+
resolved[from] = path;
|
|
980
1674
|
return path;
|
|
981
1675
|
};
|
|
982
1676
|
addTemplate({
|
|
983
1677
|
filename: "imports.d.ts",
|
|
984
|
-
getContents: () =>
|
|
1678
|
+
getContents: () => ctx.toExports()
|
|
985
1679
|
});
|
|
986
1680
|
addTemplate({
|
|
987
1681
|
filename: "types/auto-imports.d.ts",
|
|
988
|
-
getContents: () =>
|
|
989
|
-
declare global {
|
|
990
|
-
${ctx.autoImports.map((i) => ` const ${i.as}: typeof ${genDynamicImport(r(i.from), { wrapper: false })}['${i.name}']`).join("\n")}
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
export {}
|
|
994
|
-
`
|
|
1682
|
+
getContents: () => "// Generated by auto imports\n" + ctx.generateTypeDecarations(r)
|
|
995
1683
|
});
|
|
996
1684
|
}
|
|
997
1685
|
|
|
998
1686
|
const UnsupportedImports = /* @__PURE__ */ new Set(["useAsyncData", "useFetch"]);
|
|
999
1687
|
const CapiHelpers = new Set(Object.keys(CompositionApi));
|
|
1000
|
-
const ImportRewrites = {
|
|
1001
|
-
vue: "@vue/composition-api"
|
|
1002
|
-
};
|
|
1003
1688
|
function setupAutoImports() {
|
|
1004
1689
|
const nuxt = useNuxt();
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1690
|
+
const bridgePresets = [
|
|
1691
|
+
...commonPresets,
|
|
1692
|
+
{
|
|
1693
|
+
from: "#app",
|
|
1694
|
+
imports: [
|
|
1695
|
+
...appPreset.imports.filter((i) => !UnsupportedImports.has(i)),
|
|
1696
|
+
"useNuxt2Meta"
|
|
1697
|
+
]
|
|
1698
|
+
},
|
|
1699
|
+
{
|
|
1700
|
+
from: "@vue/composition-api",
|
|
1701
|
+
imports: vuePreset.imports.filter((i) => CapiHelpers.has(i))
|
|
1016
1702
|
}
|
|
1017
|
-
|
|
1018
|
-
});
|
|
1019
|
-
nuxt.hook("modules:done", () => installModule(autoImports));
|
|
1703
|
+
];
|
|
1704
|
+
nuxt.hook("modules:done", () => installModule(autoImports, { presets: bridgePresets }));
|
|
1020
1705
|
}
|
|
1021
1706
|
|
|
1022
1707
|
const extensions = ["ts", "tsx", "cts", "mts"];
|
|
@@ -1156,6 +1841,7 @@ const module = defineNuxtModule({
|
|
|
1156
1841
|
if (!nuxtCtx.use()) {
|
|
1157
1842
|
nuxtCtx.set(nuxt);
|
|
1158
1843
|
}
|
|
1844
|
+
nuxt.options._extends = nuxt.options._extends || [];
|
|
1159
1845
|
if (opts.nitro) {
|
|
1160
1846
|
await setupNitroBridge();
|
|
1161
1847
|
}
|
package/dist/chunks/module2.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import hash from 'hash-sum';
|
|
|
3
3
|
import { resolve } from 'pathe';
|
|
4
4
|
import { genImport, genObjectFromRawEntries } from 'knitwork';
|
|
5
5
|
|
|
6
|
-
const version = "3.0.0-
|
|
6
|
+
const version = "3.0.0-27449775.cff2f37";
|
|
7
7
|
|
|
8
8
|
const middlewareTemplate = {
|
|
9
9
|
filename: "middleware.js",
|
package/dist/chunks/vite.mjs
CHANGED
package/dist/module.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/bridge-edge",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-27449775.cff2f37",
|
|
4
4
|
"repository": "nuxt/framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
|
|
22
22
|
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
|
|
23
23
|
"@babel/plugin-transform-typescript": "^7.16.8",
|
|
24
|
-
"@nuxt/kit": "npm:@nuxt/kit-edge@3.0.0-
|
|
25
|
-
"@nuxt/nitro": "npm:@nuxt/nitro-edge@3.0.0-
|
|
24
|
+
"@nuxt/kit": "npm:@nuxt/kit-edge@3.0.0-27449775.cff2f37",
|
|
25
|
+
"@nuxt/nitro": "npm:@nuxt/nitro-edge@3.0.0-27449775.cff2f37",
|
|
26
26
|
"@nuxt/postcss8": "^1.1.3",
|
|
27
|
-
"@nuxt/schema": "npm:@nuxt/schema-edge@3.0.0-
|
|
27
|
+
"@nuxt/schema": "npm:@nuxt/schema-edge@3.0.0-27449775.cff2f37",
|
|
28
28
|
"@vitejs/plugin-legacy": "^1.6.4",
|
|
29
29
|
"@vue/composition-api": "^1.4.6",
|
|
30
30
|
"@vueuse/head": "^0.7.5",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"mlly": "^0.4.2",
|
|
46
46
|
"murmurhash-es": "^0.1.1",
|
|
47
47
|
"node-fetch": "^3.2.0",
|
|
48
|
-
"nuxi": "npm:nuxi-edge@3.0.0-
|
|
48
|
+
"nuxi": "npm:nuxi-edge@3.0.0-27449775.cff2f37",
|
|
49
49
|
"p-debounce": "^4.0.0",
|
|
50
50
|
"pathe": "^0.2.0",
|
|
51
51
|
"postcss": "^8",
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"ufo": "^0.7.9",
|
|
59
59
|
"unplugin": "^0.3.2",
|
|
60
60
|
"unplugin-vue2-script-setup": "0.9.2",
|
|
61
|
+
"untyped": "^0.4.2",
|
|
61
62
|
"vite": "^2.8.2",
|
|
62
63
|
"vite-plugin-vue2": "^1.9.3",
|
|
63
64
|
"vue-template-compiler": "^2.6.14"
|