@dcloudio/uni-cli-shared 3.0.0-alpha-4070720250804001 → 3.0.0-alpha-4080120250820001
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/hbx/index.js +5 -3
- package/dist/json/app/manifest/env.d.ts +1 -1
- package/dist/json/app/manifest/env.js +4 -4
- package/dist/json/app/manifest/index.js +3 -1
- package/dist/json/app/pages/definePage.d.ts +2 -1
- package/dist/json/app/pages/definePage.js +15 -3
- package/dist/json/app/pages/index.d.ts +2 -1
- package/dist/json/app/pages/index.js +5 -3
- package/dist/json/mp/types.d.ts +3 -0
- package/dist/json/theme.js +1 -4
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +5 -2
- package/dist/vite/plugins/uts/uni_modules.js +27 -2
- package/dist/vue/transforms/templateTransformAssetUrl.d.ts +5 -1
- package/dist/vue/transforms/templateTransformAssetUrl.js +23 -14
- package/dist/vue/utils.d.ts +5 -2
- package/dist/vue/utils.js +31 -4
- package/dist/workers.d.ts +4 -3
- package/dist/workers.js +125 -32
- package/lib/vapor/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +11 -2
- package/lib/vapor/@vue/compiler-vapor/dist/compiler-vapor.cjs.js +11 -2
- package/lib/vapor/@vue/compiler-vapor/dist/compiler-vapor.esm-browser.js +11 -2
- package/lib/vapor/@vue/runtime-core/dist/runtime-core.cjs.js +5 -5
- package/lib/vapor/@vue/runtime-core/dist/runtime-core.cjs.prod.js +5 -5
- package/lib/vapor/@vue/runtime-core/dist/runtime-core.esm-bundler.js +5 -5
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.esm-browser.js +5 -5
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.esm-browser.prod.js +1 -1
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.global.js +5 -5
- package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.global.prod.js +1 -1
- package/lib/vapor/@vue/runtime-vapor/dist/runtime-vapor.esm-bundler.js +36 -13
- package/lib/vapor/@vue/server-renderer/dist/server-renderer.esm-browser.js +5 -5
- package/lib/vapor/@vue/server-renderer/dist/server-renderer.esm-browser.prod.js +1 -1
- package/lib/vapor/@vue/vue/dist/vue.esm-browser.js +5 -5
- package/lib/vapor/@vue/vue/dist/vue.esm-browser.prod.js +1 -1
- package/lib/vapor/@vue/vue/dist/vue.global.js +5 -5
- package/lib/vapor/@vue/vue/dist/vue.global.prod.js +1 -1
- package/lib/vapor/@vue/vue/dist/vue.runtime-with-vapor.esm-browser.js +41 -18
- package/lib/vapor/@vue/vue/dist/vue.runtime-with-vapor.esm-browser.prod.js +3 -3
- package/lib/vapor/@vue/vue/dist/vue.runtime.esm-browser.js +5 -5
- package/lib/vapor/@vue/vue/dist/vue.runtime.esm-browser.prod.js +1 -1
- package/lib/vapor/@vue/vue/dist/vue.runtime.global.js +5 -5
- package/lib/vapor/@vue/vue/dist/vue.runtime.global.prod.js +1 -1
- package/package.json +4 -4
package/dist/workers.js
CHANGED
|
@@ -3,43 +3,55 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.initUniXCompilerRootWorkers = exports.uniJavaScriptWorkersPlugin = exports.resolveWorkersDir = exports.uniWorkersPlugin = exports.initWorkers = exports.
|
|
6
|
+
exports.initUniXCompilerRootWorkers = exports.uniJavaScriptWorkersPlugin = exports.resolveWorkersDir = exports.uniWorkersPlugin = exports.initWorkers = exports.getWorkersRootDirs = exports.resolveWorkersRootDir = exports.getWorkers = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
|
+
const debug_1 = __importDefault(require("debug"));
|
|
9
10
|
const fast_glob_1 = require("fast-glob");
|
|
10
11
|
const utils_1 = require("./utils");
|
|
11
12
|
const json_1 = require("./json");
|
|
12
13
|
const uts_1 = require("./uts");
|
|
13
14
|
const uni_modules_1 = require("./vite/plugins/uts/uni_modules");
|
|
14
15
|
const resolve_1 = require("./resolve");
|
|
16
|
+
const debugWorkers = (0, debug_1.default)('uni:workers');
|
|
15
17
|
let workersRootDir = null;
|
|
18
|
+
let workersRootDirs = [];
|
|
16
19
|
let workers = {};
|
|
17
20
|
function getWorkers() {
|
|
18
21
|
return workers;
|
|
19
22
|
}
|
|
20
23
|
exports.getWorkers = getWorkers;
|
|
21
|
-
function
|
|
22
|
-
|
|
24
|
+
function resolveWorkersRootDir() {
|
|
25
|
+
// 默认是 workers
|
|
26
|
+
return workersRootDir || 'workers';
|
|
23
27
|
}
|
|
24
|
-
exports.
|
|
28
|
+
exports.resolveWorkersRootDir = resolveWorkersRootDir;
|
|
29
|
+
function getWorkersRootDirs() {
|
|
30
|
+
return workersRootDirs;
|
|
31
|
+
}
|
|
32
|
+
exports.getWorkersRootDirs = getWorkersRootDirs;
|
|
25
33
|
/**
|
|
26
34
|
* 遍历目录下的所有uts文件,读取文件内容,正则匹配出定义的worker,返回文件名和类名的映射关系
|
|
27
35
|
* export class MyWorkerTask extends WorkerTaskImpl {}
|
|
28
36
|
* @param dir
|
|
29
37
|
*/
|
|
30
|
-
function initWorkers(
|
|
31
|
-
const dir = path_1.default.join(rootDir, workersDir);
|
|
32
|
-
if (!fs_extra_1.default.existsSync(dir)) {
|
|
33
|
-
return workers;
|
|
34
|
-
}
|
|
38
|
+
function initWorkers(workersDirs, rootDir) {
|
|
35
39
|
workers = {};
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
workers[(0, utils_1.normalizePath)(path_1.default.join(workersDir, file))] = match[1];
|
|
40
|
+
for (const workersDir of workersDirs) {
|
|
41
|
+
const dir = path_1.default.join(rootDir, workersDir);
|
|
42
|
+
if (!fs_extra_1.default.existsSync(dir)) {
|
|
43
|
+
continue;
|
|
41
44
|
}
|
|
42
|
-
|
|
45
|
+
(0, fast_glob_1.sync)('**/*.uts', { cwd: dir }).forEach((file) => {
|
|
46
|
+
const content = fs_extra_1.default.readFileSync(path_1.default.join(dir, file), 'utf-8');
|
|
47
|
+
const match = content.match(/class\s+(.*)\s+extends\s+WorkerTaskImpl/);
|
|
48
|
+
if (match && match[1]) {
|
|
49
|
+
const key = (0, utils_1.normalizePath)(path_1.default.join(workersDir, file));
|
|
50
|
+
workers[key] = match[1];
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
debugWorkers('workers', workers);
|
|
43
55
|
return workers;
|
|
44
56
|
}
|
|
45
57
|
exports.initWorkers = initWorkers;
|
|
@@ -48,13 +60,9 @@ function uniWorkersPlugin() {
|
|
|
48
60
|
const platform = process.env.UNI_UTS_PLATFORM;
|
|
49
61
|
const resolveWorkers = () => getWorkers();
|
|
50
62
|
function refreshWorkers() {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
initWorkers(workersDir, inputDir);
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
return false;
|
|
63
|
+
workersRootDirs = resolveWorkersDir(inputDir);
|
|
64
|
+
initWorkers(workersRootDirs, inputDir);
|
|
65
|
+
return Object.keys(getWorkers()).length > 0;
|
|
58
66
|
}
|
|
59
67
|
refreshWorkers();
|
|
60
68
|
const preprocessor = platform === 'app-android'
|
|
@@ -109,13 +117,16 @@ async function syncWorkersFiles(platform, inputDir, preprocessor, cache) {
|
|
|
109
117
|
platform !== 'app-ios') {
|
|
110
118
|
return;
|
|
111
119
|
}
|
|
112
|
-
const
|
|
113
|
-
if (
|
|
120
|
+
const workersDirs = resolveWorkersDir(inputDir);
|
|
121
|
+
if (workersDirs.length) {
|
|
114
122
|
const { syncUTSFiles } = (0, uts_1.resolveUTSCompiler)();
|
|
115
|
-
|
|
123
|
+
for (const workersDir of workersDirs) {
|
|
124
|
+
await syncUTSFiles((0, utils_1.normalizePath)(path_1.default.join(workersDir, '**/*.uts')), inputDir, (0, uts_1.tscOutDir)(platform), true, preprocessor, cache);
|
|
125
|
+
}
|
|
116
126
|
}
|
|
117
127
|
}
|
|
118
128
|
function resolveWorkersDir(inputDir) {
|
|
129
|
+
const workersDirs = [];
|
|
119
130
|
const manifestJson = (0, json_1.parseManifestJsonOnce)(inputDir);
|
|
120
131
|
if (manifestJson.workers) {
|
|
121
132
|
let workersDir = typeof manifestJson.workers === 'string'
|
|
@@ -125,10 +136,22 @@ function resolveWorkersDir(inputDir) {
|
|
|
125
136
|
workersDir = (0, utils_1.normalizePath)(workersDir);
|
|
126
137
|
const dir = path_1.default.join(inputDir, workersDir);
|
|
127
138
|
if (fs_extra_1.default.existsSync(dir)) {
|
|
128
|
-
|
|
139
|
+
workersRootDir = workersDir;
|
|
140
|
+
workersDirs.push(workersDir);
|
|
129
141
|
}
|
|
130
142
|
}
|
|
131
143
|
}
|
|
144
|
+
// 遍历uni_modules插件目录是否有workers目录
|
|
145
|
+
const uniModulesDir = path_1.default.join(inputDir, 'uni_modules');
|
|
146
|
+
if (fs_extra_1.default.existsSync(uniModulesDir)) {
|
|
147
|
+
fs_extra_1.default.readdirSync(uniModulesDir).forEach((dir) => {
|
|
148
|
+
if (fs_extra_1.default.existsSync(path_1.default.join(uniModulesDir, dir, 'workers'))) {
|
|
149
|
+
workersDirs.push('uni_modules/' + dir + '/workers');
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
debugWorkers('workersDirs', workersDirs);
|
|
154
|
+
return workersDirs;
|
|
132
155
|
}
|
|
133
156
|
exports.resolveWorkersDir = resolveWorkersDir;
|
|
134
157
|
function uniJavaScriptWorkersPlugin() {
|
|
@@ -137,25 +160,95 @@ function uniJavaScriptWorkersPlugin() {
|
|
|
137
160
|
let workerPolyfillCode = '';
|
|
138
161
|
let isWrite = false;
|
|
139
162
|
const UniAppWorkerJSName = external ? 'uni-worker.mp.js' : 'uni-worker.web.js';
|
|
163
|
+
let viteServer = null;
|
|
164
|
+
const workersRootPaths = [];
|
|
165
|
+
const workerPolyfillPath = `@dcloudio/uni-app/dist-x/${UniAppWorkerJSName}`;
|
|
166
|
+
const workerPolyfillAbsPath = (0, utils_1.normalizePath)((0, resolve_1.resolveBuiltIn)(workerPolyfillPath));
|
|
167
|
+
function isWorkerFile(id) {
|
|
168
|
+
if (workersRootPaths.length) {
|
|
169
|
+
return workersRootPaths.some((dir) => id.startsWith(dir));
|
|
170
|
+
}
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
function parseWorkerEntryFile(workerJsPath) {
|
|
174
|
+
const workerPath = workerJsPath.slice(1).replace('.js', '.uts');
|
|
175
|
+
if (workerPath in workers) {
|
|
176
|
+
return (0, utils_1.normalizePath)(path_1.default.resolve(process.env.UNI_INPUT_DIR, workerPath));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function parseWorkerClass(id) {
|
|
180
|
+
const filename = id.split('?')[0];
|
|
181
|
+
if (isWorkerFile(filename)) {
|
|
182
|
+
const workerPath = (0, utils_1.normalizePath)(path_1.default.relative(process.env.UNI_INPUT_DIR, filename));
|
|
183
|
+
return workers[workerPath] || '';
|
|
184
|
+
}
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
140
187
|
return {
|
|
141
188
|
name: 'uni:javascript-workers',
|
|
189
|
+
configureServer(server) {
|
|
190
|
+
viteServer = server;
|
|
191
|
+
},
|
|
192
|
+
buildStart() {
|
|
193
|
+
if (!workerPolyfillCode && Object.keys(getWorkers()).length) {
|
|
194
|
+
workerPolyfillCode = fs_extra_1.default.readFileSync(workerPolyfillAbsPath, 'utf-8');
|
|
195
|
+
}
|
|
196
|
+
workersRootPaths.length = 0;
|
|
197
|
+
for (const workersRootDir of getWorkersRootDirs()) {
|
|
198
|
+
workersRootPaths.push((0, utils_1.normalizePath)(path_1.default.resolve(process.env.UNI_INPUT_DIR, workersRootDir)));
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
resolveId(id) {
|
|
202
|
+
// uni.createWorker('workers/request/index.uts')
|
|
203
|
+
// 编译阶段调整为 uni.createWorker('workers/request/index.js'),确保开发和运行时都是用.js后缀加载
|
|
204
|
+
// 不调整成js后缀或.uts?import这些格式, vite 是不会走transform逻辑的,而是直接读取文件内容
|
|
205
|
+
if (viteServer) {
|
|
206
|
+
const workerEntryFile = parseWorkerEntryFile(id);
|
|
207
|
+
if (workerEntryFile) {
|
|
208
|
+
return workerEntryFile;
|
|
209
|
+
}
|
|
210
|
+
if (id === workerPolyfillPath) {
|
|
211
|
+
return workerPolyfillAbsPath;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
load(id) {
|
|
216
|
+
const filename = id.split('?')[0];
|
|
217
|
+
const workerClass = parseWorkerClass(filename);
|
|
218
|
+
if (workerClass === false) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (fs_extra_1.default.existsSync(filename)) {
|
|
222
|
+
let code = (viteServer ? `import '${workerPolyfillPath}';` : '') +
|
|
223
|
+
fs_extra_1.default
|
|
224
|
+
.readFileSync(filename, 'utf-8')
|
|
225
|
+
// 移除 export
|
|
226
|
+
.replace(/export\s+class\s+(.*)\s+extends\s+WorkerTaskImpl\s*{/, 'class $1 extends WorkerTaskImpl {');
|
|
227
|
+
// 如果是入口文件,需要追加初始化代码
|
|
228
|
+
if (workerClass) {
|
|
229
|
+
code += `\n;new ${workerClass}().entry()`;
|
|
230
|
+
}
|
|
231
|
+
return code;
|
|
232
|
+
}
|
|
233
|
+
},
|
|
142
234
|
generateBundle(_, bundle) {
|
|
143
235
|
const workers = getWorkers();
|
|
236
|
+
const workerRootDir = resolveWorkersRootDir();
|
|
144
237
|
const workerPaths = Object.keys(workers).map((key) => {
|
|
238
|
+
if (key.startsWith('uni_modules')) {
|
|
239
|
+
key = workerRootDir + '/' + key;
|
|
240
|
+
}
|
|
145
241
|
return key.replace('.uts', '.js');
|
|
146
242
|
});
|
|
147
243
|
if (workerPaths.length) {
|
|
148
|
-
if (!workerPolyfillCode) {
|
|
149
|
-
workerPolyfillCode = fs_extra_1.default.readFileSync((0, resolve_1.resolveBuiltIn)(`@dcloudio/uni-app/dist-x/${UniAppWorkerJSName}`), 'utf-8');
|
|
150
|
-
}
|
|
151
244
|
Object.keys(bundle).forEach((file) => {
|
|
152
245
|
if (workerPaths.includes(file)) {
|
|
153
246
|
const chunk = bundle[file];
|
|
154
247
|
if (chunk.type === 'chunk') {
|
|
155
248
|
const workerCode = external
|
|
156
|
-
? `require('${(0, utils_1.normalizePath)(path_1.default.relative(path_1.default.dirname(file), path_1.default.join(
|
|
249
|
+
? `require('${(0, utils_1.normalizePath)(path_1.default.relative(path_1.default.dirname(file), path_1.default.join(resolveWorkersRootDir(), 'uni-worker.js')))}')`
|
|
157
250
|
: workerPolyfillCode;
|
|
158
|
-
chunk.code = `${workerCode}\n${chunk.code}
|
|
251
|
+
chunk.code = `${workerCode}\n${chunk.code}`;
|
|
159
252
|
}
|
|
160
253
|
}
|
|
161
254
|
});
|
|
@@ -165,7 +258,7 @@ function uniJavaScriptWorkersPlugin() {
|
|
|
165
258
|
if (external && Object.keys(getWorkers()).length && !isWrite) {
|
|
166
259
|
isWrite = true;
|
|
167
260
|
// 写入uni-worker.js
|
|
168
|
-
fs_extra_1.default.outputFileSync(path_1.default.resolve(process.env.UNI_OUTPUT_DIR,
|
|
261
|
+
fs_extra_1.default.outputFileSync(path_1.default.resolve(process.env.UNI_OUTPUT_DIR, resolveWorkersRootDir(), 'uni-worker.js'), workerPolyfillCode);
|
|
169
262
|
}
|
|
170
263
|
},
|
|
171
264
|
};
|
|
@@ -44943,6 +44943,7 @@ class HtmlParser {
|
|
|
44943
44943
|
}
|
|
44944
44944
|
|
|
44945
44945
|
const NODE_TYPE_TEXT = "text";
|
|
44946
|
+
const NODE_TYPE_BUTTON = "button";
|
|
44946
44947
|
const NODE_TYPE_COMMENT = "comment";
|
|
44947
44948
|
const NODE_TYPE_ELEMENT = "element";
|
|
44948
44949
|
const VALUE_ATTR = "value";
|
|
@@ -44997,6 +44998,9 @@ class DomCodeGenerator {
|
|
|
44997
44998
|
if (tag === NODE_TYPE_TEXT) {
|
|
44998
44999
|
return this.genTextElementCode({ tag, attrs, children });
|
|
44999
45000
|
}
|
|
45001
|
+
if (tag === NODE_TYPE_BUTTON) {
|
|
45002
|
+
return this.genButtonElementCode({ tag, attrs, children });
|
|
45003
|
+
}
|
|
45000
45004
|
return this.genRegularElementCode({ tag, attrs, children });
|
|
45001
45005
|
}
|
|
45002
45006
|
genTextElementCode(params) {
|
|
@@ -45010,6 +45014,11 @@ class DomCodeGenerator {
|
|
|
45010
45014
|
return this.buildElementStatements(tag, finalAttrs, void 0);
|
|
45011
45015
|
}
|
|
45012
45016
|
}
|
|
45017
|
+
genButtonElementCode(params) {
|
|
45018
|
+
const textContent = this.extractTextContent(params.children);
|
|
45019
|
+
const finalAttrs = this.mergeTextAttributes(params.attrs, textContent);
|
|
45020
|
+
return this.buildElementStatements(params.tag, finalAttrs, void 0);
|
|
45021
|
+
}
|
|
45013
45022
|
genRegularElementCode(params) {
|
|
45014
45023
|
const { tag, attrs, children } = params;
|
|
45015
45024
|
return this.buildElementStatements(tag, attrs, children);
|
|
@@ -46852,7 +46861,7 @@ function processInterpolation(context) {
|
|
|
46852
46861
|
return;
|
|
46853
46862
|
}
|
|
46854
46863
|
context.template += " ";
|
|
46855
|
-
const isParentText = context.options.templateMode === "factory" && context.parent && context.parent.node.type === 1 && context.parent.node.tag === "text";
|
|
46864
|
+
const isParentText = context.options.templateMode === "factory" && context.parent && context.parent.node.type === 1 && (context.parent.node.tag === "text" || context.parent.node.tag === "button");
|
|
46856
46865
|
const id = isParentText ? context.parent.reference() : context.reference();
|
|
46857
46866
|
if (values.length === 0) {
|
|
46858
46867
|
return;
|
|
@@ -46877,7 +46886,7 @@ function processInterpolation(context) {
|
|
|
46877
46886
|
}
|
|
46878
46887
|
function processTextContainer(children, context) {
|
|
46879
46888
|
if (context.options.templateMode === "factory") {
|
|
46880
|
-
if (context.node.tag === "text") {
|
|
46889
|
+
if (context.node.tag === "text" || context.node.tag === "button") {
|
|
46881
46890
|
return;
|
|
46882
46891
|
}
|
|
46883
46892
|
}
|
|
@@ -1879,6 +1879,7 @@ class HtmlParser {
|
|
|
1879
1879
|
}
|
|
1880
1880
|
|
|
1881
1881
|
const NODE_TYPE_TEXT = "text";
|
|
1882
|
+
const NODE_TYPE_BUTTON = "button";
|
|
1882
1883
|
const NODE_TYPE_COMMENT = "comment";
|
|
1883
1884
|
const NODE_TYPE_ELEMENT = "element";
|
|
1884
1885
|
const VALUE_ATTR = "value";
|
|
@@ -1933,6 +1934,9 @@ class DomCodeGenerator {
|
|
|
1933
1934
|
if (tag === NODE_TYPE_TEXT) {
|
|
1934
1935
|
return this.genTextElementCode({ tag, attrs, children });
|
|
1935
1936
|
}
|
|
1937
|
+
if (tag === NODE_TYPE_BUTTON) {
|
|
1938
|
+
return this.genButtonElementCode({ tag, attrs, children });
|
|
1939
|
+
}
|
|
1936
1940
|
return this.genRegularElementCode({ tag, attrs, children });
|
|
1937
1941
|
}
|
|
1938
1942
|
genTextElementCode(params) {
|
|
@@ -1946,6 +1950,11 @@ class DomCodeGenerator {
|
|
|
1946
1950
|
return this.buildElementStatements(tag, finalAttrs, void 0);
|
|
1947
1951
|
}
|
|
1948
1952
|
}
|
|
1953
|
+
genButtonElementCode(params) {
|
|
1954
|
+
const textContent = this.extractTextContent(params.children);
|
|
1955
|
+
const finalAttrs = this.mergeTextAttributes(params.attrs, textContent);
|
|
1956
|
+
return this.buildElementStatements(params.tag, finalAttrs, void 0);
|
|
1957
|
+
}
|
|
1949
1958
|
genRegularElementCode(params) {
|
|
1950
1959
|
const { tag, attrs, children } = params;
|
|
1951
1960
|
return this.buildElementStatements(tag, attrs, children);
|
|
@@ -3802,7 +3811,7 @@ function processInterpolation(context) {
|
|
|
3802
3811
|
return;
|
|
3803
3812
|
}
|
|
3804
3813
|
context.template += " ";
|
|
3805
|
-
const isParentText = context.options.templateMode === "factory" && context.parent && context.parent.node.type === 1 && context.parent.node.tag === "text";
|
|
3814
|
+
const isParentText = context.options.templateMode === "factory" && context.parent && context.parent.node.type === 1 && (context.parent.node.tag === "text" || context.parent.node.tag === "button");
|
|
3806
3815
|
const id = isParentText ? context.parent.reference() : context.reference();
|
|
3807
3816
|
if (values.length === 0) {
|
|
3808
3817
|
return;
|
|
@@ -3827,7 +3836,7 @@ function processInterpolation(context) {
|
|
|
3827
3836
|
}
|
|
3828
3837
|
function processTextContainer(children, context) {
|
|
3829
3838
|
if (context.options.templateMode === "factory") {
|
|
3830
|
-
if (context.node.tag === "text") {
|
|
3839
|
+
if (context.node.tag === "text" || context.node.tag === "button") {
|
|
3831
3840
|
return;
|
|
3832
3841
|
}
|
|
3833
3842
|
}
|
|
@@ -34407,6 +34407,7 @@ class HtmlParser {
|
|
|
34407
34407
|
}
|
|
34408
34408
|
|
|
34409
34409
|
const NODE_TYPE_TEXT = "text";
|
|
34410
|
+
const NODE_TYPE_BUTTON = "button";
|
|
34410
34411
|
const NODE_TYPE_COMMENT = "comment";
|
|
34411
34412
|
const NODE_TYPE_ELEMENT = "element";
|
|
34412
34413
|
const VALUE_ATTR = "value";
|
|
@@ -34461,6 +34462,9 @@ class DomCodeGenerator {
|
|
|
34461
34462
|
if (tag === NODE_TYPE_TEXT) {
|
|
34462
34463
|
return this.genTextElementCode({ tag, attrs, children });
|
|
34463
34464
|
}
|
|
34465
|
+
if (tag === NODE_TYPE_BUTTON) {
|
|
34466
|
+
return this.genButtonElementCode({ tag, attrs, children });
|
|
34467
|
+
}
|
|
34464
34468
|
return this.genRegularElementCode({ tag, attrs, children });
|
|
34465
34469
|
}
|
|
34466
34470
|
genTextElementCode(params) {
|
|
@@ -34474,6 +34478,11 @@ class DomCodeGenerator {
|
|
|
34474
34478
|
return this.buildElementStatements(tag, finalAttrs, void 0);
|
|
34475
34479
|
}
|
|
34476
34480
|
}
|
|
34481
|
+
genButtonElementCode(params) {
|
|
34482
|
+
const textContent = this.extractTextContent(params.children);
|
|
34483
|
+
const finalAttrs = this.mergeTextAttributes(params.attrs, textContent);
|
|
34484
|
+
return this.buildElementStatements(params.tag, finalAttrs, void 0);
|
|
34485
|
+
}
|
|
34477
34486
|
genRegularElementCode(params) {
|
|
34478
34487
|
const { tag, attrs, children } = params;
|
|
34479
34488
|
return this.buildElementStatements(tag, attrs, children);
|
|
@@ -36316,7 +36325,7 @@ function processInterpolation(context) {
|
|
|
36316
36325
|
return;
|
|
36317
36326
|
}
|
|
36318
36327
|
context.template += " ";
|
|
36319
|
-
const isParentText = context.options.templateMode === "factory" && context.parent && context.parent.node.type === 1 && context.parent.node.tag === "text";
|
|
36328
|
+
const isParentText = context.options.templateMode === "factory" && context.parent && context.parent.node.type === 1 && (context.parent.node.tag === "text" || context.parent.node.tag === "button");
|
|
36320
36329
|
const id = isParentText ? context.parent.reference() : context.reference();
|
|
36321
36330
|
if (values.length === 0) {
|
|
36322
36331
|
return;
|
|
@@ -36341,7 +36350,7 @@ function processInterpolation(context) {
|
|
|
36341
36350
|
}
|
|
36342
36351
|
function processTextContainer(children, context) {
|
|
36343
36352
|
if (context.options.templateMode === "factory") {
|
|
36344
|
-
if (context.node.tag === "text") {
|
|
36353
|
+
if (context.node.tag === "text" || context.node.tag === "button") {
|
|
36345
36354
|
return;
|
|
36346
36355
|
}
|
|
36347
36356
|
}
|
|
@@ -3179,8 +3179,8 @@ function toHandlers(obj, preserveCaseIfNecessary) {
|
|
|
3179
3179
|
}
|
|
3180
3180
|
|
|
3181
3181
|
const getPublicInstance = (i) => {
|
|
3182
|
-
if (!i
|
|
3183
|
-
if (isStatefulComponent(i))
|
|
3182
|
+
if (!i) return null;
|
|
3183
|
+
if (i.vapor || isStatefulComponent(i))
|
|
3184
3184
|
return getComponentPublicInstance(i);
|
|
3185
3185
|
return getPublicInstance(i.parent);
|
|
3186
3186
|
};
|
|
@@ -8141,7 +8141,7 @@ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
|
|
|
8141
8141
|
|
|
8142
8142
|
let currentInstance = null;
|
|
8143
8143
|
const getCurrentGenericInstance = () => currentInstance || currentRenderingInstance;
|
|
8144
|
-
const getCurrentInstance = () =>
|
|
8144
|
+
const getCurrentInstance = () => getCurrentGenericInstance();
|
|
8145
8145
|
exports.isInSSRComponentSetup = false;
|
|
8146
8146
|
let setInSSRSetupState;
|
|
8147
8147
|
let simpleSetCurrentInstance;
|
|
@@ -8165,8 +8165,8 @@ const emptyAppContext = createAppContext();
|
|
|
8165
8165
|
let uid = 0;
|
|
8166
8166
|
function createComponentInstance(vnode, parent, suspense) {
|
|
8167
8167
|
const type = vnode.type;
|
|
8168
|
-
if (type.__file) {
|
|
8169
|
-
console.log("vue3 \u6807\u51C6\u6A21\u5F0F\uFF1A", `at ${type.__file}:1`);
|
|
8168
|
+
if (type.__file || type.__name) {
|
|
8169
|
+
console.log("vue3 \u6807\u51C6\u6A21\u5F0F\uFF1A", `at ${type.__file || type.__name}:1`);
|
|
8170
8170
|
}
|
|
8171
8171
|
const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
|
|
8172
8172
|
const instance = {
|
|
@@ -2463,8 +2463,8 @@ function toHandlers(obj, preserveCaseIfNecessary) {
|
|
|
2463
2463
|
}
|
|
2464
2464
|
|
|
2465
2465
|
const getPublicInstance = (i) => {
|
|
2466
|
-
if (!i
|
|
2467
|
-
if (isStatefulComponent(i))
|
|
2466
|
+
if (!i) return null;
|
|
2467
|
+
if (i.vapor || isStatefulComponent(i))
|
|
2468
2468
|
return getComponentPublicInstance(i);
|
|
2469
2469
|
return getPublicInstance(i.parent);
|
|
2470
2470
|
};
|
|
@@ -6569,7 +6569,7 @@ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
|
|
|
6569
6569
|
|
|
6570
6570
|
let currentInstance = null;
|
|
6571
6571
|
const getCurrentGenericInstance = () => currentInstance || currentRenderingInstance;
|
|
6572
|
-
const getCurrentInstance = () =>
|
|
6572
|
+
const getCurrentInstance = () => getCurrentGenericInstance();
|
|
6573
6573
|
exports.isInSSRComponentSetup = false;
|
|
6574
6574
|
let setInSSRSetupState;
|
|
6575
6575
|
let simpleSetCurrentInstance;
|
|
@@ -6593,8 +6593,8 @@ const emptyAppContext = createAppContext();
|
|
|
6593
6593
|
let uid = 0;
|
|
6594
6594
|
function createComponentInstance(vnode, parent, suspense) {
|
|
6595
6595
|
const type = vnode.type;
|
|
6596
|
-
if (type.__file) {
|
|
6597
|
-
console.log("vue3 \u6807\u51C6\u6A21\u5F0F\uFF1A", `at ${type.__file}:1`);
|
|
6596
|
+
if (type.__file || type.__name) {
|
|
6597
|
+
console.log("vue3 \u6807\u51C6\u6A21\u5F0F\uFF1A", `at ${type.__file || type.__name}:1`);
|
|
6598
6598
|
}
|
|
6599
6599
|
const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
|
|
6600
6600
|
const instance = {
|
|
@@ -3198,8 +3198,8 @@ function toHandlers(obj, preserveCaseIfNecessary) {
|
|
|
3198
3198
|
}
|
|
3199
3199
|
|
|
3200
3200
|
const getPublicInstance = (i) => {
|
|
3201
|
-
if (!i
|
|
3202
|
-
if (isStatefulComponent(i))
|
|
3201
|
+
if (!i) return null;
|
|
3202
|
+
if (i.vapor || isStatefulComponent(i))
|
|
3203
3203
|
return getComponentPublicInstance(i);
|
|
3204
3204
|
return getPublicInstance(i.parent);
|
|
3205
3205
|
};
|
|
@@ -8215,7 +8215,7 @@ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
|
|
|
8215
8215
|
|
|
8216
8216
|
let currentInstance = null;
|
|
8217
8217
|
const getCurrentGenericInstance = () => currentInstance || currentRenderingInstance;
|
|
8218
|
-
const getCurrentInstance = () =>
|
|
8218
|
+
const getCurrentInstance = () => getCurrentGenericInstance();
|
|
8219
8219
|
let isInSSRComponentSetup = false;
|
|
8220
8220
|
let setInSSRSetupState;
|
|
8221
8221
|
let simpleSetCurrentInstance;
|
|
@@ -8242,8 +8242,8 @@ function nextUid() {
|
|
|
8242
8242
|
}
|
|
8243
8243
|
function createComponentInstance(vnode, parent, suspense) {
|
|
8244
8244
|
const type = vnode.type;
|
|
8245
|
-
if (type.__file) {
|
|
8246
|
-
console.log("vue3 \u6807\u51C6\u6A21\u5F0F\uFF1A", `at ${type.__file}:1`);
|
|
8245
|
+
if (type.__file || type.__name) {
|
|
8246
|
+
console.log("vue3 \u6807\u51C6\u6A21\u5F0F\uFF1A", `at ${type.__file || type.__name}:1`);
|
|
8247
8247
|
}
|
|
8248
8248
|
const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
|
|
8249
8249
|
const instance = {
|
|
@@ -5458,8 +5458,8 @@ function toHandlers(obj, preserveCaseIfNecessary) {
|
|
|
5458
5458
|
}
|
|
5459
5459
|
|
|
5460
5460
|
const getPublicInstance = (i) => {
|
|
5461
|
-
if (!i
|
|
5462
|
-
if (isStatefulComponent(i))
|
|
5461
|
+
if (!i) return null;
|
|
5462
|
+
if (i.vapor || isStatefulComponent(i))
|
|
5463
5463
|
return getComponentPublicInstance(i);
|
|
5464
5464
|
return getPublicInstance(i.parent);
|
|
5465
5465
|
};
|
|
@@ -10420,7 +10420,7 @@ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
|
|
|
10420
10420
|
|
|
10421
10421
|
let currentInstance = null;
|
|
10422
10422
|
const getCurrentGenericInstance = () => currentInstance || currentRenderingInstance;
|
|
10423
|
-
const getCurrentInstance = () =>
|
|
10423
|
+
const getCurrentInstance = () => getCurrentGenericInstance();
|
|
10424
10424
|
let isInSSRComponentSetup = false;
|
|
10425
10425
|
let setInSSRSetupState;
|
|
10426
10426
|
let simpleSetCurrentInstance;
|
|
@@ -10444,8 +10444,8 @@ const emptyAppContext = createAppContext();
|
|
|
10444
10444
|
let uid = 0;
|
|
10445
10445
|
function createComponentInstance(vnode, parent, suspense) {
|
|
10446
10446
|
const type = vnode.type;
|
|
10447
|
-
if (type.__file) {
|
|
10448
|
-
console.log("vue3 \u6807\u51C6\u6A21\u5F0F\uFF1A", `at ${type.__file}:1`);
|
|
10447
|
+
if (type.__file || type.__name) {
|
|
10448
|
+
console.log("vue3 \u6807\u51C6\u6A21\u5F0F\uFF1A", `at ${type.__file || type.__name}:1`);
|
|
10449
10449
|
}
|
|
10450
10450
|
const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
|
|
10451
10451
|
const instance = {
|