@multiplatform.one/components 8.6.0 → 9.0.0
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.
- package/README.md +37 -12
- package/dist/cjs/shared/i18n.cjs +1 -1
- package/dist/cjs/shared/i18n.native.js +1 -1
- package/dist/cjs/shared/i18n.native.js.map +1 -1
- package/dist/esm/shared/i18n.mjs +1 -1
- package/dist/esm/shared/i18n.mjs.map +1 -1
- package/dist/esm/shared/i18n.native.js +1 -1
- package/dist/esm/shared/i18n.native.js.map +1 -1
- package/dist/jsx/shared/i18n.mjs +1 -1
- package/dist/jsx/shared/i18n.mjs.map +1 -1
- package/dist/jsx/shared/i18n.native.js +1 -1
- package/dist/jsx/shared/i18n.native.js.map +1 -1
- package/package.json +8 -10
- package/src/shared/i18n.ts +7 -11
- package/src/shared/i18nPeers.spec.ts +49 -0
- package/types/shared/i18n.d.ts +6 -9
- package/types/shared/i18n.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -6,26 +6,51 @@ through the knobs system.
|
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @multiplatform.one/components @multiplatform.one/forms @multiplatform.one/theme
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Peers every app has: `react`, `moti`, `i18next` and `react-i18next`, plus `react-dom` on web.
|
|
14
|
+
pnpm and npm install the ones you leave out.
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
A phone app lists its native modules itself, so its Expo SDK picks their versions. Add them
|
|
17
|
+
with `npx expo install`:
|
|
13
18
|
|
|
14
19
|
```bash
|
|
15
|
-
|
|
20
|
+
npx expo install react-native-reanimated react-native-svg
|
|
16
21
|
```
|
|
17
22
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
Those two are required on native. No `@multiplatform.one` package depends on a native
|
|
24
|
+
module, so the versions in your app are the only copies. The other native modules are
|
|
25
|
+
optional peers. Install one to turn its feature on:
|
|
21
26
|
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
| Peer | Without it |
|
|
28
|
+
| ---------------------- | ---------------------------------------------------------------- |
|
|
29
|
+
| `expo-camera` | The Barcode field reports the camera unavailable |
|
|
30
|
+
| `expo-linear-gradient` | The ColorPicker draws its gradients with `react-native-svg` |
|
|
31
|
+
| `react-native-mmkv` 4 | Stored state persists through AsyncStorage, or in memory without |
|
|
32
|
+
|
|
33
|
+
### In an Expo Router app
|
|
34
|
+
|
|
35
|
+
An app that does not run on [One](https://onestack.dev) wires two things. Metro swaps
|
|
36
|
+
phosphor's DOM icon base for a `react-native-svg` one:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
// metro.config.js
|
|
40
|
+
const { getDefaultConfig } = require("expo/metro-config");
|
|
41
|
+
const { withMultiplatformOne } = require("@multiplatform.one/forms/metro");
|
|
42
|
+
|
|
43
|
+
module.exports = withMultiplatformOne(getDefaultConfig(__dirname), { router: "expo-router" });
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The root layout binds MPO's links and router hooks to Expo Router, before the first render:
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
// app/_layout.tsx
|
|
50
|
+
import "@multiplatform.one/router/expo-router";
|
|
24
51
|
```
|
|
25
52
|
|
|
26
|
-
|
|
27
|
-
and `one` builds with its own bundler (vxrn). A plain Metro app fails on its web
|
|
28
|
-
`.mjs` files and `import.meta` (FZ-1854).
|
|
53
|
+
`router: "expo-router"` is for the web bundle. Leave it out when the app ships phones only.
|
|
29
54
|
|
|
30
55
|
## What it owns
|
|
31
56
|
|
package/dist/cjs/shared/i18n.cjs
CHANGED
|
@@ -40,7 +40,7 @@ var ReactI18next = __toESM(require("react-i18next"));
|
|
|
40
40
|
const useTranslation = (...args) => {
|
|
41
41
|
const impl = ReactI18next.useTranslation;
|
|
42
42
|
if (typeof impl !== "function") {
|
|
43
|
-
throw new Error("[@multiplatform.one/components] react-i18next is not installed, but a component that translates its built-in copy was rendered. Add react-i18next and i18next to your app's dependencies
|
|
43
|
+
throw new Error("[@multiplatform.one/components] react-i18next is not installed, but a component that translates its built-in copy was rendered. Add react-i18next and i18next to your app's dependencies.");
|
|
44
44
|
}
|
|
45
45
|
return impl(...args);
|
|
46
46
|
};
|
|
@@ -45,7 +45,7 @@ var useTranslation = function useTranslation2() {
|
|
|
45
45
|
}
|
|
46
46
|
var impl = ReactI18next.useTranslation;
|
|
47
47
|
if (typeof impl !== "function") {
|
|
48
|
-
throw new Error("[@multiplatform.one/components] react-i18next is not installed, but a component that translates its built-in copy was rendered. Add react-i18next and i18next to your app's dependencies
|
|
48
|
+
throw new Error("[@multiplatform.one/components] react-i18next is not installed, but a component that translates its built-in copy was rendered. Add react-i18next and i18next to your app's dependencies.");
|
|
49
49
|
}
|
|
50
50
|
return impl(...args);
|
|
51
51
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","i18n_exports","useTranslation","module","exports","ReactI18next","require","useTranslation2","_len","arguments","length","args","Array","_key","impl","Error"],"sources":["i18n.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar i18n_exports = {};\n__export(i18n_exports, {\n useTranslation: () => useTranslation\n});\nmodule.exports = __toCommonJS(i18n_exports);\nvar ReactI18next = __toESM(require(\"react-i18next\"));\nvar useTranslation = function useTranslation2() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n var impl = ReactI18next.useTranslation;\n if (typeof impl !== \"function\") {\n throw new Error(\"[@multiplatform.one/components] react-i18next is not installed, but a component that translates its built-in copy was rendered. Add react-i18next and i18next to your app's dependencies
|
|
1
|
+
{"version":3,"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toESM","mod","isNodeMode","__esModule","value","__toCommonJS","i18n_exports","useTranslation","module","exports","ReactI18next","require","useTranslation2","_len","arguments","length","args","Array","_key","impl","Error"],"sources":["i18n.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar i18n_exports = {};\n__export(i18n_exports, {\n useTranslation: () => useTranslation\n});\nmodule.exports = __toCommonJS(i18n_exports);\nvar ReactI18next = __toESM(require(\"react-i18next\"));\nvar useTranslation = function useTranslation2() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n var impl = ReactI18next.useTranslation;\n if (typeof impl !== \"function\") {\n throw new Error(\"[@multiplatform.one/components] react-i18next is not installed, but a component that translates its built-in copy was rendered. Add react-i18next and i18next to your app's dependencies.\");\n }\n return impl(...args);\n};\n//# sourceMappingURL=i18n.js.map\n"],"mappings":"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","ignoreList":[]}
|
package/dist/esm/shared/i18n.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import * as ReactI18next from "react-i18next";
|
|
|
2
2
|
const useTranslation = (...args) => {
|
|
3
3
|
const impl = ReactI18next.useTranslation;
|
|
4
4
|
if (typeof impl !== "function") {
|
|
5
|
-
throw new Error("[@multiplatform.one/components] react-i18next is not installed, but a component that translates its built-in copy was rendered. Add react-i18next and i18next to your app's dependencies
|
|
5
|
+
throw new Error("[@multiplatform.one/components] react-i18next is not installed, but a component that translates its built-in copy was rendered. Add react-i18next and i18next to your app's dependencies.");
|
|
6
6
|
}
|
|
7
7
|
return impl(...args);
|
|
8
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ReactI18next","useTranslation","args","impl","Error"],"sources":["../../../src/shared/i18n.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAYA,YAAA,MAAkB;
|
|
1
|
+
{"version":3,"names":["ReactI18next","useTranslation","args","impl","Error"],"sources":["../../../src/shared/i18n.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAYA,YAAA,MAAkB;AAUvB,MAAMC,cAAA,GAAkBA,CAAA,GAAIC,IAAA,KAAoB;EACrD,MAAMC,IAAA,GAAQH,YAAA,CACXC,cAAA;EACH,IAAI,OAAOE,IAAA,KAAS,YAAY;IAC9B,MAAM,IAAIC,KAAA,CACR,2LAGF;EACF;EACA,OAAOD,IAAA,CAAK,GAAGD,IAAI;AACrB","ignoreList":[]}
|
|
@@ -5,7 +5,7 @@ var useTranslation = function useTranslation2() {
|
|
|
5
5
|
}
|
|
6
6
|
var impl = ReactI18next.useTranslation;
|
|
7
7
|
if (typeof impl !== "function") {
|
|
8
|
-
throw new Error("[@multiplatform.one/components] react-i18next is not installed, but a component that translates its built-in copy was rendered. Add react-i18next and i18next to your app's dependencies
|
|
8
|
+
throw new Error("[@multiplatform.one/components] react-i18next is not installed, but a component that translates its built-in copy was rendered. Add react-i18next and i18next to your app's dependencies.");
|
|
9
9
|
}
|
|
10
10
|
return impl(...args);
|
|
11
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ReactI18next","useTranslation","useTranslation2","_len","arguments","length","args","Array","_key","impl","Error"],"sources":["i18n.native.js"],"sourcesContent":["import * as ReactI18next from \"react-i18next\";\nvar useTranslation = function useTranslation2() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n var impl = ReactI18next.useTranslation;\n if (typeof impl !== \"function\") {\n throw new Error(\"[@multiplatform.one/components] react-i18next is not installed, but a component that translates its built-in copy was rendered. Add react-i18next and i18next to your app's dependencies
|
|
1
|
+
{"version":3,"names":["ReactI18next","useTranslation","useTranslation2","_len","arguments","length","args","Array","_key","impl","Error"],"sources":["i18n.native.js"],"sourcesContent":["import * as ReactI18next from \"react-i18next\";\nvar useTranslation = function useTranslation2() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n var impl = ReactI18next.useTranslation;\n if (typeof impl !== \"function\") {\n throw new Error(\"[@multiplatform.one/components] react-i18next is not installed, but a component that translates its built-in copy was rendered. Add react-i18next and i18next to your app's dependencies.\");\n }\n return impl(...args);\n};\nexport {\n useTranslation\n};\n//# sourceMappingURL=i18n.js.map\n"],"mappings":"AAAA,OAAO,KAAKA,YAAY,MAAM,eAAe;AAC7C,IAAIC,cAAc,GAAG,SAASC,eAAeA,CAAA,EAAG;EAC9C,KAAK,IAAIC,IAAI,GAAGC,SAAS,CAACC,MAAM,EAAEC,IAAI,GAAG,IAAIC,KAAK,CAACJ,IAAI,CAAC,EAAEK,IAAI,GAAG,CAAC,EAAEA,IAAI,GAAGL,IAAI,EAAEK,IAAI,EAAE,EAAE;IACvFF,IAAI,CAACE,IAAI,CAAC,GAAGJ,SAAS,CAACI,IAAI,CAAC;EAC9B;EACA,IAAIC,IAAI,GAAGT,YAAY,CAACC,cAAc;EACtC,IAAI,OAAOQ,IAAI,KAAK,UAAU,EAAE;IAC9B,MAAM,IAAIC,KAAK,CAAC,2LAA2L,CAAC;EAC9M;EACA,OAAOD,IAAI,CAAC,GAAGH,IAAI,CAAC;AACtB,CAAC;AACD,SACEL,cAAc","ignoreList":[]}
|
package/dist/jsx/shared/i18n.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import * as ReactI18next from "react-i18next";
|
|
|
2
2
|
const useTranslation = (...args) => {
|
|
3
3
|
const impl = ReactI18next.useTranslation;
|
|
4
4
|
if (typeof impl !== "function") {
|
|
5
|
-
throw new Error("[@multiplatform.one/components] react-i18next is not installed, but a component that translates its built-in copy was rendered. Add react-i18next and i18next to your app's dependencies
|
|
5
|
+
throw new Error("[@multiplatform.one/components] react-i18next is not installed, but a component that translates its built-in copy was rendered. Add react-i18next and i18next to your app's dependencies.");
|
|
6
6
|
}
|
|
7
7
|
return impl(...args);
|
|
8
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ReactI18next","useTranslation","args","impl","Error"],"sources":["../../../src/shared/i18n.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAYA,YAAA,MAAkB;
|
|
1
|
+
{"version":3,"names":["ReactI18next","useTranslation","args","impl","Error"],"sources":["../../../src/shared/i18n.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAYA,YAAA,MAAkB;AAUvB,MAAMC,cAAA,GAAkBA,CAAA,GAAIC,IAAA,KAAoB;EACrD,MAAMC,IAAA,GAAQH,YAAA,CACXC,cAAA;EACH,IAAI,OAAOE,IAAA,KAAS,YAAY;IAC9B,MAAM,IAAIC,KAAA,CACR,2LAGF;EACF;EACA,OAAOD,IAAA,CAAK,GAAGD,IAAI;AACrB","ignoreList":[]}
|
|
@@ -45,7 +45,7 @@ var useTranslation = function useTranslation2() {
|
|
|
45
45
|
}
|
|
46
46
|
var impl = ReactI18next.useTranslation;
|
|
47
47
|
if (typeof impl !== "function") {
|
|
48
|
-
throw new Error("[@multiplatform.one/components] react-i18next is not installed, but a component that translates its built-in copy was rendered. Add react-i18next and i18next to your app's dependencies
|
|
48
|
+
throw new Error("[@multiplatform.one/components] react-i18next is not installed, but a component that translates its built-in copy was rendered. Add react-i18next and i18next to your app's dependencies.");
|
|
49
49
|
}
|
|
50
50
|
return impl(...args);
|
|
51
51
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable"],"sources":["../../../src/shared/i18n.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAY;;
|
|
1
|
+
{"version":3,"names":["__create","Object","create","__defProp","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getProtoOf","getPrototypeOf","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable"],"sources":["../../../src/shared/i18n.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAY;;AAUL,IAAAA,QAAM,GAAAC,MAAA,CAAAC,MAAsB;AACjC,IAAAC,SAAM,GAAQF,MAAA,CAAAG,cACX;AACH,IAAAC,gBAAW,GAASJ,MAAA,CAAAK,wBAAY;AAC9B,IAAAC,iBAAU,GAAAN,MAAA,CAAAO,mBAAA;AAAA,IAAAC,YACR,GAAAR,MAAA,CAAAS,cAAA;AAAA,IAGFC,YAAA,GAAAV,MAAA,CAAAW,SAAA,CAAAC,cAAA;AAAA,IACFC,QAAA,GAAAA,CAAAC,MAAA,EAAAC,GAAA;EACA,SAAOC,IAAK,IAAGD,GAAI,EACrBb,SAAA,CAAAY,MAAA,EAAAE,IAAA;IAAAC,GAAA,EAAAF,GAAA,CAAAC,IAAA;IAAAE,UAAA;EAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplatform.one/components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "multiplatform.one ui components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@floating-ui/react": "^0.27.20",
|
|
73
|
-
"@multiplatform.one/forms": "^
|
|
74
|
-
"@multiplatform.one/platform": "^
|
|
75
|
-
"@multiplatform.one/theme": "^
|
|
73
|
+
"@multiplatform.one/forms": "^9.0.0",
|
|
74
|
+
"@multiplatform.one/platform": "^9.0.0",
|
|
75
|
+
"@multiplatform.one/theme": "^9.0.0",
|
|
76
76
|
"@phosphor-icons/react": "^2.1.10",
|
|
77
77
|
"@shopify/flash-list": "^2.3.1",
|
|
78
78
|
"@tamagui/colors": "2.7.6",
|
|
@@ -99,9 +99,9 @@
|
|
|
99
99
|
"tamagui": "2.7.6"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
|
-
"@multiplatform.one/config": "
|
|
103
|
-
"@multiplatform.one/storybook": "
|
|
104
|
-
"@multiplatform.one/test-utils": "
|
|
102
|
+
"@multiplatform.one/config": "9.0.0",
|
|
103
|
+
"@multiplatform.one/storybook": "9.0.0",
|
|
104
|
+
"@multiplatform.one/test-utils": "9.0.0",
|
|
105
105
|
"@tamagui/build": "2.7.6",
|
|
106
106
|
"@testing-library/jest-dom": "^7.0.1",
|
|
107
107
|
"@testing-library/react": "^16.3.3",
|
|
@@ -132,6 +132,7 @@
|
|
|
132
132
|
"expo-video": "*",
|
|
133
133
|
"gray-matter": "^4.0.3",
|
|
134
134
|
"hast-util-to-html": "8.0.4",
|
|
135
|
+
"i18next": ">=25.0.0",
|
|
135
136
|
"moti": "^0.25.3 || ^0.30.0",
|
|
136
137
|
"parse-numeric-range": "^1.3.0",
|
|
137
138
|
"react": "^19.1.0",
|
|
@@ -184,9 +185,6 @@
|
|
|
184
185
|
"parse-numeric-range": {
|
|
185
186
|
"optional": true
|
|
186
187
|
},
|
|
187
|
-
"react-i18next": {
|
|
188
|
-
"optional": true
|
|
189
|
-
},
|
|
190
188
|
"react-native": {
|
|
191
189
|
"optional": true
|
|
192
190
|
},
|
package/src/shared/i18n.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import * as ReactI18next from "react-i18next";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* react-i18next is
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* Every catalog usage routes through this namespace access instead, so
|
|
11
|
-
* omission stays warning-free for tree-shakers and fails loudly — naming the
|
|
12
|
-
* package and the fix — the moment an i18n-using component actually renders.
|
|
4
|
+
* react-i18next is a required peer. When an app leaves it out anyway, the
|
|
5
|
+
* bundler can substitute an empty stub for the package, and direct named
|
|
6
|
+
* imports would then surface as cryptic MISSING_EXPORT failures far from the
|
|
7
|
+
* cause. Route every usage through this namespace access instead, so the
|
|
8
|
+
* omission fails loudly, naming the package and the fix, the moment an
|
|
9
|
+
* i18n-using component actually renders.
|
|
13
10
|
*/
|
|
14
11
|
export const useTranslation = ((...args: unknown[]) => {
|
|
15
12
|
const impl = (ReactI18next as { useTranslation?: (...args: unknown[]) => unknown })
|
|
@@ -18,8 +15,7 @@ export const useTranslation = ((...args: unknown[]) => {
|
|
|
18
15
|
throw new Error(
|
|
19
16
|
"[@multiplatform.one/components] react-i18next is not installed, but a component that " +
|
|
20
17
|
"translates its built-in copy was rendered. Add react-i18next and i18next to your " +
|
|
21
|
-
"app's dependencies
|
|
22
|
-
"components can omit them).",
|
|
18
|
+
"app's dependencies.",
|
|
23
19
|
);
|
|
24
20
|
}
|
|
25
21
|
return impl(...args);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { renderHook } from "@testing-library/react";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
|
|
6
|
+
const manifest = JSON.parse(
|
|
7
|
+
readFileSync(join(import.meta.dirname, "..", "..", "package.json"), "utf8"),
|
|
8
|
+
) as {
|
|
9
|
+
dependencies?: Record<string, string>;
|
|
10
|
+
peerDependencies?: Record<string, string>;
|
|
11
|
+
peerDependenciesMeta?: Record<string, { optional?: boolean }>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// FZ-10637, FZ-1854. components translates its built-in copy through react-i18next on
|
|
15
|
+
// every render, so the i18n pair is a required peer. Listed as optional it
|
|
16
|
+
// left a host to find out from a failed bundle.
|
|
17
|
+
describe("the i18n peers components translates through", () => {
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
vi.doUnmock("react-i18next");
|
|
20
|
+
vi.resetModules();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("declares i18next and react-i18next as required peers, never as dependencies", () => {
|
|
24
|
+
for (const name of ["i18next", "react-i18next"]) {
|
|
25
|
+
expect(manifest.dependencies ?? {}).not.toHaveProperty(name);
|
|
26
|
+
expect(manifest.peerDependencies).toHaveProperty(name);
|
|
27
|
+
expect(manifest.peerDependenciesMeta?.[name]?.optional).not.toBe(true);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("accepts the i18next majors react-i18next 16 and 17 run on", () => {
|
|
32
|
+
expect(manifest.peerDependencies?.i18next).toBe(">=25.0.0");
|
|
33
|
+
expect(manifest.peerDependencies?.["react-i18next"]).toBe(">=14");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("translates built-in copy with the host's react-i18next", async () => {
|
|
37
|
+
const { useTranslation } = await import("./i18n");
|
|
38
|
+
const { result } = renderHook(() => useTranslation());
|
|
39
|
+
expect(result.current.t("Close")).toBe("Close");
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("names the packages to install when an app leaves them out", async () => {
|
|
43
|
+
vi.doMock("react-i18next", () => ({ useTranslation: undefined }));
|
|
44
|
+
const { useTranslation } = await import("./i18n");
|
|
45
|
+
expect(() => useTranslation()).toThrow(
|
|
46
|
+
/react-i18next is not installed.*Add react-i18next and i18next to your app's dependencies\./s,
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
});
|
package/types/shared/i18n.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import * as ReactI18next from "react-i18next";
|
|
2
2
|
/**
|
|
3
|
-
* react-i18next is
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* Every catalog usage routes through this namespace access instead, so
|
|
10
|
-
* omission stays warning-free for tree-shakers and fails loudly — naming the
|
|
11
|
-
* package and the fix — the moment an i18n-using component actually renders.
|
|
3
|
+
* react-i18next is a required peer. When an app leaves it out anyway, the
|
|
4
|
+
* bundler can substitute an empty stub for the package, and direct named
|
|
5
|
+
* imports would then surface as cryptic MISSING_EXPORT failures far from the
|
|
6
|
+
* cause. Route every usage through this namespace access instead, so the
|
|
7
|
+
* omission fails loudly, naming the package and the fix, the moment an
|
|
8
|
+
* i18n-using component actually renders.
|
|
12
9
|
*/
|
|
13
10
|
export declare const useTranslation: typeof ReactI18next.useTranslation;
|
|
14
11
|
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/shared/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,eAAe,CAAC;AAE9C
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/shared/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,eAAe,CAAC;AAE9C;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,EAWrB,OAAO,YAAY,CAAC,cAAc,CAAC"}
|