2025/2/8第一次更新

This commit is contained in:
爱吃咸鱼小猫咪
2025-02-08 18:50:38 +08:00
commit d7af560866
26519 changed files with 5046029 additions and 0 deletions
+4
View 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 = "\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
View 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(',');
@@ -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;
@@ -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;
+3
View File
@@ -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
View 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, 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;
@@ -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;
};
+75
View 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.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;
@@ -0,0 +1 @@
export declare function normalizeAppUniRoutes(pagesJson: UniApp.PagesJson): string;
@@ -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;