@tolki/ts 0.0.1 → 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/dist/index.js +7 -6
- package/dist/routes.d.ts +21 -2
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +23 -17
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { cases as o, defineEnum as f, from as
|
|
2
|
-
import { addRouteDefault as
|
|
1
|
+
import { cases as o, defineEnum as f, from as a, tryFrom as r } from "./enums.js";
|
|
2
|
+
import { addRouteDefault as s, annotatePageProps as m, defineRoute as n, formSafeOptions as R, getRouteDefaults as d, resetRouteDefaults as l, setRouteDefaults as p } from "./routes.js";
|
|
3
3
|
export {
|
|
4
|
-
|
|
4
|
+
s as addRouteDefault,
|
|
5
|
+
m as annotatePageProps,
|
|
5
6
|
o as cases,
|
|
6
7
|
f as defineEnum,
|
|
7
|
-
|
|
8
|
+
n as defineRoute,
|
|
8
9
|
R as formSafeOptions,
|
|
9
|
-
|
|
10
|
+
a as from,
|
|
10
11
|
d as getRouteDefaults,
|
|
11
12
|
l as resetRouteDefaults,
|
|
12
|
-
|
|
13
|
+
p as setRouteDefaults,
|
|
13
14
|
r as tryFrom
|
|
14
15
|
};
|
package/dist/routes.d.ts
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
|
-
import { DefineRouteResult, RouteArgMeta, RouteCallResult, RouteCallResultWithComponent, RouteComponentType, RouteFormResult, RouteMetadata, RouteQueryOptions } from '../packages/types/src/index.ts';
|
|
2
|
-
export type { DefineRouteResult, RouteArgMeta, RouteCallResult, RouteCallResultWithComponent, RouteComponentType, RouteFormResult, RouteMetadata, RouteQueryOptions, };
|
|
1
|
+
import { DefineRouteResult, InferPageProps, RouteArgMeta, RouteCallResult, RouteCallResultWithComponent, RouteComponentType, RouteFormResult, RouteMetadata, RouteQueryOptions } from '../packages/types/src/index.ts';
|
|
2
|
+
export type { DefineRouteResult, InferPageProps, RouteArgMeta, RouteCallResult, RouteCallResultWithComponent, RouteComponentType, RouteFormResult, RouteMetadata, RouteQueryOptions, };
|
|
3
|
+
/**
|
|
4
|
+
* Attach a phantom page props type to a `defineRoute` result without losing
|
|
5
|
+
* the inferred TMethods / TArgs / TComponent specificity.
|
|
6
|
+
*
|
|
7
|
+
* Use a curried call so TypeScript can infer the route generics while you
|
|
8
|
+
* supply `TPageProps` explicitly:
|
|
9
|
+
*
|
|
10
|
+
* ```typescript
|
|
11
|
+
* export const dashboard = annotatePageProps<DashboardPageProps>()(defineRoute({ ... }));
|
|
12
|
+
* type Props = InferPageProps<typeof dashboard>; // DashboardPageProps
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Already-annotated routes can be re-annotated — the existing `TPageProps` generic
|
|
16
|
+
* (`TExistingPageProps`) is accepted and discarded in favour of the new one.
|
|
17
|
+
*
|
|
18
|
+
* @returns A one-argument function that accepts a `defineRoute` result and returns
|
|
19
|
+
* the same value cast to carry `TPageProps`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function annotatePageProps<TPageProps>(): <TMethods extends readonly string[], TArgs extends readonly RouteArgMeta[], TComponent extends RouteComponentType | undefined, TExistingPageProps>(route: DefineRouteResult<TMethods, TArgs, TComponent, TExistingPageProps>) => DefineRouteResult<TMethods, TArgs, TComponent, TPageProps>;
|
|
3
22
|
/**
|
|
4
23
|
* Set global default route parameter values.
|
|
5
24
|
*
|
package/dist/routes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,4BAA4B,EAC5B,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACpB,MAAM,cAAc,CAAC;AAYtB,YAAY,EACR,iBAAiB,EACjB,YAAY,EACZ,eAAe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M,GAAG,MAAM,GAAG,OAAO,CAAC,CAE5E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AA8YD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC3B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,iBAAiB,GAC5B,iBAAiB,CAWnB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CACvB,KAAK,CAAC,QAAQ,SAAS,SAAS,MAAM,EAAE,EACxC,KAAK,CAAC,KAAK,SAAS,SAAS,YAAY,EAAE,GAAG,SAAS,EAAE,EACzD,KAAK,CAAC,UAAU,SAAS,kBAAkB,GAAG,SAAS,GAAG,SAAS,EAEnE,QAAQ,EAAE,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,GACrD,iBAAiB,CAAC,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,CAyFhD"}
|
package/dist/routes.js
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
import { isString as U, isFunction as E, isUndefined as j, isNull as R, isObject as g, isArray as w, isNumber as K, isBoolean as
|
|
1
|
+
import { isString as U, isFunction as E, isUndefined as j, isNull as R, isObject as g, isArray as w, isNumber as K, isBoolean as P } from "@tolki/utils";
|
|
2
|
+
function I() {
|
|
3
|
+
return function(e) {
|
|
4
|
+
return e;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
2
7
|
const C = () => ({});
|
|
3
8
|
let b = C;
|
|
4
|
-
function
|
|
9
|
+
function N(e) {
|
|
5
10
|
b = E(e) ? e : () => ({ ...e });
|
|
6
11
|
}
|
|
7
|
-
function
|
|
12
|
+
function T(e, n) {
|
|
8
13
|
const o = b;
|
|
9
14
|
b = () => ({
|
|
10
15
|
...o(),
|
|
11
16
|
[e]: n
|
|
12
17
|
});
|
|
13
18
|
}
|
|
14
|
-
function
|
|
19
|
+
function V() {
|
|
15
20
|
return { ...b() };
|
|
16
21
|
}
|
|
17
|
-
function
|
|
22
|
+
function v() {
|
|
18
23
|
b = C;
|
|
19
24
|
}
|
|
20
25
|
function O(e, n) {
|
|
@@ -45,7 +50,7 @@ function O(e, n) {
|
|
|
45
50
|
function S(e, n) {
|
|
46
51
|
if (R(n) || j(n))
|
|
47
52
|
return [];
|
|
48
|
-
if (
|
|
53
|
+
if (P(n))
|
|
49
54
|
return [`${encodeURIComponent(e)}=${n ? "1" : "0"}`];
|
|
50
55
|
if (w(n)) {
|
|
51
56
|
const o = [];
|
|
@@ -65,7 +70,7 @@ function S(e, n) {
|
|
|
65
70
|
}
|
|
66
71
|
return [`${encodeURIComponent(e)}=${encodeURIComponent(String(n))}`];
|
|
67
72
|
}
|
|
68
|
-
function
|
|
73
|
+
function Q(e) {
|
|
69
74
|
const n = [];
|
|
70
75
|
for (const [o, r] of Object.entries(e))
|
|
71
76
|
n.push(...S(o, r));
|
|
@@ -174,7 +179,7 @@ function d(e, n, o, r) {
|
|
|
174
179
|
l[p] = y;
|
|
175
180
|
else i !== "_query" && i !== "mergeQuery" && (l[i] = f);
|
|
176
181
|
}
|
|
177
|
-
const a =
|
|
182
|
+
const a = Q(l);
|
|
178
183
|
return c + a;
|
|
179
184
|
}
|
|
180
185
|
function k(e, n) {
|
|
@@ -195,7 +200,7 @@ function _(e, n) {
|
|
|
195
200
|
}
|
|
196
201
|
};
|
|
197
202
|
}
|
|
198
|
-
function
|
|
203
|
+
function x(e, n) {
|
|
199
204
|
const o = n?.mergeQuery ? "mergeQuery" : "_query", r = n?.[o] ?? {};
|
|
200
205
|
return {
|
|
201
206
|
...n,
|
|
@@ -205,7 +210,7 @@ function P(e, n) {
|
|
|
205
210
|
}
|
|
206
211
|
};
|
|
207
212
|
}
|
|
208
|
-
function
|
|
213
|
+
function L(e) {
|
|
209
214
|
const n = e.args ?? [], o = e.methods[0] ?? "get", r = (...t) => {
|
|
210
215
|
const [u, c] = $(t, n), l = d(e.url, u, n, c);
|
|
211
216
|
return k(l, o);
|
|
@@ -234,7 +239,7 @@ function v(e) {
|
|
|
234
239
|
const u = t !== "get" && t !== "post";
|
|
235
240
|
Object.assign(m, {
|
|
236
241
|
[t]: (...c) => {
|
|
237
|
-
const [l, a] = $(c, n), i = u ?
|
|
242
|
+
const [l, a] = $(c, n), i = u ? x(t, a) : a, f = d(e.url, l, n, i);
|
|
238
243
|
return _(f, t);
|
|
239
244
|
}
|
|
240
245
|
});
|
|
@@ -252,10 +257,11 @@ function v(e) {
|
|
|
252
257
|
return s;
|
|
253
258
|
}
|
|
254
259
|
export {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
V as
|
|
260
|
-
|
|
260
|
+
T as addRouteDefault,
|
|
261
|
+
I as annotatePageProps,
|
|
262
|
+
L as defineRoute,
|
|
263
|
+
x as formSafeOptions,
|
|
264
|
+
V as getRouteDefaults,
|
|
265
|
+
v as resetRouteDefaults,
|
|
266
|
+
N as setRouteDefaults
|
|
261
267
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tolki/ts",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "A set of TypeScript utilities for the Laravel TypeScript Publish PHP package.",
|
|
5
5
|
"author": "Abraham Arango <https://github.com/abetwothree>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"schemaVersion": 1,
|
|
19
19
|
"vite": {
|
|
20
20
|
"type": "compatible",
|
|
21
|
-
"versions": "^7.0.0"
|
|
21
|
+
"versions": "^7.0.0||^8.0.0"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"main": "dist/index.js",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"tolki"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@tolki/types": "^1.
|
|
42
|
+
"@tolki/types": "^1.3.0",
|
|
43
43
|
"@tolki/utils": "^1.0.2"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"vite": "^7.0.0"
|
|
46
|
+
"vite": "^7.0.0||^8.0.0"
|
|
47
47
|
},
|
|
48
48
|
"sideEffects": false,
|
|
49
49
|
"files": [
|