@owlmeans/client-route 0.1.18-rc.47 → 0.1.18-rc.48
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 +10 -10
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/client-route/SKILL.md +1 -1
- package/build/helper/types.d.ts +9 -0
- package/build/helper/types.d.ts.map +1 -0
- package/build/helper/types.js +2 -0
- package/build/helper/types.js.map +1 -0
- package/build/helper.d.ts +3 -3
- package/build/helper.d.ts.map +1 -1
- package/build/helper.js +9 -5
- package/build/helper.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js.map +1 -1
- package/build/model.js +2 -2
- package/build/model.js.map +1 -1
- package/package.json +3 -3
- package/src/helper/types.ts +9 -0
- package/src/helper.ts +14 -7
- package/src/index.ts +1 -0
- package/src/model.ts +2 -2
package/README.md
CHANGED
|
@@ -5,32 +5,32 @@ Client-side route model extension — marks routes as client-side and provides U
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
7
|
- `route(routeModel, opts?)` — wraps a `RouteModel` into a `ClientRouteModel` (marks `_client: true`)
|
|
8
|
-
- `isClientRouteModel(route)` — type guard distinguishing client routes from server routes
|
|
9
|
-
- `extractParams(path)` — extracts path parameter names (`:param` segments) from a URL pattern
|
|
8
|
+
- `clientRouteHelper.isClientRouteModel(route)` — type guard distinguishing client routes from server routes
|
|
9
|
+
- `clientRouteHelper.extractParams(path)` — extracts path parameter names (`:param` segments) from a URL pattern
|
|
10
10
|
- Used internally by `@owlmeans/client-entrypoint` when building client-side entrypoint URLs
|
|
11
11
|
|
|
12
12
|
## Installation
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
bun add @owlmeans/client-route@^0.1.18-rc.
|
|
15
|
+
bun add @owlmeans/client-route@^0.1.18-rc.48
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
19
19
|
|
|
20
20
|
```typescript
|
|
21
|
-
import { route,
|
|
21
|
+
import { route, clientRouteHelper } from '@owlmeans/client-route'
|
|
22
22
|
import type { ClientRouteModel } from '@owlmeans/client-route'
|
|
23
23
|
|
|
24
24
|
// Wrap a route as a client route
|
|
25
25
|
const clientRoute = route(someRouteModel, { overrides: { service: 'api' } })
|
|
26
26
|
|
|
27
27
|
// Type guard
|
|
28
|
-
if (isClientRouteModel(arg)) {
|
|
28
|
+
if (clientRouteHelper.isClientRouteModel(arg)) {
|
|
29
29
|
// arg is ClientRouteModel
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
// Extract named params from a path pattern
|
|
33
|
-
const params = extractParams('/projects/:projectId/items/:itemId')
|
|
33
|
+
const params = clientRouteHelper.extractParams('/projects/:projectId/items/:itemId')
|
|
34
34
|
// => ['projectId', 'itemId']
|
|
35
35
|
```
|
|
36
36
|
|
|
@@ -41,11 +41,11 @@ const params = extractParams('/projects/:projectId/items/:itemId')
|
|
|
41
41
|
Converts a `RouteModel` to a `ClientRouteModel`. Options: `overrides?: Partial<ClientRoute>` — the
|
|
42
42
|
overrides only fill in declaration fields that are still unset.
|
|
43
43
|
|
|
44
|
-
### `isClientRouteModel(route): route is ClientRouteModel`
|
|
44
|
+
### `clientRouteHelper.isClientRouteModel(route): route is ClientRouteModel`
|
|
45
45
|
|
|
46
46
|
Returns `true` if the route was created with `route()`.
|
|
47
47
|
|
|
48
|
-
### `extractParams(path): string[]`
|
|
48
|
+
### `clientRouteHelper.extractParams(path): string[]`
|
|
49
49
|
|
|
50
50
|
Returns the list of `:param` segment names in a URL pattern string.
|
|
51
51
|
|
|
@@ -59,7 +59,7 @@ and `address()` on demand against the context that asks.
|
|
|
59
59
|
|
|
60
60
|
- [`@owlmeans/route`](../route) — `RouteModel`, `RouteDeclaration` base types and the pure
|
|
61
61
|
`resolvePath` / `resolveMount` / `resolveAddress` utilities under `@owlmeans/route/utils`
|
|
62
|
-
- [`@owlmeans/client-entrypoint`](../client-entrypoint) — uses `route()` and `isClientRouteModel()` when constructing entrypoints
|
|
62
|
+
- [`@owlmeans/client-entrypoint`](../client-entrypoint) — uses `route()` and `clientRouteHelper.isClientRouteModel()` when constructing entrypoints
|
|
63
63
|
|
|
64
64
|
<!-- owlmeans:agent-guidance:start -->
|
|
65
65
|
## Agent guidance
|
|
@@ -69,7 +69,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
69
69
|
your project's skill store (`.agents/skills/`):
|
|
70
70
|
|
|
71
71
|
```sh
|
|
72
|
-
npx @owlmeans/agent-skills@^0.1.18-rc.
|
|
72
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.49
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
The embedded files are version-matched to this package release. Do not edit them
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"package": "@owlmeans/client-route",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-10-
|
|
4
|
+
"version": "0.1.18-rc.48",
|
|
5
|
+
"generatedAt": "2026-10-05T21:03:06.366Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ClientRouteModel } from '../types.js';
|
|
2
|
+
/** Reads client route models and their paths. */
|
|
3
|
+
export interface ClientRouteHelper {
|
|
4
|
+
/** Whether a route model was marked as a client one. */
|
|
5
|
+
isClientRouteModel: (route: Object) => route is ClientRouteModel;
|
|
6
|
+
/** The names of the `:param` segments of a path, in order. */
|
|
7
|
+
extractParams: (path: string) => string[];
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/helper/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEnD,iDAAiD;AACjD,MAAM,WAAW,iBAAiB;IAChC,wDAAwD;IACxD,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,IAAI,gBAAgB,CAAA;IAChE,8DAA8D;IAC9D,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EAAE,CAAA;CAC1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/helper/types.ts"],"names":[],"mappings":""}
|
package/build/helper.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
1
|
+
import type { ClientRouteHelper } from './helper/types.js';
|
|
2
|
+
export declare const createClientRouteHelper: () => ClientRouteHelper;
|
|
3
|
+
export declare const clientRouteHelper: ClientRouteHelper;
|
|
4
4
|
//# sourceMappingURL=helper.d.ts.map
|
package/build/helper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAE1D,eAAO,MAAM,uBAAuB,QAAO,iBAW1C,CAAA;AAED,eAAO,MAAM,iBAAiB,mBAA4B,CAAA"}
|
package/build/helper.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { PARAM, SEP, normalizePath } from '@owlmeans/route';
|
|
2
|
-
export const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
.
|
|
2
|
+
export const createClientRouteHelper = () => {
|
|
3
|
+
const isClientRouteModel = (route) => '_client' in route;
|
|
4
|
+
const extractParams = (path) => {
|
|
5
|
+
path = normalizePath(path);
|
|
6
|
+
return path.split(SEP).map(item => item.startsWith(PARAM) ? item.slice(1) : null)
|
|
7
|
+
.filter(param => param);
|
|
8
|
+
};
|
|
9
|
+
return { isClientRouteModel, extractParams };
|
|
7
10
|
};
|
|
11
|
+
export const clientRouteHelper = createClientRouteHelper();
|
|
8
12
|
//# sourceMappingURL=helper.js.map
|
package/build/helper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAI3D,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAsB,EAAE;IAC7D,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAA6B,EAAE,CACtE,SAAS,IAAI,KAAK,CAAA;IAEpB,MAAM,aAAa,GAAG,CAAC,IAAY,EAAY,EAAE;QAC/C,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,CAAA;QAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;aAC9E,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAa,CAAA;IACvC,CAAC,CAAA;IAED,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,CAAA;AAC9C,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,uBAAuB,EAAE,CAAA"}
|
package/build/index.d.ts
CHANGED
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAA;AAC1B,mBAAmB,YAAY,CAAA;AAC/B,cAAc,aAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAA;AAC1B,mBAAmB,YAAY,CAAA;AAC/B,mBAAmB,mBAAmB,CAAA;AACtC,cAAc,aAAa,CAAA"}
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAA;AAG1B,cAAc,aAAa,CAAA"}
|
package/build/model.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { routeDeclarationHelper } from '@owlmeans/route/utils';
|
|
2
2
|
/**
|
|
3
3
|
* Mark a route model as a client one and fill in whatever the declaration left blank.
|
|
4
4
|
* The declared `path` stays the segment this route contributes — the entrypoint composes the
|
|
@@ -9,7 +9,7 @@ export const route = (route, opts) => {
|
|
|
9
9
|
...route,
|
|
10
10
|
_client: true
|
|
11
11
|
};
|
|
12
|
-
overrideParams(model.route, opts?.overrides);
|
|
12
|
+
routeDeclarationHelper.overrideParams(model.route, opts?.overrides);
|
|
13
13
|
return model;
|
|
14
14
|
};
|
|
15
15
|
//# sourceMappingURL=model.js.map
|
package/build/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAE9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAiB,EAAE,IAAyB,EAAoB,EAAE;IACtF,MAAM,KAAK,GAAqB;QAC9B,GAAI,KAA0B;QAE9B,OAAO,EAAE,IAAI;KACd,CAAA;IAED,sBAAsB,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC,CAAA;IAEnE,OAAO,KAAK,CAAA;AACd,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/client-route",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.48",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@owlmeans/client-context": "^0.1.18-rc.
|
|
25
|
-
"@owlmeans/route": "^0.1.18-rc.
|
|
24
|
+
"@owlmeans/client-context": "^0.1.18-rc.48",
|
|
25
|
+
"@owlmeans/route": "^0.1.18-rc.35"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@owlmeans/dep-config": "workspace:*",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ClientRouteModel } from '../types.js'
|
|
2
|
+
|
|
3
|
+
/** Reads client route models and their paths. */
|
|
4
|
+
export interface ClientRouteHelper {
|
|
5
|
+
/** Whether a route model was marked as a client one. */
|
|
6
|
+
isClientRouteModel: (route: Object) => route is ClientRouteModel
|
|
7
|
+
/** The names of the `:param` segments of a path, in order. */
|
|
8
|
+
extractParams: (path: string) => string[]
|
|
9
|
+
}
|
package/src/helper.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { PARAM, SEP, normalizePath } from '@owlmeans/route'
|
|
2
|
-
import { ClientRouteModel } from './types.js'
|
|
2
|
+
import type { ClientRouteModel } from './types.js'
|
|
3
|
+
import type { ClientRouteHelper } from './helper/types.js'
|
|
3
4
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
5
|
+
export const createClientRouteHelper = (): ClientRouteHelper => {
|
|
6
|
+
const isClientRouteModel = (route: Object): route is ClientRouteModel =>
|
|
7
|
+
'_client' in route
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const extractParams = (path: string): string[] => {
|
|
10
|
+
path = normalizePath(path)
|
|
11
|
+
return path.split(SEP).map(item => item.startsWith(PARAM) ? item.slice(1) : null)
|
|
12
|
+
.filter(param => param) as string[]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return { isClientRouteModel, extractParams }
|
|
11
16
|
}
|
|
17
|
+
|
|
18
|
+
export const clientRouteHelper = createClientRouteHelper()
|
package/src/index.ts
CHANGED
package/src/model.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RouteModel } from '@owlmeans/route'
|
|
2
2
|
import type { ClientRouteModel, ClientRouteOptions } from './types.js'
|
|
3
|
-
import {
|
|
3
|
+
import { routeDeclarationHelper } from '@owlmeans/route/utils'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Mark a route model as a client one and fill in whatever the declaration left blank.
|
|
@@ -14,7 +14,7 @@ export const route = (route: RouteModel, opts?: ClientRouteOptions): ClientRoute
|
|
|
14
14
|
_client: true
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
overrideParams(model.route, opts?.overrides)
|
|
17
|
+
routeDeclarationHelper.overrideParams(model.route, opts?.overrides)
|
|
18
18
|
|
|
19
19
|
return model
|
|
20
20
|
}
|