@powerlines/plugin-i18next 0.1.13 → 0.1.15
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/_virtual/rolldown_runtime.cjs +29 -1
- package/dist/helpers/config-utils.cjs +31 -1
- package/dist/helpers/config-utils.mjs +30 -1
- package/dist/index.cjs +117 -5
- package/dist/index.mjs +113 -5
- package/dist/powerlines/src/types/context.d.cts +43 -2
- package/dist/powerlines/src/types/context.d.mts +43 -2
- package/dist/powerlines/src/types/fs.d.cts +14 -0
- package/dist/powerlines/src/types/fs.d.mts +14 -0
- package/dist/types/i18n.mjs +1 -1
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/package.json +8 -8
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
|
@@ -1 +1,31 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __stryke_path_correct_path = require("@stryke/path/correct-path");
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/config-utils.ts
|
|
5
|
+
/**
|
|
6
|
+
* Resolve an output template (string or function) into an actual path string.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* - If `outputTemplate` is a function, call it with (language, namespace)
|
|
10
|
+
* - If it's a string, replace placeholders:
|
|
11
|
+
* - \{\{language\}\} or \{\{lng\}\} -\> language
|
|
12
|
+
* - \{\{namespace\}\} -\> namespace (or removed if namespace is undefined)
|
|
13
|
+
* - Normalizes duplicate slashes and returns a platform-correct path.
|
|
14
|
+
*/
|
|
15
|
+
function getOutputPath(outputTemplate, language, namespace) {
|
|
16
|
+
if (!outputTemplate) return (0, __stryke_path_correct_path.correctPath)(`locales/${language}/${namespace ?? "translation"}.json`);
|
|
17
|
+
if (typeof outputTemplate === "function") try {
|
|
18
|
+
return (0, __stryke_path_correct_path.correctPath)(String(outputTemplate(language, namespace)).replace(/\/{2,}/g, "/"));
|
|
19
|
+
} catch {
|
|
20
|
+
return (0, __stryke_path_correct_path.correctPath)(`locales/${language}/${namespace ?? "translation"}.json`);
|
|
21
|
+
}
|
|
22
|
+
let out = String(outputTemplate);
|
|
23
|
+
out = out.replace(/\{\{language\}\}|\{\{lng\}\}/g, language);
|
|
24
|
+
if (namespace !== void 0 && namespace !== null) out = out.replace(/\{\{namespace\}\}/g, namespace);
|
|
25
|
+
else out = out.replace(/\/?\{\{namespace\}\}/g, "");
|
|
26
|
+
out = out.replace(/\/{2,}/g, "/");
|
|
27
|
+
return (0, __stryke_path_correct_path.correctPath)(out);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
exports.getOutputPath = getOutputPath;
|
|
@@ -1 +1,30 @@
|
|
|
1
|
-
import{correctPath
|
|
1
|
+
import { correctPath } from "@stryke/path/correct-path";
|
|
2
|
+
|
|
3
|
+
//#region src/helpers/config-utils.ts
|
|
4
|
+
/**
|
|
5
|
+
* Resolve an output template (string or function) into an actual path string.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* - If `outputTemplate` is a function, call it with (language, namespace)
|
|
9
|
+
* - If it's a string, replace placeholders:
|
|
10
|
+
* - \{\{language\}\} or \{\{lng\}\} -\> language
|
|
11
|
+
* - \{\{namespace\}\} -\> namespace (or removed if namespace is undefined)
|
|
12
|
+
* - Normalizes duplicate slashes and returns a platform-correct path.
|
|
13
|
+
*/
|
|
14
|
+
function getOutputPath(outputTemplate, language, namespace) {
|
|
15
|
+
if (!outputTemplate) return correctPath(`locales/${language}/${namespace ?? "translation"}.json`);
|
|
16
|
+
if (typeof outputTemplate === "function") try {
|
|
17
|
+
return correctPath(String(outputTemplate(language, namespace)).replace(/\/{2,}/g, "/"));
|
|
18
|
+
} catch {
|
|
19
|
+
return correctPath(`locales/${language}/${namespace ?? "translation"}.json`);
|
|
20
|
+
}
|
|
21
|
+
let out = String(outputTemplate);
|
|
22
|
+
out = out.replace(/\{\{language\}\}|\{\{lng\}\}/g, language);
|
|
23
|
+
if (namespace !== void 0 && namespace !== null) out = out.replace(/\{\{namespace\}\}/g, namespace);
|
|
24
|
+
else out = out.replace(/\/?\{\{namespace\}\}/g, "");
|
|
25
|
+
out = out.replace(/\/{2,}/g, "/");
|
|
26
|
+
return correctPath(out);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { getOutputPath };
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,109 @@
|
|
|
1
|
-
Object.defineProperty(exports
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
3
|
+
const require_config_utils = require('./helpers/config-utils.cjs');
|
|
4
|
+
let __stryke_fs_list_files = require("@stryke/fs/list-files");
|
|
5
|
+
let __stryke_path_append = require("@stryke/path/append");
|
|
6
|
+
let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
7
|
+
let __stryke_path_join = require("@stryke/path/join");
|
|
8
|
+
let __stryke_type_checks_is_set = require("@stryke/type-checks/is-set");
|
|
9
|
+
let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
10
|
+
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
11
|
+
let defu = require("defu");
|
|
12
|
+
defu = require_rolldown_runtime.__toESM(defu);
|
|
13
|
+
let i18next_cli = require("i18next-cli");
|
|
14
|
+
let i18next_resources_for_ts = require("i18next-resources-for-ts");
|
|
2
15
|
|
|
3
|
-
|
|
16
|
+
//#region src/index.ts
|
|
17
|
+
/**
|
|
18
|
+
* i18next Plugin
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* A Powerlines plugin to use the i18next internationalization framework during the prepare task.
|
|
22
|
+
*
|
|
23
|
+
* @see https://i18next.com
|
|
24
|
+
*
|
|
25
|
+
* @param options - The plugin options.
|
|
26
|
+
* @returns A Powerlines plugin instance.
|
|
27
|
+
*/
|
|
28
|
+
const plugin = (options = {}) => {
|
|
29
|
+
return {
|
|
30
|
+
name: "i18next",
|
|
31
|
+
async config() {
|
|
32
|
+
const i18next = (0, defu.default)(options, { extract: {
|
|
33
|
+
output: (language, namespace = "translation") => (0, __stryke_path_join.joinPaths)(this.config.projectRoot, `locales/${language}/${namespace}.json`),
|
|
34
|
+
primaryLanguage: this.workspaceConfig.locale
|
|
35
|
+
} }, {
|
|
36
|
+
extract: {
|
|
37
|
+
input: [
|
|
38
|
+
"src/**/*.ts",
|
|
39
|
+
"src/**/*.tsx",
|
|
40
|
+
"src/**/*.js",
|
|
41
|
+
"src/**/*.jsx"
|
|
42
|
+
],
|
|
43
|
+
indentation: 2,
|
|
44
|
+
defaultNS: "translation",
|
|
45
|
+
mergeNamespaces: true,
|
|
46
|
+
nsSeparator: ":",
|
|
47
|
+
keySeparator: ".",
|
|
48
|
+
primaryLanguage: options.locales && options.locales.length > 0 ? options.locales[0] : "en"
|
|
49
|
+
},
|
|
50
|
+
types: { enableSelector: false },
|
|
51
|
+
locales: []
|
|
52
|
+
});
|
|
53
|
+
if (!i18next.locales || i18next.locales.length === 0) i18next.locales = [i18next.extract.primaryLanguage || "en"];
|
|
54
|
+
if (!(0, __stryke_type_checks_is_set.isSet)(i18next.types.indentation)) i18next.types.indentation = i18next.extract.indentation;
|
|
55
|
+
return { i18next };
|
|
56
|
+
},
|
|
57
|
+
async configResolved() {},
|
|
58
|
+
async prepare() {
|
|
59
|
+
await (0, i18next_cli.runExtractor)(this.config.i18next, {
|
|
60
|
+
isWatchMode: false,
|
|
61
|
+
isDryRun: false,
|
|
62
|
+
syncAll: true,
|
|
63
|
+
syncPrimaryWithDefaults: true
|
|
64
|
+
}, {
|
|
65
|
+
info: (message) => {
|
|
66
|
+
this.info(message);
|
|
67
|
+
},
|
|
68
|
+
warn: (message, _more) => {
|
|
69
|
+
this.warn(message);
|
|
70
|
+
},
|
|
71
|
+
error: (message) => {
|
|
72
|
+
this.error(message);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
async types(code) {
|
|
77
|
+
const resources = [];
|
|
78
|
+
for (const file of await (0, __stryke_fs_list_files.listFiles)(require_config_utils.getOutputPath(this.config.i18next.extract.output, this.config.i18next.extract.primaryLanguage, "*"))) {
|
|
79
|
+
const namespace = (0, __stryke_path_file_path_fns.findFileName)(file, { withExtension: false });
|
|
80
|
+
const parsedContent = await this.resolver.import(file);
|
|
81
|
+
if (this.config.i18next.extract.mergeNamespaces && (0, __stryke_type_checks_is_set_object.isSetObject)(parsedContent)) {
|
|
82
|
+
if (Object.keys(parsedContent).filter((k) => (0, __stryke_type_checks_is_set_object.isSetObject)(parsedContent[k])).length > 0) {
|
|
83
|
+
for (const nsName of Object.keys(parsedContent).filter((k) => (0, __stryke_type_checks_is_set_object.isSetObject)(parsedContent[k]))) resources.push({
|
|
84
|
+
name: nsName,
|
|
85
|
+
resources: parsedContent[nsName]
|
|
86
|
+
});
|
|
87
|
+
if (Object.keys(parsedContent).filter((k) => !(0, __stryke_type_checks_is_set_object.isSetObject)(parsedContent[k])).length > 0) this.warn(`The file ${file} contains top-level keys that are not objects (${Object.keys(parsedContent).filter((k) => !(0, __stryke_type_checks_is_set_object.isSetObject)(parsedContent[k])).join(", ")}). When 'mergeNamespaces' is enabled, top-level keys are treated as namespaces. These keys will be ignored.`);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
resources.push({
|
|
92
|
+
name: namespace,
|
|
93
|
+
resources: parsedContent
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
let result;
|
|
97
|
+
if (this.config.i18next.types.resourcesFile) await this.fs.write((0, __stryke_path_append.appendPath)(this.config.i18next.types.resourcesFile, this.config.i18next.types.output || this.config.projectRoot), (0, i18next_resources_for_ts.mergeResourcesAsInterface)(resources, {
|
|
98
|
+
optimize: !!this.config.i18next.types.enableSelector,
|
|
99
|
+
indentation: this.config.i18next.types.indentation
|
|
100
|
+
}));
|
|
101
|
+
else result = `${code}
|
|
102
|
+
|
|
103
|
+
${(0, i18next_resources_for_ts.mergeResourcesAsInterface)(resources, {
|
|
104
|
+
optimize: !!this.config.i18next.types.enableSelector,
|
|
105
|
+
indentation: this.config.i18next.types.indentation
|
|
106
|
+
})}
|
|
4
107
|
|
|
5
108
|
/**
|
|
6
109
|
* i18next Custom Type Options
|
|
@@ -9,9 +112,18 @@ ${(0,d.mergeResourcesAsInterface)(a,{optimize:!!this.config.i18next.types.enable
|
|
|
9
112
|
*/
|
|
10
113
|
declare module 'i18next' {
|
|
11
114
|
interface CustomTypeOptions {
|
|
12
|
-
enableSelector: ${(0,
|
|
13
|
-
defaultNS: ${this.config.i18next.extract.defaultNS
|
|
115
|
+
enableSelector: ${(0, __stryke_type_checks_is_string.isString)(this.config.i18next.types.enableSelector) ? `"${this.config.i18next.types.enableSelector}"` : this.config.i18next.types.enableSelector};
|
|
116
|
+
defaultNS: ${this.config.i18next.extract.defaultNS === false ? "false" : `'${this.config.i18next.extract.defaultNS || "translation"}'`};
|
|
14
117
|
resources: Resources;
|
|
15
118
|
}
|
|
16
119
|
}
|
|
17
|
-
|
|
120
|
+
`;
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
var src_default = plugin;
|
|
126
|
+
|
|
127
|
+
//#endregion
|
|
128
|
+
exports.default = src_default;
|
|
129
|
+
exports.plugin = plugin;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,106 @@
|
|
|
1
|
-
import{getOutputPath
|
|
1
|
+
import { getOutputPath } from "./helpers/config-utils.mjs";
|
|
2
|
+
import { listFiles } from "@stryke/fs/list-files";
|
|
3
|
+
import { appendPath } from "@stryke/path/append";
|
|
4
|
+
import { findFileName } from "@stryke/path/file-path-fns";
|
|
5
|
+
import { joinPaths } from "@stryke/path/join";
|
|
6
|
+
import { isSet } from "@stryke/type-checks/is-set";
|
|
7
|
+
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
8
|
+
import { isString } from "@stryke/type-checks/is-string";
|
|
9
|
+
import defu from "defu";
|
|
10
|
+
import { runExtractor } from "i18next-cli";
|
|
11
|
+
import { mergeResourcesAsInterface } from "i18next-resources-for-ts";
|
|
2
12
|
|
|
3
|
-
|
|
13
|
+
//#region src/index.ts
|
|
14
|
+
/**
|
|
15
|
+
* i18next Plugin
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* A Powerlines plugin to use the i18next internationalization framework during the prepare task.
|
|
19
|
+
*
|
|
20
|
+
* @see https://i18next.com
|
|
21
|
+
*
|
|
22
|
+
* @param options - The plugin options.
|
|
23
|
+
* @returns A Powerlines plugin instance.
|
|
24
|
+
*/
|
|
25
|
+
const plugin = (options = {}) => {
|
|
26
|
+
return {
|
|
27
|
+
name: "i18next",
|
|
28
|
+
async config() {
|
|
29
|
+
const i18next = defu(options, { extract: {
|
|
30
|
+
output: (language, namespace = "translation") => joinPaths(this.config.projectRoot, `locales/${language}/${namespace}.json`),
|
|
31
|
+
primaryLanguage: this.workspaceConfig.locale
|
|
32
|
+
} }, {
|
|
33
|
+
extract: {
|
|
34
|
+
input: [
|
|
35
|
+
"src/**/*.ts",
|
|
36
|
+
"src/**/*.tsx",
|
|
37
|
+
"src/**/*.js",
|
|
38
|
+
"src/**/*.jsx"
|
|
39
|
+
],
|
|
40
|
+
indentation: 2,
|
|
41
|
+
defaultNS: "translation",
|
|
42
|
+
mergeNamespaces: true,
|
|
43
|
+
nsSeparator: ":",
|
|
44
|
+
keySeparator: ".",
|
|
45
|
+
primaryLanguage: options.locales && options.locales.length > 0 ? options.locales[0] : "en"
|
|
46
|
+
},
|
|
47
|
+
types: { enableSelector: false },
|
|
48
|
+
locales: []
|
|
49
|
+
});
|
|
50
|
+
if (!i18next.locales || i18next.locales.length === 0) i18next.locales = [i18next.extract.primaryLanguage || "en"];
|
|
51
|
+
if (!isSet(i18next.types.indentation)) i18next.types.indentation = i18next.extract.indentation;
|
|
52
|
+
return { i18next };
|
|
53
|
+
},
|
|
54
|
+
async configResolved() {},
|
|
55
|
+
async prepare() {
|
|
56
|
+
await runExtractor(this.config.i18next, {
|
|
57
|
+
isWatchMode: false,
|
|
58
|
+
isDryRun: false,
|
|
59
|
+
syncAll: true,
|
|
60
|
+
syncPrimaryWithDefaults: true
|
|
61
|
+
}, {
|
|
62
|
+
info: (message) => {
|
|
63
|
+
this.info(message);
|
|
64
|
+
},
|
|
65
|
+
warn: (message, _more) => {
|
|
66
|
+
this.warn(message);
|
|
67
|
+
},
|
|
68
|
+
error: (message) => {
|
|
69
|
+
this.error(message);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
async types(code) {
|
|
74
|
+
const resources = [];
|
|
75
|
+
for (const file of await listFiles(getOutputPath(this.config.i18next.extract.output, this.config.i18next.extract.primaryLanguage, "*"))) {
|
|
76
|
+
const namespace = findFileName(file, { withExtension: false });
|
|
77
|
+
const parsedContent = await this.resolver.import(file);
|
|
78
|
+
if (this.config.i18next.extract.mergeNamespaces && isSetObject(parsedContent)) {
|
|
79
|
+
if (Object.keys(parsedContent).filter((k) => isSetObject(parsedContent[k])).length > 0) {
|
|
80
|
+
for (const nsName of Object.keys(parsedContent).filter((k) => isSetObject(parsedContent[k]))) resources.push({
|
|
81
|
+
name: nsName,
|
|
82
|
+
resources: parsedContent[nsName]
|
|
83
|
+
});
|
|
84
|
+
if (Object.keys(parsedContent).filter((k) => !isSetObject(parsedContent[k])).length > 0) this.warn(`The file ${file} contains top-level keys that are not objects (${Object.keys(parsedContent).filter((k) => !isSetObject(parsedContent[k])).join(", ")}). When 'mergeNamespaces' is enabled, top-level keys are treated as namespaces. These keys will be ignored.`);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
resources.push({
|
|
89
|
+
name: namespace,
|
|
90
|
+
resources: parsedContent
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
let result;
|
|
94
|
+
if (this.config.i18next.types.resourcesFile) await this.fs.write(appendPath(this.config.i18next.types.resourcesFile, this.config.i18next.types.output || this.config.projectRoot), mergeResourcesAsInterface(resources, {
|
|
95
|
+
optimize: !!this.config.i18next.types.enableSelector,
|
|
96
|
+
indentation: this.config.i18next.types.indentation
|
|
97
|
+
}));
|
|
98
|
+
else result = `${code}
|
|
99
|
+
|
|
100
|
+
${mergeResourcesAsInterface(resources, {
|
|
101
|
+
optimize: !!this.config.i18next.types.enableSelector,
|
|
102
|
+
indentation: this.config.i18next.types.indentation
|
|
103
|
+
})}
|
|
4
104
|
|
|
5
105
|
/**
|
|
6
106
|
* i18next Custom Type Options
|
|
@@ -9,9 +109,17 @@ ${u(a,{optimize:!!this.config.i18next.types.enableSelector,indentation:this.conf
|
|
|
9
109
|
*/
|
|
10
110
|
declare module 'i18next' {
|
|
11
111
|
interface CustomTypeOptions {
|
|
12
|
-
enableSelector: ${
|
|
13
|
-
defaultNS: ${this.config.i18next.extract.defaultNS
|
|
112
|
+
enableSelector: ${isString(this.config.i18next.types.enableSelector) ? `"${this.config.i18next.types.enableSelector}"` : this.config.i18next.types.enableSelector};
|
|
113
|
+
defaultNS: ${this.config.i18next.extract.defaultNS === false ? "false" : `'${this.config.i18next.extract.defaultNS || "translation"}'`};
|
|
14
114
|
resources: Resources;
|
|
15
115
|
}
|
|
16
116
|
}
|
|
17
|
-
|
|
117
|
+
`;
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
var src_default = plugin;
|
|
123
|
+
|
|
124
|
+
//#endregion
|
|
125
|
+
export { src_default as default, plugin };
|
|
@@ -78,10 +78,18 @@ interface ParseOptions extends ParserOptions {
|
|
|
78
78
|
*/
|
|
79
79
|
allowReturnOutsideFunction?: boolean;
|
|
80
80
|
}
|
|
81
|
+
interface EmitOptions extends WriteOptions {
|
|
82
|
+
/**
|
|
83
|
+
* If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
|
|
84
|
+
*/
|
|
85
|
+
emitWithBundler?: boolean;
|
|
86
|
+
needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
|
|
87
|
+
originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
|
|
88
|
+
}
|
|
81
89
|
/**
|
|
82
90
|
* Options for emitting entry virtual files
|
|
83
91
|
*/
|
|
84
|
-
type EmitEntryOptions =
|
|
92
|
+
type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
|
|
85
93
|
/**
|
|
86
94
|
* The unresolved Powerlines context.
|
|
87
95
|
*
|
|
@@ -292,6 +300,22 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
292
300
|
* The Powerlines builtin virtual files
|
|
293
301
|
*/
|
|
294
302
|
getBuiltins: () => Promise<VirtualFile[]>;
|
|
303
|
+
/**
|
|
304
|
+
* Resolves a file and writes it to the VFS if it does not already exist
|
|
305
|
+
*
|
|
306
|
+
* @param code - The source code of the file
|
|
307
|
+
* @param path - The path to write the file to
|
|
308
|
+
* @param options - Additional options for writing the file
|
|
309
|
+
*/
|
|
310
|
+
emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
|
|
311
|
+
/**
|
|
312
|
+
* Synchronously resolves a file and writes it to the VFS if it does not already exist
|
|
313
|
+
*
|
|
314
|
+
* @param code - The source code of the file
|
|
315
|
+
* @param path - The path to write the file to
|
|
316
|
+
* @param options - Additional options for writing the file
|
|
317
|
+
*/
|
|
318
|
+
emitSync: (code: string, path: string, options?: EmitOptions) => void;
|
|
295
319
|
/**
|
|
296
320
|
* Resolves a builtin virtual file and writes it to the VFS if it does not already exist
|
|
297
321
|
*
|
|
@@ -300,7 +324,16 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
300
324
|
* @param path - An optional path to write the builtin file to
|
|
301
325
|
* @param options - Additional options for writing the builtin file
|
|
302
326
|
*/
|
|
303
|
-
emitBuiltin: (code: string, id: string, path?: string, options?:
|
|
327
|
+
emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
|
|
328
|
+
/**
|
|
329
|
+
* Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
|
|
330
|
+
*
|
|
331
|
+
* @param code - The source code of the builtin file
|
|
332
|
+
* @param id - The unique identifier of the builtin file
|
|
333
|
+
* @param path - An optional path to write the builtin file to
|
|
334
|
+
* @param options - Additional options for writing the builtin file
|
|
335
|
+
*/
|
|
336
|
+
emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
|
|
304
337
|
/**
|
|
305
338
|
* Resolves a entry virtual file and writes it to the VFS if it does not already exist
|
|
306
339
|
*
|
|
@@ -309,6 +342,14 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
309
342
|
* @param options - Additional options for writing the entry file
|
|
310
343
|
*/
|
|
311
344
|
emitEntry: (code: string, path: string, options?: EmitEntryOptions) => Promise<void>;
|
|
345
|
+
/**
|
|
346
|
+
* Synchronously resolves a entry virtual file and writes it to the VFS if it does not already exist
|
|
347
|
+
*
|
|
348
|
+
* @param code - The source code of the entry file
|
|
349
|
+
* @param path - An optional path to write the entry file to
|
|
350
|
+
* @param options - Additional options for writing the entry file
|
|
351
|
+
*/
|
|
352
|
+
emitEntrySync: (code: string, path: string, options?: EmitEntryOptions) => void;
|
|
312
353
|
/**
|
|
313
354
|
* A function to update the context fields using a new user configuration options
|
|
314
355
|
*/
|
|
@@ -78,10 +78,18 @@ interface ParseOptions extends ParserOptions {
|
|
|
78
78
|
*/
|
|
79
79
|
allowReturnOutsideFunction?: boolean;
|
|
80
80
|
}
|
|
81
|
+
interface EmitOptions extends WriteOptions {
|
|
82
|
+
/**
|
|
83
|
+
* If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
|
|
84
|
+
*/
|
|
85
|
+
emitWithBundler?: boolean;
|
|
86
|
+
needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
|
|
87
|
+
originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
|
|
88
|
+
}
|
|
81
89
|
/**
|
|
82
90
|
* Options for emitting entry virtual files
|
|
83
91
|
*/
|
|
84
|
-
type EmitEntryOptions =
|
|
92
|
+
type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
|
|
85
93
|
/**
|
|
86
94
|
* The unresolved Powerlines context.
|
|
87
95
|
*
|
|
@@ -292,6 +300,22 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
292
300
|
* The Powerlines builtin virtual files
|
|
293
301
|
*/
|
|
294
302
|
getBuiltins: () => Promise<VirtualFile[]>;
|
|
303
|
+
/**
|
|
304
|
+
* Resolves a file and writes it to the VFS if it does not already exist
|
|
305
|
+
*
|
|
306
|
+
* @param code - The source code of the file
|
|
307
|
+
* @param path - The path to write the file to
|
|
308
|
+
* @param options - Additional options for writing the file
|
|
309
|
+
*/
|
|
310
|
+
emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
|
|
311
|
+
/**
|
|
312
|
+
* Synchronously resolves a file and writes it to the VFS if it does not already exist
|
|
313
|
+
*
|
|
314
|
+
* @param code - The source code of the file
|
|
315
|
+
* @param path - The path to write the file to
|
|
316
|
+
* @param options - Additional options for writing the file
|
|
317
|
+
*/
|
|
318
|
+
emitSync: (code: string, path: string, options?: EmitOptions) => void;
|
|
295
319
|
/**
|
|
296
320
|
* Resolves a builtin virtual file and writes it to the VFS if it does not already exist
|
|
297
321
|
*
|
|
@@ -300,7 +324,16 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
300
324
|
* @param path - An optional path to write the builtin file to
|
|
301
325
|
* @param options - Additional options for writing the builtin file
|
|
302
326
|
*/
|
|
303
|
-
emitBuiltin: (code: string, id: string, path?: string, options?:
|
|
327
|
+
emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
|
|
328
|
+
/**
|
|
329
|
+
* Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
|
|
330
|
+
*
|
|
331
|
+
* @param code - The source code of the builtin file
|
|
332
|
+
* @param id - The unique identifier of the builtin file
|
|
333
|
+
* @param path - An optional path to write the builtin file to
|
|
334
|
+
* @param options - Additional options for writing the builtin file
|
|
335
|
+
*/
|
|
336
|
+
emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
|
|
304
337
|
/**
|
|
305
338
|
* Resolves a entry virtual file and writes it to the VFS if it does not already exist
|
|
306
339
|
*
|
|
@@ -309,6 +342,14 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
|
|
|
309
342
|
* @param options - Additional options for writing the entry file
|
|
310
343
|
*/
|
|
311
344
|
emitEntry: (code: string, path: string, options?: EmitEntryOptions) => Promise<void>;
|
|
345
|
+
/**
|
|
346
|
+
* Synchronously resolves a entry virtual file and writes it to the VFS if it does not already exist
|
|
347
|
+
*
|
|
348
|
+
* @param code - The source code of the entry file
|
|
349
|
+
* @param path - An optional path to write the entry file to
|
|
350
|
+
* @param options - Additional options for writing the entry file
|
|
351
|
+
*/
|
|
352
|
+
emitEntrySync: (code: string, path: string, options?: EmitEntryOptions) => void;
|
|
312
353
|
/**
|
|
313
354
|
* A function to update the context fields using a new user configuration options
|
|
314
355
|
*/
|
|
@@ -13,6 +13,13 @@ interface StorageAdapter {
|
|
|
13
13
|
* A name identifying the storage adapter type.
|
|
14
14
|
*/
|
|
15
15
|
name: string;
|
|
16
|
+
/**
|
|
17
|
+
* The storage preset for the adapter.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* This can be used as an alternate way to identify the type of storage being used.
|
|
21
|
+
*/
|
|
22
|
+
preset?: StoragePreset | null;
|
|
16
23
|
/**
|
|
17
24
|
* Checks if a key exists in the storage.
|
|
18
25
|
*
|
|
@@ -207,6 +214,13 @@ interface WriteOptions {
|
|
|
207
214
|
* @defaultValue false
|
|
208
215
|
*/
|
|
209
216
|
skipFormat?: boolean;
|
|
217
|
+
/**
|
|
218
|
+
* The storage preset or adapter name for the output file.
|
|
219
|
+
*
|
|
220
|
+
* @remarks
|
|
221
|
+
* If not specified, the output mode will be determined by the provided `output.mode` value.
|
|
222
|
+
*/
|
|
223
|
+
storage?: StoragePreset | string;
|
|
210
224
|
/**
|
|
211
225
|
* Additional metadata for the file.
|
|
212
226
|
*/
|
|
@@ -13,6 +13,13 @@ interface StorageAdapter {
|
|
|
13
13
|
* A name identifying the storage adapter type.
|
|
14
14
|
*/
|
|
15
15
|
name: string;
|
|
16
|
+
/**
|
|
17
|
+
* The storage preset for the adapter.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* This can be used as an alternate way to identify the type of storage being used.
|
|
21
|
+
*/
|
|
22
|
+
preset?: StoragePreset | null;
|
|
16
23
|
/**
|
|
17
24
|
* Checks if a key exists in the storage.
|
|
18
25
|
*
|
|
@@ -207,6 +214,13 @@ interface WriteOptions {
|
|
|
207
214
|
* @defaultValue false
|
|
208
215
|
*/
|
|
209
216
|
skipFormat?: boolean;
|
|
217
|
+
/**
|
|
218
|
+
* The storage preset or adapter name for the output file.
|
|
219
|
+
*
|
|
220
|
+
* @remarks
|
|
221
|
+
* If not specified, the output mode will be determined by the provided `output.mode` value.
|
|
222
|
+
*/
|
|
223
|
+
storage?: StoragePreset | string;
|
|
210
224
|
/**
|
|
211
225
|
* Additional metadata for the file.
|
|
212
226
|
*/
|
package/dist/types/i18n.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export { };
|
package/dist/types/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export { };
|
package/dist/types/plugin.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-i18next",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A Powerlines plugin to use i18next for internationalization.",
|
|
6
6
|
"repository": {
|
|
@@ -117,19 +117,19 @@
|
|
|
117
117
|
"files": ["dist/**/*"],
|
|
118
118
|
"keywords": ["i18next", "powerlines", "storm-software", "powerlines-plugin"],
|
|
119
119
|
"dependencies": {
|
|
120
|
-
"@stryke/fs": "^0.33.
|
|
121
|
-
"@stryke/path": "^0.24.
|
|
122
|
-
"@stryke/types": "^0.10.
|
|
120
|
+
"@stryke/fs": "^0.33.27",
|
|
121
|
+
"@stryke/path": "^0.24.1",
|
|
122
|
+
"@stryke/types": "^0.10.29",
|
|
123
123
|
"defu": "^6.1.4",
|
|
124
|
-
"powerlines": "^0.36.
|
|
124
|
+
"powerlines": "^0.36.23"
|
|
125
125
|
},
|
|
126
126
|
"devDependencies": {
|
|
127
|
-
"@powerlines/nx": "^0.11.
|
|
128
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
127
|
+
"@powerlines/nx": "^0.11.49",
|
|
128
|
+
"@powerlines/plugin-plugin": "^0.12.70",
|
|
129
129
|
"@types/node": "^24.10.4",
|
|
130
130
|
"i18next-cli": "^1.33.5",
|
|
131
131
|
"i18next-resources-for-ts": "^2.0.0"
|
|
132
132
|
},
|
|
133
133
|
"publishConfig": { "access": "public" },
|
|
134
|
-
"gitHead": "
|
|
134
|
+
"gitHead": "be47e546b48b9a82e460b5c5d4f02fb66e821f18"
|
|
135
135
|
}
|