更新
This commit is contained in:
+3
@@ -0,0 +1,3 @@
|
||||
export * from './pages';
|
||||
export * from './manifest';
|
||||
export { polyfillCode, arrayBufferCode, restoreGlobalCode } from './pages/code';
|
||||
+23
@@ -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; } });
|
||||
Generated
Vendored
+2
@@ -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;
|
||||
Generated
Vendored
+35
@@ -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;
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export declare function initCheckSystemWebview(manifestJson: Record<string, any>): void;
|
||||
Generated
Vendored
+17
@@ -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;
|
||||
Generated
Vendored
+4
@@ -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;
|
||||
Generated
Vendored
+75
@@ -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;
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export declare function initDefaultManifestJson(): any;
|
||||
Generated
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
"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": "",
|
||||
"concatenate": true
|
||||
},
|
||||
"splashscreen": {
|
||||
"target":"id:1",
|
||||
"autoclose": true,
|
||||
"waiting": true,
|
||||
"alwaysShowBeforeRender":true
|
||||
},
|
||||
"popGesture": "close",
|
||||
"launchwebview": {}
|
||||
},
|
||||
"app-harmony": {
|
||||
"useragent": {
|
||||
"value": "",
|
||||
"concatenate": true
|
||||
}
|
||||
}
|
||||
}`;
|
||||
Generated
Vendored
+3
@@ -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
@@ -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;
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export declare function initI18n(manifestJson: Record<string, any>): Record<string, any>;
|
||||
Generated
Vendored
+14
@@ -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;
|
||||
Generated
Vendored
+5
@@ -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';
|
||||
Generated
Vendored
+63
@@ -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; } });
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export declare function initLaunchwebview(manifestJson: Record<string, any>, pagesJson: UniApp.PagesJson): string;
|
||||
Generated
Vendored
+53
@@ -0,0 +1,53 @@
|
||||
"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) { }
|
||||
}
|
||||
if (manifestJson.plus.useragent.concatenate) {
|
||||
if (manifestJson.plus.useragent.value) {
|
||||
manifestJson.plus.useragent.value = [
|
||||
'uni-app',
|
||||
manifestJson.plus.useragent.value,
|
||||
].join(' ');
|
||||
}
|
||||
else {
|
||||
manifestJson.plus.useragent.value = 'uni-app';
|
||||
}
|
||||
}
|
||||
if (manifestJson['app-harmony'].useragent.concatenate) {
|
||||
if (manifestJson['app-harmony'].useragent.value) {
|
||||
manifestJson['app-harmony'].useragent.value = [
|
||||
'uni-app',
|
||||
manifestJson['app-harmony'].useragent.value,
|
||||
].join(' ');
|
||||
}
|
||||
else {
|
||||
manifestJson['app-harmony'].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;
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export declare function initRecursiveMerge(manifestJson: Record<string, any>, userManifestJson: Record<string, any>): Record<string, any>;
|
||||
Generated
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initRecursiveMerge = void 0;
|
||||
const merge_1 = require("merge");
|
||||
function initRecursiveMerge(manifestJson, userManifestJson) {
|
||||
const platformConfig = {
|
||||
plus: userManifestJson['app-plus'],
|
||||
};
|
||||
platformConfig['app-harmony'] = userManifestJson['app-harmony'];
|
||||
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,
|
||||
}, platformConfig);
|
||||
}
|
||||
exports.initRecursiveMerge = initRecursiveMerge;
|
||||
Generated
Vendored
+4
@@ -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" | "vue" | "weex" | "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";
|
||||
Generated
Vendored
+41
@@ -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;
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export declare function initPlus(manifestJson: Record<string, any>, pagesJson: UniApp.PagesJson): void;
|
||||
Generated
Vendored
+131
@@ -0,0 +1,131 @@
|
||||
"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);
|
||||
manifestJson['app-harmony'].uniStatistics = (0, merge_1.recursive)(true, manifestJson.uniStatistics, manifestJson['app-harmony'].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,
|
||||
};
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export declare function initSafearea(manifestJson: Record<string, any>, pagesJson: UniApp.PagesJson): void;
|
||||
Generated
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
"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',
|
||||
},
|
||||
};
|
||||
}
|
||||
if (!manifestJson['app-harmony'].safearea) {
|
||||
manifestJson['app-harmony'].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;
|
||||
Generated
Vendored
+5
@@ -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;
|
||||
};
|
||||
Generated
Vendored
+43
@@ -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;
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export declare function initAppStatusbar(manifestJson: Record<string, any>, pagesJson: UniApp.PagesJson): Record<string, any>;
|
||||
Generated
Vendored
+16
@@ -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;
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export declare function initTabBar(entryPagePath: string, manifestJson: Record<string, any>, pagesJson: UniApp.PagesJson): void;
|
||||
Generated
Vendored
+24
@@ -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;
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export declare function initUniApp(manifestJson: Record<string, any>): void;
|
||||
Generated
Vendored
+19
@@ -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
@@ -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 = "\nif (typeof Promise !== 'undefined' && !Promise.prototype.finally) {\n Promise.prototype.finally = function(callback) {\n const promise = this.constructor\n return this.then(\n value => promise.resolve(callback()).then(() => value),\n reason => promise.resolve(callback()).then(() => {\n throw reason\n })\n )\n }\n};\n\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\n";
|
||||
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
@@ -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(',');
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
export declare function definePageCode(pagesJson: Record<string, any>, platform?: UniApp.PLATFORM): string;
|
||||
export declare function defineNVuePageCode(pagesJson: Record<string, any>): string;
|
||||
Generated
Vendored
+42
@@ -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, platform = 'app') {
|
||||
const importPagesCode = [];
|
||||
const definePagesCode = [];
|
||||
pagesJson.pages.forEach((page) => {
|
||||
if (platform === 'app' && page.style.isNVue) {
|
||||
return;
|
||||
}
|
||||
const pagePath = page.path;
|
||||
const pageIdentifier = (0, utils_1.normalizeIdentifier)(pagePath);
|
||||
const pagePathWithExtname = (0, utils_1.normalizePagePath)(pagePath, platform);
|
||||
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;
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
export declare function normalizeAppPagesJson(pagesJson: Record<string, any>, platform?: UniApp.PLATFORM): string;
|
||||
export declare function normalizeAppNVuePagesJson(pagesJson: Record<string, any>): string;
|
||||
export declare function normalizeAppConfigService(pagesJson: UniApp.PagesJson, manifestJson: Record<string, any>): string;
|
||||
+29
@@ -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, platform = 'app') {
|
||||
return (0, definePage_1.definePageCode)(pagesJson, platform);
|
||||
}
|
||||
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;
|
||||
Generated
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
export declare function normalizeAppUniConfig(pagesJson: UniApp.PagesJson, manifestJson: Record<string, any>): string;
|
||||
export declare function parseEntryPagePath(pagesJson: UniApp.PagesJson): {
|
||||
entryPagePath: string;
|
||||
entryPageQuery: string;
|
||||
realEntryPagePath: string;
|
||||
};
|
||||
Generated
Vendored
+75
@@ -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.parseEntryPagePath = 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),
|
||||
// @ts-expect-error
|
||||
qqMapKey: platformConfig?.distribute?.sdkConfigs?.maps?.tencent?.key,
|
||||
};
|
||||
// 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;
|
||||
}
|
||||
exports.parseEntryPagePath = parseEntryPagePath;
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export declare function normalizeAppUniRoutes(pagesJson: UniApp.PagesJson): string;
|
||||
Generated
Vendored
+8
@@ -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;
|
||||
Reference in New Issue
Block a user