@weapp-vite/i18n 0.2.10 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/compiler.cjs +2 -4
- package/dist/cjs/compiler2.cjs +2 -4
- package/dist/cjs/runtime.cjs +1 -2
- package/dist/cli.mjs +1 -2
- package/dist/{compiler-CgvzedKT.mjs → compiler-m3fheQqP.mjs} +2 -4
- package/dist/compiler.d.mts +1 -5
- package/dist/compiler.mjs +2 -3
- package/dist/config-types.d.mts +1 -1
- package/dist/{configTypes-CwpxEiy4.d.mts → configTypes-CX-OAboL.d.mts} +0 -2
- package/dist/index.d.mts +2 -2
- package/dist/miniprogram/index.js +3 -6
- package/dist/{runtime-B_Jl9Usn.d.mts → runtime-DvVcygw2.d.mts} +1 -5
- package/dist/runtime.d.mts +2 -2
- package/dist/runtime.mjs +2 -3
- package/package.json +3 -3
package/dist/cjs/compiler.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
// \0rolldown/runtime.js
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -20,12 +20,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
20
20
|
value: mod,
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
|
-
//#endregion
|
|
24
23
|
const require_compiler = require("./compiler2.cjs");
|
|
25
24
|
let node_fs = require("node:fs");
|
|
26
25
|
let node_path = require("node:path");
|
|
27
26
|
node_path = __toESM(node_path, 1);
|
|
28
|
-
|
|
27
|
+
// src/native.ts
|
|
29
28
|
async function collectLocaleFiles(root, files) {
|
|
30
29
|
const entries = await node_fs.promises.readdir(root, { withFileTypes: true });
|
|
31
30
|
for (const entry of entries) {
|
|
@@ -68,7 +67,6 @@ async function compileNativeI18n(options) {
|
|
|
68
67
|
wxsFile
|
|
69
68
|
};
|
|
70
69
|
}
|
|
71
|
-
//#endregion
|
|
72
70
|
exports.compileI18nCatalog = require_compiler.compileI18nCatalog;
|
|
73
71
|
exports.compileI18nMessage = require_compiler.compileI18nMessage;
|
|
74
72
|
exports.compileI18nMessages = require_compiler.compileI18nMessages;
|
package/dist/cjs/compiler2.cjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// ../../@weapp-core/constants/dist/index.js
|
|
2
2
|
const WEAPP_I18N_RUNTIME_MARKER = "__WEAPP_VITE_I18N__";
|
|
3
3
|
const WEAPP_I18N_LOCALE_DATA_KEY = "__wv_i18n_locale";
|
|
4
|
-
|
|
5
|
-
//#region src/compiler.ts
|
|
4
|
+
// src/compiler.ts
|
|
6
5
|
const PLACEHOLDER_PATH_RE = /^[A-Z_$][\w$]*(?:\.[A-Z_$][\w$]*)*$/i;
|
|
7
6
|
function isPlainObject(value) {
|
|
8
7
|
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
@@ -146,7 +145,6 @@ export const behavior = i18n.behavior
|
|
|
146
145
|
export const page = i18n.page
|
|
147
146
|
`;
|
|
148
147
|
}
|
|
149
|
-
//#endregion
|
|
150
148
|
Object.defineProperty(exports, "WEAPP_I18N_LOCALE_DATA_KEY", {
|
|
151
149
|
enumerable: true,
|
|
152
150
|
get: function() {
|
package/dist/cjs/runtime.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_compiler = require("./compiler2.cjs");
|
|
3
|
-
|
|
3
|
+
// src/runtime.ts
|
|
4
4
|
function hasOwn(object, key) {
|
|
5
5
|
return object != null && Object.prototype.hasOwnProperty.call(object, key);
|
|
6
6
|
}
|
|
@@ -150,5 +150,4 @@ function createI18n(options, host) {
|
|
|
150
150
|
page: createPageAdapter(state, resolvedHost)
|
|
151
151
|
};
|
|
152
152
|
}
|
|
153
|
-
//#endregion
|
|
154
153
|
exports.createI18n = createI18n;
|
package/dist/cli.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { compileNativeI18n } from "./compiler.mjs";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import { parseArgs } from "node:util";
|
|
5
|
-
|
|
5
|
+
// src/cli.ts
|
|
6
6
|
function printHelp() {
|
|
7
7
|
console.log(`weapp-i18n compile --src-root <dir> --default-locale <locale> [options]
|
|
8
8
|
|
|
@@ -53,5 +53,4 @@ main().catch((error) => {
|
|
|
53
53
|
console.error(error instanceof Error ? error.message : String(error));
|
|
54
54
|
process.exitCode = 1;
|
|
55
55
|
});
|
|
56
|
-
//#endregion
|
|
57
56
|
export {};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// ../../@weapp-core/constants/dist/index.js
|
|
2
2
|
const WEAPP_I18N_RUNTIME_MARKER = "__WEAPP_VITE_I18N__";
|
|
3
3
|
const WEAPP_I18N_LOCALE_DATA_KEY = "__wv_i18n_locale";
|
|
4
|
-
|
|
5
|
-
//#region src/compiler.ts
|
|
4
|
+
// src/compiler.ts
|
|
6
5
|
const PLACEHOLDER_PATH_RE = /^[A-Z_$][\w$]*(?:\.[A-Z_$][\w$]*)*$/i;
|
|
7
6
|
function isPlainObject(value) {
|
|
8
7
|
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
@@ -146,5 +145,4 @@ export const behavior = i18n.behavior
|
|
|
146
145
|
export const page = i18n.page
|
|
147
146
|
`;
|
|
148
147
|
}
|
|
149
|
-
//#endregion
|
|
150
148
|
export { generateI18nRuntimeSource as a, generateI18nCatalogModuleSource as i, compileI18nMessage as n, generateI18nWxsSource as o, compileI18nMessages as r, WEAPP_I18N_LOCALE_DATA_KEY as s, compileI18nCatalog as t };
|
package/dist/compiler.d.mts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { a as I18nCompiledMessages, c as I18nLocaleFileInput, f as I18nMessages, i as I18nCompileOptions, m as I18nPlaceholderToken, n as CompileNativeI18nResult, r as I18nCatalog, t as CompileNativeI18nOptions, u as I18nMessageToken } from "./configTypes-
|
|
2
|
-
//#region src/compiler.d.ts
|
|
1
|
+
import { a as I18nCompiledMessages, c as I18nLocaleFileInput, f as I18nMessages, i as I18nCompileOptions, m as I18nPlaceholderToken, n as CompileNativeI18nResult, r as I18nCatalog, t as CompileNativeI18nOptions, u as I18nMessageToken } from "./configTypes-CX-OAboL.mjs";
|
|
3
2
|
export declare function compileI18nMessage(message: string): I18nMessageToken[];
|
|
4
3
|
export declare function compileI18nMessages(messages: I18nMessages): I18nCompiledMessages;
|
|
5
4
|
export declare function compileI18nCatalog(files: I18nLocaleFileInput[], options: I18nCompileOptions): I18nCatalog;
|
|
6
5
|
export declare function generateI18nCatalogModuleSource(catalog: I18nCatalog): string;
|
|
7
6
|
export declare function generateI18nWxsSource(catalog: I18nCatalog): string;
|
|
8
7
|
export declare function generateI18nRuntimeSource(catalog: I18nCatalog): string;
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region src/native.d.ts
|
|
11
8
|
export declare function compileNativeI18n(options: CompileNativeI18nOptions): Promise<CompileNativeI18nResult>;
|
|
12
|
-
//#endregion
|
|
13
9
|
export type { CompileNativeI18nOptions, CompileNativeI18nResult, I18nCatalog, I18nCompileOptions, I18nLocaleFileInput, I18nMessageToken, I18nPlaceholderToken };
|
package/dist/compiler.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as generateI18nRuntimeSource, i as generateI18nCatalogModuleSource, n as compileI18nMessage, o as generateI18nWxsSource, r as compileI18nMessages, t as compileI18nCatalog } from "./compiler-
|
|
1
|
+
import { a as generateI18nRuntimeSource, i as generateI18nCatalogModuleSource, n as compileI18nMessage, o as generateI18nWxsSource, r as compileI18nMessages, t as compileI18nCatalog } from "./compiler-m3fheQqP.mjs";
|
|
2
2
|
import { promises } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
|
|
4
|
+
// src/native.ts
|
|
5
5
|
async function collectLocaleFiles(root, files) {
|
|
6
6
|
const entries = await promises.readdir(root, { withFileTypes: true });
|
|
7
7
|
for (const entry of entries) {
|
|
@@ -44,5 +44,4 @@ async function compileNativeI18n(options) {
|
|
|
44
44
|
wxsFile
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
//#endregion
|
|
48
47
|
export { compileI18nCatalog, compileI18nMessage, compileI18nMessages, compileNativeI18n, generateI18nCatalogModuleSource, generateI18nRuntimeSource, generateI18nWxsSource };
|
package/dist/config-types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as I18nCompiledMessages, c as I18nLocaleFileInput, d as I18nMessageValue, f as I18nMessages, i as I18nCompileOptions, l as I18nLocaleMessages, m as I18nPlaceholderToken, n as CompileNativeI18nResult, o as I18nGlobal, p as I18nOptions, r as I18nCatalog, s as I18nLocaleChangeSubscription, t as CompileNativeI18nOptions, u as I18nMessageToken } from "./configTypes-
|
|
1
|
+
import { a as I18nCompiledMessages, c as I18nLocaleFileInput, d as I18nMessageValue, f as I18nMessages, i as I18nCompileOptions, l as I18nLocaleMessages, m as I18nPlaceholderToken, n as CompileNativeI18nResult, o as I18nGlobal, p as I18nOptions, r as I18nCatalog, s as I18nLocaleChangeSubscription, t as CompileNativeI18nOptions, u as I18nMessageToken } from "./configTypes-CX-OAboL.mjs";
|
|
2
2
|
export { CompileNativeI18nOptions, CompileNativeI18nResult, I18nCatalog, I18nCompileOptions, I18nCompiledMessages, I18nGlobal, I18nLocaleChangeSubscription, I18nLocaleFileInput, I18nLocaleMessages, I18nMessageToken, I18nMessageValue, I18nMessages, I18nOptions, I18nPlaceholderToken };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/configTypes.d.ts
|
|
2
1
|
interface I18nPlaceholderToken {
|
|
3
2
|
key: string;
|
|
4
3
|
source: string;
|
|
@@ -50,5 +49,4 @@ interface CompileNativeI18nResult {
|
|
|
50
49
|
jsFile: string;
|
|
51
50
|
wxsFile: string;
|
|
52
51
|
}
|
|
53
|
-
//#endregion
|
|
54
52
|
export { I18nCompiledMessages as a, I18nLocaleFileInput as c, I18nMessageValue as d, I18nMessages as f, I18nCompileOptions as i, I18nLocaleMessages as l, I18nPlaceholderToken as m, CompileNativeI18nResult as n, I18nGlobal as o, I18nOptions as p, I18nCatalog as r, I18nLocaleChangeSubscription as s, CompileNativeI18nOptions as t, I18nMessageToken as u };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as I18nCompiledMessages, d as I18nMessageValue, f as I18nMessages, l as I18nLocaleMessages, m as I18nPlaceholderToken, o as I18nGlobal, p as I18nOptions, r as I18nCatalog, s as I18nLocaleChangeSubscription, u as I18nMessageToken } from "./configTypes-
|
|
2
|
-
import { i as I18nInstance, n as I18nBehavior, r as I18nHost, t as createI18n } from "./runtime-
|
|
1
|
+
import { a as I18nCompiledMessages, d as I18nMessageValue, f as I18nMessages, l as I18nLocaleMessages, m as I18nPlaceholderToken, o as I18nGlobal, p as I18nOptions, r as I18nCatalog, s as I18nLocaleChangeSubscription, u as I18nMessageToken } from "./configTypes-CX-OAboL.mjs";
|
|
2
|
+
import { i as I18nInstance, n as I18nBehavior, r as I18nHost, t as createI18n } from "./runtime-DvVcygw2.mjs";
|
|
3
3
|
export { type I18nBehavior, type I18nCatalog, type I18nCompiledMessages, type I18nGlobal, type I18nHost, type I18nInstance, type I18nLocaleChangeSubscription, type I18nLocaleMessages, type I18nMessageToken, type I18nMessageValue, type I18nMessages, type I18nOptions, type I18nPlaceholderToken, createI18n };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
// ../../@weapp-core/constants/dist/index.js
|
|
3
3
|
const WEAPP_I18N_LOCALE_DATA_KEY = "__wv_i18n_locale";
|
|
4
|
-
|
|
5
|
-
//#region src/compiler.ts
|
|
4
|
+
// src/compiler.ts
|
|
6
5
|
const PLACEHOLDER_PATH_RE = /^[A-Z_$][\w$]*(?:\.[A-Z_$][\w$]*)*$/i;
|
|
7
6
|
function isPlainObject(value) {
|
|
8
7
|
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
@@ -71,8 +70,7 @@ function compileI18nMessages(messages) {
|
|
|
71
70
|
}
|
|
72
71
|
return compiled;
|
|
73
72
|
}
|
|
74
|
-
|
|
75
|
-
//#region src/runtime.ts
|
|
73
|
+
// src/runtime.ts
|
|
76
74
|
function hasOwn(object, key) {
|
|
77
75
|
return object != null && Object.prototype.hasOwnProperty.call(object, key);
|
|
78
76
|
}
|
|
@@ -225,5 +223,4 @@ function createI18n(options, host) {
|
|
|
225
223
|
page: createPageAdapter(state, resolvedHost)
|
|
226
224
|
};
|
|
227
225
|
}
|
|
228
|
-
//#endregion
|
|
229
226
|
exports.createI18n = createI18n;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { o as I18nGlobal, p as I18nOptions, r as I18nCatalog } from "./configTypes-
|
|
2
|
-
//#region src/types.d.ts
|
|
1
|
+
import { o as I18nGlobal, p as I18nOptions, r as I18nCatalog } from "./configTypes-CX-OAboL.mjs";
|
|
3
2
|
type I18nBehavior = WechatMiniprogram.Behavior.Identifier<WechatMiniprogram.IAnyObject, WechatMiniprogram.IAnyObject, WechatMiniprogram.IAnyObject, []>;
|
|
4
3
|
interface I18nHost {
|
|
5
4
|
Behavior: typeof Behavior;
|
|
@@ -10,8 +9,5 @@ interface I18nInstance {
|
|
|
10
9
|
behavior: I18nBehavior;
|
|
11
10
|
page: typeof Page;
|
|
12
11
|
}
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/runtime.d.ts
|
|
15
12
|
declare function createI18n(options: I18nOptions | I18nCatalog, host?: Partial<I18nHost>): I18nInstance;
|
|
16
|
-
//#endregion
|
|
17
13
|
export { I18nInstance as i, I18nBehavior as n, I18nHost as r, createI18n as t };
|
package/dist/runtime.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { o as I18nGlobal, p as I18nOptions, r as I18nCatalog, s as I18nLocaleChangeSubscription } from "./configTypes-
|
|
2
|
-
import { i as I18nInstance, n as I18nBehavior, r as I18nHost, t as createI18n } from "./runtime-
|
|
1
|
+
import { o as I18nGlobal, p as I18nOptions, r as I18nCatalog, s as I18nLocaleChangeSubscription } from "./configTypes-CX-OAboL.mjs";
|
|
2
|
+
import { i as I18nInstance, n as I18nBehavior, r as I18nHost, t as createI18n } from "./runtime-DvVcygw2.mjs";
|
|
3
3
|
export { type I18nBehavior, type I18nCatalog, type I18nGlobal, type I18nHost, type I18nInstance, type I18nLocaleChangeSubscription, type I18nOptions, createI18n };
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as compileI18nMessages, s as WEAPP_I18N_LOCALE_DATA_KEY } from "./compiler-
|
|
2
|
-
|
|
1
|
+
import { r as compileI18nMessages, s as WEAPP_I18N_LOCALE_DATA_KEY } from "./compiler-m3fheQqP.mjs";
|
|
2
|
+
// src/runtime.ts
|
|
3
3
|
function hasOwn(object, key) {
|
|
4
4
|
return object != null && Object.prototype.hasOwnProperty.call(object, key);
|
|
5
5
|
}
|
|
@@ -149,5 +149,4 @@ function createI18n(options, host) {
|
|
|
149
149
|
page: createPageAdapter(state, resolvedHost)
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
|
-
//#endregion
|
|
153
152
|
export { createI18n };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-vite/i18n",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"description": "First-party i18n runtime and compiler for native WeChat mini programs",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/weapp-vite/weapp-vite#readme",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"dist"
|
|
60
60
|
],
|
|
61
61
|
"engines": {
|
|
62
|
-
"node": "^
|
|
62
|
+
"node": "^22.23.4 || ^24.22.1 || >=26.12.1"
|
|
63
63
|
},
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
}
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@weapp-core/constants": "0.
|
|
77
|
+
"@weapp-core/constants": "0.5.0"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"miniprogram-api-typings": "^5.2.3"
|