react-native-intlayer 8.4.4 → 8.4.6

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.
@@ -1,2 +1,77 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./exclusionList.cjs`);let t=require(`node:path`),n=require(`@intlayer/chokidar/build`),r=require(`@intlayer/config/node`),i=require(`@intlayer/config/utils`),a=require(`metro-resolver`);const o=n=>{let o=(0,i.getAlias)({configuration:(0,r.getConfiguration)(),formatter:t.resolve}),s=n?.resolver?.blockList,c=s instanceof RegExp?[s]:s??[],l=n?.resolver?.resolveRequest;return{...n,resolver:{...n?.resolver,resolveRequest:(e,t,...n)=>Object.keys(o).includes(t)?{filePath:o[t],type:`sourceFile`}:t===`@intlayer/config/client`?{filePath:require.resolve(`@intlayer/config/client`),type:`sourceFile`}:t===`@intlayer/core/file`?{filePath:require.resolve(`@intlayer/core/file/browser`),type:`sourceFile`}:l?l(e,t,...n):(0,a.resolve)(e,t,...n),blockList:e.exclusionList([...c,/.*\.content\.(?:ts|tsx|js|jsx|cjs|cjx|mjs|mjx|json)$/])}}},s=async e=>(await(0,n.prepareIntlayer)((0,r.getConfiguration)()),o(e));exports.configMetroIntlayer=s,exports.configMetroIntlayerSync=o;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_exclusionList = require('./exclusionList.cjs');
3
+ let node_path = require("node:path");
4
+ let _intlayer_chokidar_build = require("@intlayer/chokidar/build");
5
+ let _intlayer_config_node = require("@intlayer/config/node");
6
+ let _intlayer_config_utils = require("@intlayer/config/utils");
7
+ let metro_resolver = require("metro-resolver");
8
+
9
+ //#region src/configMetroIntlayer.ts
10
+ /**
11
+ * // metro.config.js
12
+ * const { getDefaultConfig } = require("expo/metro-config");
13
+ * const { configMetroIntlayerSync } = require("react-native-intlayer/metro");
14
+ *
15
+ *
16
+ * const defaultConfig = getDefaultConfig(__dirname);
17
+ *
18
+ * return configMetroIntlayerSync(defaultConfig);
19
+ * ```
20
+ *
21
+ * > Note: `configMetroIntlayerSync` does not build intlayer dictionaries on server start. Use `configMetroIntlayer` for that.
22
+ */
23
+ const configMetroIntlayerSync = (baseConfig) => {
24
+ const alias = (0, _intlayer_config_utils.getAlias)({
25
+ configuration: (0, _intlayer_config_node.getConfiguration)(),
26
+ formatter: node_path.resolve
27
+ });
28
+ const existingBlockList = baseConfig?.resolver?.blockList;
29
+ const existingPatterns = existingBlockList instanceof RegExp ? [existingBlockList] : existingBlockList ?? [];
30
+ const existingResolveRequest = baseConfig?.resolver?.resolveRequest;
31
+ return {
32
+ ...baseConfig,
33
+ resolver: {
34
+ ...baseConfig?.resolver,
35
+ resolveRequest: (context, moduleName, ...args) => {
36
+ if (Object.keys(alias).includes(moduleName)) return {
37
+ filePath: alias[moduleName],
38
+ type: "sourceFile"
39
+ };
40
+ if (moduleName === "@intlayer/config/client") return {
41
+ filePath: require.resolve("@intlayer/config/client"),
42
+ type: "sourceFile"
43
+ };
44
+ if (moduleName === "@intlayer/core/file") return {
45
+ filePath: require.resolve("@intlayer/core/file/browser"),
46
+ type: "sourceFile"
47
+ };
48
+ if (existingResolveRequest) return existingResolveRequest(context, moduleName, ...args);
49
+ return (0, metro_resolver.resolve)(context, moduleName, ...args);
50
+ },
51
+ blockList: require_exclusionList.exclusionList([...existingPatterns, /.*\.content\.(?:ts|tsx|js|jsx|cjs|cjx|mjs|mjx|json)$/])
52
+ }
53
+ };
54
+ };
55
+ /**
56
+ * // metro.config.js
57
+ * const { getDefaultConfig } = require("expo/metro-config");
58
+ * const { configMetroIntlayer } = require("react-native-intlayer/metro");
59
+ *
60
+ * module.exports = (async () => {
61
+ * const defaultConfig = getDefaultConfig(__dirname);
62
+ *
63
+ * return await configMetroIntlayer(defaultConfig);
64
+ * })();
65
+ * ```
66
+ *
67
+ * > Note: `configMetroIntlayer` builds intlayer dictionaries on server start. Use `configMetroIntlayerSync` instead if you want to skip that.
68
+ */
69
+ const configMetroIntlayer = async (baseConfig) => {
70
+ await (0, _intlayer_chokidar_build.prepareIntlayer)((0, _intlayer_config_node.getConfiguration)());
71
+ return configMetroIntlayerSync(baseConfig);
72
+ };
73
+
74
+ //#endregion
75
+ exports.configMetroIntlayer = configMetroIntlayer;
76
+ exports.configMetroIntlayerSync = configMetroIntlayerSync;
2
77
  //# sourceMappingURL=configMetroIntlayer.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"configMetroIntlayer.cjs","names":["pathResolve","exclusionList"],"sources":["../../src/configMetroIntlayer.ts"],"sourcesContent":["import { resolve as pathResolve } from 'node:path';\nimport { prepareIntlayer } from '@intlayer/chokidar/build';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { getAlias } from '@intlayer/config/utils';\nimport type { getDefaultConfig } from 'expo/metro-config';\nimport { resolve } from 'metro-resolver';\nimport { exclusionList } from './exclusionList';\n\ntype MetroConfig = ReturnType<typeof getDefaultConfig>;\n\n/**\n * // metro.config.js\n * const { getDefaultConfig } = require(\"expo/metro-config\");\n * const { configMetroIntlayerSync } = require(\"react-native-intlayer/metro\");\n *\n *\n * const defaultConfig = getDefaultConfig(__dirname);\n *\n * return configMetroIntlayerSync(defaultConfig);\n * ```\n *\n * > Note: `configMetroIntlayerSync` does not build intlayer dictionaries on server start. Use `configMetroIntlayer` for that.\n */\nexport const configMetroIntlayerSync = (\n baseConfig?: MetroConfig\n): MetroConfig => {\n const configuration = getConfiguration();\n\n const alias = getAlias({\n configuration,\n formatter: pathResolve, // get absolute path\n });\n\n const existingBlockList = baseConfig?.resolver?.blockList;\n const existingPatterns: RegExp[] =\n existingBlockList instanceof RegExp\n ? [existingBlockList]\n : (existingBlockList ?? []);\n\n const existingResolveRequest = baseConfig?.resolver?.resolveRequest;\n\n const config = {\n ...baseConfig,\n\n resolver: {\n ...baseConfig?.resolver,\n resolveRequest: (context, moduleName, ...args) => {\n if (Object.keys(alias).includes(moduleName)) {\n return {\n filePath: alias[moduleName as keyof typeof alias],\n type: 'sourceFile',\n };\n }\n\n // Because metro does not resolve submodules, we need to resolve the path manually\n if (moduleName === '@intlayer/config/client') {\n return {\n filePath: require.resolve('@intlayer/config/client'),\n type: 'sourceFile',\n };\n }\n\n // Because metro does not resolve submodules, we need to resolve the path manually\n if (moduleName === '@intlayer/core/file') {\n // Force React Native to use the correct transpiled version\n return {\n filePath: require.resolve('@intlayer/core/file/browser'),\n type: 'sourceFile',\n };\n }\n\n // Delegate to the user-provided resolver if present\n if (existingResolveRequest) {\n return existingResolveRequest(context, moduleName, ...args);\n }\n\n // Fallback to metro-resolver\n return resolve(context as any, moduleName, ...args);\n },\n blockList: exclusionList([\n ...existingPatterns,\n // the following instruction should be replaced by a pattern derived from configuration.content.fileExtensions\n // but generating the pattern from fileExtensions does not exclude the files properly for now\n /.*\\.content\\.(?:ts|tsx|js|jsx|cjs|cjx|mjs|mjx|json)$/,\n ]),\n },\n } as MetroConfig;\n\n return config;\n};\n\n/**\n * // metro.config.js\n * const { getDefaultConfig } = require(\"expo/metro-config\");\n * const { configMetroIntlayer } = require(\"react-native-intlayer/metro\");\n *\n * module.exports = (async () => {\n * const defaultConfig = getDefaultConfig(__dirname);\n *\n * return await configMetroIntlayer(defaultConfig);\n * })();\n * ```\n *\n * > Note: `configMetroIntlayer` builds intlayer dictionaries on server start. Use `configMetroIntlayerSync` instead if you want to skip that.\n */\nexport const configMetroIntlayer = async (\n baseConfig?: MetroConfig\n): Promise<MetroConfig> => {\n const configuration = getConfiguration();\n\n await prepareIntlayer(configuration);\n\n return configMetroIntlayerSync(baseConfig);\n};\n"],"mappings":"8QAuBA,MAAa,EACX,GACgB,CAGhB,IAAM,GAAA,EAAA,EAAA,UAAiB,CACrB,eAAA,EAAA,EAAA,mBAHsC,CAItC,UAAWA,EAAAA,QACZ,CAAC,CAEI,EAAoB,GAAY,UAAU,UAC1C,EACJ,aAA6B,OACzB,CAAC,EAAkB,CAClB,GAAqB,EAAE,CAExB,EAAyB,GAAY,UAAU,eAiDrD,MA/Ce,CACb,GAAG,EAEH,SAAU,CACR,GAAG,GAAY,SACf,gBAAiB,EAAS,EAAY,GAAG,IACnC,OAAO,KAAK,EAAM,CAAC,SAAS,EAAW,CAClC,CACL,SAAU,EAAM,GAChB,KAAM,aACP,CAIC,IAAe,0BACV,CACL,SAAU,QAAQ,QAAQ,0BAA0B,CACpD,KAAM,aACP,CAIC,IAAe,sBAEV,CACL,SAAU,QAAQ,QAAQ,8BAA8B,CACxD,KAAM,aACP,CAIC,EACK,EAAuB,EAAS,EAAY,GAAG,EAAK,EAI7D,EAAA,EAAA,SAAe,EAAgB,EAAY,GAAG,EAAK,CAErD,UAAWC,EAAAA,cAAc,CACvB,GAAG,EAGH,uDACD,CAAC,CACH,CACF,EAmBU,EAAsB,KACjC,KAIA,MAAA,EAAA,EAAA,kBAAA,EAAA,EAAA,mBAFwC,CAEJ,CAE7B,EAAwB,EAAW"}
1
+ {"version":3,"file":"configMetroIntlayer.cjs","names":["pathResolve","exclusionList"],"sources":["../../src/configMetroIntlayer.ts"],"sourcesContent":["import { resolve as pathResolve } from 'node:path';\nimport { prepareIntlayer } from '@intlayer/chokidar/build';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { getAlias } from '@intlayer/config/utils';\nimport type { getDefaultConfig } from 'expo/metro-config';\nimport { resolve } from 'metro-resolver';\nimport { exclusionList } from './exclusionList';\n\ntype MetroConfig = ReturnType<typeof getDefaultConfig>;\n\n/**\n * // metro.config.js\n * const { getDefaultConfig } = require(\"expo/metro-config\");\n * const { configMetroIntlayerSync } = require(\"react-native-intlayer/metro\");\n *\n *\n * const defaultConfig = getDefaultConfig(__dirname);\n *\n * return configMetroIntlayerSync(defaultConfig);\n * ```\n *\n * > Note: `configMetroIntlayerSync` does not build intlayer dictionaries on server start. Use `configMetroIntlayer` for that.\n */\nexport const configMetroIntlayerSync = (\n baseConfig?: MetroConfig\n): MetroConfig => {\n const configuration = getConfiguration();\n\n const alias = getAlias({\n configuration,\n formatter: pathResolve, // get absolute path\n });\n\n const existingBlockList = baseConfig?.resolver?.blockList;\n const existingPatterns: RegExp[] =\n existingBlockList instanceof RegExp\n ? [existingBlockList]\n : (existingBlockList ?? []);\n\n const existingResolveRequest = baseConfig?.resolver?.resolveRequest;\n\n const config = {\n ...baseConfig,\n\n resolver: {\n ...baseConfig?.resolver,\n resolveRequest: (context, moduleName, ...args) => {\n if (Object.keys(alias).includes(moduleName)) {\n return {\n filePath: alias[moduleName as keyof typeof alias],\n type: 'sourceFile',\n };\n }\n\n // Because metro does not resolve submodules, we need to resolve the path manually\n if (moduleName === '@intlayer/config/client') {\n return {\n filePath: require.resolve('@intlayer/config/client'),\n type: 'sourceFile',\n };\n }\n\n // Because metro does not resolve submodules, we need to resolve the path manually\n if (moduleName === '@intlayer/core/file') {\n // Force React Native to use the correct transpiled version\n return {\n filePath: require.resolve('@intlayer/core/file/browser'),\n type: 'sourceFile',\n };\n }\n\n // Delegate to the user-provided resolver if present\n if (existingResolveRequest) {\n return existingResolveRequest(context, moduleName, ...args);\n }\n\n // Fallback to metro-resolver\n return resolve(context as any, moduleName, ...args);\n },\n blockList: exclusionList([\n ...existingPatterns,\n // the following instruction should be replaced by a pattern derived from configuration.content.fileExtensions\n // but generating the pattern from fileExtensions does not exclude the files properly for now\n /.*\\.content\\.(?:ts|tsx|js|jsx|cjs|cjx|mjs|mjx|json)$/,\n ]),\n },\n } as MetroConfig;\n\n return config;\n};\n\n/**\n * // metro.config.js\n * const { getDefaultConfig } = require(\"expo/metro-config\");\n * const { configMetroIntlayer } = require(\"react-native-intlayer/metro\");\n *\n * module.exports = (async () => {\n * const defaultConfig = getDefaultConfig(__dirname);\n *\n * return await configMetroIntlayer(defaultConfig);\n * })();\n * ```\n *\n * > Note: `configMetroIntlayer` builds intlayer dictionaries on server start. Use `configMetroIntlayerSync` instead if you want to skip that.\n */\nexport const configMetroIntlayer = async (\n baseConfig?: MetroConfig\n): Promise<MetroConfig> => {\n const configuration = getConfiguration();\n\n await prepareIntlayer(configuration);\n\n return configMetroIntlayerSync(baseConfig);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,2BACX,eACgB;CAGhB,MAAM,6CAAiB;EACrB,4DAHsC;EAItC,WAAWA;EACZ,CAAC;CAEF,MAAM,oBAAoB,YAAY,UAAU;CAChD,MAAM,mBACJ,6BAA6B,SACzB,CAAC,kBAAkB,GAClB,qBAAqB,EAAE;CAE9B,MAAM,yBAAyB,YAAY,UAAU;AAiDrD,QA/Ce;EACb,GAAG;EAEH,UAAU;GACR,GAAG,YAAY;GACf,iBAAiB,SAAS,YAAY,GAAG,SAAS;AAChD,QAAI,OAAO,KAAK,MAAM,CAAC,SAAS,WAAW,CACzC,QAAO;KACL,UAAU,MAAM;KAChB,MAAM;KACP;AAIH,QAAI,eAAe,0BACjB,QAAO;KACL,UAAU,QAAQ,QAAQ,0BAA0B;KACpD,MAAM;KACP;AAIH,QAAI,eAAe,sBAEjB,QAAO;KACL,UAAU,QAAQ,QAAQ,8BAA8B;KACxD,MAAM;KACP;AAIH,QAAI,uBACF,QAAO,uBAAuB,SAAS,YAAY,GAAG,KAAK;AAI7D,uCAAe,SAAgB,YAAY,GAAG,KAAK;;GAErD,WAAWC,oCAAc,CACvB,GAAG,kBAGH,uDACD,CAAC;GACH;EACF;;;;;;;;;;;;;;;;AAmBH,MAAa,sBAAsB,OACjC,eACyB;AAGzB,kGAFwC,CAEJ;AAEpC,QAAO,wBAAwB,WAAW"}
@@ -1,2 +1,15 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`node:path`);const t=t=>{let n=e.sep===`\\`?`\\\\`:`/`;if(t instanceof RegExp)return t.source.replace(/\//g,n);if(typeof t==`string`)return t.replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`).replace(/\//g,n);throw Error(`Unexpected exclusion pattern: ${t}`)},n=e=>[RegExp(`(${e.map(t).join(`|`)})$`)];exports.exclusionList=n;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let node_path = require("node:path");
3
+
4
+ //#region src/exclusionList.ts
5
+ const normalizePattern = (pattern) => {
6
+ const separators = node_path.sep === "\\" ? "\\\\" : "/";
7
+ if (pattern instanceof RegExp) return pattern.source.replace(/\//g, separators);
8
+ if (typeof pattern === "string") return pattern.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&").replace(/\//g, separators);
9
+ throw new Error(`Unexpected exclusion pattern: ${pattern}`);
10
+ };
11
+ const exclusionList = (additionalExclusions) => [new RegExp(`(${additionalExclusions.map(normalizePattern).join("|")})$`)];
12
+
13
+ //#endregion
14
+ exports.exclusionList = exclusionList;
2
15
  //# sourceMappingURL=exclusionList.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"exclusionList.cjs","names":["sep"],"sources":["../../src/exclusionList.ts"],"sourcesContent":["import { sep } from 'node:path';\n\nconst normalizePattern = (pattern: RegExp | string): string => {\n // On Windows, path separators are backslashes; double-escape for use inside a RegExp source string\n const separators = sep === '\\\\' ? '\\\\\\\\' : '/';\n\n if (pattern instanceof RegExp) {\n return pattern.source.replace(/\\//g, separators);\n }\n\n if (typeof pattern === 'string') {\n const escaped = pattern.replace(/[\\\\^$.*+?()[\\]{}|]/g, '\\\\$&');\n return escaped.replace(/\\//g, separators);\n }\n\n throw new Error(`Unexpected exclusion pattern: ${pattern}`);\n};\n\nexport const exclusionList = (\n additionalExclusions: (RegExp | string)[]\n): RegExp[] => [\n new RegExp(`(${additionalExclusions.map(normalizePattern).join('|')})$`),\n];\n"],"mappings":"8FAEA,MAAM,EAAoB,GAAqC,CAE7D,IAAM,EAAaA,EAAAA,MAAQ,KAAO,OAAS,IAE3C,GAAI,aAAmB,OACrB,OAAO,EAAQ,OAAO,QAAQ,MAAO,EAAW,CAGlD,GAAI,OAAO,GAAY,SAErB,OADgB,EAAQ,QAAQ,sBAAuB,OAAO,CAC/C,QAAQ,MAAO,EAAW,CAG3C,MAAU,MAAM,iCAAiC,IAAU,EAGhD,EACX,GACa,CACT,OAAO,IAAI,EAAqB,IAAI,EAAiB,CAAC,KAAK,IAAI,CAAC,IAAI,CACzE"}
1
+ {"version":3,"file":"exclusionList.cjs","names":["sep"],"sources":["../../src/exclusionList.ts"],"sourcesContent":["import { sep } from 'node:path';\n\nconst normalizePattern = (pattern: RegExp | string): string => {\n // On Windows, path separators are backslashes; double-escape for use inside a RegExp source string\n const separators = sep === '\\\\' ? '\\\\\\\\' : '/';\n\n if (pattern instanceof RegExp) {\n return pattern.source.replace(/\\//g, separators);\n }\n\n if (typeof pattern === 'string') {\n const escaped = pattern.replace(/[\\\\^$.*+?()[\\]{}|]/g, '\\\\$&');\n return escaped.replace(/\\//g, separators);\n }\n\n throw new Error(`Unexpected exclusion pattern: ${pattern}`);\n};\n\nexport const exclusionList = (\n additionalExclusions: (RegExp | string)[]\n): RegExp[] => [\n new RegExp(`(${additionalExclusions.map(normalizePattern).join('|')})$`),\n];\n"],"mappings":";;;;AAEA,MAAM,oBAAoB,YAAqC;CAE7D,MAAM,aAAaA,kBAAQ,OAAO,SAAS;AAE3C,KAAI,mBAAmB,OACrB,QAAO,QAAQ,OAAO,QAAQ,OAAO,WAAW;AAGlD,KAAI,OAAO,YAAY,SAErB,QADgB,QAAQ,QAAQ,uBAAuB,OAAO,CAC/C,QAAQ,OAAO,WAAW;AAG3C,OAAM,IAAI,MAAM,iCAAiC,UAAU;;AAG7D,MAAa,iBACX,yBACa,CACb,IAAI,OAAO,IAAI,qBAAqB,IAAI,iBAAiB,CAAC,KAAK,IAAI,CAAC,IAAI,CACzE"}
@@ -1 +1,6 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./intlayerPolyfill.cjs`),t=require(`./intlayerProvider.cjs`);exports.IntlayerProvider=t.IntlayerProvider,exports.intlayerPolyfill=e.intlayerPolyfill;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_intlayerPolyfill = require('./intlayerPolyfill.cjs');
3
+ const require_intlayerProvider = require('./intlayerProvider.cjs');
4
+
5
+ exports.IntlayerProvider = require_intlayerProvider.IntlayerProvider;
6
+ exports.intlayerPolyfill = require_intlayerPolyfill.intlayerPolyfill;
@@ -1,2 +1,23 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=()=>{typeof global.structuredClone!=`function`&&(global.structuredClone=e=>JSON.parse(JSON.stringify(e))),typeof window<`u`&&(typeof window.addEventListener!=`function`&&(window.addEventListener=()=>null),typeof window.removeEventListener!=`function`&&(window.removeEventListener=()=>null),typeof window.postMessage!=`function`&&(window.postMessage=()=>null))};exports.intlayerPolyfill=e;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/intlayerPolyfill.ts
4
+ /**
5
+ * Applies necessary polyfills for React Native to support Intlayer.
6
+ *
7
+ * This includes polyfilling `structuredClone` if it is missing,
8
+ * and providing no-op implementations for standard DOM `window` methods
9
+ * (`addEventListener`, `removeEventListener`, `postMessage`)
10
+ * to ensure compatibility with libraries that expect a browser-like environment.
11
+ */
12
+ const intlayerPolyfill = () => {
13
+ if (typeof global.structuredClone !== "function") global.structuredClone = (obj) => JSON.parse(JSON.stringify(obj));
14
+ if (typeof window !== "undefined") {
15
+ if (typeof window.addEventListener !== "function") window.addEventListener = () => null;
16
+ if (typeof window.removeEventListener !== "function") window.removeEventListener = () => null;
17
+ if (typeof window.postMessage !== "function") window.postMessage = () => null;
18
+ }
19
+ };
20
+
21
+ //#endregion
22
+ exports.intlayerPolyfill = intlayerPolyfill;
2
23
  //# sourceMappingURL=intlayerPolyfill.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"intlayerPolyfill.cjs","names":[],"sources":["../../src/intlayerPolyfill.ts"],"sourcesContent":["/**\n * Applies necessary polyfills for React Native to support Intlayer.\n *\n * This includes polyfilling `structuredClone` if it is missing,\n * and providing no-op implementations for standard DOM `window` methods\n * (`addEventListener`, `removeEventListener`, `postMessage`)\n * to ensure compatibility with libraries that expect a browser-like environment.\n */\nexport const intlayerPolyfill = () => {\n if (typeof global.structuredClone !== 'function') {\n global.structuredClone = (obj) => JSON.parse(JSON.stringify(obj));\n }\n\n if (typeof window !== 'undefined') {\n if (typeof window.addEventListener !== 'function') {\n window.addEventListener = () => null;\n }\n if (typeof window.removeEventListener !== 'function') {\n window.removeEventListener = () => null;\n }\n if (typeof window.postMessage !== 'function') {\n window.postMessage = () => null;\n }\n }\n};\n"],"mappings":"mEAQA,MAAa,MAAyB,CAChC,OAAO,OAAO,iBAAoB,aACpC,OAAO,gBAAmB,GAAQ,KAAK,MAAM,KAAK,UAAU,EAAI,CAAC,EAG/D,OAAO,OAAW,MAChB,OAAO,OAAO,kBAAqB,aACrC,OAAO,qBAAyB,MAE9B,OAAO,OAAO,qBAAwB,aACxC,OAAO,wBAA4B,MAEjC,OAAO,OAAO,aAAgB,aAChC,OAAO,gBAAoB"}
1
+ {"version":3,"file":"intlayerPolyfill.cjs","names":[],"sources":["../../src/intlayerPolyfill.ts"],"sourcesContent":["/**\n * Applies necessary polyfills for React Native to support Intlayer.\n *\n * This includes polyfilling `structuredClone` if it is missing,\n * and providing no-op implementations for standard DOM `window` methods\n * (`addEventListener`, `removeEventListener`, `postMessage`)\n * to ensure compatibility with libraries that expect a browser-like environment.\n */\nexport const intlayerPolyfill = () => {\n if (typeof global.structuredClone !== 'function') {\n global.structuredClone = (obj) => JSON.parse(JSON.stringify(obj));\n }\n\n if (typeof window !== 'undefined') {\n if (typeof window.addEventListener !== 'function') {\n window.addEventListener = () => null;\n }\n if (typeof window.removeEventListener !== 'function') {\n window.removeEventListener = () => null;\n }\n if (typeof window.postMessage !== 'function') {\n window.postMessage = () => null;\n }\n }\n};\n"],"mappings":";;;;;;;;;;;AAQA,MAAa,yBAAyB;AACpC,KAAI,OAAO,OAAO,oBAAoB,WACpC,QAAO,mBAAmB,QAAQ,KAAK,MAAM,KAAK,UAAU,IAAI,CAAC;AAGnE,KAAI,OAAO,WAAW,aAAa;AACjC,MAAI,OAAO,OAAO,qBAAqB,WACrC,QAAO,yBAAyB;AAElC,MAAI,OAAO,OAAO,wBAAwB,WACxC,QAAO,4BAA4B;AAErC,MAAI,OAAO,OAAO,gBAAgB,WAChC,QAAO,oBAAoB"}
@@ -1,2 +1,34 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./intlayerPolyfill.cjs`);let t=require(`react-intlayer`),n=require(`react/jsx-runtime`);e.intlayerPolyfill();const r=({children:e,...r})=>(0,n.jsx)(t.IntlayerProviderContent,{...r,children:e});exports.IntlayerProvider=r;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_intlayerPolyfill = require('./intlayerPolyfill.cjs');
3
+ let react_intlayer = require("react-intlayer");
4
+ let react_jsx_runtime = require("react/jsx-runtime");
5
+
6
+ //#region src/intlayerProvider.tsx
7
+ require_intlayerPolyfill.intlayerPolyfill();
8
+ /**
9
+ * Provider component that wraps your application and provides the Intlayer context.
10
+ *
11
+ * This provider also automatically applies necessary polyfills for React Native.
12
+ *
13
+ * @param props - The provider props, excluding editor-specific and cookie-specific options which are not applicable in React Native.
14
+ * @returns The provider component.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * import { IntlayerProvider } from 'react-native-intlayer';
19
+ *
20
+ * const App = () => (
21
+ * <IntlayerProvider>
22
+ * <MyComponent />
23
+ * </IntlayerProvider>
24
+ * );
25
+ * ```
26
+ */
27
+ const IntlayerProvider = ({ children, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_intlayer.IntlayerProviderContent, {
28
+ ...props,
29
+ children
30
+ });
31
+
32
+ //#endregion
33
+ exports.IntlayerProvider = IntlayerProvider;
2
34
  //# sourceMappingURL=intlayerProvider.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"intlayerProvider.cjs","names":["intlayerPolyfill","IntlayerProviderContent"],"sources":["../../src/intlayerProvider.tsx"],"sourcesContent":["import {\n IntlayerProviderContent,\n type IntlayerProviderProps as IntlayerProviderPropsBase,\n} from 'react-intlayer';\nimport { intlayerPolyfill } from './intlayerPolyfill';\n\nintlayerPolyfill();\n\ntype IntlayerProviderProps = Omit<\n IntlayerProviderPropsBase,\n 'disableEditor' | 'isCookieEnabled'\n>;\n\n/**\n * Provider component that wraps your application and provides the Intlayer context.\n *\n * This provider also automatically applies necessary polyfills for React Native.\n *\n * @param props - The provider props, excluding editor-specific and cookie-specific options which are not applicable in React Native.\n * @returns The provider component.\n *\n * @example\n * ```tsx\n * import { IntlayerProvider } from 'react-native-intlayer';\n *\n * const App = () => (\n * <IntlayerProvider>\n * <MyComponent />\n * </IntlayerProvider>\n * );\n * ```\n */\nexport const IntlayerProvider = ({\n children,\n ...props\n}: IntlayerProviderProps) => (\n <IntlayerProviderContent {...props}>{children}</IntlayerProviderContent>\n);\n"],"mappings":"4KAMAA,EAAAA,kBAAkB,CA0BlB,MAAa,GAAoB,CAC/B,WACA,GAAG,MAEH,EAAA,EAAA,KAACC,EAAAA,wBAAD,CAAyB,GAAI,EAAQ,WAAmC,CAAA"}
1
+ {"version":3,"file":"intlayerProvider.cjs","names":["intlayerPolyfill","IntlayerProviderContent"],"sources":["../../src/intlayerProvider.tsx"],"sourcesContent":["import {\n IntlayerProviderContent,\n type IntlayerProviderProps as IntlayerProviderPropsBase,\n} from 'react-intlayer';\nimport { intlayerPolyfill } from './intlayerPolyfill';\n\nintlayerPolyfill();\n\ntype IntlayerProviderProps = Omit<\n IntlayerProviderPropsBase,\n 'disableEditor' | 'isCookieEnabled'\n>;\n\n/**\n * Provider component that wraps your application and provides the Intlayer context.\n *\n * This provider also automatically applies necessary polyfills for React Native.\n *\n * @param props - The provider props, excluding editor-specific and cookie-specific options which are not applicable in React Native.\n * @returns The provider component.\n *\n * @example\n * ```tsx\n * import { IntlayerProvider } from 'react-native-intlayer';\n *\n * const App = () => (\n * <IntlayerProvider>\n * <MyComponent />\n * </IntlayerProvider>\n * );\n * ```\n */\nexport const IntlayerProvider = ({\n children,\n ...props\n}: IntlayerProviderProps) => (\n <IntlayerProviderContent {...props}>{children}</IntlayerProviderContent>\n);\n"],"mappings":";;;;;;AAMAA,2CAAkB;;;;;;;;;;;;;;;;;;;;AA0BlB,MAAa,oBAAoB,EAC/B,UACA,GAAG,YAEH,2CAACC,wCAAD;CAAyB,GAAI;CAAQ;CAAmC"}
@@ -1 +1,5 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./configMetroIntlayer.cjs`);exports.configMetroIntlayer=e.configMetroIntlayer,exports.configMetroIntlayerSync=e.configMetroIntlayerSync;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_configMetroIntlayer = require('./configMetroIntlayer.cjs');
3
+
4
+ exports.configMetroIntlayer = require_configMetroIntlayer.configMetroIntlayer;
5
+ exports.configMetroIntlayerSync = require_configMetroIntlayer.configMetroIntlayerSync;
@@ -0,0 +1,8 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
3
+ if (typeof require !== "undefined") return require.apply(this, arguments);
4
+ throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
5
+ });
6
+
7
+ //#endregion
8
+ export { __require };
@@ -1 +1,76 @@
1
- import{n as e,t}from"./configMetroIntlayer-qNNTJySv.mjs";export{t as configMetroIntlayer,e as configMetroIntlayerSync};
1
+ import { __require } from "./_virtual/_rolldown/runtime.mjs";
2
+ import { exclusionList } from "./exclusionList.mjs";
3
+ import { resolve } from "node:path";
4
+ import { prepareIntlayer } from "@intlayer/chokidar/build";
5
+ import { getConfiguration } from "@intlayer/config/node";
6
+ import { getAlias } from "@intlayer/config/utils";
7
+ import { resolve as resolve$1 } from "metro-resolver";
8
+
9
+ //#region src/configMetroIntlayer.ts
10
+ /**
11
+ * // metro.config.js
12
+ * const { getDefaultConfig } = require("expo/metro-config");
13
+ * const { configMetroIntlayerSync } = require("react-native-intlayer/metro");
14
+ *
15
+ *
16
+ * const defaultConfig = getDefaultConfig(__dirname);
17
+ *
18
+ * return configMetroIntlayerSync(defaultConfig);
19
+ * ```
20
+ *
21
+ * > Note: `configMetroIntlayerSync` does not build intlayer dictionaries on server start. Use `configMetroIntlayer` for that.
22
+ */
23
+ const configMetroIntlayerSync = (baseConfig) => {
24
+ const alias = getAlias({
25
+ configuration: getConfiguration(),
26
+ formatter: resolve
27
+ });
28
+ const existingBlockList = baseConfig?.resolver?.blockList;
29
+ const existingPatterns = existingBlockList instanceof RegExp ? [existingBlockList] : existingBlockList ?? [];
30
+ const existingResolveRequest = baseConfig?.resolver?.resolveRequest;
31
+ return {
32
+ ...baseConfig,
33
+ resolver: {
34
+ ...baseConfig?.resolver,
35
+ resolveRequest: (context, moduleName, ...args) => {
36
+ if (Object.keys(alias).includes(moduleName)) return {
37
+ filePath: alias[moduleName],
38
+ type: "sourceFile"
39
+ };
40
+ if (moduleName === "@intlayer/config/client") return {
41
+ filePath: __require.resolve("@intlayer/config/client"),
42
+ type: "sourceFile"
43
+ };
44
+ if (moduleName === "@intlayer/core/file") return {
45
+ filePath: __require.resolve("@intlayer/core/file/browser"),
46
+ type: "sourceFile"
47
+ };
48
+ if (existingResolveRequest) return existingResolveRequest(context, moduleName, ...args);
49
+ return resolve$1(context, moduleName, ...args);
50
+ },
51
+ blockList: exclusionList([...existingPatterns, /.*\.content\.(?:ts|tsx|js|jsx|cjs|cjx|mjs|mjx|json)$/])
52
+ }
53
+ };
54
+ };
55
+ /**
56
+ * // metro.config.js
57
+ * const { getDefaultConfig } = require("expo/metro-config");
58
+ * const { configMetroIntlayer } = require("react-native-intlayer/metro");
59
+ *
60
+ * module.exports = (async () => {
61
+ * const defaultConfig = getDefaultConfig(__dirname);
62
+ *
63
+ * return await configMetroIntlayer(defaultConfig);
64
+ * })();
65
+ * ```
66
+ *
67
+ * > Note: `configMetroIntlayer` builds intlayer dictionaries on server start. Use `configMetroIntlayerSync` instead if you want to skip that.
68
+ */
69
+ const configMetroIntlayer = async (baseConfig) => {
70
+ await prepareIntlayer(getConfiguration());
71
+ return configMetroIntlayerSync(baseConfig);
72
+ };
73
+
74
+ //#endregion
75
+ export { configMetroIntlayer, configMetroIntlayerSync };
76
+ //# sourceMappingURL=configMetroIntlayer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configMetroIntlayer.mjs","names":["pathResolve","resolve"],"sources":["../../src/configMetroIntlayer.ts"],"sourcesContent":["import { resolve as pathResolve } from 'node:path';\nimport { prepareIntlayer } from '@intlayer/chokidar/build';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { getAlias } from '@intlayer/config/utils';\nimport type { getDefaultConfig } from 'expo/metro-config';\nimport { resolve } from 'metro-resolver';\nimport { exclusionList } from './exclusionList';\n\ntype MetroConfig = ReturnType<typeof getDefaultConfig>;\n\n/**\n * // metro.config.js\n * const { getDefaultConfig } = require(\"expo/metro-config\");\n * const { configMetroIntlayerSync } = require(\"react-native-intlayer/metro\");\n *\n *\n * const defaultConfig = getDefaultConfig(__dirname);\n *\n * return configMetroIntlayerSync(defaultConfig);\n * ```\n *\n * > Note: `configMetroIntlayerSync` does not build intlayer dictionaries on server start. Use `configMetroIntlayer` for that.\n */\nexport const configMetroIntlayerSync = (\n baseConfig?: MetroConfig\n): MetroConfig => {\n const configuration = getConfiguration();\n\n const alias = getAlias({\n configuration,\n formatter: pathResolve, // get absolute path\n });\n\n const existingBlockList = baseConfig?.resolver?.blockList;\n const existingPatterns: RegExp[] =\n existingBlockList instanceof RegExp\n ? [existingBlockList]\n : (existingBlockList ?? []);\n\n const existingResolveRequest = baseConfig?.resolver?.resolveRequest;\n\n const config = {\n ...baseConfig,\n\n resolver: {\n ...baseConfig?.resolver,\n resolveRequest: (context, moduleName, ...args) => {\n if (Object.keys(alias).includes(moduleName)) {\n return {\n filePath: alias[moduleName as keyof typeof alias],\n type: 'sourceFile',\n };\n }\n\n // Because metro does not resolve submodules, we need to resolve the path manually\n if (moduleName === '@intlayer/config/client') {\n return {\n filePath: require.resolve('@intlayer/config/client'),\n type: 'sourceFile',\n };\n }\n\n // Because metro does not resolve submodules, we need to resolve the path manually\n if (moduleName === '@intlayer/core/file') {\n // Force React Native to use the correct transpiled version\n return {\n filePath: require.resolve('@intlayer/core/file/browser'),\n type: 'sourceFile',\n };\n }\n\n // Delegate to the user-provided resolver if present\n if (existingResolveRequest) {\n return existingResolveRequest(context, moduleName, ...args);\n }\n\n // Fallback to metro-resolver\n return resolve(context as any, moduleName, ...args);\n },\n blockList: exclusionList([\n ...existingPatterns,\n // the following instruction should be replaced by a pattern derived from configuration.content.fileExtensions\n // but generating the pattern from fileExtensions does not exclude the files properly for now\n /.*\\.content\\.(?:ts|tsx|js|jsx|cjs|cjx|mjs|mjx|json)$/,\n ]),\n },\n } as MetroConfig;\n\n return config;\n};\n\n/**\n * // metro.config.js\n * const { getDefaultConfig } = require(\"expo/metro-config\");\n * const { configMetroIntlayer } = require(\"react-native-intlayer/metro\");\n *\n * module.exports = (async () => {\n * const defaultConfig = getDefaultConfig(__dirname);\n *\n * return await configMetroIntlayer(defaultConfig);\n * })();\n * ```\n *\n * > Note: `configMetroIntlayer` builds intlayer dictionaries on server start. Use `configMetroIntlayerSync` instead if you want to skip that.\n */\nexport const configMetroIntlayer = async (\n baseConfig?: MetroConfig\n): Promise<MetroConfig> => {\n const configuration = getConfiguration();\n\n await prepareIntlayer(configuration);\n\n return configMetroIntlayerSync(baseConfig);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,2BACX,eACgB;CAGhB,MAAM,QAAQ,SAAS;EACrB,eAHoB,kBAAkB;EAItC,WAAWA;EACZ,CAAC;CAEF,MAAM,oBAAoB,YAAY,UAAU;CAChD,MAAM,mBACJ,6BAA6B,SACzB,CAAC,kBAAkB,GAClB,qBAAqB,EAAE;CAE9B,MAAM,yBAAyB,YAAY,UAAU;AAiDrD,QA/Ce;EACb,GAAG;EAEH,UAAU;GACR,GAAG,YAAY;GACf,iBAAiB,SAAS,YAAY,GAAG,SAAS;AAChD,QAAI,OAAO,KAAK,MAAM,CAAC,SAAS,WAAW,CACzC,QAAO;KACL,UAAU,MAAM;KAChB,MAAM;KACP;AAIH,QAAI,eAAe,0BACjB,QAAO;KACL,oBAAkB,QAAQ,0BAA0B;KACpD,MAAM;KACP;AAIH,QAAI,eAAe,sBAEjB,QAAO;KACL,oBAAkB,QAAQ,8BAA8B;KACxD,MAAM;KACP;AAIH,QAAI,uBACF,QAAO,uBAAuB,SAAS,YAAY,GAAG,KAAK;AAI7D,WAAOC,UAAQ,SAAgB,YAAY,GAAG,KAAK;;GAErD,WAAW,cAAc,CACvB,GAAG,kBAGH,uDACD,CAAC;GACH;EACF;;;;;;;;;;;;;;;;AAmBH,MAAa,sBAAsB,OACjC,eACyB;AAGzB,OAAM,gBAFgB,kBAAkB,CAEJ;AAEpC,QAAO,wBAAwB,WAAW"}
@@ -1,2 +1,14 @@
1
- import{sep as e}from"node:path";const t=t=>{let n=e===`\\`?`\\\\`:`/`;if(t instanceof RegExp)return t.source.replace(/\//g,n);if(typeof t==`string`)return t.replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`).replace(/\//g,n);throw Error(`Unexpected exclusion pattern: ${t}`)},n=e=>[RegExp(`(${e.map(t).join(`|`)})$`)];export{n as exclusionList};
1
+ import { sep } from "node:path";
2
+
3
+ //#region src/exclusionList.ts
4
+ const normalizePattern = (pattern) => {
5
+ const separators = sep === "\\" ? "\\\\" : "/";
6
+ if (pattern instanceof RegExp) return pattern.source.replace(/\//g, separators);
7
+ if (typeof pattern === "string") return pattern.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&").replace(/\//g, separators);
8
+ throw new Error(`Unexpected exclusion pattern: ${pattern}`);
9
+ };
10
+ const exclusionList = (additionalExclusions) => [new RegExp(`(${additionalExclusions.map(normalizePattern).join("|")})$`)];
11
+
12
+ //#endregion
13
+ export { exclusionList };
2
14
  //# sourceMappingURL=exclusionList.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"exclusionList.mjs","names":[],"sources":["../../src/exclusionList.ts"],"sourcesContent":["import { sep } from 'node:path';\n\nconst normalizePattern = (pattern: RegExp | string): string => {\n // On Windows, path separators are backslashes; double-escape for use inside a RegExp source string\n const separators = sep === '\\\\' ? '\\\\\\\\' : '/';\n\n if (pattern instanceof RegExp) {\n return pattern.source.replace(/\\//g, separators);\n }\n\n if (typeof pattern === 'string') {\n const escaped = pattern.replace(/[\\\\^$.*+?()[\\]{}|]/g, '\\\\$&');\n return escaped.replace(/\\//g, separators);\n }\n\n throw new Error(`Unexpected exclusion pattern: ${pattern}`);\n};\n\nexport const exclusionList = (\n additionalExclusions: (RegExp | string)[]\n): RegExp[] => [\n new RegExp(`(${additionalExclusions.map(normalizePattern).join('|')})$`),\n];\n"],"mappings":"gCAEA,MAAM,EAAoB,GAAqC,CAE7D,IAAM,EAAa,IAAQ,KAAO,OAAS,IAE3C,GAAI,aAAmB,OACrB,OAAO,EAAQ,OAAO,QAAQ,MAAO,EAAW,CAGlD,GAAI,OAAO,GAAY,SAErB,OADgB,EAAQ,QAAQ,sBAAuB,OAAO,CAC/C,QAAQ,MAAO,EAAW,CAG3C,MAAU,MAAM,iCAAiC,IAAU,EAGhD,EACX,GACa,CACT,OAAO,IAAI,EAAqB,IAAI,EAAiB,CAAC,KAAK,IAAI,CAAC,IAAI,CACzE"}
1
+ {"version":3,"file":"exclusionList.mjs","names":[],"sources":["../../src/exclusionList.ts"],"sourcesContent":["import { sep } from 'node:path';\n\nconst normalizePattern = (pattern: RegExp | string): string => {\n // On Windows, path separators are backslashes; double-escape for use inside a RegExp source string\n const separators = sep === '\\\\' ? '\\\\\\\\' : '/';\n\n if (pattern instanceof RegExp) {\n return pattern.source.replace(/\\//g, separators);\n }\n\n if (typeof pattern === 'string') {\n const escaped = pattern.replace(/[\\\\^$.*+?()[\\]{}|]/g, '\\\\$&');\n return escaped.replace(/\\//g, separators);\n }\n\n throw new Error(`Unexpected exclusion pattern: ${pattern}`);\n};\n\nexport const exclusionList = (\n additionalExclusions: (RegExp | string)[]\n): RegExp[] => [\n new RegExp(`(${additionalExclusions.map(normalizePattern).join('|')})$`),\n];\n"],"mappings":";;;AAEA,MAAM,oBAAoB,YAAqC;CAE7D,MAAM,aAAa,QAAQ,OAAO,SAAS;AAE3C,KAAI,mBAAmB,OACrB,QAAO,QAAQ,OAAO,QAAQ,OAAO,WAAW;AAGlD,KAAI,OAAO,YAAY,SAErB,QADgB,QAAQ,QAAQ,uBAAuB,OAAO,CAC/C,QAAQ,OAAO,WAAW;AAG3C,OAAM,IAAI,MAAM,iCAAiC,UAAU;;AAG7D,MAAa,iBACX,yBACa,CACb,IAAI,OAAO,IAAI,qBAAqB,IAAI,iBAAiB,CAAC,KAAK,IAAI,CAAC,IAAI,CACzE"}
@@ -1 +1,4 @@
1
- import{intlayerPolyfill as e}from"./intlayerPolyfill.mjs";import{IntlayerProvider as t}from"./intlayerProvider.mjs";export{t as IntlayerProvider,e as intlayerPolyfill};
1
+ import { intlayerPolyfill } from "./intlayerPolyfill.mjs";
2
+ import { IntlayerProvider } from "./intlayerProvider.mjs";
3
+
4
+ export { IntlayerProvider, intlayerPolyfill };
@@ -1,2 +1,21 @@
1
- const e=()=>{typeof global.structuredClone!=`function`&&(global.structuredClone=e=>JSON.parse(JSON.stringify(e))),typeof window<`u`&&(typeof window.addEventListener!=`function`&&(window.addEventListener=()=>null),typeof window.removeEventListener!=`function`&&(window.removeEventListener=()=>null),typeof window.postMessage!=`function`&&(window.postMessage=()=>null))};export{e as intlayerPolyfill};
1
+ //#region src/intlayerPolyfill.ts
2
+ /**
3
+ * Applies necessary polyfills for React Native to support Intlayer.
4
+ *
5
+ * This includes polyfilling `structuredClone` if it is missing,
6
+ * and providing no-op implementations for standard DOM `window` methods
7
+ * (`addEventListener`, `removeEventListener`, `postMessage`)
8
+ * to ensure compatibility with libraries that expect a browser-like environment.
9
+ */
10
+ const intlayerPolyfill = () => {
11
+ if (typeof global.structuredClone !== "function") global.structuredClone = (obj) => JSON.parse(JSON.stringify(obj));
12
+ if (typeof window !== "undefined") {
13
+ if (typeof window.addEventListener !== "function") window.addEventListener = () => null;
14
+ if (typeof window.removeEventListener !== "function") window.removeEventListener = () => null;
15
+ if (typeof window.postMessage !== "function") window.postMessage = () => null;
16
+ }
17
+ };
18
+
19
+ //#endregion
20
+ export { intlayerPolyfill };
2
21
  //# sourceMappingURL=intlayerPolyfill.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"intlayerPolyfill.mjs","names":[],"sources":["../../src/intlayerPolyfill.ts"],"sourcesContent":["/**\n * Applies necessary polyfills for React Native to support Intlayer.\n *\n * This includes polyfilling `structuredClone` if it is missing,\n * and providing no-op implementations for standard DOM `window` methods\n * (`addEventListener`, `removeEventListener`, `postMessage`)\n * to ensure compatibility with libraries that expect a browser-like environment.\n */\nexport const intlayerPolyfill = () => {\n if (typeof global.structuredClone !== 'function') {\n global.structuredClone = (obj) => JSON.parse(JSON.stringify(obj));\n }\n\n if (typeof window !== 'undefined') {\n if (typeof window.addEventListener !== 'function') {\n window.addEventListener = () => null;\n }\n if (typeof window.removeEventListener !== 'function') {\n window.removeEventListener = () => null;\n }\n if (typeof window.postMessage !== 'function') {\n window.postMessage = () => null;\n }\n }\n};\n"],"mappings":"AAQA,MAAa,MAAyB,CAChC,OAAO,OAAO,iBAAoB,aACpC,OAAO,gBAAmB,GAAQ,KAAK,MAAM,KAAK,UAAU,EAAI,CAAC,EAG/D,OAAO,OAAW,MAChB,OAAO,OAAO,kBAAqB,aACrC,OAAO,qBAAyB,MAE9B,OAAO,OAAO,qBAAwB,aACxC,OAAO,wBAA4B,MAEjC,OAAO,OAAO,aAAgB,aAChC,OAAO,gBAAoB"}
1
+ {"version":3,"file":"intlayerPolyfill.mjs","names":[],"sources":["../../src/intlayerPolyfill.ts"],"sourcesContent":["/**\n * Applies necessary polyfills for React Native to support Intlayer.\n *\n * This includes polyfilling `structuredClone` if it is missing,\n * and providing no-op implementations for standard DOM `window` methods\n * (`addEventListener`, `removeEventListener`, `postMessage`)\n * to ensure compatibility with libraries that expect a browser-like environment.\n */\nexport const intlayerPolyfill = () => {\n if (typeof global.structuredClone !== 'function') {\n global.structuredClone = (obj) => JSON.parse(JSON.stringify(obj));\n }\n\n if (typeof window !== 'undefined') {\n if (typeof window.addEventListener !== 'function') {\n window.addEventListener = () => null;\n }\n if (typeof window.removeEventListener !== 'function') {\n window.removeEventListener = () => null;\n }\n if (typeof window.postMessage !== 'function') {\n window.postMessage = () => null;\n }\n }\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,yBAAyB;AACpC,KAAI,OAAO,OAAO,oBAAoB,WACpC,QAAO,mBAAmB,QAAQ,KAAK,MAAM,KAAK,UAAU,IAAI,CAAC;AAGnE,KAAI,OAAO,WAAW,aAAa;AACjC,MAAI,OAAO,OAAO,qBAAqB,WACrC,QAAO,yBAAyB;AAElC,MAAI,OAAO,OAAO,wBAAwB,WACxC,QAAO,4BAA4B;AAErC,MAAI,OAAO,OAAO,gBAAgB,WAChC,QAAO,oBAAoB"}
@@ -1,2 +1,33 @@
1
- import{intlayerPolyfill as e}from"./intlayerPolyfill.mjs";import{IntlayerProviderContent as t}from"react-intlayer";import{jsx as n}from"react/jsx-runtime";e();const r=({children:e,...r})=>n(t,{...r,children:e});export{r as IntlayerProvider};
1
+ import { intlayerPolyfill } from "./intlayerPolyfill.mjs";
2
+ import { IntlayerProviderContent } from "react-intlayer";
3
+ import { jsx } from "react/jsx-runtime";
4
+
5
+ //#region src/intlayerProvider.tsx
6
+ intlayerPolyfill();
7
+ /**
8
+ * Provider component that wraps your application and provides the Intlayer context.
9
+ *
10
+ * This provider also automatically applies necessary polyfills for React Native.
11
+ *
12
+ * @param props - The provider props, excluding editor-specific and cookie-specific options which are not applicable in React Native.
13
+ * @returns The provider component.
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * import { IntlayerProvider } from 'react-native-intlayer';
18
+ *
19
+ * const App = () => (
20
+ * <IntlayerProvider>
21
+ * <MyComponent />
22
+ * </IntlayerProvider>
23
+ * );
24
+ * ```
25
+ */
26
+ const IntlayerProvider = ({ children, ...props }) => /* @__PURE__ */ jsx(IntlayerProviderContent, {
27
+ ...props,
28
+ children
29
+ });
30
+
31
+ //#endregion
32
+ export { IntlayerProvider };
2
33
  //# sourceMappingURL=intlayerProvider.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"intlayerProvider.mjs","names":[],"sources":["../../src/intlayerProvider.tsx"],"sourcesContent":["import {\n IntlayerProviderContent,\n type IntlayerProviderProps as IntlayerProviderPropsBase,\n} from 'react-intlayer';\nimport { intlayerPolyfill } from './intlayerPolyfill';\n\nintlayerPolyfill();\n\ntype IntlayerProviderProps = Omit<\n IntlayerProviderPropsBase,\n 'disableEditor' | 'isCookieEnabled'\n>;\n\n/**\n * Provider component that wraps your application and provides the Intlayer context.\n *\n * This provider also automatically applies necessary polyfills for React Native.\n *\n * @param props - The provider props, excluding editor-specific and cookie-specific options which are not applicable in React Native.\n * @returns The provider component.\n *\n * @example\n * ```tsx\n * import { IntlayerProvider } from 'react-native-intlayer';\n *\n * const App = () => (\n * <IntlayerProvider>\n * <MyComponent />\n * </IntlayerProvider>\n * );\n * ```\n */\nexport const IntlayerProvider = ({\n children,\n ...props\n}: IntlayerProviderProps) => (\n <IntlayerProviderContent {...props}>{children}</IntlayerProviderContent>\n);\n"],"mappings":"2JAMA,GAAkB,CA0BlB,MAAa,GAAoB,CAC/B,WACA,GAAG,KAEH,EAAC,EAAD,CAAyB,GAAI,EAAQ,WAAmC,CAAA"}
1
+ {"version":3,"file":"intlayerProvider.mjs","names":[],"sources":["../../src/intlayerProvider.tsx"],"sourcesContent":["import {\n IntlayerProviderContent,\n type IntlayerProviderProps as IntlayerProviderPropsBase,\n} from 'react-intlayer';\nimport { intlayerPolyfill } from './intlayerPolyfill';\n\nintlayerPolyfill();\n\ntype IntlayerProviderProps = Omit<\n IntlayerProviderPropsBase,\n 'disableEditor' | 'isCookieEnabled'\n>;\n\n/**\n * Provider component that wraps your application and provides the Intlayer context.\n *\n * This provider also automatically applies necessary polyfills for React Native.\n *\n * @param props - The provider props, excluding editor-specific and cookie-specific options which are not applicable in React Native.\n * @returns The provider component.\n *\n * @example\n * ```tsx\n * import { IntlayerProvider } from 'react-native-intlayer';\n *\n * const App = () => (\n * <IntlayerProvider>\n * <MyComponent />\n * </IntlayerProvider>\n * );\n * ```\n */\nexport const IntlayerProvider = ({\n children,\n ...props\n}: IntlayerProviderProps) => (\n <IntlayerProviderContent {...props}>{children}</IntlayerProviderContent>\n);\n"],"mappings":";;;;;AAMA,kBAAkB;;;;;;;;;;;;;;;;;;;;AA0BlB,MAAa,oBAAoB,EAC/B,UACA,GAAG,YAEH,oBAAC,yBAAD;CAAyB,GAAI;CAAQ;CAAmC"}
@@ -1 +1,3 @@
1
- import{n as e,t}from"./configMetroIntlayer-qNNTJySv.mjs";export{t as configMetroIntlayer,e as configMetroIntlayerSync};
1
+ import { configMetroIntlayer, configMetroIntlayerSync } from "./configMetroIntlayer.mjs";
2
+
3
+ export { configMetroIntlayer, configMetroIntlayerSync };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-intlayer",
3
- "version": "8.4.4",
3
+ "version": "8.4.6",
4
4
  "private": false,
5
5
  "description": "A React Native plugin for seamless internationalization (i18n), providing locale detection, redirection, and environment-based configuration",
6
6
  "keywords": [
@@ -86,11 +86,11 @@
86
86
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
87
87
  },
88
88
  "dependencies": {
89
- "@intlayer/chokidar": "8.4.4",
90
- "@intlayer/config": "8.4.4",
91
- "@intlayer/core": "8.4.4",
92
- "@intlayer/types": "8.4.4",
93
- "react-intlayer": "8.4.4"
89
+ "@intlayer/chokidar": "8.4.6",
90
+ "@intlayer/config": "8.4.6",
91
+ "@intlayer/core": "8.4.6",
92
+ "@intlayer/types": "8.4.6",
93
+ "react-intlayer": "8.4.6"
94
94
  },
95
95
  "devDependencies": {
96
96
  "@types/node": "25.5.0",
@@ -110,7 +110,7 @@
110
110
  "expo": ">=52",
111
111
  "metro-resolver": ">=0.80",
112
112
  "react": ">=18.0.0",
113
- "react-intlayer": "8.4.4"
113
+ "react-intlayer": "8.4.6"
114
114
  },
115
115
  "engines": {
116
116
  "node": ">=14.18"
@@ -1,2 +0,0 @@
1
- import{exclusionList as e}from"./exclusionList.mjs";import{resolve as t}from"node:path";import{prepareIntlayer as n}from"@intlayer/chokidar/build";import{getConfiguration as r}from"@intlayer/config/node";import{getAlias as i}from"@intlayer/config/utils";import{resolve as a}from"metro-resolver";var o=(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error('Calling `require` for "'+e+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")});const s=n=>{let s=i({configuration:r(),formatter:t}),c=n?.resolver?.blockList,l=c instanceof RegExp?[c]:c??[],u=n?.resolver?.resolveRequest;return{...n,resolver:{...n?.resolver,resolveRequest:(e,t,...n)=>Object.keys(s).includes(t)?{filePath:s[t],type:`sourceFile`}:t===`@intlayer/config/client`?{filePath:o.resolve(`@intlayer/config/client`),type:`sourceFile`}:t===`@intlayer/core/file`?{filePath:o.resolve(`@intlayer/core/file/browser`),type:`sourceFile`}:u?u(e,t,...n):a(e,t,...n),blockList:e([...l,/.*\.content\.(?:ts|tsx|js|jsx|cjs|cjx|mjs|mjx|json)$/])}}},c=async e=>(await n(r()),s(e));export{s as n,c as t};
2
- //# sourceMappingURL=configMetroIntlayer-qNNTJySv.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"configMetroIntlayer-qNNTJySv.mjs","names":["pathResolve","resolve"],"sources":["../../src/configMetroIntlayer.ts"],"sourcesContent":["import { resolve as pathResolve } from 'node:path';\nimport { prepareIntlayer } from '@intlayer/chokidar/build';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { getAlias } from '@intlayer/config/utils';\nimport type { getDefaultConfig } from 'expo/metro-config';\nimport { resolve } from 'metro-resolver';\nimport { exclusionList } from './exclusionList';\n\ntype MetroConfig = ReturnType<typeof getDefaultConfig>;\n\n/**\n * // metro.config.js\n * const { getDefaultConfig } = require(\"expo/metro-config\");\n * const { configMetroIntlayerSync } = require(\"react-native-intlayer/metro\");\n *\n *\n * const defaultConfig = getDefaultConfig(__dirname);\n *\n * return configMetroIntlayerSync(defaultConfig);\n * ```\n *\n * > Note: `configMetroIntlayerSync` does not build intlayer dictionaries on server start. Use `configMetroIntlayer` for that.\n */\nexport const configMetroIntlayerSync = (\n baseConfig?: MetroConfig\n): MetroConfig => {\n const configuration = getConfiguration();\n\n const alias = getAlias({\n configuration,\n formatter: pathResolve, // get absolute path\n });\n\n const existingBlockList = baseConfig?.resolver?.blockList;\n const existingPatterns: RegExp[] =\n existingBlockList instanceof RegExp\n ? [existingBlockList]\n : (existingBlockList ?? []);\n\n const existingResolveRequest = baseConfig?.resolver?.resolveRequest;\n\n const config = {\n ...baseConfig,\n\n resolver: {\n ...baseConfig?.resolver,\n resolveRequest: (context, moduleName, ...args) => {\n if (Object.keys(alias).includes(moduleName)) {\n return {\n filePath: alias[moduleName as keyof typeof alias],\n type: 'sourceFile',\n };\n }\n\n // Because metro does not resolve submodules, we need to resolve the path manually\n if (moduleName === '@intlayer/config/client') {\n return {\n filePath: require.resolve('@intlayer/config/client'),\n type: 'sourceFile',\n };\n }\n\n // Because metro does not resolve submodules, we need to resolve the path manually\n if (moduleName === '@intlayer/core/file') {\n // Force React Native to use the correct transpiled version\n return {\n filePath: require.resolve('@intlayer/core/file/browser'),\n type: 'sourceFile',\n };\n }\n\n // Delegate to the user-provided resolver if present\n if (existingResolveRequest) {\n return existingResolveRequest(context, moduleName, ...args);\n }\n\n // Fallback to metro-resolver\n return resolve(context as any, moduleName, ...args);\n },\n blockList: exclusionList([\n ...existingPatterns,\n // the following instruction should be replaced by a pattern derived from configuration.content.fileExtensions\n // but generating the pattern from fileExtensions does not exclude the files properly for now\n /.*\\.content\\.(?:ts|tsx|js|jsx|cjs|cjx|mjs|mjx|json)$/,\n ]),\n },\n } as MetroConfig;\n\n return config;\n};\n\n/**\n * // metro.config.js\n * const { getDefaultConfig } = require(\"expo/metro-config\");\n * const { configMetroIntlayer } = require(\"react-native-intlayer/metro\");\n *\n * module.exports = (async () => {\n * const defaultConfig = getDefaultConfig(__dirname);\n *\n * return await configMetroIntlayer(defaultConfig);\n * })();\n * ```\n *\n * > Note: `configMetroIntlayer` builds intlayer dictionaries on server start. Use `configMetroIntlayerSync` instead if you want to skip that.\n */\nexport const configMetroIntlayer = async (\n baseConfig?: MetroConfig\n): Promise<MetroConfig> => {\n const configuration = getConfiguration();\n\n await prepareIntlayer(configuration);\n\n return configMetroIntlayerSync(baseConfig);\n};\n"],"mappings":"0qBAuBA,MAAa,EACX,GACgB,CAGhB,IAAM,EAAQ,EAAS,CACrB,cAHoB,GAAkB,CAItC,UAAWA,EACZ,CAAC,CAEI,EAAoB,GAAY,UAAU,UAC1C,EACJ,aAA6B,OACzB,CAAC,EAAkB,CAClB,GAAqB,EAAE,CAExB,EAAyB,GAAY,UAAU,eAiDrD,MA/Ce,CACb,GAAG,EAEH,SAAU,CACR,GAAG,GAAY,SACf,gBAAiB,EAAS,EAAY,GAAG,IACnC,OAAO,KAAK,EAAM,CAAC,SAAS,EAAW,CAClC,CACL,SAAU,EAAM,GAChB,KAAM,aACP,CAIC,IAAe,0BACV,CACL,SAAA,EAAkB,QAAQ,0BAA0B,CACpD,KAAM,aACP,CAIC,IAAe,sBAEV,CACL,SAAA,EAAkB,QAAQ,8BAA8B,CACxD,KAAM,aACP,CAIC,EACK,EAAuB,EAAS,EAAY,GAAG,EAAK,CAItDC,EAAQ,EAAgB,EAAY,GAAG,EAAK,CAErD,UAAW,EAAc,CACvB,GAAG,EAGH,uDACD,CAAC,CACH,CACF,EAmBU,EAAsB,KACjC,KAIA,MAAM,EAFgB,GAAkB,CAEJ,CAE7B,EAAwB,EAAW"}