dinou 8.0.1 → 8.0.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/CHANGELOG.md +11 -0
- package/README.md +23 -7
- package/dinou/core/generate-route-types.js +1 -14
- package/dinou/core/load-dinou-config.js +10 -0
- package/dinou/index.d.ts +9 -3
- package/dinou/package.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
7
7
|
|
|
8
|
+
## [8.0.3] - 2026-10-22
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- **Type-Safe Route Pattern Autocompletion in Segment Configs**: Added generic constraints (`TRouteOrParams extends DinouRoutePattern | object = any`) to `PageFunctions` and `LayoutFunctions`, as well as `RouteParams<T extends DinouRoutePattern = DinouRoutePattern>`. This enables immediate IDE / TypeScript autocompletion for known project routes when typing string literals (`PageFunctions<"..."`) and strict compile-time validation against typos in route strings, while preserving full backward compatibility for parameter dictionaries and custom interfaces (`PageFunctions<CustomParams>`).
|
|
12
|
+
- **Direct `defineConfig` Import from `"dinou"`**: Added an esbuild resolution plugin (`dinou-config-alias`) in `load-dinou-config.js` to alias exact `"dinou"` specifier imports to `"dinou/config"` when bundling configuration files (`dinou.config.ts`, `dinou.config.mjs`, etc.). This allows importing `defineConfig` directly from `"dinou"` (`import { defineConfig } from "dinou"`) without triggering Node.js native ESM `ERR_UNKNOWN_FILE_EXTENSION` errors from unbundled React JSX components (`redirect.jsx`, `link.jsx`) in `dinou/index.js`, while keeping all other subpath imports (`dinou/adapters/*`, `dinou/config`) intact.
|
|
13
|
+
|
|
14
|
+
## [8.0.2] - 2026-10-22
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- **Type-Safe Routing Ambient Inclusions**: Dinou no longer modifies `dinou-env.d.ts` at runtime. Ambient route declarations (`.dinou/types/routes.d.ts`) are now consumed directly via `tsconfig.json` (`".dinou/types/**/*.d.ts"`), preventing `TS6053` errors on fresh clones and keeping Git working trees clean.
|
|
18
|
+
|
|
8
19
|
## [8.0.1] - 2026-10-21
|
|
9
20
|
|
|
10
21
|
### Fixed
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# **Dinou**
|
|
2
2
|
|
|
3
|
-
[](https://dinou.dev) [](https://dinou.dev) [](https://www.npmjs.com/package/dinou)
|
|
4
4
|
|
|
5
5
|
### **Full-Stack React 19 Framework**
|
|
6
6
|
|
|
@@ -539,7 +539,8 @@ Dinou does not force you to use TypeScript—you are completely free to write yo
|
|
|
539
539
|
},
|
|
540
540
|
"include": [
|
|
541
541
|
"src",
|
|
542
|
-
"dinou-env.d.ts"
|
|
542
|
+
"dinou-env.d.ts",
|
|
543
|
+
".dinou/types/**/*.d.ts"
|
|
543
544
|
]
|
|
544
545
|
}
|
|
545
546
|
```
|
|
@@ -2221,12 +2222,24 @@ export interface RouteSegmentConfig<TParams = any, TProps = any> {
|
|
|
2221
2222
|
/**
|
|
2222
2223
|
* Concrete semantic alias to import and use in 'page_functions.ts'
|
|
2223
2224
|
*/
|
|
2224
|
-
export type PageFunctions<
|
|
2225
|
+
export type PageFunctions<
|
|
2226
|
+
TRouteOrParams extends DinouRoutePattern | object = any,
|
|
2227
|
+
TProps = any
|
|
2228
|
+
> = RouteSegmentConfig<
|
|
2229
|
+
[TRouteOrParams] extends [string] ? RouteParams<TRouteOrParams> : TRouteOrParams,
|
|
2230
|
+
TProps
|
|
2231
|
+
>;
|
|
2225
2232
|
|
|
2226
2233
|
/**
|
|
2227
2234
|
* Concrete semantic alias to import and use in 'layout_functions.ts'
|
|
2228
2235
|
*/
|
|
2229
|
-
export type LayoutFunctions<
|
|
2236
|
+
export type LayoutFunctions<
|
|
2237
|
+
TRouteOrParams extends DinouRoutePattern | object = any,
|
|
2238
|
+
TProps = any
|
|
2239
|
+
> = RouteSegmentConfig<
|
|
2240
|
+
[TRouteOrParams] extends [string] ? RouteParams<TRouteOrParams> : TRouteOrParams,
|
|
2241
|
+
TProps
|
|
2242
|
+
>;
|
|
2230
2243
|
```
|
|
2231
2244
|
|
|
2232
2245
|
| Where to use | Type to import | Purpose |
|
|
@@ -6148,7 +6161,8 @@ Ensure your `tsconfig.json` includes the declaration file and specifies `"module
|
|
|
6148
6161
|
},
|
|
6149
6162
|
"include": [
|
|
6150
6163
|
"src",
|
|
6151
|
-
"dinou-env.d.ts"
|
|
6164
|
+
"dinou-env.d.ts",
|
|
6165
|
+
".dinou/types/**/*.d.ts"
|
|
6152
6166
|
]
|
|
6153
6167
|
}
|
|
6154
6168
|
```
|
|
@@ -6426,7 +6440,8 @@ And confirm your `tsconfig.json` includes the reference:
|
|
|
6426
6440
|
},
|
|
6427
6441
|
"include": [
|
|
6428
6442
|
"src",
|
|
6429
|
-
"dinou-env.d.ts"
|
|
6443
|
+
"dinou-env.d.ts",
|
|
6444
|
+
".dinou/types/**/*.d.ts"
|
|
6430
6445
|
]
|
|
6431
6446
|
}
|
|
6432
6447
|
```
|
|
@@ -6698,7 +6713,8 @@ To enable the standard `@/*` alias pointing to your `src/` directory, configure
|
|
|
6698
6713
|
},
|
|
6699
6714
|
"include": [
|
|
6700
6715
|
"src",
|
|
6701
|
-
"dinou-env.d.ts"
|
|
6716
|
+
"dinou-env.d.ts",
|
|
6717
|
+
".dinou/types/**/*.d.ts"
|
|
6702
6718
|
]
|
|
6703
6719
|
}
|
|
6704
6720
|
```
|
|
@@ -134,7 +134,7 @@ function generateRouteDefinitions(routes) {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
/**
|
|
137
|
-
* Generates the .dinou/types/routes.d.ts
|
|
137
|
+
* Generates the .dinou/types/routes.d.ts ambient definitions file.
|
|
138
138
|
* @param {string} projectRoot Root directory of the project (default process.cwd())
|
|
139
139
|
*/
|
|
140
140
|
function generateRouteTypes(projectRoot = process.cwd()) {
|
|
@@ -225,19 +225,6 @@ ${paramsEntries}
|
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
// Ensure dinou-env.d.ts references .dinou/types/routes.d.ts
|
|
229
|
-
const envFile = path.resolve(projectRoot, "dinou-env.d.ts");
|
|
230
|
-
try {
|
|
231
|
-
if (fs.existsSync(envFile)) {
|
|
232
|
-
let envContent = fs.readFileSync(envFile, "utf8");
|
|
233
|
-
const refLine = '/// <reference path="./.dinou/types/routes.d.ts" />';
|
|
234
|
-
if (!envContent.includes(refLine)) {
|
|
235
|
-
envContent = envContent.trimEnd() + "\n" + refLine + "\n";
|
|
236
|
-
fs.writeFileSync(envFile, envContent, "utf8");
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
} catch (e) {}
|
|
240
|
-
|
|
241
228
|
return {
|
|
242
229
|
staticCount: staticRoutes.length,
|
|
243
230
|
dynamicCount: dynamicRoutes.length,
|
|
@@ -51,6 +51,16 @@ async function getDinouConfig() {
|
|
|
51
51
|
platform: "node",
|
|
52
52
|
packages: "external",
|
|
53
53
|
sourcemap: "inline",
|
|
54
|
+
plugins: [
|
|
55
|
+
{
|
|
56
|
+
name: "dinou-config-alias",
|
|
57
|
+
setup(build) {
|
|
58
|
+
build.onResolve({ filter: /^dinou$/ }, () => {
|
|
59
|
+
return { path: "dinou/config", external: true };
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
],
|
|
54
64
|
});
|
|
55
65
|
loaded = await import(pathToFileURL(bundledPath).href + (isDev ? `?t=${Date.now()}` : ""));
|
|
56
66
|
} else if (p.endsWith(".mjs")) {
|
package/dinou/index.d.ts
CHANGED
|
@@ -288,7 +288,10 @@ export interface RouteSegmentConfig<TParams = any, TProps = any> {
|
|
|
288
288
|
* Type-safe interface representing the available exports in `page_functions.ts`.
|
|
289
289
|
* Accepts either a route pattern string (e.g. `"/products/[id]"`) or a direct parameters dictionary.
|
|
290
290
|
*/
|
|
291
|
-
export type PageFunctions<
|
|
291
|
+
export type PageFunctions<
|
|
292
|
+
TRouteOrParams extends DinouRoutePattern | object = any,
|
|
293
|
+
TProps = any
|
|
294
|
+
> = RouteSegmentConfig<
|
|
292
295
|
[TRouteOrParams] extends [string] ? RouteParams<TRouteOrParams> : TRouteOrParams,
|
|
293
296
|
TProps
|
|
294
297
|
>;
|
|
@@ -297,7 +300,10 @@ export type PageFunctions<TRouteOrParams = any, TProps = any> = RouteSegmentConf
|
|
|
297
300
|
* Type-safe interface representing the available exports in `layout_functions.ts`.
|
|
298
301
|
* Accepts either a route pattern string (e.g. `"/[organization]"`) or a direct parameters dictionary.
|
|
299
302
|
*/
|
|
300
|
-
export type LayoutFunctions<
|
|
303
|
+
export type LayoutFunctions<
|
|
304
|
+
TRouteOrParams extends DinouRoutePattern | object = any,
|
|
305
|
+
TProps = any
|
|
306
|
+
> = RouteSegmentConfig<
|
|
301
307
|
[TRouteOrParams] extends [string] ? RouteParams<TRouteOrParams> : TRouteOrParams,
|
|
302
308
|
TProps
|
|
303
309
|
>;
|
|
@@ -479,7 +485,7 @@ export type CleanRoutePath<T extends string> = T extends `/${string}` ? T : `/${
|
|
|
479
485
|
* Prioritizes the generated route parameters map from .dinou/types/routes.d.ts,
|
|
480
486
|
* and falls back to template literal extraction.
|
|
481
487
|
*/
|
|
482
|
-
export type RouteParams<T extends
|
|
488
|
+
export type RouteParams<T extends DinouRoutePattern = DinouRoutePattern> =
|
|
483
489
|
DinouRouter.Register extends { params: infer P }
|
|
484
490
|
? (CleanRoutePath<T> extends keyof P
|
|
485
491
|
? P[CleanRoutePath<T>]
|
package/dinou/package.json
CHANGED
package/package.json
CHANGED