@intlayer/config 9.3.1 → 9.3.3

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 (42) hide show
  1. package/dist/cjs/configFile/buildConfigurationFields.cjs +24 -0
  2. package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
  3. package/dist/cjs/defaultValues/build.cjs +4 -0
  4. package/dist/cjs/defaultValues/build.cjs.map +1 -1
  5. package/dist/cjs/defaultValues/dictionary.cjs +41 -0
  6. package/dist/cjs/defaultValues/dictionary.cjs.map +1 -1
  7. package/dist/cjs/defaultValues/index.cjs +6 -0
  8. package/dist/cjs/dictionaryPreload.cjs +149 -0
  9. package/dist/cjs/dictionaryPreload.cjs.map +1 -0
  10. package/dist/cjs/extract/constants.cjs +19 -0
  11. package/dist/cjs/extract/constants.cjs.map +1 -0
  12. package/dist/cjs/extract/index.cjs +6 -0
  13. package/dist/cjs/extract/shouldExtract.cjs +38 -0
  14. package/dist/cjs/extract/shouldExtract.cjs.map +1 -0
  15. package/dist/esm/configFile/buildConfigurationFields.mjs +25 -1
  16. package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
  17. package/dist/esm/defaultValues/build.mjs +3 -1
  18. package/dist/esm/defaultValues/build.mjs.map +1 -1
  19. package/dist/esm/defaultValues/dictionary.mjs +38 -1
  20. package/dist/esm/defaultValues/dictionary.mjs.map +1 -1
  21. package/dist/esm/defaultValues/index.mjs +3 -3
  22. package/dist/esm/dictionaryPreload.mjs +144 -0
  23. package/dist/esm/dictionaryPreload.mjs.map +1 -0
  24. package/dist/esm/extract/constants.mjs +18 -0
  25. package/dist/esm/extract/constants.mjs.map +1 -0
  26. package/dist/esm/extract/index.mjs +4 -0
  27. package/dist/esm/extract/shouldExtract.mjs +37 -0
  28. package/dist/esm/extract/shouldExtract.mjs.map +1 -0
  29. package/dist/types/configFile/buildConfigurationFields.d.ts.map +1 -1
  30. package/dist/types/defaultValues/build.d.ts +3 -1
  31. package/dist/types/defaultValues/build.d.ts.map +1 -1
  32. package/dist/types/defaultValues/dictionary.d.ts +38 -1
  33. package/dist/types/defaultValues/dictionary.d.ts.map +1 -1
  34. package/dist/types/defaultValues/index.d.ts +3 -3
  35. package/dist/types/dictionaryPreload.d.ts +79 -0
  36. package/dist/types/dictionaryPreload.d.ts.map +1 -0
  37. package/dist/types/extract/constants.d.ts +11 -0
  38. package/dist/types/extract/constants.d.ts.map +1 -0
  39. package/dist/types/extract/index.d.ts +3 -0
  40. package/dist/types/extract/shouldExtract.d.ts +15 -0
  41. package/dist/types/extract/shouldExtract.d.ts.map +1 -0
  42. package/package.json +16 -3
@@ -0,0 +1,79 @@
1
+ //#region src/dictionaryPreload.d.ts
2
+ /**
3
+ * Matches a generated dynamic entry point, whose layout is
4
+ * `<dynamicDictionariesDir>/<key>.mjs`. The per-locale JSON chunks it imports
5
+ * live one directory deeper, under `json/`, and are deliberately excluded.
6
+ */
7
+ declare const DYNAMIC_ENTRY_PATTERN: RegExp;
8
+ /**
9
+ * Builds a filter matching only the generated dynamic entry points, for
10
+ * bundlers whose load hook is selected by a regular expression over the raw
11
+ * file path (esbuild).
12
+ *
13
+ * A hook registered on every `.mjs` would call back into JavaScript for each
14
+ * such file in the build, `node_modules` included, so the filter is anchored on
15
+ * the dictionaries directory name. It matches both path separators because
16
+ * esbuild tests the platform path, which is backslash-separated on Windows —
17
+ * the directory name itself never contains one.
18
+ *
19
+ * The name alone is not proof of location, so the callback must still confirm
20
+ * the full path lies inside `dynamicDictionariesDir`.
21
+ *
22
+ * @param dynamicDictionariesDir - Absolute dictionaries root, any separator.
23
+ */
24
+ declare const createDynamicEntryFilter: (dynamicDictionariesDir: string) => RegExp;
25
+ /**
26
+ * Specifier of the module the injected preamble reads the locale from, as the
27
+ * bundler plugins are expected to resolve it.
28
+ *
29
+ * Never emitted as-is: a generated entry point lives in the *application's*
30
+ * `.intlayer` directory, and an application depends on `intlayer` and its
31
+ * framework binding — not on `@intlayer/core` — so a bare specifier would
32
+ * resolve from a directory where the package is absent, or, worse, silently
33
+ * hit an unrelated copy hoisted higher up the tree.
34
+ */
35
+ declare const PRELOAD_MODULE_SPECIFIER = "@intlayer/core/localization";
36
+ /**
37
+ * Resolves {@link PRELOAD_MODULE_SPECIFIER} to an absolute id the injected
38
+ * preamble can import, from a package that actually depends on it.
39
+ *
40
+ * Deliberately not `require.resolve(PRELOAD_MODULE_SPECIFIER)`: that applies
41
+ * the `require` condition and lands on the package's CommonJS build, which the
42
+ * preamble would then pull into a *browser* bundle behind a CommonJS interop
43
+ * wrapper — a second copy of the module alongside the ESM one the application
44
+ * already imports, each with its own memoized locale. The manifest is resolved
45
+ * instead (a condition-free subpath) and its `import` entry read directly.
46
+ *
47
+ * @param requireFn - `require`, or `createRequire(import.meta.url)`, from the
48
+ * plugin package.
49
+ * @returns Absolute path to the ESM build, falling back to whatever the
50
+ * standard resolution yields if the package ever stops publishing one.
51
+ */
52
+ declare const resolvePreloadModuleId: (requireFn: NodeRequire) => string;
53
+ /** Why a generated entry point was left untransformed. */
54
+ type PreloadSkipReason = 'qualified' | 'unrecognized-shape';
55
+ type PreloadTransformResult = {
56
+ code: string;
57
+ skipped?: undefined;
58
+ } | {
59
+ code?: undefined;
60
+ skipped: PreloadSkipReason;
61
+ };
62
+ /**
63
+ * Adds the browsing-locale preload to a generated dynamic entry point.
64
+ *
65
+ * Bundler-agnostic on purpose: the Vite plugin and the esbuild plugin apply the
66
+ * identical transform, and keeping one implementation means the emitted shape
67
+ * cannot drift between them. The caller decides *which* modules to hand over
68
+ * (the id is matched against the dynamic dictionaries directory) and how to
69
+ * report a skip.
70
+ *
71
+ * @param code - Source of the generated `<key>.mjs` entry point.
72
+ * @param preloadModuleId - Specifier the preamble imports the locale resolver
73
+ * from, already resolved against the plugin package.
74
+ * @returns The transformed source, or the reason it was left alone.
75
+ */
76
+ declare const addDynamicEntryPreload: (code: string, preloadModuleId: string) => PreloadTransformResult;
77
+ //#endregion
78
+ export { DYNAMIC_ENTRY_PATTERN, PRELOAD_MODULE_SPECIFIER, PreloadSkipReason, PreloadTransformResult, addDynamicEntryPreload, createDynamicEntryFilter, resolvePreloadModuleId };
79
+ //# sourceMappingURL=dictionaryPreload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dictionaryPreload.d.ts","names":[],"sources":["../../src/dictionaryPreload.ts"],"mappings":";;;;;;cAYa,uBAAqB;;;;;;;;;;;;;;;;;cAsBrB,2BAAwB,mCAElC;;;;;;;;;;;cAmBU;;;;;;;;;;;;;;;;;cA2BA,yBAAsB,WAAe;;KAuEtC;KAEA;EACN;EAAc;;EACd;EAAkB,SAAS;;;;;;;;;;;;;;;;cAgBpB,yBAAsB,cACrB,4BAEX"}
@@ -0,0 +1,11 @@
1
+ //#region src/extract/constants.d.ts
2
+ /**
3
+ * Attributes that should be extracted as translatable strings from JSX/HTML elements.
4
+ * This is the single source of truth shared across all Intlayer compiler packages
5
+ * (@intlayer/babel, @intlayer/vue-compiler, @intlayer/svelte-compiler, @intlayer/engine)
6
+ * and the `eslint-plugin-intlayer` `no-raw-text` rule.
7
+ */
8
+ declare const ATTRIBUTES_TO_EXTRACT: readonly ['title', 'placeholder', 'alt', 'aria-label', 'label'];
9
+ //#endregion
10
+ export { ATTRIBUTES_TO_EXTRACT };
11
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","names":[],"sources":["../../../src/extract/constants.ts"],"mappings":";;;;;;;cAMa"}
@@ -0,0 +1,3 @@
1
+ import { ATTRIBUTES_TO_EXTRACT } from "./constants.js";
2
+ import { shouldExtract } from "./shouldExtract.js";
3
+ export { ATTRIBUTES_TO_EXTRACT, shouldExtract };
@@ -0,0 +1,15 @@
1
+ //#region src/extract/shouldExtract.d.ts
2
+ /**
3
+ * Checks whether the given text should be extracted as a translatable string.
4
+ *
5
+ * Filters out:
6
+ * - Empty strings
7
+ * - Emails
8
+ * - Single capitalized words (likely brand/proper nouns, e.g. "Intlayer")
9
+ * - Uncapitalized strings of 2 words or fewer (likely technical terms)
10
+ * - Dynamic content patterns like Vue bindings (`v-`) or object patterns (`{`)
11
+ */
12
+ declare const shouldExtract: (text: string) => boolean;
13
+ //#endregion
14
+ export { shouldExtract };
15
+ //# sourceMappingURL=shouldExtract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shouldExtract.d.ts","names":[],"sources":["../../../src/extract/shouldExtract.ts"],"mappings":";;;;;;;;;;;cAUa,gBAAa"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/config",
3
- "version": "9.3.1",
3
+ "version": "9.3.3",
4
4
  "private": false,
5
5
  "description": "Retrieve Intlayer configurations and manage environment variables for both server-side and client-side environments.",
6
6
  "keywords": [
@@ -57,6 +57,11 @@
57
57
  "import": "./dist/esm/callers/index.mjs",
58
58
  "require": "./dist/cjs/callers/index.cjs"
59
59
  },
60
+ "./extract": {
61
+ "types": "./dist/types/extract/index.d.ts",
62
+ "import": "./dist/esm/extract/index.mjs",
63
+ "require": "./dist/cjs/extract/index.cjs"
64
+ },
60
65
  "./utils": {
61
66
  "types": "./dist/types/utils/index.d.ts",
62
67
  "require": "./dist/cjs/utils/index.cjs",
@@ -92,6 +97,11 @@
92
97
  "require": "./dist/cjs/defaultValues/index.cjs",
93
98
  "import": "./dist/esm/defaultValues/index.mjs"
94
99
  },
100
+ "./dictionaryPreload": {
101
+ "types": "./dist/types/dictionaryPreload.d.ts",
102
+ "require": "./dist/cjs/dictionaryPreload.cjs",
103
+ "import": "./dist/esm/dictionaryPreload.mjs"
104
+ },
95
105
  "./bundle": {
96
106
  "types": "./dist/types/bundle/index.d.ts",
97
107
  "require": "./dist/cjs/bundle/index.cjs",
@@ -116,6 +126,9 @@
116
126
  "utils": [
117
127
  "./dist/types/utils/index.d.ts"
118
128
  ],
129
+ "extract": [
130
+ "./dist/types/extract/index.d.ts"
131
+ ],
119
132
  "file": [
120
133
  "./dist/types/loadExternalFile/index.d.ts"
121
134
  ],
@@ -164,7 +177,7 @@
164
177
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
165
178
  },
166
179
  "dependencies": {
167
- "@intlayer/types": "9.3.1",
180
+ "@intlayer/types": "9.3.3",
168
181
  "defu": "6.1.7",
169
182
  "dotenv": "17.4.2",
170
183
  "esbuild": "0.28.2",
@@ -179,7 +192,7 @@
179
192
  "rimraf": "6.1.3",
180
193
  "tsdown": "0.22.14",
181
194
  "typescript": "7.0.2",
182
- "vitest": "4.1.10"
195
+ "vitest": "4.1.11"
183
196
  },
184
197
  "peerDependencies": {
185
198
  "react": ">=16.0.0"