This commit is contained in:
2025-10-24 17:12:18 +08:00
commit 9dead7a890
2004 changed files with 298646 additions and 0 deletions

View File

@@ -0,0 +1,674 @@
module.exports = (function() {
var __MODS__ = {};
var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };
var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };
var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
__DEFINE__(1745998156416, function(require, module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformVue = exports.genClassName = void 0;
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
const plugins_1 = require("./plugins");
const css_1 = require("./plugins/css");
const mainUTS_1 = require("./plugins/mainUTS");
const manifestJson_1 = require("./plugins/manifestJson");
const pagesJson_1 = require("./plugins/pagesJson");
const pre_1 = require("./plugins/pre");
const uvue_1 = require("./plugins/uvue");
exports.default = () => {
return [
(0, pre_1.uniPrePlugin)(),
(0, uni_cli_shared_1.uniUTSPlugin)({
x: true,
extApis: (0, uni_cli_shared_1.parseUniExtApiNamespacesOnce)(process.env.UNI_UTS_PLATFORM, process.env.UNI_UTS_TARGET_LANGUAGE),
}),
(0, plugins_1.uniAppUTSPlugin)(),
(0, mainUTS_1.uniAppMainPlugin)(),
(0, manifestJson_1.uniAppManifestPlugin)(),
(0, pagesJson_1.uniAppPagesPlugin)(),
(0, css_1.uniAppCssPlugin)(),
(0, uvue_1.uniAppUVuePlugin)(),
];
};
var utils_1 = require("./plugins/utils");
Object.defineProperty(exports, "genClassName", { enumerable: true, get: function () { return utils_1.genClassName; } });
var index_1 = require("./plugins/uvue/index");
Object.defineProperty(exports, "transformVue", { enumerable: true, get: function () { return index_1.transformVue; } });
}, function(modId) {var map = {"./plugins":1745998156417,"./plugins/css":1745998156419,"./plugins/mainUTS":1745998156420,"./plugins/manifestJson":1745998156421,"./plugins/pagesJson":1745998156422,"./plugins/pre":1745998156423,"./plugins/utils":1745998156418}; return __REQUIRE__(map[modId], modId); })
__DEFINE__(1745998156417, function(require, module, exports) {
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.uniAppUTSPlugin = void 0;
const path_1 = __importDefault(require("path"));
const fs_extra_1 = __importDefault(require("fs-extra"));
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
const uni_i18n_1 = require("@dcloudio/uni-i18n");
const utils_1 = require("./utils");
const REMOVED_PLUGINS = [
'vite:build-metadata',
'vite:modulepreload-polyfill',
'vite:css',
'vite:esbuild',
'vite:json',
'vite:wasm-helper',
'vite:worker',
'vite:asset',
'vite:wasm-fallback',
'vite:define',
'vite:css-post',
'vite:build-html',
'vite:html-inline-proxy',
'vite:worker-import-meta-url',
'vite:asset-import-meta-url',
'vite:force-systemjs-wrap-complete',
'vite:watch-package-data',
'commonjs',
'vite:data-uri',
'vite:dynamic-import-vars',
'vite:import-glob',
'vite:build-import-analysis',
'vite:esbuild-transpile',
'vite:terser',
'vite:reporter',
];
function uniAppUTSPlugin() {
const inputDir = process.env.UNI_INPUT_DIR;
const outputDir = process.env.UNI_OUTPUT_DIR;
const mainUTS = (0, uni_cli_shared_1.resolveMainPathOnce)(inputDir);
const tempOutputDir = (0, utils_1.uvueOutDir)();
const manifestJson = (0, uni_cli_shared_1.parseManifestJsonOnce)(inputDir);
// 开始编译时,清空输出目录
function emptyOutDir() {
if (fs_extra_1.default.existsSync(outputDir)) {
(0, uni_cli_shared_1.emptyDir)(outputDir);
}
}
emptyOutDir();
return {
name: 'uni:app-uts',
apply: 'build',
uni: createUniOptions(),
config() {
return {
base: '/',
build: {
outDir: tempOutputDir,
lib: {
// 必须使用 lib 模式
fileName: 'output',
entry: (0, uni_cli_shared_1.resolveMainPathOnce)(inputDir),
formats: ['cjs'],
},
rollupOptions: {
external(source) {
if (['vue', 'vuex', 'pinia'].includes(source)) {
return true;
}
// 相对目录
if (source.startsWith('@/') || source.startsWith('.')) {
return false;
}
if (path_1.default.isAbsolute(source)) {
return false;
}
// android 系统库,三方库
if (source.includes('.')) {
return true;
}
return false;
},
},
},
};
},
configResolved(config) {
const plugins = config.plugins;
const len = plugins.length;
for (let i = len - 1; i >= 0; i--) {
const plugin = plugins[i];
if (REMOVED_PLUGINS.includes(plugin.name)) {
plugins.splice(i, 1);
}
}
},
async transform(code, id) {
const { filename } = (0, uni_cli_shared_1.parseVueRequest)(id);
if (!filename.endsWith('.uts')) {
return;
}
// 仅处理 uts 文件
// 忽略 uni-app-uts/lib/automator/index.uts
if (!filename.includes('uni-app-uts')) {
const isMainUTS = (0, uni_cli_shared_1.normalizePath)(id) === mainUTS;
const fileName = path_1.default.relative(inputDir, id);
this.emitFile({
type: 'asset',
fileName: normalizeFilename(fileName, isMainUTS),
source: normalizeCode(code, isMainUTS),
});
}
code = await (0, utils_1.parseImports)(code);
return code;
},
async writeBundle() {
const res = await (0, uni_cli_shared_1.resolveUTSCompiler)().compileApp(path_1.default.join(tempOutputDir, 'index.uts'), {
inputDir: tempOutputDir,
outputDir: outputDir,
package: 'uni.' + (manifestJson.appid || '').replace(/_/g, ''),
sourceMap: true,
uni_modules: [...uni_cli_shared_1.utsPlugins],
extApis: (0, uni_cli_shared_1.parseUniExtApiNamespacesOnce)(process.env.UNI_UTS_PLATFORM, process.env.UNI_UTS_TARGET_LANGUAGE),
});
if (res) {
const files = [];
if (process.env.UNI_APP_UTS_CHANGED_FILES) {
try {
files.push(...JSON.parse(process.env.UNI_APP_UTS_CHANGED_FILES));
}
catch (e) { }
}
if (res.changed && res.changed.length) {
files.push(...res.changed);
}
process.env.UNI_APP_UTS_CHANGED_FILES = JSON.stringify([
...new Set(files),
]);
}
},
};
}
exports.uniAppUTSPlugin = uniAppUTSPlugin;
function normalizeFilename(filename, isMain = false) {
if (isMain) {
return 'index.uts';
}
return (0, utils_1.parseUTSRelativeFilename)(filename);
}
function normalizeCode(code, isMain = false) {
if (!isMain) {
return code;
}
const automatorCode = process.env.UNI_AUTOMATOR_WS_ENDPOINT
? 'initAutomator();'
: '';
return `
${code}
export function main(app: IApp) {
defineAppConfig();
definePageRoutes();
${automatorCode}
(createApp()['app'] as VueApp).mount(app);
}
`;
}
function createUniOptions() {
return {
copyOptions() {
const platform = process.env.UNI_PLATFORM;
const inputDir = process.env.UNI_INPUT_DIR;
const outputDir = process.env.UNI_OUTPUT_DIR;
const targets = [];
// 自动化测试时,不启用隐私政策
if (!process.env.UNI_AUTOMATOR_WS_ENDPOINT) {
targets.push({
src: 'androidPrivacy.json',
dest: outputDir,
transform(source) {
const options = (0, uni_cli_shared_1.initI18nOptions)(platform, inputDir, false, true);
if (!options) {
return;
}
return (0, uni_i18n_1.compileI18nJsonStr)(source.toString(), options);
},
});
const debugFilename = '__nvue_debug__';
if (fs_extra_1.default.existsSync(path_1.default.resolve(inputDir, debugFilename))) {
targets.push({
src: debugFilename,
dest: outputDir,
});
}
}
return {
assets: ['hybrid/html/**/*', 'uni_modules/*/hybrid/html/**/*'],
targets,
};
},
};
}
}, function(modId) { var map = {"./utils":1745998156418}; return __REQUIRE__(map[modId], modId); })
__DEFINE__(1745998156418, function(require, module, exports) {
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseUTSImportFilename = exports.parseUTSRelativeFilename = exports.stringifyMap = exports.isVue = exports.genClassName = exports.uvueOutDir = exports.parseImports = exports.ENTRY_FILENAME = void 0;
const path_1 = __importDefault(require("path"));
const es_module_lexer_1 = require("es-module-lexer");
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
const shared_1 = require("@vue/shared");
exports.ENTRY_FILENAME = 'index.uts';
async function parseImports(code) {
await es_module_lexer_1.init;
const [imports] = (0, es_module_lexer_1.parse)(code);
return imports
.map(({ s, e }) => {
return `import "${code.slice(s, e)}"`;
})
.concat(parseUniExtApiImports(code))
.join('\n');
}
exports.parseImports = parseImports;
function parseUniExtApiImports(code) {
const extApis = (0, uni_cli_shared_1.parseUniExtApiNamespacesJsOnce)(process.env.UNI_UTS_PLATFORM, process.env.UNI_UTS_TARGET_LANGUAGE);
const pattern = /uni\.(\w+)/g;
const apis = new Set();
let match;
while ((match = pattern.exec(code)) !== null) {
apis.add(match[1]);
}
const imports = [];
apis.forEach((api) => {
const extApi = extApis[api];
if (extApi) {
imports.push(`import "${extApi[0]}"`);
}
});
return imports;
}
function uvueOutDir() {
return path_1.default.join(process.env.UNI_OUTPUT_DIR, '../.uvue');
}
exports.uvueOutDir = uvueOutDir;
function genClassName(fileName, prefix = 'Gen') {
return (prefix +
(0, shared_1.capitalize)((0, shared_1.camelize)((0, uni_cli_shared_1.removeExt)((0, uni_cli_shared_1.normalizePath)(fileName).replace(/\//g, '-')))));
}
exports.genClassName = genClassName;
function isVue(filename) {
return filename.endsWith('.vue') || filename.endsWith('.uvue');
}
exports.isVue = isVue;
function stringifyMap(obj) {
return serialize(obj, true);
}
exports.stringifyMap = stringifyMap;
function serialize(obj, ts = false) {
if ((0, shared_1.isString)(obj)) {
return `"${obj}"`;
}
else if ((0, shared_1.isPlainObject)(obj)) {
const entries = Object.entries(obj).map(([key, value]) => `[${serialize(key, ts)},${serialize(value, ts)}]`);
return `new Map${ts ? '<string, any>' : ''}([${entries.join(',')}])`;
}
else if ((0, shared_1.isArray)(obj)) {
return `[${obj.map((item) => serialize(item, ts)).join(',')}]`;
}
else {
return String(obj);
}
}
function parseUTSRelativeFilename(filename) {
if (!path_1.default.isAbsolute(filename)) {
return filename;
}
return (0, uni_cli_shared_1.normalizeNodeModules)(path_1.default.relative(process.env.UNI_INPUT_DIR, filename));
}
exports.parseUTSRelativeFilename = parseUTSRelativeFilename;
function parseUTSImportFilename(filename) {
if (!path_1.default.isAbsolute(filename)) {
return filename;
}
return (0, uni_cli_shared_1.normalizePath)(path_1.default.join(uvueOutDir(), (0, uni_cli_shared_1.normalizeNodeModules)(path_1.default.relative(process.env.UNI_INPUT_DIR, filename))));
}
exports.parseUTSImportFilename = parseUTSImportFilename;
}, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
__DEFINE__(1745998156419, function(require, module, exports) {
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.uniAppCssPlugin = void 0;
const path_1 = __importDefault(require("path"));
const picocolors_1 = __importDefault(require("picocolors"));
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
const uni_nvue_styler_1 = require("@dcloudio/uni-nvue-styler");
const utils_1 = require("./utils");
function uniAppCssPlugin() {
const mainUTS = (0, uni_cli_shared_1.resolveMainPathOnce)(process.env.UNI_INPUT_DIR);
let resolvedConfig;
const name = 'uni:app-uvue-css';
return {
name,
apply: 'build',
configResolved(config) {
resolvedConfig = config;
const uvueCssPostPlugin = (0, uni_cli_shared_1.cssPostPlugin)(config, {
isJsCode: true,
platform: process.env.UNI_PLATFORM,
chunkCssFilename(id) {
if (id === mainUTS) {
return 'App.vue.style.uts';
}
const { filename } = (0, uni_cli_shared_1.parseVueRequest)(id);
if ((0, utils_1.isVue)(filename)) {
return (0, uni_cli_shared_1.normalizePath)(path_1.default.relative(process.env.UNI_INPUT_DIR, filename) + '.style.uts');
}
},
async chunkCssCode(filename, cssCode) {
const { code, messages } = await (0, uni_nvue_styler_1.parse)(cssCode, {
filename,
logLevel: 'ERROR',
map: true,
ts: true,
chunk: 100,
type: 'uvue',
});
messages.forEach((message) => {
if (message.type === 'error') {
let msg = `[plugin:uni:app-uvue-css] ${message.text}`;
if (message.line && message.column) {
msg += `\n${(0, uni_cli_shared_1.generateCodeFrame)(cssCode, {
line: message.line,
column: message.column,
}).replace(/\t/g, ' ')}`;
}
msg += `\n${(0, uni_cli_shared_1.formatAtFilename)(filename)}`;
resolvedConfig.logger.error(picocolors_1.default.red(msg));
}
});
return `export const ${(0, utils_1.genClassName)(filename.replace('.style.uts', ''))}Styles = ${code}`;
},
});
// 增加 css plugins
(0, uni_cli_shared_1.insertBeforePlugin)((0, uni_cli_shared_1.cssPlugin)(config), name, config);
const plugins = config.plugins;
const index = plugins.findIndex((p) => p.name === 'uni:app-uvue');
plugins.splice(index, 0, uvueCssPostPlugin);
},
async transform(source, filename) {
if (!uni_cli_shared_1.cssLangRE.test(filename) || uni_cli_shared_1.commonjsProxyRE.test(filename)) {
return;
}
// 仅做校验使用
const { messages } = await (0, uni_nvue_styler_1.parse)(source, {
filename,
logLevel: 'WARNING',
map: true,
ts: true,
noCode: true,
type: 'uvue',
});
messages.forEach((message) => {
if (message.type === 'warning') {
let msg = `[plugin:uni:app-uvue-css] ${message.text}`;
if (message.line && message.column) {
msg += `\n${(0, uni_cli_shared_1.generateCodeFrame)(source, {
line: message.line,
column: message.column,
}).replace(/\t/g, ' ')}`;
}
msg += `\n${(0, uni_cli_shared_1.formatAtFilename)(filename)}`;
resolvedConfig.logger.warn(picocolors_1.default.yellow(msg));
}
});
return { code: source };
},
};
}
exports.uniAppCssPlugin = uniAppCssPlugin;
}, function(modId) { var map = {"./utils":1745998156418}; return __REQUIRE__(map[modId], modId); })
__DEFINE__(1745998156420, function(require, module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.uniAppMainPlugin = void 0;
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
const utils_1 = require("./utils");
function uniAppMainPlugin() {
const mainUTS = (0, uni_cli_shared_1.resolveMainPathOnce)(process.env.UNI_INPUT_DIR);
return {
name: 'uni:app-main',
apply: 'build',
async transform(code, id) {
if ((0, uni_cli_shared_1.normalizePath)(id) === mainUTS) {
code = await (0, utils_1.parseImports)(code);
return `
import './${uni_cli_shared_1.MANIFEST_JSON_UTS}'
import './${uni_cli_shared_1.PAGES_JSON_UTS}'
${code}
export default 'main.uts'
`;
}
},
};
}
exports.uniAppMainPlugin = uniAppMainPlugin;
}, function(modId) { var map = {"./utils":1745998156418}; return __REQUIRE__(map[modId], modId); })
__DEFINE__(1745998156421, function(require, module, exports) {
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.uniAppManifestPlugin = void 0;
const path_1 = __importDefault(require("path"));
const fs_extra_1 = __importDefault(require("fs-extra"));
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
const utils_1 = require("./utils");
function isManifest(id) {
return id.endsWith(uni_cli_shared_1.MANIFEST_JSON_UTS);
}
function uniAppManifestPlugin() {
const manifestJsonPath = path_1.default.resolve(process.env.UNI_INPUT_DIR, 'manifest.json');
const manifestJsonUTSPath = path_1.default.resolve(process.env.UNI_INPUT_DIR, uni_cli_shared_1.MANIFEST_JSON_UTS);
let manifestJson = {};
return {
name: 'uni:app-manifest',
apply: 'build',
resolveId(id) {
if (isManifest(id)) {
return manifestJsonUTSPath;
}
},
load(id) {
if (isManifest(id)) {
return fs_extra_1.default.readFileSync(manifestJsonPath, 'utf8');
}
},
transform(code, id) {
if (isManifest(id)) {
this.addWatchFile(path_1.default.resolve(process.env.UNI_INPUT_DIR, 'manifest.json'));
manifestJson = (0, uni_cli_shared_1.parseJson)(code);
return `export default 'manifest.json'`;
}
},
generateBundle(_, bundle) {
if (bundle[utils_1.ENTRY_FILENAME]) {
const asset = bundle[utils_1.ENTRY_FILENAME];
asset.source =
asset.source +
`
import "io.dcloud.uniapp.appframe.AppConfig"
export class UniAppConfig extends AppConfig {
override name: string = "${manifestJson.name || ''}"
override appid: string = "${manifestJson.appid || ''}"
override versionName: string = "${manifestJson.versionName || ''}"
override versionCode: string = "${manifestJson.versionCode || ''}"
constructor() {}
}
`;
}
fs_extra_1.default.outputFileSync(path_1.default.resolve(process.env.UNI_OUTPUT_DIR, 'manifest.json'), JSON.stringify({
id: manifestJson.appid || '',
name: manifestJson.name || '',
description: manifestJson.description || '',
version: {
name: manifestJson.versionName || '',
code: manifestJson.versionCode || '',
},
'uni-app-x': manifestJson['uni-app-x'] || {},
app: manifestJson.app || {},
}, null, 2));
},
};
}
exports.uniAppManifestPlugin = uniAppManifestPlugin;
}, function(modId) { var map = {"./utils":1745998156418}; return __REQUIRE__(map[modId], modId); })
__DEFINE__(1745998156422, function(require, module, exports) {
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.uniAppPagesPlugin = void 0;
const path_1 = __importDefault(require("path"));
const fs_extra_1 = __importDefault(require("fs-extra"));
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
const utils_1 = require("./utils");
function isPages(id) {
return id.endsWith(uni_cli_shared_1.PAGES_JSON_UTS);
}
function uniAppPagesPlugin() {
const pagesJsonPath = path_1.default.resolve(process.env.UNI_INPUT_DIR, 'pages.json');
const pagesJsonUTSPath = path_1.default.resolve(process.env.UNI_INPUT_DIR, uni_cli_shared_1.PAGES_JSON_UTS);
let imports = [];
let routes = [];
let globalStyle = 'new Map()';
let tabBar = 'null';
return {
name: 'uni:app-pages',
apply: 'build',
resolveId(id) {
if (isPages(id)) {
return pagesJsonUTSPath;
}
},
load(id) {
if (isPages(id)) {
return fs_extra_1.default.readFileSync(pagesJsonPath, 'utf8');
}
},
transform(code, id) {
if (isPages(id)) {
this.addWatchFile(path_1.default.resolve(process.env.UNI_INPUT_DIR, 'pages.json'));
const pagesJson = (0, uni_cli_shared_1.normalizeUniAppXAppPagesJson)(code);
imports = [];
routes = [];
pagesJson.pages.forEach((page, index) => {
const className = (0, utils_1.genClassName)(page.path);
let isQuit = index === 0;
imports.push(page.path);
routes.push(`{ path: "${page.path}", component: ${className}Class, meta: { isQuit: ${isQuit} } as PageMeta, style: ${stringifyPageStyle(page.style)} } as PageRoute`);
});
if (pagesJson.globalStyle) {
globalStyle = stringifyPageStyle(pagesJson.globalStyle);
}
if (pagesJson.tabBar) {
tabBar = (0, utils_1.stringifyMap)(pagesJson.tabBar);
}
return `${imports.map((p) => `import './${p}.uvue'`).join('\n')}
export default 'pages.json'`;
}
},
generateBundle(_, bundle) {
if (bundle[utils_1.ENTRY_FILENAME]) {
const asset = bundle[utils_1.ENTRY_FILENAME];
asset.source =
asset.source +
`
${imports
.map((p) => {
const className = (0, utils_1.genClassName)(p);
return `import ${className}Class from './${p}.uvue?type=page'`;
})
.join('\n')}
function definePageRoutes() {
${routes.map((route) => `__uniRoutes.push(${route})`).join('\n')}
}
function defineAppConfig(){
__uniConfig.entryPagePath = '/${imports[0]}'
__uniConfig.globalStyle = ${globalStyle}
__uniConfig.tabBar = ${tabBar}
}
`;
}
},
};
}
exports.uniAppPagesPlugin = uniAppPagesPlugin;
function stringifyPageStyle(pageStyle) {
return (0, utils_1.stringifyMap)(pageStyle);
}
}, function(modId) { var map = {"./utils":1745998156418}; return __REQUIRE__(map[modId], modId); })
__DEFINE__(1745998156423, function(require, module, exports) {
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.uniPrePlugin = void 0;
const path_1 = __importDefault(require("path"));
const debug_1 = __importDefault(require("debug"));
const pluginutils_1 = require("@rollup/pluginutils");
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
const debugPreJs = (0, debug_1.default)('uni:pre-js');
const debugPreHtml = (0, debug_1.default)('uni:pre-html');
const debugPreJsTry = (0, debug_1.default)('uni:pre-js-try');
const PRE_HTML_EXTNAME = ['.vue', '.uvue'];
const PRE_JS_EXTNAME = ['.json', '.css', '.uts'].concat(PRE_HTML_EXTNAME);
function uniPrePlugin(options = {}) {
const filter = (0, pluginutils_1.createFilter)(options.include, options.exclude);
const preJsFile = uni_cli_shared_1.preUVueJs;
const preHtmlFile = uni_cli_shared_1.preUVueHtml;
return {
name: 'uni:pre',
transform(code, id) {
if (!filter(id)) {
return;
}
const { filename } = (0, uni_cli_shared_1.parseVueRequest)(id);
const extname = path_1.default.extname(filename);
const isHtml = PRE_HTML_EXTNAME.includes(extname);
const isJs = PRE_JS_EXTNAME.includes(extname);
const isPre = isHtml || isJs;
if (isPre) {
debugPreJsTry(id);
}
const hasEndif = isPre && code.includes('#endif');
if (!hasEndif) {
return;
}
if (isHtml) {
code = preHtmlFile(code);
debugPreHtml(id);
}
if (isJs) {
code = preJsFile(code);
debugPreJs(id);
}
return {
code,
};
},
};
}
exports.uniPrePlugin = uniPrePlugin;
}, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
return __REQUIRE__(1745998156416);
})()
//miniprogram-npm-outsideDeps=["@dcloudio/uni-cli-shared","./plugins/uvue","./plugins/uvue/index","path","fs-extra","@dcloudio/uni-i18n","es-module-lexer","@vue/shared","picocolors","@dcloudio/uni-nvue-styler","debug","@rollup/pluginutils"]
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,213 @@
module.exports = (function() {
var __MODS__ = {};
var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };
var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };
var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
__DEFINE__(1745998156461, function(require, module, exports) {
var vue = require('vue');
var shared = require('@vue/shared');
var uniShared = require('@dcloudio/uni-shared');
function assertKey(key, shallow = false) {
if (!key) {
throw new Error(`${shallow ? 'shallowSsrRef' : 'ssrRef'}: You must provide a key.`);
}
}
function proxy(target, track, trigger) {
return new Proxy(target, {
get(target, prop) {
track();
if (shared.isObject(target[prop])) {
return proxy(target[prop], track, trigger);
}
return Reflect.get(target, prop);
},
set(obj, prop, newVal) {
const result = Reflect.set(obj, prop, newVal);
trigger();
return result;
},
});
}
const globalData = {};
const ssrServerRef = (value, key, shallow = false) => {
assertKey(key, shallow);
const ctx = vue.getCurrentInstance() && vue.useSSRContext();
let state;
if (ctx) {
const __uniSSR = ctx[uniShared.UNI_SSR] || (ctx[uniShared.UNI_SSR] = {});
state = __uniSSR[uniShared.UNI_SSR_DATA] || (__uniSSR[uniShared.UNI_SSR_DATA] = {});
}
else {
state = globalData;
}
state[key] = uniShared.sanitise(value);
// SSR 模式下 watchEffect 不生效 https://github.com/vuejs/vue-next/blob/master/packages/runtime-core/src/apiWatch.ts#L283
// 故自定义ref
return vue.customRef((track, trigger) => {
const customTrigger = () => (trigger(), (state[key] = uniShared.sanitise(value)));
return {
get: () => {
track();
if (!shallow && shared.isObject(value)) {
return proxy(value, track, customTrigger);
}
return value;
},
set: (v) => {
value = v;
customTrigger();
},
};
});
};
const ssrRef = (value, key) => {
{
return ssrServerRef(value, key);
}
};
const shallowSsrRef = (value, key) => {
{
return ssrServerRef(value, key, true);
}
};
function getSsrGlobalData() {
return uniShared.sanitise(globalData);
}
/**
* uni 对象是跨实例的,而此处列的 API 均是需要跟当前实例关联的,比如 requireNativePlugin 获取 dom 时,依赖当前 weex 实例
*/
function getCurrentSubNVue() {
// @ts-ignore
return uni.getSubNVueById(plus.webview.currentWebview().id);
}
function requireNativePlugin(name) {
return weex.requireModule(name);
}
function formatAppLog(type, filename, ...args) {
// @ts-ignore
if (uni.__log__) {
// @ts-ignore
uni.__log__(type, filename, ...args);
}
else {
console[type].apply(console, [...args, filename]);
}
}
function formatH5Log(type, filename, ...args) {
console[type].apply(console, [...args, filename]);
}
function resolveEasycom(component, easycom) {
return shared.isString(component) ? easycom : component;
}
/// <reference types="@dcloudio/types" />
const createHook = (lifecycle) => (hook, target = vue.getCurrentInstance()) => {
// post-create lifecycle registrations are noops during SSR
!vue.isInSSRComponentSetup && vue.injectHook(lifecycle, hook, target);
};
const onShow = /*#__PURE__*/ createHook(uniShared.ON_SHOW);
const onHide = /*#__PURE__*/ createHook(uniShared.ON_HIDE);
const onLaunch =
/*#__PURE__*/ createHook(uniShared.ON_LAUNCH);
const onError =
/*#__PURE__*/ createHook(uniShared.ON_ERROR);
const onThemeChange =
/*#__PURE__*/ createHook(uniShared.ON_THEME_CHANGE);
const onPageNotFound =
/*#__PURE__*/ createHook(uniShared.ON_PAGE_NOT_FOUND);
const onUnhandledRejection = /*#__PURE__*/ createHook(uniShared.ON_UNHANDLE_REJECTION);
const onInit =
/*#__PURE__*/ createHook(uniShared.ON_INIT);
// 小程序如果想在 setup 的 props 传递页面参数,需要定义 props故同时暴露 onLoad 吧
const onLoad =
/*#__PURE__*/ createHook(uniShared.ON_LOAD);
const onReady = /*#__PURE__*/ createHook(uniShared.ON_READY);
const onUnload = /*#__PURE__*/ createHook(uniShared.ON_UNLOAD);
const onResize =
/*#__PURE__*/ createHook(uniShared.ON_RESIZE);
const onBackPress =
/*#__PURE__*/ createHook(uniShared.ON_BACK_PRESS);
const onPageScroll =
/*#__PURE__*/ createHook(uniShared.ON_PAGE_SCROLL);
const onTabItemTap =
/*#__PURE__*/ createHook(uniShared.ON_TAB_ITEM_TAP);
const onReachBottom = /*#__PURE__*/ createHook(uniShared.ON_REACH_BOTTOM);
const onPullDownRefresh = /*#__PURE__*/ createHook(uniShared.ON_PULL_DOWN_REFRESH);
const onSaveExitState =
/*#__PURE__*/ createHook(uniShared.ON_SAVE_EXIT_STATE);
const onShareTimeline =
/*#__PURE__*/ createHook(uniShared.ON_SHARE_TIMELINE);
const onAddToFavorites =
/*#__PURE__*/ createHook(uniShared.ON_ADD_TO_FAVORITES);
const onShareAppMessage =
/*#__PURE__*/ createHook(uniShared.ON_SHARE_APP_MESSAGE);
const onNavigationBarButtonTap = /*#__PURE__*/ createHook(uniShared.ON_NAVIGATION_BAR_BUTTON_TAP);
const onNavigationBarSearchInputChanged = /*#__PURE__*/ createHook(uniShared.ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED);
const onNavigationBarSearchInputClicked = /*#__PURE__*/ createHook(uniShared.ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED);
const onNavigationBarSearchInputConfirmed = /*#__PURE__*/ createHook(uniShared.ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED);
const onNavigationBarSearchInputFocusChanged =
/*#__PURE__*/ createHook(uniShared.ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED);
Object.defineProperty(exports, 'capitalize', {
enumerable: true,
get: function () { return shared.capitalize; }
});
Object.defineProperty(exports, 'extend', {
enumerable: true,
get: function () { return shared.extend; }
});
Object.defineProperty(exports, 'hasOwn', {
enumerable: true,
get: function () { return shared.hasOwn; }
});
Object.defineProperty(exports, 'isPlainObject', {
enumerable: true,
get: function () { return shared.isPlainObject; }
});
exports.formatAppLog = formatAppLog;
exports.formatH5Log = formatH5Log;
exports.getCurrentSubNVue = getCurrentSubNVue;
exports.getSsrGlobalData = getSsrGlobalData;
exports.onAddToFavorites = onAddToFavorites;
exports.onBackPress = onBackPress;
exports.onError = onError;
exports.onHide = onHide;
exports.onInit = onInit;
exports.onLaunch = onLaunch;
exports.onLoad = onLoad;
exports.onNavigationBarButtonTap = onNavigationBarButtonTap;
exports.onNavigationBarSearchInputChanged = onNavigationBarSearchInputChanged;
exports.onNavigationBarSearchInputClicked = onNavigationBarSearchInputClicked;
exports.onNavigationBarSearchInputConfirmed = onNavigationBarSearchInputConfirmed;
exports.onNavigationBarSearchInputFocusChanged = onNavigationBarSearchInputFocusChanged;
exports.onPageNotFound = onPageNotFound;
exports.onPageScroll = onPageScroll;
exports.onPullDownRefresh = onPullDownRefresh;
exports.onReachBottom = onReachBottom;
exports.onReady = onReady;
exports.onResize = onResize;
exports.onSaveExitState = onSaveExitState;
exports.onShareAppMessage = onShareAppMessage;
exports.onShareTimeline = onShareTimeline;
exports.onShow = onShow;
exports.onTabItemTap = onTabItemTap;
exports.onThemeChange = onThemeChange;
exports.onUnhandledRejection = onUnhandledRejection;
exports.onUnload = onUnload;
exports.requireNativePlugin = requireNativePlugin;
exports.resolveEasycom = resolveEasycom;
exports.shallowSsrRef = shallowSsrRef;
exports.ssrRef = ssrRef;
}, function(modId) {var map = {}; return __REQUIRE__(map[modId], modId); })
return __REQUIRE__(1745998156461);
})()
//miniprogram-npm-outsideDeps=["vue","@vue/shared","@dcloudio/uni-shared"]
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,13 @@
module.exports = (function() {
var __MODS__ = {};
var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };
var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };
var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
__DEFINE__(1745998156611, function(require, module, exports) {
module.exports = {}
}, function(modId) {var map = {}; return __REQUIRE__(map[modId], modId); })
return __REQUIRE__(1745998156611);
})()
//miniprogram-npm-outsideDeps=[]
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;AAAA","file":"index.js","sourcesContent":["module.exports = {}"]}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,490 @@
module.exports = (function() {
var __MODS__ = {};
var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };
var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };
var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
__DEFINE__(1745998156642, function(require, module, exports) {
const isObject = (val) => val !== null && typeof val === 'object';
const defaultDelimiters = ['{', '}'];
class BaseFormatter {
constructor() {
this._caches = Object.create(null);
}
interpolate(message, values, delimiters = defaultDelimiters) {
if (!values) {
return [message];
}
let tokens = this._caches[message];
if (!tokens) {
tokens = parse(message, delimiters);
this._caches[message] = tokens;
}
return compile(tokens, values);
}
}
const RE_TOKEN_LIST_VALUE = /^(?:\d)+/;
const RE_TOKEN_NAMED_VALUE = /^(?:\w)+/;
function parse(format, [startDelimiter, endDelimiter]) {
const tokens = [];
let position = 0;
let text = '';
while (position < format.length) {
let char = format[position++];
if (char === startDelimiter) {
if (text) {
tokens.push({ type: 'text', value: text });
}
text = '';
let sub = '';
char = format[position++];
while (char !== undefined && char !== endDelimiter) {
sub += char;
char = format[position++];
}
const isClosed = char === endDelimiter;
const type = RE_TOKEN_LIST_VALUE.test(sub)
? 'list'
: isClosed && RE_TOKEN_NAMED_VALUE.test(sub)
? 'named'
: 'unknown';
tokens.push({ value: sub, type });
}
// else if (char === '%') {
// // when found rails i18n syntax, skip text capture
// if (format[position] !== '{') {
// text += char
// }
// }
else {
text += char;
}
}
text && tokens.push({ type: 'text', value: text });
return tokens;
}
function compile(tokens, values) {
const compiled = [];
let index = 0;
const mode = Array.isArray(values)
? 'list'
: isObject(values)
? 'named'
: 'unknown';
if (mode === 'unknown') {
return compiled;
}
while (index < tokens.length) {
const token = tokens[index];
switch (token.type) {
case 'text':
compiled.push(token.value);
break;
case 'list':
compiled.push(values[parseInt(token.value, 10)]);
break;
case 'named':
if (mode === 'named') {
compiled.push(values[token.value]);
}
else {
if (process.env.NODE_ENV !== 'production') {
console.warn(`Type of token '${token.type}' and format of value '${mode}' don't match!`);
}
}
break;
case 'unknown':
if (process.env.NODE_ENV !== 'production') {
console.warn(`Detect 'unknown' type of token!`);
}
break;
}
index++;
}
return compiled;
}
const LOCALE_ZH_HANS = 'zh-Hans';
const LOCALE_ZH_HANT = 'zh-Hant';
const LOCALE_EN = 'en';
const LOCALE_FR = 'fr';
const LOCALE_ES = 'es';
const hasOwnProperty = Object.prototype.hasOwnProperty;
const hasOwn = (val, key) => hasOwnProperty.call(val, key);
const defaultFormatter = new BaseFormatter();
function include(str, parts) {
return !!parts.find((part) => str.indexOf(part) !== -1);
}
function startsWith(str, parts) {
return parts.find((part) => str.indexOf(part) === 0);
}
function normalizeLocale(locale, messages) {
if (!locale) {
return;
}
locale = locale.trim().replace(/_/g, '-');
if (messages && messages[locale]) {
return locale;
}
locale = locale.toLowerCase();
if (locale === 'chinese') {
// 支付宝
return LOCALE_ZH_HANS;
}
if (locale.indexOf('zh') === 0) {
if (locale.indexOf('-hans') > -1) {
return LOCALE_ZH_HANS;
}
if (locale.indexOf('-hant') > -1) {
return LOCALE_ZH_HANT;
}
if (include(locale, ['-tw', '-hk', '-mo', '-cht'])) {
return LOCALE_ZH_HANT;
}
return LOCALE_ZH_HANS;
}
let locales = [LOCALE_EN, LOCALE_FR, LOCALE_ES];
if (messages && Object.keys(messages).length > 0) {
locales = Object.keys(messages);
}
const lang = startsWith(locale, locales);
if (lang) {
return lang;
}
}
class I18n {
constructor({ locale, fallbackLocale, messages, watcher, formater, }) {
this.locale = LOCALE_EN;
this.fallbackLocale = LOCALE_EN;
this.message = {};
this.messages = {};
this.watchers = [];
if (fallbackLocale) {
this.fallbackLocale = fallbackLocale;
}
this.formater = formater || defaultFormatter;
this.messages = messages || {};
this.setLocale(locale || LOCALE_EN);
if (watcher) {
this.watchLocale(watcher);
}
}
setLocale(locale) {
const oldLocale = this.locale;
this.locale = normalizeLocale(locale, this.messages) || this.fallbackLocale;
if (!this.messages[this.locale]) {
// 可能初始化时不存在
this.messages[this.locale] = {};
}
this.message = this.messages[this.locale];
// 仅发生变化时,通知
if (oldLocale !== this.locale) {
this.watchers.forEach((watcher) => {
watcher(this.locale, oldLocale);
});
}
}
getLocale() {
return this.locale;
}
watchLocale(fn) {
const index = this.watchers.push(fn) - 1;
return () => {
this.watchers.splice(index, 1);
};
}
add(locale, message, override = true) {
const curMessages = this.messages[locale];
if (curMessages) {
if (override) {
Object.assign(curMessages, message);
}
else {
Object.keys(message).forEach((key) => {
if (!hasOwn(curMessages, key)) {
curMessages[key] = message[key];
}
});
}
}
else {
this.messages[locale] = message;
}
}
f(message, values, delimiters) {
return this.formater.interpolate(message, values, delimiters).join('');
}
t(key, locale, values) {
let message = this.message;
if (typeof locale === 'string') {
locale = normalizeLocale(locale, this.messages);
locale && (message = this.messages[locale]);
}
else {
values = locale;
}
if (!hasOwn(message, key)) {
console.warn(`Cannot translate the value of keypath ${key}. Use the value of keypath as default.`);
return key;
}
return this.formater.interpolate(message[key], values).join('');
}
}
function watchAppLocale(appVm, i18n) {
// 需要保证 watch 的触发在组件渲染之前
if (appVm.$watchLocale) {
// vue2
appVm.$watchLocale((newLocale) => {
i18n.setLocale(newLocale);
});
}
else {
appVm.$watch(() => appVm.$locale, (newLocale) => {
i18n.setLocale(newLocale);
});
}
}
function getDefaultLocale() {
if (typeof uni !== 'undefined' && uni.getLocale) {
return uni.getLocale();
}
// 小程序平台uni 和 uni-i18n 互相引用,导致访问不到 uni故在 global 上挂了 getLocale
if (typeof global !== 'undefined' && global.getLocale) {
return global.getLocale();
}
return LOCALE_EN;
}
function initVueI18n(locale, messages = {}, fallbackLocale, watcher) {
// 兼容旧版本入参
if (typeof locale !== 'string') {
[locale, messages] = [
messages,
locale,
];
}
if (typeof locale !== 'string') {
// 因为小程序平台uni-i18n 和 uni 互相引用,导致此时访问 uni 时,为 undefined
locale = getDefaultLocale();
}
if (typeof fallbackLocale !== 'string') {
fallbackLocale =
(typeof __uniConfig !== 'undefined' && __uniConfig.fallbackLocale) ||
LOCALE_EN;
}
const i18n = new I18n({
locale,
fallbackLocale,
messages,
watcher,
});
let t = (key, values) => {
if (typeof getApp !== 'function') {
// app view
/* eslint-disable no-func-assign */
t = function (key, values) {
return i18n.t(key, values);
};
}
else {
let isWatchedAppLocale = false;
t = function (key, values) {
const appVm = getApp().$vm;
// 可能$vm还不存在比如在支付宝小程序中组件定义较早在props的default里使用了t()函数如uni-goods-nav此时app还未初始化
// options: {
// type: Array,
// default () {
// return [{
// icon: 'shop',
// text: t("uni-goods-nav.options.shop"),
// }, {
// icon: 'cart',
// text: t("uni-goods-nav.options.cart")
// }]
// }
// },
if (appVm) {
// 触发响应式
appVm.$locale;
if (!isWatchedAppLocale) {
isWatchedAppLocale = true;
watchAppLocale(appVm, i18n);
}
}
return i18n.t(key, values);
};
}
return t(key, values);
};
return {
i18n,
f(message, values, delimiters) {
return i18n.f(message, values, delimiters);
},
t(key, values) {
return t(key, values);
},
add(locale, message, override = true) {
return i18n.add(locale, message, override);
},
watch(fn) {
return i18n.watchLocale(fn);
},
getLocale() {
return i18n.getLocale();
},
setLocale(newLocale) {
return i18n.setLocale(newLocale);
},
};
}
const isString = (val) => typeof val === 'string';
let formater;
function hasI18nJson(jsonObj, delimiters) {
if (!formater) {
formater = new BaseFormatter();
}
return walkJsonObj(jsonObj, (jsonObj, key) => {
const value = jsonObj[key];
if (isString(value)) {
if (isI18nStr(value, delimiters)) {
return true;
}
}
else {
return hasI18nJson(value, delimiters);
}
});
}
function parseI18nJson(jsonObj, values, delimiters) {
if (!formater) {
formater = new BaseFormatter();
}
walkJsonObj(jsonObj, (jsonObj, key) => {
const value = jsonObj[key];
if (isString(value)) {
if (isI18nStr(value, delimiters)) {
jsonObj[key] = compileStr(value, values, delimiters);
}
}
else {
parseI18nJson(value, values, delimiters);
}
});
return jsonObj;
}
function compileI18nJsonStr(jsonStr, { locale, locales, delimiters, }) {
if (!isI18nStr(jsonStr, delimiters)) {
return jsonStr;
}
if (!formater) {
formater = new BaseFormatter();
}
const localeValues = [];
Object.keys(locales).forEach((name) => {
if (name !== locale) {
localeValues.push({
locale: name,
values: locales[name],
});
}
});
localeValues.unshift({ locale, values: locales[locale] });
try {
return JSON.stringify(compileJsonObj(JSON.parse(jsonStr), localeValues, delimiters), null, 2);
}
catch (e) { }
return jsonStr;
}
function isI18nStr(value, delimiters) {
return value.indexOf(delimiters[0]) > -1;
}
function compileStr(value, values, delimiters) {
return formater.interpolate(value, values, delimiters).join('');
}
function compileValue(jsonObj, key, localeValues, delimiters) {
const value = jsonObj[key];
if (isString(value)) {
// 存在国际化
if (isI18nStr(value, delimiters)) {
jsonObj[key] = compileStr(value, localeValues[0].values, delimiters);
if (localeValues.length > 1) {
// 格式化国际化语言
const valueLocales = (jsonObj[key + 'Locales'] = {});
localeValues.forEach((localValue) => {
valueLocales[localValue.locale] = compileStr(value, localValue.values, delimiters);
});
}
}
}
else {
compileJsonObj(value, localeValues, delimiters);
}
}
function compileJsonObj(jsonObj, localeValues, delimiters) {
walkJsonObj(jsonObj, (jsonObj, key) => {
compileValue(jsonObj, key, localeValues, delimiters);
});
return jsonObj;
}
function walkJsonObj(jsonObj, walk) {
if (Array.isArray(jsonObj)) {
for (let i = 0; i < jsonObj.length; i++) {
if (walk(jsonObj, i)) {
return true;
}
}
}
else if (isObject(jsonObj)) {
for (const key in jsonObj) {
if (walk(jsonObj, key)) {
return true;
}
}
}
return false;
}
function resolveLocale(locales) {
return (locale) => {
if (!locale) {
return locale;
}
locale = normalizeLocale(locale) || locale;
return resolveLocaleChain(locale).find((locale) => locales.indexOf(locale) > -1);
};
}
function resolveLocaleChain(locale) {
const chain = [];
const tokens = locale.split('-');
while (tokens.length) {
chain.push(tokens.join('-'));
tokens.pop();
}
return chain;
}
exports.Formatter = BaseFormatter;
exports.I18n = I18n;
exports.LOCALE_EN = LOCALE_EN;
exports.LOCALE_ES = LOCALE_ES;
exports.LOCALE_FR = LOCALE_FR;
exports.LOCALE_ZH_HANS = LOCALE_ZH_HANS;
exports.LOCALE_ZH_HANT = LOCALE_ZH_HANT;
exports.compileI18nJsonStr = compileI18nJsonStr;
exports.hasI18nJson = hasI18nJson;
exports.initVueI18n = initVueI18n;
exports.isI18nStr = isI18nStr;
exports.isString = isString;
exports.normalizeLocale = normalizeLocale;
exports.parseI18nJson = parseI18nJson;
exports.resolveLocale = resolveLocale;
}, function(modId) {var map = {}; return __REQUIRE__(map[modId], modId); })
return __REQUIRE__(1745998156642);
})()
//miniprogram-npm-outsideDeps=[]
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long