@intlayer/config 8.6.2 → 8.6.4

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 (65) hide show
  1. package/dist/cjs/built.browser.cjs +26 -1
  2. package/dist/cjs/built.browser.cjs.map +1 -1
  3. package/dist/cjs/built.cjs +26 -1
  4. package/dist/cjs/built.cjs.map +1 -1
  5. package/dist/cjs/client.cjs +2 -0
  6. package/dist/cjs/configFile/buildBrowserConfiguration.cjs +1 -10
  7. package/dist/cjs/configFile/buildBrowserConfiguration.cjs.map +1 -1
  8. package/dist/cjs/configFile/buildConfigurationFields.cjs +0 -1
  9. package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
  10. package/dist/cjs/envVars/envVars.cjs +8 -83
  11. package/dist/cjs/envVars/envVars.cjs.map +1 -1
  12. package/dist/cjs/envVars/index.cjs +0 -9
  13. package/dist/cjs/logger.cjs.map +1 -1
  14. package/dist/cjs/node.cjs +4 -0
  15. package/dist/cjs/utils/getStorageAttributes.cjs +13 -8
  16. package/dist/cjs/utils/getStorageAttributes.cjs.map +1 -1
  17. package/dist/cjs/utils/importMap.cjs +73 -0
  18. package/dist/cjs/utils/importMap.cjs.map +1 -0
  19. package/dist/cjs/utils/index.cjs +6 -0
  20. package/dist/cjs/utils/setIntlayerIdentifier.cjs +14 -0
  21. package/dist/cjs/utils/setIntlayerIdentifier.cjs.map +1 -0
  22. package/dist/esm/built.browser.mjs +13 -1
  23. package/dist/esm/built.browser.mjs.map +1 -1
  24. package/dist/esm/built.mjs +13 -1
  25. package/dist/esm/built.mjs.map +1 -1
  26. package/dist/esm/client.mjs +2 -1
  27. package/dist/esm/configFile/buildBrowserConfiguration.mjs +1 -8
  28. package/dist/esm/configFile/buildBrowserConfiguration.mjs.map +1 -1
  29. package/dist/esm/configFile/buildConfigurationFields.mjs +0 -1
  30. package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
  31. package/dist/esm/envVars/envVars.mjs +9 -75
  32. package/dist/esm/envVars/envVars.mjs.map +1 -1
  33. package/dist/esm/envVars/index.mjs +2 -2
  34. package/dist/esm/logger.mjs.map +1 -1
  35. package/dist/esm/node.mjs +2 -1
  36. package/dist/esm/utils/cacheDisk.mjs +4 -4
  37. package/dist/esm/utils/cacheDisk.mjs.map +1 -1
  38. package/dist/esm/utils/getStorageAttributes.mjs +13 -8
  39. package/dist/esm/utils/getStorageAttributes.mjs.map +1 -1
  40. package/dist/esm/utils/importMap.mjs +70 -0
  41. package/dist/esm/utils/importMap.mjs.map +1 -0
  42. package/dist/esm/utils/index.mjs +3 -1
  43. package/dist/esm/utils/setIntlayerIdentifier.mjs +12 -0
  44. package/dist/esm/utils/setIntlayerIdentifier.mjs.map +1 -0
  45. package/dist/types/built.browser.d.ts +15 -1
  46. package/dist/types/built.browser.d.ts.map +1 -1
  47. package/dist/types/built.d.ts +15 -1
  48. package/dist/types/built.d.ts.map +1 -1
  49. package/dist/types/client.d.ts +2 -1
  50. package/dist/types/configFile/buildBrowserConfiguration.d.ts +0 -1
  51. package/dist/types/configFile/buildBrowserConfiguration.d.ts.map +1 -1
  52. package/dist/types/configFile/configurationSchema.d.ts +2 -2
  53. package/dist/types/envVars/envVars.d.ts +2 -68
  54. package/dist/types/envVars/envVars.d.ts.map +1 -1
  55. package/dist/types/envVars/index.d.ts +2 -2
  56. package/dist/types/logger.d.ts +1 -1
  57. package/dist/types/logger.d.ts.map +1 -1
  58. package/dist/types/node.d.ts +2 -1
  59. package/dist/types/utils/getStorageAttributes.d.ts.map +1 -1
  60. package/dist/types/utils/importMap.d.ts +85 -0
  61. package/dist/types/utils/importMap.d.ts.map +1 -0
  62. package/dist/types/utils/index.d.ts +3 -1
  63. package/dist/types/utils/setIntlayerIdentifier.d.ts +15 -0
  64. package/dist/types/utils/setIntlayerIdentifier.d.ts.map +1 -0
  65. package/package.json +2 -2
@@ -1,71 +1,5 @@
1
1
  //#region src/envVars/envVars.ts
2
2
  /**
3
- * True when the build-time routing mode is known and is NOT 'no-prefix'.
4
- * Use to guard no-prefix-specific code paths so bundlers can eliminate them.
5
- *
6
- * @example
7
- * if (!TREE_SHAKE_NO_PREFIX && mode === 'no-prefix') { ... }
8
- */
9
- const TREE_SHAKE_NO_PREFIX = process.env["INTLAYER_ROUTING_MODE"] && process.env["INTLAYER_ROUTING_MODE"] !== "no-prefix";
10
- /**
11
- * True when the build-time routing mode is known and is NOT 'search-params'.
12
- *
13
- * @example
14
- * if (!TREE_SHAKE_SEARCH_PARAMS && mode === 'search-params') { ... }
15
- */
16
- const TREE_SHAKE_SEARCH_PARAMS = process.env["INTLAYER_ROUTING_MODE"] && process.env["INTLAYER_ROUTING_MODE"] !== "search-params";
17
- /**
18
- * True when the build-time routing mode is known and is not a prefix-based
19
- * mode (neither 'prefix-all' nor 'prefix-no-default').
20
- *
21
- * @example
22
- * if (!TREE_SHAKE_PREFIX_MODES && (mode === 'prefix-all' || mode === 'prefix-no-default')) { ... }
23
- */
24
- const TREE_SHAKE_PREFIX_MODES = process.env["INTLAYER_ROUTING_MODE"] && process.env["INTLAYER_ROUTING_MODE"] !== "prefix-all" && process.env["INTLAYER_ROUTING_MODE"] !== "prefix-no-default";
25
- /**
26
- * True when rewrite rules are explicitly disabled at build time
27
- * (INTLAYER_ROUTING_REWRITE_RULES === 'false').
28
- *
29
- * @example
30
- * if (!TREE_SHAKE_REWRITE && rewrite) { ... }
31
- */
32
- const TREE_SHAKE_REWRITE = process.env["INTLAYER_ROUTING_REWRITE_RULES"] === "false";
33
- /**
34
- * True when cookie storage is explicitly disabled at build time.
35
- *
36
- * @example
37
- * if (!TREE_SHAKE_STORAGE_COOKIES) { // cookie logic }
38
- */
39
- const TREE_SHAKE_STORAGE_COOKIES = process.env["INTLAYER_ROUTING_STORAGE_COOKIES"] === "false";
40
- /**
41
- * True when localStorage is explicitly disabled at build time.
42
- *
43
- * @example
44
- * if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE) { // localStorage logic }
45
- */
46
- const TREE_SHAKE_STORAGE_LOCAL_STORAGE = process.env["INTLAYER_ROUTING_STORAGE_LOCALSTORAGE"] === "false";
47
- /**
48
- * True when sessionStorage is explicitly disabled at build time.
49
- *
50
- * @example
51
- * if (!TREE_SHAKE_STORAGE_SESSION_STORAGE) { // sessionStorage logic }
52
- */
53
- const TREE_SHAKE_STORAGE_SESSION_STORAGE = process.env["INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE"] === "false";
54
- /**
55
- * True when header storage is explicitly disabled at build time.
56
- *
57
- * @example
58
- * if (!TREE_SHAKE_STORAGE_HEADERS) { // header logic }
59
- */
60
- const TREE_SHAKE_STORAGE_HEADERS = process.env["INTLAYER_ROUTING_STORAGE_HEADERS"] === "false";
61
- /**
62
- * True when the editor is explicitly disabled at build time.
63
- *
64
- * @example
65
- * if (!TREE_SHAKE_EDITOR) { // editor logic }
66
- */
67
- const TREE_SHAKE_EDITOR = process.env["INTLAYER_EDITOR_ENABLED"] === "false";
68
- /**
69
3
  * Converts a list of unused NodeType keys into env-var definitions.
70
4
  * Set to `"false"` so bundlers can eliminate the corresponding plugin code.
71
5
  *
@@ -92,19 +26,19 @@ const formatNodeTypeToEnvVar = (nodeTypes, addProcessEnv = false) => nodeTypes.r
92
26
  * getConfigEnvVars(config, true)
93
27
  * // { 'process.env.INTLAYER_ROUTING_MODE': '"prefix-no-default"', ... }
94
28
  */
95
- const getConfigEnvVars = (config, addProcessEnv = false) => {
29
+ const getConfigEnvVars = (config, addProcessEnv = false, wrapValue = (value) => value) => {
96
30
  const prefix = addProcessEnv ? "process.env." : "";
97
31
  const { routing, editor } = config;
98
- const envVars = { [`${prefix}INTLAYER_ROUTING_MODE`]: JSON.stringify(routing.mode) };
99
- if (!routing.rewrite) envVars[`${prefix}INTLAYER_ROUTING_REWRITE_RULES`] = "\"false\"";
100
- if (routing.storage.cookies.length === 0) envVars[`${prefix}INTLAYER_ROUTING_STORAGE_COOKIES`] = "\"false\"";
101
- if (routing.storage.localStorage.length === 0) envVars[`${prefix}INTLAYER_ROUTING_STORAGE_LOCALSTORAGE`] = "\"false\"";
102
- if (routing.storage.sessionStorage.length === 0) envVars[`${prefix}INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE`] = "\"false\"";
103
- if (routing.storage.headers.length === 0) envVars[`${prefix}INTLAYER_ROUTING_STORAGE_HEADERS`] = "\"false\"";
104
- if (editor?.enabled === false) envVars[`${prefix}INTLAYER_EDITOR_ENABLED`] = "\"false\"";
32
+ const envVars = { [`${prefix}INTLAYER_ROUTING_MODE`]: wrapValue(routing.mode) };
33
+ if (!routing.rewrite) envVars[`${prefix}INTLAYER_ROUTING_REWRITE_RULES`] = wrapValue("false");
34
+ if (!routing.storage.cookies || routing.storage.cookies.length === 0) envVars[`${prefix}INTLAYER_ROUTING_STORAGE_COOKIES`] = wrapValue("false");
35
+ if (!routing.storage.localStorage || routing.storage.localStorage.length === 0) envVars[`${prefix}INTLAYER_ROUTING_STORAGE_LOCALSTORAGE`] = wrapValue("false");
36
+ if (!routing.storage.sessionStorage || routing.storage.sessionStorage.length === 0) envVars[`${prefix}INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE`] = wrapValue("false");
37
+ if (!routing.storage.headers || routing.storage.headers.length === 0) envVars[`${prefix}INTLAYER_ROUTING_STORAGE_HEADERS`] = wrapValue("false");
38
+ if (editor?.enabled === false) envVars[`${prefix}INTLAYER_EDITOR_ENABLED`] = wrapValue("false");
105
39
  return envVars;
106
40
  };
107
41
 
108
42
  //#endregion
109
- export { TREE_SHAKE_EDITOR, TREE_SHAKE_NO_PREFIX, TREE_SHAKE_PREFIX_MODES, TREE_SHAKE_REWRITE, TREE_SHAKE_SEARCH_PARAMS, TREE_SHAKE_STORAGE_COOKIES, TREE_SHAKE_STORAGE_HEADERS, TREE_SHAKE_STORAGE_LOCAL_STORAGE, TREE_SHAKE_STORAGE_SESSION_STORAGE, formatNodeTypeToEnvVar, getConfigEnvVars };
43
+ export { formatNodeTypeToEnvVar, getConfigEnvVars };
110
44
  //# sourceMappingURL=envVars.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"envVars.mjs","names":[],"sources":["../../../src/envVars/envVars.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\n\n// ── Tree-shake constants ──────────────────────────────────────────────────────\n// When these env vars are injected at build time, bundlers eliminate the\n// branches guarded by these constants.\n\n/**\n * True when the build-time routing mode is known and is NOT 'no-prefix'.\n * Use to guard no-prefix-specific code paths so bundlers can eliminate them.\n *\n * @example\n * if (!TREE_SHAKE_NO_PREFIX && mode === 'no-prefix') { ... }\n */\nexport const TREE_SHAKE_NO_PREFIX =\n process.env['INTLAYER_ROUTING_MODE'] &&\n process.env['INTLAYER_ROUTING_MODE'] !== 'no-prefix';\n\n/**\n * True when the build-time routing mode is known and is NOT 'search-params'.\n *\n * @example\n * if (!TREE_SHAKE_SEARCH_PARAMS && mode === 'search-params') { ... }\n */\nexport const TREE_SHAKE_SEARCH_PARAMS =\n process.env['INTLAYER_ROUTING_MODE'] &&\n process.env['INTLAYER_ROUTING_MODE'] !== 'search-params';\n\n/**\n * True when the build-time routing mode is known and is not a prefix-based\n * mode (neither 'prefix-all' nor 'prefix-no-default').\n *\n * @example\n * if (!TREE_SHAKE_PREFIX_MODES && (mode === 'prefix-all' || mode === 'prefix-no-default')) { ... }\n */\nexport const TREE_SHAKE_PREFIX_MODES =\n process.env['INTLAYER_ROUTING_MODE'] &&\n process.env['INTLAYER_ROUTING_MODE'] !== 'prefix-all' &&\n process.env['INTLAYER_ROUTING_MODE'] !== 'prefix-no-default';\n\n/**\n * True when rewrite rules are explicitly disabled at build time\n * (INTLAYER_ROUTING_REWRITE_RULES === 'false').\n *\n * @example\n * if (!TREE_SHAKE_REWRITE && rewrite) { ... }\n */\nexport const TREE_SHAKE_REWRITE =\n process.env['INTLAYER_ROUTING_REWRITE_RULES'] === 'false';\n\n// ── Storage tree-shake constants ──────────────────────────────────────────────\n\n/**\n * True when cookie storage is explicitly disabled at build time.\n *\n * @example\n * if (!TREE_SHAKE_STORAGE_COOKIES) { // cookie logic }\n */\nexport const TREE_SHAKE_STORAGE_COOKIES =\n process.env['INTLAYER_ROUTING_STORAGE_COOKIES'] === 'false';\n\n/**\n * True when localStorage is explicitly disabled at build time.\n *\n * @example\n * if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE) { // localStorage logic }\n */\nexport const TREE_SHAKE_STORAGE_LOCAL_STORAGE =\n process.env['INTLAYER_ROUTING_STORAGE_LOCALSTORAGE'] === 'false';\n\n/**\n * True when sessionStorage is explicitly disabled at build time.\n *\n * @example\n * if (!TREE_SHAKE_STORAGE_SESSION_STORAGE) { // sessionStorage logic }\n */\nexport const TREE_SHAKE_STORAGE_SESSION_STORAGE =\n process.env['INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE'] === 'false';\n\n/**\n * True when header storage is explicitly disabled at build time.\n *\n * @example\n * if (!TREE_SHAKE_STORAGE_HEADERS) { // header logic }\n */\nexport const TREE_SHAKE_STORAGE_HEADERS =\n process.env['INTLAYER_ROUTING_STORAGE_HEADERS'] === 'false';\n\n/**\n * True when the editor is explicitly disabled at build time.\n *\n * @example\n * if (!TREE_SHAKE_EDITOR) { // editor logic }\n */\nexport const TREE_SHAKE_EDITOR =\n process.env['INTLAYER_EDITOR_ENABLED'] === 'false';\n\n// ── Build-time env-var helpers ────────────────────────────────────────────────\n\n/**\n * Converts a list of unused NodeType keys into env-var definitions.\n * Set to `\"false\"` so bundlers can eliminate the corresponding plugin code.\n *\n * @example\n * formatNodeTypeToEnvVar(['enumeration'])\n * // { 'INTLAYER_NODE_TYPE_ENUMERATION': '\"false\"' }\n *\n * formatNodeTypeToEnvVar(['enumeration'], true)\n * // { 'process.env.INTLAYER_NODE_TYPE_ENUMERATION': '\"false\"' }\n */\nexport const formatNodeTypeToEnvVar = (\n nodeTypes: string[],\n addProcessEnv: boolean = false\n): Record<string, string> =>\n nodeTypes.reduce(\n (acc, nodeType) => {\n acc[\n addProcessEnv\n ? `process.env.INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}`\n : `INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}`\n ] = '\"false\"';\n return acc;\n },\n {} as Record<string, string>\n );\n\n/**\n * Returns env-var definitions for the full Intlayer config to be injected at\n * build time. Allows bundlers to dead-code-eliminate unused routing modes,\n * rewrite logic, storage mechanisms, and editor code.\n *\n * @example\n * getConfigEnvVars(config)\n * // { INTLAYER_ROUTING_MODE: '\"prefix-no-default\"', INTLAYER_ROUTING_REWRITE_RULES: '\"false\"', ... }\n *\n * getConfigEnvVars(config, true)\n * // { 'process.env.INTLAYER_ROUTING_MODE': '\"prefix-no-default\"', ... }\n */\nexport const getConfigEnvVars = (\n config: IntlayerConfig,\n addProcessEnv: boolean = false\n): Record<string, string> => {\n const prefix = addProcessEnv ? 'process.env.' : '';\n const { routing, editor } = config;\n\n const envVars: Record<string, string> = {\n [`${prefix}INTLAYER_ROUTING_MODE`]: JSON.stringify(routing.mode),\n };\n\n if (!routing.rewrite) {\n envVars[`${prefix}INTLAYER_ROUTING_REWRITE_RULES`] = '\"false\"';\n }\n\n if (routing.storage.cookies.length === 0) {\n envVars[`${prefix}INTLAYER_ROUTING_STORAGE_COOKIES`] = '\"false\"';\n }\n\n if (routing.storage.localStorage.length === 0) {\n envVars[`${prefix}INTLAYER_ROUTING_STORAGE_LOCALSTORAGE`] = '\"false\"';\n }\n\n if (routing.storage.sessionStorage.length === 0) {\n envVars[`${prefix}INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE`] = '\"false\"';\n }\n\n if (routing.storage.headers.length === 0) {\n envVars[`${prefix}INTLAYER_ROUTING_STORAGE_HEADERS`] = '\"false\"';\n }\n\n if (editor?.enabled === false) {\n envVars[`${prefix}INTLAYER_EDITOR_ENABLED`] = '\"false\"';\n }\n\n return envVars;\n};\n"],"mappings":";;;;;;;;AAaA,MAAa,uBACX,QAAQ,IAAI,4BACZ,QAAQ,IAAI,6BAA6B;;;;;;;AAQ3C,MAAa,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AAO"}
1
+ {"version":3,"file":"envVars.mjs","names":[],"sources":["../../../src/envVars/envVars.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Converts a list of unused NodeType keys into env-var definitions.\n * Set to `\"false\"` so bundlers can eliminate the corresponding plugin code.\n *\n * @example\n * formatNodeTypeToEnvVar(['enumeration'])\n * // { 'INTLAYER_NODE_TYPE_ENUMERATION': '\"false\"' }\n *\n * formatNodeTypeToEnvVar(['enumeration'], true)\n * // { 'process.env.INTLAYER_NODE_TYPE_ENUMERATION': '\"false\"' }\n */\nexport const formatNodeTypeToEnvVar = (\n nodeTypes: string[],\n addProcessEnv: boolean = false\n): Record<string, string> =>\n nodeTypes.reduce(\n (acc, nodeType) => {\n acc[\n addProcessEnv\n ? `process.env.INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}`\n : `INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}`\n ] = '\"false\"';\n return acc;\n },\n {} as Record<string, string>\n );\n\n/**\n * Returns env-var definitions for the full Intlayer config to be injected at\n * build time. Allows bundlers to dead-code-eliminate unused routing modes,\n * rewrite logic, storage mechanisms, and editor code.\n *\n * @example\n * getConfigEnvVars(config)\n * // { INTLAYER_ROUTING_MODE: '\"prefix-no-default\"', INTLAYER_ROUTING_REWRITE_RULES: '\"false\"', ... }\n *\n * getConfigEnvVars(config, true)\n * // { 'process.env.INTLAYER_ROUTING_MODE': '\"prefix-no-default\"', ... }\n */\nexport const getConfigEnvVars = (\n config: IntlayerConfig,\n addProcessEnv: boolean = false,\n wrapValue: (value: string) => string = (value) => value\n): Record<string, string> => {\n const prefix = addProcessEnv ? 'process.env.' : '';\n const { routing, editor } = config;\n\n const envVars: Record<string, string> = {\n [`${prefix}INTLAYER_ROUTING_MODE`]: wrapValue(routing.mode),\n };\n\n if (!routing.rewrite) {\n envVars[`${prefix}INTLAYER_ROUTING_REWRITE_RULES`] = wrapValue('false');\n }\n\n if (!routing.storage.cookies || routing.storage.cookies.length === 0) {\n envVars[`${prefix}INTLAYER_ROUTING_STORAGE_COOKIES`] = wrapValue('false');\n }\n\n if (\n !routing.storage.localStorage ||\n routing.storage.localStorage.length === 0\n ) {\n envVars[`${prefix}INTLAYER_ROUTING_STORAGE_LOCALSTORAGE`] =\n wrapValue('false');\n }\n\n if (\n !routing.storage.sessionStorage ||\n routing.storage.sessionStorage.length === 0\n ) {\n envVars[`${prefix}INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE`] =\n wrapValue('false');\n }\n\n if (!routing.storage.headers || routing.storage.headers.length === 0) {\n envVars[`${prefix}INTLAYER_ROUTING_STORAGE_HEADERS`] = wrapValue('false');\n }\n\n if (editor?.enabled === false) {\n envVars[`${prefix}INTLAYER_EDITOR_ENABLED`] = wrapValue('false');\n }\n\n return envVars;\n};\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,0BACX,WACA,gBAAyB,UAEzB,UAAU,QACP,KAAK,aAAa;AACjB,KACE,gBACI,kCAAkC,SAAS,aAAa,KACxD,sBAAsB,SAAS,aAAa,MAC9C;AACJ,QAAO;GAET,EAAE,CACH;;;;;;;;;;;;;AAcH,MAAa,oBACX,QACA,gBAAyB,OACzB,aAAwC,UAAU,UACvB;CAC3B,MAAM,SAAS,gBAAgB,iBAAiB;CAChD,MAAM,EAAE,SAAS,WAAW;CAE5B,MAAM,UAAkC,GACrC,GAAG,OAAO,yBAAyB,UAAU,QAAQ,KAAK,EAC5D;AAED,KAAI,CAAC,QAAQ,QACX,SAAQ,GAAG,OAAO,mCAAmC,UAAU,QAAQ;AAGzE,KAAI,CAAC,QAAQ,QAAQ,WAAW,QAAQ,QAAQ,QAAQ,WAAW,EACjE,SAAQ,GAAG,OAAO,qCAAqC,UAAU,QAAQ;AAG3E,KACE,CAAC,QAAQ,QAAQ,gBACjB,QAAQ,QAAQ,aAAa,WAAW,EAExC,SAAQ,GAAG,OAAO,0CAChB,UAAU,QAAQ;AAGtB,KACE,CAAC,QAAQ,QAAQ,kBACjB,QAAQ,QAAQ,eAAe,WAAW,EAE1C,SAAQ,GAAG,OAAO,4CAChB,UAAU,QAAQ;AAGtB,KAAI,CAAC,QAAQ,QAAQ,WAAW,QAAQ,QAAQ,QAAQ,WAAW,EACjE,SAAQ,GAAG,OAAO,qCAAqC,UAAU,QAAQ;AAG3E,KAAI,QAAQ,YAAY,MACtB,SAAQ,GAAG,OAAO,4BAA4B,UAAU,QAAQ;AAGlE,QAAO"}
@@ -1,3 +1,3 @@
1
- import { TREE_SHAKE_EDITOR, TREE_SHAKE_NO_PREFIX, TREE_SHAKE_PREFIX_MODES, TREE_SHAKE_REWRITE, TREE_SHAKE_SEARCH_PARAMS, TREE_SHAKE_STORAGE_COOKIES, TREE_SHAKE_STORAGE_HEADERS, TREE_SHAKE_STORAGE_LOCAL_STORAGE, TREE_SHAKE_STORAGE_SESSION_STORAGE, formatNodeTypeToEnvVar, getConfigEnvVars } from "./envVars.mjs";
1
+ import { formatNodeTypeToEnvVar, getConfigEnvVars } from "./envVars.mjs";
2
2
 
3
- export { TREE_SHAKE_EDITOR, TREE_SHAKE_NO_PREFIX, TREE_SHAKE_PREFIX_MODES, TREE_SHAKE_REWRITE, TREE_SHAKE_SEARCH_PARAMS, TREE_SHAKE_STORAGE_COOKIES, TREE_SHAKE_STORAGE_HEADERS, TREE_SHAKE_STORAGE_LOCAL_STORAGE, TREE_SHAKE_STORAGE_SESSION_STORAGE, formatNodeTypeToEnvVar, getConfigEnvVars };
3
+ export { formatNodeTypeToEnvVar, getConfigEnvVars };
@@ -1 +1 @@
1
- {"version":3,"file":"logger.mjs","names":[],"sources":["../../src/logger.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n} from '@intlayer/types/config';\nimport type * as ANSIColorsTypes from './colors';\nimport { BEIGE, BLUE, GREEN, GREY, RED, RESET } from './colors';\n\nexport type ANSIColorsType =\n (typeof ANSIColorsTypes)[keyof typeof ANSIColorsTypes];\n\nexport type Details = {\n isVerbose?: boolean;\n level?: 'info' | 'warn' | 'error' | 'debug';\n config?: CustomIntlayerConfig['log'];\n};\n\nexport type Logger = (content: any, details?: Details) => void;\n\nlet loggerPrefix: string | undefined;\n\nexport const setPrefix = (prefix: string | undefined) => {\n loggerPrefix = prefix;\n};\n\nexport const getPrefix = (configPrefix?: string): string | undefined => {\n if (typeof loggerPrefix !== 'undefined') {\n return loggerPrefix;\n }\n\n return configPrefix;\n};\n\nexport const logger: Logger = (content, details) => {\n const config = details?.config ?? {};\n const mode = config.mode ?? 'default';\n\n if (mode === 'disabled' || (details?.isVerbose && mode !== 'verbose')) return;\n\n const prefix = getPrefix(config.prefix);\n const flatContent = prefix ? [prefix, ...[content].flat()] : [content].flat();\n const level = details?.level ?? 'info';\n\n const logMethod =\n config[level] ?? console[level] ?? config.log ?? console.log;\n\n logMethod(...flatContent);\n};\n\nexport const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\n/**\n * The appLogger function takes the logger and merges it with the configuration from the intlayer config file.\n * It allows overriding the default configuration by passing a config object in the details parameter.\n * The configuration is merged with the default configuration from the intlayer config file.\n */\nexport const getAppLogger =\n (configuration?: IntlayerConfig, globalDetails?: Details) =>\n (content: any, details?: Details) =>\n logger(content, {\n ...(details ?? {}),\n config: {\n ...configuration?.log,\n ...globalDetails?.config,\n ...(details?.config ?? {}),\n },\n });\n\nexport const colorize = (\n string: string,\n color?: ANSIColorsType,\n reset?: boolean | ANSIColorsType\n): string =>\n color\n ? `${color}${string}${reset ? (typeof reset === 'boolean' ? RESET : reset) : RESET}`\n : string;\n\nexport const colorizeLocales = (\n locales: Locale | Locale[],\n color: ANSIColorsType = GREEN,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [locales]\n .flat()\n .map((locale) => colorize(locale, color, reset))\n .join(`, `);\n\nexport const colorizeKey = (\n keyPath: string | string[],\n color: ANSIColorsType = BEIGE,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [keyPath]\n .flat()\n .map((key) => colorize(key, color, reset))\n .join(`, `);\n\nexport const colorizePath = (\n path: string | string[],\n color: ANSIColorsType = GREY,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [path]\n .flat()\n .map((path) => colorize(path, color, reset))\n .join(`, `);\n\nexport const colorizeNumber = (\n number: number | string,\n options: Partial<Record<Intl.LDMLPluralRule, ANSIColorsType>> = {\n zero: BLUE,\n one: BLUE,\n two: BLUE,\n few: BLUE,\n many: BLUE,\n other: BLUE,\n }\n): string => {\n if (number === 0 || number === '0') {\n const color = options.zero ?? GREEN;\n return colorize(number.toString(), color);\n }\n\n // Kept inside the function. Top-level instantiation of classes/APIs\n // is treated as a side-effect and prevents tree-shaking if the function is unused.\n const rule = new Intl.PluralRules('en').select(Number(number));\n const color = options[rule];\n return colorize(number.toString(), color);\n};\n\nexport const removeColor = (text: string) =>\n // biome-ignore lint/suspicious/noControlCharactersInRegex: we need to remove the color codes\n text.replace(/\\x1b\\[[0-9;]*m/g, '');\n\nconst getLength = (length: number | number[] | string | string[]): number => {\n let value: number = 0;\n if (typeof length === 'number') {\n value = length;\n }\n if (typeof length === 'string') {\n value = length.length;\n }\n if (\n Array.isArray(length) &&\n length.every((locale) => typeof locale === 'string')\n ) {\n value = Math.max(...length.map((str) => str.length));\n }\n if (\n Array.isArray(length) &&\n length.every((locale) => typeof locale === 'number')\n ) {\n value = Math.max(...length);\n }\n return Math.max(value, 0);\n};\n\nconst defaultColonOptions = {\n colSize: 0,\n minSize: 0,\n maxSize: Infinity,\n pad: 'right',\n padChar: '0',\n};\n\n/**\n * Create a string of spaces of a given length.\n *\n * @param colSize - The length of the string to create.\n * @returns A string of spaces.\n */\nexport const colon = (\n text: string | string[],\n options?: {\n colSize?: number | number[] | string | string[];\n minSize?: number;\n maxSize?: number;\n pad?: 'left' | 'right';\n padChar?: string;\n }\n): string =>\n [text]\n .flat()\n .map((text) => {\n const { colSize, minSize, maxSize, pad } = {\n ...defaultColonOptions,\n ...(options ?? {}),\n };\n\n const length = getLength(colSize);\n const spacesLength = Math.max(\n minSize!,\n Math.min(maxSize!, length - removeColor(text).length)\n );\n\n if (pad === 'left') {\n return `${' '.repeat(spacesLength)}${text}`;\n }\n\n return `${text}${' '.repeat(spacesLength)}`;\n })\n .join('');\n\nexport const x = colorize('✗', RED);\nexport const v = colorize('✓', GREEN);\nexport const clock = colorize('⏲', BLUE);\n"],"mappings":";;;AAmBA,IAAI;AAEJ,MAAa,aAAa,WAA+B;AACvD,gBAAe;;AAGjB,MAAa,aAAa,iBAA8C;AACtE,KAAI,OAAO,iBAAiB,YAC1B,QAAO;AAGT,QAAO;;AAGT,MAAa,UAAkB,SAAS,YAAY;CAClD,MAAM,SAAS,SAAS,UAAU,EAAE;CACpC,MAAM,OAAO,OAAO,QAAQ;AAE5B,KAAI,SAAS,cAAe,SAAS,aAAa,SAAS,UAAY;CAEvE,MAAM,SAAS,UAAU,OAAO,OAAO;CACvC,MAAM,cAAc,SAAS,CAAC,QAAQ,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM;CAC7E,MAAM,QAAQ,SAAS,SAAS;AAKhC,EAFE,OAAO,UAAU,QAAQ,UAAU,OAAO,OAAO,QAAQ,KAEjD,GAAG,YAAY;;AAG3B,MAAa,gBAAgB;CAAC;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAI;;;;;;AAO/E,MAAa,gBACV,eAAgC,mBAChC,SAAc,YACb,OAAO,SAAS;CACd,GAAI,WAAW,EAAE;CACjB,QAAQ;EACN,GAAG,eAAe;EAClB,GAAG,eAAe;EAClB,GAAI,SAAS,UAAU,EAAE;EAC1B;CACF,CAAC;AAEN,MAAa,YACX,QACA,OACA,UAEA,QACI,GAAG,QAAQ,SAAS,QAAS,OAAO,UAAU,YAAY,QAAQ,QAAS,UAC3E;AAEN,MAAa,mBACX,SACA,QAAwB,OACxB,QAAkC,UA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SAAS;CACT,KAAK;CACL,SAAS;CACV;;;;;;;AAQD,MAAa,SACX,MACA,YAQA,CAAC,KAAK,CACH,MAAM,CACN,KAAK,SAAS;CACb,MAAM,EAAE,SAAS,SAAS,SAAS,QAAQ;EACzC,GAAG;EACH,GAAI,WAAW,EAAE;EAClB;CAED,MAAM,SAAS,UAAU,QAAQ;CACjC,MAAM,eAAe,KAAK,IACxB,SACA,KAAK,IAAI,SAAU,SAAS,YAAY,KAAK,CAAC,OAAO,CACtD;AAED,KAAI,QAAQ,OACV,QAAO,GAAG,IAAI,OAAO,aAAa,GAAG;AAGvC,QAAO,GAAG,OAAO,IAAI,OAAO,aAAa;EACzC,CACD,KAAK,GAAG;AAEb,MAAa,IAAI,SAAS,KAAK,IAAI;AACnC,MAAa,IAAI,SAAS,KAAK,MAAM;AACrC,MAAa,QAAQ,SAAS,KAAK,KAAK"}
1
+ {"version":3,"file":"logger.mjs","names":[],"sources":["../../src/logger.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n} from '@intlayer/types/config';\nimport type * as ANSIColorsTypes from './colors';\nimport { BEIGE, BLUE, GREEN, GREY, RED, RESET } from './colors';\n\nexport type ANSIColorsType =\n (typeof ANSIColorsTypes)[keyof typeof ANSIColorsTypes];\n\nexport type Details = {\n isVerbose?: boolean;\n level?: 'info' | 'warn' | 'error' | 'debug';\n config?: CustomIntlayerConfig['log'];\n};\n\nexport type Logger = (content: any, details?: Details) => void;\n\nlet loggerPrefix: string | undefined;\n\nexport const setPrefix = (prefix: string | undefined) => {\n loggerPrefix = prefix;\n};\n\nexport const getPrefix = (configPrefix?: string): string | undefined => {\n if (typeof loggerPrefix !== 'undefined') {\n return loggerPrefix;\n }\n\n return configPrefix;\n};\n\nexport const logger: Logger = (content, details) => {\n const config = details?.config ?? {};\n const mode = config.mode ?? 'default';\n\n if (mode === 'disabled' || (details?.isVerbose && mode !== 'verbose')) return;\n\n const prefix = getPrefix(config.prefix);\n const flatContent = prefix ? [prefix, ...[content].flat()] : [content].flat();\n const level = details?.level ?? 'info';\n\n const logMethod =\n config[level] ?? console[level] ?? config.log ?? console.log;\n\n logMethod(...flatContent);\n};\n\nexport const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\n/**\n * The appLogger function takes the logger and merges it with the configuration from the intlayer config file.\n * It allows overriding the default configuration by passing a config object in the details parameter.\n * The configuration is merged with the default configuration from the intlayer config file.\n */\nexport const getAppLogger =\n (configuration?: Pick<IntlayerConfig, 'log'>, globalDetails?: Details) =>\n (content: any, details?: Details) =>\n logger(content, {\n ...(details ?? {}),\n config: {\n ...configuration?.log,\n ...globalDetails?.config,\n ...(details?.config ?? {}),\n },\n });\n\nexport const colorize = (\n string: string,\n color?: ANSIColorsType,\n reset?: boolean | ANSIColorsType\n): string =>\n color\n ? `${color}${string}${reset ? (typeof reset === 'boolean' ? RESET : reset) : RESET}`\n : string;\n\nexport const colorizeLocales = (\n locales: Locale | Locale[],\n color: ANSIColorsType = GREEN,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [locales]\n .flat()\n .map((locale) => colorize(locale, color, reset))\n .join(`, `);\n\nexport const colorizeKey = (\n keyPath: string | string[],\n color: ANSIColorsType = BEIGE,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [keyPath]\n .flat()\n .map((key) => colorize(key, color, reset))\n .join(`, `);\n\nexport const colorizePath = (\n path: string | string[],\n color: ANSIColorsType = GREY,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [path]\n .flat()\n .map((path) => colorize(path, color, reset))\n .join(`, `);\n\nexport const colorizeNumber = (\n number: number | string,\n options: Partial<Record<Intl.LDMLPluralRule, ANSIColorsType>> = {\n zero: BLUE,\n one: BLUE,\n two: BLUE,\n few: BLUE,\n many: BLUE,\n other: BLUE,\n }\n): string => {\n if (number === 0 || number === '0') {\n const color = options.zero ?? GREEN;\n return colorize(number.toString(), color);\n }\n\n // Kept inside the function. Top-level instantiation of classes/APIs\n // is treated as a side-effect and prevents tree-shaking if the function is unused.\n const rule = new Intl.PluralRules('en').select(Number(number));\n const color = options[rule];\n return colorize(number.toString(), color);\n};\n\nexport const removeColor = (text: string) =>\n // biome-ignore lint/suspicious/noControlCharactersInRegex: we need to remove the color codes\n text.replace(/\\x1b\\[[0-9;]*m/g, '');\n\nconst getLength = (length: number | number[] | string | string[]): number => {\n let value: number = 0;\n if (typeof length === 'number') {\n value = length;\n }\n if (typeof length === 'string') {\n value = length.length;\n }\n if (\n Array.isArray(length) &&\n length.every((locale) => typeof locale === 'string')\n ) {\n value = Math.max(...length.map((str) => str.length));\n }\n if (\n Array.isArray(length) &&\n length.every((locale) => typeof locale === 'number')\n ) {\n value = Math.max(...length);\n }\n return Math.max(value, 0);\n};\n\nconst defaultColonOptions = {\n colSize: 0,\n minSize: 0,\n maxSize: Infinity,\n pad: 'right',\n padChar: '0',\n};\n\n/**\n * Create a string of spaces of a given length.\n *\n * @param colSize - The length of the string to create.\n * @returns A string of spaces.\n */\nexport const colon = (\n text: string | string[],\n options?: {\n colSize?: number | number[] | string | string[];\n minSize?: number;\n maxSize?: number;\n pad?: 'left' | 'right';\n padChar?: string;\n }\n): string =>\n [text]\n .flat()\n .map((text) => {\n const { colSize, minSize, maxSize, pad } = {\n ...defaultColonOptions,\n ...(options ?? {}),\n };\n\n const length = getLength(colSize);\n const spacesLength = Math.max(\n minSize!,\n Math.min(maxSize!, length - removeColor(text).length)\n );\n\n if (pad === 'left') {\n return `${' '.repeat(spacesLength)}${text}`;\n }\n\n return `${text}${' '.repeat(spacesLength)}`;\n })\n .join('');\n\nexport const x = colorize('✗', RED);\nexport const v = colorize('✓', GREEN);\nexport const clock = colorize('⏲', BLUE);\n"],"mappings":";;;AAmBA,IAAI;AAEJ,MAAa,aAAa,WAA+B;AACvD,gBAAe;;AAGjB,MAAa,aAAa,iBAA8C;AACtE,KAAI,OAAO,iBAAiB,YAC1B,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IAAI,OAAO,aAAa;EACzC,CACD,KAAK,GAAG;AAEb,MAAa,IAAI,SAAS,KAAK,IAAI;AACnC,MAAa,IAAI,SAAS,KAAK,MAAM;AACrC,MAAa,QAAQ,SAAS,KAAK,KAAK"}
package/dist/esm/node.mjs CHANGED
@@ -1,7 +1,8 @@
1
+ import { getImportMap, getImportMapContent, getImportMapScript } from "./utils/importMap.mjs";
1
2
  import { buildBrowserConfiguration, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, extractBrowserConfiguration } from "./configFile/buildBrowserConfiguration.mjs";
2
3
  import { aiSchema, buildSchema, compilerSchema, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, storageAttributesSchema, storageSchema, systemSchema } from "./configFile/configurationSchema.mjs";
3
4
  import { buildConfigurationFields } from "./configFile/buildConfigurationFields.mjs";
4
5
  import { configurationFilesCandidates, searchConfigurationFile } from "./configFile/searchConfigurationFile.mjs";
5
6
  import { getConfiguration, getConfigurationAndFilePath } from "./configFile/getConfiguration.mjs";
6
7
 
7
- export { aiSchema, buildBrowserConfiguration, buildConfigurationFields, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, buildSchema, compilerSchema, configurationFilesCandidates, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, extractBrowserConfiguration, getConfiguration, getConfigurationAndFilePath, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, searchConfigurationFile, storageAttributesSchema, storageSchema, systemSchema };
8
+ export { aiSchema, buildBrowserConfiguration, buildConfigurationFields, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, buildSchema, compilerSchema, configurationFilesCandidates, contentSchema, cookiesAttributesSchema, dictionarySchema, editorSchema, extractBrowserConfiguration, getConfiguration, getConfigurationAndFilePath, getImportMap, getImportMapContent, getImportMapScript, internationalizationSchema, intlayerConfigSchema, logSchema, rewriteObjectSchema, rewriteRuleSchema, rewriteRulesSchema, routingSchema, searchConfigurationFile, storageAttributesSchema, storageSchema, systemSchema };
@@ -3,7 +3,7 @@ import { basename, dirname, join } from "node:path";
3
3
  import { mkdir, readFile, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
4
4
  import { deserialize, serialize } from "node:v8";
5
5
  import { gunzipSync, gzipSync } from "node:zlib";
6
- import packageJson from "@intlayer/types/package.json" with { type: "json" };
6
+ import configPackageJson from "@intlayer/types/package.json" with { type: "json" };
7
7
 
8
8
  //#region src/utils/cacheDisk.ts
9
9
  const DEFAULTS = { compress: true };
@@ -60,7 +60,7 @@ const cacheDisk = (intlayerConfig, keys, options) => {
60
60
  const maybeObj = deserialized;
61
61
  if (!!maybeObj && typeof maybeObj === "object" && typeof maybeObj.version === "string" && typeof maybeObj.timestamp === "number" && Object.hasOwn(maybeObj, "data")) {
62
62
  const entry = maybeObj;
63
- if (entry.version !== packageJson.version) {
63
+ if (entry.version !== configPackageJson.version) {
64
64
  try {
65
65
  await unlink(filePath);
66
66
  } catch {}
@@ -96,7 +96,7 @@ const cacheDisk = (intlayerConfig, keys, options) => {
96
96
  try {
97
97
  await ensureDir(dirname(filePath));
98
98
  const envelope = {
99
- version: packageJson.version,
99
+ version: configPackageJson.version,
100
100
  timestamp: Date.now(),
101
101
  data: value
102
102
  };
@@ -151,7 +151,7 @@ const cacheDisk = (intlayerConfig, keys, options) => {
151
151
  const maybeObj = deserialize(flag === 1 ? gunzipSync(raw) : raw);
152
152
  if (!!maybeObj && typeof maybeObj === "object" && typeof maybeObj.version === "string" && typeof maybeObj.timestamp === "number" && Object.hasOwn(maybeObj, "data")) {
153
153
  const entry = maybeObj;
154
- if (entry.version !== packageJson.version) return false;
154
+ if (entry.version !== configPackageJson.version) return false;
155
155
  if (typeof maxTimeMs === "number" && maxTimeMs > 0) {
156
156
  if (Date.now() - entry.timestamp > maxTimeMs) return false;
157
157
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cacheDisk.mjs","names":["configPackageJson"],"sources":["../../../src/utils/cacheDisk.ts"],"sourcesContent":["import {\n mkdir,\n readFile,\n rename,\n rm,\n stat,\n unlink,\n writeFile,\n} from 'node:fs/promises';\nimport { basename, dirname, join } from 'node:path';\nimport { deserialize, serialize } from 'node:v8';\nimport { gunzipSync, gzipSync } from 'node:zlib';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport configPackageJson from '@intlayer/types/package.json' with {\n type: 'json',\n};\nimport { type CacheKey, clearAllCache, computeKeyId } from './cacheMemory';\n\n/** ------------------------- Persistence layer ------------------------- **/\n\n/** Cache envelope structure stored on disk */\ntype CacheEnvelope = {\n /** Version of the config package (for cache invalidation) */\n version: string;\n /** Timestamp when the cache entry was created (in milliseconds) */\n timestamp: number;\n /** Data payload (the actual cached value) */\n data: unknown;\n};\n\ntype LocalCacheOptions = {\n /** Preferred new option name */\n persistent?: boolean;\n /** Time-to-live in ms; if expired, disk entry is ignored. */\n ttlMs?: number;\n /** Max age in ms based on stored creation timestamp; invalidates on exceed. */\n maxTimeMs?: number;\n /** Optional namespace to separate different logical caches. */\n namespace?: string;\n /** Gzip values on disk (on by default for blobs > 1KB). */\n compress?: boolean;\n};\n\nconst DEFAULTS: Required<Pick<LocalCacheOptions, 'compress'>> = {\n compress: true,\n};\n\nconst ensureDir = async (dir: string) => {\n await mkdir(dir, { recursive: true });\n};\n\nconst atomicWriteFile = async (\n file: string,\n data: Buffer,\n tempDir?: string\n) => {\n if (tempDir) {\n try {\n await ensureDir(tempDir);\n } catch {}\n }\n\n const tempFileName = `${basename(file)}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n const tmp = tempDir\n ? join(tempDir, tempFileName)\n : `${file}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n try {\n await writeFile(tmp, data);\n await rename(tmp, file);\n } catch (error) {\n try {\n await rm(tmp, { force: true });\n } catch {\n // Ignore\n }\n throw error;\n }\n};\n\nconst shouldUseCompression = (buf: Buffer, force?: boolean) =>\n force === true || (force !== false && buf.byteLength > 1024);\n\n/** Derive on-disk path from config dir + namespace + key id. */\nconst cachePath = (cacheDir: string, id: string, ns?: string) =>\n join(cacheDir, ns ? join(ns, id) : id);\n\n/** ------------------------- Local cache facade ------------------------- **/\n\nconst cacheMap = new Map<string, any>();\n\n/** Clears the in-memory portion of the disk cache without touching disk files. */\nexport const clearDiskCacheMemory = (): void => {\n cacheMap.clear();\n};\n\nexport const cacheDisk = (\n intlayerConfig: IntlayerConfig,\n keys: CacheKey[],\n options?: LocalCacheOptions\n) => {\n const { cacheDir, tempDir } = intlayerConfig.system;\n const buildCacheEnabled = intlayerConfig.build.cache ?? true;\n const persistent =\n options?.persistent === true ||\n (typeof options?.persistent === 'undefined' && buildCacheEnabled);\n\n const { compress, ttlMs, maxTimeMs, namespace } = {\n ...DEFAULTS,\n ...options,\n };\n\n // single stable id for this key tuple (works for both memory & disk)\n const id = computeKeyId(keys);\n const filePath = cachePath(cacheDir, id, namespace);\n\n const readFromDisk = async (): Promise<unknown | undefined> => {\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n\n if (!statValue) return undefined;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return undefined;\n }\n let raw = await readFile(filePath);\n // header: 1 byte flag (0x00 raw, 0x01 gzip)\n const flag = raw[0];\n\n raw = raw.subarray(1);\n\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n let value: unknown;\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof (maybeObj as any).version === 'string' &&\n typeof (maybeObj as any).timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n\n if (entry.version !== configPackageJson.version) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n\n value = entry.data;\n } else {\n // Backward compatibility: old entries had raw serialized value.\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n value = deserialized;\n }\n\n // hydrate memory cache as well\n cacheMap.set(id, value);\n return value;\n } catch {\n return undefined;\n }\n };\n\n const writeToDisk = async (value: unknown) => {\n try {\n await ensureDir(dirname(filePath));\n const envelope: CacheEnvelope = {\n version: configPackageJson.version,\n timestamp: Date.now(),\n data: value,\n };\n const payload = Buffer.from(serialize(envelope));\n\n const gz = shouldUseCompression(payload, compress)\n ? gzipSync(payload)\n : payload;\n\n // prepend a 1-byte header indicating compression\n const buf = Buffer.concat([\n Buffer.from([gz === payload ? 0x00 : 0x01]),\n gz,\n ]);\n\n await atomicWriteFile(filePath, buf, tempDir);\n } catch {\n // swallow disk errors for cache writes\n }\n };\n\n return {\n /** In-memory first, then disk (if enabled), otherwise undefined. */\n get: async <T>(): Promise<T | undefined> => {\n const mem = cacheMap.get(id);\n\n if (mem !== undefined) return mem as T;\n\n if (persistent && buildCacheEnabled) {\n return (await readFromDisk()) as T | undefined;\n }\n return undefined;\n },\n /** Sets in-memory (always) and persists to disk if enabled. */\n set: async (value: unknown): Promise<void> => {\n cacheMap.set(id, value);\n\n if (persistent && buildCacheEnabled) {\n await writeToDisk(value);\n }\n },\n /** Clears only this entry from memory and disk. */\n clear: async (): Promise<void> => {\n cacheMap.delete(id);\n\n try {\n await unlink(filePath);\n } catch {}\n },\n /** Clears ALL cached entries (memory Map and entire cacheDir namespace if persistent). */\n clearAll: async (): Promise<void> => {\n clearAllCache();\n if (persistent && buildCacheEnabled) {\n // remove only the current namespace (if provided), else the root dir\n const base = namespace ? join(cacheDir, namespace) : cacheDir;\n\n try {\n await rm(base, { recursive: true, force: true });\n } catch {}\n\n try {\n await mkdir(base, { recursive: true });\n } catch {}\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n isValid: async (): Promise<boolean> => {\n const cachedValue = cacheMap.get(id);\n if (cachedValue !== undefined) return true;\n\n // If persistence is disabled or build cache disabled, only memory can be valid\n if (!persistent || !buildCacheEnabled) return false;\n\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n if (!statValue) return false;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return false;\n }\n\n let raw = await readFile(filePath);\n const flag = raw[0];\n raw = raw.subarray(1);\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof maybeObj.version === 'string' &&\n typeof maybeObj.timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n if (entry.version !== configPackageJson.version) return false;\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) return false;\n }\n return true;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) return false;\n }\n return true;\n } catch {\n return false;\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n id,\n /** Expose the absolute file path for debugging. */\n filePath,\n };\n};\n"],"mappings":";;;;;;;;AA2CA,MAAM,WAA0D,EAC9D,UAAU,MACX;AAED,MAAM,YAAY,OAAO,QAAgB;AACvC,OAAM,MAAM,KAAK,EAAE,WAAW,MAAM,CAAC;;AAGvC,MAAM,kBAAkB,OACtB,MACA,MACA,YACG;AACH,KAA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,KAAK,KAAK,GAAG,MAAM,YACrB,UAAW,QAAO;;AAE9B,YAAO;;AAGT,QAAI,OAAO,cAAc,YAAY,YAAY,GAE/C;SADY,KAAK,KAAK,GAAG,UAAU,UACzB,UAAW,QAAO;;AAE9B,WAAO;WACD;AACN,WAAO;;;EAIX;EAEA;EACD"}
1
+ {"version":3,"file":"cacheDisk.mjs","names":[],"sources":["../../../src/utils/cacheDisk.ts"],"sourcesContent":["import {\n mkdir,\n readFile,\n rename,\n rm,\n stat,\n unlink,\n writeFile,\n} from 'node:fs/promises';\nimport { basename, dirname, join } from 'node:path';\nimport { deserialize, serialize } from 'node:v8';\nimport { gunzipSync, gzipSync } from 'node:zlib';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport configPackageJson from '@intlayer/types/package.json' with {\n type: 'json',\n};\nimport { type CacheKey, clearAllCache, computeKeyId } from './cacheMemory';\n\n/** ------------------------- Persistence layer ------------------------- **/\n\n/** Cache envelope structure stored on disk */\ntype CacheEnvelope = {\n /** Version of the config package (for cache invalidation) */\n version: string;\n /** Timestamp when the cache entry was created (in milliseconds) */\n timestamp: number;\n /** Data payload (the actual cached value) */\n data: unknown;\n};\n\ntype LocalCacheOptions = {\n /** Preferred new option name */\n persistent?: boolean;\n /** Time-to-live in ms; if expired, disk entry is ignored. */\n ttlMs?: number;\n /** Max age in ms based on stored creation timestamp; invalidates on exceed. */\n maxTimeMs?: number;\n /** Optional namespace to separate different logical caches. */\n namespace?: string;\n /** Gzip values on disk (on by default for blobs > 1KB). */\n compress?: boolean;\n};\n\nconst DEFAULTS: Required<Pick<LocalCacheOptions, 'compress'>> = {\n compress: true,\n};\n\nconst ensureDir = async (dir: string) => {\n await mkdir(dir, { recursive: true });\n};\n\nconst atomicWriteFile = async (\n file: string,\n data: Buffer,\n tempDir?: string\n) => {\n if (tempDir) {\n try {\n await ensureDir(tempDir);\n } catch {}\n }\n\n const tempFileName = `${basename(file)}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n const tmp = tempDir\n ? join(tempDir, tempFileName)\n : `${file}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;\n try {\n await writeFile(tmp, data);\n await rename(tmp, file);\n } catch (error) {\n try {\n await rm(tmp, { force: true });\n } catch {\n // Ignore\n }\n throw error;\n }\n};\n\nconst shouldUseCompression = (buf: Buffer, force?: boolean) =>\n force === true || (force !== false && buf.byteLength > 1024);\n\n/** Derive on-disk path from config dir + namespace + key id. */\nconst cachePath = (cacheDir: string, id: string, ns?: string) =>\n join(cacheDir, ns ? join(ns, id) : id);\n\n/** ------------------------- Local cache facade ------------------------- **/\n\nconst cacheMap = new Map<string, any>();\n\n/** Clears the in-memory portion of the disk cache without touching disk files. */\nexport const clearDiskCacheMemory = (): void => {\n cacheMap.clear();\n};\n\nexport const cacheDisk = (\n intlayerConfig: IntlayerConfig,\n keys: CacheKey[],\n options?: LocalCacheOptions\n) => {\n const { cacheDir, tempDir } = intlayerConfig.system;\n const buildCacheEnabled = intlayerConfig.build.cache ?? true;\n const persistent =\n options?.persistent === true ||\n (typeof options?.persistent === 'undefined' && buildCacheEnabled);\n\n const { compress, ttlMs, maxTimeMs, namespace } = {\n ...DEFAULTS,\n ...options,\n };\n\n // single stable id for this key tuple (works for both memory & disk)\n const id = computeKeyId(keys);\n const filePath = cachePath(cacheDir, id, namespace);\n\n const readFromDisk = async (): Promise<unknown | undefined> => {\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n\n if (!statValue) return undefined;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return undefined;\n }\n let raw = await readFile(filePath);\n // header: 1 byte flag (0x00 raw, 0x01 gzip)\n const flag = raw[0];\n\n raw = raw.subarray(1);\n\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n let value: unknown;\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof (maybeObj as any).version === 'string' &&\n typeof (maybeObj as any).timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n\n if (entry.version !== configPackageJson.version) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n\n value = entry.data;\n } else {\n // Backward compatibility: old entries had raw serialized value.\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) {\n try {\n await unlink(filePath);\n } catch {}\n return undefined;\n }\n }\n value = deserialized;\n }\n\n // hydrate memory cache as well\n cacheMap.set(id, value);\n return value;\n } catch {\n return undefined;\n }\n };\n\n const writeToDisk = async (value: unknown) => {\n try {\n await ensureDir(dirname(filePath));\n const envelope: CacheEnvelope = {\n version: configPackageJson.version,\n timestamp: Date.now(),\n data: value,\n };\n const payload = Buffer.from(serialize(envelope));\n\n const gz = shouldUseCompression(payload, compress)\n ? gzipSync(payload)\n : payload;\n\n // prepend a 1-byte header indicating compression\n const buf = Buffer.concat([\n Buffer.from([gz === payload ? 0x00 : 0x01]),\n gz,\n ]);\n\n await atomicWriteFile(filePath, buf, tempDir);\n } catch {\n // swallow disk errors for cache writes\n }\n };\n\n return {\n /** In-memory first, then disk (if enabled), otherwise undefined. */\n get: async <T>(): Promise<T | undefined> => {\n const mem = cacheMap.get(id);\n\n if (mem !== undefined) return mem as T;\n\n if (persistent && buildCacheEnabled) {\n return (await readFromDisk()) as T | undefined;\n }\n return undefined;\n },\n /** Sets in-memory (always) and persists to disk if enabled. */\n set: async (value: unknown): Promise<void> => {\n cacheMap.set(id, value);\n\n if (persistent && buildCacheEnabled) {\n await writeToDisk(value);\n }\n },\n /** Clears only this entry from memory and disk. */\n clear: async (): Promise<void> => {\n cacheMap.delete(id);\n\n try {\n await unlink(filePath);\n } catch {}\n },\n /** Clears ALL cached entries (memory Map and entire cacheDir namespace if persistent). */\n clearAll: async (): Promise<void> => {\n clearAllCache();\n if (persistent && buildCacheEnabled) {\n // remove only the current namespace (if provided), else the root dir\n const base = namespace ? join(cacheDir, namespace) : cacheDir;\n\n try {\n await rm(base, { recursive: true, force: true });\n } catch {}\n\n try {\n await mkdir(base, { recursive: true });\n } catch {}\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n isValid: async (): Promise<boolean> => {\n const cachedValue = cacheMap.get(id);\n if (cachedValue !== undefined) return true;\n\n // If persistence is disabled or build cache disabled, only memory can be valid\n if (!persistent || !buildCacheEnabled) return false;\n\n try {\n const statValue = await stat(filePath).catch(() => undefined);\n if (!statValue) return false;\n\n if (typeof ttlMs === 'number' && ttlMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > ttlMs) return false;\n }\n\n let raw = await readFile(filePath);\n const flag = raw[0];\n raw = raw.subarray(1);\n const payload = flag === 0x01 ? gunzipSync(raw) : raw;\n const deserialized = deserialize(payload) as unknown;\n\n const maybeObj = deserialized as Record<string, unknown> | null;\n const isEnvelope =\n !!maybeObj &&\n typeof maybeObj === 'object' &&\n typeof maybeObj.version === 'string' &&\n typeof maybeObj.timestamp === 'number' &&\n Object.hasOwn(maybeObj, 'data');\n\n if (isEnvelope) {\n const entry = maybeObj as CacheEnvelope;\n if (entry.version !== configPackageJson.version) return false;\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - entry.timestamp;\n if (age > maxTimeMs) return false;\n }\n return true;\n }\n\n if (typeof maxTimeMs === 'number' && maxTimeMs > 0) {\n const age = Date.now() - statValue.mtimeMs;\n if (age > maxTimeMs) return false;\n }\n return true;\n } catch {\n return false;\n }\n },\n /** Expose the computed id (useful if you want to key other structures). */\n id,\n /** Expose the absolute file path for debugging. */\n filePath,\n };\n};\n"],"mappings":";;;;;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,YAC5B,OAAO,SAAS,cAAc,YAC9B,OAAO,OAAO,UAAU,OAAO,EAEjB;KACd,MAAM,QAAQ;AACd,SAAI,MAAM,YAAY,kBAAkB,QAAS,QAAO;AAExD,SAAI,OAAO,cAAc,YAAY,YAAY,GAE/C;UADY,KAAK,KAAK,GAAG,MAAM,YACrB,UAAW,QAAO;;AAE9B,YAAO;;AAGT,QAAI,OAAO,cAAc,YAAY,YAAY,GAE/C;SADY,KAAK,KAAK,GAAG,UAAU,UACzB,UAAW,QAAO;;AAE9B,WAAO;WACD;AACN,WAAO;;;EAIX;EAEA;EACD"}
@@ -52,10 +52,10 @@ const processStorageEntry = (entry) => {
52
52
  };
53
53
  };
54
54
  const mergeStorageAttributes = (accumulated, partial) => ({
55
- cookies: [...accumulated.cookies, ...partial.cookies ?? []],
56
- localStorage: [...accumulated.localStorage, ...partial.localStorage ?? []],
57
- sessionStorage: [...accumulated.sessionStorage, ...partial.sessionStorage ?? []],
58
- headers: [...accumulated.headers, ...partial.headers ?? []]
55
+ cookies: [...accumulated.cookies ?? [], ...partial.cookies ?? []],
56
+ localStorage: [...accumulated.localStorage ?? [], ...partial.localStorage ?? []],
57
+ sessionStorage: [...accumulated.sessionStorage ?? [], ...partial.sessionStorage ?? []],
58
+ headers: [...accumulated.headers ?? [], ...partial.headers ?? []]
59
59
  });
60
60
  /**
61
61
  * Extracts and normalizes storage configuration into separate arrays for each storage type.
@@ -71,11 +71,16 @@ const getStorageAttributes = (options) => {
71
71
  sessionStorage: [],
72
72
  headers: []
73
73
  };
74
- if (options === false || options === void 0) return emptyResult;
75
- if (Array.isArray(options)) return options.reduce((acc, entry) => {
74
+ if (options === false || options === void 0) return {};
75
+ const result = Array.isArray(options) ? options.reduce((acc, entry) => {
76
76
  return mergeStorageAttributes(acc, processStorageEntry(entry));
77
- }, emptyResult);
78
- return mergeStorageAttributes(emptyResult, processStorageEntry(options));
77
+ }, emptyResult) : mergeStorageAttributes(emptyResult, processStorageEntry(options));
78
+ const cleanedResult = {};
79
+ if (result.cookies && result.cookies.length > 0) cleanedResult.cookies = result.cookies;
80
+ if (result.localStorage && result.localStorage.length > 0) cleanedResult.localStorage = result.localStorage;
81
+ if (result.sessionStorage && result.sessionStorage.length > 0) cleanedResult.sessionStorage = result.sessionStorage;
82
+ if (result.headers && result.headers.length > 0) cleanedResult.headers = result.headers;
83
+ return cleanedResult;
79
84
  };
80
85
 
81
86
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"getStorageAttributes.mjs","names":[],"sources":["../../../src/utils/getStorageAttributes.ts"],"sourcesContent":["import type {\n CookiesAttributes,\n ProcessedStorageAttributes,\n RoutingStorageInput,\n StorageAttributes,\n} from '@intlayer/types/config';\nimport {\n COOKIE_NAME,\n HEADER_NAME,\n LOCALE_STORAGE_NAME,\n} from '../defaultValues/routing';\n\n// ============================================================================\n// Types\n// ============================================================================\n\ntype CookieEntry = {\n name: string;\n attributes: Omit<CookiesAttributes, 'type' | 'name'>;\n};\n\ntype WebStorageEntry = {\n name: string;\n};\n\ntype HeaderEntry = {\n name: string;\n};\n\ntype StorageEntry =\n | 'cookie'\n | 'localStorage'\n | 'sessionStorage'\n | 'header'\n | CookiesAttributes\n | StorageAttributes;\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\nconst createCookieEntry = (\n options?: Partial<CookiesAttributes>\n): CookieEntry => {\n const { name, path, expires, domain, secure, sameSite, httpOnly } =\n options ?? {};\n return {\n name: name ?? COOKIE_NAME,\n attributes: { path, expires, domain, secure, sameSite, httpOnly },\n };\n};\n\nconst createWebStorageEntry = (\n options?: Partial<StorageAttributes>\n): WebStorageEntry => ({\n name: options?.name ?? LOCALE_STORAGE_NAME,\n});\n\nconst createHeaderEntry = (\n options?: Partial<StorageAttributes>\n): HeaderEntry => ({\n name: options?.name ?? HEADER_NAME,\n});\n\nconst isCookieEntry = (entry: unknown): boolean => {\n if (typeof entry !== 'object' || entry === null) return false;\n const e = entry as Record<string, unknown>;\n return (\n e['type'] === 'cookie' ||\n 'sameSite' in e ||\n 'httpOnly' in e ||\n 'secure' in e\n );\n};\n\nconst isStorageType = (\n value: string\n): value is 'cookie' | 'localStorage' | 'sessionStorage' | 'header' =>\n value === 'cookie' ||\n value === 'localStorage' ||\n value === 'sessionStorage' ||\n value === 'header';\n\n// ============================================================================\n// Main Function\n// ============================================================================\n\nconst processStorageEntry = (\n entry: StorageEntry\n): Partial<ProcessedStorageAttributes> => {\n if (typeof entry === 'string') {\n if (!isStorageType(entry)) {\n return { cookies: [], localStorage: [], sessionStorage: [], headers: [] };\n }\n if (entry === 'cookie') return { cookies: [createCookieEntry()] };\n if (entry === 'localStorage')\n return { localStorage: [createWebStorageEntry()] };\n if (entry === 'sessionStorage')\n return { sessionStorage: [createWebStorageEntry()] };\n if (entry === 'header') return { headers: [createHeaderEntry()] };\n }\n\n if (typeof entry === 'object' && entry !== null) {\n const typedEntry = entry as CookiesAttributes | StorageAttributes;\n\n if (isCookieEntry(typedEntry)) {\n return { cookies: [createCookieEntry(typedEntry as CookiesAttributes)] };\n }\n if ('type' in typedEntry && typedEntry.type === 'localStorage') {\n return {\n localStorage: [createWebStorageEntry(typedEntry as StorageAttributes)],\n };\n }\n if ('type' in typedEntry && typedEntry.type === 'sessionStorage') {\n return {\n sessionStorage: [\n createWebStorageEntry(typedEntry as StorageAttributes),\n ],\n };\n }\n if ('type' in typedEntry && typedEntry.type === 'header') {\n return { headers: [createHeaderEntry(typedEntry as StorageAttributes)] };\n }\n // Default to localStorage for ambiguous objects\n return {\n localStorage: [\n createWebStorageEntry(typedEntry as Omit<StorageAttributes, 'type'>),\n ],\n };\n }\n\n return { cookies: [], localStorage: [], sessionStorage: [], headers: [] };\n};\n\nconst mergeStorageAttributes = (\n accumulated: ProcessedStorageAttributes,\n partial: Partial<ProcessedStorageAttributes>\n): ProcessedStorageAttributes => ({\n cookies: [...accumulated.cookies, ...(partial.cookies ?? [])],\n localStorage: [...accumulated.localStorage, ...(partial.localStorage ?? [])],\n sessionStorage: [\n ...accumulated.sessionStorage,\n ...(partial.sessionStorage ?? []),\n ],\n headers: [...accumulated.headers, ...(partial.headers ?? [])],\n});\n\n/**\n * Extracts and normalizes storage configuration into separate arrays for each storage type.\n * Called at config-build time so the result is pre-computed and stored in the config.\n *\n * @param options - The storage configuration from IntlayerConfig\n * @returns An object containing arrays for cookies, localStorage, sessionStorage and headers\n */\nexport const getStorageAttributes = (\n options: RoutingStorageInput\n): ProcessedStorageAttributes => {\n const emptyResult: ProcessedStorageAttributes = {\n cookies: [],\n localStorage: [],\n sessionStorage: [],\n headers: [],\n };\n\n if (options === false || options === undefined) return emptyResult;\n\n if (Array.isArray(options)) {\n return options.reduce<ProcessedStorageAttributes>((acc, entry) => {\n const partial = processStorageEntry(entry);\n return mergeStorageAttributes(acc, partial);\n }, emptyResult);\n }\n\n return mergeStorageAttributes(emptyResult, processStorageEntry(options));\n};\n"],"mappings":";;;AAyCA,MAAM,qBACJ,YACgB;CAChB,MAAM,EAAE,MAAM,MAAM,SAAS,QAAQ,QAAQ,UAAU,aACrD,WAAW,EAAE;AACf,QAAO;EACL,MAAM;EACN,YAAY;GAAE;GAAM;GAAS;GAAQ;GAAQ;GAAU;GAAU;EAClE;;AAGH,MAAM,yBACJ,aACqB,EACrB,MAAM,SAAS,2BAChB;AAED,MAAM,qBACJ,aACiB,EACjB,MAAM,SAAS,6BAChB;AAED,MAAM,iBAAiB,UAA4B;AACjD,KAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;CACxD,MAAM,IAAI;AACV,QACE,EAAE,YAAY,YACd,cAAc,KACd,cAAc,KACd,YAAY;;AAIhB,MAAM,iBACJ,UAEA,UAAU,YACV,UAAU,kBACV,UAAU,oBACV,UAAU;AAMZ,MAAM,uBACJ,UACwC;AACxC,KAAI,OAAO,UAAU,UAAU;AAC7B,MAAI,CAAC,cAAc,MAAM,CACvB,QAAO;GAAE,SAAS,EAAE;GAAE,cAAc,EAAE;GAAE,gBAAgB,EAAE;GAAE,SAAS,EA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M,cAA0C;EAC9C,SAAS,EAAE;EACX,cAAc,EAAE;EAChB,gBAAgB,EAAE;EAClB,SAAS,EAAE;EACZ;AAED,KAAI,YAAY,SAAS,YAAY,OAAW,QAAO;AAEvD,KAAI,MAAM,QAAQ,QAAQ,CACxB,QAAO,QAAQ,QAAoC,KAAK,UAAU;AAEhE,SAAO,uBAAuB,KADd,oBAAoB,MAAM,CACC;IAC1C,YAAY;AAGjB,QAAO,uBAAuB,aAAa,oBAAoB,QAAQ,CAAC"}
1
+ {"version":3,"file":"getStorageAttributes.mjs","names":[],"sources":["../../../src/utils/getStorageAttributes.ts"],"sourcesContent":["import type {\n CookiesAttributes,\n ProcessedStorageAttributes,\n RoutingStorageInput,\n StorageAttributes,\n} from '@intlayer/types/config';\nimport {\n COOKIE_NAME,\n HEADER_NAME,\n LOCALE_STORAGE_NAME,\n} from '../defaultValues/routing';\n\n// ============================================================================\n// Types\n// ============================================================================\n\ntype CookieEntry = {\n name: string;\n attributes: Omit<CookiesAttributes, 'type' | 'name'>;\n};\n\ntype WebStorageEntry = {\n name: string;\n};\n\ntype HeaderEntry = {\n name: string;\n};\n\ntype StorageEntry =\n | 'cookie'\n | 'localStorage'\n | 'sessionStorage'\n | 'header'\n | CookiesAttributes\n | StorageAttributes;\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\nconst createCookieEntry = (\n options?: Partial<CookiesAttributes>\n): CookieEntry => {\n const { name, path, expires, domain, secure, sameSite, httpOnly } =\n options ?? {};\n return {\n name: name ?? COOKIE_NAME,\n attributes: { path, expires, domain, secure, sameSite, httpOnly },\n };\n};\n\nconst createWebStorageEntry = (\n options?: Partial<StorageAttributes>\n): WebStorageEntry => ({\n name: options?.name ?? LOCALE_STORAGE_NAME,\n});\n\nconst createHeaderEntry = (\n options?: Partial<StorageAttributes>\n): HeaderEntry => ({\n name: options?.name ?? HEADER_NAME,\n});\n\nconst isCookieEntry = (entry: unknown): boolean => {\n if (typeof entry !== 'object' || entry === null) return false;\n const e = entry as Record<string, unknown>;\n return (\n e['type'] === 'cookie' ||\n 'sameSite' in e ||\n 'httpOnly' in e ||\n 'secure' in e\n );\n};\n\nconst isStorageType = (\n value: string\n): value is 'cookie' | 'localStorage' | 'sessionStorage' | 'header' =>\n value === 'cookie' ||\n value === 'localStorage' ||\n value === 'sessionStorage' ||\n value === 'header';\n\n// ============================================================================\n// Main Function\n// ============================================================================\n\nconst processStorageEntry = (\n entry: StorageEntry\n): Partial<ProcessedStorageAttributes> => {\n if (typeof entry === 'string') {\n if (!isStorageType(entry)) {\n return { cookies: [], localStorage: [], sessionStorage: [], headers: [] };\n }\n if (entry === 'cookie') return { cookies: [createCookieEntry()] };\n if (entry === 'localStorage')\n return { localStorage: [createWebStorageEntry()] };\n if (entry === 'sessionStorage')\n return { sessionStorage: [createWebStorageEntry()] };\n if (entry === 'header') return { headers: [createHeaderEntry()] };\n }\n\n if (typeof entry === 'object' && entry !== null) {\n const typedEntry = entry as CookiesAttributes | StorageAttributes;\n\n if (isCookieEntry(typedEntry)) {\n return { cookies: [createCookieEntry(typedEntry as CookiesAttributes)] };\n }\n if ('type' in typedEntry && typedEntry.type === 'localStorage') {\n return {\n localStorage: [createWebStorageEntry(typedEntry as StorageAttributes)],\n };\n }\n if ('type' in typedEntry && typedEntry.type === 'sessionStorage') {\n return {\n sessionStorage: [\n createWebStorageEntry(typedEntry as StorageAttributes),\n ],\n };\n }\n if ('type' in typedEntry && typedEntry.type === 'header') {\n return { headers: [createHeaderEntry(typedEntry as StorageAttributes)] };\n }\n // Default to localStorage for ambiguous objects\n return {\n localStorage: [\n createWebStorageEntry(typedEntry as Omit<StorageAttributes, 'type'>),\n ],\n };\n }\n\n return { cookies: [], localStorage: [], sessionStorage: [], headers: [] };\n};\n\nconst mergeStorageAttributes = (\n accumulated: ProcessedStorageAttributes,\n partial: Partial<ProcessedStorageAttributes>\n): ProcessedStorageAttributes => ({\n cookies: [...(accumulated.cookies ?? []), ...(partial.cookies ?? [])],\n localStorage: [\n ...(accumulated.localStorage ?? []),\n ...(partial.localStorage ?? []),\n ],\n sessionStorage: [\n ...(accumulated.sessionStorage ?? []),\n ...(partial.sessionStorage ?? []),\n ],\n headers: [...(accumulated.headers ?? []), ...(partial.headers ?? [])],\n});\n\n/**\n * Extracts and normalizes storage configuration into separate arrays for each storage type.\n * Called at config-build time so the result is pre-computed and stored in the config.\n *\n * @param options - The storage configuration from IntlayerConfig\n * @returns An object containing arrays for cookies, localStorage, sessionStorage and headers\n */\nexport const getStorageAttributes = (\n options: RoutingStorageInput\n): ProcessedStorageAttributes => {\n const emptyResult: ProcessedStorageAttributes = {\n cookies: [],\n localStorage: [],\n sessionStorage: [],\n headers: [],\n };\n\n if (options === false || options === undefined) return {};\n\n const result = Array.isArray(options)\n ? options.reduce<ProcessedStorageAttributes>((acc, entry) => {\n const partial = processStorageEntry(entry);\n return mergeStorageAttributes(acc, partial);\n }, emptyResult)\n : mergeStorageAttributes(emptyResult, processStorageEntry(options));\n\n // Remove empty arrays\n const cleanedResult: ProcessedStorageAttributes = {};\n\n if (result.cookies && result.cookies.length > 0) {\n cleanedResult.cookies = result.cookies;\n }\n\n if (result.localStorage && result.localStorage.length > 0) {\n cleanedResult.localStorage = result.localStorage;\n }\n\n if (result.sessionStorage && result.sessionStorage.length > 0) {\n cleanedResult.sessionStorage = result.sessionStorage;\n }\n\n if (result.headers && result.headers.length > 0) {\n cleanedResult.headers = result.headers;\n }\n\n return cleanedResult;\n};\n"],"mappings":";;;AAyCA,MAAM,qBACJ,YACgB;CAChB,MAAM,EAAE,MAAM,MAAM,SAAS,QAAQ,QAAQ,UAAU,aACrD,WAAW,EAAE;AACf,QAAO;EACL,MAAM;EACN,YAAY;GAAE;GAAM;GAAS;GAAQ;GAAQ;GAAU;GAAU;EAClE;;AAGH,MAAM,yBACJ,aACqB,EACrB,MAAM,SAAS,2BAChB;AAED,MAAM,qBACJ,aACiB,EACjB,MAAM,SAAS,6BAChB;AAED,MAAM,iBAAiB,UAA4B;AACjD,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E,MAAM,0BACJ,aACA,aACgC;CAChC,SAAS,CAAC,GAAI,YAAY,WAAW,EAAE,EAAG,GAAI,QAAQ,WAAW,EAAE,CAAE;CACrE,cAAc,CACZ,GAAI,YAAY,gBAAgB,EAAE,EAClC,GAAI,QAAQ,gBAAgB,EAAE,CAC/B;CACD,gBAAgB,CACd,GAAI,YAAY,kBAAkB,EAAE,EACpC,GAAI,QAAQ,kBAAkB,EAAE,CACjC;CACD,SAAS,CAAC,GAAI,YAAY,WAAW,EAAE,EAAG,GAAI,QAAQ,WAAW,EAAE,CAAE;CACtE;;;;;;;;AASD,MAAa,wBACX,YAC+B;CAC/B,MAAM,cAA0C;EAC9C,SAAS,EAAE;EACX,cAAc,EAAE;EAChB,gBAAgB,EAAE;EAClB,SAAS,EAAE;EACZ;AAED,KAAI,YAAY,SAAS,YAAY,OAAW,QAAO,EAAE;CAEzD,MAAM,SAAS,MAAM,QAAQ,QAAQ,GACjC,QAAQ,QAAoC,KAAK,UAAU;AAEzD,SAAO,uBAAuB,KADd,oBAAoB,MAAM,CACC;IAC1C,YAAY,GACf,uBAAuB,aAAa,oBAAoB,QAAQ,CAAC;CAGrE,MAAM,gBAA4C,EAAE;AAEpD,KAAI,OAAO,WAAW,OAAO,QAAQ,SAAS,EAC5C,eAAc,UAAU,OAAO;AAGjC,KAAI,OAAO,gBAAgB,OAAO,aAAa,SAAS,EACtD,eAAc,eAAe,OAAO;AAGtC,KAAI,OAAO,kBAAkB,OAAO,eAAe,SAAS,EAC1D,eAAc,iBAAiB,OAAO;AAGxC,KAAI,OAAO,WAAW,OAAO,QAAQ,SAAS,EAC5C,eAAc,UAAU,OAAO;AAGjC,QAAO"}
@@ -0,0 +1,70 @@
1
+ import { getAlias } from "./alias.mjs";
2
+
3
+ //#region src/utils/importMap.ts
4
+ /**
5
+ * Generates a browser-native import map object from the Intlayer configuration.
6
+ *
7
+ * The import map resolves bare module specifiers (e.g. `@intlayer/dictionaries-entry`)
8
+ * to their physical `.mjs` file paths relative to the project root, replicating
9
+ * what a bundler's `alias` plugin would do.
10
+ *
11
+ * Paths are always forced to ESM (`.mjs`) and prefixed with `./` so they are
12
+ * valid relative URL references for the browser.
13
+ *
14
+ * @example
15
+ * ```json
16
+ * {
17
+ * "imports": {
18
+ * "@intlayer/dictionaries-entry": "./.intlayer/main/dictionaries.mjs",
19
+ * "@intlayer/unmerged-dictionaries-entry": "./.intlayer/main/unmerged_dictionaries.mjs",
20
+ * "@intlayer/remote-dictionaries-entry": "./.intlayer/main/remote_dictionaries.mjs",
21
+ * "@intlayer/dynamic-dictionaries-entry": "./.intlayer/main/dynamic_dictionaries.mjs",
22
+ * "@intlayer/fetch-dictionaries-entry": "./.intlayer/main/fetch_dictionaries.mjs",
23
+ * "@intlayer/config/built": "./.intlayer/config/configuration.mjs"
24
+ * }
25
+ * }
26
+ * ```
27
+ */
28
+ const getImportMap = ({ configuration, extraImports = {} }) => {
29
+ return { imports: {
30
+ ...getAlias({
31
+ configuration,
32
+ format: "esm",
33
+ formatter: (value) => `./${value}`
34
+ }),
35
+ ...extraImports
36
+ } };
37
+ };
38
+ /**
39
+ * Returns the JSON string representation of the import map.
40
+ *
41
+ * Can be embedded directly as the content of a `<script type="importmap">` tag,
42
+ * or written to a standalone `.importmap` file and referenced via
43
+ * `<script type="importmap" src="./importmap.json">`.
44
+ */
45
+ const getImportMapContent = (options) => JSON.stringify(getImportMap(options), null, 2);
46
+ /**
47
+ * Generates a complete `<script type="importmap">` HTML element string.
48
+ *
49
+ * Inject this into your HTML `<head>` **before** any `<script type="module">`
50
+ * tags to enable bare module specifier resolution without a bundler.
51
+ *
52
+ * Prerequisites:
53
+ * - Run `npx intlayer build` so the `.intlayer` folder is populated.
54
+ * - Your static server must serve the `.intlayer` directory.
55
+ *
56
+ * @example
57
+ * ```html
58
+ * <!DOCTYPE html>
59
+ * <html lang="en">
60
+ * <head>
61
+ * <!-- generated output goes here, before any module scripts -->
62
+ * <script type="module" src="./src/main.js"><\/script>
63
+ * </head>
64
+ * ```
65
+ */
66
+ const getImportMapScript = (options) => `<script type="importmap">\n${getImportMapContent(options)}\n<\/script>`;
67
+
68
+ //#endregion
69
+ export { getImportMap, getImportMapContent, getImportMapScript };
70
+ //# sourceMappingURL=importMap.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"importMap.mjs","names":[],"sources":["../../../src/utils/importMap.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\nimport { getAlias } from './alias';\n\nexport type GetImportMapOptions = {\n configuration: IntlayerConfig;\n /**\n * Extra module specifier → URL mappings to merge into the import map.\n * Use this to add paths for top-level packages (e.g. `intlayer`, `vanilla-intlayer`)\n * that are not generated by Intlayer's build step.\n *\n * @example\n * ```ts\n * {\n * extraImports: {\n * 'intlayer': './node_modules/intlayer/dist/index.mjs',\n * 'vanilla-intlayer': './node_modules/vanilla-intlayer/dist/index.mjs',\n * }\n * }\n * ```\n */\n extraImports?: Record<string, string>;\n};\n\nexport type ImportMap = {\n imports: Record<string, string>;\n};\n\n/**\n * Generates a browser-native import map object from the Intlayer configuration.\n *\n * The import map resolves bare module specifiers (e.g. `@intlayer/dictionaries-entry`)\n * to their physical `.mjs` file paths relative to the project root, replicating\n * what a bundler's `alias` plugin would do.\n *\n * Paths are always forced to ESM (`.mjs`) and prefixed with `./` so they are\n * valid relative URL references for the browser.\n *\n * @example\n * ```json\n * {\n * \"imports\": {\n * \"@intlayer/dictionaries-entry\": \"./.intlayer/main/dictionaries.mjs\",\n * \"@intlayer/unmerged-dictionaries-entry\": \"./.intlayer/main/unmerged_dictionaries.mjs\",\n * \"@intlayer/remote-dictionaries-entry\": \"./.intlayer/main/remote_dictionaries.mjs\",\n * \"@intlayer/dynamic-dictionaries-entry\": \"./.intlayer/main/dynamic_dictionaries.mjs\",\n * \"@intlayer/fetch-dictionaries-entry\": \"./.intlayer/main/fetch_dictionaries.mjs\",\n * \"@intlayer/config/built\": \"./.intlayer/config/configuration.mjs\"\n * }\n * }\n * ```\n */\nexport const getImportMap = ({\n configuration,\n extraImports = {},\n}: GetImportMapOptions): ImportMap => {\n const aliases = getAlias({\n configuration,\n format: 'esm',\n formatter: (value) => `./${value}`,\n });\n\n return {\n imports: {\n ...aliases,\n ...extraImports,\n },\n };\n};\n\n/**\n * Returns the JSON string representation of the import map.\n *\n * Can be embedded directly as the content of a `<script type=\"importmap\">` tag,\n * or written to a standalone `.importmap` file and referenced via\n * `<script type=\"importmap\" src=\"./importmap.json\">`.\n */\nexport const getImportMapContent = (options: GetImportMapOptions): string =>\n JSON.stringify(getImportMap(options), null, 2);\n\n/**\n * Generates a complete `<script type=\"importmap\">` HTML element string.\n *\n * Inject this into your HTML `<head>` **before** any `<script type=\"module\">`\n * tags to enable bare module specifier resolution without a bundler.\n *\n * Prerequisites:\n * - Run `npx intlayer build` so the `.intlayer` folder is populated.\n * - Your static server must serve the `.intlayer` directory.\n *\n * @example\n * ```html\n * <!DOCTYPE html>\n * <html lang=\"en\">\n * <head>\n * <!-- generated output goes here, before any module scripts -->\n * <script type=\"module\" src=\"./src/main.js\"></script>\n * </head>\n * ```\n */\nexport const getImportMapScript = (options: GetImportMapOptions): string =>\n `<script type=\"importmap\">\\n${getImportMapContent(options)}\\n</script>`;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAa,gBAAgB,EAC3B,eACA,eAAe,EAAE,OACmB;AAOpC,QAAO,EACL,SAAS;EACP,GARY,SAAS;GACvB;GACA,QAAQ;GACR,YAAY,UAAU,KAAK;GAC5B,CAAC;EAKE,GAAG;EACJ,EACF;;;;;;;;;AAUH,MAAa,uBAAuB,YAClC,KAAK,UAAU,aAAa,QAAQ,EAAE,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;AAsBhD,MAAa,sBAAsB,YACjC,8BAA8B,oBAAoB,QAAQ,CAAC"}
@@ -9,13 +9,15 @@ import { clearModuleCache } from "./clearModuleCache.mjs";
9
9
  import { compareVersions } from "./compareVersions.mjs";
10
10
  import { extractErrorMessage } from "./extractErrorMessage.mjs";
11
11
  import { getStorageAttributes } from "./getStorageAttributes.mjs";
12
+ import { getImportMap, getImportMapContent, getImportMapScript } from "./importMap.mjs";
12
13
  import { getUnusedNodeTypes, getUnusedNodeTypesAsync, getUsedNodeTypes, getUsedNodeTypesAsync } from "./getUsedNodeTypes.mjs";
13
14
  import { logStack } from "./logStack.mjs";
14
15
  import { parseFilePathPattern, parseStringPattern } from "./parseFilePathPattern.mjs";
15
16
  import { retryManager } from "./retryManager.mjs";
17
+ import { setIntlayerIdentifier } from "./setIntlayerIdentifier.mjs";
16
18
  import { camelCaseToKebabCase } from "./stringFormatter/camelCaseToKebabCase.mjs";
17
19
  import { camelCaseToSentence } from "./stringFormatter/camelCaseToSentence.mjs";
18
20
  import { kebabCaseToCamelCase } from "./stringFormatter/kebabCaseToCamelCase.mjs";
19
21
  import { toLowerCamelCase } from "./stringFormatter/toLowerCamelCase.mjs";
20
22
 
21
- export { cacheDisk, cacheMemory, camelCaseToKebabCase, camelCaseToSentence, clearAllCache, clearCache, clearDiskCacheMemory, clearModuleCache, compareVersions, computeKeyId, configESMxCJSRequire, extractErrorMessage, getAlias, getCache, getExtension, getPackageJsonPath, getProjectRequire, getStorageAttributes, getUnusedNodeTypes, getUnusedNodeTypesAsync, getUsedNodeTypes, getUsedNodeTypesAsync, isESModule, kebabCaseToCamelCase, logStack, normalizePath, parseFilePathPattern, parseStringPattern, retryManager, setCache, stableStringify, toLowerCamelCase };
23
+ export { cacheDisk, cacheMemory, camelCaseToKebabCase, camelCaseToSentence, clearAllCache, clearCache, clearDiskCacheMemory, clearModuleCache, compareVersions, computeKeyId, configESMxCJSRequire, extractErrorMessage, getAlias, getCache, getExtension, getImportMap, getImportMapContent, getImportMapScript, getPackageJsonPath, getProjectRequire, getStorageAttributes, getUnusedNodeTypes, getUnusedNodeTypesAsync, getUsedNodeTypes, getUsedNodeTypesAsync, isESModule, kebabCaseToCamelCase, logStack, normalizePath, parseFilePathPattern, parseStringPattern, retryManager, setCache, setIntlayerIdentifier, stableStringify, toLowerCamelCase };
@@ -0,0 +1,12 @@
1
+ //#region src/utils/setIntlayerIdentifier.ts
2
+ /**
3
+ * Sets the version of Intlayer in the window object.
4
+ * This is used for Intlayer detection in the browser.
5
+ */
6
+ const setIntlayerIdentifier = () => {
7
+ if (typeof window !== "undefined") window.intlayer = { enabled: true };
8
+ };
9
+
10
+ //#endregion
11
+ export { setIntlayerIdentifier };
12
+ //# sourceMappingURL=setIntlayerIdentifier.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setIntlayerIdentifier.mjs","names":[],"sources":["../../../src/utils/setIntlayerIdentifier.ts"],"sourcesContent":["type Meta = {\n enabled: true;\n};\n\nexport type WindowsWithIntlayer = typeof window & {\n intlayer?: Meta;\n};\n\n/**\n * Sets the version of Intlayer in the window object.\n * This is used for Intlayer detection in the browser.\n */\nexport const setIntlayerIdentifier = (): void => {\n if (typeof window !== 'undefined') {\n (window as WindowsWithIntlayer).intlayer = {\n enabled: true,\n };\n }\n};\n"],"mappings":";;;;;AAYA,MAAa,8BAAoC;AAC/C,KAAI,OAAO,WAAW,YACpB,CAAC,OAA+B,WAAW,EACzC,SAAS,MACV"}
@@ -1,4 +1,6 @@
1
+ import * as _$_intlayer_types_config0 from "@intlayer/types/config";
1
2
  import { IntlayerConfig } from "@intlayer/types/config";
3
+ import * as _$_intlayer_types_plugin0 from "@intlayer/types/plugin";
2
4
 
3
5
  //#region src/built.browser.d.ts
4
6
  /**
@@ -8,6 +10,18 @@ import { IntlayerConfig } from "@intlayer/types/config";
8
10
  * only read when a property is first accessed.
9
11
  */
10
12
  declare const configuration: IntlayerConfig;
13
+ declare const internationalization: _$_intlayer_types_config0.InternationalizationConfig;
14
+ declare const dictionary: Partial<_$_intlayer_types_config0.DictionaryConfig>;
15
+ declare const routing: _$_intlayer_types_config0.RoutingConfig;
16
+ declare const content: _$_intlayer_types_config0.ContentConfig;
17
+ declare const system: _$_intlayer_types_config0.SystemConfig;
18
+ declare const editor: _$_intlayer_types_config0.EditorConfig;
19
+ declare const log: _$_intlayer_types_config0.LogConfig;
20
+ declare const ai: Partial<_$_intlayer_types_config0.AiConfig>;
21
+ declare const build: _$_intlayer_types_config0.BuildConfig;
22
+ declare const compiler: _$_intlayer_types_config0.CompilerConfig;
23
+ declare const schemas: Record<string, _$_intlayer_types_config0.Schema>;
24
+ declare const plugins: _$_intlayer_types_plugin0.Plugin[];
11
25
  //#endregion
12
- export { configuration as default };
26
+ export { ai, build, compiler, content, configuration as default, dictionary, editor, internationalization, log, plugins, routing, schemas, system };
13
27
  //# sourceMappingURL=built.browser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"built.browser.d.ts","names":[],"sources":["../../src/built.browser.ts"],"mappings":";;;;;;;;;cAwBM,aAAA,EAAa,cAAA"}
1
+ {"version":3,"file":"built.browser.d.ts","names":[],"sources":["../../src/built.browser.ts"],"mappings":";;;;;AAsCA;;;;;AACA;AADA,cAdM,aAAA,EAAa,cAAA;AAAA,cAaN,oBAAA,EAAyD,yBAAA,CAArC,0BAAA;AAAA,cACpB,UAAA,EAAU,OAAA,CAA2B,yBAAA,CAA3B,gBAAA;AAAA,cACV,OAAA,EAA+B,yBAAA,CAAxB,aAAA;AAAA,cACP,OAAA,EAA+B,yBAAA,CAAxB,aAAA;AAAA,cACP,MAAA,EAA6B,yBAAA,CAAvB,YAAA;AAAA,cACN,MAAA,EAA6B,yBAAA,CAAvB,YAAA;AAAA,cACN,GAAA,EAAuB,yBAAA,CAApB,SAAA;AAAA,cACH,EAAA,EAAE,OAAA,CAAmB,yBAAA,CAAnB,QAAA;AAAA,cACF,KAAA,EAA2B,yBAAA,CAAtB,WAAA;AAAA,cACL,QAAA,EAAiC,yBAAA,CAAzB,cAAA;AAAA,cACR,OAAA,EAAO,MAAA,SAAwB,yBAAA,CAAxB,MAAA;AAAA,cACP,OAAA,EAA+B,yBAAA,CAAxB,MAAA"}
@@ -1,7 +1,21 @@
1
+ import * as _$_intlayer_types_config0 from "@intlayer/types/config";
1
2
  import { IntlayerConfig } from "@intlayer/types/config";
3
+ import * as _$_intlayer_types_plugin0 from "@intlayer/types/plugin";
2
4
 
3
5
  //#region src/built.d.ts
4
6
  declare const configuration: IntlayerConfig;
7
+ declare const internationalization: _$_intlayer_types_config0.InternationalizationConfig;
8
+ declare const dictionary: Partial<_$_intlayer_types_config0.DictionaryConfig>;
9
+ declare const routing: _$_intlayer_types_config0.RoutingConfig;
10
+ declare const content: _$_intlayer_types_config0.ContentConfig;
11
+ declare const system: _$_intlayer_types_config0.SystemConfig;
12
+ declare const editor: _$_intlayer_types_config0.EditorConfig;
13
+ declare const log: _$_intlayer_types_config0.LogConfig;
14
+ declare const ai: Partial<_$_intlayer_types_config0.AiConfig>;
15
+ declare const build: _$_intlayer_types_config0.BuildConfig;
16
+ declare const compiler: _$_intlayer_types_config0.CompilerConfig;
17
+ declare const schemas: Record<string, _$_intlayer_types_config0.Schema>;
18
+ declare const plugins: _$_intlayer_types_plugin0.Plugin[];
5
19
  //#endregion
6
- export { configuration as default };
20
+ export { ai, build, compiler, content, configuration as default, dictionary, editor, internationalization, log, plugins, routing, schemas, system };
7
21
  //# sourceMappingURL=built.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"built.d.ts","names":[],"sources":["../../src/built.ts"],"mappings":";;;cAQM,aAAA,EAAe,cAAA"}
1
+ {"version":3,"file":"built.d.ts","names":[],"sources":["../../src/built.ts"],"mappings":";;;;;cAQM,aAAA,EAAe,cAAA;AAAA,cAER,oBAAA,EAAyD,yBAAA,CAArC,0BAAA;AAAA,cACpB,UAAA,EAAU,OAAA,CAA2B,yBAAA,CAA3B,gBAAA;AAAA,cACV,OAAA,EAA+B,yBAAA,CAAxB,aAAA;AAAA,cACP,OAAA,EAA+B,yBAAA,CAAxB,aAAA;AAAA,cACP,MAAA,EAA6B,yBAAA,CAAvB,YAAA;AAAA,cACN,MAAA,EAA6B,yBAAA,CAAvB,YAAA;AAAA,cACN,GAAA,EAAuB,yBAAA,CAApB,SAAA;AAAA,cACH,EAAA,EAAE,OAAA,CAAmB,yBAAA,CAAnB,QAAA;AAAA,cACF,KAAA,EAA2B,yBAAA,CAAtB,WAAA;AAAA,cACL,QAAA,EAAiC,yBAAA,CAAzB,cAAA;AAAA,cACR,OAAA,EAAO,MAAA,SAAwB,yBAAA,CAAxB,MAAA;AAAA,cACP,OAAA,EAA+B,yBAAA,CAAxB,MAAA"}
@@ -2,8 +2,9 @@ import { BrowserIntlayerConfig, buildBrowserConfiguration, buildEditorFields, bu
2
2
  import { extractErrorMessage } from "./utils/extractErrorMessage.js";
3
3
  import { logStack } from "./utils/logStack.js";
4
4
  import { normalizePath } from "./utils/normalizePath.js";
5
+ import { WindowsWithIntlayer, setIntlayerIdentifier } from "./utils/setIntlayerIdentifier.js";
5
6
  import { camelCaseToKebabCase } from "./utils/stringFormatter/camelCaseToKebabCase.js";
6
7
  import { camelCaseToSentence } from "./utils/stringFormatter/camelCaseToSentence.js";
7
8
  import { kebabCaseToCamelCase } from "./utils/stringFormatter/kebabCaseToCamelCase.js";
8
9
  import { toLowerCamelCase } from "./utils/stringFormatter/toLowerCamelCase.js";
9
- export { BrowserIntlayerConfig, buildBrowserConfiguration, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, camelCaseToKebabCase, camelCaseToSentence, extractBrowserConfiguration, extractErrorMessage, kebabCaseToCamelCase, logStack, normalizePath, toLowerCamelCase };
10
+ export { BrowserIntlayerConfig, WindowsWithIntlayer, buildBrowserConfiguration, buildEditorFields, buildInternationalizationFields, buildLogFields, buildRoutingFields, camelCaseToKebabCase, camelCaseToSentence, extractBrowserConfiguration, extractErrorMessage, kebabCaseToCamelCase, logStack, normalizePath, setIntlayerIdentifier, toLowerCamelCase };
@@ -13,7 +13,6 @@ type BrowserIntlayerConfig = {
13
13
  routing: RoutingConfig;
14
14
  editor: Omit<EditorConfig, 'clientId' | 'clientSecret'>;
15
15
  log: Pick<LogConfig, 'mode' | 'prefix'>;
16
- metadata: IntlayerConfig['metadata'];
17
16
  };
18
17
  declare global {
19
18
  interface Window {
@@ -1 +1 @@
1
- {"version":3,"file":"buildBrowserConfiguration.d.ts","names":[],"sources":["../../../src/configFile/buildBrowserConfiguration.ts"],"mappings":";;;;;AA2CA;;;;;KAAY,qBAAA;EACV,oBAAA,EAAsB,IAAA,CACpB,0BAAA;EAGF,OAAA,EAAS,aAAA;EACT,MAAA,EAAQ,IAAA,CAAK,YAAA;EACb,GAAA,EAAK,IAAA,CAAK,SAAA;EACV,QAAA,EAAU,cAAA;AAAA;AAAA,QAGJ,MAAA;EAAA,UACI,MAAA;IAXY;IAapB,eAAA,GAAkB,qBAAA;EAAA;AAAA;;;;;;;cAiBT,+BAAA,GACX,mBAAA,GAAsB,OAAA,CAAQ,0BAAA,MAC7B,0BAAA;;;;AAxBD;;;cAuEW,kBAAA,GACX,mBAAA,GAAsB,OAAA,CAAQ,mBAAA,MAC7B,aAAA;;;;;;;;AAnDH;;;cAgJa,iBAAA,GACX,mBAAA,GAAsB,OAAA,CAAQ,YAAA,MAC7B,YAAA;;;;;;;;cAmIU,cAAA,GACX,mBAAA,GAAsB,OAAA,CAAQ,SAAA,GAC9B,YAAA,GAAe,YAAA,KACd,SAAA;;;AAvOH;;;;;;;;;;;;;;AA+FA;;;;;;cAgMa,yBAAA,GACX,YAAA,GAAe,oBAAA,KACd,qBAAA;;;;;;;;AA7DH;;;;cAiGa,2BAAA,GACX,MAAA,EAAQ,cAAA,KACP,qBAAA"}
1
+ {"version":3,"file":"buildBrowserConfiguration.d.ts","names":[],"sources":["../../../src/configFile/buildBrowserConfiguration.ts"],"mappings":";;;;;AA0CA;;;;;KAAY,qBAAA;EACV,oBAAA,EAAsB,IAAA,CACpB,0BAAA;EAGF,OAAA,EAAS,aAAA;EACT,MAAA,EAAQ,IAAA,CAAK,YAAA;EACb,GAAA,EAAK,IAAA,CAAK,SAAA;AAAA;AAAA,QAGJ,MAAA;EAAA,UACI,MAAA;I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