@powerlines/plugin-i18next 0.1.17 → 0.1.19

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 (48) hide show
  1. package/dist/i18n-C5zfq1YM.d.mts +22 -0
  2. package/dist/i18n-CUSH-jI_.mjs +1 -0
  3. package/dist/i18n-ComTDYPk.d.cts +22 -0
  4. package/dist/i18n-Ctazdbgs.cjs +0 -0
  5. package/dist/index-CA4VvAY_.d.mts +1 -0
  6. package/dist/index-CmCelmEL.d.cts +1 -0
  7. package/dist/index.cjs +60 -4
  8. package/dist/index.d.cts +3 -3
  9. package/dist/index.d.mts +3 -4
  10. package/dist/index.mjs +31 -1
  11. package/dist/plugin-B-8QVe28.cjs +0 -0
  12. package/dist/plugin-B7p8VtjC.mjs +1 -0
  13. package/dist/plugin-Ch2Q61lm.d.cts +1768 -0
  14. package/dist/plugin-DCHnIvFL.d.mts +1768 -0
  15. package/dist/types/i18n.cjs +1 -0
  16. package/dist/types/i18n.d.cts +1 -21
  17. package/dist/types/i18n.d.mts +1 -21
  18. package/dist/types/i18n.mjs +2 -0
  19. package/dist/types/index.cjs +3 -0
  20. package/dist/types/index.d.cts +3 -2
  21. package/dist/types/index.d.mts +3 -2
  22. package/dist/types/index.mjs +4 -0
  23. package/dist/types/plugin.cjs +1 -0
  24. package/dist/types/plugin.d.cts +1 -24
  25. package/dist/types/plugin.d.mts +1 -24
  26. package/dist/types/plugin.mjs +2 -0
  27. package/dist/types-BReKsBV6.mjs +1 -0
  28. package/dist/types-CBTc19th.cjs +0 -0
  29. package/package.json +5 -5
  30. package/dist/_virtual/rolldown_runtime.cjs +0 -29
  31. package/dist/helpers/config-utils.cjs +0 -31
  32. package/dist/helpers/config-utils.mjs +0 -30
  33. package/dist/powerlines/src/types/build.d.cts +0 -145
  34. package/dist/powerlines/src/types/build.d.mts +0 -145
  35. package/dist/powerlines/src/types/commands.d.cts +0 -8
  36. package/dist/powerlines/src/types/commands.d.mts +0 -8
  37. package/dist/powerlines/src/types/config.d.cts +0 -369
  38. package/dist/powerlines/src/types/config.d.mts +0 -369
  39. package/dist/powerlines/src/types/context.d.cts +0 -403
  40. package/dist/powerlines/src/types/context.d.mts +0 -403
  41. package/dist/powerlines/src/types/fs.d.cts +0 -486
  42. package/dist/powerlines/src/types/fs.d.mts +0 -486
  43. package/dist/powerlines/src/types/plugin.d.cts +0 -231
  44. package/dist/powerlines/src/types/plugin.d.mts +0 -231
  45. package/dist/powerlines/src/types/resolved.d.cts +0 -81
  46. package/dist/powerlines/src/types/resolved.d.mts +0 -81
  47. package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
  48. package/dist/powerlines/src/types/tsconfig.d.mts +0 -69
@@ -0,0 +1,22 @@
1
+ //#region src/types/i18n.d.ts
2
+ /**
3
+ * Represents a translation resource with its namespace name and content
4
+ */
5
+ interface ResourceContent {
6
+ [key: string]: string | ResourceContent;
7
+ }
8
+ /**
9
+ * Represents a translation resource with its namespace name and content
10
+ */
11
+ interface Resource {
12
+ /**
13
+ * The namespace name (filename without extension)
14
+ */
15
+ name: string;
16
+ /**
17
+ * The parsed JSON resources object
18
+ */
19
+ resources: ResourceContent;
20
+ }
21
+ //#endregion
22
+ export { ResourceContent as n, Resource as t };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,22 @@
1
+ //#region src/types/i18n.d.ts
2
+ /**
3
+ * Represents a translation resource with its namespace name and content
4
+ */
5
+ interface ResourceContent {
6
+ [key: string]: string | ResourceContent;
7
+ }
8
+ /**
9
+ * Represents a translation resource with its namespace name and content
10
+ */
11
+ interface Resource {
12
+ /**
13
+ * The namespace name (filename without extension)
14
+ */
15
+ name: string;
16
+ /**
17
+ * The parsed JSON resources object
18
+ */
19
+ resources: ResourceContent;
20
+ }
21
+ //#endregion
22
+ export { ResourceContent as n, Resource as t };
File without changes
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export { };
package/dist/index.cjs CHANGED
@@ -1,6 +1,34 @@
1
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');
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');
4
32
  let __stryke_fs_list_files = require("@stryke/fs/list-files");
5
33
  let __stryke_path_append = require("@stryke/path/append");
6
34
  let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
@@ -9,10 +37,38 @@ let __stryke_type_checks_is_set = require("@stryke/type-checks/is-set");
9
37
  let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
10
38
  let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
11
39
  let defu = require("defu");
12
- defu = require_rolldown_runtime.__toESM(defu);
40
+ defu = __toESM(defu);
13
41
  let i18next_cli = require("i18next-cli");
14
42
  let i18next_resources_for_ts = require("i18next-resources-for-ts");
43
+ let __stryke_path_correct_path = require("@stryke/path/correct-path");
15
44
 
45
+ //#region src/helpers/config-utils.ts
46
+ /**
47
+ * Resolve an output template (string or function) into an actual path string.
48
+ *
49
+ * @remarks
50
+ * - If `outputTemplate` is a function, call it with (language, namespace)
51
+ * - If it's a string, replace placeholders:
52
+ * - \{\{language\}\} or \{\{lng\}\} -\> language
53
+ * - \{\{namespace\}\} -\> namespace (or removed if namespace is undefined)
54
+ * - Normalizes duplicate slashes and returns a platform-correct path.
55
+ */
56
+ function getOutputPath(outputTemplate, language, namespace) {
57
+ if (!outputTemplate) return (0, __stryke_path_correct_path.correctPath)(`locales/${language}/${namespace ?? "translation"}.json`);
58
+ if (typeof outputTemplate === "function") try {
59
+ return (0, __stryke_path_correct_path.correctPath)(String(outputTemplate(language, namespace)).replace(/\/{2,}/g, "/"));
60
+ } catch {
61
+ return (0, __stryke_path_correct_path.correctPath)(`locales/${language}/${namespace ?? "translation"}.json`);
62
+ }
63
+ let out = String(outputTemplate);
64
+ out = out.replace(/\{\{language\}\}|\{\{lng\}\}/g, language);
65
+ if (namespace !== void 0 && namespace !== null) out = out.replace(/\{\{namespace\}\}/g, namespace);
66
+ else out = out.replace(/\/?\{\{namespace\}\}/g, "");
67
+ out = out.replace(/\/{2,}/g, "/");
68
+ return (0, __stryke_path_correct_path.correctPath)(out);
69
+ }
70
+
71
+ //#endregion
16
72
  //#region src/index.ts
17
73
  /**
18
74
  * i18next Plugin
@@ -75,7 +131,7 @@ const plugin = (options = {}) => {
75
131
  },
76
132
  async types(code) {
77
133
  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, "*"))) {
134
+ for (const file of await (0, __stryke_fs_list_files.listFiles)(getOutputPath(this.config.i18next.extract.output, this.config.i18next.extract.primaryLanguage, "*"))) {
79
135
  const namespace = (0, __stryke_path_file_path_fns.findFileName)(file, { withExtension: false });
80
136
  const parsedContent = await this.resolver.import(file);
81
137
  if (this.config.i18next.extract.mergeNamespaces && (0, __stryke_type_checks_is_set_object.isSetObject)(parsedContent)) {
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { Plugin } from "./powerlines/src/types/plugin.cjs";
2
- import { I18NextPluginContext, I18NextPluginOptions, I18NextPluginResolvedConfig, I18NextPluginUserConfig } from "./types/plugin.cjs";
3
- import { Resource, ResourceContent } from "./types/i18n.cjs";
1
+ import { a as Plugin, i as I18NextPluginUserConfig, n as I18NextPluginOptions, r as I18NextPluginResolvedConfig, t as I18NextPluginContext } from "./plugin-Ch2Q61lm.cjs";
2
+ import { n as ResourceContent, t as Resource } from "./i18n-ComTDYPk.cjs";
3
+ import "./index-CmCelmEL.cjs";
4
4
 
5
5
  //#region src/index.d.ts
6
6
 
package/dist/index.d.mts CHANGED
@@ -1,7 +1,6 @@
1
- import { Plugin } from "./powerlines/src/types/plugin.mjs";
2
- import { I18NextPluginContext, I18NextPluginOptions, I18NextPluginResolvedConfig, I18NextPluginUserConfig } from "./types/plugin.mjs";
3
- import { Resource, ResourceContent } from "./types/i18n.mjs";
4
- import "./types/index.mjs";
1
+ import { a as Plugin, i as I18NextPluginUserConfig, n as I18NextPluginOptions, r as I18NextPluginResolvedConfig, t as I18NextPluginContext } from "./plugin-DCHnIvFL.mjs";
2
+ import { n as ResourceContent, t as Resource } from "./i18n-C5zfq1YM.mjs";
3
+ import "./index-CA4VvAY_.mjs";
5
4
 
6
5
  //#region src/index.d.ts
7
6
 
package/dist/index.mjs CHANGED
@@ -1,4 +1,6 @@
1
- import { getOutputPath } from "./helpers/config-utils.mjs";
1
+ import "./i18n-CUSH-jI_.mjs";
2
+ import "./plugin-B7p8VtjC.mjs";
3
+ import "./types-BReKsBV6.mjs";
2
4
  import { listFiles } from "@stryke/fs/list-files";
3
5
  import { appendPath } from "@stryke/path/append";
4
6
  import { findFileName } from "@stryke/path/file-path-fns";
@@ -9,7 +11,35 @@ import { isString } from "@stryke/type-checks/is-string";
9
11
  import defu from "defu";
10
12
  import { runExtractor } from "i18next-cli";
11
13
  import { mergeResourcesAsInterface } from "i18next-resources-for-ts";
14
+ import { correctPath } from "@stryke/path/correct-path";
12
15
 
16
+ //#region src/helpers/config-utils.ts
17
+ /**
18
+ * Resolve an output template (string or function) into an actual path string.
19
+ *
20
+ * @remarks
21
+ * - If `outputTemplate` is a function, call it with (language, namespace)
22
+ * - If it's a string, replace placeholders:
23
+ * - \{\{language\}\} or \{\{lng\}\} -\> language
24
+ * - \{\{namespace\}\} -\> namespace (or removed if namespace is undefined)
25
+ * - Normalizes duplicate slashes and returns a platform-correct path.
26
+ */
27
+ function getOutputPath(outputTemplate, language, namespace) {
28
+ if (!outputTemplate) return correctPath(`locales/${language}/${namespace ?? "translation"}.json`);
29
+ if (typeof outputTemplate === "function") try {
30
+ return correctPath(String(outputTemplate(language, namespace)).replace(/\/{2,}/g, "/"));
31
+ } catch {
32
+ return correctPath(`locales/${language}/${namespace ?? "translation"}.json`);
33
+ }
34
+ let out = String(outputTemplate);
35
+ out = out.replace(/\{\{language\}\}|\{\{lng\}\}/g, language);
36
+ if (namespace !== void 0 && namespace !== null) out = out.replace(/\{\{namespace\}\}/g, namespace);
37
+ else out = out.replace(/\/?\{\{namespace\}\}/g, "");
38
+ out = out.replace(/\/{2,}/g, "/");
39
+ return correctPath(out);
40
+ }
41
+
42
+ //#endregion
13
43
  //#region src/index.ts
14
44
  /**
15
45
  * i18next Plugin
File without changes
@@ -0,0 +1 @@
1
+ export { };