nuxt-i18n-micro 1.36.1 → 1.37.0

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.
@@ -1,12 +1,12 @@
1
1
  <!DOCTYPE html><html data-capo=""><head><meta charset="utf-8">
2
2
  <meta name="viewport" content="width=device-width, initial-scale=1">
3
- <link rel="stylesheet" href="/__nuxt-i18n-micro/_nuxt/entry.BWujgj23.css" crossorigin>
4
- <link rel="modulepreload" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/Bi0F1qle.js">
5
- <link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/B6E6ObS_.js">
6
- <link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-404.SWzu_puR.css">
7
- <link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/BSIK_tlD.js">
8
- <link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/Bg-EgkMt.js">
9
- <link rel="prefetch" as="style" crossorigin href="/__nuxt-i18n-micro/_nuxt/error-500.Bkv_zTjr.css">
10
- <link rel="prefetch" as="script" crossorigin href="/__nuxt-i18n-micro/_nuxt/B-rdPz5C.js">
11
- <script type="module" src="/__nuxt-i18n-micro/_nuxt/Bi0F1qle.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1733172240437,false]</script>
12
- <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__nuxt-i18n-micro",buildId:"c0d0f579-bc8e-401c-b344-5ab0f1c7c077",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
3
+ <link rel="stylesheet" href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/entry.BWujgj23.css" crossorigin>
4
+ <link rel="modulepreload" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/n4MbYZHF.js">
5
+ <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/B6E6ObS_.js">
6
+ <link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-404.SWzu_puR.css">
7
+ <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/Ltm7XuUs.js">
8
+ <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/CBccCxXK.js">
9
+ <link rel="prefetch" as="style" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/error-500.Bkv_zTjr.css">
10
+ <link rel="prefetch" as="script" crossorigin href="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/DNen4El9.js">
11
+ <script type="module" src="/__NUXT_DEVTOOLS_I18N_BASE__/_nuxt/n4MbYZHF.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1733208468833,false]</script>
12
+ <script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__NUXT_DEVTOOLS_I18N_BASE__/",buildId:"d48170a8-5b86-44b8-8103-1aa6250c5f55",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-i18n-micro",
3
3
  "configKey": "i18n",
4
- "version": "1.36.1",
4
+ "version": "1.37.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -1,20 +1,41 @@
1
- import path from 'node:path';
1
+ import path, { resolve } from 'node:path';
2
2
  import * as fs from 'node:fs';
3
3
  import fs__default, { readFileSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';
4
4
  import { useNuxt, defineNuxtModule, useLogger, createResolver, addTemplate, addPlugin, addImportsDir, addServerHandler, addComponentsDir, addTypeTemplate, extendPages, addPrerenderRoutes } from '@nuxt/kit';
5
5
  import { watch } from 'chokidar';
6
+ import { fileURLToPath } from 'node:url';
6
7
  import { onDevToolsInitialized, extendServerRpc } from '@nuxt/devtools-kit';
8
+ import sirv from 'sirv';
7
9
 
8
10
  const DEVTOOLS_UI_PORT = 3030;
9
11
  const DEVTOOLS_UI_ROUTE = "/__nuxt-i18n-micro";
10
- function setupDevToolsUI(options, resolve) {
12
+ const distDir = resolve(fileURLToPath(import.meta.url), "..");
13
+ const clientDir = resolve(distDir, "client");
14
+ function setupDevToolsUI(options, resolve2) {
11
15
  const nuxt = useNuxt();
12
- const clientPath = resolve("./client");
13
- const isProductionBuild = fs.existsSync(clientPath);
14
- if (isProductionBuild) {
15
- nuxt.hook("vite:serverCreated", async (server) => {
16
- const sirv = await import('sirv').then((r) => r.default || r);
17
- server.middlewares.use(DEVTOOLS_UI_ROUTE, sirv(clientPath, { dev: true, single: true }));
16
+ const clientPath = resolve2("./client");
17
+ const clientDirExists = fs.existsSync(clientPath);
18
+ const ROUTE_PATH = `${nuxt.options.app.baseURL || "/"}/__nuxt-i18n-micro`.replace(/\/+/g, "/");
19
+ const ROUTE_CLIENT = `${ROUTE_PATH}/client`;
20
+ if (clientDirExists) {
21
+ nuxt.hook("vite:serverCreated", (server) => {
22
+ const indexHtmlPath = path.join(clientDir, "index.html");
23
+ const indexContent = fs.readFileSync(indexHtmlPath);
24
+ const handleStatic = sirv(clientDir, {
25
+ dev: true,
26
+ single: false
27
+ });
28
+ const handleIndex = async (res) => {
29
+ res.setHeader("Content-Type", "text/html");
30
+ res.statusCode = 200;
31
+ res.write((await indexContent).toString().replace(/\/__NUXT_DEVTOOLS_I18N_BASE__\//g, `${ROUTE_CLIENT}/`));
32
+ res.end();
33
+ };
34
+ server.middlewares.use(ROUTE_CLIENT, (req, res) => {
35
+ if (req.url === "/")
36
+ return handleIndex(res);
37
+ return handleStatic(req, res, () => handleIndex(res));
38
+ });
18
39
  });
19
40
  } else {
20
41
  nuxt.hook("vite:extendConfig", (config) => {
@@ -81,7 +102,7 @@ function setupDevToolsUI(options, resolve) {
81
102
  icon: "carbon:language",
82
103
  view: {
83
104
  type: "iframe",
84
- src: DEVTOOLS_UI_ROUTE
105
+ src: ROUTE_CLIENT
85
106
  }
86
107
  });
87
108
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-i18n-micro",
3
- "version": "1.36.1",
3
+ "version": "1.37.0",
4
4
  "description": "Nuxt I18n Micro is a lightweight, high-performance internationalization module for Nuxt, designed to handle multi-language support with minimal overhead, fast build times, and efficient runtime performance.",
5
5
  "repository": "s00d/nuxt-i18n-micro",
6
6
  "license": "MIT",