@sheet-i18n/react-client 1.0.4 → 1.0.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.
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +46 -17
- package/dist/index.mjs +46 -17
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -5,10 +5,11 @@ import { I18nStore } from '@sheet-i18n/react-core';
|
|
|
5
5
|
type UseIntlParams$1<D = MessageDescriptor> = Parameters<IntlShape['$t']> extends [D, ...infer R] ? [...R, Omit<D, 'id'>] : never;
|
|
6
6
|
type $TParams$1 = Partial<UseIntlParams$1>;
|
|
7
7
|
type GetTranslationReturn<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any>>, TTypeSafe extends boolean, TSheetTitle extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]] : string> = {
|
|
8
|
-
t: <TMessageId extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle] : string, TValues extends $TParams$1[0], TOpts extends $TParams$1[1], TDescriptor extends $TParams$1[2]>(id: TMessageId, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ?
|
|
8
|
+
t: <TMessageId extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle] : string, TValues extends $TParams$1[0], TOpts extends $TParams$1[1], TDescriptor extends $TParams$1[2]>(id: TMessageId, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ? TMessageId : any;
|
|
9
9
|
} & {
|
|
10
10
|
t: {
|
|
11
|
-
dynamic: <TMessageId extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle] : string, TValues extends $TParams$1[0], TOpts extends $TParams$1[1], TDescriptor extends $TParams$1[2]>(id: string, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ?
|
|
11
|
+
dynamic: <TMessageId extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle] : string, TValues extends $TParams$1[0], TOpts extends $TParams$1[1], TDescriptor extends $TParams$1[2]>(id: string, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ? string : any;
|
|
12
|
+
promise: <TMessageId extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle] : string, TValues extends $TParams$1[0], TOpts extends $TParams$1[1], TDescriptor extends $TParams$1[2]>(id: TMessageId, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ? Promise<TMessageId> : any;
|
|
12
13
|
};
|
|
13
14
|
};
|
|
14
15
|
|
package/dist/index.d.ts
CHANGED
|
@@ -5,10 +5,11 @@ import { I18nStore } from '@sheet-i18n/react-core';
|
|
|
5
5
|
type UseIntlParams$1<D = MessageDescriptor> = Parameters<IntlShape['$t']> extends [D, ...infer R] ? [...R, Omit<D, 'id'>] : never;
|
|
6
6
|
type $TParams$1 = Partial<UseIntlParams$1>;
|
|
7
7
|
type GetTranslationReturn<TSupportedLocales extends readonly string[], TLocaleSet extends Record<TSupportedLocales[number], Record<string, any>>, TTypeSafe extends boolean, TSheetTitle extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]] : string> = {
|
|
8
|
-
t: <TMessageId extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle] : string, TValues extends $TParams$1[0], TOpts extends $TParams$1[1], TDescriptor extends $TParams$1[2]>(id: TMessageId, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ?
|
|
8
|
+
t: <TMessageId extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle] : string, TValues extends $TParams$1[0], TOpts extends $TParams$1[1], TDescriptor extends $TParams$1[2]>(id: TMessageId, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ? TMessageId : any;
|
|
9
9
|
} & {
|
|
10
10
|
t: {
|
|
11
|
-
dynamic: <TMessageId extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle] : string, TValues extends $TParams$1[0], TOpts extends $TParams$1[1], TDescriptor extends $TParams$1[2]>(id: string, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ?
|
|
11
|
+
dynamic: <TMessageId extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle] : string, TValues extends $TParams$1[0], TOpts extends $TParams$1[1], TDescriptor extends $TParams$1[2]>(id: string, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ? string : any;
|
|
12
|
+
promise: <TMessageId extends TTypeSafe extends true ? keyof TLocaleSet[TSupportedLocales[number]][TSheetTitle] : string, TValues extends $TParams$1[0], TOpts extends $TParams$1[1], TDescriptor extends $TParams$1[2]>(id: TMessageId, values?: TValues, opts?: TOpts, _descriptor?: TDescriptor) => TTypeSafe extends true ? Promise<TMessageId> : any;
|
|
12
13
|
};
|
|
13
14
|
};
|
|
14
15
|
|
package/dist/index.js
CHANGED
|
@@ -183,35 +183,48 @@ function getTranslation({
|
|
|
183
183
|
sheetTitle,
|
|
184
184
|
i18nStore
|
|
185
185
|
}) {
|
|
186
|
-
const intlInitPromise = new Promise((resolve) => {
|
|
187
|
-
setTimeout(() => {
|
|
188
|
-
const intlInstance = intlInstanceCache.getCachedIntlInstance(
|
|
189
|
-
sheetTitle,
|
|
190
|
-
i18nStore,
|
|
191
|
-
"server"
|
|
192
|
-
);
|
|
193
|
-
resolve(intlInstance);
|
|
194
|
-
}, 1);
|
|
195
|
-
});
|
|
196
186
|
const t = (id, values, opts, _descriptor) => {
|
|
197
|
-
var _a;
|
|
187
|
+
var _a, _b, _c, _d;
|
|
198
188
|
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
199
189
|
id,
|
|
200
190
|
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
201
191
|
});
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
192
|
+
const intlInstance = intlInstanceCache.getCachedIntlInstance(
|
|
193
|
+
sheetTitle,
|
|
194
|
+
i18nStore,
|
|
195
|
+
"server"
|
|
196
|
+
);
|
|
197
|
+
return (_d = (_c = (_b = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _b.call(intlInstance, descriptor, values, opts)) != null ? _c : id) != null ? _d : "";
|
|
208
198
|
};
|
|
209
199
|
t.dynamic = (id, values, opts, _descriptor) => {
|
|
200
|
+
var _a, _b, _c, _d;
|
|
201
|
+
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
202
|
+
id,
|
|
203
|
+
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
204
|
+
});
|
|
205
|
+
const intlInstance = intlInstanceCache.getCachedIntlInstance(
|
|
206
|
+
sheetTitle,
|
|
207
|
+
i18nStore,
|
|
208
|
+
"server"
|
|
209
|
+
);
|
|
210
|
+
return (_d = (_c = (_b = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _b.call(intlInstance, descriptor, values, opts)) != null ? _c : id) != null ? _d : "";
|
|
211
|
+
};
|
|
212
|
+
t.promise = (id, values, opts, _descriptor) => {
|
|
210
213
|
var _a;
|
|
211
214
|
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
212
215
|
id,
|
|
213
216
|
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
214
217
|
});
|
|
218
|
+
const intlInitPromise = new Promise((resolve) => {
|
|
219
|
+
setTimeout(() => {
|
|
220
|
+
const intlInstance = intlInstanceCache.getCachedIntlInstance(
|
|
221
|
+
sheetTitle,
|
|
222
|
+
i18nStore,
|
|
223
|
+
"server"
|
|
224
|
+
);
|
|
225
|
+
resolve(intlInstance);
|
|
226
|
+
}, 1);
|
|
227
|
+
});
|
|
215
228
|
return new Promise((resolve) => {
|
|
216
229
|
intlInitPromise.then((intlInstance) => {
|
|
217
230
|
var _a2, _b, _c;
|
|
@@ -219,6 +232,22 @@ function getTranslation({
|
|
|
219
232
|
});
|
|
220
233
|
});
|
|
221
234
|
};
|
|
235
|
+
t.lazy = (id, values, opts, _descriptor) => {
|
|
236
|
+
var _a;
|
|
237
|
+
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
238
|
+
id,
|
|
239
|
+
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
240
|
+
});
|
|
241
|
+
const intlInstance = intlInstanceCache.getCachedIntlInstance(
|
|
242
|
+
sheetTitle,
|
|
243
|
+
i18nStore,
|
|
244
|
+
"server"
|
|
245
|
+
);
|
|
246
|
+
return () => {
|
|
247
|
+
var _a2, _b, _c;
|
|
248
|
+
return (_c = (_b = (_a2 = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _a2.call(intlInstance, descriptor, values, opts)) != null ? _b : id) != null ? _c : "";
|
|
249
|
+
};
|
|
250
|
+
};
|
|
222
251
|
return { t };
|
|
223
252
|
}
|
|
224
253
|
|
package/dist/index.mjs
CHANGED
|
@@ -160,35 +160,48 @@ function getTranslation({
|
|
|
160
160
|
sheetTitle,
|
|
161
161
|
i18nStore
|
|
162
162
|
}) {
|
|
163
|
-
const intlInitPromise = new Promise((resolve) => {
|
|
164
|
-
setTimeout(() => {
|
|
165
|
-
const intlInstance = intlInstanceCache.getCachedIntlInstance(
|
|
166
|
-
sheetTitle,
|
|
167
|
-
i18nStore,
|
|
168
|
-
"server"
|
|
169
|
-
);
|
|
170
|
-
resolve(intlInstance);
|
|
171
|
-
}, 1);
|
|
172
|
-
});
|
|
173
163
|
const t = (id, values, opts, _descriptor) => {
|
|
174
|
-
var _a;
|
|
164
|
+
var _a, _b, _c, _d;
|
|
175
165
|
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
176
166
|
id,
|
|
177
167
|
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
178
168
|
});
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
169
|
+
const intlInstance = intlInstanceCache.getCachedIntlInstance(
|
|
170
|
+
sheetTitle,
|
|
171
|
+
i18nStore,
|
|
172
|
+
"server"
|
|
173
|
+
);
|
|
174
|
+
return (_d = (_c = (_b = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _b.call(intlInstance, descriptor, values, opts)) != null ? _c : id) != null ? _d : "";
|
|
185
175
|
};
|
|
186
176
|
t.dynamic = (id, values, opts, _descriptor) => {
|
|
177
|
+
var _a, _b, _c, _d;
|
|
178
|
+
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
179
|
+
id,
|
|
180
|
+
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
181
|
+
});
|
|
182
|
+
const intlInstance = intlInstanceCache.getCachedIntlInstance(
|
|
183
|
+
sheetTitle,
|
|
184
|
+
i18nStore,
|
|
185
|
+
"server"
|
|
186
|
+
);
|
|
187
|
+
return (_d = (_c = (_b = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _b.call(intlInstance, descriptor, values, opts)) != null ? _c : id) != null ? _d : "";
|
|
188
|
+
};
|
|
189
|
+
t.promise = (id, values, opts, _descriptor) => {
|
|
187
190
|
var _a;
|
|
188
191
|
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
189
192
|
id,
|
|
190
193
|
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
191
194
|
});
|
|
195
|
+
const intlInitPromise = new Promise((resolve) => {
|
|
196
|
+
setTimeout(() => {
|
|
197
|
+
const intlInstance = intlInstanceCache.getCachedIntlInstance(
|
|
198
|
+
sheetTitle,
|
|
199
|
+
i18nStore,
|
|
200
|
+
"server"
|
|
201
|
+
);
|
|
202
|
+
resolve(intlInstance);
|
|
203
|
+
}, 1);
|
|
204
|
+
});
|
|
192
205
|
return new Promise((resolve) => {
|
|
193
206
|
intlInitPromise.then((intlInstance) => {
|
|
194
207
|
var _a2, _b, _c;
|
|
@@ -196,6 +209,22 @@ function getTranslation({
|
|
|
196
209
|
});
|
|
197
210
|
});
|
|
198
211
|
};
|
|
212
|
+
t.lazy = (id, values, opts, _descriptor) => {
|
|
213
|
+
var _a;
|
|
214
|
+
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
215
|
+
id,
|
|
216
|
+
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
217
|
+
});
|
|
218
|
+
const intlInstance = intlInstanceCache.getCachedIntlInstance(
|
|
219
|
+
sheetTitle,
|
|
220
|
+
i18nStore,
|
|
221
|
+
"server"
|
|
222
|
+
);
|
|
223
|
+
return () => {
|
|
224
|
+
var _a2, _b, _c;
|
|
225
|
+
return (_c = (_b = (_a2 = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _a2.call(intlInstance, descriptor, values, opts)) != null ? _b : id) != null ? _c : "";
|
|
226
|
+
};
|
|
227
|
+
};
|
|
199
228
|
return { t };
|
|
200
229
|
}
|
|
201
230
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sheet-i18n/react-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "a client package for react modules used by sheet-i18n",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"react": "^18.2.0",
|
|
29
29
|
"react-intl": "^7.0.4",
|
|
30
|
-
"@sheet-i18n/
|
|
31
|
-
"@sheet-i18n/
|
|
32
|
-
"@sheet-i18n/
|
|
30
|
+
"@sheet-i18n/react-core": "1.0.4",
|
|
31
|
+
"@sheet-i18n/shared-utils": "1.3.6",
|
|
32
|
+
"@sheet-i18n/errors": "1.3.6"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/react": "^19.0.2",
|
|
36
36
|
"@types/react-dom": "^19.0.2",
|
|
37
|
-
"@sheet-i18n/typescript-config": "1.3.
|
|
37
|
+
"@sheet-i18n/typescript-config": "1.3.6"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "tsup",
|