@luwiostack/router 0.1.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.
- package/README.md +780 -0
- package/dist/index.cjs +8116 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +3131 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +3131 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +8069 -0
- package/dist/index.mjs.map +1 -0
- package/dist/vite.cjs +41 -0
- package/dist/vite.cjs.map +1 -0
- package/dist/vite.d.cts +40 -0
- package/dist/vite.d.cts.map +1 -0
- package/dist/vite.d.mts +40 -0
- package/dist/vite.d.mts.map +1 -0
- package/dist/vite.mjs +40 -0
- package/dist/vite.mjs.map +1 -0
- package/package.json +92 -0
- package/vite-client.d.ts +10 -0
package/dist/vite.cjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _luwiostack_registry_vite = require("@luwiostack/registry/vite");
|
|
3
|
+
//#region src/vite.ts
|
|
4
|
+
/**
|
|
5
|
+
* Vite plugin that auto-discovers route files so they self-register — no glob in your app code.
|
|
6
|
+
*
|
|
7
|
+
* Scans `dir` for `*.route.{ts,tsx,js,jsx}` files and exposes a virtual module that collects
|
|
8
|
+
* each one's exported route(s) via `registerModules`. Import it once, before you call `createRouter`:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* // vite.config.ts
|
|
12
|
+
* import { luwioRouter } from '@luwiostack/router/vite'
|
|
13
|
+
* export default defineConfig({ plugins: [luwioRouter()] })
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* // router.ts
|
|
18
|
+
* import 'virtual:@luwiostack/router/routes' // every *.route file is now registered
|
|
19
|
+
* import { createRouter, routeRegistry } from '@luwiostack/router'
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Adding, removing, or editing a route file triggers a full reload so the registry is rebuilt
|
|
23
|
+
* cleanly (its `add()` throws on duplicates, so stale entries must not linger). Keep route files
|
|
24
|
+
* thin — put components in their own modules — so day-to-day component edits keep fast HMR.
|
|
25
|
+
*
|
|
26
|
+
* Built on `@luwiostack/registry`'s shared `createRegistryPlugin` — the same scanner behind
|
|
27
|
+
* `@luwiostack/http`'s `luwioApi`.
|
|
28
|
+
*/
|
|
29
|
+
function luwioRouter(options = {}) {
|
|
30
|
+
return (0, _luwiostack_registry_vite.createRegistryPlugin)({
|
|
31
|
+
name: "@luwiostack/router",
|
|
32
|
+
dir: options.dir ?? "src",
|
|
33
|
+
suffix: options.suffix ?? ".route",
|
|
34
|
+
virtualId: options.virtualId ?? "virtual:@luwiostack/router/routes",
|
|
35
|
+
registerImport: "@luwiostack/router"
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
exports.luwioRouter = luwioRouter;
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=vite.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.cjs","names":["createRegistryPlugin"],"sources":["../src/vite.ts"],"sourcesContent":["import { createRegistryPlugin } from '@luwiostack/registry/vite'\nimport type { Plugin } from 'vite'\n\n/** Options for the {@link luwioRouter} Vite plugin. */\nexport interface LuwioRouterPluginOptions {\n /** Directory scanned for route files (recursively), relative to the Vite root. Default: `'src'`. */\n dir?: string\n /** Filename suffix that marks a route module (before the extension). Default: `'.route'`. */\n suffix?: string\n /** The virtual module id imported once to load every route. Default: `'virtual:@luwiostack/router/routes'`. */\n virtualId?: string\n}\n\n/**\n * Vite plugin that auto-discovers route files so they self-register — no glob in your app code.\n *\n * Scans `dir` for `*.route.{ts,tsx,js,jsx}` files and exposes a virtual module that collects\n * each one's exported route(s) via `registerModules`. Import it once, before you call `createRouter`:\n *\n * ```ts\n * // vite.config.ts\n * import { luwioRouter } from '@luwiostack/router/vite'\n * export default defineConfig({ plugins: [luwioRouter()] })\n * ```\n *\n * ```ts\n * // router.ts\n * import 'virtual:@luwiostack/router/routes' // every *.route file is now registered\n * import { createRouter, routeRegistry } from '@luwiostack/router'\n * ```\n *\n * Adding, removing, or editing a route file triggers a full reload so the registry is rebuilt\n * cleanly (its `add()` throws on duplicates, so stale entries must not linger). Keep route files\n * thin — put components in their own modules — so day-to-day component edits keep fast HMR.\n *\n * Built on `@luwiostack/registry`'s shared `createRegistryPlugin` — the same scanner behind\n * `@luwiostack/http`'s `luwioApi`.\n */\nexport function luwioRouter(options: LuwioRouterPluginOptions = {}): Plugin {\n return createRegistryPlugin({\n name: '@luwiostack/router',\n dir: options.dir ?? 'src',\n suffix: options.suffix ?? '.route',\n virtualId: options.virtualId ?? 'virtual:@luwiostack/router/routes',\n registerImport: '@luwiostack/router',\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,YAAY,UAAoC,CAAC,GAAW;CAC1E,QAAA,GAAOA,0BAAAA,qBAAAA,CAAqB;EAC1B,MAAM;EACN,KAAK,QAAQ,OAAO;EACpB,QAAQ,QAAQ,UAAU;EAC1B,WAAW,QAAQ,aAAa;EAChC,gBAAgB;CAClB,CAAC;AACH"}
|
package/dist/vite.d.cts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
//#region src/vite.d.ts
|
|
3
|
+
/** Options for the {@link luwioRouter} Vite plugin. */
|
|
4
|
+
interface LuwioRouterPluginOptions {
|
|
5
|
+
/** Directory scanned for route files (recursively), relative to the Vite root. Default: `'src'`. */
|
|
6
|
+
dir?: string;
|
|
7
|
+
/** Filename suffix that marks a route module (before the extension). Default: `'.route'`. */
|
|
8
|
+
suffix?: string;
|
|
9
|
+
/** The virtual module id imported once to load every route. Default: `'virtual:@luwiostack/router/routes'`. */
|
|
10
|
+
virtualId?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Vite plugin that auto-discovers route files so they self-register — no glob in your app code.
|
|
14
|
+
*
|
|
15
|
+
* Scans `dir` for `*.route.{ts,tsx,js,jsx}` files and exposes a virtual module that collects
|
|
16
|
+
* each one's exported route(s) via `registerModules`. Import it once, before you call `createRouter`:
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* // vite.config.ts
|
|
20
|
+
* import { luwioRouter } from '@luwiostack/router/vite'
|
|
21
|
+
* export default defineConfig({ plugins: [luwioRouter()] })
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* // router.ts
|
|
26
|
+
* import 'virtual:@luwiostack/router/routes' // every *.route file is now registered
|
|
27
|
+
* import { createRouter, routeRegistry } from '@luwiostack/router'
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* Adding, removing, or editing a route file triggers a full reload so the registry is rebuilt
|
|
31
|
+
* cleanly (its `add()` throws on duplicates, so stale entries must not linger). Keep route files
|
|
32
|
+
* thin — put components in their own modules — so day-to-day component edits keep fast HMR.
|
|
33
|
+
*
|
|
34
|
+
* Built on `@luwiostack/registry`'s shared `createRegistryPlugin` — the same scanner behind
|
|
35
|
+
* `@luwiostack/http`'s `luwioApi`.
|
|
36
|
+
*/
|
|
37
|
+
declare function luwioRouter(options?: LuwioRouterPluginOptions): Plugin;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { LuwioRouterPluginOptions, luwioRouter };
|
|
40
|
+
//# sourceMappingURL=vite.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.d.cts","names":[],"sources":["../src/vite.ts"],"mappings":";;;UAIiB;;EAEf;;EAEA;;EAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4Bc,YAAY,UAAS,2BAAgC"}
|
package/dist/vite.d.mts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
//#region src/vite.d.ts
|
|
3
|
+
/** Options for the {@link luwioRouter} Vite plugin. */
|
|
4
|
+
interface LuwioRouterPluginOptions {
|
|
5
|
+
/** Directory scanned for route files (recursively), relative to the Vite root. Default: `'src'`. */
|
|
6
|
+
dir?: string;
|
|
7
|
+
/** Filename suffix that marks a route module (before the extension). Default: `'.route'`. */
|
|
8
|
+
suffix?: string;
|
|
9
|
+
/** The virtual module id imported once to load every route. Default: `'virtual:@luwiostack/router/routes'`. */
|
|
10
|
+
virtualId?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Vite plugin that auto-discovers route files so they self-register — no glob in your app code.
|
|
14
|
+
*
|
|
15
|
+
* Scans `dir` for `*.route.{ts,tsx,js,jsx}` files and exposes a virtual module that collects
|
|
16
|
+
* each one's exported route(s) via `registerModules`. Import it once, before you call `createRouter`:
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* // vite.config.ts
|
|
20
|
+
* import { luwioRouter } from '@luwiostack/router/vite'
|
|
21
|
+
* export default defineConfig({ plugins: [luwioRouter()] })
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* // router.ts
|
|
26
|
+
* import 'virtual:@luwiostack/router/routes' // every *.route file is now registered
|
|
27
|
+
* import { createRouter, routeRegistry } from '@luwiostack/router'
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* Adding, removing, or editing a route file triggers a full reload so the registry is rebuilt
|
|
31
|
+
* cleanly (its `add()` throws on duplicates, so stale entries must not linger). Keep route files
|
|
32
|
+
* thin — put components in their own modules — so day-to-day component edits keep fast HMR.
|
|
33
|
+
*
|
|
34
|
+
* Built on `@luwiostack/registry`'s shared `createRegistryPlugin` — the same scanner behind
|
|
35
|
+
* `@luwiostack/http`'s `luwioApi`.
|
|
36
|
+
*/
|
|
37
|
+
declare function luwioRouter(options?: LuwioRouterPluginOptions): Plugin;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { LuwioRouterPluginOptions, luwioRouter };
|
|
40
|
+
//# sourceMappingURL=vite.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.d.mts","names":[],"sources":["../src/vite.ts"],"mappings":";;;UAIiB;;EAEf;;EAEA;;EAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4Bc,YAAY,UAAS,2BAAgC"}
|
package/dist/vite.mjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createRegistryPlugin } from "@luwiostack/registry/vite";
|
|
2
|
+
//#region src/vite.ts
|
|
3
|
+
/**
|
|
4
|
+
* Vite plugin that auto-discovers route files so they self-register — no glob in your app code.
|
|
5
|
+
*
|
|
6
|
+
* Scans `dir` for `*.route.{ts,tsx,js,jsx}` files and exposes a virtual module that collects
|
|
7
|
+
* each one's exported route(s) via `registerModules`. Import it once, before you call `createRouter`:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* // vite.config.ts
|
|
11
|
+
* import { luwioRouter } from '@luwiostack/router/vite'
|
|
12
|
+
* export default defineConfig({ plugins: [luwioRouter()] })
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* // router.ts
|
|
17
|
+
* import 'virtual:@luwiostack/router/routes' // every *.route file is now registered
|
|
18
|
+
* import { createRouter, routeRegistry } from '@luwiostack/router'
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Adding, removing, or editing a route file triggers a full reload so the registry is rebuilt
|
|
22
|
+
* cleanly (its `add()` throws on duplicates, so stale entries must not linger). Keep route files
|
|
23
|
+
* thin — put components in their own modules — so day-to-day component edits keep fast HMR.
|
|
24
|
+
*
|
|
25
|
+
* Built on `@luwiostack/registry`'s shared `createRegistryPlugin` — the same scanner behind
|
|
26
|
+
* `@luwiostack/http`'s `luwioApi`.
|
|
27
|
+
*/
|
|
28
|
+
function luwioRouter(options = {}) {
|
|
29
|
+
return createRegistryPlugin({
|
|
30
|
+
name: "@luwiostack/router",
|
|
31
|
+
dir: options.dir ?? "src",
|
|
32
|
+
suffix: options.suffix ?? ".route",
|
|
33
|
+
virtualId: options.virtualId ?? "virtual:@luwiostack/router/routes",
|
|
34
|
+
registerImport: "@luwiostack/router"
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { luwioRouter };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=vite.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.mjs","names":[],"sources":["../src/vite.ts"],"sourcesContent":["import { createRegistryPlugin } from '@luwiostack/registry/vite'\nimport type { Plugin } from 'vite'\n\n/** Options for the {@link luwioRouter} Vite plugin. */\nexport interface LuwioRouterPluginOptions {\n /** Directory scanned for route files (recursively), relative to the Vite root. Default: `'src'`. */\n dir?: string\n /** Filename suffix that marks a route module (before the extension). Default: `'.route'`. */\n suffix?: string\n /** The virtual module id imported once to load every route. Default: `'virtual:@luwiostack/router/routes'`. */\n virtualId?: string\n}\n\n/**\n * Vite plugin that auto-discovers route files so they self-register — no glob in your app code.\n *\n * Scans `dir` for `*.route.{ts,tsx,js,jsx}` files and exposes a virtual module that collects\n * each one's exported route(s) via `registerModules`. Import it once, before you call `createRouter`:\n *\n * ```ts\n * // vite.config.ts\n * import { luwioRouter } from '@luwiostack/router/vite'\n * export default defineConfig({ plugins: [luwioRouter()] })\n * ```\n *\n * ```ts\n * // router.ts\n * import 'virtual:@luwiostack/router/routes' // every *.route file is now registered\n * import { createRouter, routeRegistry } from '@luwiostack/router'\n * ```\n *\n * Adding, removing, or editing a route file triggers a full reload so the registry is rebuilt\n * cleanly (its `add()` throws on duplicates, so stale entries must not linger). Keep route files\n * thin — put components in their own modules — so day-to-day component edits keep fast HMR.\n *\n * Built on `@luwiostack/registry`'s shared `createRegistryPlugin` — the same scanner behind\n * `@luwiostack/http`'s `luwioApi`.\n */\nexport function luwioRouter(options: LuwioRouterPluginOptions = {}): Plugin {\n return createRegistryPlugin({\n name: '@luwiostack/router',\n dir: options.dir ?? 'src',\n suffix: options.suffix ?? '.route',\n virtualId: options.virtualId ?? 'virtual:@luwiostack/router/routes',\n registerImport: '@luwiostack/router',\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,YAAY,UAAoC,CAAC,GAAW;CAC1E,OAAO,qBAAqB;EAC1B,MAAM;EACN,KAAK,QAAQ,OAAO;EACpB,QAAQ,QAAQ,UAAU;EAC1B,WAAW,QAAQ,aAAa;EAChC,gBAAgB;CAClB,CAAC;AACH"}
|
package/package.json
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@luwiostack/router",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Locale-aware route registry for TanStack Router — one file per route, translated URL segments per locale.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"router",
|
|
8
|
+
"routing",
|
|
9
|
+
"tanstack",
|
|
10
|
+
"tanstack-router",
|
|
11
|
+
"i18n",
|
|
12
|
+
"locale",
|
|
13
|
+
"luwio"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/Tactics/LuwioStack.git",
|
|
19
|
+
"directory": "packages/router"
|
|
20
|
+
},
|
|
21
|
+
"type": "module",
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"vite-client.d.ts"
|
|
26
|
+
],
|
|
27
|
+
"main": "./dist/index.cjs",
|
|
28
|
+
"module": "./dist/index.mjs",
|
|
29
|
+
"types": "./dist/index.d.cts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"import": {
|
|
33
|
+
"types": "./dist/index.d.mts",
|
|
34
|
+
"default": "./dist/index.mjs"
|
|
35
|
+
},
|
|
36
|
+
"require": {
|
|
37
|
+
"types": "./dist/index.d.cts",
|
|
38
|
+
"default": "./dist/index.cjs"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"./vite": {
|
|
42
|
+
"import": {
|
|
43
|
+
"types": "./dist/vite.d.mts",
|
|
44
|
+
"default": "./dist/vite.mjs"
|
|
45
|
+
},
|
|
46
|
+
"require": {
|
|
47
|
+
"types": "./dist/vite.d.cts",
|
|
48
|
+
"default": "./dist/vite.cjs"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"./vite-client": {
|
|
52
|
+
"types": "./vite-client.d.ts"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public",
|
|
57
|
+
"provenance": true
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"use-sync-external-store": "^1.2.0",
|
|
61
|
+
"@luwiostack/locale": "0.1.0",
|
|
62
|
+
"@luwiostack/registry": "0.1.0"
|
|
63
|
+
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"react": ">=18",
|
|
66
|
+
"vite": ">=5"
|
|
67
|
+
},
|
|
68
|
+
"peerDependenciesMeta": {
|
|
69
|
+
"vite": {
|
|
70
|
+
"optional": true
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@tanstack/react-router": "^1.170.30",
|
|
75
|
+
"@testing-library/react": "^16.3.2",
|
|
76
|
+
"@types/node": "^26.2.0",
|
|
77
|
+
"@types/react": "^19.2.18",
|
|
78
|
+
"@types/react-dom": "^19.2.4",
|
|
79
|
+
"happy-dom": "^20.11.2",
|
|
80
|
+
"react": "^19.2.8",
|
|
81
|
+
"react-dom": "^19.2.8",
|
|
82
|
+
"vite": "^8.2.1"
|
|
83
|
+
},
|
|
84
|
+
"scripts": {
|
|
85
|
+
"build": "tsdown",
|
|
86
|
+
"dev": "tsdown --watch --no-clean",
|
|
87
|
+
"test": "vitest run",
|
|
88
|
+
"bench": "vitest bench",
|
|
89
|
+
"lint": "biome check .",
|
|
90
|
+
"typecheck": "tsc --noEmit"
|
|
91
|
+
}
|
|
92
|
+
}
|
package/vite-client.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ambient type for the virtual module created by the `@luwiostack/router/vite` plugin.
|
|
3
|
+
*
|
|
4
|
+
* Reference it once in your app (e.g. in `vite-env.d.ts`):
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* /// <reference types="@luwiostack/router/vite-client" />
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
declare module 'virtual:@luwiostack/router/routes' {}
|