@furystack/shades-i18n 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.0.4] - 2026-02-22
|
|
4
|
+
|
|
5
|
+
### 🧪 Tests
|
|
6
|
+
|
|
7
|
+
- Replaced `sleepAsync()` with `flushUpdates()` across all i18n component tests for deterministic, timing-independent assertions
|
|
8
|
+
|
|
9
|
+
### ⬆️ Dependencies
|
|
10
|
+
|
|
11
|
+
- Updated `@furystack/shades` peer dependency
|
|
12
|
+
|
|
13
|
+
## [2.0.3] - 2026-02-22
|
|
14
|
+
|
|
15
|
+
### ⬆️ Dependencies
|
|
16
|
+
|
|
17
|
+
- Updated `@furystack/shades` to pick up dependency tracking support in `useDisposable`
|
|
18
|
+
|
|
3
19
|
## [2.0.2] - 2026-02-19
|
|
4
20
|
|
|
5
21
|
### ⬆️ Dependencies
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { I18NService } from '@furystack/i18n';
|
|
2
2
|
import { Injector } from '@furystack/inject';
|
|
3
|
-
import { createComponent, initializeShadeRoot } from '@furystack/shades';
|
|
4
|
-
import {
|
|
3
|
+
import { createComponent, flushUpdates, initializeShadeRoot } from '@furystack/shades';
|
|
4
|
+
import { usingAsync } from '@furystack/utils';
|
|
5
5
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
6
6
|
import { createI18nComponent } from './create-i18n-component.js';
|
|
7
7
|
const createTestService = () => {
|
|
@@ -47,7 +47,7 @@ describe('createI18nComponent', () => {
|
|
|
47
47
|
rootElement,
|
|
48
48
|
jsxElement: createComponent(I18n, { key: "hello" }),
|
|
49
49
|
});
|
|
50
|
-
await
|
|
50
|
+
await flushUpdates();
|
|
51
51
|
expect(rootElement.textContent).toBe('Hello');
|
|
52
52
|
});
|
|
53
53
|
});
|
|
@@ -67,7 +67,7 @@ describe('createI18nComponent', () => {
|
|
|
67
67
|
createComponent("span", null, " "),
|
|
68
68
|
createComponent(I18n, { key: "world" }))),
|
|
69
69
|
});
|
|
70
|
-
await
|
|
70
|
+
await flushUpdates();
|
|
71
71
|
expect(rootElement.textContent).toBe('Hello World');
|
|
72
72
|
});
|
|
73
73
|
});
|
|
@@ -84,13 +84,13 @@ describe('createI18nComponent', () => {
|
|
|
84
84
|
rootElement,
|
|
85
85
|
jsxElement: createComponent(I18n, { key: "hello" }),
|
|
86
86
|
});
|
|
87
|
-
await
|
|
87
|
+
await flushUpdates();
|
|
88
88
|
expect(rootElement.textContent).toBe('Hello');
|
|
89
89
|
service.currentLanguage = 'hu';
|
|
90
|
-
await
|
|
90
|
+
await flushUpdates();
|
|
91
91
|
expect(rootElement.textContent).toBe('Szia');
|
|
92
92
|
service.currentLanguage = 'de';
|
|
93
|
-
await
|
|
93
|
+
await flushUpdates();
|
|
94
94
|
expect(rootElement.textContent).toBe('Hallo');
|
|
95
95
|
});
|
|
96
96
|
});
|
|
@@ -107,11 +107,11 @@ describe('createI18nComponent', () => {
|
|
|
107
107
|
rootElement,
|
|
108
108
|
jsxElement: createComponent(I18n, { key: "world" }),
|
|
109
109
|
});
|
|
110
|
-
await
|
|
110
|
+
await flushUpdates();
|
|
111
111
|
expect(rootElement.textContent).toBe('World');
|
|
112
112
|
// German doesn't have 'world' translation, should fallback to English
|
|
113
113
|
service.currentLanguage = 'de';
|
|
114
|
-
await
|
|
114
|
+
await flushUpdates();
|
|
115
115
|
expect(rootElement.textContent).toBe('World');
|
|
116
116
|
});
|
|
117
117
|
});
|
|
@@ -128,13 +128,13 @@ describe('createI18nComponent', () => {
|
|
|
128
128
|
rootElement,
|
|
129
129
|
jsxElement: createComponent(I18n, { key: "hello" }),
|
|
130
130
|
});
|
|
131
|
-
await
|
|
131
|
+
await flushUpdates();
|
|
132
132
|
// Rapid language changes
|
|
133
133
|
service.currentLanguage = 'hu';
|
|
134
134
|
service.currentLanguage = 'de';
|
|
135
135
|
service.currentLanguage = 'en';
|
|
136
136
|
service.currentLanguage = 'hu';
|
|
137
|
-
await
|
|
137
|
+
await flushUpdates();
|
|
138
138
|
expect(rootElement.textContent).toBe('Szia');
|
|
139
139
|
});
|
|
140
140
|
});
|
|
@@ -162,11 +162,11 @@ describe('createI18nComponent', () => {
|
|
|
162
162
|
rootElement,
|
|
163
163
|
jsxElement: createComponent(I18n, { key: "hello" }),
|
|
164
164
|
});
|
|
165
|
-
await
|
|
165
|
+
await flushUpdates();
|
|
166
166
|
expect(unsubscribeSpy).not.toHaveBeenCalled();
|
|
167
167
|
// Unmount by clearing the DOM
|
|
168
168
|
document.body.innerHTML = '';
|
|
169
|
-
await
|
|
169
|
+
await flushUpdates();
|
|
170
170
|
expect(unsubscribeSpy).toHaveBeenCalled();
|
|
171
171
|
});
|
|
172
172
|
});
|
|
@@ -183,7 +183,7 @@ describe('createI18nComponent', () => {
|
|
|
183
183
|
rootElement,
|
|
184
184
|
jsxElement: createComponent(I18n, { key: "hello" }),
|
|
185
185
|
});
|
|
186
|
-
await
|
|
186
|
+
await flushUpdates();
|
|
187
187
|
// The component uses elementBaseName: 'span', so it renders as <span is="test-i18n-span">
|
|
188
188
|
const i18nElement = rootElement.querySelector('span[is="test-i18n-span"]');
|
|
189
189
|
expect(i18nElement).toBeInstanceOf(HTMLSpanElement);
|
|
@@ -205,10 +205,10 @@ describe('createI18nComponent', () => {
|
|
|
205
205
|
' - ',
|
|
206
206
|
createComponent(I18n, { key: "goodbye" }))),
|
|
207
207
|
});
|
|
208
|
-
await
|
|
208
|
+
await flushUpdates();
|
|
209
209
|
expect(rootElement.textContent).toBe('Hello - Goodbye');
|
|
210
210
|
service.currentLanguage = 'hu';
|
|
211
|
-
await
|
|
211
|
+
await flushUpdates();
|
|
212
212
|
expect(rootElement.textContent).toBe('Szia - Viszlát');
|
|
213
213
|
});
|
|
214
214
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-i18n-component.spec.js","sourceRoot":"","sources":["../src/create-i18n-component.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"create-i18n-component.spec.js","sourceRoot":"","sources":["../src/create-i18n-component.spec.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAIhE,MAAM,iBAAiB,GAAG,GAAG,EAAE;IAC7B,OAAO,IAAI,WAAW,CACpB;QACE,IAAI,EAAE,IAAI;QACV,MAAM,EAAE;YACN,KAAK,EAAE,OAAO;YACd,OAAO,EAAE,SAAS;YAClB,KAAK,EAAE,OAAO;SACf;KACF,EACD;QACE,IAAI,EAAE,IAAI;QACV,MAAM,EAAE;YACN,KAAK,EAAE,MAAM;YACb,OAAO,EAAE,SAAS;YAClB,KAAK,EAAE,OAAO;SACf;KACF,EACD;QACE,IAAI,EAAE,IAAI;QACV,MAAM,EAAE;YACN,KAAK,EAAE,OAAO;YACd,OAAO,EAAE,iBAAiB;SAC3B;KACF,CACF,CAAA;AACH,CAAC,CAAA;AAED,QAAQ,CAAC,qBAAqB,EAAE,G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E,KAAK,IAAI,EAAE;QACxE,MAAM,UAAU,CAAC,IAAI,QAAQ,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;YAClD,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAA;YACnC,MAAM,IAAI,GAAG,mBAAmB,CAAC;gBAC/B,OAAO;gBACP,aAAa,EAAE,oBAAoB;aACpC,CAAC,CAAA;YAEF,MAAM,WAAW,GAAG,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAmB,CAAA;YACrE,mBAAmB,CAAC;gBAClB,QAAQ;gBACR,WAAW;gBACX,UAAU,EAAE,CACV;oBACE,gBAAC,IAAI,IAAC,GAAG,EAAC,OAAO,GAAG;oBACnB,KAAK;oBACN,gBAAC,IAAI,IAAC,GAAG,EAAC,SAAS,GAAG,CAClB,CACP;aACF,CAAC,CAAA;YAEF,MAAM,YAAY,EAAE,CAAA;YACpB,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;YAEvD,OAAO,CAAC,eAAe,GAAG,IAAI,CAAA;YAC9B,MAAM,YAAY,EAAE,CAAA;YACpB,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;QACxD,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@furystack/shades-i18n",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "I18n translation package and components for Shades",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@furystack/i18n": "^1.0.30",
|
|
41
41
|
"@furystack/inject": "^12.0.30",
|
|
42
|
-
"@furystack/shades": "^12.1
|
|
42
|
+
"@furystack/shades": "^12.2.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/node": "^25.3.0",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { I18NService } from '@furystack/i18n'
|
|
2
2
|
import { Injector } from '@furystack/inject'
|
|
3
|
-
import { createComponent, initializeShadeRoot } from '@furystack/shades'
|
|
4
|
-
import {
|
|
3
|
+
import { createComponent, flushUpdates, initializeShadeRoot } from '@furystack/shades'
|
|
4
|
+
import { usingAsync } from '@furystack/utils'
|
|
5
5
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
6
6
|
import { createI18nComponent } from './create-i18n-component.js'
|
|
7
7
|
|
|
@@ -59,7 +59,7 @@ describe('createI18nComponent', () => {
|
|
|
59
59
|
jsxElement: <I18n key="hello" />,
|
|
60
60
|
})
|
|
61
61
|
|
|
62
|
-
await
|
|
62
|
+
await flushUpdates()
|
|
63
63
|
expect(rootElement.textContent).toBe('Hello')
|
|
64
64
|
})
|
|
65
65
|
})
|
|
@@ -85,7 +85,7 @@ describe('createI18nComponent', () => {
|
|
|
85
85
|
),
|
|
86
86
|
})
|
|
87
87
|
|
|
88
|
-
await
|
|
88
|
+
await flushUpdates()
|
|
89
89
|
expect(rootElement.textContent).toBe('Hello World')
|
|
90
90
|
})
|
|
91
91
|
})
|
|
@@ -105,15 +105,15 @@ describe('createI18nComponent', () => {
|
|
|
105
105
|
jsxElement: <I18n key="hello" />,
|
|
106
106
|
})
|
|
107
107
|
|
|
108
|
-
await
|
|
108
|
+
await flushUpdates()
|
|
109
109
|
expect(rootElement.textContent).toBe('Hello')
|
|
110
110
|
|
|
111
111
|
service.currentLanguage = 'hu'
|
|
112
|
-
await
|
|
112
|
+
await flushUpdates()
|
|
113
113
|
expect(rootElement.textContent).toBe('Szia')
|
|
114
114
|
|
|
115
115
|
service.currentLanguage = 'de'
|
|
116
|
-
await
|
|
116
|
+
await flushUpdates()
|
|
117
117
|
expect(rootElement.textContent).toBe('Hallo')
|
|
118
118
|
})
|
|
119
119
|
})
|
|
@@ -133,12 +133,12 @@ describe('createI18nComponent', () => {
|
|
|
133
133
|
jsxElement: <I18n key="world" />,
|
|
134
134
|
})
|
|
135
135
|
|
|
136
|
-
await
|
|
136
|
+
await flushUpdates()
|
|
137
137
|
expect(rootElement.textContent).toBe('World')
|
|
138
138
|
|
|
139
139
|
// German doesn't have 'world' translation, should fallback to English
|
|
140
140
|
service.currentLanguage = 'de'
|
|
141
|
-
await
|
|
141
|
+
await flushUpdates()
|
|
142
142
|
expect(rootElement.textContent).toBe('World')
|
|
143
143
|
})
|
|
144
144
|
})
|
|
@@ -158,7 +158,7 @@ describe('createI18nComponent', () => {
|
|
|
158
158
|
jsxElement: <I18n key="hello" />,
|
|
159
159
|
})
|
|
160
160
|
|
|
161
|
-
await
|
|
161
|
+
await flushUpdates()
|
|
162
162
|
|
|
163
163
|
// Rapid language changes
|
|
164
164
|
service.currentLanguage = 'hu'
|
|
@@ -166,7 +166,7 @@ describe('createI18nComponent', () => {
|
|
|
166
166
|
service.currentLanguage = 'en'
|
|
167
167
|
service.currentLanguage = 'hu'
|
|
168
168
|
|
|
169
|
-
await
|
|
169
|
+
await flushUpdates()
|
|
170
170
|
expect(rootElement.textContent).toBe('Szia')
|
|
171
171
|
})
|
|
172
172
|
})
|
|
@@ -198,12 +198,12 @@ describe('createI18nComponent', () => {
|
|
|
198
198
|
jsxElement: <I18n key="hello" />,
|
|
199
199
|
})
|
|
200
200
|
|
|
201
|
-
await
|
|
201
|
+
await flushUpdates()
|
|
202
202
|
expect(unsubscribeSpy).not.toHaveBeenCalled()
|
|
203
203
|
|
|
204
204
|
// Unmount by clearing the DOM
|
|
205
205
|
document.body.innerHTML = ''
|
|
206
|
-
await
|
|
206
|
+
await flushUpdates()
|
|
207
207
|
|
|
208
208
|
expect(unsubscribeSpy).toHaveBeenCalled()
|
|
209
209
|
})
|
|
@@ -224,7 +224,7 @@ describe('createI18nComponent', () => {
|
|
|
224
224
|
jsxElement: <I18n key="hello" />,
|
|
225
225
|
})
|
|
226
226
|
|
|
227
|
-
await
|
|
227
|
+
await flushUpdates()
|
|
228
228
|
// The component uses elementBaseName: 'span', so it renders as <span is="test-i18n-span">
|
|
229
229
|
const i18nElement = rootElement.querySelector('span[is="test-i18n-span"]')
|
|
230
230
|
expect(i18nElement).toBeInstanceOf(HTMLSpanElement)
|
|
@@ -252,11 +252,11 @@ describe('createI18nComponent', () => {
|
|
|
252
252
|
),
|
|
253
253
|
})
|
|
254
254
|
|
|
255
|
-
await
|
|
255
|
+
await flushUpdates()
|
|
256
256
|
expect(rootElement.textContent).toBe('Hello - Goodbye')
|
|
257
257
|
|
|
258
258
|
service.currentLanguage = 'hu'
|
|
259
|
-
await
|
|
259
|
+
await flushUpdates()
|
|
260
260
|
expect(rootElement.textContent).toBe('Szia - Viszlát')
|
|
261
261
|
})
|
|
262
262
|
})
|