@uipkge/nuxt 0.1.11 → 0.1.13

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/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.0.0"
6
6
  },
7
- "version": "0.1.11",
7
+ "version": "0.1.13",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "unknown"
@@ -4,11 +4,12 @@ export function useI18n(options) {
4
4
  const i18n = _useI18n({ useScope: "global", ...options });
5
5
  const nuxtApp = useNuxtApp();
6
6
  const originalT = i18n.t.bind(i18n);
7
- const patchedT = (key, defaultValue, namedParams) => {
8
- const result = namedParams ? originalT(key, namedParams) : originalT(key);
7
+ const patchedT = (key, defaultValue, ...rest) => {
8
+ const result = typeof defaultValue === "object" && defaultValue !== null ? originalT(key, defaultValue) : originalT(key);
9
9
  const sync = nuxtApp.$i18nowSync;
10
- if (sync && !sync.existingKeys.has(key) && defaultValue !== void 0) {
11
- sync.syncKey(key, defaultValue);
10
+ const defaultStr = typeof defaultValue === "string" ? defaultValue : typeof rest[0] === "string" ? rest[0] : void 0;
11
+ if (sync && !sync.existingKeys.has(key) && defaultStr !== void 0) {
12
+ sync.syncKey(key, defaultStr);
12
13
  }
13
14
  return result;
14
15
  };
@@ -24,7 +24,7 @@ function createI18nowSyncer(options) {
24
24
  }
25
25
  }).catch((err) => {
26
26
  const status = err.status ?? 0;
27
- const retryable = status === 0 || status >= 500;
27
+ const retryable = status === 0 || status === 429 || status >= 500;
28
28
  for (const { key } of keys) {
29
29
  if (!retryable) {
30
30
  retries.delete(key);
@@ -89,10 +89,11 @@ export default defineNuxtPlugin(async (nuxtApp) => {
89
89
  await loadLocale(locale);
90
90
  const originalGlobalT = nuxtApp.vueApp.config.globalProperties.$t;
91
91
  if (originalGlobalT) {
92
- nuxtApp.vueApp.config.globalProperties.$t = function(key, defaultValue, namedParams) {
93
- const result = namedParams ? originalGlobalT.call(this, key, namedParams) : originalGlobalT.call(this, key);
94
- if (!syncer.existingKeys.has(key) && defaultValue !== void 0) {
95
- syncer.syncKey(key, defaultValue);
92
+ nuxtApp.vueApp.config.globalProperties.$t = function(key, defaultValue, ...rest) {
93
+ const result = typeof defaultValue === "object" && defaultValue !== null ? originalGlobalT.call(this, key, defaultValue) : originalGlobalT.call(this, key);
94
+ const defaultStr = typeof defaultValue === "string" ? defaultValue : typeof rest[0] === "string" ? rest[0] : void 0;
95
+ if (!syncer.existingKeys.has(key) && defaultStr !== void 0) {
96
+ syncer.syncKey(key, defaultStr);
96
97
  }
97
98
  return result;
98
99
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipkge/nuxt",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -12,6 +12,16 @@
12
12
  "files": [
13
13
  "dist"
14
14
  ],
15
+ "scripts": {
16
+ "build": "nuxt-module-build build",
17
+ "dev": "nuxt-module-build prepare",
18
+ "dev:playground": "nuxi dev playground",
19
+ "prepack": "nuxt-module-build build",
20
+ "test": "vitest run",
21
+ "test:watch": "vitest",
22
+ "test:coverage": "vitest run --coverage",
23
+ "release": "vitest run && nuxt-module-build build && pnpm publish --access public --no-git-checks"
24
+ },
15
25
  "dependencies": {
16
26
  "@nuxt/kit": "^3.0.0"
17
27
  },
@@ -29,18 +39,9 @@
29
39
  },
30
40
  "devDependencies": {
31
41
  "@nuxt/module-builder": "^1.0.0",
42
+ "@uipkge/core": "workspace:*",
32
43
  "happy-dom": "^17.0.0",
33
44
  "nuxt": "^3.0.0",
34
- "vitest": "^4.0.0",
35
- "@uipkge/core": "0.1.1"
36
- },
37
- "scripts": {
38
- "build": "nuxt-module-build build",
39
- "dev": "nuxt-module-build prepare",
40
- "dev:playground": "nuxi dev playground",
41
- "test": "vitest run",
42
- "test:watch": "vitest",
43
- "test:coverage": "vitest run --coverage",
44
- "release": "vitest run && nuxt-module-build build && pnpm publish --access public --no-git-checks"
45
+ "vitest": "^4.0.0"
45
46
  }
46
- }
47
+ }