@uipkge/nuxt 0.1.9 → 0.1.11
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 +1 -1
- package/dist/module.mjs +2 -9
- package/dist/runtime/plugin.client.js +6 -5
- package/package.json +13 -14
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, addPlugin,
|
|
1
|
+
import { defineNuxtModule, createResolver, addPlugin, addImports } from '@nuxt/kit';
|
|
2
2
|
|
|
3
3
|
const module$1 = defineNuxtModule({
|
|
4
4
|
meta: {
|
|
@@ -29,11 +29,9 @@ const module$1 = defineNuxtModule({
|
|
|
29
29
|
`[i18now] DANGER: syncIn includes "${dangerousEnvs.join('", "')}" \u2014 key sync is enabled in a production-like environment. This will expose your API key to users and flood i18now with production traffic. syncIn should only contain "development".`
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
|
-
nuxt.options.runtimeConfig.i18now = {
|
|
33
|
-
apiKey: options.apiKey
|
|
34
|
-
};
|
|
35
32
|
nuxt.options.runtimeConfig.public.i18now = {
|
|
36
33
|
projectId: options.projectId,
|
|
34
|
+
apiKey: options.apiKey,
|
|
37
35
|
host: options.host,
|
|
38
36
|
cdnUrl: options.cdnUrl,
|
|
39
37
|
environment: options.environment,
|
|
@@ -45,11 +43,6 @@ const module$1 = defineNuxtModule({
|
|
|
45
43
|
mode: "server"
|
|
46
44
|
});
|
|
47
45
|
if (nuxt.options.dev) {
|
|
48
|
-
addServerHandler({
|
|
49
|
-
route: "/api/_i18now/sync",
|
|
50
|
-
handler: resolver.resolve("./runtime/server/sync"),
|
|
51
|
-
method: "post"
|
|
52
|
-
});
|
|
53
46
|
addPlugin({
|
|
54
47
|
src: resolver.resolve("./runtime/plugin.client"),
|
|
55
48
|
mode: "client"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineNuxtPlugin, useRuntimeConfig } from "#app";
|
|
2
2
|
function createI18nowSyncer(options) {
|
|
3
|
-
const { endpoint, debug = false, maxTracked = 2e3, maxRetries = 3 } = options;
|
|
3
|
+
const { endpoint, apiKey, debug = false, maxTracked = 2e3, maxRetries = 3 } = options;
|
|
4
4
|
const existingKeys = /* @__PURE__ */ new Set();
|
|
5
5
|
const synced = /* @__PURE__ */ new Set();
|
|
6
6
|
const retries = /* @__PURE__ */ new Map();
|
|
@@ -14,11 +14,11 @@ function createI18nowSyncer(options) {
|
|
|
14
14
|
fetch(endpoint, {
|
|
15
15
|
method: "POST",
|
|
16
16
|
headers: { "Content-Type": "application/json" },
|
|
17
|
-
body: JSON.stringify({ keys })
|
|
17
|
+
body: JSON.stringify({ apiKey, keys })
|
|
18
18
|
}).then((res) => {
|
|
19
19
|
if (!res.ok) {
|
|
20
20
|
if (debug) {
|
|
21
|
-
res.json().then((data) => console.warn(`[i18now] Sync failed (${res.status}):`, data?.statusMessage ?? data)).catch(() => console.warn(`[i18now] Sync failed with status ${res.status}`));
|
|
21
|
+
res.json().then((data) => console.warn(`[i18now] Sync failed (${res.status}):`, data?.error ?? data?.statusMessage ?? data)).catch(() => console.warn(`[i18now] Sync failed with status ${res.status}`));
|
|
22
22
|
}
|
|
23
23
|
throw Object.assign(new Error(`${res.status}`), { status: res.status });
|
|
24
24
|
}
|
|
@@ -54,7 +54,7 @@ function createI18nowSyncer(options) {
|
|
|
54
54
|
return { syncKey, existingKeys, setExistingKeys };
|
|
55
55
|
}
|
|
56
56
|
export default defineNuxtPlugin(async (nuxtApp) => {
|
|
57
|
-
const { projectId, cdnUrl, environment, syncIn, locale: configLocale } = useRuntimeConfig().public.i18now;
|
|
57
|
+
const { projectId, apiKey, host, cdnUrl, environment, syncIn, locale: configLocale } = useRuntimeConfig().public.i18now;
|
|
58
58
|
if (!syncIn.includes(process.env.NODE_ENV ?? "production")) return;
|
|
59
59
|
if (!projectId) {
|
|
60
60
|
console.warn("[i18now] projectId is not set \u2014 key sync disabled.");
|
|
@@ -62,7 +62,8 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
62
62
|
}
|
|
63
63
|
const i18nGlobal = nuxtApp.$i18n ?? nuxtApp.vueApp.config.globalProperties.$i18n;
|
|
64
64
|
const syncer = createI18nowSyncer({
|
|
65
|
-
endpoint:
|
|
65
|
+
endpoint: `${host}/api/v1/projects/${projectId}/sync`,
|
|
66
|
+
apiKey,
|
|
66
67
|
debug: import.meta.dev
|
|
67
68
|
});
|
|
68
69
|
const locale = i18nGlobal?.locale?.value ?? i18nGlobal?.locale ?? configLocale;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipkge/nuxt",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -12,16 +12,6 @@
|
|
|
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
|
-
},
|
|
25
15
|
"dependencies": {
|
|
26
16
|
"@nuxt/kit": "^3.0.0"
|
|
27
17
|
},
|
|
@@ -39,9 +29,18 @@
|
|
|
39
29
|
},
|
|
40
30
|
"devDependencies": {
|
|
41
31
|
"@nuxt/module-builder": "^1.0.0",
|
|
42
|
-
"@uipkge/core": "workspace:*",
|
|
43
32
|
"happy-dom": "^17.0.0",
|
|
44
33
|
"nuxt": "^3.0.0",
|
|
45
|
-
"vitest": "^4.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"
|
|
46
45
|
}
|
|
47
|
-
}
|
|
46
|
+
}
|