Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Effector 23 #59

Merged
merged 5 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cool-bags-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@withease/i18next': patch
---

Add forgotten allowance for usage with i18next 23 in peerDependencies
6 changes: 6 additions & 0 deletions .changeset/tame-cows-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@withease/i18next': minor
'@withease/web-api': minor
---

Allow to use with Effector 23
4 changes: 2 additions & 2 deletions apps/website/docs/web-api/media_query.live.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup>
import { trackMediaQuery } from '@withease/web-api';
import { createEvent } from 'effector';
import { useStore } from 'effector-vue/composition';
import { useUnit } from 'effector-vue/composition';
import { onMounted } from 'vue';

const appStarted = createEvent();
Expand All @@ -10,7 +10,7 @@ const mq = trackMediaQuery('(max-width: 320px)', {
setup: appStarted,
});

const matchesSmall = useStore(mq.$matches);
const matchesSmall = useUnit(mq.$matches);

onMounted(appStarted);
</script>
Expand Down
5 changes: 2 additions & 3 deletions apps/website/docs/web-api/network_status.live.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<script setup>
import { trackNetworkStatus } from '@withease/web-api';
import { createEvent } from 'effector';
import { useStore } from 'effector-vue/composition';
import { useUnit } from 'effector-vue/composition';
import { onMounted } from 'vue';

const appStarted = createEvent();

const { $online, $offline } = trackNetworkStatus({ setup: appStarted });

const online = useStore($online);
const offline = useStore($offline);
const [online, offline] = useUnit([$online, $offline]);

onMounted(appStarted);
</script>
Expand Down
4 changes: 2 additions & 2 deletions apps/website/docs/web-api/page_visibility.live.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup>
import { trackPageVisibility } from '@withease/web-api';
import { createEvent, createStore } from 'effector';
import { useStore } from 'effector-vue/composition';
import { useUnit } from 'effector-vue/composition';
import { onMounted } from 'vue';

const appStarted = createEvent();
Expand All @@ -12,7 +12,7 @@ const $history = createStore([])
.on(visible, (state) => [...state, { at: new Date(), action: 'visible' }])
.on(hidden, (state) => [...state, { at: new Date(), action: 'hidden' }]);

const history = useStore($history);
const history = useUnit($history);

onMounted(appStarted);
</script>
Expand Down
4 changes: 2 additions & 2 deletions apps/website/docs/web-api/preferred_languages.live.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<script setup>
import { trackPreferredLanguages } from '@withease/web-api';
import { createEvent } from 'effector';
import { useStore } from 'effector-vue/composition';
import { useUnit } from 'effector-vue/composition';
import { onMounted } from 'vue';

const appStarted = createEvent();

const { $languages } = trackPreferredLanguages({ setup: appStarted });

const languages = useStore($languages);
const languages = useUnit($languages);

onMounted(appStarted);
</script>
Expand Down
5 changes: 2 additions & 3 deletions apps/website/docs/web-api/screen_orientation.live.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<script setup>
import { trackScreenOrientation } from '@withease/web-api';
import { createEvent } from 'effector';
import { useStore } from 'effector-vue/composition';
import { useUnit } from 'effector-vue/composition';
import { onMounted } from 'vue';

const appStarted = createEvent();

const { $type, $angle } = trackScreenOrientation({ setup: appStarted });

const type = useStore($type);
const angle = useStore($angle);
const [type, angle] = useUnit([$type, $angle]);

onMounted(appStarted);
</script>
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/i18next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
14 changes: 10 additions & 4 deletions packages/i18next/src/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,21 @@ export function createI18nextIntegration({
// -- Parse options
const $instance: Store<i18n | null> = 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<TFunction | null>(null, {
serialize: 'ignore',
name: '$stanaloneT',
});

// -- Public API
Expand Down Expand Up @@ -110,7 +114,7 @@ export function createI18nextIntegration({

const finalKey = result.join('');

return t(finalKey);
return t(finalKey) ?? finalKey;
}
);
}
Expand All @@ -121,7 +125,7 @@ export function createI18nextIntegration({
): Store<string> {
return combine(
{ t: $t, variables: combine(variables ?? {}) },
({ t, variables }) => t(key, variables)
({ t, variables }) => t(key, variables) ?? key
);
}

Expand Down Expand Up @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/i18next/src/reporting.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down
24 changes: 12 additions & 12 deletions packages/i18next/src/t.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();

Expand All @@ -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();

Expand All @@ -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();

Expand All @@ -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();

Expand Down Expand Up @@ -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();

Expand All @@ -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();

Expand All @@ -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();

Expand All @@ -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();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion packages/web-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"version": "1.0.1",
"type": "commonjs",
"peerDependencies": {
"effector": "^22.5.0"
"effector": "^22.5.0 || ^23.0.0"
}
}
26 changes: 13 additions & 13 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.