@weapp-vite/i18n 0.2.9 → 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 -3
- package/dist/cjs/runtime.cjs +1 -2
- package/dist/cli.mjs +1 -2
- package/dist/{compiler2.mjs → compiler-m3fheQqP.mjs} +2 -3
- package/dist/compiler.d.mts +1 -5
- package/dist/compiler.mjs +2 -3
- package/dist/config-types.d.mts +2 -0
- package/dist/config-types.mjs +1 -0
- package/dist/{types.d.mts → configTypes-CX-OAboL.d.mts} +1 -13
- package/dist/index.d.mts +2 -2
- package/dist/miniprogram/index.js +3 -5
- package/dist/runtime-DvVcygw2.d.mts +13 -0
- package/dist/runtime.d.mts +3 -5
- package/dist/runtime.mjs +2 -3
- package/package.json +10 -6
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,7 +1,7 @@
|
|
|
1
|
+
// ../../@weapp-core/constants/dist/index.js
|
|
1
2
|
const WEAPP_I18N_RUNTIME_MARKER = "__WEAPP_VITE_I18N__";
|
|
2
3
|
const WEAPP_I18N_LOCALE_DATA_KEY = "__wv_i18n_locale";
|
|
3
|
-
|
|
4
|
-
//#region src/compiler.ts
|
|
4
|
+
// src/compiler.ts
|
|
5
5
|
const PLACEHOLDER_PATH_RE = /^[A-Z_$][\w$]*(?:\.[A-Z_$][\w$]*)*$/i;
|
|
6
6
|
function isPlainObject(value) {
|
|
7
7
|
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
@@ -145,7 +145,6 @@ export const behavior = i18n.behavior
|
|
|
145
145
|
export const page = i18n.page
|
|
146
146
|
`;
|
|
147
147
|
}
|
|
148
|
-
//#endregion
|
|
149
148
|
Object.defineProperty(exports, "WEAPP_I18N_LOCALE_DATA_KEY", {
|
|
150
149
|
enumerable: true,
|
|
151
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,7 +1,7 @@
|
|
|
1
|
+
// ../../@weapp-core/constants/dist/index.js
|
|
1
2
|
const WEAPP_I18N_RUNTIME_MARKER = "__WEAPP_VITE_I18N__";
|
|
2
3
|
const WEAPP_I18N_LOCALE_DATA_KEY = "__wv_i18n_locale";
|
|
3
|
-
|
|
4
|
-
//#region src/compiler.ts
|
|
4
|
+
// src/compiler.ts
|
|
5
5
|
const PLACEHOLDER_PATH_RE = /^[A-Z_$][\w$]*(?:\.[A-Z_$][\w$]*)*$/i;
|
|
6
6
|
function isPlainObject(value) {
|
|
7
7
|
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
@@ -145,5 +145,4 @@ export const behavior = i18n.behavior
|
|
|
145
145
|
export const page = i18n.page
|
|
146
146
|
`;
|
|
147
147
|
}
|
|
148
|
-
//#endregion
|
|
149
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 {
|
|
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 "./
|
|
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 };
|
|
@@ -0,0 +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-CX-OAboL.mjs";
|
|
2
|
+
export { CompileNativeI18nOptions, CompileNativeI18nResult, I18nCatalog, I18nCompileOptions, I18nCompiledMessages, I18nGlobal, I18nLocaleChangeSubscription, I18nLocaleFileInput, I18nLocaleMessages, I18nMessageToken, I18nMessageValue, I18nMessages, I18nOptions, I18nPlaceholderToken };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/types.d.ts
|
|
2
1
|
interface I18nPlaceholderToken {
|
|
3
2
|
key: string;
|
|
4
3
|
source: string;
|
|
@@ -33,7 +32,6 @@ interface I18nCompileOptions {
|
|
|
33
32
|
interface I18nLocaleChangeSubscription {
|
|
34
33
|
off: () => void;
|
|
35
34
|
}
|
|
36
|
-
type I18nBehavior = WechatMiniprogram.Behavior.Identifier<WechatMiniprogram.IAnyObject, WechatMiniprogram.IAnyObject, WechatMiniprogram.IAnyObject, []>;
|
|
37
35
|
interface I18nGlobal {
|
|
38
36
|
t: (key: string, params?: Record<string, unknown>) => string;
|
|
39
37
|
locale: string;
|
|
@@ -41,15 +39,6 @@ interface I18nGlobal {
|
|
|
41
39
|
readonly availableLocales: readonly string[];
|
|
42
40
|
onLocaleChange: (handler: (locale: string) => void) => I18nLocaleChangeSubscription;
|
|
43
41
|
}
|
|
44
|
-
interface I18nHost {
|
|
45
|
-
Behavior: typeof Behavior;
|
|
46
|
-
Page: typeof Page;
|
|
47
|
-
}
|
|
48
|
-
interface I18nInstance {
|
|
49
|
-
global: I18nGlobal;
|
|
50
|
-
behavior: I18nBehavior;
|
|
51
|
-
page: typeof Page;
|
|
52
|
-
}
|
|
53
42
|
interface CompileNativeI18nOptions extends I18nCompileOptions {
|
|
54
43
|
outDir?: string;
|
|
55
44
|
srcRoot: string;
|
|
@@ -60,5 +49,4 @@ interface CompileNativeI18nResult {
|
|
|
60
49
|
jsFile: string;
|
|
61
50
|
wxsFile: string;
|
|
62
51
|
}
|
|
63
|
-
|
|
64
|
-
export { I18nPlaceholderToken as _, I18nCompileOptions as a, I18nHost as c, I18nLocaleFileInput as d, I18nLocaleMessages as f, I18nOptions as g, I18nMessages as h, I18nCatalog as i, I18nInstance as l, I18nMessageValue as m, CompileNativeI18nResult as n, I18nCompiledMessages as o, I18nMessageToken as p, I18nBehavior as r, I18nGlobal as s, CompileNativeI18nOptions as t, I18nLocaleChangeSubscription as u };
|
|
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 {
|
|
2
|
-
import { createI18n } from "./runtime.mjs";
|
|
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,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
// ../../@weapp-core/constants/dist/index.js
|
|
2
3
|
const WEAPP_I18N_LOCALE_DATA_KEY = "__wv_i18n_locale";
|
|
3
|
-
|
|
4
|
-
//#region src/compiler.ts
|
|
4
|
+
// src/compiler.ts
|
|
5
5
|
const PLACEHOLDER_PATH_RE = /^[A-Z_$][\w$]*(?:\.[A-Z_$][\w$]*)*$/i;
|
|
6
6
|
function isPlainObject(value) {
|
|
7
7
|
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
@@ -70,8 +70,7 @@ function compileI18nMessages(messages) {
|
|
|
70
70
|
}
|
|
71
71
|
return compiled;
|
|
72
72
|
}
|
|
73
|
-
|
|
74
|
-
//#region src/runtime.ts
|
|
73
|
+
// src/runtime.ts
|
|
75
74
|
function hasOwn(object, key) {
|
|
76
75
|
return object != null && Object.prototype.hasOwnProperty.call(object, key);
|
|
77
76
|
}
|
|
@@ -224,5 +223,4 @@ function createI18n(options, host) {
|
|
|
224
223
|
page: createPageAdapter(state, resolvedHost)
|
|
225
224
|
};
|
|
226
225
|
}
|
|
227
|
-
//#endregion
|
|
228
226
|
exports.createI18n = createI18n;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { o as I18nGlobal, p as I18nOptions, r as I18nCatalog } from "./configTypes-CX-OAboL.mjs";
|
|
2
|
+
type I18nBehavior = WechatMiniprogram.Behavior.Identifier<WechatMiniprogram.IAnyObject, WechatMiniprogram.IAnyObject, WechatMiniprogram.IAnyObject, []>;
|
|
3
|
+
interface I18nHost {
|
|
4
|
+
Behavior: typeof Behavior;
|
|
5
|
+
Page: typeof Page;
|
|
6
|
+
}
|
|
7
|
+
interface I18nInstance {
|
|
8
|
+
global: I18nGlobal;
|
|
9
|
+
behavior: I18nBehavior;
|
|
10
|
+
page: typeof Page;
|
|
11
|
+
}
|
|
12
|
+
declare function createI18n(options: I18nOptions | I18nCatalog, host?: Partial<I18nHost>): I18nInstance;
|
|
13
|
+
export { I18nInstance as i, I18nBehavior as n, I18nHost as r, createI18n as t };
|
package/dist/runtime.d.mts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
//#endregion
|
|
5
|
-
export type { I18nBehavior, I18nCatalog, I18nGlobal, I18nHost, I18nInstance, I18nLocaleChangeSubscription, I18nOptions };
|
|
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
|
+
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 "./
|
|
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",
|
|
@@ -41,7 +41,10 @@
|
|
|
41
41
|
"import": "./dist/compiler.mjs",
|
|
42
42
|
"require": "./dist/cjs/compiler.cjs"
|
|
43
43
|
},
|
|
44
|
-
"./package.json": "./package.json"
|
|
44
|
+
"./package.json": "./package.json",
|
|
45
|
+
"./types": {
|
|
46
|
+
"types": "./dist/config-types.d.mts"
|
|
47
|
+
}
|
|
45
48
|
},
|
|
46
49
|
"main": "./dist/cjs/index.cjs",
|
|
47
50
|
"module": "./dist/index.mjs",
|
|
@@ -56,7 +59,7 @@
|
|
|
56
59
|
"dist"
|
|
57
60
|
],
|
|
58
61
|
"engines": {
|
|
59
|
-
"node": "^
|
|
62
|
+
"node": "^22.23.4 || ^24.22.1 || >=26.12.1"
|
|
60
63
|
},
|
|
61
64
|
"publishConfig": {
|
|
62
65
|
"access": "public",
|
|
@@ -71,7 +74,7 @@
|
|
|
71
74
|
}
|
|
72
75
|
},
|
|
73
76
|
"dependencies": {
|
|
74
|
-
"@weapp-core/constants": "0.
|
|
77
|
+
"@weapp-core/constants": "0.5.0"
|
|
75
78
|
},
|
|
76
79
|
"devDependencies": {
|
|
77
80
|
"miniprogram-api-typings": "^5.2.3"
|
|
@@ -88,9 +91,10 @@
|
|
|
88
91
|
"build": "tsdown",
|
|
89
92
|
"test": "vitest run",
|
|
90
93
|
"test:types": "pnpm build && pnpm run test:types:check",
|
|
91
|
-
"test:types:check": "tsd --files \"test-d/**/*.test-d.ts\"",
|
|
94
|
+
"test:types:check": "tsd --files \"test-d/**/*.test-d.ts\" && pnpm run test:types:pure",
|
|
92
95
|
"typecheck": "tsc --noEmit",
|
|
93
96
|
"lint": "eslint .",
|
|
94
|
-
"lint:fix": "eslint . --fix"
|
|
97
|
+
"lint:fix": "eslint . --fix",
|
|
98
|
+
"test:types:pure": "cd test-d-pure && tsd --files \"**/*.test-d.ts\""
|
|
95
99
|
}
|
|
96
100
|
}
|