@sheet-i18n/react-client 1.0.2 → 1.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/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +28 -13
- package/dist/index.mjs +28 -13
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -5,10 +5,10 @@ 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 ? TMessageId : any;
|
|
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 ? Promise<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 ? Promise<TMessageId> : any;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
14
|
|
package/dist/index.d.ts
CHANGED
|
@@ -5,10 +5,10 @@ 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 ? TMessageId : any;
|
|
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 ? Promise<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 ? Promise<TMessageId> : any;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
14
|
|
package/dist/index.js
CHANGED
|
@@ -153,20 +153,20 @@ function useTranslation({
|
|
|
153
153
|
i18nStore
|
|
154
154
|
);
|
|
155
155
|
const t = (id, values, opts, _descriptor) => {
|
|
156
|
-
var _a;
|
|
156
|
+
var _a, _b, _c, _d;
|
|
157
157
|
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
158
158
|
id,
|
|
159
159
|
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
160
160
|
});
|
|
161
|
-
return intlInstance ? intlInstance.$t(descriptor, values, opts) : id;
|
|
161
|
+
return (_d = (_c = (_b = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _b.call(intlInstance, descriptor, values, opts)) != null ? _c : id) != null ? _d : "";
|
|
162
162
|
};
|
|
163
163
|
t.dynamic = (id, values, opts, _descriptor) => {
|
|
164
|
-
var _a;
|
|
164
|
+
var _a, _b, _c, _d;
|
|
165
165
|
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
166
166
|
id,
|
|
167
167
|
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
168
168
|
});
|
|
169
|
-
return intlInstance ? intlInstance.$t(descriptor, values, opts) : id;
|
|
169
|
+
return (_d = (_c = (_b = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _b.call(intlInstance, descriptor, values, opts)) != null ? _c : id) != null ? _d : "";
|
|
170
170
|
};
|
|
171
171
|
return { t };
|
|
172
172
|
}
|
|
@@ -183,26 +183,41 @@ function getTranslation({
|
|
|
183
183
|
sheetTitle,
|
|
184
184
|
i18nStore
|
|
185
185
|
}) {
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
+
});
|
|
191
196
|
const t = (id, values, opts, _descriptor) => {
|
|
192
|
-
var _a
|
|
197
|
+
var _a;
|
|
193
198
|
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
194
199
|
id,
|
|
195
200
|
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
196
201
|
});
|
|
197
|
-
return
|
|
202
|
+
return new Promise((resolve) => {
|
|
203
|
+
intlInitPromise.then((intlInstance) => {
|
|
204
|
+
var _a2, _b, _c;
|
|
205
|
+
resolve((_c = (_b = (_a2 = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _a2.call(intlInstance, descriptor, values, opts)) != null ? _b : id) != null ? _c : "");
|
|
206
|
+
});
|
|
207
|
+
});
|
|
198
208
|
};
|
|
199
209
|
t.dynamic = (id, values, opts, _descriptor) => {
|
|
200
|
-
var _a
|
|
210
|
+
var _a;
|
|
201
211
|
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
202
212
|
id,
|
|
203
213
|
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
204
214
|
});
|
|
205
|
-
return
|
|
215
|
+
return new Promise((resolve) => {
|
|
216
|
+
intlInitPromise.then((intlInstance) => {
|
|
217
|
+
var _a2, _b, _c;
|
|
218
|
+
resolve((_c = (_b = (_a2 = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _a2.call(intlInstance, descriptor, values, opts)) != null ? _b : id) != null ? _c : "");
|
|
219
|
+
});
|
|
220
|
+
});
|
|
206
221
|
};
|
|
207
222
|
return { t };
|
|
208
223
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -130,20 +130,20 @@ function useTranslation({
|
|
|
130
130
|
i18nStore
|
|
131
131
|
);
|
|
132
132
|
const t = (id, values, opts, _descriptor) => {
|
|
133
|
-
var _a;
|
|
133
|
+
var _a, _b, _c, _d;
|
|
134
134
|
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
135
135
|
id,
|
|
136
136
|
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
137
137
|
});
|
|
138
|
-
return intlInstance ? intlInstance.$t(descriptor, values, opts) : id;
|
|
138
|
+
return (_d = (_c = (_b = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _b.call(intlInstance, descriptor, values, opts)) != null ? _c : id) != null ? _d : "";
|
|
139
139
|
};
|
|
140
140
|
t.dynamic = (id, values, opts, _descriptor) => {
|
|
141
|
-
var _a;
|
|
141
|
+
var _a, _b, _c, _d;
|
|
142
142
|
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
143
143
|
id,
|
|
144
144
|
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
145
145
|
});
|
|
146
|
-
return intlInstance ? intlInstance.$t(descriptor, values, opts) : id;
|
|
146
|
+
return (_d = (_c = (_b = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _b.call(intlInstance, descriptor, values, opts)) != null ? _c : id) != null ? _d : "";
|
|
147
147
|
};
|
|
148
148
|
return { t };
|
|
149
149
|
}
|
|
@@ -160,26 +160,41 @@ function getTranslation({
|
|
|
160
160
|
sheetTitle,
|
|
161
161
|
i18nStore
|
|
162
162
|
}) {
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
+
});
|
|
168
173
|
const t = (id, values, opts, _descriptor) => {
|
|
169
|
-
var _a
|
|
174
|
+
var _a;
|
|
170
175
|
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
171
176
|
id,
|
|
172
177
|
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
173
178
|
});
|
|
174
|
-
return
|
|
179
|
+
return new Promise((resolve) => {
|
|
180
|
+
intlInitPromise.then((intlInstance) => {
|
|
181
|
+
var _a2, _b, _c;
|
|
182
|
+
resolve((_c = (_b = (_a2 = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _a2.call(intlInstance, descriptor, values, opts)) != null ? _b : id) != null ? _c : "");
|
|
183
|
+
});
|
|
184
|
+
});
|
|
175
185
|
};
|
|
176
186
|
t.dynamic = (id, values, opts, _descriptor) => {
|
|
177
|
-
var _a
|
|
187
|
+
var _a;
|
|
178
188
|
const descriptor = __spreadProps(__spreadValues({}, _descriptor != null ? _descriptor : {}), {
|
|
179
189
|
id,
|
|
180
190
|
defaultMessage: (_a = _descriptor == null ? void 0 : _descriptor.defaultMessage) != null ? _a : id
|
|
181
191
|
});
|
|
182
|
-
return
|
|
192
|
+
return new Promise((resolve) => {
|
|
193
|
+
intlInitPromise.then((intlInstance) => {
|
|
194
|
+
var _a2, _b, _c;
|
|
195
|
+
resolve((_c = (_b = (_a2 = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _a2.call(intlInstance, descriptor, values, opts)) != null ? _b : id) != null ? _c : "");
|
|
196
|
+
});
|
|
197
|
+
});
|
|
183
198
|
};
|
|
184
199
|
return { t };
|
|
185
200
|
}
|
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.4",
|
|
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/shared-utils": "1.3.
|
|
31
|
-
"@sheet-i18n/errors": "1.3.
|
|
32
|
-
"@sheet-i18n/react-core": "1.0.
|
|
30
|
+
"@sheet-i18n/shared-utils": "1.3.5",
|
|
31
|
+
"@sheet-i18n/errors": "1.3.5",
|
|
32
|
+
"@sheet-i18n/react-core": "1.0.3"
|
|
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.5"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "tsup",
|