@powerlines/plugin-i18next 0.1.149 → 0.1.151

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.
Files changed (72) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  2. package/dist/helpers/config-utils.cjs +31 -0
  3. package/dist/helpers/config-utils.mjs +31 -0
  4. package/dist/helpers/config-utils.mjs.map +1 -0
  5. package/dist/index.cjs +13 -241
  6. package/dist/index.d.cts +3 -3
  7. package/dist/index.d.mts +3 -3
  8. package/dist/index.mjs +4 -206
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/get-object-tag.cjs +15 -0
  11. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/get-object-tag.mjs +15 -0
  12. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/get-object-tag.mjs.map +1 -0
  13. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-empty.cjs +20 -0
  14. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-empty.mjs +21 -0
  15. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-empty.mjs.map +1 -0
  16. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-non-null-object.cjs +16 -0
  17. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-non-null-object.mjs +17 -0
  18. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-non-null-object.mjs.map +1 -0
  19. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-null.cjs +12 -0
  20. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-null.mjs +12 -0
  21. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-null.mjs.map +1 -0
  22. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-object.cjs +19 -0
  23. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-object.mjs +20 -0
  24. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-object.mjs.map +1 -0
  25. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-plain-object.cjs +63 -0
  26. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-plain-object.mjs +64 -0
  27. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-plain-object.mjs.map +1 -0
  28. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-set-object.cjs +19 -0
  29. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-set-object.mjs +20 -0
  30. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-set-object.mjs.map +1 -0
  31. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-set.cjs +19 -0
  32. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-set.mjs +20 -0
  33. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-set.mjs.map +1 -0
  34. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-string.cjs +12 -0
  35. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-string.mjs +12 -0
  36. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-string.mjs.map +1 -0
  37. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-undefined.cjs +8 -0
  38. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-undefined.mjs +8 -0
  39. package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-undefined.mjs.map +1 -0
  40. package/dist/types/i18n.cjs +0 -1
  41. package/dist/types/i18n.d.cts +23 -2
  42. package/dist/types/i18n.d.cts.map +1 -0
  43. package/dist/types/i18n.d.mts +23 -2
  44. package/dist/types/i18n.d.mts.map +1 -0
  45. package/dist/types/i18n.mjs +0 -2
  46. package/dist/types/index.cjs +0 -3
  47. package/dist/types/index.d.cts +2 -3
  48. package/dist/types/index.d.mts +2 -3
  49. package/dist/types/index.mjs +0 -4
  50. package/dist/types/plugin.cjs +0 -1
  51. package/dist/types/plugin.d.cts +26 -2
  52. package/dist/types/plugin.d.cts.map +1 -0
  53. package/dist/types/plugin.d.mts +26 -2
  54. package/dist/types/plugin.d.mts.map +1 -0
  55. package/dist/types/plugin.mjs +0 -2
  56. package/package.json +7 -7
  57. package/dist/i18n-C5zfq1YM.d.mts +0 -23
  58. package/dist/i18n-C5zfq1YM.d.mts.map +0 -1
  59. package/dist/i18n-CUSH-jI_.mjs +0 -1
  60. package/dist/i18n-ComTDYPk.d.cts +0 -23
  61. package/dist/i18n-ComTDYPk.d.cts.map +0 -1
  62. package/dist/i18n-Ctazdbgs.cjs +0 -0
  63. package/dist/index-CA4VvAY_.d.mts +0 -1
  64. package/dist/index-CmCelmEL.d.cts +0 -1
  65. package/dist/plugin-2ZxcgDXs.d.cts +0 -26
  66. package/dist/plugin-2ZxcgDXs.d.cts.map +0 -1
  67. package/dist/plugin-B-8QVe28.cjs +0 -0
  68. package/dist/plugin-B6BWQgT4.d.mts +0 -26
  69. package/dist/plugin-B6BWQgT4.d.mts.map +0 -1
  70. package/dist/plugin-B7p8VtjC.mjs +0 -1
  71. package/dist/types-BReKsBV6.mjs +0 -1
  72. package/dist/types-CBTc19th.cjs +0 -0
@@ -0,0 +1,29 @@
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;
@@ -0,0 +1,31 @@
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;
@@ -0,0 +1,31 @@
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 };
31
+ //# sourceMappingURL=config-utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-utils.mjs","names":[],"sources":["../../src/helpers/config-utils.ts"],"sourcesContent":["/* -------------------------------------------------------------------\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"],"mappings":";;;;;;;;;;;;;AA8BA,SAAgB,cACd,gBAIA,UACA,WACQ;AACR,KAAI,CAAC,eAEH,QAAO,YACL,WAAW,SAAS,GAAG,aAAa,cAAc,OACnD;AAGH,KAAI,OAAO,mBAAmB,WAC5B,KAAI;AAGF,SAAO,YAFQ,OAAO,eAAe,UAAU,UAAU,CAAC,CAEhC,QAAQ,WAAW,IAAI,CAAC;SAC5C;AAEN,SAAO,YACL,WAAW,SAAS,GAAG,aAAa,cAAc,OACnD;;CAKL,IAAI,MAAM,OAAO,eAAe;AAChC,OAAM,IAAI,QAAQ,iCAAiC,SAAS;AAE5D,KAAI,cAAc,UAAa,cAAc,KAC3C,OAAM,IAAI,QAAQ,sBAAsB,UAAU;KAGlD,OAAM,IAAI,QAAQ,yBAAyB,GAAG;AAIhD,OAAM,IAAI,QAAQ,WAAW,IAAI;AACjC,QAAO,YAAY,IAAI"}
package/dist/index.cjs CHANGED
@@ -1,246 +1,18 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
- //#region rolldown:runtime
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
- key = keys[i];
13
- if (!__hasOwnProp.call(to, key) && key !== except) {
14
- __defProp(to, key, {
15
- get: ((k) => from[k]).bind(null, key),
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
- });
18
- }
19
- }
20
- }
21
- return to;
22
- };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
- value: mod,
25
- enumerable: true
26
- }) : target, mod));
27
-
28
- //#endregion
29
- require('./i18n-Ctazdbgs.cjs');
30
- require('./plugin-B-8QVe28.cjs');
31
- require('./types-CBTc19th.cjs');
2
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
3
+ const require_is_set = require('./node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-set.cjs');
4
+ const require_is_set_object = require('./node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-set-object.cjs');
5
+ const require_is_string = require('./node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-string.cjs');
6
+ const require_config_utils = require('./helpers/config-utils.cjs');
32
7
  let __stryke_fs_list_files = require("@stryke/fs/list-files");
33
8
  let __stryke_path_append = require("@stryke/path/append");
34
9
  let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
35
10
  let __stryke_path_join = require("@stryke/path/join");
36
11
  let defu = require("defu");
37
- defu = __toESM(defu);
12
+ defu = require_rolldown_runtime.__toESM(defu);
38
13
  let i18next_cli = require("i18next-cli");
39
14
  let i18next_resources_for_ts = require("i18next-resources-for-ts");
40
- let __stryke_path_correct_path = require("@stryke/path/correct-path");
41
-
42
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/get-object-tag.mjs
43
- /**
44
- * Gets the `toStringTag` of `obj`.
45
- *
46
- * @param value - The obj to query.
47
- * @returns Returns the `toStringTag`.
48
- */
49
- const getObjectTag = (value) => {
50
- if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
51
- return Object.prototype.toString.call(value);
52
- };
53
15
 
54
- //#endregion
55
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-plain-object.mjs
56
- /**
57
- * Checks if `value` is object-like. A value is object-like if it's not `null`
58
- * and has a `typeof` result of "object".
59
- *
60
- * @example
61
- * ```typescript
62
- * isObjectLike({})
63
- * // => true
64
- *
65
- * isObjectLike([1, 2, 3])
66
- * // => true
67
- *
68
- * isObjectLike(Function)
69
- * // => false
70
- *
71
- * isObjectLike(null)
72
- * // => false
73
- * ```
74
- *
75
- * @param value - The value to check.
76
- * @returns Returns `true` if `value` is object-like, else `false`.
77
- */
78
- const isObjectLike = (obj) => {
79
- return typeof obj === "object" && obj !== null;
80
- };
81
- /**
82
- * Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.
83
- *
84
- * @example
85
- * ```typescript
86
- * function Foo() {
87
- * this.a = 1
88
- * }
89
- *
90
- * isPlainObject(new Foo)
91
- * // => false
92
- *
93
- * isPlainObject([1, 2, 3])
94
- * // => false
95
- *
96
- * isPlainObject({ 'x': 0, 'y': 0 })
97
- * // => true
98
- *
99
- * isPlainObject(Object.create(null))
100
- * // => true
101
- * ```
102
- *
103
- * @param obj - The value to check.
104
- * @returns Returns `true` if `obj` is a plain object, else `false`.
105
- */
106
- const isPlainObject = (obj) => {
107
- if (!isObjectLike(obj) || getObjectTag(obj) !== "[object Object]") return false;
108
- if (Object.getPrototypeOf(obj) === null) return true;
109
- let proto = obj;
110
- while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
111
- return Object.getPrototypeOf(obj) === proto;
112
- };
113
-
114
- //#endregion
115
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-null.mjs
116
- const isNull = (value) => {
117
- try {
118
- return value === null;
119
- } catch {
120
- return false;
121
- }
122
- };
123
-
124
- //#endregion
125
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-undefined.mjs
126
- const isUndefined = (value) => {
127
- return value === void 0;
128
- };
129
-
130
- //#endregion
131
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-empty.mjs
132
- /**
133
- * Check if the provided value's type is `null` or `undefined`
134
- *
135
- * @param value - The value to type check
136
- * @returns An indicator specifying if the value provided is of type `null` or `undefined`
137
- */
138
- const isEmpty = (value) => {
139
- try {
140
- return isUndefined(value) || isNull(value);
141
- } catch {
142
- return false;
143
- }
144
- };
145
-
146
- //#endregion
147
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-set.mjs
148
- /**
149
- * The inverse of the `isEmpty` function
150
- *
151
- * @param value - The value to type check
152
- * @returns An indicator specifying if the value provided is **NOT** of type `null` or `undefined`
153
- */
154
- const isSet = (value) => {
155
- try {
156
- return !isEmpty(value);
157
- } catch {
158
- return false;
159
- }
160
- };
161
-
162
- //#endregion
163
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-object.mjs
164
- /**
165
- * Check if the provided value's type is `Object`
166
- *
167
- * @param value - The value to type check
168
- * @returns An indicator specifying if the value provided is of type `Object`
169
- */
170
- const isObject = (value) => {
171
- try {
172
- return typeof value === "object" || Boolean(value) && value?.constructor === Object || isPlainObject(value);
173
- } catch {
174
- return false;
175
- }
176
- };
177
-
178
- //#endregion
179
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-non-null-object.mjs
180
- /**
181
- * Check if the provided value's type is `Object` and is not `null` or `undefined`
182
- *
183
- * @param value - The value to type check
184
- * @returns An indicator specifying if the value provided is of type `Object` and is not `null` or `undefined`
185
- */
186
- const isNonNullObject = (value) => {
187
- return isSet(value) && isObject(value);
188
- };
189
-
190
- //#endregion
191
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-set-object.mjs
192
- /**
193
- * Check if the provided value's type is an object with some fields set
194
- *
195
- * @param value - The value to type check
196
- * @returns An indicator specifying if the value provided is an object with some fields se
197
- */
198
- const isSetObject = (value) => {
199
- try {
200
- return isNonNullObject(value) && Object.keys(value).length > 0;
201
- } catch {
202
- return false;
203
- }
204
- };
205
-
206
- //#endregion
207
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-string.mjs
208
- const isString = (value) => {
209
- try {
210
- return typeof value === "string";
211
- } catch {
212
- return false;
213
- }
214
- };
215
-
216
- //#endregion
217
- //#region src/helpers/config-utils.ts
218
- /**
219
- * Resolve an output template (string or function) into an actual path string.
220
- *
221
- * @remarks
222
- * - If `outputTemplate` is a function, call it with (language, namespace)
223
- * - If it's a string, replace placeholders:
224
- * - \{\{language\}\} or \{\{lng\}\} -\> language
225
- * - \{\{namespace\}\} -\> namespace (or removed if namespace is undefined)
226
- * - Normalizes duplicate slashes and returns a platform-correct path.
227
- */
228
- function getOutputPath(outputTemplate, language, namespace) {
229
- if (!outputTemplate) return (0, __stryke_path_correct_path.correctPath)(`locales/${language}/${namespace ?? "translation"}.json`);
230
- if (typeof outputTemplate === "function") try {
231
- return (0, __stryke_path_correct_path.correctPath)(String(outputTemplate(language, namespace)).replace(/\/{2,}/g, "/"));
232
- } catch {
233
- return (0, __stryke_path_correct_path.correctPath)(`locales/${language}/${namespace ?? "translation"}.json`);
234
- }
235
- let out = String(outputTemplate);
236
- out = out.replace(/\{\{language\}\}|\{\{lng\}\}/g, language);
237
- if (namespace !== void 0 && namespace !== null) out = out.replace(/\{\{namespace\}\}/g, namespace);
238
- else out = out.replace(/\/?\{\{namespace\}\}/g, "");
239
- out = out.replace(/\/{2,}/g, "/");
240
- return (0, __stryke_path_correct_path.correctPath)(out);
241
- }
242
-
243
- //#endregion
244
16
  //#region src/index.ts
245
17
  /**
246
18
  * i18next Plugin
@@ -279,7 +51,7 @@ const plugin = (options = {}) => {
279
51
  locales: []
280
52
  });
281
53
  if (!i18next.locales || i18next.locales.length === 0) i18next.locales = [i18next.extract.primaryLanguage || "en"];
282
- if (!isSet(i18next.types.indentation)) i18next.types.indentation = i18next.extract.indentation;
54
+ if (!require_is_set.isSet(i18next.types.indentation)) i18next.types.indentation = i18next.extract.indentation;
283
55
  return { i18next };
284
56
  },
285
57
  async configResolved() {},
@@ -303,16 +75,16 @@ const plugin = (options = {}) => {
303
75
  },
304
76
  async types(code) {
305
77
  const resources = [];
306
- for (const file of await (0, __stryke_fs_list_files.listFiles)(getOutputPath(this.config.i18next.extract.output, this.config.i18next.extract.primaryLanguage, "*"))) {
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, "*"))) {
307
79
  const namespace = (0, __stryke_path_file_path_fns.findFileName)(file, { withExtension: false });
308
80
  const parsedContent = await this.resolver.import(file);
309
- if (this.config.i18next.extract.mergeNamespaces && isSetObject(parsedContent)) {
310
- if (Object.keys(parsedContent).filter((k) => isSetObject(parsedContent[k])).length > 0) {
311
- for (const nsName of Object.keys(parsedContent).filter((k) => isSetObject(parsedContent[k]))) resources.push({
81
+ if (this.config.i18next.extract.mergeNamespaces && require_is_set_object.isSetObject(parsedContent)) {
82
+ if (Object.keys(parsedContent).filter((k) => require_is_set_object.isSetObject(parsedContent[k])).length > 0) {
83
+ for (const nsName of Object.keys(parsedContent).filter((k) => require_is_set_object.isSetObject(parsedContent[k]))) resources.push({
312
84
  name: nsName,
313
85
  resources: parsedContent[nsName]
314
86
  });
315
- 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.`);
87
+ if (Object.keys(parsedContent).filter((k) => !require_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) => !require_is_set_object.isSetObject(parsedContent[k])).join(", ")}). When 'mergeNamespaces' is enabled, top-level keys are treated as namespaces. These keys will be ignored.`);
316
88
  continue;
317
89
  }
318
90
  }
@@ -340,7 +112,7 @@ ${(0, i18next_resources_for_ts.mergeResourcesAsInterface)(resources, {
340
112
  */
341
113
  declare module 'i18next' {
342
114
  interface CustomTypeOptions {
343
- enableSelector: ${isString(this.config.i18next.types.enableSelector) ? `"${this.config.i18next.types.enableSelector}"` : this.config.i18next.types.enableSelector};
115
+ enableSelector: ${require_is_string.isString(this.config.i18next.types.enableSelector) ? `"${this.config.i18next.types.enableSelector}"` : this.config.i18next.types.enableSelector};
344
116
  defaultNS: ${this.config.i18next.extract.defaultNS === false ? "false" : `'${this.config.i18next.extract.defaultNS || "translation"}'`};
345
117
  resources: Resources;
346
118
  }
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { i as I18NextPluginUserConfig, n as I18NextPluginOptions, r as I18NextPluginResolvedConfig, t as I18NextPluginContext } from "./plugin-2ZxcgDXs.cjs";
2
- import { n as ResourceContent, t as Resource } from "./i18n-ComTDYPk.cjs";
3
- import "./index-CmCelmEL.cjs";
1
+ import { I18NextPluginContext, I18NextPluginOptions, I18NextPluginResolvedConfig, I18NextPluginUserConfig } from "./types/plugin.cjs";
2
+ import { Resource, ResourceContent } from "./types/i18n.cjs";
3
+ import "./types/index.cjs";
4
4
  import { Plugin } from "powerlines/types/plugin";
5
5
 
6
6
  //#region src/index.d.ts
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { i as I18NextPluginUserConfig, n as I18NextPluginOptions, r as I18NextPluginResolvedConfig, t as I18NextPluginContext } from "./plugin-B6BWQgT4.mjs";
2
- import { n as ResourceContent, t as Resource } from "./i18n-C5zfq1YM.mjs";
3
- import "./index-CA4VvAY_.mjs";
1
+ import { I18NextPluginContext, I18NextPluginOptions, I18NextPluginResolvedConfig, I18NextPluginUserConfig } from "./types/plugin.mjs";
2
+ import { Resource, ResourceContent } from "./types/i18n.mjs";
3
+ import "./types/index.mjs";
4
4
  import { Plugin } from "powerlines/types/plugin";
5
5
 
6
6
  //#region src/index.d.ts
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
- import "./i18n-CUSH-jI_.mjs";
2
- import "./plugin-B7p8VtjC.mjs";
3
- import "./types-BReKsBV6.mjs";
1
+ import { isSet } from "./node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-set.mjs";
2
+ import { isSetObject } from "./node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-set-object.mjs";
3
+ import { isString } from "./node_modules/.pnpm/@stryke_type-checks@0.5.23/node_modules/@stryke/type-checks/dist/is-string.mjs";
4
+ import { getOutputPath } from "./helpers/config-utils.mjs";
4
5
  import { listFiles } from "@stryke/fs/list-files";
5
6
  import { appendPath } from "@stryke/path/append";
6
7
  import { findFileName } from "@stryke/path/file-path-fns";
@@ -8,210 +9,7 @@ import { joinPaths } from "@stryke/path/join";
8
9
  import defu from "defu";
9
10
  import { runExtractor } from "i18next-cli";
10
11
  import { mergeResourcesAsInterface } from "i18next-resources-for-ts";
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
14
- /**
15
- * Gets the `toStringTag` of `obj`.
16
- *
17
- * @param value - The obj to query.
18
- * @returns Returns the `toStringTag`.
19
- */
20
- const getObjectTag = (value) => {
21
- if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
22
- return Object.prototype.toString.call(value);
23
- };
24
-
25
- //#endregion
26
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-plain-object.mjs
27
- /**
28
- * Checks if `value` is object-like. A value is object-like if it's not `null`
29
- * and has a `typeof` result of "object".
30
- *
31
- * @example
32
- * ```typescript
33
- * isObjectLike({})
34
- * // => true
35
- *
36
- * isObjectLike([1, 2, 3])
37
- * // => true
38
- *
39
- * isObjectLike(Function)
40
- * // => false
41
- *
42
- * isObjectLike(null)
43
- * // => false
44
- * ```
45
- *
46
- * @param value - The value to check.
47
- * @returns Returns `true` if `value` is object-like, else `false`.
48
- */
49
- const isObjectLike = (obj) => {
50
- return typeof obj === "object" && obj !== null;
51
- };
52
- /**
53
- * Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.
54
- *
55
- * @example
56
- * ```typescript
57
- * function Foo() {
58
- * this.a = 1
59
- * }
60
- *
61
- * isPlainObject(new Foo)
62
- * // => false
63
- *
64
- * isPlainObject([1, 2, 3])
65
- * // => false
66
- *
67
- * isPlainObject({ 'x': 0, 'y': 0 })
68
- * // => true
69
- *
70
- * isPlainObject(Object.create(null))
71
- * // => true
72
- * ```
73
- *
74
- * @param obj - The value to check.
75
- * @returns Returns `true` if `obj` is a plain object, else `false`.
76
- */
77
- const isPlainObject = (obj) => {
78
- if (!isObjectLike(obj) || getObjectTag(obj) !== "[object Object]") return false;
79
- if (Object.getPrototypeOf(obj) === null) return true;
80
- let proto = obj;
81
- while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
82
- return Object.getPrototypeOf(obj) === proto;
83
- };
84
-
85
- //#endregion
86
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-null.mjs
87
- const isNull = (value) => {
88
- try {
89
- return value === null;
90
- } catch {
91
- return false;
92
- }
93
- };
94
-
95
- //#endregion
96
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-undefined.mjs
97
- const isUndefined = (value) => {
98
- return value === void 0;
99
- };
100
-
101
- //#endregion
102
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-empty.mjs
103
- /**
104
- * Check if the provided value's type is `null` or `undefined`
105
- *
106
- * @param value - The value to type check
107
- * @returns An indicator specifying if the value provided is of type `null` or `undefined`
108
- */
109
- const isEmpty = (value) => {
110
- try {
111
- return isUndefined(value) || isNull(value);
112
- } catch {
113
- return false;
114
- }
115
- };
116
-
117
- //#endregion
118
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-set.mjs
119
- /**
120
- * The inverse of the `isEmpty` function
121
- *
122
- * @param value - The value to type check
123
- * @returns An indicator specifying if the value provided is **NOT** of type `null` or `undefined`
124
- */
125
- const isSet = (value) => {
126
- try {
127
- return !isEmpty(value);
128
- } catch {
129
- return false;
130
- }
131
- };
132
-
133
- //#endregion
134
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-object.mjs
135
- /**
136
- * Check if the provided value's type is `Object`
137
- *
138
- * @param value - The value to type check
139
- * @returns An indicator specifying if the value provided is of type `Object`
140
- */
141
- const isObject = (value) => {
142
- try {
143
- return typeof value === "object" || Boolean(value) && value?.constructor === Object || isPlainObject(value);
144
- } catch {
145
- return false;
146
- }
147
- };
148
-
149
- //#endregion
150
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-non-null-object.mjs
151
- /**
152
- * Check if the provided value's type is `Object` and is not `null` or `undefined`
153
- *
154
- * @param value - The value to type check
155
- * @returns An indicator specifying if the value provided is of type `Object` and is not `null` or `undefined`
156
- */
157
- const isNonNullObject = (value) => {
158
- return isSet(value) && isObject(value);
159
- };
160
-
161
- //#endregion
162
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-set-object.mjs
163
- /**
164
- * Check if the provided value's type is an object with some fields set
165
- *
166
- * @param value - The value to type check
167
- * @returns An indicator specifying if the value provided is an object with some fields se
168
- */
169
- const isSetObject = (value) => {
170
- try {
171
- return isNonNullObject(value) && Object.keys(value).length > 0;
172
- } catch {
173
- return false;
174
- }
175
- };
176
-
177
- //#endregion
178
- //#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.22/node_modules/@stryke/type-checks/dist/is-string.mjs
179
- const isString = (value) => {
180
- try {
181
- return typeof value === "string";
182
- } catch {
183
- return false;
184
- }
185
- };
186
-
187
- //#endregion
188
- //#region src/helpers/config-utils.ts
189
- /**
190
- * Resolve an output template (string or function) into an actual path string.
191
- *
192
- * @remarks
193
- * - If `outputTemplate` is a function, call it with (language, namespace)
194
- * - If it's a string, replace placeholders:
195
- * - \{\{language\}\} or \{\{lng\}\} -\> language
196
- * - \{\{namespace\}\} -\> namespace (or removed if namespace is undefined)
197
- * - Normalizes duplicate slashes and returns a platform-correct path.
198
- */
199
- function getOutputPath(outputTemplate, language, namespace) {
200
- if (!outputTemplate) return correctPath(`locales/${language}/${namespace ?? "translation"}.json`);
201
- if (typeof outputTemplate === "function") try {
202
- return correctPath(String(outputTemplate(language, namespace)).replace(/\/{2,}/g, "/"));
203
- } catch {
204
- return correctPath(`locales/${language}/${namespace ?? "translation"}.json`);
205
- }
206
- let out = String(outputTemplate);
207
- out = out.replace(/\{\{language\}\}|\{\{lng\}\}/g, language);
208
- if (namespace !== void 0 && namespace !== null) out = out.replace(/\{\{namespace\}\}/g, namespace);
209
- else out = out.replace(/\/?\{\{namespace\}\}/g, "");
210
- out = out.replace(/\/{2,}/g, "/");
211
- return correctPath(out);
212
- }
213
-
214
- //#endregion
215
13
  //#region src/index.ts
216
14
  /**
217
15
  * i18next Plugin