初始化fy
This commit is contained in:
3
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/checkUpdate.d.ts
generated
vendored
Normal file
3
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/checkUpdate.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
declare function checkUpdate1(options: any): Promise<undefined>;
|
||||
export declare const checkUpdate: typeof checkUpdate1;
|
||||
export {};
|
||||
61
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/checkUpdate.js
generated
vendored
Normal file
61
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/checkUpdate.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/* eslint-disable */
|
||||
// @ts-ignore
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.checkUpdate = void 0;
|
||||
var __importDefault = this && this.__importDefault || function (mod) { return mod && mod.__esModule ? mod : { default: mod }; };
|
||||
Object.defineProperty(exports, "__esModule", { value: !0 }), exports.createPostData = exports.getMac = exports.md5 = exports.checkLocalCache = exports.checkUpdate1 = void 0;
|
||||
const fs_extra_1 = __importDefault(require("fs-extra")), os_1 = __importDefault(require("os")), path_1 = __importDefault(require("path")), debug_1 = __importDefault(require("debug")), crypto_1 = __importDefault(require("crypto")), https_1 = require("https"), compare_versions_1 = __importDefault(require("compare-versions")), shared_1 = require("@vue/shared"), json_1 = require("./json"), hbx_1 = require("./hbx"), debugCheckUpdate = (0, debug_1.default)("uni:check-update"), INTERVAL = 864e5;
|
||||
async function checkUpdate1(options) { if (process.env.CI)
|
||||
return void debugCheckUpdate("isInCI"); if ((0, hbx_1.isInHBuilderX)())
|
||||
return void debugCheckUpdate("isInHBuilderX"); const { inputDir: inputDir, compilerVersion: compilerVersion } = options, updateCache = readCheckUpdateCache(inputDir); debugCheckUpdate("read.cache", updateCache); const res = checkLocalCache(updateCache, compilerVersion); res ? (0, shared_1.isString)(res) && (console.log(), console.log(res)) : await checkVersion(options, normalizeUpdateCache(updateCache, (0, json_1.parseManifestJsonOnce)(inputDir))), writeCheckUpdateCache(inputDir, statUpdateCache(normalizeUpdateCache(updateCache))); }
|
||||
function normalizeUpdateCache(updateCache, manifestJson) { const platform = process.env.UNI_PLATFORM; if (updateCache[platform] || (updateCache[platform] = { appid: "", dev: 0, build: 0 }), manifestJson) {
|
||||
const platformOptions = manifestJson["app" === platform ? "app-plus" : platform];
|
||||
updateCache[platform].appid = platformOptions && (platformOptions.appid || platformOptions.package) || "";
|
||||
} return updateCache; }
|
||||
function statUpdateCache(updateCache) { debugCheckUpdate("stat.before", updateCache); const platform = process.env.UNI_PLATFORM, type = "production" === process.env.NODE_ENV ? "build" : "dev", platformOptions = updateCache[platform]; return platformOptions[type] = (platformOptions[type] || 0) + 1, debugCheckUpdate("stat.after", updateCache), updateCache; }
|
||||
function getFilepath(inputDir, filename) { return path_1.default.resolve(os_1.default.tmpdir(), "uni-app-cli", md5(inputDir), filename); }
|
||||
function getCheckUpdateFilepath(inputDir) { return getFilepath(inputDir, "check-update.json"); }
|
||||
function generateVid() { let result = ""; for (let i = 0; i < 4; i++)
|
||||
result += (65536 * (1 + Math.random()) | 0).toString(16).substring(1); return "UNI_" + result.toUpperCase(); }
|
||||
function createCheckUpdateCache(vid = generateVid()) { return { vid: generateVid(), lastCheck: 0 }; }
|
||||
function readCheckUpdateCache(inputDir) { const updateFilepath = getCheckUpdateFilepath(inputDir); if (debugCheckUpdate("read:", updateFilepath), fs_extra_1.default.existsSync(updateFilepath))
|
||||
try {
|
||||
return require(updateFilepath);
|
||||
}
|
||||
catch (e) {
|
||||
debugCheckUpdate("read.error", e);
|
||||
} return createCheckUpdateCache(); }
|
||||
function checkLocalCache(updateCache, compilerVersion, interval = INTERVAL) { return updateCache.lastCheck ? Date.now() - updateCache.lastCheck > interval ? (debugCheckUpdate("cache: lastCheck > interval"), !1) : !(updateCache.newVersion && (0, compare_versions_1.default)(updateCache.newVersion, compilerVersion) > 0) || (debugCheckUpdate("cache: find new version"), updateCache.note) : (debugCheckUpdate("cache: lastCheck not found"), !1); }
|
||||
function writeCheckUpdateCache(inputDir, updateCache) { const filepath = getCheckUpdateFilepath(inputDir); debugCheckUpdate("write:", filepath, updateCache); try {
|
||||
fs_extra_1.default.outputFileSync(filepath, JSON.stringify(updateCache));
|
||||
}
|
||||
catch (e) {
|
||||
debugCheckUpdate("write.error", e);
|
||||
} }
|
||||
function md5(str) { return crypto_1.default.createHash("md5").update(str).digest("hex"); }
|
||||
function getMac() { let mac = ""; const network = os_1.default.networkInterfaces(); for (const key in network) {
|
||||
const array = network[key];
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const item = array[i];
|
||||
if (item.family && (!item.mac || "00:00:00:00:00:00" !== item.mac)) {
|
||||
if ((0, shared_1.isString)(item.family) && ("IPv4" === item.family || "IPv6" === item.family)) {
|
||||
mac = item.mac;
|
||||
break;
|
||||
}
|
||||
if ("number" == typeof item.family && (4 === item.family || 6 === item.family)) {
|
||||
mac = item.mac;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} return mac; }
|
||||
function createPostData({ versionType: versionType, compilerVersion: compilerVersion }, manifestJson, updateCache) { const data = { vv: 3, device: md5(getMac()), vtype: versionType, vcode: compilerVersion }; return manifestJson.appid ? data.appid = manifestJson.appid : data.vid = updateCache.vid, Object.keys(updateCache).forEach((name => { const value = updateCache[name]; (0, shared_1.isPlainObject)(value) && ((0, shared_1.hasOwn)(value, "dev") || (0, shared_1.hasOwn)(value, "build")) && (data[name] = value); })), JSON.stringify(data); }
|
||||
function handleCheckVersion({ code: code, isUpdate: isUpdate, newVersion: newVersion, note: note }, updateCache) { 0 === code && (Object.keys(updateCache).forEach((key => { "vid" !== key && delete updateCache[key]; })), updateCache.lastCheck = Date.now(), isUpdate ? (updateCache.note = note, updateCache.newVersion = newVersion) : (delete updateCache.note, delete updateCache.newVersion)); }
|
||||
exports.checkUpdate1 = checkUpdate1, exports.checkLocalCache = checkLocalCache, exports.md5 = md5, exports.getMac = getMac, exports.createPostData = createPostData;
|
||||
const HOSTNAME = "uniapp.dcloud.net.cn", PATH = "/update/cli";
|
||||
function checkVersion(options, updateCache) { return new Promise((resolve => { const postData = JSON.stringify({ id: createPostData(options, (0, json_1.parseManifestJsonOnce)(options.inputDir), updateCache) }); let responseData = ""; const req = (0, https_1.request)({ hostname: HOSTNAME, path: PATH, port: 443, method: "POST", headers: { "Content-Type": "application/json", "Content-Length": postData.length } }, (res => { res.setEncoding("utf8"), res.on("data", (chunk => { responseData += chunk; })), res.on("end", (() => { debugCheckUpdate("response: ", responseData); try {
|
||||
handleCheckVersion(JSON.parse(responseData), updateCache);
|
||||
}
|
||||
catch (e) { } resolve(!0); })), res.on("error", (e => { debugCheckUpdate("response.error:", e), resolve(!1); })); })).on("error", (e => { debugCheckUpdate("request.error:", e), resolve(!1); })); debugCheckUpdate("request: ", postData), req.write(postData), req.end(); })); }
|
||||
exports.checkUpdate = checkUpdate1;
|
||||
36
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/constants.d.ts
generated
vendored
Normal file
36
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/constants.d.ts
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
export declare const PUBLIC_DIR = "static";
|
||||
export declare const EXTNAME_JS: string[];
|
||||
export declare const EXTNAME_TS: string[];
|
||||
export declare const EXTNAME_VUE: string[];
|
||||
export declare const X_EXTNAME_VUE: string[];
|
||||
export declare const EXTNAME_VUE_TEMPLATE: string[];
|
||||
export declare const EXTNAME_VUE_RE: RegExp;
|
||||
export declare const EXTNAME_JS_RE: RegExp;
|
||||
export declare const EXTNAME_TS_RE: RegExp;
|
||||
export declare const extensions: string[];
|
||||
export declare const uni_app_x_extensions: string[];
|
||||
export declare const PAGES_JSON_JS = "pages-json-js";
|
||||
export declare const PAGES_JSON_UTS = "pages-json-uts";
|
||||
export declare const MANIFEST_JSON_JS = "manifest-json-js";
|
||||
export declare const MANIFEST_JSON_UTS = "manifest-json-uts";
|
||||
export declare const JSON_JS_MAP: {
|
||||
readonly 'pages.json': "pages-json-js";
|
||||
readonly 'manifest.json': "manifest-json-js";
|
||||
};
|
||||
export declare const ASSETS_INLINE_LIMIT: number;
|
||||
export declare const APP_SERVICE_FILENAME = "app-service.js";
|
||||
export declare const APP_CONFIG = "app-config.js";
|
||||
export declare const APP_CONFIG_SERVICE = "app-config-service.js";
|
||||
export declare const BINDING_COMPONENTS = "__BINDING_COMPONENTS__";
|
||||
export declare const PAGE_EXTNAME_APP: string[];
|
||||
export declare const PAGE_EXTNAME: string[];
|
||||
export declare const X_PAGE_EXTNAME: string[];
|
||||
export declare const X_PAGE_EXTNAME_APP: string[];
|
||||
export declare const H5_API_STYLE_PATH = "@dcloudio/uni-h5/style/api/";
|
||||
export declare const H5_FRAMEWORK_STYLE_PATH = "@dcloudio/uni-h5/style/framework/";
|
||||
export declare const H5_COMPONENTS_STYLE_PATH = "@dcloudio/uni-h5/style/";
|
||||
export declare const BASE_COMPONENTS_STYLE_PATH = "@dcloudio/uni-components/style/";
|
||||
export declare const COMMON_EXCLUDE: RegExp[];
|
||||
export declare const KNOWN_ASSET_TYPES: string[];
|
||||
export declare const DEFAULT_ASSETS_RE: RegExp;
|
||||
export declare const TEXT_STYLE: string[];
|
||||
87
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/constants.js
generated
vendored
Normal file
87
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/constants.js
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TEXT_STYLE = exports.DEFAULT_ASSETS_RE = exports.KNOWN_ASSET_TYPES = exports.COMMON_EXCLUDE = exports.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = exports.X_PAGE_EXTNAME_APP = exports.X_PAGE_EXTNAME = exports.PAGE_EXTNAME = exports.PAGE_EXTNAME_APP = exports.BINDING_COMPONENTS = exports.APP_CONFIG_SERVICE = exports.APP_CONFIG = exports.APP_SERVICE_FILENAME = exports.ASSETS_INLINE_LIMIT = exports.JSON_JS_MAP = exports.MANIFEST_JSON_UTS = exports.MANIFEST_JSON_JS = exports.PAGES_JSON_UTS = exports.PAGES_JSON_JS = exports.uni_app_x_extensions = exports.extensions = exports.EXTNAME_TS_RE = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE_TEMPLATE = exports.X_EXTNAME_VUE = exports.EXTNAME_VUE = exports.EXTNAME_TS = exports.EXTNAME_JS = exports.PUBLIC_DIR = void 0;
|
||||
exports.PUBLIC_DIR = 'static';
|
||||
exports.EXTNAME_JS = ['.js', '.ts', '.jsx', '.tsx'];
|
||||
exports.EXTNAME_TS = ['.ts', '.tsx'];
|
||||
exports.EXTNAME_VUE = ['.vue', '.nvue', '.uvue'];
|
||||
exports.X_EXTNAME_VUE = ['.uvue', '.vue'];
|
||||
exports.EXTNAME_VUE_TEMPLATE = ['.vue', '.nvue', '.uvue', '.jsx', '.tsx'];
|
||||
exports.EXTNAME_VUE_RE = /\.(vue|nvue|uvue)$/;
|
||||
exports.EXTNAME_JS_RE = /\.(js|jsx|ts|tsx|mjs)$/;
|
||||
exports.EXTNAME_TS_RE = /\.tsx?$/;
|
||||
const COMMON_EXTENSIONS = [
|
||||
'.uts',
|
||||
'.mjs',
|
||||
'.js',
|
||||
'.ts',
|
||||
'.jsx',
|
||||
'.tsx',
|
||||
'.json',
|
||||
];
|
||||
exports.extensions = COMMON_EXTENSIONS.concat(exports.EXTNAME_VUE);
|
||||
exports.uni_app_x_extensions = COMMON_EXTENSIONS.concat(['.uvue', '.vue']);
|
||||
exports.PAGES_JSON_JS = 'pages-json-js';
|
||||
exports.PAGES_JSON_UTS = 'pages-json-uts';
|
||||
exports.MANIFEST_JSON_JS = 'manifest-json-js';
|
||||
exports.MANIFEST_JSON_UTS = 'manifest-json-uts';
|
||||
exports.JSON_JS_MAP = {
|
||||
'pages.json': exports.PAGES_JSON_JS,
|
||||
'manifest.json': exports.MANIFEST_JSON_JS,
|
||||
};
|
||||
exports.ASSETS_INLINE_LIMIT = 40 * 1024;
|
||||
exports.APP_SERVICE_FILENAME = 'app-service.js';
|
||||
exports.APP_CONFIG = 'app-config.js';
|
||||
exports.APP_CONFIG_SERVICE = 'app-config-service.js';
|
||||
exports.BINDING_COMPONENTS = '__BINDING_COMPONENTS__';
|
||||
// APP 平台解析页面后缀的优先级
|
||||
exports.PAGE_EXTNAME_APP = ['.nvue', '.vue', '.tsx', '.jsx', '.js'];
|
||||
// 其他平台解析页面后缀的优先级
|
||||
exports.PAGE_EXTNAME = ['.vue', '.nvue', '.tsx', '.jsx', '.js'];
|
||||
exports.X_PAGE_EXTNAME = ['.vue', '.uvue', '.tsx', '.jsx', '.js'];
|
||||
exports.X_PAGE_EXTNAME_APP = ['.uvue', '.tsx', '.jsx', '.js'];
|
||||
exports.H5_API_STYLE_PATH = '@dcloudio/uni-h5/style/api/';
|
||||
exports.H5_FRAMEWORK_STYLE_PATH = '@dcloudio/uni-h5/style/framework/';
|
||||
exports.H5_COMPONENTS_STYLE_PATH = '@dcloudio/uni-h5/style/';
|
||||
exports.BASE_COMPONENTS_STYLE_PATH = '@dcloudio/uni-components/style/';
|
||||
exports.COMMON_EXCLUDE = [
|
||||
/\/pages\.json\.js$/,
|
||||
/\/manifest\.json\.js$/,
|
||||
/\/vite\//,
|
||||
/\/@vue\//,
|
||||
/\/vue-router\//,
|
||||
/\/vuex\//,
|
||||
/\/vue-i18n\//,
|
||||
/\/@dcloudio\/uni-h5-vue/,
|
||||
/\/@dcloudio\/uni-shared/,
|
||||
/\/@dcloudio\/uni-h5\/style/,
|
||||
/\/@dcloudio\/uni-components\/style/,
|
||||
];
|
||||
exports.KNOWN_ASSET_TYPES = [
|
||||
// images
|
||||
'png',
|
||||
'jpe?g',
|
||||
'gif',
|
||||
'svg',
|
||||
'ico',
|
||||
'webp',
|
||||
'avif',
|
||||
// media
|
||||
'mp4',
|
||||
'webm',
|
||||
'ogg',
|
||||
'mp3',
|
||||
'wav',
|
||||
'flac',
|
||||
'aac',
|
||||
// fonts
|
||||
'woff2?',
|
||||
'eot',
|
||||
'ttf',
|
||||
'otf',
|
||||
// other
|
||||
'pdf',
|
||||
'txt',
|
||||
];
|
||||
exports.DEFAULT_ASSETS_RE = new RegExp(`\\.(` + exports.KNOWN_ASSET_TYPES.join('|') + `)(\\?.*)?$`);
|
||||
exports.TEXT_STYLE = ['black', 'white'];
|
||||
19
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/deps.d.ts
generated
vendored
Normal file
19
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/deps.d.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
export declare const API_DEPS_CSS: {
|
||||
showModal: string[];
|
||||
showToast: string[];
|
||||
showActionSheet: string[];
|
||||
previewImage: string[];
|
||||
openLocation: string[];
|
||||
chooseLocation: string[];
|
||||
};
|
||||
export declare const COMPONENT_DEPS_CSS: {
|
||||
canvas: string[];
|
||||
image: string[];
|
||||
'movable-area': string[];
|
||||
'picker-view': string[];
|
||||
'picker-view-column': string[];
|
||||
'rich-text': string[];
|
||||
textarea: string[];
|
||||
'web-view': string[];
|
||||
picker: string[];
|
||||
};
|
||||
39
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/deps.js
generated
vendored
Normal file
39
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/deps.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.COMPONENT_DEPS_CSS = exports.API_DEPS_CSS = void 0;
|
||||
const constants_1 = require("./constants");
|
||||
const RESIZE_SENSOR_CSS = constants_1.BASE_COMPONENTS_STYLE_PATH + 'resize-sensor.css';
|
||||
exports.API_DEPS_CSS = {
|
||||
showModal: [`${constants_1.H5_API_STYLE_PATH}modal.css`],
|
||||
showToast: [`${constants_1.H5_API_STYLE_PATH}toast.css`],
|
||||
showActionSheet: [`${constants_1.H5_API_STYLE_PATH}action-sheet.css`],
|
||||
previewImage: [
|
||||
RESIZE_SENSOR_CSS,
|
||||
`${constants_1.BASE_COMPONENTS_STYLE_PATH}swiper.css`,
|
||||
`${constants_1.BASE_COMPONENTS_STYLE_PATH}swiper-item.css`,
|
||||
`${constants_1.BASE_COMPONENTS_STYLE_PATH}movable-area.css`,
|
||||
`${constants_1.BASE_COMPONENTS_STYLE_PATH}movable-view.css`,
|
||||
],
|
||||
openLocation: [`${constants_1.H5_API_STYLE_PATH}location-view.css`],
|
||||
chooseLocation: [
|
||||
`${constants_1.H5_API_STYLE_PATH}/location-picker.css`,
|
||||
`${constants_1.BASE_COMPONENTS_STYLE_PATH}/input.css`,
|
||||
`${constants_1.H5_COMPONENTS_STYLE_PATH}/map.css`,
|
||||
`${constants_1.BASE_COMPONENTS_STYLE_PATH}/scroll-view.css`,
|
||||
],
|
||||
};
|
||||
exports.COMPONENT_DEPS_CSS = {
|
||||
canvas: [RESIZE_SENSOR_CSS],
|
||||
image: [RESIZE_SENSOR_CSS],
|
||||
'movable-area': [RESIZE_SENSOR_CSS],
|
||||
'picker-view': [RESIZE_SENSOR_CSS],
|
||||
'picker-view-column': [RESIZE_SENSOR_CSS],
|
||||
'rich-text': [RESIZE_SENSOR_CSS],
|
||||
textarea: [RESIZE_SENSOR_CSS],
|
||||
'web-view': [RESIZE_SENSOR_CSS],
|
||||
picker: [
|
||||
RESIZE_SENSOR_CSS,
|
||||
`${constants_1.BASE_COMPONENTS_STYLE_PATH}picker-view.css`,
|
||||
`${constants_1.BASE_COMPONENTS_STYLE_PATH}picker-view-column.css`,
|
||||
],
|
||||
};
|
||||
31
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/easycom.d.ts
generated
vendored
Normal file
31
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/easycom.d.ts
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
interface EasycomOption {
|
||||
dirs?: string[];
|
||||
rootDir: string;
|
||||
extensions: string[];
|
||||
autoscan?: boolean;
|
||||
custom?: EasycomCustom;
|
||||
}
|
||||
export interface EasycomMatcher {
|
||||
name: string;
|
||||
pattern: RegExp;
|
||||
replacement: string;
|
||||
}
|
||||
interface EasycomCustom {
|
||||
[key: string]: string;
|
||||
}
|
||||
export declare function initEasycoms(inputDir: string, { dirs, platform, isX, }: {
|
||||
dirs: string[];
|
||||
platform: UniApp.PLATFORM;
|
||||
isX?: boolean;
|
||||
}): {
|
||||
options: EasycomOption;
|
||||
filter: (id: unknown) => boolean;
|
||||
refresh(): void;
|
||||
easycoms: EasycomMatcher[];
|
||||
};
|
||||
export declare const initEasycomsOnce: typeof initEasycoms;
|
||||
export declare function matchEasycom(tag: string): string | false | undefined;
|
||||
export declare function addImportDeclaration(importDeclarations: string[], local: string, source: string, imported?: string): string;
|
||||
export declare function genResolveEasycomCode(importDeclarations: string[], code: string, name: string): string;
|
||||
export declare const UNI_EASYCOM_EXCLUDE: RegExp[];
|
||||
export {};
|
||||
221
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/easycom.js
generated
vendored
Normal file
221
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/easycom.js
generated
vendored
Normal file
@@ -0,0 +1,221 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UNI_EASYCOM_EXCLUDE = exports.genResolveEasycomCode = exports.addImportDeclaration = exports.matchEasycom = exports.initEasycomsOnce = exports.initEasycoms = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const shared_1 = require("@vue/shared");
|
||||
const pluginutils_1 = require("@rollup/pluginutils");
|
||||
const uni_shared_1 = require("@dcloudio/uni-shared");
|
||||
const utils_1 = require("./utils");
|
||||
const pages_1 = require("./json/pages");
|
||||
const messages_1 = require("./messages");
|
||||
const uts_1 = require("./uts");
|
||||
const debugEasycom = (0, debug_1.default)('uni:easycom');
|
||||
const easycoms = [];
|
||||
const easycomsCache = new Map();
|
||||
const easycomsInvalidCache = new Set();
|
||||
let hasEasycom = false;
|
||||
function clearEasycom() {
|
||||
easycoms.length = 0;
|
||||
easycomsCache.clear();
|
||||
easycomsInvalidCache.clear();
|
||||
}
|
||||
function initEasycoms(inputDir, { dirs, platform, isX, }) {
|
||||
const componentsDir = path_1.default.resolve(inputDir, 'components');
|
||||
const uniModulesDir = path_1.default.resolve(inputDir, 'uni_modules');
|
||||
const initEasycomOptions = (pagesJson) => {
|
||||
// 初始化时,从once中读取缓存,refresh时,实时读取
|
||||
const { easycom } = pagesJson || (0, pages_1.parsePagesJson)(inputDir, platform, false);
|
||||
const easycomOptions = {
|
||||
dirs: easycom && easycom.autoscan === false
|
||||
? [...dirs] // 禁止自动扫描
|
||||
: [
|
||||
...dirs,
|
||||
componentsDir,
|
||||
...initUniModulesEasycomDirs(uniModulesDir),
|
||||
],
|
||||
rootDir: inputDir,
|
||||
autoscan: !!(easycom && easycom.autoscan),
|
||||
custom: (easycom && easycom.custom) || {},
|
||||
extensions: [...(isX ? ['.uvue'] : []), ...['.vue', '.jsx', '.tsx']],
|
||||
};
|
||||
debugEasycom(easycomOptions);
|
||||
return easycomOptions;
|
||||
};
|
||||
const options = initEasycomOptions((0, pages_1.parsePagesJsonOnce)(inputDir, platform));
|
||||
const initUTSEasycom = () => {
|
||||
(0, uts_1.initUTSComponents)(inputDir, platform).forEach((item) => {
|
||||
const index = easycoms.findIndex((easycom) => item.name === easycom.name);
|
||||
if (index > -1) {
|
||||
easycoms.splice(index, 1, item);
|
||||
}
|
||||
else {
|
||||
easycoms.push(item);
|
||||
}
|
||||
});
|
||||
};
|
||||
initEasycom(options);
|
||||
initUTSEasycom();
|
||||
const componentExtNames = isX ? 'uvue|vue' : 'vue';
|
||||
const res = {
|
||||
options,
|
||||
filter: (0, pluginutils_1.createFilter)([
|
||||
'components/*/*.(' + componentExtNames + '|jsx|tsx)',
|
||||
'uni_modules/*/components/*/*.(' + componentExtNames + '|jsx|tsx)',
|
||||
'utssdk/*/**/*.(' + componentExtNames + ')',
|
||||
'uni_modules/*/utssdk/*/*.(' + componentExtNames + ')',
|
||||
], [], {
|
||||
resolve: inputDir,
|
||||
}),
|
||||
refresh() {
|
||||
res.options = initEasycomOptions();
|
||||
initEasycom(res.options);
|
||||
initUTSEasycom();
|
||||
},
|
||||
easycoms,
|
||||
};
|
||||
return res;
|
||||
}
|
||||
exports.initEasycoms = initEasycoms;
|
||||
exports.initEasycomsOnce = (0, uni_shared_1.once)(initEasycoms);
|
||||
function initUniModulesEasycomDirs(uniModulesDir) {
|
||||
if (!fs_1.default.existsSync(uniModulesDir)) {
|
||||
return [];
|
||||
}
|
||||
return fs_1.default
|
||||
.readdirSync(uniModulesDir)
|
||||
.map((uniModuleDir) => {
|
||||
const uniModuleComponentsDir = path_1.default.resolve(uniModulesDir, uniModuleDir, 'components');
|
||||
if (fs_1.default.existsSync(uniModuleComponentsDir)) {
|
||||
return uniModuleComponentsDir;
|
||||
}
|
||||
})
|
||||
.filter(Boolean);
|
||||
}
|
||||
function initEasycom({ dirs, rootDir, custom, extensions }) {
|
||||
clearEasycom();
|
||||
const easycomsObj = Object.create(null);
|
||||
if (dirs && dirs.length && rootDir) {
|
||||
(0, shared_1.extend)(easycomsObj, initAutoScanEasycoms(dirs, rootDir, extensions));
|
||||
}
|
||||
if (custom) {
|
||||
Object.keys(custom).forEach((name) => {
|
||||
const componentPath = custom[name];
|
||||
easycomsObj[name] = componentPath.startsWith('@/')
|
||||
? (0, utils_1.normalizePath)(path_1.default.join(rootDir, componentPath.slice(2)))
|
||||
: componentPath;
|
||||
});
|
||||
}
|
||||
Object.keys(easycomsObj).forEach((name) => {
|
||||
easycoms.push({
|
||||
name: name.startsWith('^') && name.endsWith('$') ? name.slice(1, -1) : name,
|
||||
pattern: new RegExp(name),
|
||||
replacement: easycomsObj[name],
|
||||
});
|
||||
});
|
||||
debugEasycom(easycoms);
|
||||
hasEasycom = !!easycoms.length;
|
||||
return easycoms;
|
||||
}
|
||||
function matchEasycom(tag) {
|
||||
if (!hasEasycom) {
|
||||
return;
|
||||
}
|
||||
let source = easycomsCache.get(tag);
|
||||
if (source) {
|
||||
return source;
|
||||
}
|
||||
if (easycomsInvalidCache.has(tag)) {
|
||||
return false;
|
||||
}
|
||||
const matcher = easycoms.find((matcher) => matcher.pattern.test(tag));
|
||||
if (!matcher) {
|
||||
easycomsInvalidCache.add(tag);
|
||||
return false;
|
||||
}
|
||||
source = tag.replace(matcher.pattern, matcher.replacement);
|
||||
easycomsCache.set(tag, source);
|
||||
debugEasycom('matchEasycom', tag, source);
|
||||
return source;
|
||||
}
|
||||
exports.matchEasycom = matchEasycom;
|
||||
const isDir = (path) => fs_1.default.lstatSync(path).isDirectory();
|
||||
function initAutoScanEasycom(dir, rootDir, extensions) {
|
||||
if (!path_1.default.isAbsolute(dir)) {
|
||||
dir = path_1.default.resolve(rootDir, dir);
|
||||
}
|
||||
const easycoms = Object.create(null);
|
||||
if (!fs_1.default.existsSync(dir)) {
|
||||
return easycoms;
|
||||
}
|
||||
fs_1.default.readdirSync(dir).forEach((name) => {
|
||||
const folder = path_1.default.resolve(dir, name);
|
||||
if (!isDir(folder)) {
|
||||
return;
|
||||
}
|
||||
const importDir = (0, utils_1.normalizePath)(folder);
|
||||
const files = fs_1.default.readdirSync(folder);
|
||||
// 读取文件夹文件列表,比对文件名(fs.existsSync在大小写不敏感的系统会匹配不准确)
|
||||
for (let i = 0; i < extensions.length; i++) {
|
||||
const ext = extensions[i];
|
||||
if (files.includes(name + ext)) {
|
||||
easycoms[`^${name}$`] = `${importDir}/${name}${ext}`;
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return easycoms;
|
||||
}
|
||||
function initAutoScanEasycoms(dirs, rootDir, extensions) {
|
||||
const conflict = {};
|
||||
const res = dirs.reduce((easycoms, dir) => {
|
||||
const curEasycoms = initAutoScanEasycom(dir, rootDir, extensions);
|
||||
Object.keys(curEasycoms).forEach((name) => {
|
||||
// Use the first component when name conflict
|
||||
const componentPath = easycoms[name];
|
||||
if (!componentPath) {
|
||||
easycoms[name] = curEasycoms[name];
|
||||
}
|
||||
else {
|
||||
;
|
||||
(conflict[componentPath] || (conflict[componentPath] = [])).push(normalizeComponentPath(curEasycoms[name], rootDir));
|
||||
}
|
||||
});
|
||||
return easycoms;
|
||||
}, Object.create(null));
|
||||
const conflictComponents = Object.keys(conflict);
|
||||
if (conflictComponents.length) {
|
||||
console.warn(messages_1.M['easycom.conflict']);
|
||||
conflictComponents.forEach((com) => {
|
||||
console.warn([normalizeComponentPath(com, rootDir), conflict[com]].join(','));
|
||||
});
|
||||
}
|
||||
return res;
|
||||
}
|
||||
function normalizeComponentPath(componentPath, rootDir) {
|
||||
return (0, utils_1.normalizePath)(path_1.default.relative(rootDir, componentPath));
|
||||
}
|
||||
function addImportDeclaration(importDeclarations, local, source, imported) {
|
||||
importDeclarations.push(createImportDeclaration(local, source, imported));
|
||||
return local;
|
||||
}
|
||||
exports.addImportDeclaration = addImportDeclaration;
|
||||
function createImportDeclaration(local, source, imported) {
|
||||
if (imported) {
|
||||
return `import { ${imported} as ${local} } from '${source}';`;
|
||||
}
|
||||
return `import ${local} from '${source}';`;
|
||||
}
|
||||
const RESOLVE_EASYCOM_IMPORT_CODE = `import { resolveDynamicComponent as __resolveDynamicComponent } from 'vue';import { resolveEasycom } from '@dcloudio/uni-app';`;
|
||||
function genResolveEasycomCode(importDeclarations, code, name) {
|
||||
if (!importDeclarations.includes(RESOLVE_EASYCOM_IMPORT_CODE)) {
|
||||
importDeclarations.push(RESOLVE_EASYCOM_IMPORT_CODE);
|
||||
}
|
||||
return `resolveEasycom(${code.replace('_resolveComponent', '__resolveDynamicComponent')}, ${name})`;
|
||||
}
|
||||
exports.genResolveEasycomCode = genResolveEasycomCode;
|
||||
exports.UNI_EASYCOM_EXCLUDE = [/App.vue$/, /@dcloudio\/uni-h5/];
|
||||
19
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/env/define.d.ts
generated
vendored
Normal file
19
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/env/define.d.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
export declare function initDefine(stringifyBoolean?: boolean): {
|
||||
'process.env.NODE_ENV': string;
|
||||
'process.env.UNI_DEBUG': string | boolean;
|
||||
'process.env.UNI_APP_ID': string;
|
||||
'process.env.UNI_APP_NAME': string;
|
||||
'process.env.UNI_APP_VERSION_NAME': string;
|
||||
'process.env.UNI_APP_VERSION_CODE': string;
|
||||
'process.env.UNI_PLATFORM': string;
|
||||
'process.env.UNI_SUB_PLATFORM': string;
|
||||
'process.env.UNI_MP_PLUGIN': string;
|
||||
'process.env.UNI_SUBPACKAGE': string;
|
||||
'process.env.UNI_COMPILER_VERSION': string;
|
||||
'process.env.RUN_BY_HBUILDERX': string | boolean;
|
||||
'process.env.UNI_AUTOMATOR_WS_ENDPOINT': string;
|
||||
'process.env.UNI_CLOUD_PROVIDER': string;
|
||||
'process.env.UNICLOUD_DEBUG': string;
|
||||
'process.env.VUE_APP_PLATFORM': string;
|
||||
'process.env.VUE_APP_DARK_MODE': string;
|
||||
};
|
||||
50
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/env/define.js
generated
vendored
Normal file
50
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/env/define.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initDefine = void 0;
|
||||
const env_1 = require("../hbx/env");
|
||||
const json_1 = require("../json");
|
||||
function initDefine(stringifyBoolean = false) {
|
||||
const manifestJson = (0, json_1.parseManifestJsonOnce)(process.env.UNI_INPUT_DIR);
|
||||
const platformManifestJson = (0, json_1.getPlatformManifestJsonOnce)();
|
||||
const isRunByHBuilderX = (0, env_1.runByHBuilderX)();
|
||||
const isDebug = !!manifestJson.debug;
|
||||
return {
|
||||
...initCustomDefine(),
|
||||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
||||
'process.env.UNI_DEBUG': stringifyBoolean
|
||||
? JSON.stringify(isDebug)
|
||||
: isDebug,
|
||||
'process.env.UNI_APP_ID': JSON.stringify(manifestJson.appid || ''),
|
||||
'process.env.UNI_APP_NAME': JSON.stringify(manifestJson.name || ''),
|
||||
'process.env.UNI_APP_VERSION_NAME': JSON.stringify(manifestJson.versionName || ''),
|
||||
'process.env.UNI_APP_VERSION_CODE': JSON.stringify(manifestJson.versionCode || ''),
|
||||
'process.env.UNI_PLATFORM': JSON.stringify(process.env.UNI_PLATFORM),
|
||||
'process.env.UNI_SUB_PLATFORM': JSON.stringify(process.env.UNI_SUB_PLATFORM || ''),
|
||||
'process.env.UNI_MP_PLUGIN': JSON.stringify(process.env.UNI_MP_PLUGIN || ''),
|
||||
'process.env.UNI_SUBPACKAGE': JSON.stringify(process.env.UNI_SUBPACKAGE || ''),
|
||||
'process.env.UNI_COMPILER_VERSION': JSON.stringify(process.env.UNI_COMPILER_VERSION || ''),
|
||||
'process.env.RUN_BY_HBUILDERX': stringifyBoolean
|
||||
? JSON.stringify(isRunByHBuilderX)
|
||||
: isRunByHBuilderX,
|
||||
'process.env.UNI_AUTOMATOR_WS_ENDPOINT': JSON.stringify(process.env.UNI_AUTOMATOR_WS_ENDPOINT || ''),
|
||||
'process.env.UNI_CLOUD_PROVIDER': JSON.stringify(process.env.UNI_CLOUD_PROVIDER || ''),
|
||||
'process.env.UNICLOUD_DEBUG': JSON.stringify(process.env.UNICLOUD_DEBUG || ''),
|
||||
// 兼容旧版本
|
||||
'process.env.VUE_APP_PLATFORM': JSON.stringify(process.env.UNI_PLATFORM || ''),
|
||||
'process.env.VUE_APP_DARK_MODE': JSON.stringify(platformManifestJson.darkmode || false),
|
||||
};
|
||||
}
|
||||
exports.initDefine = initDefine;
|
||||
function initCustomDefine() {
|
||||
let define = {};
|
||||
if (process.env.UNI_CUSTOM_DEFINE) {
|
||||
try {
|
||||
define = JSON.parse(process.env.UNI_CUSTOM_DEFINE);
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
return Object.keys(define).reduce((res, name) => {
|
||||
res['process.env.' + name] = JSON.stringify(define[name]);
|
||||
return res;
|
||||
}, {});
|
||||
}
|
||||
2
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/env/index.d.ts
generated
vendored
Normal file
2
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/env/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export { initDefine } from './define';
|
||||
export { initAppProvide, initH5Provide } from './provide';
|
||||
8
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/env/index.js
generated
vendored
Normal file
8
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/env/index.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initH5Provide = exports.initAppProvide = exports.initDefine = void 0;
|
||||
var define_1 = require("./define");
|
||||
Object.defineProperty(exports, "initDefine", { enumerable: true, get: function () { return define_1.initDefine; } });
|
||||
var provide_1 = require("./provide");
|
||||
Object.defineProperty(exports, "initAppProvide", { enumerable: true, get: function () { return provide_1.initAppProvide; } });
|
||||
Object.defineProperty(exports, "initH5Provide", { enumerable: true, get: function () { return provide_1.initH5Provide; } });
|
||||
11
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/env/provide.d.ts
generated
vendored
Normal file
11
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/env/provide.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
export declare function initAppProvide(): {
|
||||
__f__: string[];
|
||||
crypto: string[];
|
||||
'window.crypto': string[];
|
||||
'global.crypto': string[];
|
||||
'uni.getCurrentSubNVue': string[];
|
||||
'uni.requireNativePlugin': string[];
|
||||
};
|
||||
export declare function initH5Provide(): {
|
||||
__f__: string[];
|
||||
};
|
||||
26
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/env/provide.js
generated
vendored
Normal file
26
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/env/provide.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initH5Provide = exports.initAppProvide = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const libDir = path_1.default.resolve(__dirname, '../../lib');
|
||||
function initAppProvide() {
|
||||
const cryptoDefine = [path_1.default.join(libDir, 'crypto.js'), 'default'];
|
||||
return {
|
||||
__f__: ['@dcloudio/uni-app', 'formatAppLog'],
|
||||
crypto: cryptoDefine,
|
||||
'window.crypto': cryptoDefine,
|
||||
'global.crypto': cryptoDefine,
|
||||
'uni.getCurrentSubNVue': ['@dcloudio/uni-app', 'getCurrentSubNVue'],
|
||||
'uni.requireNativePlugin': ['@dcloudio/uni-app', 'requireNativePlugin'],
|
||||
};
|
||||
}
|
||||
exports.initAppProvide = initAppProvide;
|
||||
function initH5Provide() {
|
||||
return {
|
||||
__f__: ['@dcloudio/uni-app', 'formatH5Log'],
|
||||
};
|
||||
}
|
||||
exports.initH5Provide = initH5Provide;
|
||||
3
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/esbuild.d.ts
generated
vendored
Normal file
3
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/esbuild.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { BuildOptions } from 'esbuild';
|
||||
export declare function transformWithEsbuild(code: string, filename: string, options: BuildOptions): Promise<import("esbuild").BuildResult<BuildOptions>>;
|
||||
export declare function esbuild(options: BuildOptions): Promise<import("esbuild").BuildResult<BuildOptions>>;
|
||||
46
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/esbuild.js
generated
vendored
Normal file
46
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/esbuild.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.esbuild = exports.transformWithEsbuild = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
function transformWithEsbuild(code, filename, options) {
|
||||
options.stdin = {
|
||||
contents: code,
|
||||
resolveDir: path_1.default.dirname(filename),
|
||||
};
|
||||
return Promise.resolve().then(() => __importStar(require('esbuild'))).then((esbuild) => {
|
||||
return esbuild.build(options);
|
||||
});
|
||||
}
|
||||
exports.transformWithEsbuild = transformWithEsbuild;
|
||||
function esbuild(options) {
|
||||
return Promise.resolve().then(() => __importStar(require('esbuild'))).then((esbuild) => {
|
||||
return esbuild.build(options);
|
||||
});
|
||||
}
|
||||
exports.esbuild = esbuild;
|
||||
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/exports.d.ts
generated
vendored
Normal file
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/exports.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export { default as chokidar } from 'chokidar';
|
||||
8
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/exports.js
generated
vendored
Normal file
8
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/exports.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.chokidar = void 0;
|
||||
var chokidar_1 = require("chokidar");
|
||||
Object.defineProperty(exports, "chokidar", { enumerable: true, get: function () { return __importDefault(chokidar_1).default; } });
|
||||
16
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/filter.d.ts
generated
vendored
Normal file
16
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/filter.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
export declare function isWxs(id: string): boolean;
|
||||
export declare function isSjs(id: string): boolean;
|
||||
export declare function isRenderjs(id: string): boolean;
|
||||
type FilterType = 'wxs' | 'renderjs' | 'sjs';
|
||||
export declare function parseRenderjs(id: string): {
|
||||
type: FilterType;
|
||||
name: string;
|
||||
filename: string;
|
||||
} | {
|
||||
readonly type: "";
|
||||
readonly name: "";
|
||||
readonly filename: "";
|
||||
};
|
||||
export declare function missingModuleName(type: FilterType, code: string): string;
|
||||
export declare function parseFilterNames(lang: string, code: string): string[];
|
||||
export {};
|
||||
60
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/filter.js
generated
vendored
Normal file
60
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/filter.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseFilterNames = exports.missingModuleName = exports.parseRenderjs = exports.isRenderjs = exports.isSjs = exports.isWxs = void 0;
|
||||
const url_1 = require("./vite/utils/url");
|
||||
const WXS_RE = /vue&type=wxs/;
|
||||
function isWxs(id) {
|
||||
return WXS_RE.test(id);
|
||||
}
|
||||
exports.isWxs = isWxs;
|
||||
const SJS_RE = /vue&type=sjs/;
|
||||
function isSjs(id) {
|
||||
return SJS_RE.test(id);
|
||||
}
|
||||
exports.isSjs = isSjs;
|
||||
const RENDERJS_RE = /vue&type=renderjs/;
|
||||
function isRenderjs(id) {
|
||||
return RENDERJS_RE.test(id);
|
||||
}
|
||||
exports.isRenderjs = isRenderjs;
|
||||
function parseRenderjs(id) {
|
||||
if (isWxs(id) || isRenderjs(id) || isSjs(id)) {
|
||||
const { query, filename } = (0, url_1.parseVueRequest)(id);
|
||||
return {
|
||||
type: query.type,
|
||||
name: query.name,
|
||||
filename,
|
||||
};
|
||||
}
|
||||
return {
|
||||
type: '',
|
||||
name: '',
|
||||
filename: '',
|
||||
};
|
||||
}
|
||||
exports.parseRenderjs = parseRenderjs;
|
||||
function missingModuleName(type, code) {
|
||||
return `<script module="missing module name" lang="${type}">
|
||||
${code}
|
||||
</script>`;
|
||||
}
|
||||
exports.missingModuleName = missingModuleName;
|
||||
const moduleRE = /module=["'](.*?)["']/;
|
||||
function parseFilterNames(lang, code) {
|
||||
const names = [];
|
||||
const scriptTags = code.match(/<script\b[^>]*>/gm);
|
||||
if (!scriptTags) {
|
||||
return names;
|
||||
}
|
||||
const langRE = new RegExp(`lang=["']${lang}["']`);
|
||||
scriptTags.forEach((scriptTag) => {
|
||||
if (langRE.test(scriptTag)) {
|
||||
const matches = scriptTag.match(moduleRE);
|
||||
if (matches) {
|
||||
names.push(matches[1]);
|
||||
}
|
||||
}
|
||||
});
|
||||
return names;
|
||||
}
|
||||
exports.parseFilterNames = parseFilterNames;
|
||||
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/fs.d.ts
generated
vendored
Normal file
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/fs.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function emptyDir(dir: string, skip?: string[]): void;
|
||||
18
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/fs.js
generated
vendored
Normal file
18
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/fs.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.emptyDir = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
function emptyDir(dir, skip = []) {
|
||||
for (const file of fs_1.default.readdirSync(dir)) {
|
||||
if (skip.includes(file)) {
|
||||
continue;
|
||||
}
|
||||
// node >= 14.14.0
|
||||
fs_1.default.rmSync(path_1.default.resolve(dir, file), { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
exports.emptyDir = emptyDir;
|
||||
5
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/hbx/alias.d.ts
generated
vendored
Normal file
5
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/hbx/alias.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import type { Formatter } from '../logs/format';
|
||||
export declare function initModuleAlias(): void;
|
||||
export declare function installHBuilderXPlugin(plugin: string): void;
|
||||
export declare const moduleAliasFormatter: Formatter;
|
||||
export declare function formatInstallHBuilderXPluginTips(lang: string, preprocessor: string): string;
|
||||
98
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/hbx/alias.js
generated
vendored
Normal file
98
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/hbx/alias.js
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.formatInstallHBuilderXPluginTips = exports.moduleAliasFormatter = exports.installHBuilderXPlugin = exports.initModuleAlias = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const module_alias_1 = __importDefault(require("module-alias"));
|
||||
const resolve_1 = __importDefault(require("resolve"));
|
||||
const env_1 = require("./env");
|
||||
const hbxPlugins = {
|
||||
// typescript: 'compile-typescript/node_modules/typescript',
|
||||
less: 'compile-less/node_modules/less',
|
||||
sass: 'compile-dart-sass/node_modules/sass',
|
||||
stylus: 'compile-stylus/node_modules/stylus',
|
||||
pug: 'compile-pug-cli/node_modules/pug',
|
||||
};
|
||||
function initModuleAlias() {
|
||||
const compilerSfcPath = require.resolve('@vue/compiler-sfc');
|
||||
const serverRendererPath = require.resolve('@vue/server-renderer');
|
||||
module_alias_1.default.addAliases({
|
||||
'@vue/shared': require.resolve('@vue/shared'),
|
||||
'@vue/shared/dist/shared.esm-bundler.js': require.resolve('@vue/shared/dist/shared.esm-bundler.js'),
|
||||
'@vue/compiler-dom': require.resolve('@vue/compiler-dom'),
|
||||
'@vue/compiler-sfc': compilerSfcPath,
|
||||
'@vue/server-renderer': serverRendererPath,
|
||||
'vue/compiler-sfc': compilerSfcPath,
|
||||
'vue/server-renderer': serverRendererPath,
|
||||
});
|
||||
if (process.env.VITEST) {
|
||||
module_alias_1.default.addAliases({
|
||||
vue: '@dcloudio/uni-h5-vue',
|
||||
'vue/package.json': '@dcloudio/uni-h5-vue/package.json',
|
||||
});
|
||||
}
|
||||
if ((0, env_1.isInHBuilderX)()) {
|
||||
// 又是为了复用 HBuilderX 的插件逻辑,硬编码映射
|
||||
Object.keys(hbxPlugins).forEach((name) => {
|
||||
module_alias_1.default.addAlias(name, path_1.default.resolve(process.env.UNI_HBUILDERX_PLUGINS, hbxPlugins[name]));
|
||||
});
|
||||
// https://github.com/vitejs/vite/blob/892916d040a035edde1add93c192e0b0c5c9dd86/packages/vite/src/node/plugins/css.ts#L1481
|
||||
const oldSync = resolve_1.default.sync;
|
||||
resolve_1.default.sync = (id, opts) => {
|
||||
if (hbxPlugins[id]) {
|
||||
return path_1.default.resolve(process.env.UNI_HBUILDERX_PLUGINS, hbxPlugins[id]);
|
||||
}
|
||||
return oldSync(id, opts);
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.initModuleAlias = initModuleAlias;
|
||||
function supportAutoInstallPlugin() {
|
||||
return !!process.env.HX_Version;
|
||||
}
|
||||
function installHBuilderXPlugin(plugin) {
|
||||
if (!supportAutoInstallPlugin()) {
|
||||
return;
|
||||
}
|
||||
return console.error(`%HXRunUniAPPPluginName%${plugin}%HXRunUniAPPPluginName%`);
|
||||
}
|
||||
exports.installHBuilderXPlugin = installHBuilderXPlugin;
|
||||
const installPreprocessorTips = {};
|
||||
exports.moduleAliasFormatter = {
|
||||
test(msg) {
|
||||
return msg.includes('Preprocessor dependency');
|
||||
},
|
||||
format(msg) {
|
||||
let lang = '';
|
||||
let preprocessor = '';
|
||||
if (msg.includes(`"sass"`)) {
|
||||
lang = 'sass';
|
||||
preprocessor = 'compile-dart-sass';
|
||||
}
|
||||
else if (msg.includes(`"less"`)) {
|
||||
lang = 'less';
|
||||
preprocessor = 'compile-less';
|
||||
}
|
||||
else if (msg.includes('"stylus"')) {
|
||||
lang = 'stylus';
|
||||
preprocessor = 'compile-stylus';
|
||||
}
|
||||
if (lang) {
|
||||
// 仅提醒一次
|
||||
if (installPreprocessorTips[lang]) {
|
||||
return '';
|
||||
}
|
||||
installPreprocessorTips[lang] = true;
|
||||
installHBuilderXPlugin(preprocessor);
|
||||
return formatInstallHBuilderXPluginTips(lang, preprocessor);
|
||||
}
|
||||
return msg;
|
||||
},
|
||||
};
|
||||
function formatInstallHBuilderXPluginTips(lang, preprocessor) {
|
||||
return `预编译器错误:代码使用了${lang}语言,但未安装相应的编译器插件,${supportAutoInstallPlugin() ? '正在从' : '请前往'}插件市场安装该插件:
|
||||
https://ext.dcloud.net.cn/plugin?name=${preprocessor}`;
|
||||
}
|
||||
exports.formatInstallHBuilderXPluginTips = formatInstallHBuilderXPluginTips;
|
||||
7
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/hbx/env.d.ts
generated
vendored
Normal file
7
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/hbx/env.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export declare const isInHBuilderX: () => boolean;
|
||||
export declare const runByHBuilderX: () => boolean;
|
||||
/**
|
||||
* 增加 node_modules
|
||||
*/
|
||||
export declare function initModulePaths(): void;
|
||||
export declare function fixBinaryPath(): void;
|
||||
79
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/hbx/env.js
generated
vendored
Normal file
79
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/hbx/env.js
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.fixBinaryPath = exports.initModulePaths = exports.runByHBuilderX = exports.isInHBuilderX = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const module_1 = __importDefault(require("module"));
|
||||
const uni_shared_1 = require("@dcloudio/uni-shared");
|
||||
const resolve_1 = require("../resolve");
|
||||
const utils_1 = require("../utils");
|
||||
exports.isInHBuilderX = (0, uni_shared_1.once)(() => {
|
||||
// 自动化测试传入了 HX_APP_ROOT(其实就是UNI_HBUILDERX_PLUGINS)
|
||||
if (process.env.HX_APP_ROOT) {
|
||||
process.env.UNI_HBUILDERX_PLUGINS = process.env.HX_APP_ROOT + '/plugins';
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
const { name } = require(path_1.default.resolve(process.cwd(), '../about/package.json'));
|
||||
if (name === 'about') {
|
||||
process.env.UNI_HBUILDERX_PLUGINS = path_1.default.resolve(process.cwd(), '..');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
// console.error(e)
|
||||
}
|
||||
return false;
|
||||
});
|
||||
exports.runByHBuilderX = (0, uni_shared_1.once)(() => {
|
||||
return (!!process.env.UNI_HBUILDERX_PLUGINS &&
|
||||
(!!process.env.RUN_BY_HBUILDERX || !!process.env.HX_Version));
|
||||
});
|
||||
/**
|
||||
* 增加 node_modules
|
||||
*/
|
||||
function initModulePaths() {
|
||||
if (!(0, exports.isInHBuilderX)()) {
|
||||
return;
|
||||
}
|
||||
const Module = module.constructor.length > 1 ? module.constructor : module_1.default;
|
||||
const nodeModulesPath = path_1.default.resolve(process.env.UNI_CLI_CONTEXT, 'node_modules');
|
||||
const oldNodeModulePaths = Module._nodeModulePaths;
|
||||
Module._nodeModulePaths = function (from) {
|
||||
const paths = oldNodeModulePaths.call(this, from);
|
||||
if (!paths.includes(nodeModulesPath)) {
|
||||
paths.push(nodeModulesPath);
|
||||
}
|
||||
return paths;
|
||||
};
|
||||
}
|
||||
exports.initModulePaths = initModulePaths;
|
||||
function resolveEsbuildModule(name) {
|
||||
try {
|
||||
return path_1.default.dirname(require.resolve(name + '/package.json', {
|
||||
paths: [path_1.default.dirname((0, resolve_1.resolveBuiltIn)('esbuild/package.json'))],
|
||||
}));
|
||||
}
|
||||
catch (e) { }
|
||||
return '';
|
||||
}
|
||||
function fixBinaryPath() {
|
||||
// cli 工程在 HBuilderX 中运行
|
||||
if (!(0, exports.isInHBuilderX)() && (0, exports.runByHBuilderX)()) {
|
||||
if (utils_1.isWindows) {
|
||||
const win64 = resolveEsbuildModule('esbuild-windows-64');
|
||||
if (win64) {
|
||||
process.env.ESBUILD_BINARY_PATH = path_1.default.join(win64, 'esbuild.exe');
|
||||
}
|
||||
}
|
||||
else {
|
||||
const arm64 = resolveEsbuildModule('esbuild-darwin-arm64');
|
||||
if (arm64) {
|
||||
process.env.ESBUILD_BINARY_PATH = path_1.default.join(arm64, 'bin/esbuild');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.fixBinaryPath = fixBinaryPath;
|
||||
4
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/hbx/index.d.ts
generated
vendored
Normal file
4
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/hbx/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export { formatAtFilename } from './log';
|
||||
export * from './env';
|
||||
export { initModuleAlias, installHBuilderXPlugin, formatInstallHBuilderXPluginTips, } from './alias';
|
||||
export declare function uniHBuilderXConsolePlugin(method?: string): import("vite").Plugin;
|
||||
43
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/hbx/index.js
generated
vendored
Normal file
43
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/hbx/index.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.uniHBuilderXConsolePlugin = exports.formatInstallHBuilderXPluginTips = exports.installHBuilderXPlugin = exports.initModuleAlias = exports.formatAtFilename = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const utils_1 = require("../utils");
|
||||
const console_1 = require("../vite/plugins/console");
|
||||
var log_1 = require("./log");
|
||||
Object.defineProperty(exports, "formatAtFilename", { enumerable: true, get: function () { return log_1.formatAtFilename; } });
|
||||
__exportStar(require("./env"), exports);
|
||||
var alias_1 = require("./alias");
|
||||
Object.defineProperty(exports, "initModuleAlias", { enumerable: true, get: function () { return alias_1.initModuleAlias; } });
|
||||
Object.defineProperty(exports, "installHBuilderXPlugin", { enumerable: true, get: function () { return alias_1.installHBuilderXPlugin; } });
|
||||
Object.defineProperty(exports, "formatInstallHBuilderXPluginTips", { enumerable: true, get: function () { return alias_1.formatInstallHBuilderXPluginTips; } });
|
||||
function uniHBuilderXConsolePlugin(method = '__f__') {
|
||||
return (0, console_1.uniConsolePlugin)({
|
||||
method,
|
||||
filename(filename) {
|
||||
filename = path_1.default.relative(process.env.UNI_INPUT_DIR, filename);
|
||||
if (filename.startsWith('.') || path_1.default.isAbsolute(filename)) {
|
||||
return '';
|
||||
}
|
||||
return (0, utils_1.normalizePath)(filename);
|
||||
},
|
||||
});
|
||||
}
|
||||
exports.uniHBuilderXConsolePlugin = uniHBuilderXConsolePlugin;
|
||||
7
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/hbx/log.d.ts
generated
vendored
Normal file
7
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/hbx/log.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { LogErrorOptions } from 'vite';
|
||||
import { Formatter } from '../logs/format';
|
||||
export declare function formatAtFilename(filename: string, line?: number, column?: number): string;
|
||||
export declare const h5ServeFormatter: Formatter;
|
||||
export declare const removeInfoFormatter: Formatter;
|
||||
export declare const removeWarnFormatter: Formatter;
|
||||
export declare const errorFormatter: Formatter<LogErrorOptions>;
|
||||
154
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/hbx/log.js
generated
vendored
Normal file
154
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/hbx/log.js
generated
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.errorFormatter = exports.removeWarnFormatter = exports.removeInfoFormatter = exports.h5ServeFormatter = exports.formatAtFilename = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const picocolors_1 = __importDefault(require("picocolors"));
|
||||
const shared_1 = require("@vue/shared");
|
||||
const utils_1 = require("../utils");
|
||||
const constants_1 = require("../constants");
|
||||
const ast_1 = require("../vite/utils/ast");
|
||||
const utils_2 = require("../vite/plugins/vitejs/utils");
|
||||
const SIGNAL_H5_LOCAL = ' ➜ Local:';
|
||||
const SIGNAL_H5_NETWORK = ' ➜ Network:';
|
||||
const networkLogs = [];
|
||||
const ZERO_WIDTH_CHAR = {
|
||||
NOTE: '',
|
||||
WARNING: '\u200B',
|
||||
ERROR: '\u200C',
|
||||
backup0: '\u200D',
|
||||
backup1: '\u200E',
|
||||
backup2: '\u200F',
|
||||
backup3: '\uFEFF',
|
||||
};
|
||||
function overridedConsole(name, oldFn, char) {
|
||||
console[name] = function (...args) {
|
||||
oldFn.apply(this, args.map((arg) => {
|
||||
let item;
|
||||
if (typeof arg !== 'object') {
|
||||
item = `${char}${arg}${char}`;
|
||||
}
|
||||
else {
|
||||
item = `${char}${JSON.stringify(arg)}${char}`;
|
||||
}
|
||||
return item;
|
||||
}));
|
||||
};
|
||||
}
|
||||
if (typeof console !== 'undefined') {
|
||||
overridedConsole('warn', console.log, ZERO_WIDTH_CHAR.WARNING);
|
||||
// overridedConsole('error', console.error, ZERO_WIDTH_CHAR.ERROR)
|
||||
}
|
||||
function formatAtFilename(filename, line, column) {
|
||||
return `at ${picocolors_1.default.cyan((0, utils_1.normalizePath)(path_1.default.relative(process.env.UNI_INPUT_DIR, filename.replace('\x00', '').split('?')[0])) +
|
||||
':' +
|
||||
(line || 1) +
|
||||
':' +
|
||||
(column || 0))}`;
|
||||
}
|
||||
exports.formatAtFilename = formatAtFilename;
|
||||
exports.h5ServeFormatter = {
|
||||
test(msg) {
|
||||
return msg.includes(SIGNAL_H5_LOCAL) || msg.includes(SIGNAL_H5_NETWORK);
|
||||
},
|
||||
format(msg) {
|
||||
if (msg.includes(SIGNAL_H5_NETWORK)) {
|
||||
networkLogs.push(msg.replace('➜ ', '*'));
|
||||
process.nextTick(() => {
|
||||
if (networkLogs.length) {
|
||||
// 延迟打印所有 network,仅最后一个 network 替换 ➜ 为 -,通知 hbx
|
||||
const len = networkLogs.length - 1;
|
||||
networkLogs[len] = networkLogs[len].replace('* Network', '- Network');
|
||||
console.log(networkLogs.join('\n'));
|
||||
networkLogs.length = 0;
|
||||
}
|
||||
});
|
||||
return '';
|
||||
}
|
||||
if (msg.includes(SIGNAL_H5_LOCAL)) {
|
||||
return msg.replace('➜ ', '-');
|
||||
}
|
||||
return msg.replace('➜ ', '*');
|
||||
},
|
||||
};
|
||||
const REMOVED_MSGS = [
|
||||
'build started...',
|
||||
(msg) => {
|
||||
return /built in [0-9]+ms\./.test(msg);
|
||||
},
|
||||
'watching for file changes...',
|
||||
];
|
||||
exports.removeInfoFormatter = {
|
||||
test(msg) {
|
||||
return !!REMOVED_MSGS.find((m) => ((0, shared_1.isString)(m) ? msg.includes(m) : m(msg)));
|
||||
},
|
||||
format() {
|
||||
return '';
|
||||
},
|
||||
};
|
||||
const REMOVED_WARN_MSGS = [];
|
||||
exports.removeWarnFormatter = {
|
||||
test(msg) {
|
||||
return !!REMOVED_WARN_MSGS.find((m) => msg.includes(m));
|
||||
},
|
||||
format() {
|
||||
return '';
|
||||
},
|
||||
};
|
||||
exports.errorFormatter = {
|
||||
test(_, opts) {
|
||||
return !!(opts && opts.error);
|
||||
},
|
||||
format(_, opts) {
|
||||
return buildErrorMessage(opts.error, [], false);
|
||||
},
|
||||
};
|
||||
function buildErrorMessage(err, args = [], includeStack = true) {
|
||||
if (err.plugin) {
|
||||
args.push(`${picocolors_1.default.magenta('[plugin:' + err.plugin + ']')} ${picocolors_1.default.red(err.message)}`);
|
||||
if (err.loc &&
|
||||
err.hook === 'transform' &&
|
||||
err.plugin === 'rollup-plugin-dynamic-import-variables' &&
|
||||
err.id &&
|
||||
constants_1.EXTNAME_VUE_RE.test(err.id)) {
|
||||
try {
|
||||
const ast = (0, ast_1.parseVue)(fs_1.default.readFileSync(err.id, 'utf8'), []);
|
||||
const scriptNode = ast.children.find((node) => node.type === 1 /* NodeTypes.ELEMENT */ && node.tag === 'script');
|
||||
if (scriptNode) {
|
||||
const scriptLoc = scriptNode.loc;
|
||||
args.push(picocolors_1.default.yellow(pad((0, utils_2.generateCodeFrame)(scriptLoc.source, err.loc))));
|
||||
// correct error location
|
||||
err.loc.line = scriptLoc.start.line + err.loc.line - 1;
|
||||
}
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
}
|
||||
else {
|
||||
args.push(picocolors_1.default.red(err.message));
|
||||
}
|
||||
if (err.id) {
|
||||
args.push(formatAtFilename(err.id, err.loc?.line, err.loc?.column));
|
||||
}
|
||||
if (err.frame) {
|
||||
args.push(picocolors_1.default.yellow(pad(err.frame)));
|
||||
}
|
||||
if (includeStack && err.stack) {
|
||||
args.push(pad(cleanStack(err.stack)));
|
||||
}
|
||||
return args.join('\n');
|
||||
}
|
||||
function cleanStack(stack) {
|
||||
return stack
|
||||
.split(/\n/g)
|
||||
.filter((l) => /^\s*at/.test(l))
|
||||
.join('\n');
|
||||
}
|
||||
const splitRE = /\r?\n/;
|
||||
function pad(source, n = 2) {
|
||||
const lines = source.split(splitRE);
|
||||
return lines.map((l) => ` `.repeat(n) + l).join(`\n`);
|
||||
}
|
||||
10
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/i18n.d.ts
generated
vendored
Normal file
10
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/i18n.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
export declare function initI18nOptions(platform: UniApp.PLATFORM, inputDir: string, warning?: boolean, withMessages?: boolean): {
|
||||
locale: string;
|
||||
locales: Record<string, Record<string, string>>;
|
||||
delimiters: [string, string];
|
||||
} | undefined;
|
||||
export declare const initI18nOptionsOnce: typeof initI18nOptions;
|
||||
export declare function isUniAppLocaleFile(filepath: string): boolean;
|
||||
export declare function getLocaleFiles(cwd: string): string[];
|
||||
export declare function initLocales(dir: string, withMessages?: boolean): Record<string, Record<string, string>>;
|
||||
export declare function resolveI18nLocale(platform: UniApp.PLATFORM, locales: string[], locale?: string): string;
|
||||
94
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/i18n.js
generated
vendored
Normal file
94
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/i18n.js
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.resolveI18nLocale = exports.initLocales = exports.getLocaleFiles = exports.isUniAppLocaleFile = exports.initI18nOptionsOnce = exports.initI18nOptions = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const fast_glob_1 = require("fast-glob");
|
||||
const shared_1 = require("@vue/shared");
|
||||
const uni_shared_1 = require("@dcloudio/uni-shared");
|
||||
const json_1 = require("./json");
|
||||
const messages_1 = require("./messages");
|
||||
function initI18nOptions(platform, inputDir, warning = false, withMessages = true) {
|
||||
const locales = initLocales(path_1.default.resolve(inputDir, 'locale'), withMessages);
|
||||
if (!Object.keys(locales).length) {
|
||||
return;
|
||||
}
|
||||
const manifestJson = (0, json_1.parseManifestJsonOnce)(inputDir);
|
||||
let fallbackLocale = manifestJson.fallbackLocale || 'en';
|
||||
const locale = resolveI18nLocale(platform, Object.keys(locales), fallbackLocale);
|
||||
if (warning) {
|
||||
if (!fallbackLocale) {
|
||||
console.warn(messages_1.M['i18n.fallbackLocale.default'].replace('{locale}', locale));
|
||||
}
|
||||
else if (locale !== fallbackLocale) {
|
||||
console.warn(messages_1.M['i18n.fallbackLocale.missing'].replace('{locale}', fallbackLocale));
|
||||
}
|
||||
}
|
||||
return {
|
||||
locale,
|
||||
locales,
|
||||
delimiters: uni_shared_1.I18N_JSON_DELIMITERS,
|
||||
};
|
||||
}
|
||||
exports.initI18nOptions = initI18nOptions;
|
||||
exports.initI18nOptionsOnce = (0, uni_shared_1.once)(initI18nOptions);
|
||||
const localeJsonRE = /uni-app.*.json/;
|
||||
function isUniAppLocaleFile(filepath) {
|
||||
if (!filepath) {
|
||||
return false;
|
||||
}
|
||||
return localeJsonRE.test(path_1.default.basename(filepath));
|
||||
}
|
||||
exports.isUniAppLocaleFile = isUniAppLocaleFile;
|
||||
function parseLocaleJson(filepath) {
|
||||
let jsonObj = (0, json_1.parseJson)(fs_1.default.readFileSync(filepath, 'utf8'));
|
||||
if (isUniAppLocaleFile(filepath)) {
|
||||
jsonObj = jsonObj.common || {};
|
||||
}
|
||||
return jsonObj;
|
||||
}
|
||||
function getLocaleFiles(cwd) {
|
||||
return (0, fast_glob_1.sync)('*.json', { cwd, absolute: true });
|
||||
}
|
||||
exports.getLocaleFiles = getLocaleFiles;
|
||||
function initLocales(dir, withMessages = true) {
|
||||
if (!fs_1.default.existsSync(dir)) {
|
||||
return {};
|
||||
}
|
||||
return fs_1.default.readdirSync(dir).reduce((res, filename) => {
|
||||
if (path_1.default.extname(filename) === '.json') {
|
||||
try {
|
||||
const locale = path_1.default
|
||||
.basename(filename)
|
||||
.replace(/(uni-app.)?(.*).json/, '$2');
|
||||
if (withMessages) {
|
||||
(0, shared_1.extend)(res[locale] || (res[locale] = {}), parseLocaleJson(path_1.default.join(dir, filename)));
|
||||
}
|
||||
else {
|
||||
res[locale] = {};
|
||||
}
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
return res;
|
||||
}, {});
|
||||
}
|
||||
exports.initLocales = initLocales;
|
||||
function resolveI18nLocale(platform, locales, locale) {
|
||||
if (locale && locales.includes(locale)) {
|
||||
return locale;
|
||||
}
|
||||
const defaultLocales = ['zh-Hans', 'zh-Hant'];
|
||||
if (platform === 'app' || platform === 'h5') {
|
||||
defaultLocales.unshift('en');
|
||||
}
|
||||
else {
|
||||
// 小程序
|
||||
defaultLocales.push('en');
|
||||
}
|
||||
return defaultLocales.find((locale) => locales.includes(locale)) || locales[0];
|
||||
}
|
||||
exports.resolveI18nLocale = resolveI18nLocale;
|
||||
27
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/index.d.ts
generated
vendored
Normal file
27
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
export * from './fs';
|
||||
export * from './mp';
|
||||
export * from './url';
|
||||
export * from './env';
|
||||
export * from './hbx';
|
||||
export * from './ssr';
|
||||
export * from './vue';
|
||||
export * from './uts';
|
||||
export * from './logs';
|
||||
export * from './i18n';
|
||||
export * from './deps';
|
||||
export * from './json';
|
||||
export * from './vite';
|
||||
export * from './utils';
|
||||
export * from './easycom';
|
||||
export * from './constants';
|
||||
export * from './preprocess';
|
||||
export * from './postcss';
|
||||
export * from './filter';
|
||||
export * from './esbuild';
|
||||
export * from './resolve';
|
||||
export * from './scripts';
|
||||
export * from './platform';
|
||||
export { parseUniExtApis, parseInjects, Define, DefineOptions, Defines, } from './uni_modules';
|
||||
export { M } from './messages';
|
||||
export * from './exports';
|
||||
export { checkUpdate } from './checkUpdate';
|
||||
49
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/index.js
generated
vendored
Normal file
49
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.checkUpdate = exports.M = exports.parseInjects = exports.parseUniExtApis = void 0;
|
||||
__exportStar(require("./fs"), exports);
|
||||
__exportStar(require("./mp"), exports);
|
||||
__exportStar(require("./url"), exports);
|
||||
__exportStar(require("./env"), exports);
|
||||
__exportStar(require("./hbx"), exports);
|
||||
__exportStar(require("./ssr"), exports);
|
||||
__exportStar(require("./vue"), exports);
|
||||
__exportStar(require("./uts"), exports);
|
||||
__exportStar(require("./logs"), exports);
|
||||
__exportStar(require("./i18n"), exports);
|
||||
__exportStar(require("./deps"), exports);
|
||||
__exportStar(require("./json"), exports);
|
||||
__exportStar(require("./vite"), exports);
|
||||
__exportStar(require("./utils"), exports);
|
||||
__exportStar(require("./easycom"), exports);
|
||||
__exportStar(require("./constants"), exports);
|
||||
__exportStar(require("./preprocess"), exports);
|
||||
__exportStar(require("./postcss"), exports);
|
||||
__exportStar(require("./filter"), exports);
|
||||
__exportStar(require("./esbuild"), exports);
|
||||
__exportStar(require("./resolve"), exports);
|
||||
__exportStar(require("./scripts"), exports);
|
||||
__exportStar(require("./platform"), exports);
|
||||
var uni_modules_1 = require("./uni_modules");
|
||||
Object.defineProperty(exports, "parseUniExtApis", { enumerable: true, get: function () { return uni_modules_1.parseUniExtApis; } });
|
||||
Object.defineProperty(exports, "parseInjects", { enumerable: true, get: function () { return uni_modules_1.parseInjects; } });
|
||||
var messages_1 = require("./messages");
|
||||
Object.defineProperty(exports, "M", { enumerable: true, get: function () { return messages_1.M; } });
|
||||
__exportStar(require("./exports"), exports);
|
||||
// @ts-ignore
|
||||
var checkUpdate_1 = require("./checkUpdate");
|
||||
Object.defineProperty(exports, "checkUpdate", { enumerable: true, get: function () { return checkUpdate_1.checkUpdate; } });
|
||||
3
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/index.d.ts
generated
vendored
Normal file
3
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './pages';
|
||||
export * from './manifest';
|
||||
export { polyfillCode, arrayBufferCode, restoreGlobalCode } from './pages/code';
|
||||
23
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/index.js
generated
vendored
Normal file
23
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/index.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.restoreGlobalCode = exports.arrayBufferCode = exports.polyfillCode = void 0;
|
||||
__exportStar(require("./pages"), exports);
|
||||
__exportStar(require("./manifest"), exports);
|
||||
var code_1 = require("./pages/code");
|
||||
Object.defineProperty(exports, "polyfillCode", { enumerable: true, get: function () { return code_1.polyfillCode; } });
|
||||
Object.defineProperty(exports, "arrayBufferCode", { enumerable: true, get: function () { return code_1.arrayBufferCode; } });
|
||||
Object.defineProperty(exports, "restoreGlobalCode", { enumerable: true, get: function () { return code_1.restoreGlobalCode; } });
|
||||
2
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/arguments.d.ts
generated
vendored
Normal file
2
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/arguments.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export declare function initArguments(manifestJson: Record<string, any>, pagesJson: UniApp.PagesJson): void;
|
||||
export declare function parseArguments(pagesJson: UniApp.PagesJson): string | undefined;
|
||||
35
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/arguments.js
generated
vendored
Normal file
35
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/arguments.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseArguments = exports.initArguments = void 0;
|
||||
function initArguments(manifestJson, pagesJson) {
|
||||
const args = parseArguments(pagesJson);
|
||||
if (args) {
|
||||
manifestJson.plus.arguments = args;
|
||||
}
|
||||
}
|
||||
exports.initArguments = initArguments;
|
||||
function parseArguments(pagesJson) {
|
||||
if (process.env.NODE_ENV !== 'development') {
|
||||
return;
|
||||
}
|
||||
// 指定了入口
|
||||
if (process.env.UNI_CLI_LAUNCH_PAGE_PATH) {
|
||||
return JSON.stringify({
|
||||
path: process.env.UNI_CLI_LAUNCH_PAGE_PATH,
|
||||
query: process.env.UNI_CLI_LAUNCH_PAGE_QUERY,
|
||||
});
|
||||
}
|
||||
const condition = pagesJson.condition;
|
||||
if (condition && condition.list?.length) {
|
||||
const list = condition.list;
|
||||
let current = condition.current || 0;
|
||||
if (current < 0) {
|
||||
current = 0;
|
||||
}
|
||||
if (current >= list.length) {
|
||||
current = 0;
|
||||
}
|
||||
return JSON.stringify(list[current]);
|
||||
}
|
||||
}
|
||||
exports.parseArguments = parseArguments;
|
||||
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/checksystemwebview.d.ts
generated
vendored
Normal file
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/checksystemwebview.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function initCheckSystemWebview(manifestJson: Record<string, any>): void;
|
||||
17
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/checksystemwebview.js
generated
vendored
Normal file
17
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/checksystemwebview.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initCheckSystemWebview = void 0;
|
||||
function initCheckSystemWebview(manifestJson) {
|
||||
// 检查Android系统webview版本 || 下载X5后启动
|
||||
let plusWebView = manifestJson.plus.webView;
|
||||
if (plusWebView) {
|
||||
manifestJson.plus['uni-app'].webView = plusWebView;
|
||||
delete manifestJson.plus.webView;
|
||||
}
|
||||
else {
|
||||
manifestJson.plus['uni-app'].webView = {
|
||||
minUserAgentVersion: '49.0',
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.initCheckSystemWebview = initCheckSystemWebview;
|
||||
4
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/confusion.d.ts
generated
vendored
Normal file
4
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/confusion.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export declare const APP_CONFUSION_FILENAME = "app-confusion.js";
|
||||
export declare function isConfusionFile(filename: string): boolean;
|
||||
export declare function hasConfusionFile(inputDir?: string): boolean;
|
||||
export declare function initConfusion(manifestJson: Record<string, any>): void;
|
||||
75
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/confusion.js
generated
vendored
Normal file
75
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/confusion.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initConfusion = exports.hasConfusionFile = exports.isConfusionFile = exports.APP_CONFUSION_FILENAME = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const utils_1 = require("../../../utils");
|
||||
const constants_1 = require("../../../constants");
|
||||
const manifest_1 = require("../../manifest");
|
||||
function isJsFile(filename) {
|
||||
return constants_1.EXTNAME_JS_RE.test(filename);
|
||||
}
|
||||
function isStaticJsFile(filename) {
|
||||
return (filename.indexOf('hybrid/html') === 0 ||
|
||||
filename.indexOf('static/') === 0 ||
|
||||
filename.indexOf('/static/') !== -1); // subpackages, uni_modules 中的 static 目录
|
||||
}
|
||||
const dynamicConfusionJsFiles = [];
|
||||
exports.APP_CONFUSION_FILENAME = 'app-confusion.js';
|
||||
function isConfusionFile(filename) {
|
||||
return dynamicConfusionJsFiles.includes((0, utils_1.normalizePath)(filename));
|
||||
}
|
||||
exports.isConfusionFile = isConfusionFile;
|
||||
function hasConfusionFile(inputDir) {
|
||||
if (inputDir) {
|
||||
const manifestJson = (0, manifest_1.parseManifestJsonOnce)(inputDir);
|
||||
const resources = manifestJson['app-plus']?.confusion?.resources;
|
||||
if (resources && parseConfusion(resources)[1].length) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return !!dynamicConfusionJsFiles.length;
|
||||
}
|
||||
exports.hasConfusionFile = hasConfusionFile;
|
||||
function parseConfusion(resources) {
|
||||
const res = {};
|
||||
const dynamicJsFiles = [];
|
||||
Object.keys(resources).reduce((res, name) => {
|
||||
const extname = path_1.default.extname(name);
|
||||
if (extname === '.nvue') {
|
||||
res[name.replace('.nvue', '.js')] = resources[name];
|
||||
}
|
||||
else if (isJsFile(name)) {
|
||||
// 静态 js 加密
|
||||
if (isStaticJsFile(name)) {
|
||||
res[name] = resources[name];
|
||||
}
|
||||
else {
|
||||
// 非静态 js 将被合并进 app-confusion.js
|
||||
dynamicJsFiles.push(name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new Error(`原生混淆仅支持 nvue 页面,错误的页面路径:${name}`);
|
||||
}
|
||||
// TODO 旧编译器会检查要加密的 nvue 页面(包括subnvue)是否被使用?后续有时间再考虑支持吧,意义不太大
|
||||
return res;
|
||||
}, res);
|
||||
if (dynamicJsFiles.length) {
|
||||
res[exports.APP_CONFUSION_FILENAME] = {};
|
||||
}
|
||||
return [res, dynamicJsFiles];
|
||||
}
|
||||
function initConfusion(manifestJson) {
|
||||
dynamicConfusionJsFiles.length = 0;
|
||||
if (!manifestJson.plus.confusion?.resources) {
|
||||
return;
|
||||
}
|
||||
const resources = manifestJson.plus.confusion.resources;
|
||||
const [res, dynamicJsFiles] = parseConfusion(resources);
|
||||
manifestJson.plus.confusion.resources = res;
|
||||
dynamicConfusionJsFiles.push(...dynamicJsFiles);
|
||||
}
|
||||
exports.initConfusion = initConfusion;
|
||||
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/defaultManifestJson.d.ts
generated
vendored
Normal file
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/defaultManifestJson.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function initDefaultManifestJson(): any;
|
||||
41
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/defaultManifestJson.js
generated
vendored
Normal file
41
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/defaultManifestJson.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initDefaultManifestJson = void 0;
|
||||
function initDefaultManifestJson() {
|
||||
return JSON.parse(defaultManifestJson);
|
||||
}
|
||||
exports.initDefaultManifestJson = initDefaultManifestJson;
|
||||
const defaultManifestJson = `{
|
||||
"@platforms": [
|
||||
"android",
|
||||
"iPhone",
|
||||
"iPad"
|
||||
],
|
||||
"id": "__WEAPP_ID",
|
||||
"name": "__WEAPP_NAME",
|
||||
"version": {
|
||||
"name": "1.0",
|
||||
"code": ""
|
||||
},
|
||||
"description": "",
|
||||
"developer": {
|
||||
"name": "",
|
||||
"email": "",
|
||||
"url": ""
|
||||
},
|
||||
"permissions": {},
|
||||
"plus": {
|
||||
"useragent": {
|
||||
"value": "uni-app appservice",
|
||||
"concatenate": true
|
||||
},
|
||||
"splashscreen": {
|
||||
"target":"id:1",
|
||||
"autoclose": true,
|
||||
"waiting": true,
|
||||
"alwaysShowBeforeRender":true
|
||||
},
|
||||
"popGesture": "close",
|
||||
"launchwebview": {}
|
||||
}
|
||||
}`;
|
||||
3
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/env.d.ts
generated
vendored
Normal file
3
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/env.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare function getAppRenderer(manifestJson: Record<string, any>): "" | "native";
|
||||
export declare function getAppCodeSpliting(manifestJson: Record<string, any>): boolean;
|
||||
export declare function getAppStyleIsolation(manifestJson: Record<string, any>): 'apply-shared' | 'isolated' | 'shared';
|
||||
22
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/env.js
generated
vendored
Normal file
22
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/env.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getAppStyleIsolation = exports.getAppCodeSpliting = exports.getAppRenderer = void 0;
|
||||
function getAppRenderer(manifestJson) {
|
||||
const platformOptions = manifestJson['app-plus'];
|
||||
if (platformOptions && platformOptions.renderer === 'native') {
|
||||
return 'native';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
exports.getAppRenderer = getAppRenderer;
|
||||
function getAppCodeSpliting(manifestJson) {
|
||||
if (manifestJson['app-plus']?.optimization?.codeSpliting === true) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
exports.getAppCodeSpliting = getAppCodeSpliting;
|
||||
function getAppStyleIsolation(manifestJson) {
|
||||
return (manifestJson['app-plus']?.optimization?.styleIsolation ?? 'apply-shared');
|
||||
}
|
||||
exports.getAppStyleIsolation = getAppStyleIsolation;
|
||||
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/i18n.d.ts
generated
vendored
Normal file
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/i18n.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function initI18n(manifestJson: Record<string, any>): Record<string, any>;
|
||||
14
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/i18n.js
generated
vendored
Normal file
14
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/i18n.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initI18n = void 0;
|
||||
const uni_i18n_1 = require("@dcloudio/uni-i18n");
|
||||
const i18n_1 = require("../../../i18n");
|
||||
function initI18n(manifestJson) {
|
||||
const i18nOptions = (0, i18n_1.initI18nOptions)(process.env.UNI_PLATFORM, process.env.UNI_INPUT_DIR, true);
|
||||
if (i18nOptions) {
|
||||
manifestJson = JSON.parse((0, uni_i18n_1.compileI18nJsonStr)(JSON.stringify(manifestJson), i18nOptions));
|
||||
manifestJson.fallbackLocale = i18nOptions.locale;
|
||||
}
|
||||
return manifestJson;
|
||||
}
|
||||
exports.initI18n = initI18n;
|
||||
5
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/index.d.ts
generated
vendored
Normal file
5
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export declare function normalizeAppManifestJson(userManifestJson: Record<string, any>, pagesJson: UniApp.PagesJson): Record<string, any>;
|
||||
export * from './env';
|
||||
export { APP_CONFUSION_FILENAME, isConfusionFile, hasConfusionFile, } from './confusion';
|
||||
export { getNVueCompiler, getNVueStyleCompiler, getNVueFlexDirection, } from './nvue';
|
||||
export { parseArguments } from './arguments';
|
||||
63
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/index.js
generated
vendored
Normal file
63
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/index.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseArguments = exports.getNVueFlexDirection = exports.getNVueStyleCompiler = exports.getNVueCompiler = exports.hasConfusionFile = exports.isConfusionFile = exports.APP_CONFUSION_FILENAME = exports.normalizeAppManifestJson = void 0;
|
||||
const shared_1 = require("@vue/shared");
|
||||
const merge_1 = require("./merge");
|
||||
const defaultManifestJson_1 = require("./defaultManifestJson");
|
||||
const statusbar_1 = require("./statusbar");
|
||||
const plus_1 = require("./plus");
|
||||
const nvue_1 = require("./nvue");
|
||||
const arguments_1 = require("./arguments");
|
||||
const safearea_1 = require("./safearea");
|
||||
const splashscreen_1 = require("./splashscreen");
|
||||
const confusion_1 = require("./confusion");
|
||||
const uniApp_1 = require("./uniApp");
|
||||
const launchwebview_1 = require("./launchwebview");
|
||||
const checksystemwebview_1 = require("./checksystemwebview");
|
||||
const tabBar_1 = require("./tabBar");
|
||||
const i18n_1 = require("./i18n");
|
||||
const theme_1 = require("../../theme");
|
||||
function normalizeAppManifestJson(userManifestJson, pagesJson) {
|
||||
const manifestJson = (0, merge_1.initRecursiveMerge)((0, defaultManifestJson_1.initDefaultManifestJson)(), userManifestJson);
|
||||
const { pages, globalStyle, tabBar } = (0, theme_1.initTheme)(manifestJson, pagesJson);
|
||||
(0, shared_1.extend)(pagesJson, JSON.parse(JSON.stringify({ pages, globalStyle, tabBar })));
|
||||
(0, statusbar_1.initAppStatusbar)(manifestJson, pagesJson);
|
||||
(0, arguments_1.initArguments)(manifestJson, pagesJson);
|
||||
(0, plus_1.initPlus)(manifestJson, pagesJson);
|
||||
(0, nvue_1.initNVue)(manifestJson, pagesJson);
|
||||
(0, safearea_1.initSafearea)(manifestJson, pagesJson);
|
||||
(0, splashscreen_1.initSplashscreen)(manifestJson, userManifestJson);
|
||||
(0, confusion_1.initConfusion)(manifestJson);
|
||||
(0, uniApp_1.initUniApp)(manifestJson);
|
||||
// 依赖 initArguments 先执行
|
||||
(0, tabBar_1.initTabBar)((0, launchwebview_1.initLaunchwebview)(manifestJson, pagesJson), manifestJson, pagesJson);
|
||||
// 依赖 initUniApp 先执行
|
||||
(0, checksystemwebview_1.initCheckSystemWebview)(manifestJson);
|
||||
return (0, i18n_1.initI18n)(manifestJson);
|
||||
}
|
||||
exports.normalizeAppManifestJson = normalizeAppManifestJson;
|
||||
__exportStar(require("./env"), exports);
|
||||
var confusion_2 = require("./confusion");
|
||||
Object.defineProperty(exports, "APP_CONFUSION_FILENAME", { enumerable: true, get: function () { return confusion_2.APP_CONFUSION_FILENAME; } });
|
||||
Object.defineProperty(exports, "isConfusionFile", { enumerable: true, get: function () { return confusion_2.isConfusionFile; } });
|
||||
Object.defineProperty(exports, "hasConfusionFile", { enumerable: true, get: function () { return confusion_2.hasConfusionFile; } });
|
||||
var nvue_2 = require("./nvue");
|
||||
Object.defineProperty(exports, "getNVueCompiler", { enumerable: true, get: function () { return nvue_2.getNVueCompiler; } });
|
||||
Object.defineProperty(exports, "getNVueStyleCompiler", { enumerable: true, get: function () { return nvue_2.getNVueStyleCompiler; } });
|
||||
Object.defineProperty(exports, "getNVueFlexDirection", { enumerable: true, get: function () { return nvue_2.getNVueFlexDirection; } });
|
||||
var arguments_2 = require("./arguments");
|
||||
Object.defineProperty(exports, "parseArguments", { enumerable: true, get: function () { return arguments_2.parseArguments; } });
|
||||
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/launchwebview.d.ts
generated
vendored
Normal file
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/launchwebview.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function initLaunchwebview(manifestJson: Record<string, any>, pagesJson: UniApp.PagesJson): string;
|
||||
32
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/launchwebview.js
generated
vendored
Normal file
32
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/launchwebview.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initLaunchwebview = void 0;
|
||||
const shared_1 = require("@vue/shared");
|
||||
function initLaunchwebview(manifestJson, pagesJson) {
|
||||
let entryPagePath = pagesJson.pages[0].path;
|
||||
// 依赖前置执行initArguments
|
||||
if (manifestJson.plus.arguments) {
|
||||
try {
|
||||
const args = JSON.parse(manifestJson.plus.arguments);
|
||||
if (args.path) {
|
||||
entryPagePath = args.path;
|
||||
}
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
manifestJson.plus.useragent.value = 'uni-app';
|
||||
(0, shared_1.extend)(manifestJson.plus.launchwebview, {
|
||||
id: '1',
|
||||
kernel: 'WKWebview',
|
||||
});
|
||||
// 首页为nvue
|
||||
const entryPage = pagesJson.pages.find((p) => p.path === entryPagePath);
|
||||
if (entryPage?.style.isNVue) {
|
||||
manifestJson.plus.launchwebview.uniNView = { path: entryPagePath + '.js' };
|
||||
}
|
||||
else {
|
||||
manifestJson.launch_path = '__uniappview.html';
|
||||
}
|
||||
return entryPagePath;
|
||||
}
|
||||
exports.initLaunchwebview = initLaunchwebview;
|
||||
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/merge.d.ts
generated
vendored
Normal file
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/merge.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function initRecursiveMerge(manifestJson: Record<string, any>, userManifestJson: Record<string, any>): Record<string, any>;
|
||||
18
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/merge.js
generated
vendored
Normal file
18
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/merge.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initRecursiveMerge = void 0;
|
||||
const merge_1 = require("merge");
|
||||
function initRecursiveMerge(manifestJson, userManifestJson) {
|
||||
return (0, merge_1.recursive)(true, manifestJson, {
|
||||
id: userManifestJson.appid || '',
|
||||
name: userManifestJson.name || '',
|
||||
description: userManifestJson.description || '',
|
||||
version: {
|
||||
name: userManifestJson.versionName,
|
||||
code: userManifestJson.versionCode,
|
||||
},
|
||||
locale: userManifestJson.locale,
|
||||
uniStatistics: userManifestJson.uniStatistics,
|
||||
}, { plus: userManifestJson['app-plus'] });
|
||||
}
|
||||
exports.initRecursiveMerge = initRecursiveMerge;
|
||||
4
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/nvue.d.ts
generated
vendored
Normal file
4
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/nvue.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export declare function initNVue(manifestJson: Record<string, any>, pagesJson: UniApp.PagesJson): void;
|
||||
export declare function getNVueCompiler(manifestJson: Record<string, any>): "uni-app" | "weex" | "vue" | "vite";
|
||||
export declare function getNVueStyleCompiler(manifestJson: Record<string, any>): "uni-app" | "weex";
|
||||
export declare function getNVueFlexDirection(manifestJson: Record<string, any>): "column" | "row" | "row-reverse" | "column-reverse";
|
||||
41
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/nvue.js
generated
vendored
Normal file
41
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/nvue.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getNVueFlexDirection = exports.getNVueStyleCompiler = exports.getNVueCompiler = exports.initNVue = void 0;
|
||||
function initNVue(manifestJson, pagesJson) { }
|
||||
exports.initNVue = initNVue;
|
||||
function getNVueCompiler(manifestJson) {
|
||||
const platformOptions = manifestJson['app-plus'];
|
||||
if (platformOptions) {
|
||||
const { nvueCompiler } = platformOptions;
|
||||
if (nvueCompiler === 'weex') {
|
||||
return 'weex';
|
||||
}
|
||||
if (nvueCompiler === 'vue') {
|
||||
return 'vue';
|
||||
}
|
||||
if (nvueCompiler === 'vite') {
|
||||
return 'vite';
|
||||
}
|
||||
}
|
||||
return 'uni-app';
|
||||
}
|
||||
exports.getNVueCompiler = getNVueCompiler;
|
||||
function getNVueStyleCompiler(manifestJson) {
|
||||
const platformOptions = manifestJson['app-plus'];
|
||||
if (platformOptions && platformOptions.nvueStyleCompiler === 'uni-app') {
|
||||
return 'uni-app';
|
||||
}
|
||||
return 'weex';
|
||||
}
|
||||
exports.getNVueStyleCompiler = getNVueStyleCompiler;
|
||||
const flexDirs = ['row', 'row-reverse', 'column', 'column-reverse'];
|
||||
function getNVueFlexDirection(manifestJson) {
|
||||
let flexDir = 'column';
|
||||
const appPlusJson = manifestJson['app-plus'] || manifestJson['plus'];
|
||||
if (appPlusJson?.nvue?.['flex-direction'] &&
|
||||
flexDirs.includes(appPlusJson?.nvue?.['flex-direction'])) {
|
||||
flexDir = appPlusJson.nvue['flex-direction'];
|
||||
}
|
||||
return flexDir;
|
||||
}
|
||||
exports.getNVueFlexDirection = getNVueFlexDirection;
|
||||
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/plus.d.ts
generated
vendored
Normal file
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/plus.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function initPlus(manifestJson: Record<string, any>, pagesJson: UniApp.PagesJson): void;
|
||||
130
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/plus.js
generated
vendored
Normal file
130
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/plus.js
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initPlus = void 0;
|
||||
const shared_1 = require("@vue/shared");
|
||||
const merge_1 = require("merge");
|
||||
const wxPageOrientationMapping = {
|
||||
auto: [
|
||||
'portrait-primary',
|
||||
'portrait-secondary',
|
||||
'landscape-primary',
|
||||
'landscape-secondary',
|
||||
],
|
||||
portrait: ['portrait-primary', 'portrait-secondary'],
|
||||
landscape: ['landscape-primary', 'landscape-secondary'],
|
||||
};
|
||||
function initPlus(manifestJson, pagesJson) {
|
||||
initUniStatistics(manifestJson);
|
||||
// 转换为老版本配置
|
||||
if (manifestJson.plus.modules) {
|
||||
manifestJson.permissions = manifestJson.plus.modules;
|
||||
delete manifestJson.plus.modules;
|
||||
}
|
||||
const distribute = manifestJson.plus.distribute;
|
||||
if (distribute) {
|
||||
if (distribute.android) {
|
||||
manifestJson.plus.distribute.google = distribute.android;
|
||||
delete manifestJson.plus.distribute.android;
|
||||
}
|
||||
if (distribute.ios) {
|
||||
manifestJson.plus.distribute.apple = distribute.ios;
|
||||
delete manifestJson.plus.distribute.ios;
|
||||
}
|
||||
if (distribute.sdkConfigs) {
|
||||
manifestJson.plus.distribute.plugins = distribute.sdkConfigs;
|
||||
delete manifestJson.plus.distribute.sdkConfigs;
|
||||
}
|
||||
if (manifestJson.plus.darkmode) {
|
||||
if (!(distribute.google || (distribute.google = {})).defaultNightMode) {
|
||||
distribute.google.defaultNightMode = 'auto';
|
||||
}
|
||||
if (!(distribute.apple || (distribute.apple = {})).UIUserInterfaceStyle) {
|
||||
distribute.apple.UIUserInterfaceStyle = 'Automatic';
|
||||
}
|
||||
}
|
||||
}
|
||||
// 屏幕启动方向
|
||||
if (manifestJson.plus.screenOrientation) {
|
||||
// app平台优先使用 manifest 配置
|
||||
manifestJson.screenOrientation = manifestJson.plus.screenOrientation;
|
||||
delete manifestJson.plus.screenOrientation;
|
||||
}
|
||||
else if (pagesJson.globalStyle?.pageOrientation) {
|
||||
// 兼容微信小程序
|
||||
const pageOrientationValue = wxPageOrientationMapping[pagesJson.globalStyle
|
||||
.pageOrientation];
|
||||
if (pageOrientationValue) {
|
||||
manifestJson.screenOrientation = pageOrientationValue;
|
||||
}
|
||||
}
|
||||
// 全屏配置
|
||||
manifestJson.fullscreen = manifestJson.plus.fullscreen;
|
||||
// 地图坐标系
|
||||
if (manifestJson.permissions && manifestJson.permissions.Maps) {
|
||||
manifestJson.permissions.Maps.coordType = 'gcj02';
|
||||
}
|
||||
if (!manifestJson.permissions) {
|
||||
manifestJson.permissions = {};
|
||||
}
|
||||
manifestJson.permissions.UniNView = {
|
||||
description: 'UniNView原生渲染',
|
||||
};
|
||||
// 允许内联播放视频
|
||||
manifestJson.plus.allowsInlineMediaPlayback = true;
|
||||
if (!manifestJson.plus.distribute) {
|
||||
manifestJson.plus.distribute = {
|
||||
plugins: {},
|
||||
};
|
||||
}
|
||||
if (!manifestJson.plus.distribute.plugins) {
|
||||
manifestJson.plus.distribute.plugins = {};
|
||||
}
|
||||
// 录音支持 mp3
|
||||
manifestJson.plus.distribute.plugins.audio = {
|
||||
mp3: {
|
||||
description: 'Android平台录音支持MP3格式文件',
|
||||
},
|
||||
};
|
||||
// 有效值为 close,none
|
||||
if (!['close', 'none'].includes(manifestJson.plus.popGesture)) {
|
||||
manifestJson.plus.popGesture = 'close';
|
||||
}
|
||||
}
|
||||
exports.initPlus = initPlus;
|
||||
function initUniStatistics(manifestJson) {
|
||||
// 根节点配置了统计
|
||||
if (manifestJson.uniStatistics) {
|
||||
manifestJson.plus.uniStatistics = (0, merge_1.recursive)(true, manifestJson.uniStatistics, manifestJson.plus.uniStatistics);
|
||||
delete manifestJson.uniStatistics;
|
||||
}
|
||||
if (!process.env.UNI_CLOUD_PROVIDER) {
|
||||
return;
|
||||
}
|
||||
let spaces = [];
|
||||
try {
|
||||
spaces = JSON.parse(process.env.UNI_CLOUD_PROVIDER);
|
||||
}
|
||||
catch (e) { }
|
||||
if (!(0, shared_1.isArray)(spaces) || !spaces.length) {
|
||||
return;
|
||||
}
|
||||
const space = spaces[0];
|
||||
if (!space) {
|
||||
return;
|
||||
}
|
||||
const uniStatistics = manifestJson.plus?.uniStatistics;
|
||||
if (!uniStatistics) {
|
||||
return;
|
||||
}
|
||||
if (uniStatistics.version === 2 || uniStatistics.version === '2') {
|
||||
if (uniStatistics.uniCloud && uniStatistics.uniCloud.spaceId) {
|
||||
return;
|
||||
}
|
||||
uniStatistics.uniCloud = {
|
||||
provider: space.provider,
|
||||
spaceId: space.spaceId,
|
||||
clientSecret: space.clientSecret,
|
||||
endpoint: space.endpoint,
|
||||
};
|
||||
}
|
||||
}
|
||||
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/safearea.d.ts
generated
vendored
Normal file
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/safearea.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function initSafearea(manifestJson: Record<string, any>, pagesJson: UniApp.PagesJson): void;
|
||||
27
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/safearea.js
generated
vendored
Normal file
27
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/safearea.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initSafearea = void 0;
|
||||
function initSafearea(manifestJson, pagesJson) {
|
||||
if (pagesJson.tabBar?.list?.length) {
|
||||
// 安全区配置 仅包含 tabBar 的时候才配置
|
||||
if (!manifestJson.plus.safearea) {
|
||||
manifestJson.plus.safearea = {
|
||||
background: pagesJson.tabBar.backgroundColor || '#FFFFFF',
|
||||
bottom: {
|
||||
offset: 'auto',
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!manifestJson.plus.launchwebview) {
|
||||
manifestJson.plus.launchwebview = {
|
||||
render: 'always',
|
||||
};
|
||||
}
|
||||
else if (!manifestJson.plus.launchwebview.render) {
|
||||
manifestJson.plus.launchwebview.render = 'always';
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.initSafearea = initSafearea;
|
||||
5
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/splashscreen.d.ts
generated
vendored
Normal file
5
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/splashscreen.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export declare function initSplashscreen(manifestJson: Record<string, any>, userManifestJson: Record<string, any>): void;
|
||||
export declare function getSplashscreen(manifestJson: Record<string, any>): {
|
||||
autoclose: boolean;
|
||||
alwaysShowBeforeRender: boolean;
|
||||
};
|
||||
43
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/splashscreen.js
generated
vendored
Normal file
43
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/splashscreen.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getSplashscreen = exports.initSplashscreen = void 0;
|
||||
const shared_1 = require("@vue/shared");
|
||||
function initSplashscreen(manifestJson, userManifestJson) {
|
||||
if (!manifestJson.plus.splashscreen) {
|
||||
return;
|
||||
}
|
||||
// 强制白屏检测
|
||||
const splashscreenOptions = userManifestJson['app-plus'] && userManifestJson['app-plus'].splashscreen;
|
||||
const hasAlwaysShowBeforeRender = splashscreenOptions && (0, shared_1.hasOwn)(splashscreenOptions, 'alwaysShowBeforeRender');
|
||||
if (!hasAlwaysShowBeforeRender &&
|
||||
manifestJson.plus.splashscreen.autoclose === false) {
|
||||
// 兼容旧版本仅配置了 autoclose 为 false
|
||||
manifestJson.plus.splashscreen.alwaysShowBeforeRender = false;
|
||||
}
|
||||
if (manifestJson.plus.splashscreen.alwaysShowBeforeRender) {
|
||||
// 白屏检测
|
||||
if (!manifestJson.plus.splashscreen.target) {
|
||||
manifestJson.plus.splashscreen.target = 'id:1';
|
||||
}
|
||||
manifestJson.plus.splashscreen.autoclose = true;
|
||||
manifestJson.plus.splashscreen.delay = 0;
|
||||
}
|
||||
else {
|
||||
// 不启用白屏检测
|
||||
delete manifestJson.plus.splashscreen.target;
|
||||
if (manifestJson.plus.splashscreen.autoclose) {
|
||||
// 启用 uni-app 框架关闭 splash
|
||||
manifestJson.plus.splashscreen.autoclose = false; // 原 5+ autoclose 改为 false
|
||||
}
|
||||
}
|
||||
delete manifestJson.plus.splashscreen.alwaysShowBeforeRender;
|
||||
}
|
||||
exports.initSplashscreen = initSplashscreen;
|
||||
function getSplashscreen(manifestJson) {
|
||||
const splashscreenOptions = manifestJson['app-plus']?.splashscreen || {};
|
||||
return {
|
||||
autoclose: splashscreenOptions.autoclose !== false,
|
||||
alwaysShowBeforeRender: splashscreenOptions.alwaysShowBeforeRender !== false,
|
||||
};
|
||||
}
|
||||
exports.getSplashscreen = getSplashscreen;
|
||||
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/statusbar.d.ts
generated
vendored
Normal file
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/statusbar.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function initAppStatusbar(manifestJson: Record<string, any>, pagesJson: UniApp.PagesJson): Record<string, any>;
|
||||
16
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/statusbar.js
generated
vendored
Normal file
16
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/statusbar.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initAppStatusbar = void 0;
|
||||
function initAppStatusbar(manifestJson, pagesJson) {
|
||||
const titleColor = pagesJson.pages[0].style.navigationBar.titleColor ||
|
||||
pagesJson.globalStyle.navigationBar.titleColor ||
|
||||
'#000000';
|
||||
const backgroundColor = pagesJson.globalStyle.navigationBar.backgroundColor || '#000000';
|
||||
manifestJson.plus.statusbar = {
|
||||
immersed: 'supportedDevice',
|
||||
style: titleColor === '#ffffff' ? 'light' : 'dark',
|
||||
background: backgroundColor,
|
||||
};
|
||||
return manifestJson;
|
||||
}
|
||||
exports.initAppStatusbar = initAppStatusbar;
|
||||
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/tabBar.d.ts
generated
vendored
Normal file
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/tabBar.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function initTabBar(entryPagePath: string, manifestJson: Record<string, any>, pagesJson: UniApp.PagesJson): void;
|
||||
24
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/tabBar.js
generated
vendored
Normal file
24
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/tabBar.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initTabBar = void 0;
|
||||
const uni_shared_1 = require("@dcloudio/uni-shared");
|
||||
function initTabBar(entryPagePath, manifestJson, pagesJson) {
|
||||
if (!pagesJson.tabBar?.list?.length) {
|
||||
return;
|
||||
}
|
||||
const tabBar = JSON.parse(JSON.stringify(pagesJson.tabBar));
|
||||
tabBar.borderStyle = (0, uni_shared_1.normalizeTabBarStyles)(tabBar.borderStyle);
|
||||
if (!tabBar.selectedColor) {
|
||||
tabBar.selectedColor = uni_shared_1.SELECTED_COLOR;
|
||||
}
|
||||
tabBar.height = `${parseFloat(tabBar.height) || uni_shared_1.TABBAR_HEIGHT}px`;
|
||||
// 首页是 tabBar 页面
|
||||
const item = tabBar.list.find((page) => page.pagePath === entryPagePath);
|
||||
if (item) {
|
||||
;
|
||||
tabBar.child = ['lauchwebview'];
|
||||
tabBar.selected = tabBar.list.indexOf(item);
|
||||
}
|
||||
manifestJson.plus.tabBar = tabBar;
|
||||
}
|
||||
exports.initTabBar = initTabBar;
|
||||
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/uniApp.d.ts
generated
vendored
Normal file
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/uniApp.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function initUniApp(manifestJson: Record<string, any>): void;
|
||||
19
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/uniApp.js
generated
vendored
Normal file
19
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/manifest/uniApp.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initUniApp = void 0;
|
||||
const nvue_1 = require("./nvue");
|
||||
function initUniApp(manifestJson) {
|
||||
manifestJson.plus['uni-app'] = {
|
||||
control: 'uni-v3',
|
||||
vueVersion: '3',
|
||||
compilerVersion: process.env.UNI_COMPILER_VERSION,
|
||||
nvueCompiler: (0, nvue_1.getNVueCompiler)(manifestJson),
|
||||
renderer: 'auto',
|
||||
nvue: {
|
||||
'flex-direction': (0, nvue_1.getNVueFlexDirection)(manifestJson),
|
||||
},
|
||||
nvueLaunchMode: manifestJson.plus.nvueLaunchMode === 'fast' ? 'fast' : 'normal',
|
||||
};
|
||||
delete manifestJson.plus.nvueLaunchMode;
|
||||
}
|
||||
exports.initUniApp = initUniApp;
|
||||
4
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/pages/code.d.ts
generated
vendored
Normal file
4
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/pages/code.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export declare const arrayBufferCode = "\nif (typeof uni !== 'undefined' && uni && uni.requireGlobal) {\n const global = uni.requireGlobal()\n ArrayBuffer = global.ArrayBuffer\n Int8Array = global.Int8Array\n Uint8Array = global.Uint8Array\n Uint8ClampedArray = global.Uint8ClampedArray\n Int16Array = global.Int16Array\n Uint16Array = global.Uint16Array\n Int32Array = global.Int32Array\n Uint32Array = global.Uint32Array\n Float32Array = global.Float32Array\n Float64Array = global.Float64Array\n BigInt64Array = global.BigInt64Array\n BigUint64Array = global.BigUint64Array\n};\n";
|
||||
export declare const polyfillCode: string;
|
||||
export declare const restoreGlobalCode = "\nif(uni.restoreGlobal){\n uni.restoreGlobal(Vue,weex,plus,setTimeout,clearTimeout,setInterval,clearInterval)\n}\n";
|
||||
export declare const globalCode: string;
|
||||
61
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/pages/code.js
generated
vendored
Normal file
61
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/pages/code.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.globalCode = exports.restoreGlobalCode = exports.polyfillCode = exports.arrayBufferCode = void 0;
|
||||
exports.arrayBufferCode = `
|
||||
if (typeof uni !== 'undefined' && uni && uni.requireGlobal) {
|
||||
const global = uni.requireGlobal()
|
||||
ArrayBuffer = global.ArrayBuffer
|
||||
Int8Array = global.Int8Array
|
||||
Uint8Array = global.Uint8Array
|
||||
Uint8ClampedArray = global.Uint8ClampedArray
|
||||
Int16Array = global.Int16Array
|
||||
Uint16Array = global.Uint16Array
|
||||
Int32Array = global.Int32Array
|
||||
Uint32Array = global.Uint32Array
|
||||
Float32Array = global.Float32Array
|
||||
Float64Array = global.Float64Array
|
||||
BigInt64Array = global.BigInt64Array
|
||||
BigUint64Array = global.BigUint64Array
|
||||
};
|
||||
`;
|
||||
exports.polyfillCode = `
|
||||
if (typeof Promise !== 'undefined' && !Promise.prototype.finally) {
|
||||
Promise.prototype.finally = function(callback) {
|
||||
const promise = this.constructor
|
||||
return this.then(
|
||||
value => promise.resolve(callback()).then(() => value),
|
||||
reason => promise.resolve(callback()).then(() => {
|
||||
throw reason
|
||||
})
|
||||
)
|
||||
}
|
||||
};
|
||||
${exports.arrayBufferCode}
|
||||
`;
|
||||
exports.restoreGlobalCode = `
|
||||
if(uni.restoreGlobal){
|
||||
uni.restoreGlobal(Vue,weex,plus,setTimeout,clearTimeout,setInterval,clearInterval)
|
||||
}
|
||||
`;
|
||||
const GLOBALS = [
|
||||
'global',
|
||||
'window',
|
||||
'document',
|
||||
'frames',
|
||||
'self',
|
||||
'location',
|
||||
'navigator',
|
||||
'localStorage',
|
||||
'history',
|
||||
'Caches',
|
||||
'screen',
|
||||
'alert',
|
||||
'confirm',
|
||||
'prompt',
|
||||
'fetch',
|
||||
'XMLHttpRequest',
|
||||
'WebSocket',
|
||||
'webkit',
|
||||
'print',
|
||||
];
|
||||
exports.globalCode = GLOBALS.map((g) => `${g}:u`).join(',');
|
||||
2
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/pages/definePage.d.ts
generated
vendored
Normal file
2
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/pages/definePage.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export declare function definePageCode(pagesJson: Record<string, any>): string;
|
||||
export declare function defineNVuePageCode(pagesJson: Record<string, any>): string;
|
||||
42
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/pages/definePage.js
generated
vendored
Normal file
42
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/pages/definePage.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.defineNVuePageCode = exports.definePageCode = void 0;
|
||||
const utils_1 = require("../../../utils");
|
||||
function definePageCode(pagesJson) {
|
||||
const importPagesCode = [];
|
||||
const definePagesCode = [];
|
||||
pagesJson.pages.forEach((page) => {
|
||||
if (page.style.isNVue) {
|
||||
return;
|
||||
}
|
||||
const pagePath = page.path;
|
||||
const pageIdentifier = (0, utils_1.normalizeIdentifier)(pagePath);
|
||||
const pagePathWithExtname = (0, utils_1.normalizePagePath)(pagePath, 'app');
|
||||
if (pagePathWithExtname) {
|
||||
if (process.env.UNI_APP_CODE_SPLITING) {
|
||||
// 拆分页面
|
||||
importPagesCode.push(`const ${pageIdentifier} = ()=>import('./${pagePathWithExtname}')`);
|
||||
}
|
||||
else {
|
||||
importPagesCode.push(`import ${pageIdentifier} from './${pagePathWithExtname}'`);
|
||||
}
|
||||
definePagesCode.push(`__definePage('${pagePath}',${pageIdentifier})`);
|
||||
}
|
||||
});
|
||||
return importPagesCode.join('\n') + '\n' + definePagesCode.join('\n');
|
||||
}
|
||||
exports.definePageCode = definePageCode;
|
||||
function defineNVuePageCode(pagesJson) {
|
||||
const importNVuePagesCode = [];
|
||||
pagesJson.pages.forEach((page) => {
|
||||
if (!page.style.isNVue) {
|
||||
return;
|
||||
}
|
||||
const pagePathWithExtname = (0, utils_1.normalizePagePath)(page.path, 'app');
|
||||
if (pagePathWithExtname) {
|
||||
importNVuePagesCode.push(`import('./${pagePathWithExtname}').then((res)=>{res.length})`);
|
||||
}
|
||||
});
|
||||
return importNVuePagesCode.join('\n');
|
||||
}
|
||||
exports.defineNVuePageCode = defineNVuePageCode;
|
||||
3
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/pages/index.d.ts
generated
vendored
Normal file
3
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/pages/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare function normalizeAppPagesJson(pagesJson: Record<string, any>): string;
|
||||
export declare function normalizeAppNVuePagesJson(pagesJson: Record<string, any>): string;
|
||||
export declare function normalizeAppConfigService(pagesJson: UniApp.PagesJson, manifestJson: Record<string, any>): string;
|
||||
29
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/pages/index.js
generated
vendored
Normal file
29
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/pages/index.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.normalizeAppConfigService = exports.normalizeAppNVuePagesJson = exports.normalizeAppPagesJson = void 0;
|
||||
const code_1 = require("./code");
|
||||
const definePage_1 = require("./definePage");
|
||||
const uniConfig_1 = require("./uniConfig");
|
||||
const uniRoutes_1 = require("./uniRoutes");
|
||||
function normalizeAppPagesJson(pagesJson) {
|
||||
return (0, definePage_1.definePageCode)(pagesJson);
|
||||
}
|
||||
exports.normalizeAppPagesJson = normalizeAppPagesJson;
|
||||
function normalizeAppNVuePagesJson(pagesJson) {
|
||||
return (0, definePage_1.defineNVuePageCode)(pagesJson);
|
||||
}
|
||||
exports.normalizeAppNVuePagesJson = normalizeAppNVuePagesJson;
|
||||
function normalizeAppConfigService(pagesJson, manifestJson) {
|
||||
return `
|
||||
;(function(){
|
||||
let u=void 0,isReady=false,onReadyCallbacks=[],isServiceReady=false,onServiceReadyCallbacks=[];
|
||||
const __uniConfig = ${(0, uniConfig_1.normalizeAppUniConfig)(pagesJson, manifestJson)};
|
||||
const __uniRoutes = ${(0, uniRoutes_1.normalizeAppUniRoutes)(pagesJson)}.map(uniRoute=>(uniRoute.meta.route=uniRoute.path,__uniConfig.pages.push(uniRoute.path),uniRoute.path='/'+uniRoute.path,uniRoute));
|
||||
__uniConfig.styles=${process.env.UNI_NVUE_APP_STYLES || '[]'};//styles
|
||||
__uniConfig.onReady=function(callback){if(__uniConfig.ready){callback()}else{onReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"ready",{get:function(){return isReady},set:function(val){isReady=val;if(!isReady){return}const callbacks=onReadyCallbacks.slice(0);onReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
|
||||
__uniConfig.onServiceReady=function(callback){if(__uniConfig.serviceReady){callback()}else{onServiceReadyCallbacks.push(callback)}};Object.defineProperty(__uniConfig,"serviceReady",{get:function(){return isServiceReady},set:function(val){isServiceReady=val;if(!isServiceReady){return}const callbacks=onServiceReadyCallbacks.slice(0);onServiceReadyCallbacks.length=0;callbacks.forEach(function(callback){callback()})}});
|
||||
service.register("uni-app-config",{create(a,b,c){if(!__uniConfig.viewport){var d=b.weex.config.env.scale,e=b.weex.config.env.deviceWidth,f=Math.ceil(e/d);Object.assign(__uniConfig,{viewport:f,defaultFontSize:16})}return{instance:{__uniConfig:__uniConfig,__uniRoutes:__uniRoutes,${code_1.globalCode}}}}});
|
||||
})();
|
||||
`;
|
||||
}
|
||||
exports.normalizeAppConfigService = normalizeAppConfigService;
|
||||
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/pages/uniConfig.d.ts
generated
vendored
Normal file
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/pages/uniConfig.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function normalizeAppUniConfig(pagesJson: UniApp.PagesJson, manifestJson: Record<string, any>): string;
|
||||
72
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/pages/uniConfig.js
generated
vendored
Normal file
72
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/pages/uniConfig.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.normalizeAppUniConfig = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const i18n_1 = require("../../../i18n");
|
||||
const manifest_1 = require("../../manifest");
|
||||
const manifest_2 = require("../manifest");
|
||||
const arguments_1 = require("../manifest/arguments");
|
||||
const splashscreen_1 = require("../manifest/splashscreen");
|
||||
const theme_1 = require("../../theme");
|
||||
function normalizeAppUniConfig(pagesJson, manifestJson) {
|
||||
const { autoclose, alwaysShowBeforeRender } = (0, splashscreen_1.getSplashscreen)(manifestJson);
|
||||
const platformConfig = (0, manifest_1.getPlatformManifestJsonOnce)();
|
||||
const config = {
|
||||
pages: [],
|
||||
globalStyle: pagesJson.globalStyle,
|
||||
nvue: {
|
||||
compiler: (0, manifest_2.getNVueCompiler)(manifestJson),
|
||||
styleCompiler: (0, manifest_2.getNVueStyleCompiler)(manifestJson),
|
||||
'flex-direction': (0, manifest_2.getNVueFlexDirection)(manifestJson),
|
||||
},
|
||||
renderer: manifestJson['app-plus']?.renderer === 'native' ? 'native' : 'auto',
|
||||
appname: manifestJson.name || '',
|
||||
splashscreen: {
|
||||
alwaysShowBeforeRender,
|
||||
autoclose,
|
||||
},
|
||||
compilerVersion: process.env.UNI_COMPILER_VERSION,
|
||||
...parseEntryPagePath(pagesJson),
|
||||
networkTimeout: (0, manifest_1.normalizeNetworkTimeout)(manifestJson.networkTimeout),
|
||||
tabBar: pagesJson.tabBar,
|
||||
fallbackLocale: manifestJson.fallbackLocale,
|
||||
locales: (0, i18n_1.initLocales)(path_1.default.join(process.env.UNI_INPUT_DIR, 'locale')),
|
||||
darkmode: platformConfig.darkmode || false,
|
||||
themeConfig: (0, theme_1.normalizeThemeConfigOnce)(platformConfig),
|
||||
};
|
||||
// TODO 待支持分包
|
||||
return JSON.stringify(config);
|
||||
}
|
||||
exports.normalizeAppUniConfig = normalizeAppUniConfig;
|
||||
function parseEntryPagePath(pagesJson) {
|
||||
const res = {
|
||||
entryPagePath: '',
|
||||
entryPageQuery: '',
|
||||
realEntryPagePath: '',
|
||||
};
|
||||
if (!pagesJson.pages.length) {
|
||||
return res;
|
||||
}
|
||||
res.entryPagePath = pagesJson.pages[0].path;
|
||||
const argsJsonStr = (0, arguments_1.parseArguments)(pagesJson);
|
||||
if (argsJsonStr) {
|
||||
try {
|
||||
const args = JSON.parse(argsJsonStr);
|
||||
const entryPagePath = args.path || args.pathName;
|
||||
const realEntryPagePath = res.entryPagePath;
|
||||
if (entryPagePath && realEntryPagePath !== entryPagePath) {
|
||||
res.entryPagePath = entryPagePath;
|
||||
res.entryPageQuery = args.query ? '?' + args.query : '';
|
||||
// non tabBar page
|
||||
if (!(pagesJson.tabBar?.list || []).find((page) => page.pagePath === entryPagePath)) {
|
||||
res.realEntryPagePath = realEntryPagePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
return res;
|
||||
}
|
||||
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/pages/uniRoutes.d.ts
generated
vendored
Normal file
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/pages/uniRoutes.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function normalizeAppUniRoutes(pagesJson: UniApp.PagesJson): string;
|
||||
8
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/pages/uniRoutes.js
generated
vendored
Normal file
8
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/app/pages/uniRoutes.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.normalizeAppUniRoutes = void 0;
|
||||
const pages_1 = require("../../pages");
|
||||
function normalizeAppUniRoutes(pagesJson) {
|
||||
return JSON.stringify((0, pages_1.normalizePagesRoute)(pagesJson));
|
||||
}
|
||||
exports.normalizeAppUniRoutes = normalizeAppUniRoutes;
|
||||
7
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/index.d.ts
generated
vendored
Normal file
7
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export * from './mp';
|
||||
export * from './app';
|
||||
export * from './json';
|
||||
export * from './pages';
|
||||
export * from './manifest';
|
||||
export * from './theme';
|
||||
export { normalizeUniAppXAppPagesJson } from './uniAppX';
|
||||
25
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/index.js
generated
vendored
Normal file
25
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/index.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.normalizeUniAppXAppPagesJson = void 0;
|
||||
__exportStar(require("./mp"), exports);
|
||||
__exportStar(require("./app"), exports);
|
||||
__exportStar(require("./json"), exports);
|
||||
__exportStar(require("./pages"), exports);
|
||||
__exportStar(require("./manifest"), exports);
|
||||
__exportStar(require("./theme"), exports);
|
||||
var uniAppX_1 = require("./uniAppX");
|
||||
Object.defineProperty(exports, "normalizeUniAppXAppPagesJson", { enumerable: true, get: function () { return uniAppX_1.normalizeUniAppXAppPagesJson; } });
|
||||
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/json.d.ts
generated
vendored
Normal file
1
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/json.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function parseJson(jsonStr: string, shouldPre?: boolean): any;
|
||||
9
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/json.js
generated
vendored
Normal file
9
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/json.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseJson = void 0;
|
||||
const jsonc_parser_1 = require("jsonc-parser");
|
||||
const preprocess_1 = require("../preprocess");
|
||||
function parseJson(jsonStr, shouldPre = false) {
|
||||
return (0, jsonc_parser_1.parse)(shouldPre ? (0, preprocess_1.preJson)(jsonStr) : jsonStr);
|
||||
}
|
||||
exports.parseJson = parseJson;
|
||||
34
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/manifest.d.ts
generated
vendored
Normal file
34
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/manifest.d.ts
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
export declare const parseManifestJson: (inputDir: string) => any;
|
||||
export declare const parseManifestJsonOnce: (inputDir: string) => any;
|
||||
export declare const parseRpx2UnitOnce: (inputDir: string, platform?: UniApp.PLATFORM) => any;
|
||||
interface CompilerCompatConfig {
|
||||
MODE?: 2 | 3;
|
||||
}
|
||||
declare function parseCompatConfig(_inputDir: string): CompilerCompatConfig;
|
||||
export declare const parseCompatConfigOnce: typeof parseCompatConfig;
|
||||
declare const defaultNetworkTimeout: {
|
||||
request: number;
|
||||
connectSocket: number;
|
||||
uploadFile: number;
|
||||
downloadFile: number;
|
||||
};
|
||||
export declare function normalizeNetworkTimeout(networkTimeout?: Partial<typeof defaultNetworkTimeout>): {
|
||||
request: number;
|
||||
connectSocket: number;
|
||||
uploadFile: number;
|
||||
downloadFile: number;
|
||||
};
|
||||
export declare function getUniStatistics(inputDir: string, platform: UniApp.PLATFORM): any;
|
||||
export declare function isEnableUniPushV1(inputDir: string, platform: UniApp.PLATFORM): boolean;
|
||||
export declare function isEnableUniPushV2(inputDir: string, platform: UniApp.PLATFORM): boolean;
|
||||
export declare function isEnableSecureNetwork(inputDir: string, platform: UniApp.PLATFORM): boolean;
|
||||
export declare function hasPushModule(inputDir: string): boolean;
|
||||
export declare function isUniPushOffline(inputDir: string): boolean;
|
||||
export declare function getRouterOptions(manifestJson: Record<string, any>): {
|
||||
mode?: 'history' | 'hash';
|
||||
base?: string;
|
||||
};
|
||||
export declare function isEnableTreeShaking(manifestJson: Record<string, any>): boolean;
|
||||
export declare function getDevServerOptions(manifestJson: Record<string, any>): any;
|
||||
export declare function getPlatformManifestJsonOnce(): any;
|
||||
export {};
|
||||
113
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/manifest.js
generated
vendored
Normal file
113
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/manifest.js
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getPlatformManifestJsonOnce = exports.getDevServerOptions = exports.isEnableTreeShaking = exports.getRouterOptions = exports.isUniPushOffline = exports.hasPushModule = exports.isEnableSecureNetwork = exports.isEnableUniPushV2 = exports.isEnableUniPushV1 = exports.getUniStatistics = exports.normalizeNetworkTimeout = exports.parseCompatConfigOnce = exports.parseRpx2UnitOnce = exports.parseManifestJsonOnce = exports.parseManifestJson = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const shared_1 = require("@vue/shared");
|
||||
const uni_shared_1 = require("@dcloudio/uni-shared");
|
||||
const json_1 = require("./json");
|
||||
const parseManifestJson = (inputDir) => {
|
||||
return (0, json_1.parseJson)(fs_1.default.readFileSync(path_1.default.join(inputDir, 'manifest.json'), 'utf8'));
|
||||
};
|
||||
exports.parseManifestJson = parseManifestJson;
|
||||
exports.parseManifestJsonOnce = (0, uni_shared_1.once)(exports.parseManifestJson);
|
||||
exports.parseRpx2UnitOnce = (0, uni_shared_1.once)((inputDir, platform = 'h5') => {
|
||||
const rpx2unit = platform === 'h5' || platform === 'app'
|
||||
? uni_shared_1.defaultRpx2Unit
|
||||
: uni_shared_1.defaultMiniProgramRpx2Unit;
|
||||
const platformOptions = (0, exports.parseManifestJsonOnce)(inputDir)[platform];
|
||||
if (platformOptions && platformOptions.rpx) {
|
||||
return (0, shared_1.extend)({}, rpx2unit, platformOptions);
|
||||
}
|
||||
return (0, shared_1.extend)({}, rpx2unit);
|
||||
});
|
||||
function parseCompatConfig(_inputDir) {
|
||||
// 不支持 mode:2
|
||||
return { MODE: 3 }; //parseManifestJsonOnce(inputDir).compatConfig || {}
|
||||
}
|
||||
exports.parseCompatConfigOnce = (0, uni_shared_1.once)(parseCompatConfig);
|
||||
const defaultNetworkTimeout = {
|
||||
request: 60000,
|
||||
connectSocket: 60000,
|
||||
uploadFile: 60000,
|
||||
downloadFile: 60000,
|
||||
};
|
||||
function normalizeNetworkTimeout(networkTimeout) {
|
||||
return {
|
||||
...defaultNetworkTimeout,
|
||||
...networkTimeout,
|
||||
};
|
||||
}
|
||||
exports.normalizeNetworkTimeout = normalizeNetworkTimeout;
|
||||
function getUniStatistics(inputDir, platform) {
|
||||
const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
|
||||
if (platform === 'app') {
|
||||
platform = 'app-plus';
|
||||
}
|
||||
return (0, shared_1.extend)({}, manifest.uniStatistics, manifest[platform] && manifest[platform].uniStatistics);
|
||||
}
|
||||
exports.getUniStatistics = getUniStatistics;
|
||||
function isEnableUniPushV1(inputDir, platform) {
|
||||
if (isEnableUniPushV2(inputDir, platform)) {
|
||||
return false;
|
||||
}
|
||||
const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
|
||||
if (platform === 'app') {
|
||||
const push = manifest['app-plus']?.distribute?.sdkConfigs?.push;
|
||||
if (push && (0, shared_1.hasOwn)(push, 'unipush')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
exports.isEnableUniPushV1 = isEnableUniPushV1;
|
||||
function isEnableUniPushV2(inputDir, platform) {
|
||||
const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
|
||||
if (platform === 'app') {
|
||||
return (manifest['app-plus']?.distribute?.sdkConfigs?.push?.unipush?.version ==
|
||||
'2');
|
||||
}
|
||||
return manifest[platform]?.unipush?.enable === true;
|
||||
}
|
||||
exports.isEnableUniPushV2 = isEnableUniPushV2;
|
||||
function isEnableSecureNetwork(inputDir, platform) {
|
||||
const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
|
||||
if (platform === 'app') {
|
||||
return !!manifest['app-plus']?.modules?.SecureNetwork;
|
||||
}
|
||||
return manifest[platform]?.secureNetwork?.enable === true;
|
||||
}
|
||||
exports.isEnableSecureNetwork = isEnableSecureNetwork;
|
||||
function hasPushModule(inputDir) {
|
||||
const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
|
||||
return !!manifest['app-plus']?.modules?.Push;
|
||||
}
|
||||
exports.hasPushModule = hasPushModule;
|
||||
function isUniPushOffline(inputDir) {
|
||||
const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
|
||||
return (manifest['app-plus']?.distribute?.sdkConfigs?.push?.unipush?.offline ===
|
||||
true);
|
||||
}
|
||||
exports.isUniPushOffline = isUniPushOffline;
|
||||
function getRouterOptions(manifestJson) {
|
||||
return (0, shared_1.extend)({}, manifestJson.h5?.router);
|
||||
}
|
||||
exports.getRouterOptions = getRouterOptions;
|
||||
function isEnableTreeShaking(manifestJson) {
|
||||
return manifestJson.h5?.optimization?.treeShaking?.enable !== false;
|
||||
}
|
||||
exports.isEnableTreeShaking = isEnableTreeShaking;
|
||||
function getDevServerOptions(manifestJson) {
|
||||
return (0, shared_1.extend)({}, manifestJson.h5?.devServer);
|
||||
}
|
||||
exports.getDevServerOptions = getDevServerOptions;
|
||||
function getPlatformManifestJsonOnce() {
|
||||
const platform = process.env.UNI_PLATFORM === 'app' ? 'app-plus' : process.env.UNI_PLATFORM;
|
||||
return !process.env.UNI_INPUT_DIR
|
||||
? {}
|
||||
: (0, exports.parseManifestJsonOnce)(process.env.UNI_INPUT_DIR)[platform] || {};
|
||||
}
|
||||
exports.getPlatformManifestJsonOnce = getPlatformManifestJsonOnce;
|
||||
4
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/index.d.ts
generated
vendored
Normal file
4
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export * from './jsonFile';
|
||||
export { AppJson } from './types';
|
||||
export { mergeMiniProgramAppJson, parseMiniProgramPagesJson } from './pages';
|
||||
export { parseMiniProgramProjectJson } from './project';
|
||||
23
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/index.js
generated
vendored
Normal file
23
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/index.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseMiniProgramProjectJson = exports.parseMiniProgramPagesJson = exports.mergeMiniProgramAppJson = void 0;
|
||||
__exportStar(require("./jsonFile"), exports);
|
||||
var pages_1 = require("./pages");
|
||||
Object.defineProperty(exports, "mergeMiniProgramAppJson", { enumerable: true, get: function () { return pages_1.mergeMiniProgramAppJson; } });
|
||||
Object.defineProperty(exports, "parseMiniProgramPagesJson", { enumerable: true, get: function () { return pages_1.parseMiniProgramPagesJson; } });
|
||||
var project_1 = require("./project");
|
||||
Object.defineProperty(exports, "parseMiniProgramProjectJson", { enumerable: true, get: function () { return project_1.parseMiniProgramProjectJson; } });
|
||||
27
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/jsonFile.d.ts
generated
vendored
Normal file
27
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/jsonFile.d.ts
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import { ComponentJson, PageWindowOptions, UsingComponents } from './types';
|
||||
export declare function isMiniProgramPageFile(file: string, inputDir?: string): boolean;
|
||||
export declare function isMiniProgramPageSfcFile(file: string, inputDir?: string): boolean;
|
||||
export declare function hasJsonFile(filename: string): boolean;
|
||||
export declare function getComponentJsonFilenames(): string[];
|
||||
export declare function findJsonFile(filename: string): Record<string, any> | ComponentJson | PageWindowOptions | undefined;
|
||||
export declare function findUsingComponents(filename: string): UsingComponents | undefined;
|
||||
export declare function normalizeJsonFilename(filename: string): string;
|
||||
export declare function findChangedJsonFiles(supportGlobalUsingComponents?: boolean): Map<string, string>;
|
||||
export declare function addMiniProgramAppJson(appJson: Record<string, any>): void;
|
||||
export declare function addMiniProgramPageJson(filename: string, json: PageWindowOptions): void;
|
||||
export declare function addMiniProgramComponentJson(filename: string, json: ComponentJson): void;
|
||||
export declare function addMiniProgramUsingComponents(filename: string, json: UsingComponents): void;
|
||||
export declare function isMiniProgramUsingComponent(name: string, options: {
|
||||
filename: string;
|
||||
inputDir: string;
|
||||
componentsDir?: string;
|
||||
}): boolean;
|
||||
interface MiniProgramComponents {
|
||||
[name: string]: 'plugin' | 'component' | 'dynamicLib';
|
||||
}
|
||||
export declare function findMiniProgramUsingComponents({ filename, inputDir, componentsDir, }: {
|
||||
filename: string;
|
||||
inputDir: string;
|
||||
componentsDir?: string;
|
||||
}): MiniProgramComponents;
|
||||
export {};
|
||||
154
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/jsonFile.js
generated
vendored
Normal file
154
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/jsonFile.js
generated
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.findMiniProgramUsingComponents = exports.isMiniProgramUsingComponent = exports.addMiniProgramUsingComponents = exports.addMiniProgramComponentJson = exports.addMiniProgramPageJson = exports.addMiniProgramAppJson = exports.findChangedJsonFiles = exports.normalizeJsonFilename = exports.findUsingComponents = exports.findJsonFile = exports.getComponentJsonFilenames = exports.hasJsonFile = exports.isMiniProgramPageSfcFile = exports.isMiniProgramPageFile = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const shared_1 = require("@vue/shared");
|
||||
const utils_1 = require("../../utils");
|
||||
const resolve_1 = require("../../resolve");
|
||||
const utils_2 = require("../../vue/utils");
|
||||
let appJsonCache = {};
|
||||
const jsonFilesCache = new Map();
|
||||
const jsonPagesCache = new Map();
|
||||
const jsonComponentsCache = new Map();
|
||||
const jsonUsingComponentsCache = new Map();
|
||||
function isMiniProgramPageFile(file, inputDir) {
|
||||
if (inputDir && path_1.default.isAbsolute(file)) {
|
||||
file = (0, utils_1.normalizePath)(path_1.default.relative(inputDir, file));
|
||||
}
|
||||
return jsonPagesCache.has((0, utils_1.removeExt)(file));
|
||||
}
|
||||
exports.isMiniProgramPageFile = isMiniProgramPageFile;
|
||||
function isMiniProgramPageSfcFile(file, inputDir) {
|
||||
return (0, utils_2.isVueSfcFile)(file) && isMiniProgramPageFile(file, inputDir);
|
||||
}
|
||||
exports.isMiniProgramPageSfcFile = isMiniProgramPageSfcFile;
|
||||
function hasJsonFile(filename) {
|
||||
return (filename === 'app' ||
|
||||
jsonPagesCache.has(filename) ||
|
||||
jsonComponentsCache.has(filename));
|
||||
}
|
||||
exports.hasJsonFile = hasJsonFile;
|
||||
function getComponentJsonFilenames() {
|
||||
return [...jsonComponentsCache.keys()];
|
||||
}
|
||||
exports.getComponentJsonFilenames = getComponentJsonFilenames;
|
||||
function findJsonFile(filename) {
|
||||
if (filename === 'app') {
|
||||
return appJsonCache;
|
||||
}
|
||||
return jsonPagesCache.get(filename) || jsonComponentsCache.get(filename);
|
||||
}
|
||||
exports.findJsonFile = findJsonFile;
|
||||
function findUsingComponents(filename) {
|
||||
return jsonUsingComponentsCache.get(filename);
|
||||
}
|
||||
exports.findUsingComponents = findUsingComponents;
|
||||
function normalizeJsonFilename(filename) {
|
||||
return (0, utils_1.normalizeNodeModules)(filename);
|
||||
}
|
||||
exports.normalizeJsonFilename = normalizeJsonFilename;
|
||||
function findChangedJsonFiles(supportGlobalUsingComponents = true) {
|
||||
const changedJsonFiles = new Map();
|
||||
function findChangedFile(filename, json) {
|
||||
const newJson = JSON.parse(JSON.stringify(json));
|
||||
if (!newJson.usingComponents) {
|
||||
newJson.usingComponents = {};
|
||||
}
|
||||
(0, shared_1.extend)(newJson.usingComponents, jsonUsingComponentsCache.get(filename));
|
||||
// 格式化为相对路径,这样作为分包也可以直接运行
|
||||
// app.json mp-baidu 在 win 不支持相对路径。所有平台改用绝对路径
|
||||
if (filename !== 'app') {
|
||||
let usingComponents = newJson.usingComponents;
|
||||
// 如果小程序不支持 global 的 usingComponents
|
||||
if (!supportGlobalUsingComponents) {
|
||||
// 从取全局的 usingComponents 并补充到子组件 usingComponents 中
|
||||
const globalUsingComponents = appJsonCache?.usingComponents || {};
|
||||
const globalComponents = findUsingComponents('app') || {};
|
||||
usingComponents = {
|
||||
...globalUsingComponents,
|
||||
...globalComponents,
|
||||
...newJson.usingComponents,
|
||||
};
|
||||
}
|
||||
Object.keys(usingComponents).forEach((name) => {
|
||||
const componentFilename = usingComponents[name];
|
||||
if (componentFilename.startsWith('/')) {
|
||||
usingComponents[name] = (0, resolve_1.relativeFile)(filename, componentFilename.slice(1));
|
||||
}
|
||||
});
|
||||
newJson.usingComponents = usingComponents;
|
||||
}
|
||||
const jsonStr = JSON.stringify(newJson, null, 2);
|
||||
if (jsonFilesCache.get(filename) !== jsonStr) {
|
||||
changedJsonFiles.set(filename, jsonStr);
|
||||
jsonFilesCache.set(filename, jsonStr);
|
||||
}
|
||||
}
|
||||
function findChangedFiles(jsonsCache) {
|
||||
for (const name of jsonsCache.keys()) {
|
||||
findChangedFile(name, jsonsCache.get(name));
|
||||
}
|
||||
}
|
||||
findChangedFile('app', appJsonCache);
|
||||
findChangedFiles(jsonPagesCache);
|
||||
findChangedFiles(jsonComponentsCache);
|
||||
return changedJsonFiles;
|
||||
}
|
||||
exports.findChangedJsonFiles = findChangedJsonFiles;
|
||||
function addMiniProgramAppJson(appJson) {
|
||||
appJsonCache = appJson;
|
||||
}
|
||||
exports.addMiniProgramAppJson = addMiniProgramAppJson;
|
||||
function addMiniProgramPageJson(filename, json) {
|
||||
jsonPagesCache.set(filename, json);
|
||||
}
|
||||
exports.addMiniProgramPageJson = addMiniProgramPageJson;
|
||||
function addMiniProgramComponentJson(filename, json) {
|
||||
jsonComponentsCache.set(filename, json);
|
||||
}
|
||||
exports.addMiniProgramComponentJson = addMiniProgramComponentJson;
|
||||
function addMiniProgramUsingComponents(filename, json) {
|
||||
jsonUsingComponentsCache.set(filename, json);
|
||||
}
|
||||
exports.addMiniProgramUsingComponents = addMiniProgramUsingComponents;
|
||||
function isMiniProgramUsingComponent(name, options) {
|
||||
return !!findMiniProgramUsingComponents(options)[name];
|
||||
}
|
||||
exports.isMiniProgramUsingComponent = isMiniProgramUsingComponent;
|
||||
function findMiniProgramUsingComponents({ filename, inputDir, componentsDir, }) {
|
||||
const globalUsingComponents = appJsonCache && appJsonCache.usingComponents;
|
||||
const miniProgramComponents = {};
|
||||
if (globalUsingComponents) {
|
||||
(0, shared_1.extend)(miniProgramComponents, findMiniProgramUsingComponent(globalUsingComponents, componentsDir));
|
||||
}
|
||||
const jsonFile = findJsonFile((0, utils_1.removeExt)((0, utils_1.normalizeMiniProgramFilename)(filename, inputDir)));
|
||||
if (jsonFile) {
|
||||
if (jsonFile.usingComponents) {
|
||||
(0, shared_1.extend)(miniProgramComponents, findMiniProgramUsingComponent(jsonFile.usingComponents, componentsDir));
|
||||
}
|
||||
// mp-baidu 特有
|
||||
if (jsonFile.usingSwanComponents) {
|
||||
(0, shared_1.extend)(miniProgramComponents, findMiniProgramUsingComponent(jsonFile.usingSwanComponents, componentsDir));
|
||||
}
|
||||
}
|
||||
return miniProgramComponents;
|
||||
}
|
||||
exports.findMiniProgramUsingComponents = findMiniProgramUsingComponents;
|
||||
function findMiniProgramUsingComponent(usingComponents, componentsDir) {
|
||||
return Object.keys(usingComponents).reduce((res, name) => {
|
||||
const path = usingComponents[name];
|
||||
if (path.includes('plugin://')) {
|
||||
res[name] = 'plugin';
|
||||
}
|
||||
else if (path.includes('dynamicLib://')) {
|
||||
res[name] = 'dynamicLib';
|
||||
}
|
||||
else if (componentsDir && path.includes(componentsDir + '/')) {
|
||||
res[name] = 'component';
|
||||
}
|
||||
return res;
|
||||
}, {});
|
||||
}
|
||||
17
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/pages.d.ts
generated
vendored
Normal file
17
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/pages.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { AppJson, NetworkTimeout, PageWindowOptions } from './types';
|
||||
interface ParsePagesJsonOptions {
|
||||
debug?: boolean;
|
||||
darkmode?: boolean;
|
||||
subpackages: boolean;
|
||||
windowOptionsMap?: Record<string, string>;
|
||||
tabBarOptionsMap?: Record<string, string>;
|
||||
tabBarItemOptionsMap?: Record<string, string>;
|
||||
networkTimeout?: NetworkTimeout;
|
||||
}
|
||||
export declare function parseMiniProgramPagesJson(jsonStr: string, platform: UniApp.PLATFORM, options?: ParsePagesJsonOptions): {
|
||||
appJson: AppJson;
|
||||
pageJsons: Record<string, PageWindowOptions>;
|
||||
nvuePages: string[];
|
||||
};
|
||||
export declare function mergeMiniProgramAppJson(appJson: Record<string, any>, platformJson?: Record<string, any>): void;
|
||||
export {};
|
||||
147
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/pages.js
generated
vendored
Normal file
147
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/pages.js
generated
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.mergeMiniProgramAppJson = exports.parseMiniProgramPagesJson = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const shared_1 = require("@vue/shared");
|
||||
const json_1 = require("../json");
|
||||
const pages_1 = require("../pages");
|
||||
const utils_1 = require("./utils");
|
||||
const utils_2 = require("../../utils");
|
||||
const project_1 = require("./project");
|
||||
const manifest_1 = require("../manifest");
|
||||
const theme_1 = require("../theme");
|
||||
function parseMiniProgramPagesJson(jsonStr, platform, options = { subpackages: false }) {
|
||||
return parsePagesJson(jsonStr, platform, options);
|
||||
}
|
||||
exports.parseMiniProgramPagesJson = parseMiniProgramPagesJson;
|
||||
const NON_APP_JSON_KEYS = [
|
||||
'unipush',
|
||||
'secureNetwork',
|
||||
'usingComponents',
|
||||
'optimization',
|
||||
'scopedSlotsCompiler',
|
||||
'usingComponents',
|
||||
'uniStatistics',
|
||||
'mergeVirtualHostAttributes',
|
||||
];
|
||||
function mergeMiniProgramAppJson(appJson, platformJson = {}) {
|
||||
Object.keys(platformJson).forEach((name) => {
|
||||
if (!(0, project_1.isMiniProgramProjectJsonKey)(name) &&
|
||||
!NON_APP_JSON_KEYS.includes(name)) {
|
||||
appJson[name] = platformJson[name];
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.mergeMiniProgramAppJson = mergeMiniProgramAppJson;
|
||||
function parsePagesJson(jsonStr, platform, { debug, darkmode, networkTimeout, subpackages, windowOptionsMap, tabBarOptionsMap, tabBarItemOptionsMap, } = {
|
||||
subpackages: false,
|
||||
}) {
|
||||
let appJson = {
|
||||
pages: [],
|
||||
};
|
||||
let pageJsons = {};
|
||||
let nvuePages = [];
|
||||
// preprocess
|
||||
const pagesJson = (0, json_1.parseJson)(jsonStr, true);
|
||||
if (!pagesJson) {
|
||||
throw new Error(`[vite] Error: pages.json parse failed.\n`);
|
||||
}
|
||||
function addPageJson(pagePath, style) {
|
||||
const filename = path_1.default.join(process.env.UNI_INPUT_DIR, pagePath);
|
||||
if (fs_1.default.existsSync(filename + '.nvue') &&
|
||||
!fs_1.default.existsSync(filename + '.vue')) {
|
||||
nvuePages.push(pagePath);
|
||||
}
|
||||
const windowOptions = {};
|
||||
if (platform === 'mp-baidu') {
|
||||
// 仅百度小程序需要页面配置 component:true
|
||||
// 快手小程序反而不能配置 component:true,故不能统一添加,目前硬编码处理
|
||||
windowOptions.component = true;
|
||||
}
|
||||
pageJsons[pagePath] = (0, shared_1.extend)(windowOptions, (0, utils_1.parseWindowOptions)(style, platform, windowOptionsMap));
|
||||
}
|
||||
// pages
|
||||
(0, pages_1.validatePages)(pagesJson, jsonStr);
|
||||
pagesJson.pages.forEach((page) => {
|
||||
appJson.pages.push(page.path);
|
||||
addPageJson(page.path, page.style);
|
||||
});
|
||||
// subpackages
|
||||
pagesJson.subPackages = pagesJson.subPackages || pagesJson.subpackages;
|
||||
if (pagesJson.subPackages) {
|
||||
if (subpackages) {
|
||||
appJson.subPackages = pagesJson.subPackages.map(({ root, pages, ...rest }) => {
|
||||
return (0, shared_1.extend)({
|
||||
root,
|
||||
pages: pages.map((page) => {
|
||||
addPageJson((0, utils_2.normalizePath)(path_1.default.join(root, page.path)), page.style);
|
||||
return page.path;
|
||||
}),
|
||||
}, rest);
|
||||
});
|
||||
}
|
||||
else {
|
||||
pagesJson.subPackages.forEach(({ root, pages }) => {
|
||||
pages.forEach((page) => {
|
||||
const pagePath = (0, utils_2.normalizePath)(path_1.default.join(root, page.path));
|
||||
appJson.pages.push(pagePath);
|
||||
addPageJson(pagePath, page.style);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
// window
|
||||
if (pagesJson.globalStyle) {
|
||||
const windowOptions = (0, utils_1.parseWindowOptions)(pagesJson.globalStyle, platform, windowOptionsMap);
|
||||
const { usingComponents } = windowOptions;
|
||||
if (usingComponents) {
|
||||
delete windowOptions.usingComponents;
|
||||
appJson.usingComponents = usingComponents;
|
||||
}
|
||||
else {
|
||||
delete appJson.usingComponents;
|
||||
}
|
||||
appJson.window = windowOptions;
|
||||
}
|
||||
// tabBar
|
||||
if (pagesJson.tabBar) {
|
||||
const tabBar = (0, utils_1.parseTabBar)(pagesJson.tabBar, platform, tabBarOptionsMap, tabBarItemOptionsMap);
|
||||
if (tabBar) {
|
||||
appJson.tabBar = tabBar;
|
||||
}
|
||||
}
|
||||
;
|
||||
['preloadRule', 'workers', 'plugins', 'entryPagePath'].forEach((name) => {
|
||||
if ((0, shared_1.hasOwn)(pagesJson, name)) {
|
||||
appJson[name] = pagesJson[name];
|
||||
}
|
||||
});
|
||||
if (debug) {
|
||||
appJson.debug = debug;
|
||||
}
|
||||
if (networkTimeout) {
|
||||
appJson.networkTimeout = networkTimeout;
|
||||
}
|
||||
const manifestJson = (0, manifest_1.getPlatformManifestJsonOnce)();
|
||||
if (!darkmode) {
|
||||
const { pages, window, tabBar } = (0, theme_1.initTheme)(manifestJson, appJson);
|
||||
(0, shared_1.extend)(appJson, JSON.parse(JSON.stringify({ pages, window, tabBar })));
|
||||
delete appJson.darkmode;
|
||||
delete appJson.themeLocation;
|
||||
pageJsons = (0, theme_1.initTheme)(manifestJson, pageJsons);
|
||||
}
|
||||
else {
|
||||
const themeLocation = manifestJson.themeLocation || 'theme.json';
|
||||
if ((0, theme_1.hasThemeJson)(path_1.default.join(process.env.UNI_INPUT_DIR, themeLocation)))
|
||||
appJson.themeLocation = themeLocation;
|
||||
}
|
||||
return {
|
||||
appJson,
|
||||
pageJsons,
|
||||
nvuePages,
|
||||
};
|
||||
}
|
||||
14
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/project.d.ts
generated
vendored
Normal file
14
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/project.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
interface ParseMiniProgramProjectJsonOptions {
|
||||
template: Record<string, any>;
|
||||
pagesJson: UniApp.PagesJson;
|
||||
}
|
||||
interface ProjectConfig {
|
||||
appid: string;
|
||||
projectname: string;
|
||||
condition?: {
|
||||
miniprogram?: UniApp.PagesJson['condition'];
|
||||
};
|
||||
}
|
||||
export declare function isMiniProgramProjectJsonKey(name: string): boolean;
|
||||
export declare function parseMiniProgramProjectJson(jsonStr: string, platform: UniApp.PLATFORM, { template, pagesJson }: ParseMiniProgramProjectJsonOptions): ProjectConfig;
|
||||
export {};
|
||||
105
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/project.js
generated
vendored
Normal file
105
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/project.js
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseMiniProgramProjectJson = exports.isMiniProgramProjectJsonKey = void 0;
|
||||
const shared_1 = require("@vue/shared");
|
||||
const merge_1 = require("merge");
|
||||
const json_1 = require("../json");
|
||||
const projectKeys = [
|
||||
'appid',
|
||||
'setting',
|
||||
'miniprogramRoot',
|
||||
'cloudfunctionRoot',
|
||||
'qcloudRoot',
|
||||
'pluginRoot',
|
||||
'compileType',
|
||||
'libVersion',
|
||||
'projectname',
|
||||
'packOptions',
|
||||
'debugOptions',
|
||||
'scripts',
|
||||
'cloudbaseRoot',
|
||||
];
|
||||
function isMiniProgramProjectJsonKey(name) {
|
||||
return projectKeys.includes(name);
|
||||
}
|
||||
exports.isMiniProgramProjectJsonKey = isMiniProgramProjectJsonKey;
|
||||
function parseMiniProgramProjectJson(jsonStr, platform, { template, pagesJson }) {
|
||||
const projectJson = JSON.parse(JSON.stringify(template));
|
||||
const manifestJson = (0, json_1.parseJson)(jsonStr);
|
||||
if (manifestJson) {
|
||||
projectJson.projectname = manifestJson.name;
|
||||
const platformConfig = manifestJson[platform];
|
||||
if (platformConfig) {
|
||||
projectKeys.forEach((name) => {
|
||||
if ((0, shared_1.hasOwn)(platformConfig, name)) {
|
||||
if ((0, shared_1.isPlainObject)(platformConfig[name]) &&
|
||||
(0, shared_1.isPlainObject)(projectJson[name])) {
|
||||
;
|
||||
projectJson[name] = (0, merge_1.recursive)(true, projectJson[name], platformConfig[name]);
|
||||
}
|
||||
else {
|
||||
;
|
||||
projectJson[name] = platformConfig[name];
|
||||
}
|
||||
}
|
||||
});
|
||||
// 使用了微信小程序手势系统,自动开启 ES6=>ES5
|
||||
platform === 'mp-weixin' &&
|
||||
weixinSkyline(platformConfig) &&
|
||||
openES62ES5(projectJson);
|
||||
}
|
||||
}
|
||||
// 其实仅开发期间 condition 生效即可,暂不做判断
|
||||
const miniprogram = parseMiniProgramCondition(pagesJson);
|
||||
if (miniprogram) {
|
||||
if (!projectJson.condition) {
|
||||
projectJson.condition = {};
|
||||
}
|
||||
projectJson.condition.miniprogram = miniprogram;
|
||||
}
|
||||
if (!projectJson.appid) {
|
||||
projectJson.appid = 'touristappid';
|
||||
}
|
||||
return projectJson;
|
||||
}
|
||||
exports.parseMiniProgramProjectJson = parseMiniProgramProjectJson;
|
||||
function weixinSkyline(config) {
|
||||
return (config.renderer === 'skyline' &&
|
||||
config.lazyCodeLoading === 'requiredComponents');
|
||||
}
|
||||
function openES62ES5(config) {
|
||||
if (!config.setting) {
|
||||
config.setting = {};
|
||||
}
|
||||
if (!config.setting.es6) {
|
||||
config.setting.es6 = true;
|
||||
}
|
||||
}
|
||||
function parseMiniProgramCondition(pagesJson) {
|
||||
const launchPagePath = process.env.UNI_CLI_LAUNCH_PAGE_PATH || '';
|
||||
if (launchPagePath) {
|
||||
return {
|
||||
current: 0,
|
||||
list: [
|
||||
{
|
||||
id: 0,
|
||||
name: launchPagePath,
|
||||
pathName: launchPagePath,
|
||||
query: process.env.UNI_CLI_LAUNCH_PAGE_QUERY || '', // 启动参数,在页面的onLoad函数里面得到。
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
const condition = pagesJson.condition;
|
||||
if (!condition || !(0, shared_1.isArray)(condition.list) || !condition.list.length) {
|
||||
return;
|
||||
}
|
||||
condition.list.forEach(function (item, index) {
|
||||
item.id = item.id || index;
|
||||
if (item.path) {
|
||||
item.pathName = item.path;
|
||||
delete item.path;
|
||||
}
|
||||
});
|
||||
return condition;
|
||||
}
|
||||
122
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/types.d.ts
generated
vendored
Normal file
122
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
export interface ComponentJson {
|
||||
component: true;
|
||||
usingComponents?: UsingComponents;
|
||||
usingSwanComponents?: UsingComponents;
|
||||
styleIsolation?: 'apply-shared' | 'shared';
|
||||
}
|
||||
interface ShareWindowOptions {
|
||||
navigationBarBackgroundColor?: string;
|
||||
navigationBarTextStyle?: 'white' | 'black';
|
||||
navigationBarTitleText?: string;
|
||||
navigationStyle?: 'default' | 'custom';
|
||||
backgroundColor?: string;
|
||||
backgroundTextStyle?: 'dark' | 'light';
|
||||
backgroundColorTop?: string;
|
||||
backgroundColorBottom?: string;
|
||||
enablePullDownRefresh?: boolean;
|
||||
onReachBottomDistance?: number;
|
||||
pageOrientation?: 'portrait' | 'landscape' | 'auto';
|
||||
}
|
||||
type Style = 'v2' | string;
|
||||
type RestartStrategy = 'homePage' | 'homePageAndLatestPage' | string;
|
||||
export interface PageWindowOptions extends ShareWindowOptions {
|
||||
component?: true;
|
||||
disableScroll?: boolean;
|
||||
usingComponents?: UsingComponents;
|
||||
usingSwanComponents?: UsingComponents;
|
||||
initialRenderingCache?: 'static' | string;
|
||||
style?: Style;
|
||||
singlePage?: SinglePage;
|
||||
restartStrategy?: RestartStrategy;
|
||||
}
|
||||
export interface AppWindowOptions extends ShareWindowOptions {
|
||||
visualEffectInBackground?: 'none' | 'hidden';
|
||||
}
|
||||
interface SubPackage {
|
||||
name?: string;
|
||||
root: string;
|
||||
pages: string[];
|
||||
independent?: boolean;
|
||||
}
|
||||
interface TabBarItem {
|
||||
pagePath: string;
|
||||
text: string;
|
||||
iconPath?: string;
|
||||
selectedIconPath?: string;
|
||||
}
|
||||
export interface TabBar {
|
||||
color: string;
|
||||
selectedColor: string;
|
||||
backgroundColor: string;
|
||||
borderStyle?: 'black' | 'white';
|
||||
list: TabBarItem[];
|
||||
position?: 'bottom' | 'top';
|
||||
custom?: boolean;
|
||||
}
|
||||
export interface NetworkTimeout {
|
||||
request?: number;
|
||||
requeconnectSocketst?: number;
|
||||
uploadFile?: number;
|
||||
downloadFile?: number;
|
||||
}
|
||||
interface Plugins {
|
||||
[name: string]: {
|
||||
version: string;
|
||||
provider: string;
|
||||
};
|
||||
}
|
||||
interface PreloadRule {
|
||||
[name: string]: {
|
||||
network: 'wifi' | 'all';
|
||||
packages: string[];
|
||||
};
|
||||
}
|
||||
export interface UsingComponents {
|
||||
[name: string]: string;
|
||||
}
|
||||
interface Permission {
|
||||
[name: string]: {
|
||||
desc: string;
|
||||
};
|
||||
}
|
||||
interface UseExtendedLib {
|
||||
kbone: boolean;
|
||||
weui: boolean;
|
||||
}
|
||||
interface EntranceDeclare {
|
||||
locationMessage: {
|
||||
path: string;
|
||||
query: string;
|
||||
};
|
||||
}
|
||||
interface SinglePage {
|
||||
navigationBarFit?: 'squeezed' | 'float';
|
||||
}
|
||||
export interface AppJson {
|
||||
entryPagePath?: string;
|
||||
pages: string[];
|
||||
window?: AppWindowOptions;
|
||||
tabBar?: TabBar;
|
||||
networkTimeout?: NetworkTimeout;
|
||||
debug?: boolean;
|
||||
functionalPages?: boolean;
|
||||
subPackages?: SubPackage[];
|
||||
workers?: string;
|
||||
requiredBackgroundModes?: string[];
|
||||
plugins?: Plugins;
|
||||
preloadRule?: PreloadRule;
|
||||
resizable?: boolean;
|
||||
usingComponents?: UsingComponents;
|
||||
permission?: Permission;
|
||||
sitemapLocation?: string;
|
||||
style?: Style;
|
||||
useExtendedLib?: UseExtendedLib;
|
||||
entranceDeclare?: EntranceDeclare;
|
||||
darkmode?: boolean;
|
||||
themeLocation?: string;
|
||||
lazyCodeLoading?: 'requiredComponents' | string;
|
||||
singlePage?: SinglePage;
|
||||
restartStrategy?: RestartStrategy;
|
||||
[name: string]: unknown;
|
||||
}
|
||||
export {};
|
||||
2
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/types.js
generated
vendored
Normal file
2
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/types.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
3
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/utils.d.ts
generated
vendored
Normal file
3
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { AppWindowOptions, PageWindowOptions, TabBar } from './types';
|
||||
export declare function parseWindowOptions(style: UniApp.PagesJsonPageStyle, platform: UniApp.PLATFORM, windowOptionsMap?: Record<string, string>): PageWindowOptions | AppWindowOptions;
|
||||
export declare function parseTabBar(tabBar: UniApp.TabBarOptions, platform: UniApp.PLATFORM, tabBarOptionsMap?: Record<string, string>, tabBarItemOptionsMap?: Record<string, string>): TabBar;
|
||||
66
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/utils.js
generated
vendored
Normal file
66
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/mp/utils.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseTabBar = exports.parseWindowOptions = void 0;
|
||||
const shared_1 = require("@vue/shared");
|
||||
const pages_1 = require("../pages");
|
||||
function trimJson(json) {
|
||||
delete json.maxWidth;
|
||||
delete json.topWindow;
|
||||
delete json.leftWindow;
|
||||
delete json.rightWindow;
|
||||
if (json.tabBar) {
|
||||
delete json.tabBar.matchMedia;
|
||||
}
|
||||
return json;
|
||||
}
|
||||
function convert(to, from, map) {
|
||||
Object.keys(map).forEach((key) => {
|
||||
if ((0, shared_1.hasOwn)(from, map[key])) {
|
||||
to[key] = from[map[key]];
|
||||
}
|
||||
});
|
||||
return to;
|
||||
}
|
||||
function parseWindowOptions(style, platform, windowOptionsMap) {
|
||||
if (!style) {
|
||||
return {};
|
||||
}
|
||||
const platformStyle = style[platform] || {};
|
||||
(0, pages_1.removePlatformStyle)(trimJson(style));
|
||||
const res = {};
|
||||
if (windowOptionsMap) {
|
||||
return (0, shared_1.extend)(convert(res, style, windowOptionsMap), platformStyle);
|
||||
}
|
||||
return (0, shared_1.extend)(res, style, platformStyle);
|
||||
}
|
||||
exports.parseWindowOptions = parseWindowOptions;
|
||||
function trimTabBarJson(tabBar) {
|
||||
;
|
||||
[
|
||||
'fontSize',
|
||||
'height',
|
||||
'iconWidth',
|
||||
'midButton',
|
||||
'selectedIndex',
|
||||
'spacing',
|
||||
].forEach((name) => {
|
||||
delete tabBar[name];
|
||||
});
|
||||
return tabBar;
|
||||
}
|
||||
function parseTabBar(tabBar, platform, tabBarOptionsMap, tabBarItemOptionsMap) {
|
||||
const platformStyle = tabBar[platform] || {};
|
||||
(0, pages_1.removePlatformStyle)(trimTabBarJson(tabBar));
|
||||
const res = {};
|
||||
if (tabBarOptionsMap) {
|
||||
if (tabBarItemOptionsMap && tabBar.list) {
|
||||
tabBar.list = tabBar.list.map((item) => {
|
||||
return convert({}, item, tabBarItemOptionsMap);
|
||||
});
|
||||
}
|
||||
convert(res, tabBar, tabBarOptionsMap);
|
||||
return (0, shared_1.extend)(res, platformStyle);
|
||||
}
|
||||
return (0, shared_1.extend)(res, tabBar, platformStyle);
|
||||
}
|
||||
exports.parseTabBar = parseTabBar;
|
||||
31
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/pages.d.ts
generated
vendored
Normal file
31
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/pages.d.ts
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
export declare function isUniPageFile(file: string, inputDir?: string): boolean;
|
||||
export declare function isUniPageSetupAndTs(file: string): boolean;
|
||||
export declare function isUniPageSfcFile(file: string, inputDir?: string): boolean;
|
||||
/**
|
||||
* 小程序平台慎用,因为该解析不支持 subpackages
|
||||
* @param inputDir
|
||||
* @param platform
|
||||
* @param normalize
|
||||
* @returns
|
||||
*/
|
||||
export declare const parsePagesJson: (inputDir: string, platform: UniApp.PLATFORM, normalize?: boolean) => UniApp.PagesJson;
|
||||
/**
|
||||
* 该方法解析出来的是不支持 subpackages,会被合并入 pages
|
||||
*/
|
||||
export declare const parsePagesJsonOnce: (inputDir: string, platform: UniApp.PLATFORM, normalize?: boolean) => UniApp.PagesJson;
|
||||
/**
|
||||
* 目前 App 和 H5 使用了该方法
|
||||
* @param jsonStr
|
||||
* @param platform
|
||||
* @param param2
|
||||
* @returns
|
||||
*/
|
||||
export declare function normalizePagesJson(jsonStr: string, platform: UniApp.PLATFORM, { subpackages, }?: {
|
||||
subpackages: boolean;
|
||||
}): UniApp.PagesJson;
|
||||
export declare function validatePages(pagesJson: Record<string, any>, jsonStr: string): void;
|
||||
export declare function removePlatformStyle(pageStyle: Record<string, any>): Record<string, any>;
|
||||
export declare function normalizePagesRoute(pagesJson: UniApp.PagesJson): UniApp.UniRoute[];
|
||||
declare function parseSubpackagesRoot(inputDir: string, platform: UniApp.PLATFORM): string[];
|
||||
export declare const parseSubpackagesRootOnce: typeof parseSubpackagesRoot;
|
||||
export {};
|
||||
438
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/pages.js
generated
vendored
Normal file
438
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/pages.js
generated
vendored
Normal file
@@ -0,0 +1,438 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseSubpackagesRootOnce = exports.normalizePagesRoute = exports.removePlatformStyle = exports.validatePages = exports.normalizePagesJson = exports.parsePagesJsonOnce = exports.parsePagesJson = exports.isUniPageSfcFile = exports.isUniPageSetupAndTs = exports.isUniPageFile = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const shared_1 = require("@vue/shared");
|
||||
const uni_shared_1 = require("@dcloudio/uni-shared");
|
||||
const utils_1 = require("../utils");
|
||||
const json_1 = require("./json");
|
||||
const utils_2 = require("../vue/utils");
|
||||
const vite_1 = require("../vite");
|
||||
const constants_1 = require("../constants");
|
||||
const theme_1 = require("./theme");
|
||||
const manifest_1 = require("./manifest");
|
||||
const pagesCacheSet = new Set();
|
||||
function isUniPageFile(file, inputDir = process.env.UNI_INPUT_DIR) {
|
||||
if (inputDir && path_1.default.isAbsolute(file)) {
|
||||
file = (0, utils_1.normalizePath)(path_1.default.relative(inputDir, file));
|
||||
}
|
||||
return pagesCacheSet.has((0, utils_1.removeExt)(file));
|
||||
}
|
||||
exports.isUniPageFile = isUniPageFile;
|
||||
function isUniPageSetupAndTs(file) {
|
||||
const { filename, query } = (0, vite_1.parseVueRequest)(file);
|
||||
return !!(query.vue &&
|
||||
query.setup &&
|
||||
(0, shared_1.hasOwn)(query, 'lang.ts') &&
|
||||
constants_1.EXTNAME_VUE_RE.test(filename));
|
||||
}
|
||||
exports.isUniPageSetupAndTs = isUniPageSetupAndTs;
|
||||
function isUniPageSfcFile(file, inputDir = process.env.UNI_INPUT_DIR) {
|
||||
return (0, utils_2.isVueSfcFile)(file) && isUniPageFile(file, inputDir);
|
||||
}
|
||||
exports.isUniPageSfcFile = isUniPageSfcFile;
|
||||
/**
|
||||
* 小程序平台慎用,因为该解析不支持 subpackages
|
||||
* @param inputDir
|
||||
* @param platform
|
||||
* @param normalize
|
||||
* @returns
|
||||
*/
|
||||
const parsePagesJson = (inputDir, platform, normalize = true) => {
|
||||
const jsonStr = fs_1.default.readFileSync(path_1.default.join(inputDir, 'pages.json'), 'utf8');
|
||||
if (normalize) {
|
||||
return normalizePagesJson(jsonStr, platform);
|
||||
}
|
||||
return (0, json_1.parseJson)(jsonStr, true);
|
||||
};
|
||||
exports.parsePagesJson = parsePagesJson;
|
||||
/**
|
||||
* 该方法解析出来的是不支持 subpackages,会被合并入 pages
|
||||
*/
|
||||
exports.parsePagesJsonOnce = (0, uni_shared_1.once)(exports.parsePagesJson);
|
||||
/**
|
||||
* 目前 App 和 H5 使用了该方法
|
||||
* @param jsonStr
|
||||
* @param platform
|
||||
* @param param2
|
||||
* @returns
|
||||
*/
|
||||
function normalizePagesJson(jsonStr, platform, { subpackages, } = { subpackages: false }) {
|
||||
let pagesJson = {
|
||||
pages: [],
|
||||
globalStyle: {
|
||||
navigationBar: {},
|
||||
},
|
||||
};
|
||||
// preprocess
|
||||
try {
|
||||
pagesJson = (0, json_1.parseJson)(jsonStr, true);
|
||||
}
|
||||
catch (e) {
|
||||
console.error(`[vite] Error: pages.json parse failed.\n`, jsonStr, e);
|
||||
}
|
||||
// pages
|
||||
validatePages(pagesJson, jsonStr);
|
||||
pagesJson.subPackages = pagesJson.subPackages || pagesJson.subpackages;
|
||||
delete pagesJson.subpackages;
|
||||
// subpackages
|
||||
if (pagesJson.subPackages) {
|
||||
if (subpackages) {
|
||||
pagesJson.subPackages.forEach(({ pages }) => {
|
||||
pages && normalizePages(pages, platform);
|
||||
});
|
||||
}
|
||||
else {
|
||||
pagesJson.pages.push(...normalizeSubpackages(pagesJson.subPackages));
|
||||
delete pagesJson.subPackages;
|
||||
}
|
||||
}
|
||||
else {
|
||||
delete pagesJson.subPackages;
|
||||
}
|
||||
// pageStyle
|
||||
normalizePages(pagesJson.pages, platform);
|
||||
// globalStyle
|
||||
pagesJson.globalStyle = normalizePageStyle(null, pagesJson.globalStyle, platform);
|
||||
// tabBar
|
||||
if (pagesJson.tabBar) {
|
||||
const tabBar = normalizeTabBar(pagesJson.tabBar, platform);
|
||||
if (tabBar) {
|
||||
pagesJson.tabBar = tabBar;
|
||||
}
|
||||
else {
|
||||
delete pagesJson.tabBar;
|
||||
}
|
||||
}
|
||||
// 缓存页面列表
|
||||
pagesCacheSet.clear();
|
||||
pagesJson.pages.forEach((page) => pagesCacheSet.add(page.path));
|
||||
const manifestJsonPlatform = (0, manifest_1.getPlatformManifestJsonOnce)();
|
||||
if (!manifestJsonPlatform.darkmode) {
|
||||
const { pages, globalStyle, tabBar } = (0, theme_1.initTheme)(manifestJsonPlatform, pagesJson);
|
||||
(0, shared_1.extend)(pagesJson, { pages, globalStyle, tabBar });
|
||||
}
|
||||
return pagesJson;
|
||||
}
|
||||
exports.normalizePagesJson = normalizePagesJson;
|
||||
function validatePages(pagesJson, jsonStr) {
|
||||
if (!(0, shared_1.isArray)(pagesJson.pages)) {
|
||||
pagesJson.pages = [];
|
||||
throw new Error(`[uni-app] Error: pages.json->pages parse failed.`);
|
||||
}
|
||||
else if (!pagesJson.pages.length) {
|
||||
throw new Error(`[uni-app] Error: pages.json->pages must contain at least 1 page.`);
|
||||
}
|
||||
else {
|
||||
const pages = [];
|
||||
pagesJson.pages.forEach((page) => {
|
||||
if (pages.indexOf(page.path) !== -1) {
|
||||
throw new Error(`[uni-app] Error: pages.json->${page.path} duplication.`);
|
||||
}
|
||||
pages.push(page.path);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.validatePages = validatePages;
|
||||
function normalizePages(pages, platform) {
|
||||
pages.forEach((page) => {
|
||||
page.style = normalizePageStyle(page.path, page.style, platform);
|
||||
});
|
||||
if (platform !== 'app') {
|
||||
return;
|
||||
}
|
||||
const subNVuePages = [];
|
||||
// subNVues
|
||||
pages.forEach(({ style: { subNVues } }) => {
|
||||
if (!(0, shared_1.isArray)(subNVues)) {
|
||||
return;
|
||||
}
|
||||
subNVues.forEach((subNVue) => {
|
||||
if (subNVue && subNVue.path) {
|
||||
subNVuePages.push({
|
||||
path: subNVue.path,
|
||||
style: { isSubNVue: true, isNVue: true, navigationBar: {} },
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
if (subNVuePages.length) {
|
||||
pages.push(...subNVuePages);
|
||||
}
|
||||
}
|
||||
function normalizeSubpackages(subpackages) {
|
||||
const pages = [];
|
||||
if ((0, shared_1.isArray)(subpackages)) {
|
||||
subpackages.forEach(({ root, pages: subPages }) => {
|
||||
if (root && subPages.length) {
|
||||
subPages.forEach((subPage) => {
|
||||
subPage.path = (0, utils_1.normalizePath)(path_1.default.join(root, subPage.path));
|
||||
subPage.style = normalizeSubpackageSubNVues(root, subPage.style);
|
||||
pages.push(subPage);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return pages;
|
||||
}
|
||||
function normalizeSubpackageSubNVues(root, style = { navigationBar: {} }) {
|
||||
const platformStyle = style['app'] || style['app-plus'];
|
||||
if (!platformStyle) {
|
||||
return style;
|
||||
}
|
||||
if ((0, shared_1.isArray)(platformStyle.subNVues)) {
|
||||
platformStyle.subNVues.forEach((subNVue) => {
|
||||
if (subNVue.path) {
|
||||
subNVue.path = (0, utils_1.normalizePath)(path_1.default.join(root, subNVue.path));
|
||||
}
|
||||
});
|
||||
}
|
||||
return style;
|
||||
}
|
||||
function normalizePageStyle(pagePath, pageStyle, platform) {
|
||||
const hasNVue = pagePath &&
|
||||
process.env.UNI_INPUT_DIR &&
|
||||
fs_1.default.existsSync(path_1.default.join(process.env.UNI_INPUT_DIR, pagePath + '.nvue'))
|
||||
? true
|
||||
: undefined;
|
||||
let isNVue = false;
|
||||
if (hasNVue) {
|
||||
const hasVue = fs_1.default.existsSync(path_1.default.join(process.env.UNI_INPUT_DIR, pagePath + '.vue'));
|
||||
if (hasVue) {
|
||||
if (platform === 'app') {
|
||||
if (process.env.UNI_NVUE_COMPILER !== 'vue') {
|
||||
isNVue = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
isNVue = true;
|
||||
}
|
||||
}
|
||||
if (pageStyle) {
|
||||
if (platform === 'h5') {
|
||||
(0, shared_1.extend)(pageStyle, pageStyle['app'] || pageStyle['app-plus'], pageStyle['web'] || pageStyle['h5']);
|
||||
}
|
||||
else if (platform === 'app') {
|
||||
(0, shared_1.extend)(pageStyle, pageStyle['app'] || pageStyle['app-plus']);
|
||||
}
|
||||
else {
|
||||
(0, shared_1.extend)(pageStyle, pageStyle[platform]);
|
||||
}
|
||||
if (['h5', 'app'].includes(platform)) {
|
||||
pageStyle.navigationBar = normalizeNavigationBar(pageStyle);
|
||||
if (isEnablePullDownRefresh(pageStyle)) {
|
||||
pageStyle.enablePullDownRefresh = true;
|
||||
pageStyle.pullToRefresh = normalizePullToRefresh(pageStyle);
|
||||
}
|
||||
if (platform === 'app') {
|
||||
pageStyle.disableSwipeBack === true
|
||||
? (pageStyle.popGesture = 'none')
|
||||
: delete pageStyle.popGesture;
|
||||
delete pageStyle.disableSwipeBack;
|
||||
}
|
||||
}
|
||||
pageStyle.isNVue = isNVue;
|
||||
removePlatformStyle(pageStyle);
|
||||
return pageStyle;
|
||||
}
|
||||
return { navigationBar: {}, isNVue };
|
||||
}
|
||||
const navigationBarMaps = {
|
||||
navigationBarBackgroundColor: 'backgroundColor',
|
||||
navigationBarTextStyle: 'textStyle',
|
||||
navigationBarTitleText: 'titleText',
|
||||
navigationStyle: 'style',
|
||||
titleImage: 'titleImage',
|
||||
titlePenetrate: 'titlePenetrate',
|
||||
transparentTitle: 'transparentTitle',
|
||||
};
|
||||
function normalizeNavigationBar(pageStyle) {
|
||||
const navigationBar = Object.create(null);
|
||||
Object.keys(navigationBarMaps).forEach((name) => {
|
||||
if ((0, shared_1.hasOwn)(pageStyle, name)) {
|
||||
navigationBar[navigationBarMaps[name]] =
|
||||
pageStyle[name];
|
||||
delete pageStyle[name];
|
||||
}
|
||||
});
|
||||
navigationBar.type = navigationBar.type || 'default';
|
||||
const { titleNView } = pageStyle;
|
||||
if ((0, shared_1.isPlainObject)(titleNView)) {
|
||||
(0, shared_1.extend)(navigationBar, titleNView);
|
||||
delete pageStyle.titleNView;
|
||||
}
|
||||
else if (titleNView === false) {
|
||||
navigationBar.style = 'custom';
|
||||
}
|
||||
if ((0, shared_1.hasOwn)(navigationBar, 'transparentTitle')) {
|
||||
const transparentTitle = navigationBar.transparentTitle;
|
||||
if (transparentTitle === 'always') {
|
||||
navigationBar.style = 'custom';
|
||||
navigationBar.type = 'float';
|
||||
}
|
||||
else if (transparentTitle === 'auto') {
|
||||
navigationBar.type = 'transparent';
|
||||
}
|
||||
else {
|
||||
navigationBar.type = 'default';
|
||||
}
|
||||
delete navigationBar.transparentTitle;
|
||||
}
|
||||
if (navigationBar.titleImage && navigationBar.titleText) {
|
||||
delete navigationBar.titleText;
|
||||
}
|
||||
if (!navigationBar.titleColor && (0, shared_1.hasOwn)(navigationBar, 'textStyle')) {
|
||||
const textStyle = navigationBar.textStyle;
|
||||
if (constants_1.TEXT_STYLE.includes(textStyle)) {
|
||||
navigationBar.titleColor = (0, uni_shared_1.normalizeTitleColor)(textStyle);
|
||||
}
|
||||
else {
|
||||
navigationBar.titleColor = navigationBar.textStyle;
|
||||
}
|
||||
delete navigationBar.textStyle;
|
||||
}
|
||||
if (pageStyle.navigationBarShadow &&
|
||||
pageStyle.navigationBarShadow.colorType) {
|
||||
navigationBar.shadowColorType = pageStyle.navigationBarShadow.colorType;
|
||||
delete pageStyle.navigationBarShadow;
|
||||
}
|
||||
const parsedNavigationBar = (0, theme_1.initTheme)((0, manifest_1.getPlatformManifestJsonOnce)(), navigationBar);
|
||||
if ((0, shared_1.isArray)(navigationBar.buttons)) {
|
||||
navigationBar.buttons = navigationBar.buttons.map((btn) => normalizeNavigationBarButton(btn, navigationBar.type, parsedNavigationBar.titleColor));
|
||||
}
|
||||
if ((0, shared_1.isPlainObject)(navigationBar.searchInput)) {
|
||||
navigationBar.searchInput = normalizeNavigationBarSearchInput(navigationBar.searchInput);
|
||||
}
|
||||
if (navigationBar.type === 'transparent') {
|
||||
navigationBar.coverage = navigationBar.coverage || '132px';
|
||||
}
|
||||
return navigationBar;
|
||||
}
|
||||
function normalizeNavigationBarButton(btn, type, titleColor) {
|
||||
btn.color = btn.color || titleColor;
|
||||
if (!btn.fontSize) {
|
||||
btn.fontSize =
|
||||
type === 'transparent' || (btn.text && /\\u/.test(btn.text))
|
||||
? '22px'
|
||||
: '27px';
|
||||
}
|
||||
else if (/\d$/.test(btn.fontSize)) {
|
||||
btn.fontSize += 'px';
|
||||
}
|
||||
btn.text = btn.text || '';
|
||||
return btn;
|
||||
}
|
||||
function normalizeNavigationBarSearchInput(searchInput) {
|
||||
return (0, shared_1.extend)({
|
||||
autoFocus: false,
|
||||
align: 'center',
|
||||
color: '#000',
|
||||
backgroundColor: 'rgba(255,255,255,0.5)',
|
||||
borderRadius: '0px',
|
||||
placeholder: '',
|
||||
placeholderColor: '#CCCCCC',
|
||||
disabled: false,
|
||||
}, searchInput);
|
||||
}
|
||||
const DEFAULT_TAB_BAR = {
|
||||
position: 'bottom',
|
||||
color: '#999',
|
||||
selectedColor: '#007aff',
|
||||
borderStyle: 'black',
|
||||
blurEffect: 'none',
|
||||
fontSize: '10px',
|
||||
iconWidth: '24px',
|
||||
spacing: '3px',
|
||||
height: uni_shared_1.TABBAR_HEIGHT + 'px',
|
||||
};
|
||||
function normalizeTabBar(tabBar, platform) {
|
||||
const { list, midButton } = tabBar;
|
||||
if (!list || !list.length) {
|
||||
return;
|
||||
}
|
||||
tabBar = (0, shared_1.extend)({}, DEFAULT_TAB_BAR, tabBar);
|
||||
list.forEach((item) => {
|
||||
if (item.iconPath) {
|
||||
item.iconPath = normalizeFilepath(item.iconPath);
|
||||
}
|
||||
if (item.selectedIconPath) {
|
||||
item.selectedIconPath = normalizeFilepath(item.selectedIconPath);
|
||||
}
|
||||
});
|
||||
if (midButton && midButton.backgroundImage) {
|
||||
midButton.backgroundImage = normalizeFilepath(midButton.backgroundImage);
|
||||
}
|
||||
tabBar.selectedIndex = 0;
|
||||
tabBar.shown = true;
|
||||
return tabBar;
|
||||
}
|
||||
const SCHEME_RE = /^([a-z-]+:)?\/\//i;
|
||||
const DATA_RE = /^data:.*,.*/;
|
||||
function normalizeFilepath(filepath) {
|
||||
const themeConfig = (0, theme_1.normalizeThemeConfigOnce)()['light'] || {};
|
||||
if (themeConfig[filepath.replace('@', '')])
|
||||
return filepath;
|
||||
if (!(SCHEME_RE.test(filepath) || DATA_RE.test(filepath)) &&
|
||||
filepath.indexOf('/') !== 0) {
|
||||
return (0, uni_shared_1.addLeadingSlash)(filepath);
|
||||
}
|
||||
return filepath;
|
||||
}
|
||||
const platforms = ['h5', 'app', 'mp-', 'quickapp', 'web'];
|
||||
function removePlatformStyle(pageStyle) {
|
||||
Object.keys(pageStyle).forEach((name) => {
|
||||
if (platforms.find((prefix) => name.startsWith(prefix))) {
|
||||
delete pageStyle[name];
|
||||
}
|
||||
});
|
||||
return pageStyle;
|
||||
}
|
||||
exports.removePlatformStyle = removePlatformStyle;
|
||||
function normalizePagesRoute(pagesJson) {
|
||||
const firstPagePath = pagesJson.pages[0].path;
|
||||
const tabBarList = (pagesJson.tabBar && pagesJson.tabBar.list) || [];
|
||||
return pagesJson.pages.map((pageOptions) => {
|
||||
const pagePath = pageOptions.path;
|
||||
const isEntry = firstPagePath === pagePath ? true : undefined;
|
||||
const tabBarIndex = tabBarList.findIndex((tabBarPage) => tabBarPage.pagePath === pagePath);
|
||||
const isTabBar = tabBarIndex !== -1 ? true : undefined;
|
||||
let windowTop = 0;
|
||||
const meta = (0, shared_1.extend)({
|
||||
isQuit: isEntry || isTabBar ? true : undefined,
|
||||
isEntry: isEntry || undefined,
|
||||
isTabBar: isTabBar || undefined,
|
||||
tabBarIndex: isTabBar ? tabBarIndex : undefined,
|
||||
windowTop: windowTop || undefined,
|
||||
}, pageOptions.style);
|
||||
return {
|
||||
path: pageOptions.path,
|
||||
meta,
|
||||
};
|
||||
});
|
||||
}
|
||||
exports.normalizePagesRoute = normalizePagesRoute;
|
||||
function isEnablePullDownRefresh(pageStyle) {
|
||||
return pageStyle.enablePullDownRefresh || pageStyle.pullToRefresh?.support;
|
||||
}
|
||||
function normalizePullToRefresh(pageStyle) {
|
||||
return pageStyle.pullToRefresh;
|
||||
}
|
||||
function parseSubpackagesRoot(inputDir, platform) {
|
||||
const pagesJson = (0, exports.parsePagesJson)(inputDir, platform, false);
|
||||
const subpackages = pagesJson.subPackages || pagesJson.subpackages;
|
||||
const roots = [];
|
||||
if ((0, shared_1.isArray)(subpackages)) {
|
||||
subpackages.forEach(({ root }) => {
|
||||
if (root) {
|
||||
roots.push(root);
|
||||
}
|
||||
});
|
||||
}
|
||||
return roots;
|
||||
}
|
||||
exports.parseSubpackagesRootOnce = (0, uni_shared_1.once)(parseSubpackagesRoot);
|
||||
4
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/theme.d.ts
generated
vendored
Normal file
4
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/theme.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export declare function hasThemeJson(themeLocation: string): boolean;
|
||||
export declare const parseThemeJson: (themeLocation?: string) => UniApp.ThemeJson;
|
||||
export declare const normalizeThemeConfigOnce: (manifestJsonPlatform?: Record<string, any>) => UniApp.ThemeJson;
|
||||
export declare function initTheme<T extends object>(manifestJson: Record<string, any>, pagesJson: T): T;
|
||||
37
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/theme.js
generated
vendored
Normal file
37
uni_modules/UniDevTools/node_modules/@dcloudio/uni-cli-shared/dist/json/theme.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initTheme = exports.normalizeThemeConfigOnce = exports.parseThemeJson = exports.hasThemeJson = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const json_1 = require("./json");
|
||||
const uni_shared_1 = require("@dcloudio/uni-shared");
|
||||
function hasThemeJson(themeLocation) {
|
||||
if (!fs_1.default.existsSync(themeLocation)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
exports.hasThemeJson = hasThemeJson;
|
||||
const parseThemeJson = (themeLocation = 'theme.json') => {
|
||||
if (!themeLocation || !process.env.UNI_INPUT_DIR) {
|
||||
return {};
|
||||
}
|
||||
themeLocation = path_1.default.join(process.env.UNI_INPUT_DIR, themeLocation);
|
||||
if (!hasThemeJson(themeLocation)) {
|
||||
return {};
|
||||
}
|
||||
const jsonStr = fs_1.default.readFileSync(themeLocation, 'utf8');
|
||||
return (0, json_1.parseJson)(jsonStr, true);
|
||||
};
|
||||
exports.parseThemeJson = parseThemeJson;
|
||||
exports.normalizeThemeConfigOnce = (0, uni_shared_1.once)((manifestJsonPlatform = {}) => (0, exports.parseThemeJson)(manifestJsonPlatform.themeLocation));
|
||||
function initTheme(manifestJson, pagesJson) {
|
||||
const platform = process.env.UNI_PLATFORM === 'app' ? 'app-plus' : process.env.UNI_PLATFORM;
|
||||
const manifestPlatform = manifestJson['plus'] || manifestJson[platform] || {};
|
||||
const themeConfig = (0, exports.normalizeThemeConfigOnce)(manifestPlatform);
|
||||
return (0, uni_shared_1.normalizeStyles)(pagesJson, themeConfig);
|
||||
}
|
||||
exports.initTheme = initTheme;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user