diff --git a/.changeset/cool-bags-whisper.md b/.changeset/cool-bags-whisper.md new file mode 100644 index 00000000..01a5405c --- /dev/null +++ b/.changeset/cool-bags-whisper.md @@ -0,0 +1,5 @@ +--- +'@withease/i18next': patch +--- + +Add forgotten allowance for usage with i18next 23 in peerDependencies diff --git a/.changeset/tame-cows-begin.md b/.changeset/tame-cows-begin.md new file mode 100644 index 00000000..e7715de5 --- /dev/null +++ b/.changeset/tame-cows-begin.md @@ -0,0 +1,6 @@ +--- +'@withease/i18next': minor +'@withease/web-api': minor +--- + +Allow to use with Effector 23 diff --git a/apps/website/docs/web-api/media_query.live.vue b/apps/website/docs/web-api/media_query.live.vue index 0a528570..c79bc203 100644 --- a/apps/website/docs/web-api/media_query.live.vue +++ b/apps/website/docs/web-api/media_query.live.vue @@ -1,7 +1,7 @@ diff --git a/apps/website/docs/web-api/network_status.live.vue b/apps/website/docs/web-api/network_status.live.vue index f3dfb07a..6289274e 100644 --- a/apps/website/docs/web-api/network_status.live.vue +++ b/apps/website/docs/web-api/network_status.live.vue @@ -1,15 +1,14 @@ diff --git a/apps/website/docs/web-api/page_visibility.live.vue b/apps/website/docs/web-api/page_visibility.live.vue index e622db01..d44d3ec6 100644 --- a/apps/website/docs/web-api/page_visibility.live.vue +++ b/apps/website/docs/web-api/page_visibility.live.vue @@ -1,7 +1,7 @@ diff --git a/apps/website/docs/web-api/preferred_languages.live.vue b/apps/website/docs/web-api/preferred_languages.live.vue index af91f7c3..4e94157a 100644 --- a/apps/website/docs/web-api/preferred_languages.live.vue +++ b/apps/website/docs/web-api/preferred_languages.live.vue @@ -1,14 +1,14 @@ diff --git a/apps/website/docs/web-api/screen_orientation.live.vue b/apps/website/docs/web-api/screen_orientation.live.vue index e5472ef1..88ee6a18 100644 --- a/apps/website/docs/web-api/screen_orientation.live.vue +++ b/apps/website/docs/web-api/screen_orientation.live.vue @@ -1,15 +1,14 @@ diff --git a/package.json b/package.json index 97f70db1..e23ce575 100644 --- a/package.json +++ b/package.json @@ -37,8 +37,8 @@ "@typescript-eslint/parser": "5.62.0", "@vitest/ui": "0.34.4", "bytes-iec": "^3.1.1", - "effector": "^22.8.6", - "effector-vue": "^22.2.0", + "effector": "23.0.0", + "effector-vue": "23.0.0", "eslint": "8.46.0", "glob": "^8.0.3", "i18next": "23.0.0", diff --git a/packages/i18next/package.json b/packages/i18next/package.json index 56b2846a..9977d3b3 100644 --- a/packages/i18next/package.json +++ b/packages/i18next/package.json @@ -3,7 +3,7 @@ "version": "23.0.0", "type": "commonjs", "peerDependencies": { - "effector": "^22.5.0", - "i18next": "^22.4.10" + "effector": "^22.5.0 || ^23.0.0", + "i18next": "^22.4.10 || ^23.0.0" } } diff --git a/packages/i18next/src/integration.ts b/packages/i18next/src/integration.ts index d709a6ba..83a62797 100644 --- a/packages/i18next/src/integration.ts +++ b/packages/i18next/src/integration.ts @@ -51,17 +51,21 @@ export function createI18nextIntegration({ // -- Parse options const $instance: Store = is.store(instance) ? instance - : createStore(instance as i18n | null); + : createStore(instance as i18n | null, { + serialize: 'ignore', + name: '$instance', + }); const destroy = teardown ?? createEvent(); // -- Internal API - const $derivedT = $instance.map((i18next): TFunction | null => + const $derivedT = combine($instance, (i18next): TFunction | null => i18next ? i18next.t.bind(i18next) : null ); const $stanaloneT = createStore(null, { serialize: 'ignore', + name: '$stanaloneT', }); // -- Public API @@ -110,7 +114,7 @@ export function createI18nextIntegration({ const finalKey = result.join(''); - return t(finalKey); + return t(finalKey) ?? finalKey; } ); } @@ -121,7 +125,7 @@ export function createI18nextIntegration({ ): Store { return combine( { t: $t, variables: combine(variables ?? {}) }, - ({ t, variables }) => t(key, variables) + ({ t, variables }) => t(key, variables) ?? key ); } @@ -155,10 +159,12 @@ export function createI18nextIntegration({ const $contextChangeListener = createStore<(() => void) | null>(null, { serialize: 'ignore', + name: '$contextChangeListener', }); const $missingKeyListener = createStore<(() => void) | null>(null, { serialize: 'ignore', + name: '$missingKeyListener', }); const setupListenersFx = createEffect((i18next: i18n) => { diff --git a/packages/i18next/src/reporting.test.ts b/packages/i18next/src/reporting.test.ts index dbe9dd1f..d0d096bf 100644 --- a/packages/i18next/src/reporting.test.ts +++ b/packages/i18next/src/reporting.test.ts @@ -23,7 +23,7 @@ describe('integration.reporting.missingKey', () => { reporting.missingKey.watch(listener); - const $result = $t.map((t) => t('common:key')); + const $result = $t.map((t) => t('common:key') ?? null); const scope = fork(); @@ -51,7 +51,7 @@ describe('integration.reporting.missingKey', () => { reporting.missingKey.watch(listener); - const $result = $t.map((t) => t('common:other_key')); + const $result = $t.map((t) => t('common:other_key') ?? null); const scope = fork(); diff --git a/packages/i18next/src/t.test.ts b/packages/i18next/src/t.test.ts index cbd2533b..fca7a982 100644 --- a/packages/i18next/src/t.test.ts +++ b/packages/i18next/src/t.test.ts @@ -13,7 +13,7 @@ describe('integration.$t', () => { setup, }); - const $result = $t.map((t) => t('common:foo')); + const $result = $t.map((t) => t('common:foo') ?? null); const scope = fork(); @@ -28,7 +28,7 @@ describe('integration.$t', () => { setup, }); - const $result = $t.map((t) => t('common:foo')); + const $result = $t.map((t) => t('common:foo') ?? null); const scope = fork(); @@ -50,7 +50,7 @@ describe('integration.$t', () => { setup, }); - const $result = $t.map((t) => t('common:foo')); + const $result = $t.map((t) => t('common:foo') ?? null); const scope = fork(); @@ -72,7 +72,7 @@ describe('integration.$t', () => { setup, }); - const $result = $t.map((t) => t('common:foo')); + const $result = $t.map((t) => t('common:foo') ?? null); const scope = fork(); @@ -95,7 +95,7 @@ describe('integration.$t', () => { setup, }); - const $result = $t.map((t) => t('common:foo')); + const $result = $t.map((t) => t('common:foo') ?? null); const scope = fork(); @@ -123,7 +123,7 @@ describe('integration.$t', () => { setup, }); - const $result = $t.map((t) => t('common:hello')); + const $result = $t.map((t) => t('common:hello') ?? null); const scope = fork(); @@ -149,7 +149,7 @@ describe('integration.$t', () => { setup, }); - const $result = $t.map((t) => t('common:hello')); + const $result = $t.map((t) => t('common:hello') ?? null); const scope = fork(); @@ -174,7 +174,7 @@ describe('integration.$t', () => { setup, }); - const $result = $t.map((t) => t('common:hello')); + const $result = $t.map((t) => t('common:hello') ?? null); const scope = fork(); @@ -199,7 +199,7 @@ describe('integration.$t', () => { setup, }); - const $result = $t.map((t) => t('common:hello')); + const $result = $t.map((t) => t('common:hello') ?? null); const scope = fork(); @@ -230,7 +230,7 @@ describe('integration.$t', () => { teardown, }); - const $result = $t.map((t) => t('common:hello')); + const $result = $t.map((t) => t('common:hello') ?? null); const scope = fork(); @@ -260,7 +260,7 @@ describe('integration.$t', () => { teardown, }); - const $result = $t.map((t) => t('common:hello')); + const $result = $t.map((t) => t('common:hello') ?? null); const scope = fork(); @@ -289,7 +289,7 @@ describe('integration.$t', () => { setup, }); - const $result = $t.map((t) => t('common:hello')); + const $result = $t.map((t) => t('common:hello') ?? null); const scope = fork(); expect(scope.getState($result)).toBe('hello'); diff --git a/packages/web-api/package.json b/packages/web-api/package.json index ad756cde..ffd05d14 100644 --- a/packages/web-api/package.json +++ b/packages/web-api/package.json @@ -3,6 +3,6 @@ "version": "1.0.1", "type": "commonjs", "peerDependencies": { - "effector": "^22.5.0" + "effector": "^22.5.0 || ^23.0.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index db972673..7a2edc38 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -25,8 +25,8 @@ importers: '@typescript-eslint/parser': 5.62.0 '@vitest/ui': 0.34.4 bytes-iec: ^3.1.1 - effector: ^22.8.6 - effector-vue: ^22.2.0 + effector: 23.0.0 + effector-vue: 23.0.0 eslint: 8.46.0 glob: ^8.0.3 i18next: 23.0.0 @@ -52,7 +52,7 @@ importers: '@babel/core': 7.18.6 '@babel/preset-typescript': 7.18.6_@babel+core@7.18.6 '@changesets/cli': 2.24.1 - '@farfetched/core': 0.8.13_effector@22.8.6 + '@farfetched/core': 0.8.13_effector@23.0.0 '@mands/nx-playwright': 0.4.0_bsyr2bp2xmxrf4lzacid2x337y '@nrwl/rollup': 16.5.5_oktbkxpsmwvyf527clbg2rcz6y '@nx/devkit': 16.5.5_nx@16.5.5 @@ -69,8 +69,8 @@ importers: '@typescript-eslint/parser': 5.62.0_7haavtekmro7ptbnqmctjaodju '@vitest/ui': 0.34.4_vitest@0.34.4 bytes-iec: 3.1.1 - effector: 22.8.6 - effector-vue: 22.2.0_effector@22.8.6+vue@3.3.4 + effector: 23.0.0 + effector-vue: 23.0.0_effector@23.0.0+vue@3.3.4 eslint: 8.46.0 glob: 8.1.0 i18next: 23.0.0 @@ -2662,12 +2662,12 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@farfetched/core/0.8.13_effector@22.8.6: + /@farfetched/core/0.8.13_effector@23.0.0: resolution: {integrity: sha512-Q/Hzw07VQ53BK7jLwgrOHkU63hkiF5Hd8cBGlGVjzz2wt+87wxauvuLdwDr/81eeM6aCVdeBSzVAS+KkOt/Xhw==} peerDependencies: effector: ^22.5.0 dependencies: - effector: 22.8.6 + effector: 23.0.0 dev: true /@humanwhocodes/config-array/0.11.11: @@ -5016,21 +5016,21 @@ packages: resolution: {integrity: sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==} dev: true - /effector-vue/22.2.0_effector@22.8.6+vue@3.3.4: - resolution: {integrity: sha512-ltiGrWizwBFXuIL0KuW11GXl253/AI/xSnSR1EtWlgDobzzEZ9G6gV6eUmcC36S4Jo34K7FJpKTmE/ODfGED6w==} + /effector-vue/23.0.0_effector@23.0.0+vue@3.3.4: + resolution: {integrity: sha512-Zn4/GeQ605nWapstNEsNvlbu/HfbQQ4+dSqlJlV0ujcuqbeVEBqEEJ0sufVzuRmwz4/+c7aNjlqk0PpTNOHOJg==} engines: {node: '>=11.0.0'} peerDependencies: '@vue/reactivity': ^3.0.2 '@vue/runtime-core': ^3.0.2 - effector: ^22.0.2 + effector: ^23.0.0 vue: '*' dependencies: - effector: 22.8.6 + effector: 23.0.0 vue: 3.3.4 dev: true - /effector/22.8.6: - resolution: {integrity: sha512-Bkg/rlPs7J4dmOFGPLLcL7X0SZeA8WdRnyC2X4tGVo7i6M8oxYwtNOkEUact/zIT/MgqTGm9A8T40dPnr8oXmA==} + /effector/23.0.0: + resolution: {integrity: sha512-8lT1iX8ivWRUnJL4XG2OhCZPRZku1XVc7AwbJCChxZhhB6ii/hZgs0GOTeE3BJfvc1BKf97q2hU3Yzp323sCiA==} engines: {node: '>=11.0.0'} dev: true