@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/hbx/index.js
CHANGED
|
@@ -32,10 +32,12 @@ Object.defineProperty(exports, "formatInstallHBuilderXPluginTips", { enumerable:
|
|
|
32
32
|
function uniHBuilderXConsolePlugin(method = '__f__') {
|
|
33
33
|
const exclude = [];
|
|
34
34
|
if (process.env.UNI_APP_X === 'true') {
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
35
|
+
const workersDirs = (0, workers_1.resolveWorkersDir)(process.env.UNI_INPUT_DIR);
|
|
36
|
+
if (workersDirs.length) {
|
|
37
37
|
// 排除workers目录
|
|
38
|
-
|
|
38
|
+
for (const workersDir of workersDirs) {
|
|
39
|
+
exclude.push((0, utils_1.pathToGlob)(path_1.default.join(process.env.UNI_INPUT_DIR, workersDir), '**/*'));
|
|
40
|
+
}
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
return (0, console_1.uniConsolePlugin)({
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare function getAppRenderer(manifestJson: Record<string, any>): "" | "native";
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function getAppCodeSplitting(manifestJson: Record<string, any>): boolean;
|
|
3
3
|
export declare function getAppStyleIsolation(manifestJson: Record<string, any>): 'apply-shared' | 'isolated' | 'shared';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAppStyleIsolation = exports.
|
|
3
|
+
exports.getAppStyleIsolation = exports.getAppCodeSplitting = exports.getAppRenderer = void 0;
|
|
4
4
|
function getAppRenderer(manifestJson) {
|
|
5
5
|
const platformOptions = manifestJson['app-plus'];
|
|
6
6
|
if (platformOptions && platformOptions.renderer === 'native') {
|
|
@@ -9,13 +9,13 @@ function getAppRenderer(manifestJson) {
|
|
|
9
9
|
return '';
|
|
10
10
|
}
|
|
11
11
|
exports.getAppRenderer = getAppRenderer;
|
|
12
|
-
function
|
|
13
|
-
if (manifestJson['app-plus']?.optimization?.
|
|
12
|
+
function getAppCodeSplitting(manifestJson) {
|
|
13
|
+
if (manifestJson['app-plus']?.optimization?.codeSplitting === true) {
|
|
14
14
|
return true;
|
|
15
15
|
}
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
18
|
-
exports.
|
|
18
|
+
exports.getAppCodeSplitting = getAppCodeSplitting;
|
|
19
19
|
function getAppStyleIsolation(manifestJson) {
|
|
20
20
|
return (manifestJson['app-plus']?.optimization?.styleIsolation ?? 'apply-shared');
|
|
21
21
|
}
|
|
@@ -31,9 +31,11 @@ const checksystemwebview_1 = require("./checksystemwebview");
|
|
|
31
31
|
const tabBar_1 = require("./tabBar");
|
|
32
32
|
const i18n_1 = require("./i18n");
|
|
33
33
|
const theme_1 = require("../../theme");
|
|
34
|
+
const manifest_1 = require("../../manifest");
|
|
34
35
|
function normalizeAppManifestJson(userManifestJson, pagesJson) {
|
|
35
36
|
const manifestJson = (0, merge_1.initRecursiveMerge)((0, defaultManifestJson_1.initDefaultManifestJson)(), userManifestJson);
|
|
36
|
-
const
|
|
37
|
+
const manifestJsonPlatform = (0, manifest_1.getPlatformManifestJson)(manifestJson);
|
|
38
|
+
const { pages, globalStyle, tabBar } = (0, theme_1.initTheme)(manifestJsonPlatform, pagesJson);
|
|
37
39
|
(0, shared_1.extend)(pagesJson, JSON.parse(JSON.stringify({ pages, globalStyle, tabBar })));
|
|
38
40
|
(0, statusbar_1.initAppStatusbar)(manifestJson, pagesJson);
|
|
39
41
|
(0, arguments_1.initArguments)(manifestJson, pagesJson);
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function staticImportPageCode(pagesJson: Record<string, any>): string;
|
|
2
|
+
export declare function definePageCode(pagesJson: Record<string, any>, platform?: UniApp.PLATFORM, dynamicImport?: boolean): string;
|
|
2
3
|
export declare function defineNVuePageCode(pagesJson: Record<string, any>): string;
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defineNVuePageCode = exports.definePageCode = void 0;
|
|
3
|
+
exports.defineNVuePageCode = exports.definePageCode = exports.staticImportPageCode = void 0;
|
|
4
4
|
const utils_1 = require("../../../utils");
|
|
5
|
-
function
|
|
5
|
+
function staticImportPageCode(pagesJson) {
|
|
6
|
+
const importPagesCode = [];
|
|
7
|
+
pagesJson.pages.forEach((page) => {
|
|
8
|
+
const pagePath = page.path;
|
|
9
|
+
const pagePathWithExtname = (0, utils_1.normalizePagePath)(pagePath, 'app');
|
|
10
|
+
if (pagePathWithExtname) {
|
|
11
|
+
importPagesCode.push(`import '../assets/${(0, utils_1.removeExt)(pagePathWithExtname)}'`);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
return importPagesCode.join('\n');
|
|
15
|
+
}
|
|
16
|
+
exports.staticImportPageCode = staticImportPageCode;
|
|
17
|
+
function definePageCode(pagesJson, platform = 'app', dynamicImport = false) {
|
|
6
18
|
const importPagesCode = [];
|
|
7
19
|
const definePagesCode = [];
|
|
8
20
|
pagesJson.pages.forEach((page) => {
|
|
@@ -13,7 +25,7 @@ function definePageCode(pagesJson, platform = 'app') {
|
|
|
13
25
|
const pageIdentifier = (0, utils_1.normalizeIdentifier)(pagePath);
|
|
14
26
|
const pagePathWithExtname = (0, utils_1.normalizePagePath)(pagePath, platform);
|
|
15
27
|
if (pagePathWithExtname) {
|
|
16
|
-
if (
|
|
28
|
+
if (dynamicImport) {
|
|
17
29
|
// 拆分页面
|
|
18
30
|
importPagesCode.push(`const ${pageIdentifier} = ()=>import('./${pagePathWithExtname}')`);
|
|
19
31
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { staticImportPageCode } from './definePage';
|
|
2
|
+
export declare function normalizeAppPagesJson(pagesJson: Record<string, any>, platform?: UniApp.PLATFORM, dynamicImport?: boolean): string;
|
|
2
3
|
export declare function normalizeAppNVuePagesJson(pagesJson: Record<string, any>): string;
|
|
3
4
|
export declare function normalizeAppConfigService(pagesJson: UniApp.PagesJson, manifestJson: Record<string, any>): string;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeAppConfigService = exports.normalizeAppNVuePagesJson = exports.normalizeAppPagesJson = void 0;
|
|
3
|
+
exports.normalizeAppConfigService = exports.normalizeAppNVuePagesJson = exports.normalizeAppPagesJson = exports.staticImportPageCode = void 0;
|
|
4
4
|
const code_1 = require("./code");
|
|
5
5
|
const definePage_1 = require("./definePage");
|
|
6
6
|
const uniConfig_1 = require("./uniConfig");
|
|
7
7
|
const uniRoutes_1 = require("./uniRoutes");
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
var definePage_2 = require("./definePage");
|
|
9
|
+
Object.defineProperty(exports, "staticImportPageCode", { enumerable: true, get: function () { return definePage_2.staticImportPageCode; } });
|
|
10
|
+
function normalizeAppPagesJson(pagesJson, platform = 'app', dynamicImport = false) {
|
|
11
|
+
return (0, definePage_1.definePageCode)(pagesJson, platform, dynamicImport);
|
|
10
12
|
}
|
|
11
13
|
exports.normalizeAppPagesJson = normalizeAppPagesJson;
|
|
12
14
|
function normalizeAppNVuePagesJson(pagesJson) {
|
package/dist/json/mp/types.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ interface SubPackage {
|
|
|
37
37
|
root: string;
|
|
38
38
|
pages: string[];
|
|
39
39
|
independent?: boolean;
|
|
40
|
+
plugins?: Plugins;
|
|
40
41
|
}
|
|
41
42
|
interface TabBarItem {
|
|
42
43
|
pagePath: string;
|
|
@@ -63,6 +64,8 @@ interface Plugins {
|
|
|
63
64
|
[name: string]: {
|
|
64
65
|
version: string;
|
|
65
66
|
provider: string;
|
|
67
|
+
export?: string;
|
|
68
|
+
lazy?: boolean;
|
|
66
69
|
};
|
|
67
70
|
}
|
|
68
71
|
interface PreloadRule {
|
package/dist/json/theme.js
CHANGED
|
@@ -8,7 +8,6 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const json_1 = require("./json");
|
|
10
10
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
11
|
-
const manifest_1 = require("./manifest");
|
|
12
11
|
function hasThemeJson(themeLocation) {
|
|
13
12
|
if (!fs_1.default.existsSync(themeLocation)) {
|
|
14
13
|
return false;
|
|
@@ -84,9 +83,7 @@ exports.normalizeThemeConfigOnce = (0, uni_shared_1.once)((manifestJsonPlatform
|
|
|
84
83
|
return themeConfig;
|
|
85
84
|
});
|
|
86
85
|
function initTheme(manifestJson, pagesJson) {
|
|
87
|
-
const
|
|
88
|
-
const manifestPlatform = (0, manifest_1.getPlatformManifestJson)(manifestJson, platform) || {};
|
|
89
|
-
const themeConfig = (0, exports.normalizeThemeConfigOnce)(manifestPlatform);
|
|
86
|
+
const themeConfig = (0, exports.normalizeThemeConfigOnce)(manifestJson);
|
|
90
87
|
return (0, uni_shared_1.normalizeStyles)(pagesJson, themeConfig);
|
|
91
88
|
}
|
|
92
89
|
exports.initTheme = initTheme;
|
package/dist/utils.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export declare function enableSourceMap(): boolean;
|
|
|
35
35
|
export declare function requireUniHelpers(): any;
|
|
36
36
|
export declare function normalizeEmitAssetFileName(fileName: string): string;
|
|
37
37
|
export declare function getShadowImagePath(type: string): string;
|
|
38
|
-
export declare function createShadowImageUrl(cdn: number, type?: string): string;
|
|
38
|
+
export declare function createShadowImageUrl(cdn: number, type?: string, isInternational?: boolean): string;
|
|
39
39
|
export declare function isNormalCompileTarget(): boolean;
|
|
40
40
|
/**
|
|
41
41
|
* copy from entities 用于转义实体字符
|
package/dist/utils.js
CHANGED
|
@@ -224,8 +224,11 @@ function getShadowImagePath(type) {
|
|
|
224
224
|
return `/${identStr}img/shadow-${type}.png`;
|
|
225
225
|
}
|
|
226
226
|
exports.getShadowImagePath = getShadowImagePath;
|
|
227
|
-
function createShadowImageUrl(cdn, type = 'grey') {
|
|
228
|
-
|
|
227
|
+
function createShadowImageUrl(cdn, type = 'grey', isInternational = false) {
|
|
228
|
+
const domain = isInternational
|
|
229
|
+
? 'cdn.dcimg.net'
|
|
230
|
+
: `cdn${(cdn || 0) + (process.env.UNI_APP_X === 'true' ? 1000 : 0) || ''}.dcloud.net.cn`;
|
|
231
|
+
return `https://${domain}${getShadowImagePath(type)}`;
|
|
229
232
|
}
|
|
230
233
|
exports.createShadowImageUrl = createShadowImageUrl;
|
|
231
234
|
function isNormalCompileTarget() {
|
|
@@ -81,11 +81,28 @@ function createUniModulesSyncFilePreprocessor(platform, utsPlatform, isX) {
|
|
|
81
81
|
return replaceExtApiPages(rewriteUniModulesConsoleExpr(fileName, preJs(content)));
|
|
82
82
|
}
|
|
83
83
|
else if (extname === '.uvue' || extname === '.vue') {
|
|
84
|
-
return rewriteUniModulesConsoleExpr(fileName, preJs(preHtml(content)));
|
|
84
|
+
return rewriteUniModulesConsoleExpr(fileName, preUTSSDKVueFile(fileName, preJs(preHtml(content))));
|
|
85
85
|
}
|
|
86
86
|
return content;
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
+
function preUTSSDKVueFile(filename, content) {
|
|
90
|
+
if (filename.includes('utssdk') &&
|
|
91
|
+
(filename.includes('app-android') || filename.includes('app-ios'))) {
|
|
92
|
+
const { parse } = require('@vue/compiler-sfc');
|
|
93
|
+
const { descriptor } = parse(content, {
|
|
94
|
+
sourceMap: false,
|
|
95
|
+
pad: 'line',
|
|
96
|
+
});
|
|
97
|
+
if (descriptor.script?.content) {
|
|
98
|
+
return (descriptor.script.content +
|
|
99
|
+
// 补充 template 内容
|
|
100
|
+
`/*${descriptor.template?.content}*/`);
|
|
101
|
+
}
|
|
102
|
+
return content;
|
|
103
|
+
}
|
|
104
|
+
return content;
|
|
105
|
+
}
|
|
89
106
|
function replaceExtApiPages(code) {
|
|
90
107
|
// 定制实现
|
|
91
108
|
if (process.env.UNI_COMPILE_EXT_API_PAGES) {
|
|
@@ -208,7 +225,7 @@ function uniUTSAppUniModulesPlugin(options = {}) {
|
|
|
208
225
|
};
|
|
209
226
|
}
|
|
210
227
|
}
|
|
211
|
-
const { createUniXKotlinCompilerOnce, createUniXSwiftCompilerOnce, createUniXArkTSCompilerOnce, syncUniModuleFilesByCompiler, resolveTscUniModuleIndexFileName, } = (0, uts_1.resolveUTSCompiler)();
|
|
228
|
+
const { createUniXKotlinCompilerOnce, createUniXSwiftCompilerOnce, createUniXArkTSCompilerOnce, syncUniModuleFilesByCompiler, resolveTscUniModuleIndexFileName, resolveTscUniModuleUTSSDKVueFileNames, } = (0, uts_1.resolveUTSCompiler)();
|
|
212
229
|
const resolveWorkers = () => (0, workers_1.getWorkers)();
|
|
213
230
|
const uniXKotlinCompiler = process.env.UNI_APP_X_TSC === 'true' &&
|
|
214
231
|
(process.env.UNI_UTS_PLATFORM === 'app-android' ||
|
|
@@ -255,6 +272,10 @@ function uniUTSAppUniModulesPlugin(options = {}) {
|
|
|
255
272
|
utsPlugins.add(pluginId);
|
|
256
273
|
if (uniXKotlinCompiler) {
|
|
257
274
|
const platform = 'app-android';
|
|
275
|
+
const vueFiles = resolveTscUniModuleUTSSDKVueFileNames(platform, pluginDir);
|
|
276
|
+
for (const vueFile of vueFiles) {
|
|
277
|
+
await uniXKotlinCompiler.addRootFile(vueFile);
|
|
278
|
+
}
|
|
258
279
|
const indexFileName = resolveTscUniModuleIndexFileName(platform, pluginDir);
|
|
259
280
|
if (indexFileName) {
|
|
260
281
|
await uniXKotlinCompiler.addRootFile(indexFileName);
|
|
@@ -262,6 +283,10 @@ function uniUTSAppUniModulesPlugin(options = {}) {
|
|
|
262
283
|
}
|
|
263
284
|
if (uniXSwiftCompiler) {
|
|
264
285
|
const platform = 'app-ios';
|
|
286
|
+
const vueFiles = resolveTscUniModuleUTSSDKVueFileNames(platform, pluginDir);
|
|
287
|
+
for (const vueFile of vueFiles) {
|
|
288
|
+
await uniXSwiftCompiler.addRootFile(vueFile);
|
|
289
|
+
}
|
|
265
290
|
const indexFileName = resolveTscUniModuleIndexFileName(platform, pluginDir);
|
|
266
291
|
if (indexFileName) {
|
|
267
292
|
await uniXSwiftCompiler.addRootFile(indexFileName);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type NodeTransform } from '@vue/compiler-core';
|
|
1
|
+
import { type NodeTransform, type TransformContext } from '@vue/compiler-core';
|
|
2
2
|
export interface AssetURLTagConfig {
|
|
3
3
|
[name: string]: string[];
|
|
4
4
|
}
|
|
@@ -13,6 +13,10 @@ export interface AssetURLOptions {
|
|
|
13
13
|
*/
|
|
14
14
|
includeAbsolute?: boolean;
|
|
15
15
|
tags?: AssetURLTagConfig;
|
|
16
|
+
/**
|
|
17
|
+
* 将static静态资源转换为绝对路径的函数
|
|
18
|
+
*/
|
|
19
|
+
resolveStaticAsset?: ((relativePath: string, context: TransformContext, options: AssetURLOptions) => string) | null;
|
|
16
20
|
}
|
|
17
21
|
export declare const defaultAssetUrlOptions: Required<AssetURLOptions>;
|
|
18
22
|
export declare const normalizeOptions: (options: AssetURLOptions | AssetURLTagConfig) => Required<AssetURLOptions>;
|
|
@@ -18,6 +18,7 @@ exports.defaultAssetUrlOptions = {
|
|
|
18
18
|
image: ['xlink:href', 'href'],
|
|
19
19
|
use: ['xlink:href', 'href'],
|
|
20
20
|
},
|
|
21
|
+
resolveStaticAsset: null,
|
|
21
22
|
};
|
|
22
23
|
const normalizeOptions = (options) => {
|
|
23
24
|
if (Object.keys(options).some((key) => (0, shared_1.isArray)(options[key]))) {
|
|
@@ -89,20 +90,28 @@ const transformAssetUrl = (node, context, options = exports.defaultAssetUrlOptio
|
|
|
89
90
|
// 当static相对路径经过vue的transformAssetUrl后,就变成了 import 语句,不会再走到下边的逻辑里
|
|
90
91
|
// 最初的设计,应该是用uni-app的transformAssetUrl来直接替换vue的transformAssetUrl的。
|
|
91
92
|
// 如果后续要替换,需要考虑这个问题
|
|
92
|
-
if (
|
|
93
|
-
//
|
|
94
|
-
//
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
93
|
+
if (attr.value.content[0] === '.' && isStaticAsset) {
|
|
94
|
+
// resolveStaticAsset 里边会处理分包、uni_modules里的 static 资源
|
|
95
|
+
// 为了减少影响范围,目前仅限蒸汽模式的App端使用吧。
|
|
96
|
+
if (options.resolveStaticAsset) {
|
|
97
|
+
attr.value.content = options.resolveStaticAsset(attr.value.content, context, options);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (options.base) {
|
|
101
|
+
// explicit base - directly rewrite relative urls into absolute url
|
|
102
|
+
// to avoid generating extra imports
|
|
103
|
+
// Allow for full hostnames provided in options.base
|
|
104
|
+
const base = (0, templateUtils_1.parseUrl)(options.base);
|
|
105
|
+
const protocol = base.protocol || '';
|
|
106
|
+
const host = base.host ? protocol + '//' + base.host : '';
|
|
107
|
+
const basePath = base.path || '/';
|
|
108
|
+
// when packaged in the browser, path will be using the posix-
|
|
109
|
+
// only version provided by rollup-plugin-node-builtins.
|
|
110
|
+
attr.value.content =
|
|
111
|
+
host +
|
|
112
|
+
(path_1.default.posix || path_1.default).join(basePath, url.path + (url.hash || ''));
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
106
115
|
}
|
|
107
116
|
// otherwise, transform the url into an import.
|
|
108
117
|
// this assumes a bundler will resolve the import into the correct
|
package/dist/vue/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type AttributeNode, type ComponentNode, type DirectiveNode, type ElementNode, type ExpressionNode, type Position, type RootNode, type SourceLocation, type TemplateChildNode, type TransformContext } from '@vue/compiler-core';
|
|
2
|
+
import { type AssetURLOptions } from './transforms/templateTransformAssetUrl';
|
|
2
3
|
export declare const VUE_REF = "r";
|
|
3
4
|
export declare const VUE_REF_IN_FOR = "r-i-f";
|
|
4
5
|
export declare function isVueSfcFile(id: string): boolean;
|
|
@@ -10,7 +11,7 @@ export declare function addStaticClass(node: ElementNode, clazz: string): string
|
|
|
10
11
|
export declare function createDirectiveNode(name: string, arg: string, exp?: string | ExpressionNode): DirectiveNode;
|
|
11
12
|
export declare function createOnDirectiveNode(name: string, value: string | ExpressionNode): DirectiveNode;
|
|
12
13
|
export declare function createBindDirectiveNode(name: string, value: string | ExpressionNode): DirectiveNode;
|
|
13
|
-
export declare function createUniVueTransformAssetUrls(base: string): {
|
|
14
|
+
export declare function createUniVueTransformAssetUrls(base: string, resolveStaticAsset?: (relativePath: string, context: TransformContext, options: AssetURLOptions) => string): {
|
|
14
15
|
base: string;
|
|
15
16
|
includeAbsolute: boolean;
|
|
16
17
|
tags: {
|
|
@@ -26,10 +27,12 @@ export declare function createUniVueTransformAssetUrls(base: string): {
|
|
|
26
27
|
'u-image': string[];
|
|
27
28
|
'u-video': string[];
|
|
28
29
|
};
|
|
30
|
+
resolveStaticAsset: ((relativePath: string, context: TransformContext, options: AssetURLOptions) => string) | null;
|
|
29
31
|
};
|
|
30
|
-
export declare function getBaseNodeTransforms(base: string): import("@vue/compiler-core").NodeTransform[];
|
|
32
|
+
export declare function getBaseNodeTransforms(base: string, resolveStaticAsset?: (relativePath: string, context: TransformContext, options: AssetURLOptions) => string): import("@vue/compiler-core").NodeTransform[];
|
|
31
33
|
export declare function renameProp(name: string, prop?: DirectiveNode | AttributeNode): void;
|
|
32
34
|
export declare function isPropNameEquals(prop: AttributeNode | DirectiveNode, name: string): boolean;
|
|
33
35
|
export declare function getInnerRange(loc: SourceLocation, offset: number, length: number): SourceLocation;
|
|
34
36
|
export declare function advancePositionWithClone(pos: Position, source: string, numberOfCharacters?: number): Position;
|
|
35
37
|
export declare function advancePositionWithMutation(pos: Position, source: string, numberOfCharacters?: number): Position;
|
|
38
|
+
export declare function createResolveStaticAsset(inputDir: string): (relativePath: string, context: TransformContext, options: AssetURLOptions) => string;
|
package/dist/vue/utils.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.advancePositionWithMutation = exports.advancePositionWithClone = exports.getInnerRange = exports.isPropNameEquals = exports.renameProp = exports.getBaseNodeTransforms = exports.createUniVueTransformAssetUrls = exports.createBindDirectiveNode = exports.createOnDirectiveNode = exports.createDirectiveNode = exports.addStaticClass = exports.createAttributeNode = exports.isUserComponent = exports.isVueSfcFile = exports.VUE_REF_IN_FOR = exports.VUE_REF = void 0;
|
|
6
|
+
exports.createResolveStaticAsset = exports.advancePositionWithMutation = exports.advancePositionWithClone = exports.getInnerRange = exports.isPropNameEquals = exports.renameProp = exports.getBaseNodeTransforms = exports.createUniVueTransformAssetUrls = exports.createBindDirectiveNode = exports.createOnDirectiveNode = exports.createDirectiveNode = exports.addStaticClass = exports.createAttributeNode = exports.isUserComponent = exports.isVueSfcFile = exports.VUE_REF_IN_FOR = exports.VUE_REF = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
4
8
|
const shared_1 = require("@vue/shared");
|
|
5
9
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
6
10
|
const compiler_core_1 = require("@vue/compiler-core");
|
|
@@ -9,6 +13,8 @@ const templateTransformSrcset_1 = require("./transforms/templateTransformSrcset"
|
|
|
9
13
|
const ast_1 = require("../vite/utils/ast");
|
|
10
14
|
const url_1 = require("../vite/utils/url");
|
|
11
15
|
const constants_1 = require("../constants");
|
|
16
|
+
const utils_1 = require("../utils");
|
|
17
|
+
const templateUtils_1 = require("./transforms/templateUtils");
|
|
12
18
|
exports.VUE_REF = 'r';
|
|
13
19
|
exports.VUE_REF_IN_FOR = 'r-i-f';
|
|
14
20
|
function isVueSfcFile(id) {
|
|
@@ -75,7 +81,7 @@ function createBindDirectiveNode(name, value) {
|
|
|
75
81
|
return createDirectiveNode('bind', name, value);
|
|
76
82
|
}
|
|
77
83
|
exports.createBindDirectiveNode = createBindDirectiveNode;
|
|
78
|
-
function createUniVueTransformAssetUrls(base) {
|
|
84
|
+
function createUniVueTransformAssetUrls(base, resolveStaticAsset) {
|
|
79
85
|
return {
|
|
80
86
|
base,
|
|
81
87
|
includeAbsolute: true,
|
|
@@ -94,11 +100,12 @@ function createUniVueTransformAssetUrls(base) {
|
|
|
94
100
|
'u-image': ['src'],
|
|
95
101
|
'u-video': ['src', 'poster'],
|
|
96
102
|
},
|
|
103
|
+
resolveStaticAsset: resolveStaticAsset || null,
|
|
97
104
|
};
|
|
98
105
|
}
|
|
99
106
|
exports.createUniVueTransformAssetUrls = createUniVueTransformAssetUrls;
|
|
100
|
-
function getBaseNodeTransforms(base) {
|
|
101
|
-
const transformAssetUrls = createUniVueTransformAssetUrls(base);
|
|
107
|
+
function getBaseNodeTransforms(base, resolveStaticAsset) {
|
|
108
|
+
const transformAssetUrls = createUniVueTransformAssetUrls(base, resolveStaticAsset);
|
|
102
109
|
return [
|
|
103
110
|
(0, templateTransformAssetUrl_1.createAssetUrlTransformWithOptions)(transformAssetUrls),
|
|
104
111
|
(0, templateTransformSrcset_1.createSrcsetTransformWithOptions)(transformAssetUrls),
|
|
@@ -169,3 +176,23 @@ function advancePositionWithMutation(pos, source, numberOfCharacters = source.le
|
|
|
169
176
|
return pos;
|
|
170
177
|
}
|
|
171
178
|
exports.advancePositionWithMutation = advancePositionWithMutation;
|
|
179
|
+
function createResolveStaticAsset(inputDir) {
|
|
180
|
+
return function resolveStaticAsset(relativePath, context, options) {
|
|
181
|
+
const newRelativePath = (0, utils_1.normalizePath)(path_1.default.relative(inputDir, path_1.default.resolve(path_1.default.dirname(context.filename), relativePath)));
|
|
182
|
+
if (options.base) {
|
|
183
|
+
// explicit base - directly rewrite relative urls into absolute url
|
|
184
|
+
// to avoid generating extra imports
|
|
185
|
+
// Allow for full hostnames provided in options.base
|
|
186
|
+
const base = (0, templateUtils_1.parseUrl)(options.base);
|
|
187
|
+
const protocol = base.protocol || '';
|
|
188
|
+
const host = base.host ? protocol + '//' + base.host : '';
|
|
189
|
+
const basePath = base.path || '/';
|
|
190
|
+
const url = (0, templateUtils_1.parseUrl)(newRelativePath);
|
|
191
|
+
// when packaged in the browser, path will be using the posix-
|
|
192
|
+
// only version provided by rollup-plugin-node-builtins.
|
|
193
|
+
return (host + (path_1.default.posix || path_1.default).join(basePath, url.path + (url.hash || '')));
|
|
194
|
+
}
|
|
195
|
+
return newRelativePath;
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
exports.createResolveStaticAsset = createResolveStaticAsset;
|
package/dist/workers.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
2
|
import type { UniXCompiler } from '@dcloudio/uni-uts-v1';
|
|
3
3
|
export declare function getWorkers(): Record<string, string>;
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function resolveWorkersRootDir(): string;
|
|
5
|
+
export declare function getWorkersRootDirs(): string[];
|
|
5
6
|
/**
|
|
6
7
|
* 遍历目录下的所有uts文件,读取文件内容,正则匹配出定义的worker,返回文件名和类名的映射关系
|
|
7
8
|
* export class MyWorkerTask extends WorkerTaskImpl {}
|
|
8
9
|
* @param dir
|
|
9
10
|
*/
|
|
10
|
-
export declare function initWorkers(
|
|
11
|
+
export declare function initWorkers(workersDirs: string[], rootDir: string): Record<string, string>;
|
|
11
12
|
export declare function uniWorkersPlugin(): Plugin;
|
|
12
|
-
export declare function resolveWorkersDir(inputDir: string):
|
|
13
|
+
export declare function resolveWorkersDir(inputDir: string): Array<string>;
|
|
13
14
|
export declare function uniJavaScriptWorkersPlugin(): Plugin;
|
|
14
15
|
export declare function initUniXCompilerRootWorkers(rootDir: string, compiler: UniXCompiler): Promise<void>;
|