setupin 3.0.0 → 3.1.1
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/README.md +95 -16
- package/README.zh-CN.md +98 -16
- package/dist/main.js +162 -142
- package/dist/main.prod.js +100 -103
- package/package.json +3 -6
- package/dist/main.d.mts +0 -954
- package/dist/main.d.ts +0 -954
package/dist/main.js
CHANGED
|
@@ -51,26 +51,25 @@ var __async = (__this, __arguments, generator) => {
|
|
|
51
51
|
};
|
|
52
52
|
(function() {
|
|
53
53
|
"use strict";
|
|
54
|
-
const ASCII_LOGO = "/***************************************\r\n** _ _ **\r\n** ___ ___| |_ _ _ _ __ (_)_ __ **\r\n** / __|/ _ \\ __| | | | '_ \\| | '_ \\ **\r\n** \\__ \\ __/ |_| |_| | |_/ | | | | | **\r\n** |___/\\___|\\__|\\__,_| .__/|_|_| |_| **\r\n** |_| **\r\n***************************************/\r\n";
|
|
54
|
+
const ASCII_LOGO = "\r\n/***************************************\r\n** _ _ **\r\n** ___ ___| |_ _ _ _ __ (_)_ __ **\r\n** / __|/ _ \\ __| | | | '_ \\| | '_ \\ **\r\n** \\__ \\ __/ |_| |_| | |_/ | | | | | **\r\n** |___/\\___|\\__|\\__,_| .__/|_|_| |_| **\r\n** |_| **\r\n***************************************/\r\n";
|
|
55
55
|
const APP_VAR_NAME = "APP$";
|
|
56
56
|
const REPO_NAME = "setupin";
|
|
57
|
-
const IMPORTS_JSON = JSON.stringify({ imports: { vue: "https://unpkg.com/vue/dist/vue.runtime.esm-browser.js" } });
|
|
57
|
+
const IMPORTS_JSON = JSON.stringify({ imports: { vue: "https://unpkg.com/vue@latest/dist/vue.runtime.esm-browser.js" } });
|
|
58
58
|
const INIT_CODE = `
|
|
59
|
-
<script>
|
|
60
59
|
${ASCII_LOGO}
|
|
61
60
|
import * as Vue from "vue";
|
|
62
|
-
let ${APP_VAR_NAME} =
|
|
63
|
-
<\/script>
|
|
61
|
+
let ${APP_VAR_NAME} = Object.create(null);
|
|
64
62
|
`;
|
|
65
63
|
const CREATE_APP_CODE = `
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
Vue.createApp(Vue.defineComponent(
|
|
65
|
+
String(${APP_VAR_NAME}.setup).startsWith('async')
|
|
66
|
+
? () => () =>
|
|
67
|
+
Vue.h(Vue.Suspense, null, {
|
|
68
|
+
default: Vue.h(${APP_VAR_NAME}),
|
|
69
|
+
fallback: Vue.h('div', 'Loading...'),
|
|
70
|
+
})
|
|
71
|
+
: ${APP_VAR_NAME}
|
|
72
|
+
)).mount(document.body)
|
|
74
73
|
`;
|
|
75
74
|
/**
|
|
76
75
|
* @vue/compiler-sfc v3.5.12
|
|
@@ -18051,7 +18050,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
18051
18050
|
}
|
|
18052
18051
|
}
|
|
18053
18052
|
function createTransformContext(root2, {
|
|
18054
|
-
filename
|
|
18053
|
+
filename = "",
|
|
18055
18054
|
prefixIdentifiers = false,
|
|
18056
18055
|
hoistStatic = false,
|
|
18057
18056
|
hmr = false,
|
|
@@ -18074,10 +18073,10 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
18074
18073
|
onWarn = defaultOnWarn,
|
|
18075
18074
|
compatConfig
|
|
18076
18075
|
}) {
|
|
18077
|
-
const nameMatch =
|
|
18076
|
+
const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
|
|
18078
18077
|
const context = {
|
|
18079
18078
|
// options
|
|
18080
|
-
filename
|
|
18079
|
+
filename,
|
|
18081
18080
|
selfName: nameMatch && capitalize(camelize(nameMatch[1])),
|
|
18082
18081
|
prefixIdentifiers,
|
|
18083
18082
|
hoistStatic,
|
|
@@ -18983,7 +18982,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
18983
18982
|
SourceMapGenerator.prototype._version = 3;
|
|
18984
18983
|
SourceMapGenerator.fromSourceMap = function SourceMapGenerator_fromSourceMap(aSourceMapConsumer, generatorOps) {
|
|
18985
18984
|
var sourceRoot = aSourceMapConsumer.sourceRoot;
|
|
18986
|
-
var
|
|
18985
|
+
var generator2 = new SourceMapGenerator(Object.assign(generatorOps || {}, {
|
|
18987
18986
|
file: aSourceMapConsumer.file,
|
|
18988
18987
|
sourceRoot
|
|
18989
18988
|
}));
|
|
@@ -19007,22 +19006,22 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
19007
19006
|
newMapping.name = mapping.name;
|
|
19008
19007
|
}
|
|
19009
19008
|
}
|
|
19010
|
-
|
|
19009
|
+
generator2.addMapping(newMapping);
|
|
19011
19010
|
});
|
|
19012
19011
|
aSourceMapConsumer.sources.forEach(function(sourceFile) {
|
|
19013
19012
|
var sourceRelative = sourceFile;
|
|
19014
19013
|
if (sourceRoot !== null) {
|
|
19015
19014
|
sourceRelative = util2.relative(sourceRoot, sourceFile);
|
|
19016
19015
|
}
|
|
19017
|
-
if (!
|
|
19018
|
-
|
|
19016
|
+
if (!generator2._sources.has(sourceRelative)) {
|
|
19017
|
+
generator2._sources.add(sourceRelative);
|
|
19019
19018
|
}
|
|
19020
19019
|
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
|
19021
19020
|
if (content != null) {
|
|
19022
|
-
|
|
19021
|
+
generator2.setSourceContent(sourceFile, content);
|
|
19023
19022
|
}
|
|
19024
19023
|
});
|
|
19025
|
-
return
|
|
19024
|
+
return generator2;
|
|
19026
19025
|
};
|
|
19027
19026
|
SourceMapGenerator.prototype.addMapping = function SourceMapGenerator_addMapping(aArgs) {
|
|
19028
19027
|
var generated = util2.getArg(aArgs, "generated");
|
|
@@ -20286,7 +20285,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
20286
20285
|
mode = "function",
|
|
20287
20286
|
prefixIdentifiers = mode === "module",
|
|
20288
20287
|
sourceMap: sourceMap2 = false,
|
|
20289
|
-
filename
|
|
20288
|
+
filename = `template.vue.html`,
|
|
20290
20289
|
scopeId = null,
|
|
20291
20290
|
optimizeImports = false,
|
|
20292
20291
|
runtimeGlobalName = `Vue`,
|
|
@@ -20300,7 +20299,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
20300
20299
|
mode,
|
|
20301
20300
|
prefixIdentifiers,
|
|
20302
20301
|
sourceMap: sourceMap2,
|
|
20303
|
-
filename
|
|
20302
|
+
filename,
|
|
20304
20303
|
scopeId,
|
|
20305
20304
|
optimizeImports,
|
|
20306
20305
|
runtimeGlobalName,
|
|
@@ -20382,14 +20381,14 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
20382
20381
|
// source-map column is 0 based
|
|
20383
20382
|
generatedLine: context.line,
|
|
20384
20383
|
generatedColumn: context.column - 1,
|
|
20385
|
-
source:
|
|
20384
|
+
source: filename,
|
|
20386
20385
|
name
|
|
20387
20386
|
});
|
|
20388
20387
|
}
|
|
20389
20388
|
if (sourceMap2) {
|
|
20390
20389
|
context.map = new sourceMapExports.SourceMapGenerator();
|
|
20391
|
-
context.map.setSourceContent(
|
|
20392
|
-
context.map._sources.add(
|
|
20390
|
+
context.map.setSourceContent(filename, context.source);
|
|
20391
|
+
context.map._sources.add(filename);
|
|
20393
20392
|
}
|
|
20394
20393
|
return context;
|
|
20395
20394
|
}
|
|
@@ -24674,7 +24673,7 @@ ${defaultVar}.setup = __setup__
|
|
|
24674
24673
|
}
|
|
24675
24674
|
const {
|
|
24676
24675
|
sourceMap: sourceMap2 = true,
|
|
24677
|
-
filename
|
|
24676
|
+
filename = DEFAULT_FILENAME,
|
|
24678
24677
|
sourceRoot = "",
|
|
24679
24678
|
pad: pad2 = false,
|
|
24680
24679
|
ignoreEmpty = true,
|
|
@@ -24682,7 +24681,7 @@ ${defaultVar}.setup = __setup__
|
|
|
24682
24681
|
templateParseOptions = {}
|
|
24683
24682
|
} = options;
|
|
24684
24683
|
const descriptor = {
|
|
24685
|
-
filename
|
|
24684
|
+
filename,
|
|
24686
24685
|
source,
|
|
24687
24686
|
template: null,
|
|
24688
24687
|
script: null,
|
|
@@ -24797,7 +24796,7 @@ ${defaultVar}.setup = __setup__
|
|
|
24797
24796
|
const genMap = (block, columnOffset = 0) => {
|
|
24798
24797
|
if (block && !block.src) {
|
|
24799
24798
|
block.map = generateSourceMap(
|
|
24800
|
-
|
|
24799
|
+
filename,
|
|
24801
24800
|
source,
|
|
24802
24801
|
block.content,
|
|
24803
24802
|
sourceRoot,
|
|
@@ -24867,13 +24866,13 @@ ${defaultVar}.setup = __setup__
|
|
|
24867
24866
|
const splitRE = /\r?\n/g;
|
|
24868
24867
|
const emptyRE = /^(?:\/\/)?\s*$/;
|
|
24869
24868
|
const replaceRE = /./g;
|
|
24870
|
-
function generateSourceMap(
|
|
24869
|
+
function generateSourceMap(filename, source, generated, sourceRoot, lineOffset, columnOffset) {
|
|
24871
24870
|
const map2 = new sourceMapExports.SourceMapGenerator({
|
|
24872
|
-
file:
|
|
24871
|
+
file: filename.replace(/\\/g, "/"),
|
|
24873
24872
|
sourceRoot: sourceRoot.replace(/\\/g, "/")
|
|
24874
24873
|
});
|
|
24875
|
-
map2.setSourceContent(
|
|
24876
|
-
map2._sources.add(
|
|
24874
|
+
map2.setSourceContent(filename, source);
|
|
24875
|
+
map2._sources.add(filename);
|
|
24877
24876
|
generated.split(splitRE).forEach((line, index) => {
|
|
24878
24877
|
if (!emptyRE.test(line)) {
|
|
24879
24878
|
const originalLine = index + 1 + lineOffset;
|
|
@@ -24885,7 +24884,7 @@ ${defaultVar}.setup = __setup__
|
|
|
24885
24884
|
originalColumn: i + columnOffset,
|
|
24886
24885
|
generatedLine,
|
|
24887
24886
|
generatedColumn: i,
|
|
24888
|
-
source:
|
|
24887
|
+
source: filename,
|
|
24889
24888
|
name: null
|
|
24890
24889
|
});
|
|
24891
24890
|
}
|
|
@@ -24974,8 +24973,8 @@ ${defaultVar}.setup = __setup__
|
|
|
24974
24973
|
return parts;
|
|
24975
24974
|
}
|
|
24976
24975
|
var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
|
|
24977
|
-
var splitPath = function(
|
|
24978
|
-
return splitPathRe.exec(
|
|
24976
|
+
var splitPath = function(filename) {
|
|
24977
|
+
return splitPathRe.exec(filename).slice(1);
|
|
24979
24978
|
};
|
|
24980
24979
|
function resolve() {
|
|
24981
24980
|
var resolvedPath = "", resolvedAbsolute = false;
|
|
@@ -29657,12 +29656,12 @@ ${defaultVar}.setup = __setup__
|
|
|
29657
29656
|
return a;
|
|
29658
29657
|
};
|
|
29659
29658
|
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
|
29660
|
-
function preprocess$1({ source, filename
|
|
29659
|
+
function preprocess$1({ source, filename, preprocessOptions }, preprocessor) {
|
|
29661
29660
|
let res = "";
|
|
29662
29661
|
let err = null;
|
|
29663
29662
|
preprocessor.render(
|
|
29664
29663
|
source,
|
|
29665
|
-
__spreadValues$6({ filename
|
|
29664
|
+
__spreadValues$6({ filename }, preprocessOptions),
|
|
29666
29665
|
(_err, _res) => {
|
|
29667
29666
|
if (_err) err = _err;
|
|
29668
29667
|
res = _res;
|
|
@@ -29710,7 +29709,7 @@ ${defaultVar}.setup = __setup__
|
|
|
29710
29709
|
}
|
|
29711
29710
|
}
|
|
29712
29711
|
function doCompileTemplate({
|
|
29713
|
-
filename
|
|
29712
|
+
filename,
|
|
29714
29713
|
id: id2,
|
|
29715
29714
|
scoped,
|
|
29716
29715
|
slotted,
|
|
@@ -29776,7 +29775,7 @@ ${defaultVar}.setup = __setup__
|
|
|
29776
29775
|
}, compilerOptions), {
|
|
29777
29776
|
hmr: !isProd,
|
|
29778
29777
|
nodeTransforms: nodeTransforms.concat(compilerOptions.nodeTransforms || []),
|
|
29779
|
-
filename
|
|
29778
|
+
filename,
|
|
29780
29779
|
onError: (e) => errors2.push(e),
|
|
29781
29780
|
onWarn: (w) => warnings.push(w)
|
|
29782
29781
|
}));
|
|
@@ -29835,17 +29834,17 @@ ${generateCodeFrame(
|
|
|
29835
29834
|
name: origPosInOldMap.name
|
|
29836
29835
|
});
|
|
29837
29836
|
});
|
|
29838
|
-
const
|
|
29837
|
+
const generator2 = mergedMapGenerator;
|
|
29839
29838
|
oldMapConsumer.sources.forEach((sourceFile) => {
|
|
29840
|
-
|
|
29839
|
+
generator2._sources.add(sourceFile);
|
|
29841
29840
|
const sourceContent = oldMapConsumer.sourceContentFor(sourceFile);
|
|
29842
29841
|
if (sourceContent != null) {
|
|
29843
29842
|
mergedMapGenerator.setSourceContent(sourceFile, sourceContent);
|
|
29844
29843
|
}
|
|
29845
29844
|
});
|
|
29846
|
-
|
|
29847
|
-
|
|
29848
|
-
return
|
|
29845
|
+
generator2._sourceRoot = oldMap.sourceRoot;
|
|
29846
|
+
generator2._file = oldMap.file;
|
|
29847
|
+
return generator2.toJSON();
|
|
29849
29848
|
}
|
|
29850
29849
|
function patchErrors(errors2, source, inMap) {
|
|
29851
29850
|
const originalSource = inMap.sourcesContent[0];
|
|
@@ -32110,7 +32109,7 @@ ${generateCodeFrame(
|
|
|
32110
32109
|
SourceMapGenerator.prototype._version = 3;
|
|
32111
32110
|
SourceMapGenerator.fromSourceMap = function SourceMapGenerator_fromSourceMap(aSourceMapConsumer, generatorOps) {
|
|
32112
32111
|
var sourceRoot = aSourceMapConsumer.sourceRoot;
|
|
32113
|
-
var
|
|
32112
|
+
var generator2 = new SourceMapGenerator(Object.assign(generatorOps || {}, {
|
|
32114
32113
|
file: aSourceMapConsumer.file,
|
|
32115
32114
|
sourceRoot
|
|
32116
32115
|
}));
|
|
@@ -32134,22 +32133,22 @@ ${generateCodeFrame(
|
|
|
32134
32133
|
newMapping.name = mapping.name;
|
|
32135
32134
|
}
|
|
32136
32135
|
}
|
|
32137
|
-
|
|
32136
|
+
generator2.addMapping(newMapping);
|
|
32138
32137
|
});
|
|
32139
32138
|
aSourceMapConsumer.sources.forEach(function(sourceFile) {
|
|
32140
32139
|
var sourceRelative = sourceFile;
|
|
32141
32140
|
if (sourceRoot !== null) {
|
|
32142
32141
|
sourceRelative = util2.relative(sourceRoot, sourceFile);
|
|
32143
32142
|
}
|
|
32144
|
-
if (!
|
|
32145
|
-
|
|
32143
|
+
if (!generator2._sources.has(sourceRelative)) {
|
|
32144
|
+
generator2._sources.add(sourceRelative);
|
|
32146
32145
|
}
|
|
32147
32146
|
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
|
32148
32147
|
if (content != null) {
|
|
32149
|
-
|
|
32148
|
+
generator2.setSourceContent(sourceFile, content);
|
|
32150
32149
|
}
|
|
32151
32150
|
});
|
|
32152
|
-
return
|
|
32151
|
+
return generator2;
|
|
32153
32152
|
};
|
|
32154
32153
|
SourceMapGenerator.prototype.addMapping = function SourceMapGenerator_addMapping(aArgs) {
|
|
32155
32154
|
var generated = util2.getArg(aArgs, "generated");
|
|
@@ -36768,10 +36767,10 @@ ${generateCodeFrame(
|
|
|
36768
36767
|
})(comment, comment.exports);
|
|
36769
36768
|
return comment.exports;
|
|
36770
36769
|
}
|
|
36771
|
-
var id
|
|
36770
|
+
var id = { exports: {} };
|
|
36772
36771
|
var hasRequiredId;
|
|
36773
36772
|
function requireId() {
|
|
36774
|
-
if (hasRequiredId) return id
|
|
36773
|
+
if (hasRequiredId) return id.exports;
|
|
36775
36774
|
hasRequiredId = 1;
|
|
36776
36775
|
(function(module, exports) {
|
|
36777
36776
|
exports.__esModule = true;
|
|
@@ -36809,8 +36808,8 @@ ${generateCodeFrame(
|
|
|
36809
36808
|
}(_node["default"]);
|
|
36810
36809
|
exports["default"] = ID;
|
|
36811
36810
|
module.exports = exports.default;
|
|
36812
|
-
})(id
|
|
36813
|
-
return id
|
|
36811
|
+
})(id, id.exports);
|
|
36812
|
+
return id.exports;
|
|
36814
36813
|
}
|
|
36815
36814
|
var tag = { exports: {} };
|
|
36816
36815
|
var namespace = { exports: {} };
|
|
@@ -40040,7 +40039,7 @@ ${generateCodeFrame(
|
|
|
40040
40039
|
SourceMapGenerator.prototype._version = 3;
|
|
40041
40040
|
SourceMapGenerator.fromSourceMap = function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
|
|
40042
40041
|
var sourceRoot = aSourceMapConsumer.sourceRoot;
|
|
40043
|
-
var
|
|
40042
|
+
var generator2 = new SourceMapGenerator({
|
|
40044
40043
|
file: aSourceMapConsumer.file,
|
|
40045
40044
|
sourceRoot
|
|
40046
40045
|
});
|
|
@@ -40064,22 +40063,22 @@ ${generateCodeFrame(
|
|
|
40064
40063
|
newMapping.name = mapping.name;
|
|
40065
40064
|
}
|
|
40066
40065
|
}
|
|
40067
|
-
|
|
40066
|
+
generator2.addMapping(newMapping);
|
|
40068
40067
|
});
|
|
40069
40068
|
aSourceMapConsumer.sources.forEach(function(sourceFile) {
|
|
40070
40069
|
var sourceRelative = sourceFile;
|
|
40071
40070
|
if (sourceRoot !== null) {
|
|
40072
40071
|
sourceRelative = util2.relative(sourceRoot, sourceFile);
|
|
40073
40072
|
}
|
|
40074
|
-
if (!
|
|
40075
|
-
|
|
40073
|
+
if (!generator2._sources.has(sourceRelative)) {
|
|
40074
|
+
generator2._sources.add(sourceRelative);
|
|
40076
40075
|
}
|
|
40077
40076
|
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
|
40078
40077
|
if (content != null) {
|
|
40079
|
-
|
|
40078
|
+
generator2.setSourceContent(sourceFile, content);
|
|
40080
40079
|
}
|
|
40081
40080
|
});
|
|
40082
|
-
return
|
|
40081
|
+
return generator2;
|
|
40083
40082
|
};
|
|
40084
40083
|
SourceMapGenerator.prototype.addMapping = function SourceMapGenerator_addMapping(aArgs) {
|
|
40085
40084
|
var generated = util2.getArg(aArgs, "generated");
|
|
@@ -41434,10 +41433,10 @@ ${generateCodeFrame(
|
|
|
41434
41433
|
return { code: "", errors: [e], dependencies: [] };
|
|
41435
41434
|
}
|
|
41436
41435
|
};
|
|
41437
|
-
function getSource(source,
|
|
41436
|
+
function getSource(source, filename, additionalData) {
|
|
41438
41437
|
if (!additionalData) return source;
|
|
41439
41438
|
if (isFunction$1(additionalData)) {
|
|
41440
|
-
return additionalData(source,
|
|
41439
|
+
return additionalData(source, filename);
|
|
41441
41440
|
}
|
|
41442
41441
|
return additionalData + source;
|
|
41443
41442
|
}
|
|
@@ -41474,7 +41473,7 @@ ${generateCodeFrame(
|
|
|
41474
41473
|
}
|
|
41475
41474
|
function doCompileStyle(options) {
|
|
41476
41475
|
const {
|
|
41477
|
-
filename
|
|
41476
|
+
filename,
|
|
41478
41477
|
id: id2,
|
|
41479
41478
|
scoped = false,
|
|
41480
41479
|
trim = true,
|
|
@@ -41508,8 +41507,8 @@ ${generateCodeFrame(
|
|
|
41508
41507
|
}
|
|
41509
41508
|
}
|
|
41510
41509
|
const postCSSOptions = __spreadProps$3(__spreadValues$4({}, postcssOptions), {
|
|
41511
|
-
to:
|
|
41512
|
-
from:
|
|
41510
|
+
to: filename,
|
|
41511
|
+
from: filename
|
|
41513
41512
|
});
|
|
41514
41513
|
if (map2) {
|
|
41515
41514
|
postCSSOptions.map = {
|
|
@@ -41524,7 +41523,7 @@ ${generateCodeFrame(
|
|
|
41524
41523
|
const dependencies = new Set(
|
|
41525
41524
|
preProcessedSource ? preProcessedSource.dependencies : []
|
|
41526
41525
|
);
|
|
41527
|
-
dependencies.delete(
|
|
41526
|
+
dependencies.delete(filename);
|
|
41528
41527
|
const errors2 = [];
|
|
41529
41528
|
if (preProcessedSource && preProcessedSource.errors.length) {
|
|
41530
41529
|
errors2.push(...preProcessedSource.errors);
|
|
@@ -42773,9 +42772,9 @@ ${generateCodeFrame(
|
|
|
42773
42772
|
this.isJS = scriptLang === "js" || scriptLang === "jsx" || scriptSetupLang === "js" || scriptSetupLang === "jsx";
|
|
42774
42773
|
this.isTS = scriptLang === "ts" || scriptLang === "tsx" || scriptSetupLang === "ts" || scriptSetupLang === "tsx";
|
|
42775
42774
|
const customElement = options.customElement;
|
|
42776
|
-
const
|
|
42775
|
+
const filename = this.descriptor.filename;
|
|
42777
42776
|
if (customElement) {
|
|
42778
|
-
this.isCE = typeof customElement === "boolean" ? customElement : customElement(
|
|
42777
|
+
this.isCE = typeof customElement === "boolean" ? customElement : customElement(filename);
|
|
42779
42778
|
}
|
|
42780
42779
|
const plugins = resolveParserPlugins(
|
|
42781
42780
|
scriptLang || scriptSetupLang,
|
|
@@ -43017,8 +43016,8 @@ export default ${defaultVar}`;
|
|
|
43017
43016
|
};
|
|
43018
43017
|
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
43019
43018
|
class TypeScope {
|
|
43020
|
-
constructor(
|
|
43021
|
-
this.filename =
|
|
43019
|
+
constructor(filename, source, offset = 0, imports = /* @__PURE__ */ Object.create(null), types2 = /* @__PURE__ */ Object.create(null), declares = /* @__PURE__ */ Object.create(null)) {
|
|
43020
|
+
this.filename = filename;
|
|
43022
43021
|
this.source = source;
|
|
43023
43022
|
this.offset = offset;
|
|
43024
43023
|
this.imports = imports;
|
|
@@ -43616,11 +43615,11 @@ Note: both in 3.2 or with the ignore, the properties in the base type are treate
|
|
|
43616
43615
|
if (!resolved) {
|
|
43617
43616
|
if (source.startsWith("..")) {
|
|
43618
43617
|
const osSpecificJoinFn = joinPaths;
|
|
43619
|
-
const
|
|
43620
|
-
resolved = resolveExt(
|
|
43618
|
+
const filename = osSpecificJoinFn(dirname(scope.filename), source);
|
|
43619
|
+
resolved = resolveExt(filename, fs);
|
|
43621
43620
|
} else if (source[0] === ".") {
|
|
43622
|
-
const
|
|
43623
|
-
resolved = resolveExt(
|
|
43621
|
+
const filename = joinPaths(dirname(scope.filename), source);
|
|
43622
|
+
resolved = resolveExt(filename, fs);
|
|
43624
43623
|
} else {
|
|
43625
43624
|
{
|
|
43626
43625
|
return ctx.error(
|
|
@@ -43645,35 +43644,35 @@ Note: both in 3.2 or with the ignore, the properties in the base type are treate
|
|
|
43645
43644
|
);
|
|
43646
43645
|
}
|
|
43647
43646
|
}
|
|
43648
|
-
function resolveExt(
|
|
43649
|
-
|
|
43650
|
-
const tryResolve = (
|
|
43651
|
-
if (fs.fileExists(
|
|
43647
|
+
function resolveExt(filename, fs) {
|
|
43648
|
+
filename = filename.replace(/\.js$/, "");
|
|
43649
|
+
const tryResolve = (filename2) => {
|
|
43650
|
+
if (fs.fileExists(filename2)) return filename2;
|
|
43652
43651
|
};
|
|
43653
|
-
return tryResolve(
|
|
43652
|
+
return tryResolve(filename) || tryResolve(filename + `.ts`) || tryResolve(filename + `.tsx`) || tryResolve(filename + `.d.ts`) || tryResolve(joinPaths(filename, `index.ts`)) || tryResolve(joinPaths(filename, `index.tsx`)) || tryResolve(joinPaths(filename, `index.d.ts`));
|
|
43654
43653
|
}
|
|
43655
43654
|
const fileToScopeCache = createCache();
|
|
43656
|
-
function fileToScope(ctx,
|
|
43657
|
-
const cached = fileToScopeCache.get(
|
|
43655
|
+
function fileToScope(ctx, filename, asGlobal = false) {
|
|
43656
|
+
const cached = fileToScopeCache.get(filename);
|
|
43658
43657
|
if (cached) {
|
|
43659
43658
|
return cached;
|
|
43660
43659
|
}
|
|
43661
43660
|
const fs = resolveFS(ctx);
|
|
43662
|
-
const source = fs.readFile(
|
|
43663
|
-
const body = parseFile(
|
|
43664
|
-
const scope = new TypeScope(
|
|
43661
|
+
const source = fs.readFile(filename) || "";
|
|
43662
|
+
const body = parseFile(filename, source, ctx.options.babelParserPlugins);
|
|
43663
|
+
const scope = new TypeScope(filename, source, 0, recordImports(body));
|
|
43665
43664
|
recordTypes(ctx, body, scope, asGlobal);
|
|
43666
|
-
fileToScopeCache.set(
|
|
43665
|
+
fileToScopeCache.set(filename, scope);
|
|
43667
43666
|
return scope;
|
|
43668
43667
|
}
|
|
43669
|
-
function parseFile(
|
|
43670
|
-
const ext = extname(
|
|
43668
|
+
function parseFile(filename, content, parserPlugins) {
|
|
43669
|
+
const ext = extname(filename);
|
|
43671
43670
|
if (ext === ".ts" || ext === ".mts" || ext === ".tsx" || ext === ".mtsx") {
|
|
43672
43671
|
return libExports.parse(content, {
|
|
43673
43672
|
plugins: resolveParserPlugins(
|
|
43674
43673
|
ext.slice(1),
|
|
43675
43674
|
parserPlugins,
|
|
43676
|
-
/\.d\.m?ts$/.test(
|
|
43675
|
+
/\.d\.m?ts$/.test(filename)
|
|
43677
43676
|
),
|
|
43678
43677
|
sourceType: "module"
|
|
43679
43678
|
}).program.body;
|
|
@@ -45081,7 +45080,7 @@ Upgrade your vite or vue-loader version for compatibility with the latest experi
|
|
|
45081
45080
|
);
|
|
45082
45081
|
}
|
|
45083
45082
|
const ctx = new ScriptCompileContext(sfc, options);
|
|
45084
|
-
const { script, scriptSetup, source, filename
|
|
45083
|
+
const { script, scriptSetup, source, filename } = sfc;
|
|
45085
45084
|
const hoistStatic = options.hoistStatic !== false && !script;
|
|
45086
45085
|
const scopeId = options.id ? options.id.replace(/^data-v-/, "") : "";
|
|
45087
45086
|
const scriptLang = script && script.lang;
|
|
@@ -45554,7 +45553,7 @@ let __temp${any}, __restore${any}
|
|
|
45554
45553
|
hasInlinedSsrRenderFn = true;
|
|
45555
45554
|
}
|
|
45556
45555
|
const { code, ast, preamble, tips, errors: errors2 } = compileTemplate(__spreadProps2(__spreadValues$1({
|
|
45557
|
-
filename
|
|
45556
|
+
filename,
|
|
45558
45557
|
ast: sfc.template.ast,
|
|
45559
45558
|
source: sfc.template.content,
|
|
45560
45559
|
inMap: sfc.template.map
|
|
@@ -45619,8 +45618,8 @@ return ${returned}
|
|
|
45619
45618
|
}
|
|
45620
45619
|
const genDefaultAs = options.genDefaultAs ? `const ${options.genDefaultAs} =` : `export default`;
|
|
45621
45620
|
let runtimeOptions = ``;
|
|
45622
|
-
if (!ctx.hasDefaultExportName &&
|
|
45623
|
-
const match =
|
|
45621
|
+
if (!ctx.hasDefaultExportName && filename && filename !== DEFAULT_FILENAME) {
|
|
45622
|
+
const match = filename.match(/([^/\\]+)\.\w+$/);
|
|
45624
45623
|
if (match) {
|
|
45625
45624
|
runtimeOptions += `
|
|
45626
45625
|
__name: '${match[1]}',`;
|
|
@@ -45690,7 +45689,7 @@ ${exposeCall}`
|
|
|
45690
45689
|
imports: ctx.userImports,
|
|
45691
45690
|
content: ctx.s.toString(),
|
|
45692
45691
|
map: options.sourceMap !== false ? ctx.s.generateMap({
|
|
45693
|
-
source:
|
|
45692
|
+
source: filename,
|
|
45694
45693
|
hires: true,
|
|
45695
45694
|
includeContent: true
|
|
45696
45695
|
}) : void 0,
|
|
@@ -45872,37 +45871,50 @@ ${exposeCall}`
|
|
|
45872
45871
|
};
|
|
45873
45872
|
__spreadValues2(__spreadValues2({}, errorMessages$1), DOMErrorMessages);
|
|
45874
45873
|
libExports.parse;
|
|
45875
|
-
const filename = `${REPO_NAME}.vue`;
|
|
45876
|
-
const id = REPO_NAME;
|
|
45877
45874
|
function compilerSfc(source) {
|
|
45878
45875
|
var _a2, _b2;
|
|
45879
|
-
const
|
|
45876
|
+
const id2 = REPO_NAME;
|
|
45877
|
+
const filename = `${REPO_NAME}.vue`;
|
|
45878
|
+
const sfcParseResult = parse$2(source, { filename });
|
|
45880
45879
|
sfcParseResult.errors.forEach((e) => {
|
|
45881
45880
|
console.warn(e);
|
|
45882
45881
|
});
|
|
45883
|
-
const sfcScriptBlock = compileScript(sfcParseResult.descriptor, { id });
|
|
45884
|
-
const sfcTemplateCompileResults = compileTemplate({
|
|
45885
|
-
id,
|
|
45886
|
-
filename,
|
|
45887
|
-
source: (_b2 = (_a2 = sfcParseResult.descriptor.template) == null ? void 0 : _a2.content) != null ? _b2 : ""
|
|
45888
|
-
});
|
|
45889
45882
|
const sfcStyleCompileResultsList = sfcParseResult.descriptor.styles.map((style) => {
|
|
45890
|
-
|
|
45891
|
-
id,
|
|
45883
|
+
const sfcStyleCompileResults = compileStyle({
|
|
45884
|
+
id: id2,
|
|
45892
45885
|
filename,
|
|
45893
45886
|
source: style.content,
|
|
45894
|
-
scoped: style.scoped
|
|
45887
|
+
scoped: style.scoped,
|
|
45888
|
+
isProd: false
|
|
45895
45889
|
});
|
|
45890
|
+
sfcStyleCompileResults.errors.forEach((e) => {
|
|
45891
|
+
console.warn(e);
|
|
45892
|
+
});
|
|
45893
|
+
return sfcStyleCompileResults;
|
|
45894
|
+
});
|
|
45895
|
+
const sfcAppBlock = compileScript(sfcParseResult.descriptor, {
|
|
45896
|
+
id: id2,
|
|
45897
|
+
isProd: false
|
|
45898
|
+
});
|
|
45899
|
+
sfcAppBlock.isScoped = sfcParseResult.descriptor.styles.some((s) => s.scoped);
|
|
45900
|
+
const sfcTemplateCompileResults = compileTemplate({
|
|
45901
|
+
id: id2,
|
|
45902
|
+
filename,
|
|
45903
|
+
source: (_b2 = (_a2 = sfcParseResult.descriptor.template) == null ? void 0 : _a2.content) != null ? _b2 : "",
|
|
45904
|
+
isProd: false
|
|
45905
|
+
});
|
|
45906
|
+
sfcTemplateCompileResults.errors.forEach((e) => {
|
|
45907
|
+
console.warn(e);
|
|
45896
45908
|
});
|
|
45897
45909
|
return {
|
|
45898
|
-
|
|
45899
|
-
|
|
45900
|
-
|
|
45910
|
+
sfcStyleCompileResultsList,
|
|
45911
|
+
sfcAppBlock,
|
|
45912
|
+
sfcTemplateCompileResults
|
|
45901
45913
|
};
|
|
45902
45914
|
}
|
|
45903
45915
|
function createDom(row, inner) {
|
|
45904
45916
|
var _a2;
|
|
45905
|
-
const container2 = document.createElement("
|
|
45917
|
+
const container2 = document.createElement("body");
|
|
45906
45918
|
container2.insertAdjacentHTML("afterbegin", row);
|
|
45907
45919
|
const sample = container2.firstElementChild;
|
|
45908
45920
|
const dom = document.createElement(sample.tagName);
|
|
@@ -45911,9 +45923,7 @@ ${exposeCall}`
|
|
|
45911
45923
|
dom.setAttribute(n2, (_a2 = sample.getAttribute(n2)) != null ? _a2 : "");
|
|
45912
45924
|
}
|
|
45913
45925
|
return {
|
|
45914
|
-
mount(el)
|
|
45915
|
-
el.appendChild(dom);
|
|
45916
|
-
}
|
|
45926
|
+
mount: (el) => el.appendChild(dom)
|
|
45917
45927
|
};
|
|
45918
45928
|
}
|
|
45919
45929
|
function watchRoot(handler) {
|
|
@@ -45937,44 +45947,54 @@ ${exposeCall}`
|
|
|
45937
45947
|
}
|
|
45938
45948
|
function awaitCompileSfc(handler) {
|
|
45939
45949
|
return __async(this, null, function* () {
|
|
45940
|
-
const
|
|
45941
|
-
if (
|
|
45942
|
-
|
|
45943
|
-
|
|
45944
|
-
|
|
45950
|
+
const clientCodeList = yield watchRoot((node2, clientCodeList2) => {
|
|
45951
|
+
if (!/^(?:script|template|style)$/.test(node2.localName))
|
|
45952
|
+
return;
|
|
45953
|
+
if (node2.hasAttribute("src"))
|
|
45954
|
+
return;
|
|
45955
|
+
clientCodeList2.push(node2.outerHTML);
|
|
45956
|
+
node2.localName === "style" ? node2.onload = node2.remove : node2.remove();
|
|
45945
45957
|
});
|
|
45946
|
-
const
|
|
45947
|
-
|
|
45958
|
+
const hasScript = clientCodeList.some((code) => code.slice(1, 7) === "script");
|
|
45959
|
+
hasScript || clientCodeList.push("<script>/* empty script */<\/script>");
|
|
45960
|
+
handler(compilerSfc(clientCodeList.join("\n")));
|
|
45948
45961
|
});
|
|
45949
45962
|
}
|
|
45950
|
-
function
|
|
45963
|
+
function generateCssCode(sfcStyleCompileResultsList) {
|
|
45951
45964
|
return sfcStyleCompileResultsList.map((style) => style.code).join("\n");
|
|
45952
45965
|
}
|
|
45953
|
-
function generateEsmCode(
|
|
45966
|
+
function generateEsmCode(sfcAppBlock, sfcTemplateCompileResults) {
|
|
45954
45967
|
return `
|
|
45955
|
-
${
|
|
45968
|
+
${INIT_CODE}
|
|
45969
|
+
${_scriptTransform(sfcAppBlock)}
|
|
45956
45970
|
${_templateTransform(sfcTemplateCompileResults)}
|
|
45957
|
-
|
|
45958
|
-
else{${CREATE_APP_CODE}}
|
|
45971
|
+
${CREATE_APP_CODE}
|
|
45959
45972
|
`;
|
|
45973
|
+
function _scriptTransform(sfcAppBlock2) {
|
|
45974
|
+
const s = new MagicString(sfcAppBlock2.content);
|
|
45975
|
+
s.replace("export default", `${APP_VAR_NAME} =`);
|
|
45976
|
+
sfcAppBlock2.isScoped && s.prependLeft(sfcAppBlock2.content.indexOf("__name"), `__scopeId: "data-v-${REPO_NAME}",`);
|
|
45977
|
+
s.replace(/Object\.defineProperty\(__returned__.*/, "");
|
|
45978
|
+
return s.toString();
|
|
45979
|
+
}
|
|
45980
|
+
function _templateTransform(sfcTemplateCompileResults2) {
|
|
45981
|
+
const s = new MagicString(sfcTemplateCompileResults2.code);
|
|
45982
|
+
s.replace("export function render", `${APP_VAR_NAME}.render = function`);
|
|
45983
|
+
return s.toString();
|
|
45984
|
+
}
|
|
45960
45985
|
}
|
|
45961
|
-
function
|
|
45962
|
-
const
|
|
45963
|
-
|
|
45964
|
-
|
|
45965
|
-
|
|
45966
|
-
|
|
45967
|
-
function _templateTransform(sfcTemplateCompileResults) {
|
|
45968
|
-
const t = new MagicString(sfcTemplateCompileResults.code);
|
|
45969
|
-
t.replace("export function render", `${APP_VAR_NAME}.render = function`);
|
|
45970
|
-
return t.toString();
|
|
45986
|
+
function generator(compiledSfc) {
|
|
45987
|
+
const { sfcAppBlock, sfcStyleCompileResultsList, sfcTemplateCompileResults } = compiledSfc;
|
|
45988
|
+
return {
|
|
45989
|
+
esmCode: generateEsmCode(sfcAppBlock, sfcTemplateCompileResults),
|
|
45990
|
+
cssCode: generateCssCode(sfcStyleCompileResultsList)
|
|
45991
|
+
};
|
|
45971
45992
|
}
|
|
45972
|
-
awaitCompileSfc((
|
|
45993
|
+
awaitCompileSfc((compiledSfc) => {
|
|
45994
|
+
const _toHead = (...args) => createDom(...args).mount(document.head);
|
|
45995
|
+
const g = generator(compiledSfc);
|
|
45973
45996
|
_toHead(`<script ${REPO_NAME} type="importmap">${IMPORTS_JSON}<\/script>`);
|
|
45974
|
-
_toHead(`<script ${REPO_NAME} type="module">`,
|
|
45975
|
-
_toHead(`<style ${REPO_NAME}>`,
|
|
45997
|
+
_toHead(`<script ${REPO_NAME} type="module">`, g.esmCode);
|
|
45998
|
+
_toHead(`<style ${REPO_NAME}>`, g.cssCode);
|
|
45976
45999
|
});
|
|
45977
|
-
function _toHead(...args) {
|
|
45978
|
-
createDom(...args).mount(document.head);
|
|
45979
|
-
}
|
|
45980
46000
|
})();
|