vite-intlayer 8.12.1 → 8.12.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/esm/IntlayerCompilerPlugin.mjs.map +1 -1
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/intlayerMinifyPlugin.mjs.map +1 -1
- package/dist/esm/intlayerNitroHandler.mjs +107 -0
- package/dist/esm/intlayerNitroHandler.mjs.map +1 -0
- package/dist/esm/intlayerOptimizePlugin.mjs +2 -2
- package/dist/esm/intlayerOptimizePlugin.mjs.map +1 -1
- package/dist/esm/intlayerPlugin.mjs.map +1 -1
- package/dist/esm/intlayerProxyPlugin.mjs +146 -77
- package/dist/esm/intlayerProxyPlugin.mjs.map +1 -1
- package/dist/esm/intlayerPrunePlugin.mjs.map +1 -1
- package/dist/esm/intlayerVueAsyncPlugin.mjs.map +1 -1
- package/dist/esm/pruneContext.mjs.map +1 -1
- package/dist/types/IntlayerCompilerPlugin.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/intlayerMinifyPlugin.d.ts.map +1 -1
- package/dist/types/intlayerNitroHandler.d.ts +57 -0
- package/dist/types/intlayerNitroHandler.d.ts.map +1 -0
- package/dist/types/intlayerOptimizePlugin.d.ts.map +1 -1
- package/dist/types/intlayerPlugin.d.ts.map +1 -1
- package/dist/types/intlayerProxyPlugin.d.ts +55 -6
- package/dist/types/intlayerProxyPlugin.d.ts.map +1 -1
- package/dist/types/intlayerPrunePlugin.d.ts.map +1 -1
- package/dist/types/intlayerVueAsyncPlugin.d.ts.map +1 -1
- package/dist/types/pruneContext.d.ts.map +1 -1
- package/package.json +20 -11
package/dist/types/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ import { IntlayerCompilerOptions, intlayerCompiler } from "./IntlayerCompilerPlu
|
|
|
2
2
|
import { intlayerMinify } from "./intlayerMinifyPlugin.js";
|
|
3
3
|
import { intlayerOptimize } from "./intlayerOptimizePlugin.js";
|
|
4
4
|
import { intLayerPlugin, intlayer, intlayerPlugin } from "./intlayerPlugin.js";
|
|
5
|
-
import { intLayerMiddlewarePlugin, intlayerMiddleware, intlayerProxy } from "./intlayerProxyPlugin.js";
|
|
5
|
+
import { createIntlayerProxyHandler, intLayerMiddlewarePlugin, intlayerMiddleware, intlayerProxy } from "./intlayerProxyPlugin.js";
|
|
6
6
|
import { intlayerPrune } from "./intlayerPrunePlugin.js";
|
|
7
|
-
export { IntlayerCompilerOptions, intLayerMiddlewarePlugin, intLayerPlugin, intlayer, intlayerCompiler, intlayerMiddleware, intlayerMinify, intlayerOptimize, intlayerPlugin, intlayerProxy, intlayerPrune };
|
|
7
|
+
export { IntlayerCompilerOptions, createIntlayerProxyHandler, intLayerMiddlewarePlugin, intLayerPlugin, intlayer, intlayerCompiler, intlayerMiddleware, intlayerMinify, intlayerOptimize, intlayerPlugin, intlayerProxy, intlayerPrune };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerMinifyPlugin.d.ts","names":[],"sources":["../../src/intlayerMinifyPlugin.ts"],"mappings":";;;;;;;AAiIA
|
|
1
|
+
{"version":3,"file":"intlayerMinifyPlugin.d.ts","names":[],"sources":["../../src/intlayerMinifyPlugin.ts"],"mappings":";;;;;;;AAiIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,cAAA,GACX,cAAA,EAAgB,cAAA,EAChB,YAAA,EAAc,YAAA,YACb,YAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
//#region src/intlayerNitroHandler.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Minimal duck-type for h3 v2's H3Event.
|
|
4
|
+
*
|
|
5
|
+
* We intentionally avoid importing from 'h3' to keep this file runtime-agnostic —
|
|
6
|
+
* Nitro bundles h3 internally and provides the populated event at runtime. Using a
|
|
7
|
+
* structural type here means the file compiles without h3 in devDependencies and
|
|
8
|
+
* works with any h3 v2-compatible runtime (Bun, Deno, Node).
|
|
9
|
+
*/
|
|
10
|
+
type H3EventLike = {
|
|
11
|
+
/**
|
|
12
|
+
* pathname + search — a computed getter on H3Event:
|
|
13
|
+
* `return this.url.pathname + this.url.search`
|
|
14
|
+
*/
|
|
15
|
+
readonly path: string;
|
|
16
|
+
/**
|
|
17
|
+
* Full URL object — a **plain property** (not a getter) on H3Event, safe to
|
|
18
|
+
* replace for internal URL rewrites. After assignment, `event.path` will
|
|
19
|
+
* automatically reflect the new pathname + search via the getter.
|
|
20
|
+
*/
|
|
21
|
+
url: URL;
|
|
22
|
+
/**
|
|
23
|
+
* Web Fetch API Headers — always populated in h3 v2 regardless of preset
|
|
24
|
+
* (Node, Bun, Deno). Use `.get(name)` instead of bracket-access.
|
|
25
|
+
*/
|
|
26
|
+
readonly headers: Headers;
|
|
27
|
+
/**
|
|
28
|
+
* Lazy response object — created on first access; its `headers` carry outgoing
|
|
29
|
+
* response headers (e.g. Set-Cookie) that h3 merges into the HTTP response.
|
|
30
|
+
*/
|
|
31
|
+
readonly res: {
|
|
32
|
+
readonly headers: Headers;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Native h3 v2 event handler for Nitro production servers (TanStack Start, Nuxt, etc.).
|
|
37
|
+
*
|
|
38
|
+
* Unlike `fromNodeMiddleware` (h3 v1 API), this handler uses the Web Fetch API event
|
|
39
|
+
* model exclusively and is therefore compatible with ALL Nitro presets — including Bun
|
|
40
|
+
* and Deno — where `event.node` is `undefined` and `fromNodeMiddleware` crashes with
|
|
41
|
+
* "undefined is not an object (evaluating 'event.node.req')".
|
|
42
|
+
*
|
|
43
|
+
* It bridges h3 v2 events to the Node.js-style `createIntlayerProxyHandler` middleware
|
|
44
|
+
* via lightweight IncomingMessage / ServerResponse shims:
|
|
45
|
+
*
|
|
46
|
+
* - **Redirect** (301 / 5xx): builds a Web API `Response` and returns it — Nitro sends
|
|
47
|
+
* the correct HTTP response to the browser.
|
|
48
|
+
* - **Rewrite** (`next()` + modified `req.url`): replaces `event.url` with the rewritten
|
|
49
|
+
* URL so `event.path` (a getter) returns the new pathname for downstream handlers and
|
|
50
|
+
* the Nitro router.
|
|
51
|
+
* - **Pass-through** (`next()`, URL unchanged): returns `undefined` — Nitro proceeds to
|
|
52
|
+
* the next handler / route.
|
|
53
|
+
*/
|
|
54
|
+
declare const _default: (event: H3EventLike) => Promise<Response | void>;
|
|
55
|
+
//#endregion
|
|
56
|
+
export { _default as default };
|
|
57
|
+
//# sourceMappingURL=intlayerNitroHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intlayerNitroHandler.d.ts","names":[],"sources":["../../src/intlayerNitroHandler.ts"],"mappings":";;;;;;;;;KAcK,WAAA;EAKM;;;;EAAA,SAAA,IAAA;EAgBA;;;;;EAVT,GAAA,EAAK,GAAA;EA0C4D;;;;EAAA,SArCxD,OAAA,EAAS,OAAA;EAqC8B;;;;EAAA,SAhCvC,GAAA;IAAA,SACE,OAAA,EAAS,OAAA;EAAA;AAAA;;;;;;;;;;;;;;;;;;;;cAAO,QAAA,GA+BP,KAAA,EAAO,WAAA,KAAc,OAAA,CAAQ,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerOptimizePlugin.d.ts","names":[],"sources":["../../src/intlayerOptimizePlugin.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"intlayerOptimizePlugin.d.ts","names":[],"sources":["../../src/intlayerOptimizePlugin.ts"],"mappings":";;;;;;;AAuDA;;;;;;;;;;;;;;;;;;;;cAAa,gBAAA,GACX,cAAA,EAAgB,cAAA,EAChB,YAAA,EAAc,YAAA,YACb,OAAA,CAAQ,YAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerPlugin.d.ts","names":[],"sources":["../../src/intlayerPlugin.ts"],"mappings":";;;;;;AA6CA
|
|
1
|
+
{"version":3,"file":"intlayerPlugin.d.ts","names":[],"sources":["../../src/intlayerPlugin.ts"],"mappings":";;;;;;AA6CA;;;;;;;;;AAoKA;;;;;;;;;AAaA;;;cAjLa,cAAA,GACX,aAAA,GAAgB,uBAAA,KACf,YAAA;;;;;;;;;;;cAkKU,QAAA,GAAQ,aAAA,GAnKH,uBAAA,KACf,YAAA;;;;;;;;;;;;;cA+KU,cAAA,GAAc,aAAA,GAhLT,uBAAA,KACf,YAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetConfigurationOptions } from "@intlayer/config/node";
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
|
-
import { IncomingMessage } from "node:http";
|
|
3
|
+
import { IncomingMessage, ServerResponse } from "node:http";
|
|
4
4
|
|
|
5
5
|
//#region src/intlayerProxyPlugin.d.ts
|
|
6
6
|
type IntlayerProxyPluginOptions = {
|
|
@@ -20,10 +20,59 @@ type IntlayerProxyPluginOptions = {
|
|
|
20
20
|
ignore?: (req: IncomingMessage) => boolean | undefined;
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* A Node.js-compatible Connect middleware function.
|
|
24
|
+
* Compatible with Vite dev/preview server, Node.js http, Express, and h3's
|
|
25
|
+
* `fromNodeMiddleware` wrapper for Nitro/TanStack Start production use.
|
|
26
|
+
*/
|
|
27
|
+
type NodeMiddleware = (req: IncomingMessage, res: ServerResponse<IncomingMessage>, next: () => void) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a standalone, framework-agnostic locale-routing middleware.
|
|
30
|
+
*
|
|
31
|
+
* This function contains all the locale detection, redirect, and rewrite logic.
|
|
32
|
+
* It is intentionally separated from the Vite plugin so the same handler can be
|
|
33
|
+
* used in every environment:
|
|
34
|
+
*
|
|
35
|
+
* - **Dev**: wired up automatically by `intlayerProxy` via `configureServer`
|
|
36
|
+
* - **Preview**: wired up automatically by `intlayerProxy` via `configurePreviewServer`
|
|
37
|
+
* - **Production (Nitro / TanStack Start)**: create `server/middleware/intlayerProxy.ts`:
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* // server/middleware/intlayerProxy.ts
|
|
42
|
+
* import { fromNodeMiddleware } from 'h3';
|
|
43
|
+
* import { createIntlayerProxyHandler } from 'vite-intlayer';
|
|
24
44
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
45
|
+
* export default fromNodeMiddleware(createIntlayerProxyHandler());
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @param configOptions - Optional Intlayer configuration overrides.
|
|
49
|
+
* @param options - Plugin-specific options, such as path ignoring.
|
|
50
|
+
* @returns A Connect-compatible `(req, res, next) => void` middleware.
|
|
51
|
+
*/
|
|
52
|
+
declare const createIntlayerProxyHandler: (configOptions?: GetConfigurationOptions, options?: IntlayerProxyPluginOptions) => NodeMiddleware;
|
|
53
|
+
/**
|
|
54
|
+
* Vite plugin that provides locale-based routing middleware for **all environments**:
|
|
55
|
+
* development, preview, and production SSR (Nitro / TanStack Start).
|
|
56
|
+
*
|
|
57
|
+
* - **Dev** (`vite dev`): registered via `configureServer`.
|
|
58
|
+
* - **Preview** (`vite preview`): registered via `configurePreviewServer`.
|
|
59
|
+
* - **Production Nitro** (`vite build`): automatically injected via the `.nitro` module
|
|
60
|
+
* property that `nitro/vite` reads and pushes into `nitroConfig.modules`. The module
|
|
61
|
+
* registers `intlayerNitroHandler` as a Nitro server middleware — no extra user config
|
|
62
|
+
* needed.
|
|
63
|
+
*
|
|
64
|
+
* If you need custom config options or an `ignore` predicate in production, bypass
|
|
65
|
+
* auto-injection and create a server middleware file manually:
|
|
66
|
+
*
|
|
67
|
+
* ```ts
|
|
68
|
+
* // server/middleware/intlayerProxy.ts
|
|
69
|
+
* import { fromNodeMiddleware } from 'h3';
|
|
70
|
+
* import { createIntlayerProxyHandler } from 'vite-intlayer';
|
|
71
|
+
*
|
|
72
|
+
* export default fromNodeMiddleware(
|
|
73
|
+
* createIntlayerProxyHandler(myConfig, { ignore: (req) => req.url?.startsWith('/api') })
|
|
74
|
+
* );
|
|
75
|
+
* ```
|
|
27
76
|
*
|
|
28
77
|
* @param configOptions - Optional configuration for Intlayer.
|
|
29
78
|
* @param options - Plugin-specific options, like ignoring certain paths.
|
|
@@ -56,7 +105,7 @@ declare const intlayerMiddleware: (configOptions?: GetConfigurationOptions, opti
|
|
|
56
105
|
* @deprecated Rename to intlayerProxy instead
|
|
57
106
|
*
|
|
58
107
|
* A Vite plugin that integrates a logic similar to the Next.js intlayer middleware.
|
|
59
|
-
|
|
108
|
+
*
|
|
60
109
|
* ```ts
|
|
61
110
|
* // Example usage of the plugin in a Vite configuration
|
|
62
111
|
* export default defineConfig({
|
|
@@ -66,5 +115,5 @@ declare const intlayerMiddleware: (configOptions?: GetConfigurationOptions, opti
|
|
|
66
115
|
*/
|
|
67
116
|
declare const intLayerMiddlewarePlugin: (configOptions?: GetConfigurationOptions, options?: IntlayerProxyPluginOptions) => Plugin;
|
|
68
117
|
//#endregion
|
|
69
|
-
export { intLayerMiddlewarePlugin, intlayerMiddleware, intlayerProxy };
|
|
118
|
+
export { createIntlayerProxyHandler, intLayerMiddlewarePlugin, intlayerMiddleware, intlayerProxy };
|
|
70
119
|
//# sourceMappingURL=intlayerProxyPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerProxyPlugin.d.ts","names":[],"sources":["../../src/intlayerProxyPlugin.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"intlayerProxyPlugin.d.ts","names":[],"sources":["../../src/intlayerProxyPlugin.ts"],"mappings":";;;;;KAwBK,0BAAA;;AAFuC;;;;;;;;;AAgBZ;;;EAA9B,MAAA,IAAU,GAAA,EAAK,eAAA;AAAA;;;;;;KAQZ,cAAA,IACH,GAAA,EAAK,eAAA,EACL,GAAA,EAAK,cAAA,CAAe,eAAA,GACpB,IAAA;;;;;;AA2BF;;;;;;;;;;;;;;;AAowBA;;;;cApwBa,0BAAA,GACX,aAAA,GAAgB,uBAAA,EAChB,OAAA,GAAU,0BAAA,KACT,cAAA;;;;;;;;;;;AAq1BH;;;;;;;;;;;;;;;AAcA;;;;;;;;;;;;cAlGa,aAAA,GACX,aAAA,GAAgB,uBAAA,EAChB,OAAA,GAAU,0BAAA,KACT,MAAA;;;;;;;;;;;;;cAiFU,kBAAA,GAAkB,aAAA,GAnFb,uBAAA,EAAuB,OAAA,GAC7B,0BAAA,KACT,MAAA;;;;;;;;;;;;;cA+FU,wBAAA,GAAwB,aAAA,GAjGnB,uBAAA,EAAuB,OAAA,GAC7B,0BAAA,KACT,MAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerPrunePlugin.d.ts","names":[],"sources":["../../src/intlayerPrunePlugin.ts"],"mappings":";;;;;;;AA4MA
|
|
1
|
+
{"version":3,"file":"intlayerPrunePlugin.d.ts","names":[],"sources":["../../src/intlayerPrunePlugin.ts"],"mappings":";;;;;;;AA4MA;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,aAAA,GACX,cAAA,EAAgB,cAAA,EAChB,YAAA,EAAc,YAAA,KACb,YAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerVueAsyncPlugin.d.ts","names":[],"sources":["../../src/intlayerVueAsyncPlugin.ts"],"mappings":";;;;cAGa,sBAAA,GACX,aAAA,EAAe,cAAA,EACf,SAAA,eACC,
|
|
1
|
+
{"version":3,"file":"intlayerVueAsyncPlugin.d.ts","names":[],"sources":["../../src/intlayerVueAsyncPlugin.ts"],"mappings":";;;;cAGa,sBAAA,GACX,aAAA,EAAe,cAAA,EACf,SAAA,eACC,YAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pruneContext.d.ts","names":[],"sources":["../../src/pruneContext.ts"],"mappings":";;;cAQa,kBAAA,QAAyB,
|
|
1
|
+
{"version":3,"file":"pruneContext.d.ts","names":[],"sources":["../../src/pruneContext.ts"],"mappings":";;;cAQa,kBAAA,QAAyB,YAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-intlayer",
|
|
3
|
-
"version": "8.12.
|
|
3
|
+
"version": "8.12.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A Vite plugin for seamless internationalization (i18n), providing locale detection, redirection, and environment-based configuration",
|
|
6
6
|
"keywords": [
|
|
@@ -42,6 +42,11 @@
|
|
|
42
42
|
"import": "./dist/esm/index.mjs",
|
|
43
43
|
"default": "./dist/esm/index.mjs"
|
|
44
44
|
},
|
|
45
|
+
"./nitro-handler": {
|
|
46
|
+
"types": "./dist/types/intlayerNitroHandler.d.ts",
|
|
47
|
+
"import": "./dist/esm/intlayerNitroHandler.mjs",
|
|
48
|
+
"default": "./dist/esm/intlayerNitroHandler.mjs"
|
|
49
|
+
},
|
|
45
50
|
"./package.json": "./package.json"
|
|
46
51
|
},
|
|
47
52
|
"main": "./dist/esm/index.mjs",
|
|
@@ -76,27 +81,28 @@
|
|
|
76
81
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
77
82
|
},
|
|
78
83
|
"dependencies": {
|
|
79
|
-
"@intlayer/babel": "8.12.
|
|
80
|
-
"@intlayer/chokidar": "8.12.
|
|
81
|
-
"@intlayer/config": "8.12.
|
|
82
|
-
"@intlayer/core": "8.12.
|
|
83
|
-
"@intlayer/dictionaries-entry": "8.12.
|
|
84
|
-
"@intlayer/types": "8.12.
|
|
84
|
+
"@intlayer/babel": "8.12.3",
|
|
85
|
+
"@intlayer/chokidar": "8.12.3",
|
|
86
|
+
"@intlayer/config": "8.12.3",
|
|
87
|
+
"@intlayer/core": "8.12.3",
|
|
88
|
+
"@intlayer/dictionaries-entry": "8.12.3",
|
|
89
|
+
"@intlayer/types": "8.12.3"
|
|
85
90
|
},
|
|
86
91
|
"devDependencies": {
|
|
87
|
-
"@types/node": "25.9.
|
|
92
|
+
"@types/node": "25.9.2",
|
|
88
93
|
"@utils/ts-config": "1.0.4",
|
|
89
94
|
"@utils/ts-config-types": "1.0.4",
|
|
90
95
|
"@utils/tsdown-config": "1.0.4",
|
|
91
96
|
"rimraf": "6.1.3",
|
|
92
|
-
"tsdown": "0.
|
|
97
|
+
"tsdown": "0.21.10",
|
|
93
98
|
"typescript": "6.0.3",
|
|
94
99
|
"vitest": "4.1.8"
|
|
95
100
|
},
|
|
96
101
|
"peerDependencies": {
|
|
97
102
|
"@babel/core": ">=6.0.0",
|
|
98
|
-
"@intlayer/svelte-compiler": "8.12.
|
|
99
|
-
"@intlayer/vue-compiler": "8.12.
|
|
103
|
+
"@intlayer/svelte-compiler": "8.12.3",
|
|
104
|
+
"@intlayer/vue-compiler": "8.12.3",
|
|
105
|
+
"h3": ">=1.0.0",
|
|
100
106
|
"vite": ">=4.0.0"
|
|
101
107
|
},
|
|
102
108
|
"peerDependenciesMeta": {
|
|
@@ -108,6 +114,9 @@
|
|
|
108
114
|
},
|
|
109
115
|
"@intlayer/vue-compiler": {
|
|
110
116
|
"optional": true
|
|
117
|
+
},
|
|
118
|
+
"h3": {
|
|
119
|
+
"optional": true
|
|
111
120
|
}
|
|
112
121
|
},
|
|
113
122
|
"engines": {
|