@powerlines/plugin-i18next 0.1.149 → 0.1.150

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/index.cjs CHANGED
@@ -39,7 +39,7 @@ let i18next_cli = require("i18next-cli");
39
39
  let i18next_resources_for_ts = require("i18next-resources-for-ts");
40
40
  let __stryke_path_correct_path = require("@stryke/path/correct-path");
41
41
 
42
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/get-object-tag.mjs
42
+ //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/get-object-tag.mjs
43
43
  /**
44
44
  * Gets the `toStringTag` of `obj`.
45
45
  *
@@ -52,7 +52,7 @@ const getObjectTag = (value) => {
52
52
  };
53
53
 
54
54
  //#endregion
55
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-plain-object.mjs
55
+ //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-plain-object.mjs
56
56
  /**
57
57
  * Checks if `value` is object-like. A value is object-like if it's not `null`
58
58
  * and has a `typeof` result of "object".
@@ -112,7 +112,7 @@ const isPlainObject = (obj) => {
112
112
  };
113
113
 
114
114
  //#endregion
115
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-null.mjs
115
+ //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-null.mjs
116
116
  const isNull = (value) => {
117
117
  try {
118
118
  return value === null;
@@ -122,13 +122,13 @@ const isNull = (value) => {
122
122
  };
123
123
 
124
124
  //#endregion
125
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-undefined.mjs
125
+ //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-undefined.mjs
126
126
  const isUndefined = (value) => {
127
127
  return value === void 0;
128
128
  };
129
129
 
130
130
  //#endregion
131
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-empty.mjs
131
+ //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-empty.mjs
132
132
  /**
133
133
  * Check if the provided value's type is `null` or `undefined`
134
134
  *
@@ -144,7 +144,7 @@ const isEmpty = (value) => {
144
144
  };
145
145
 
146
146
  //#endregion
147
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-set.mjs
147
+ //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-set.mjs
148
148
  /**
149
149
  * The inverse of the `isEmpty` function
150
150
  *
@@ -160,7 +160,7 @@ const isSet = (value) => {
160
160
  };
161
161
 
162
162
  //#endregion
163
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-object.mjs
163
+ //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-object.mjs
164
164
  /**
165
165
  * Check if the provided value's type is `Object`
166
166
  *
@@ -176,7 +176,7 @@ const isObject = (value) => {
176
176
  };
177
177
 
178
178
  //#endregion
179
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-non-null-object.mjs
179
+ //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-non-null-object.mjs
180
180
  /**
181
181
  * Check if the provided value's type is `Object` and is not `null` or `undefined`
182
182
  *
@@ -188,7 +188,7 @@ const isNonNullObject = (value) => {
188
188
  };
189
189
 
190
190
  //#endregion
191
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-set-object.mjs
191
+ //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-set-object.mjs
192
192
  /**
193
193
  * Check if the provided value's type is an object with some fields set
194
194
  *
@@ -204,7 +204,7 @@ const isSetObject = (value) => {
204
204
  };
205
205
 
206
206
  //#endregion
207
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-string.mjs
207
+ //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-string.mjs
208
208
  const isString = (value) => {
209
209
  try {
210
210
  return typeof value === "string";
package/dist/index.mjs CHANGED
@@ -10,7 +10,7 @@ import { runExtractor } from "i18next-cli";
10
10
  import { mergeResourcesAsInterface } from "i18next-resources-for-ts";
11
11
  import { correctPath } from "@stryke/path/correct-path";
12
12
 
13
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/get-object-tag.mjs
13
+ //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/get-object-tag.mjs
14
14
  /**
15
15
  * Gets the `toStringTag` of `obj`.
16
16
  *
@@ -23,7 +23,7 @@ const getObjectTag = (value) => {
23
23
  };
24
24
 
25
25
  //#endregion
26
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-plain-object.mjs
26
+ //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-plain-object.mjs
27
27
  /**
28
28
  * Checks if `value` is object-like. A value is object-like if it's not `null`
29
29
  * and has a `typeof` result of "object".
@@ -83,7 +83,7 @@ const isPlainObject = (obj) => {
83
83
  };
84
84
 
85
85
  //#endregion
86
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-null.mjs
86
+ //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-null.mjs
87
87
  const isNull = (value) => {
88
88
  try {
89
89
  return value === null;
@@ -93,13 +93,13 @@ const isNull = (value) => {
93
93
  };
94
94
 
95
95
  //#endregion
96
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-undefined.mjs
96
+ //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-undefined.mjs
97
97
  const isUndefined = (value) => {
98
98
  return value === void 0;
99
99
  };
100
100
 
101
101
  //#endregion
102
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-empty.mjs
102
+ //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-empty.mjs
103
103
  /**
104
104
  * Check if the provided value's type is `null` or `undefined`
105
105
  *
@@ -115,7 +115,7 @@ const isEmpty = (value) => {
115
115
  };
116
116
 
117
117
  //#endregion
118
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-set.mjs
118
+ //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-set.mjs
119
119
  /**
120
120
  * The inverse of the `isEmpty` function
121
121
  *
@@ -131,7 +131,7 @@ const isSet = (value) => {
131
131
  };
132
132
 
133
133
  //#endregion
134
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-object.mjs
134
+ //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-object.mjs
135
135
  /**
136
136
  * Check if the provided value's type is `Object`
137
137
  *
@@ -147,7 +147,7 @@ const isObject = (value) => {
147
147
  };
148
148
 
149
149
  //#endregion
150
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-non-null-object.mjs
150
+ //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-non-null-object.mjs
151
151
  /**
152
152
  * Check if the provided value's type is `Object` and is not `null` or `undefined`
153
153
  *
@@ -159,7 +159,7 @@ const isNonNullObject = (value) => {
159
159
  };
160
160
 
161
161
  //#endregion
162
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-set-object.mjs
162
+ //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-set-object.mjs
163
163
  /**
164
164
  * Check if the provided value's type is an object with some fields set
165
165
  *
@@ -175,7 +175,7 @@ const isSetObject = (value) => {
175
175
  };
176
176
 
177
177
  //#endregion
178
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-string.mjs
178
+ //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-string.mjs
179
179
  const isString = (value) => {
180
180
  try {
181
181
  return typeof value === "string";
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["resources: Resource[]","result!: string"],"sources":["../../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/get-object-tag.mjs","../../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-plain-object.mjs","../../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-null.mjs","../../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-undefined.mjs","../../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-empty.mjs","../../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-set.mjs","../../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-object.mjs","../../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-non-null-object.mjs","../../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-set-object.mjs","../../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-string.mjs","../src/helpers/config-utils.ts","../src/index.ts"],"sourcesContent":["//#region src/get-object-tag.ts\n/**\n* Gets the `toStringTag` of `obj`.\n*\n* @param value - The obj to query.\n* @returns Returns the `toStringTag`.\n*/\nconst getObjectTag = (value) => {\n\tif (value == null) return value === void 0 ? \"[object Undefined]\" : \"[object Null]\";\n\treturn Object.prototype.toString.call(value);\n};\n\n//#endregion\nexport { getObjectTag };\n//# sourceMappingURL=get-object-tag.mjs.map","import { getObjectTag } from \"./get-object-tag.mjs\";\n\n//#region src/is-plain-object.ts\n/**\n* Checks if `value` is object-like. A value is object-like if it's not `null`\n* and has a `typeof` result of \"object\".\n*\n* @example\n* ```typescript\n* isObjectLike({})\n* // => true\n*\n* isObjectLike([1, 2, 3])\n* // => true\n*\n* isObjectLike(Function)\n* // => false\n*\n* isObjectLike(null)\n* // => false\n* ```\n*\n* @param value - The value to check.\n* @returns Returns `true` if `value` is object-like, else `false`.\n*/\nconst isObjectLike = (obj) => {\n\treturn typeof obj === \"object\" && obj !== null;\n};\n/**\n* Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.\n*\n* @example\n* ```typescript\n* function Foo() {\n* this.a = 1\n* }\n*\n* isPlainObject(new Foo)\n* // => false\n*\n* isPlainObject([1, 2, 3])\n* // => false\n*\n* isPlainObject({ 'x': 0, 'y': 0 })\n* // => true\n*\n* isPlainObject(Object.create(null))\n* // => true\n* ```\n*\n* @param obj - The value to check.\n* @returns Returns `true` if `obj` is a plain object, else `false`.\n*/\nconst isPlainObject = (obj) => {\n\tif (!isObjectLike(obj) || getObjectTag(obj) !== \"[object Object]\") return false;\n\tif (Object.getPrototypeOf(obj) === null) return true;\n\tlet proto = obj;\n\twhile (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);\n\treturn Object.getPrototypeOf(obj) === proto;\n};\n\n//#endregion\nexport { isObjectLike, isPlainObject };\n//# sourceMappingURL=is-plain-object.mjs.map","//#region src/is-null.ts\nconst isNull = (value) => {\n\ttry {\n\t\treturn value === null;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\n//#endregion\nexport { isNull };\n//# sourceMappingURL=is-null.mjs.map","//#region src/is-undefined.ts\nconst isUndefined = (value) => {\n\treturn value === void 0;\n};\n\n//#endregion\nexport { isUndefined };\n//# sourceMappingURL=is-undefined.mjs.map","import { isDate } from \"./is-date.mjs\";\nimport { isFunction } from \"./is-function.mjs\";\nimport { isNull } from \"./is-null.mjs\";\nimport { isNumber } from \"./is-number.mjs\";\nimport { isSymbol } from \"./is-symbol.mjs\";\nimport { isUndefined } from \"./is-undefined.mjs\";\n\n//#region src/is-empty.ts\n/**\n* Check if the provided value's type is `null` or `undefined`\n*\n* @param value - The value to type check\n* @returns An indicator specifying if the value provided is of type `null` or `undefined`\n*/\nconst isEmpty = (value) => {\n\ttry {\n\t\treturn isUndefined(value) || isNull(value);\n\t} catch {\n\t\treturn false;\n\t}\n};\nconst isEmptyAnything = (value) => {\n\tif (value === true || value === false) return true;\n\tif (value === null || value === void 0) return true;\n\tif (isNumber(value)) return value === 0;\n\tif (isDate(value)) return Number.isNaN(value.getTime());\n\tif (isFunction(value)) return false;\n\tif (isSymbol(value)) return false;\n\tconst { length } = value;\n\tif (isNumber(length)) return length === 0;\n\tconst { size } = value;\n\tif (isNumber(size)) return size === 0;\n\treturn Object.keys(value).length === 0;\n};\n\n//#endregion\nexport { isEmpty, isEmptyAnything };\n//# sourceMappingURL=is-empty.mjs.map","import { isEmpty } from \"./is-empty.mjs\";\n\n//#region src/is-set.ts\n/**\n* The inverse of the `isEmpty` function\n*\n* @param value - The value to type check\n* @returns An indicator specifying if the value provided is **NOT** of type `null` or `undefined`\n*/\nconst isSet = (value) => {\n\ttry {\n\t\treturn !isEmpty(value);\n\t} catch {\n\t\treturn false;\n\t}\n};\n\n//#endregion\nexport { isSet };\n//# sourceMappingURL=is-set.mjs.map","import { isPlainObject } from \"./is-plain-object.mjs\";\n\n//#region src/is-object.ts\nconst isClassRegex = /^class\\s|^function\\s+[A-Z]/;\nconst isConventionalClassRegex = /^function\\s+[A-Z]/;\nconst isNativeClassRegex = /^class\\s/;\n/** Is ES6+ class */\nfunction isNativeClass(value) {\n\treturn typeof value === \"function\" && isNativeClassRegex.test(value.toString());\n}\n/**\n* Check if the provided value's type is a conventional class\n*\n* @remarks\n* Is Conventional Class\n* Looks for function with capital first letter MyClass\n* First letter is the 9th character\n* If changed, isClass must also be updated\n*\n* @param value - The value to type check\n* @returns An indicator specifying if the value provided is a conventional class\n*/\nfunction isConventionalClass(value) {\n\treturn typeof value === \"function\" && isConventionalClassRegex.test(value.toString());\n}\nfunction isClass(value) {\n\treturn typeof value === \"function\" && isClassRegex.test(value.toString());\n}\n/**\n* Check if the provided value's type is `Object`\n*\n* @param value - The value to type check\n* @returns An indicator specifying if the value provided is of type `Object`\n*/\nconst isObject = (value) => {\n\ttry {\n\t\treturn typeof value === \"object\" || Boolean(value) && value?.constructor === Object || isPlainObject(value);\n\t} catch {\n\t\treturn false;\n\t}\n};\n\n//#endregion\nexport { isClass, isConventionalClass, isNativeClass, isObject };\n//# sourceMappingURL=is-object.mjs.map","import { isObject } from \"./is-object.mjs\";\nimport { isSet } from \"./is-set.mjs\";\n\n//#region src/is-non-null-object.ts\n/**\n* Check if the provided value's type is `Object` and is not `null` or `undefined`\n*\n* @param value - The value to type check\n* @returns An indicator specifying if the value provided is of type `Object` and is not `null` or `undefined`\n*/\nconst isNonNullObject = (value) => {\n\treturn isSet(value) && isObject(value);\n};\n\n//#endregion\nexport { isNonNullObject };\n//# sourceMappingURL=is-non-null-object.mjs.map","import { isNonNullObject } from \"./is-non-null-object.mjs\";\n\n//#region src/is-set-object.ts\n/**\n* Check if the provided value's type is an object with some fields set\n*\n* @param value - The value to type check\n* @returns An indicator specifying if the value provided is an object with some fields se\n*/\nconst isSetObject = (value) => {\n\ttry {\n\t\treturn isNonNullObject(value) && Object.keys(value).length > 0;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\n//#endregion\nexport { isSetObject };\n//# sourceMappingURL=is-set-object.mjs.map","//#region src/is-string.ts\nconst isString = (value) => {\n\ttry {\n\t\treturn typeof value === \"string\";\n\t} catch {\n\t\treturn false;\n\t}\n};\n\n//#endregion\nexport { isString };\n//# sourceMappingURL=is-string.mjs.map","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { correctPath } from \"@stryke/path/correct-path\";\n\n/**\n * Resolve an output template (string or function) into an actual path string.\n *\n * @remarks\n * - If `outputTemplate` is a function, call it with (language, namespace)\n * - If it's a string, replace placeholders:\n * - \\{\\{language\\}\\} or \\{\\{lng\\}\\} -\\> language\n * - \\{\\{namespace\\}\\} -\\> namespace (or removed if namespace is undefined)\n * - Normalizes duplicate slashes and returns a platform-correct path.\n */\nexport function getOutputPath(\n outputTemplate:\n | string\n | ((language: string, namespace?: string) => string)\n | undefined,\n language: string,\n namespace?: string\n): string {\n if (!outputTemplate) {\n // Fallback to a sensible default\n return correctPath(\n `locales/${language}/${namespace ?? \"translation\"}.json`\n );\n }\n\n if (typeof outputTemplate === \"function\") {\n try {\n const result = String(outputTemplate(language, namespace));\n\n return correctPath(result.replace(/\\/{2,}/g, \"/\"));\n } catch {\n // If user function throws, fallback to default path\n return correctPath(\n `locales/${language}/${namespace ?? \"translation\"}.json`\n );\n }\n }\n\n // It's a string template\n let out = String(outputTemplate);\n out = out.replace(/\\{\\{language\\}\\}|\\{\\{lng\\}\\}/g, language);\n\n if (namespace !== undefined && namespace !== null) {\n out = out.replace(/\\{\\{namespace\\}\\}/g, namespace);\n } else {\n // remove any occurrences of /{{namespace}} or {{namespace}} (keeping surrounding slashes tidy)\n out = out.replace(/\\/?\\{\\{namespace\\}\\}/g, \"\");\n }\n\n // collapse duplicate slashes and normalize to platform-specific separators\n out = out.replace(/\\/{2,}/g, \"/\");\n return correctPath(out);\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { listFiles } from \"@stryke/fs/list-files\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFileName } from \"@stryke/path/file-path-fns\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport defu from \"defu\";\nimport { I18nextToolkitConfig, runExtractor } from \"i18next-cli\";\nimport { mergeResourcesAsInterface } from \"i18next-resources-for-ts\";\nimport { Plugin } from \"powerlines/types/plugin\";\nimport { getOutputPath } from \"./helpers/config-utils\";\nimport { Resource, ResourceContent } from \"./types/i18n\";\nimport {\n I18NextPluginContext,\n I18NextPluginOptions,\n I18NextPluginResolvedConfig\n} from \"./types/plugin\";\n\nexport * from \"./types\";\n\n/**\n * i18next Plugin\n *\n * @remarks\n * A Powerlines plugin to use the i18next internationalization framework during the prepare task.\n *\n * @see https://i18next.com\n *\n * @param options - The plugin options.\n * @returns A Powerlines plugin instance.\n */\nexport const plugin = <\n TContext extends I18NextPluginContext = I18NextPluginContext\n>(\n options: I18NextPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"i18next\",\n async config() {\n const i18next = defu<\n I18NextPluginResolvedConfig[\"i18next\"],\n I18NextPluginOptions[]\n >(\n options,\n {\n extract: {\n output: (language: string, namespace = \"translation\") =>\n joinPaths(\n this.config.projectRoot,\n `locales/${language}/${namespace}.json`\n ),\n primaryLanguage: this.workspaceConfig.locale\n }\n },\n {\n extract: {\n input: [\n \"src/**/*.ts\",\n \"src/**/*.tsx\",\n \"src/**/*.js\",\n \"src/**/*.jsx\"\n ],\n indentation: 2,\n defaultNS: \"translation\",\n mergeNamespaces: true,\n nsSeparator: \":\",\n keySeparator: \".\",\n primaryLanguage:\n options.locales && options.locales.length > 0\n ? options.locales[0]\n : \"en\"\n },\n types: {\n enableSelector: false\n },\n locales: [] as string[]\n }\n );\n\n if (!i18next.locales || i18next.locales.length === 0) {\n i18next.locales = [i18next.extract.primaryLanguage || \"en\"];\n }\n\n if (!isSet(i18next.types.indentation)) {\n i18next.types.indentation = i18next.extract.indentation;\n }\n\n return {\n i18next\n };\n },\n async configResolved() {},\n async prepare() {\n await runExtractor(\n this.config.i18next as I18nextToolkitConfig,\n {\n isWatchMode: false,\n isDryRun: false,\n syncAll: true,\n syncPrimaryWithDefaults: true\n },\n {\n info: (message: string) => {\n this.info(message);\n },\n warn: (message: string, _more?: any) => {\n this.warn(message);\n },\n error: (message: string | any) => {\n this.error(message);\n }\n }\n );\n },\n async types(code: string) {\n const resources: Resource[] = [];\n for (const file of await listFiles(\n getOutputPath(\n this.config.i18next.extract.output,\n this.config.i18next.extract.primaryLanguage,\n \"*\"\n )\n )) {\n const namespace = findFileName(file, { withExtension: false });\n const parsedContent = await this.resolver.import<ResourceContent>(file);\n\n // If mergeNamespaces is used, a single file can contain multiple namespaces\n // (e.g. { \"translation\": { ... }, \"common\": { ... } } in a per-language file).\n // In that case, expose each top-level key as a namespace entry so the type\n // generator will produce top-level namespace interfaces (not a language wrapper).\n if (\n this.config.i18next.extract.mergeNamespaces &&\n isSetObject(parsedContent)\n ) {\n // If we have at least one object and we are in mergeNamespaces mode, assume it's a merged file\n if (\n Object.keys(parsedContent).filter(k =>\n isSetObject(parsedContent[k])\n ).length > 0\n ) {\n for (const nsName of Object.keys(parsedContent).filter(k =>\n isSetObject(parsedContent[k])\n )) {\n resources.push({\n name: nsName,\n resources: parsedContent[nsName] as ResourceContent\n });\n }\n\n if (\n Object.keys(parsedContent).filter(\n k => !isSetObject(parsedContent[k])\n ).length > 0\n ) {\n this.warn(\n `The file ${file} contains top-level keys that are not objects (${Object.keys(\n parsedContent\n )\n .filter(k => !isSetObject(parsedContent[k]))\n .join(\n \", \"\n )}). When 'mergeNamespaces' is enabled, top-level keys are treated as namespaces. These keys will be ignored.`\n );\n }\n\n continue;\n }\n }\n\n resources.push({ name: namespace, resources: parsedContent });\n }\n\n let result!: string;\n if (this.config.i18next.types.resourcesFile) {\n await this.fs.write(\n appendPath(\n this.config.i18next.types.resourcesFile,\n this.config.i18next.types.output || this.config.projectRoot\n ),\n mergeResourcesAsInterface(resources, {\n optimize: !!this.config.i18next.types.enableSelector,\n indentation: this.config.i18next.types.indentation\n })\n );\n } else {\n result = `${code}\n\n${mergeResourcesAsInterface(resources, {\n optimize: !!this.config.i18next.types.enableSelector,\n indentation: this.config.i18next.types.indentation\n})}\n\n/**\n * i18next Custom Type Options\n *\n * @see https://www.i18next.com/overview/typescript#custom-type-options\n */\ndeclare module 'i18next' {\n interface CustomTypeOptions {\n enableSelector: ${isString(this.config.i18next.types.enableSelector) ? `\"${this.config.i18next.types.enableSelector}\"` : this.config.i18next.types.enableSelector};\n defaultNS: ${\n this.config.i18next.extract.defaultNS === false\n ? \"false\"\n : `'${this.config.i18next.extract.defaultNS || \"translation\"}'`\n };\n resources: Resources;\n }\n}\n`;\n }\n\n return result;\n }\n };\n};\n\nexport default plug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G,CAAC,CAC3C,KACC,KACD,CAAC,6GACL;AAGH;;;AAIJ,cAAU,KAAK;KAAE,MAAM;KAAW,WAAW;KAAe,CAAC;;GAG/D,IAAIC;AACJ,OAAI,KAAK,OAAO,QAAQ,MAAM,cAC5B,OAAM,KAAK,GAAG,MACZ,WACE,KAAK,OAAO,QAAQ,MAAM,eAC1B,KAAK,OAAO,QAAQ,MAAM,UAAU,KAAK,OAAO,YACjD,EACD,0BAA0B,WAAW;IACnC,UAAU,CAAC,CAAC,KAAK,OAAO,QAAQ,MAAM;IACtC,aAAa,KAAK,OAAO,QAAQ,MAAM;IACxC,CAAC,CACH;OAED,UAAS,GAAG,KAAK;;EAEvB,0BAA0B,WAAW;IACrC,UAAU,CAAC,CAAC,KAAK,OAAO,QAAQ,MAAM;IACtC,aAAa,KAAK,OAAO,QAAQ,MAAM;IACxC,CAAC,CAAC;;;;;;;;;sBASmB,SAAS,KAAK,OAAO,QAAQ,MAAM,eAAe,GAAG,IAAI,KAAK,OAAO,QAAQ,MAAM,eAAe,KAAK,KAAK,OAAO,QAAQ,MAAM,eAAe;iBAEhK,KAAK,OAAO,QAAQ,QAAQ,cAAc,QACtC,UACA,IAAI,KAAK,OAAO,QAAQ,QAAQ,aAAa,cAAc,GAChE;;;;;AAOC,UAAO;;EAEV;;AAGH,kBAAe"}
1
+ {"version":3,"file":"index.mjs","names":["resources: Resource[]","result!: string"],"sources":["../../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/get-object-tag.mjs","../../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-plain-object.mjs","../../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-null.mjs","../../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-undefined.mjs","../../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-empty.mjs","../../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-set.mjs","../../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-object.mjs","../../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-non-null-object.mjs","../../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-set-object.mjs","../../../node_modules/.pnpm/@stryke+type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-string.mjs","../src/helpers/config-utils.ts","../src/index.ts"],"sourcesContent":["//#region src/get-object-tag.ts\n/**\n* Gets the `toStringTag` of `obj`.\n*\n* @param value - The obj to query.\n* @returns Returns the `toStringTag`.\n*/\nconst getObjectTag = (value) => {\n\tif (value == null) return value === void 0 ? \"[object Undefined]\" : \"[object Null]\";\n\treturn Object.prototype.toString.call(value);\n};\n\n//#endregion\nexport { getObjectTag };\n//# sourceMappingURL=get-object-tag.mjs.map","import { getObjectTag } from \"./get-object-tag.mjs\";\n\n//#region src/is-plain-object.ts\n/**\n* Checks if `value` is object-like. A value is object-like if it's not `null`\n* and has a `typeof` result of \"object\".\n*\n* @example\n* ```typescript\n* isObjectLike({})\n* // => true\n*\n* isObjectLike([1, 2, 3])\n* // => true\n*\n* isObjectLike(Function)\n* // => false\n*\n* isObjectLike(null)\n* // => false\n* ```\n*\n* @param value - The value to check.\n* @returns Returns `true` if `value` is object-like, else `false`.\n*/\nconst isObjectLike = (obj) => {\n\treturn typeof obj === \"object\" && obj !== null;\n};\n/**\n* Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.\n*\n* @example\n* ```typescript\n* function Foo() {\n* this.a = 1\n* }\n*\n* isPlainObject(new Foo)\n* // => false\n*\n* isPlainObject([1, 2, 3])\n* // => false\n*\n* isPlainObject({ 'x': 0, 'y': 0 })\n* // => true\n*\n* isPlainObject(Object.create(null))\n* // => true\n* ```\n*\n* @param obj - The value to check.\n* @returns Returns `true` if `obj` is a plain object, else `false`.\n*/\nconst isPlainObject = (obj) => {\n\tif (!isObjectLike(obj) || getObjectTag(obj) !== \"[object Object]\") return false;\n\tif (Object.getPrototypeOf(obj) === null) return true;\n\tlet proto = obj;\n\twhile (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);\n\treturn Object.getPrototypeOf(obj) === proto;\n};\n\n//#endregion\nexport { isObjectLike, isPlainObject };\n//# sourceMappingURL=is-plain-object.mjs.map","//#region src/is-null.ts\nconst isNull = (value) => {\n\ttry {\n\t\treturn value === null;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\n//#endregion\nexport { isNull };\n//# sourceMappingURL=is-null.mjs.map","//#region src/is-undefined.ts\nconst isUndefined = (value) => {\n\treturn value === void 0;\n};\n\n//#endregion\nexport { isUndefined };\n//# sourceMappingURL=is-undefined.mjs.map","import { isDate } from \"./is-date.mjs\";\nimport { isFunction } from \"./is-function.mjs\";\nimport { isNull } from \"./is-null.mjs\";\nimport { isNumber } from \"./is-number.mjs\";\nimport { isSymbol } from \"./is-symbol.mjs\";\nimport { isUndefined } from \"./is-undefined.mjs\";\n\n//#region src/is-empty.ts\n/**\n* Check if the provided value's type is `null` or `undefined`\n*\n* @param value - The value to type check\n* @returns An indicator specifying if the value provided is of type `null` or `undefined`\n*/\nconst isEmpty = (value) => {\n\ttry {\n\t\treturn isUndefined(value) || isNull(value);\n\t} catch {\n\t\treturn false;\n\t}\n};\nconst isEmptyAnything = (value) => {\n\tif (value === true || value === false) return true;\n\tif (value === null || value === void 0) return true;\n\tif (isNumber(value)) return value === 0;\n\tif (isDate(value)) return Number.isNaN(value.getTime());\n\tif (isFunction(value)) return false;\n\tif (isSymbol(value)) return false;\n\tconst { length } = value;\n\tif (isNumber(length)) return length === 0;\n\tconst { size } = value;\n\tif (isNumber(size)) return size === 0;\n\treturn Object.keys(value).length === 0;\n};\n\n//#endregion\nexport { isEmpty, isEmptyAnything };\n//# sourceMappingURL=is-empty.mjs.map","import { isEmpty } from \"./is-empty.mjs\";\n\n//#region src/is-set.ts\n/**\n* The inverse of the `isEmpty` function\n*\n* @param value - The value to type check\n* @returns An indicator specifying if the value provided is **NOT** of type `null` or `undefined`\n*/\nconst isSet = (value) => {\n\ttry {\n\t\treturn !isEmpty(value);\n\t} catch {\n\t\treturn false;\n\t}\n};\n\n//#endregion\nexport { isSet };\n//# sourceMappingURL=is-set.mjs.map","import { isPlainObject } from \"./is-plain-object.mjs\";\n\n//#region src/is-object.ts\nconst isClassRegex = /^class\\s|^function\\s+[A-Z]/;\nconst isConventionalClassRegex = /^function\\s+[A-Z]/;\nconst isNativeClassRegex = /^class\\s/;\n/** Is ES6+ class */\nfunction isNativeClass(value) {\n\treturn typeof value === \"function\" && isNativeClassRegex.test(value.toString());\n}\n/**\n* Check if the provided value's type is a conventional class\n*\n* @remarks\n* Is Conventional Class\n* Looks for function with capital first letter MyClass\n* First letter is the 9th character\n* If changed, isClass must also be updated\n*\n* @param value - The value to type check\n* @returns An indicator specifying if the value provided is a conventional class\n*/\nfunction isConventionalClass(value) {\n\treturn typeof value === \"function\" && isConventionalClassRegex.test(value.toString());\n}\nfunction isClass(value) {\n\treturn typeof value === \"function\" && isClassRegex.test(value.toString());\n}\n/**\n* Check if the provided value's type is `Object`\n*\n* @param value - The value to type check\n* @returns An indicator specifying if the value provided is of type `Object`\n*/\nconst isObject = (value) => {\n\ttry {\n\t\treturn typeof value === \"object\" || Boolean(value) && value?.constructor === Object || isPlainObject(value);\n\t} catch {\n\t\treturn false;\n\t}\n};\n\n//#endregion\nexport { isClass, isConventionalClass, isNativeClass, isObject };\n//# sourceMappingURL=is-object.mjs.map","import { isObject } from \"./is-object.mjs\";\nimport { isSet } from \"./is-set.mjs\";\n\n//#region src/is-non-null-object.ts\n/**\n* Check if the provided value's type is `Object` and is not `null` or `undefined`\n*\n* @param value - The value to type check\n* @returns An indicator specifying if the value provided is of type `Object` and is not `null` or `undefined`\n*/\nconst isNonNullObject = (value) => {\n\treturn isSet(value) && isObject(value);\n};\n\n//#endregion\nexport { isNonNullObject };\n//# sourceMappingURL=is-non-null-object.mjs.map","import { isNonNullObject } from \"./is-non-null-object.mjs\";\n\n//#region src/is-set-object.ts\n/**\n* Check if the provided value's type is an object with some fields set\n*\n* @param value - The value to type check\n* @returns An indicator specifying if the value provided is an object with some fields se\n*/\nconst isSetObject = (value) => {\n\ttry {\n\t\treturn isNonNullObject(value) && Object.keys(value).length > 0;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\n//#endregion\nexport { isSetObject };\n//# sourceMappingURL=is-set-object.mjs.map","//#region src/is-string.ts\nconst isString = (value) => {\n\ttry {\n\t\treturn typeof value === \"string\";\n\t} catch {\n\t\treturn false;\n\t}\n};\n\n//#endregion\nexport { isString };\n//# sourceMappingURL=is-string.mjs.map","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { correctPath } from \"@stryke/path/correct-path\";\n\n/**\n * Resolve an output template (string or function) into an actual path string.\n *\n * @remarks\n * - If `outputTemplate` is a function, call it with (language, namespace)\n * - If it's a string, replace placeholders:\n * - \\{\\{language\\}\\} or \\{\\{lng\\}\\} -\\> language\n * - \\{\\{namespace\\}\\} -\\> namespace (or removed if namespace is undefined)\n * - Normalizes duplicate slashes and returns a platform-correct path.\n */\nexport function getOutputPath(\n outputTemplate:\n | string\n | ((language: string, namespace?: string) => string)\n | undefined,\n language: string,\n namespace?: string\n): string {\n if (!outputTemplate) {\n // Fallback to a sensible default\n return correctPath(\n `locales/${language}/${namespace ?? \"translation\"}.json`\n );\n }\n\n if (typeof outputTemplate === \"function\") {\n try {\n const result = String(outputTemplate(language, namespace));\n\n return correctPath(result.replace(/\\/{2,}/g, \"/\"));\n } catch {\n // If user function throws, fallback to default path\n return correctPath(\n `locales/${language}/${namespace ?? \"translation\"}.json`\n );\n }\n }\n\n // It's a string template\n let out = String(outputTemplate);\n out = out.replace(/\\{\\{language\\}\\}|\\{\\{lng\\}\\}/g, language);\n\n if (namespace !== undefined && namespace !== null) {\n out = out.replace(/\\{\\{namespace\\}\\}/g, namespace);\n } else {\n // remove any occurrences of /{{namespace}} or {{namespace}} (keeping surrounding slashes tidy)\n out = out.replace(/\\/?\\{\\{namespace\\}\\}/g, \"\");\n }\n\n // collapse duplicate slashes and normalize to platform-specific separators\n out = out.replace(/\\/{2,}/g, \"/\");\n return correctPath(out);\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { listFiles } from \"@stryke/fs/list-files\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFileName } from \"@stryke/path/file-path-fns\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport defu from \"defu\";\nimport { I18nextToolkitConfig, runExtractor } from \"i18next-cli\";\nimport { mergeResourcesAsInterface } from \"i18next-resources-for-ts\";\nimport { Plugin } from \"powerlines/types/plugin\";\nimport { getOutputPath } from \"./helpers/config-utils\";\nimport { Resource, ResourceContent } from \"./types/i18n\";\nimport {\n I18NextPluginContext,\n I18NextPluginOptions,\n I18NextPluginResolvedConfig\n} from \"./types/plugin\";\n\nexport * from \"./types\";\n\n/**\n * i18next Plugin\n *\n * @remarks\n * A Powerlines plugin to use the i18next internationalization framework during the prepare task.\n *\n * @see https://i18next.com\n *\n * @param options - The plugin options.\n * @returns A Powerlines plugin instance.\n */\nexport const plugin = <\n TContext extends I18NextPluginContext = I18NextPluginContext\n>(\n options: I18NextPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"i18next\",\n async config() {\n const i18next = defu<\n I18NextPluginResolvedConfig[\"i18next\"],\n I18NextPluginOptions[]\n >(\n options,\n {\n extract: {\n output: (language: string, namespace = \"translation\") =>\n joinPaths(\n this.config.projectRoot,\n `locales/${language}/${namespace}.json`\n ),\n primaryLanguage: this.workspaceConfig.locale\n }\n },\n {\n extract: {\n input: [\n \"src/**/*.ts\",\n \"src/**/*.tsx\",\n \"src/**/*.js\",\n \"src/**/*.jsx\"\n ],\n indentation: 2,\n defaultNS: \"translation\",\n mergeNamespaces: true,\n nsSeparator: \":\",\n keySeparator: \".\",\n primaryLanguage:\n options.locales && options.locales.length > 0\n ? options.locales[0]\n : \"en\"\n },\n types: {\n enableSelector: false\n },\n locales: [] as string[]\n }\n );\n\n if (!i18next.locales || i18next.locales.length === 0) {\n i18next.locales = [i18next.extract.primaryLanguage || \"en\"];\n }\n\n if (!isSet(i18next.types.indentation)) {\n i18next.types.indentation = i18next.extract.indentation;\n }\n\n return {\n i18next\n };\n },\n async configResolved() {},\n async prepare() {\n await runExtractor(\n this.config.i18next as I18nextToolkitConfig,\n {\n isWatchMode: false,\n isDryRun: false,\n syncAll: true,\n syncPrimaryWithDefaults: true\n },\n {\n info: (message: string) => {\n this.info(message);\n },\n warn: (message: string, _more?: any) => {\n this.warn(message);\n },\n error: (message: string | any) => {\n this.error(message);\n }\n }\n );\n },\n async types(code: string) {\n const resources: Resource[] = [];\n for (const file of await listFiles(\n getOutputPath(\n this.config.i18next.extract.output,\n this.config.i18next.extract.primaryLanguage,\n \"*\"\n )\n )) {\n const namespace = findFileName(file, { withExtension: false });\n const parsedContent = await this.resolver.import<ResourceContent>(file);\n\n // If mergeNamespaces is used, a single file can contain multiple namespaces\n // (e.g. { \"translation\": { ... }, \"common\": { ... } } in a per-language file).\n // In that case, expose each top-level key as a namespace entry so the type\n // generator will produce top-level namespace interfaces (not a language wrapper).\n if (\n this.config.i18next.extract.mergeNamespaces &&\n isSetObject(parsedContent)\n ) {\n // If we have at least one object and we are in mergeNamespaces mode, assume it's a merged file\n if (\n Object.keys(parsedContent).filter(k =>\n isSetObject(parsedContent[k])\n ).length > 0\n ) {\n for (const nsName of Object.keys(parsedContent).filter(k =>\n isSetObject(parsedContent[k])\n )) {\n resources.push({\n name: nsName,\n resources: parsedContent[nsName] as ResourceContent\n });\n }\n\n if (\n Object.keys(parsedContent).filter(\n k => !isSetObject(parsedContent[k])\n ).length > 0\n ) {\n this.warn(\n `The file ${file} contains top-level keys that are not objects (${Object.keys(\n parsedContent\n )\n .filter(k => !isSetObject(parsedContent[k]))\n .join(\n \", \"\n )}). When 'mergeNamespaces' is enabled, top-level keys are treated as namespaces. These keys will be ignored.`\n );\n }\n\n continue;\n }\n }\n\n resources.push({ name: namespace, resources: parsedContent });\n }\n\n let result!: string;\n if (this.config.i18next.types.resourcesFile) {\n await this.fs.write(\n appendPath(\n this.config.i18next.types.resourcesFile,\n this.config.i18next.types.output || this.config.projectRoot\n ),\n mergeResourcesAsInterface(resources, {\n optimize: !!this.config.i18next.types.enableSelector,\n indentation: this.config.i18next.types.indentation\n })\n );\n } else {\n result = `${code}\n\n${mergeResourcesAsInterface(resources, {\n optimize: !!this.config.i18next.types.enableSelector,\n indentation: this.config.i18next.types.indentation\n})}\n\n/**\n * i18next Custom Type Options\n *\n * @see https://www.i18next.com/overview/typescript#custom-type-options\n */\ndeclare module 'i18next' {\n interface CustomTypeOptions {\n enableSelector: ${isString(this.config.i18next.types.enableSelector) ? `\"${this.config.i18next.types.enableSelector}\"` : this.config.i18next.types.enableSelector};\n defaultNS: ${\n this.config.i18next.extract.defaultNS === false\n ? \"false\"\n : `'${this.config.i18next.extract.defaultNS || \"translation\"}'`\n };\n resources: Resources;\n }\n}\n`;\n }\n\n return result;\n }\n };\n};\n\nexport default plugin;\n"],"x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9],"mappings":";;;;;;;;;;;;;;;;;;;AAOA,MAAM,gBAAgB,UAAU;AAC/B,KAAI,SAAS,KAAM,QAAO,UAAU,KAAK,IAAI,uBAAuB;AACpE,QAAO,OAAO,UAAU,SAAS,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;ACgB7C,MAAM,gBAAgB,QAAQ;AAC7B,QAAO,OAAO,QAAQ,YAAY,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2B3C,MAAM,iBAAiB,QAAQ;AAC9B,KAAI,CAAC,aAAa,IAAI,IAAI,aAAa,IAAI,KAAK,kBAAmB,QAAO;AAC1E,KAAI,OAAO,eAAe,IAAI,KAAK,KAAM,QAAO;CAChD,IAAI,QAAQ;AACZ,QAAO,OAAO,eAAe,MAAM,KAAK,KAAM,SAAQ,OAAO,eAAe,MAAM;AAClF,QAAO,OAAO,eAAe,IAAI,KAAK;;;;;ACzDvC,MAAM,UAAU,UAAU;AACzB,KAAI;AACH,SAAO,UAAU;SACV;AACP,SAAO;;;;;;ACJT,MAAM,eAAe,UAAU;AAC9B,QAAO,UAAU,KAAK;;;;;;;;;;;ACYvB,MAAM,WAAW,UAAU;AAC1B,KAAI;AACH,SAAO,YAAY,MAAM,IAAI,OAAO,MAAM;SACnC;AACP,SAAO;;;;;;;;;;;;ACTT,MAAM,SAAS,UAAU;AACxB,KAAI;AACH,SAAO,CAAC,QAAQ,MAAM;SACf;AACP,SAAO;;;;;;;;;;;;ACqBT,MAAM,YAAY,UAAU;AAC3B,KAAI;AACH,SAAO,OAAO,UAAU,YAAY,QAAQ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AAW,cAAc;OAC1B,CAAC;AAGJ,UACE,OAAO,KAAK,cAAc,CAAC,QACzB,MAAK,CAAC,YAAY,cAAc,GAAG,CACpC,CAAC,SAAS,EAEX,MAAK,KACH,YAAY,KAAK,iDAAiD,OAAO,KACvE,cACD,CACE,QAAO,MAAK,CAAC,YAAY,cAAc,GAAG,CAAC,CAC3C,KACC,KACD,CAAC,6GACL;AAGH;;;AAIJ,cAAU,KAAK;KAAE,MAAM;KAAW,WAAW;KAAe,CAAC;;GAG/D,IAAIC;AACJ,OAAI,KAAK,OAAO,QAAQ,MAAM,cAC5B,OAAM,KAAK,GAAG,MACZ,WACE,KAAK,OAAO,QAAQ,MAAM,eAC1B,KAAK,OAAO,QAAQ,MAAM,UAAU,KAAK,OAAO,YACjD,EACD,0BAA0B,WAAW;IACnC,UAAU,CAAC,CAAC,KAAK,OAAO,QAAQ,MAAM;IACtC,aAAa,KAAK,OAAO,QAAQ,MAAM;IACxC,CAAC,CACH;OAED,UAAS,GAAG,KAAK;;EAEvB,0BAA0B,WAAW;IACrC,UAAU,CAAC,CAAC,KAAK,OAAO,QAAQ,MAAM;IACtC,aAAa,KAAK,OAAO,QAAQ,MAAM;IACxC,CAAC,CAAC;;;;;;;;;sBASmB,SAAS,KAAK,OAAO,QAAQ,MAAM,eAAe,GAAG,IAAI,KAAK,OAAO,QAAQ,MAAM,eAAe,KAAK,KAAK,OAAO,QAAQ,MAAM,eAAe;iBAEhK,KAAK,OAAO,QAAQ,QAAQ,cAAc,QACtC,UACA,IAAI,KAAK,OAAO,QAAQ,QAAQ,aAAa,cAAc,GAChE;;;;;AAOC,UAAO;;EAEV;;AAGH,kBAAe"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-i18next",
3
- "version": "0.1.149",
3
+ "version": "0.1.150",
4
4
  "type": "module",
5
5
  "description": "A Powerlines plugin to use i18next for internationalization.",
6
6
  "repository": {
@@ -103,19 +103,19 @@
103
103
  "files": ["dist/**/*"],
104
104
  "keywords": ["i18next", "powerlines", "storm-software", "powerlines-plugin"],
105
105
  "dependencies": {
106
- "@stryke/fs": "^0.33.39",
107
- "@stryke/path": "^0.26.3",
108
- "@stryke/types": "^0.10.36",
106
+ "@stryke/fs": "^0.33.40",
107
+ "@stryke/path": "^0.26.4",
108
+ "@stryke/types": "^0.10.37",
109
109
  "defu": "^6.1.4",
110
110
  "i18next-cli": "^1.40.1",
111
111
  "i18next-resources-for-ts": "^2.0.0",
112
- "powerlines": "^0.38.19"
112
+ "powerlines": "^0.38.20"
113
113
  },
114
114
  "devDependencies": {
115
- "@powerlines/plugin-plugin": "^0.12.203",
115
+ "@powerlines/plugin-plugin": "^0.12.204",
116
116
  "@types/node": "^24.10.9"
117
117
  },
118
118
  "publishConfig": { "access": "public" },
119
119
  "types": "./dist/index.d.cts",
120
- "gitHead": "ed4d8044dcb6e1de7843b3908424bb0a7e636620"
120
+ "gitHead": "54a89805dd69f77013ebbd3282232563d7af4e7b"
121
121
  }