@sheet-i18n/react-client 1.0.2 → 1.0.3

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 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 ? string : any;
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 ? string : any;
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
@@ -183,26 +183,41 @@ function getTranslation({
183
183
  sheetTitle,
184
184
  i18nStore
185
185
  }) {
186
- const intlInstance = intlInstanceCache.getCachedIntlInstance(
187
- sheetTitle,
188
- i18nStore,
189
- "server"
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, _b, _c;
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 (_c = (_b = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _b.call(intlInstance, descriptor, values, opts)) != null ? _c : id;
202
+ return new Promise((resolve) => {
203
+ intlInitPromise.then((intlInstance) => {
204
+ var _a2, _b;
205
+ resolve((_b = (_a2 = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _a2.call(intlInstance, descriptor, values, opts)) != null ? _b : id);
206
+ });
207
+ });
198
208
  };
199
209
  t.dynamic = (id, values, opts, _descriptor) => {
200
- var _a, _b, _c;
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 (_c = (_b = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _b.call(intlInstance, descriptor, values, opts)) != null ? _c : id;
215
+ return new Promise((resolve) => {
216
+ intlInitPromise.then((intlInstance) => {
217
+ var _a2, _b;
218
+ resolve((_b = (_a2 = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _a2.call(intlInstance, descriptor, values, opts)) != null ? _b : id);
219
+ });
220
+ });
206
221
  };
207
222
  return { t };
208
223
  }
package/dist/index.mjs CHANGED
@@ -160,26 +160,41 @@ function getTranslation({
160
160
  sheetTitle,
161
161
  i18nStore
162
162
  }) {
163
- const intlInstance = intlInstanceCache.getCachedIntlInstance(
164
- sheetTitle,
165
- i18nStore,
166
- "server"
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, _b, _c;
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 (_c = (_b = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _b.call(intlInstance, descriptor, values, opts)) != null ? _c : id;
179
+ return new Promise((resolve) => {
180
+ intlInitPromise.then((intlInstance) => {
181
+ var _a2, _b;
182
+ resolve((_b = (_a2 = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _a2.call(intlInstance, descriptor, values, opts)) != null ? _b : id);
183
+ });
184
+ });
175
185
  };
176
186
  t.dynamic = (id, values, opts, _descriptor) => {
177
- var _a, _b, _c;
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 (_c = (_b = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _b.call(intlInstance, descriptor, values, opts)) != null ? _c : id;
192
+ return new Promise((resolve) => {
193
+ intlInitPromise.then((intlInstance) => {
194
+ var _a2, _b;
195
+ resolve((_b = (_a2 = intlInstance == null ? void 0 : intlInstance.$t) == null ? void 0 : _a2.call(intlInstance, descriptor, values, opts)) != null ? _b : id);
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.2",
3
+ "version": "1.0.3",
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.3",
31
- "@sheet-i18n/errors": "1.3.3",
32
- "@sheet-i18n/react-core": "1.0.1"
30
+ "@sheet-i18n/shared-utils": "1.3.4",
31
+ "@sheet-i18n/errors": "1.3.4",
32
+ "@sheet-i18n/react-core": "1.0.2"
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.3"
37
+ "@sheet-i18n/typescript-config": "1.3.4"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "tsup",