foldkit 0.15.0 → 0.17.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 +2 -2
- package/dist/{fieldValidation.d.ts → fieldValidation/index.d.ts} +21 -1
- package/dist/fieldValidation/index.d.ts.map +1 -0
- package/dist/{fieldValidation.js → fieldValidation/index.js} +27 -11
- package/dist/fieldValidation/public.d.ts +3 -0
- package/dist/fieldValidation/public.d.ts.map +1 -0
- package/dist/fieldValidation/public.js +1 -0
- package/dist/{html.d.ts → html/index.d.ts} +32 -4
- package/dist/html/index.d.ts.map +1 -0
- package/dist/{html.js → html/index.js} +18 -2
- package/dist/html/public.d.ts +3 -0
- package/dist/html/public.d.ts.map +1 -0
- package/dist/html/public.js +1 -0
- package/dist/index.d.ts +10 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -8
- package/dist/navigation/index.d.ts +12 -0
- package/dist/navigation/index.d.ts.map +1 -0
- package/dist/{navigation.js → navigation/index.js} +5 -0
- package/dist/navigation/public.d.ts +2 -0
- package/dist/navigation/public.d.ts.map +1 -0
- package/dist/navigation/public.js +1 -0
- package/dist/route/index.d.ts +2 -0
- package/dist/route/index.d.ts.map +1 -0
- package/dist/{parser.d.ts → route/parser.d.ts} +124 -3
- package/dist/route/parser.d.ts.map +1 -0
- package/dist/{parser.js → route/parser.js} +91 -0
- package/dist/route/public.d.ts +3 -0
- package/dist/route/public.d.ts.map +1 -0
- package/dist/route/public.js +1 -0
- package/dist/runtime/public.d.ts +5 -0
- package/dist/runtime/public.d.ts.map +1 -0
- package/dist/runtime/public.js +2 -0
- package/dist/runtime/runtime.d.ts +18 -1
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +3 -3
- package/dist/runtime/urlRequest.d.ts +6 -0
- package/dist/runtime/urlRequest.d.ts.map +1 -1
- package/dist/runtime/urlRequest.js +3 -0
- package/dist/{schema.d.ts → schema/index.d.ts} +1 -1
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/public.d.ts +2 -0
- package/dist/schema/public.d.ts.map +1 -0
- package/dist/schema/public.js +1 -0
- package/dist/{struct.d.ts → struct/index.d.ts} +2 -1
- package/dist/struct/index.d.ts.map +1 -0
- package/dist/struct/index.js +3 -0
- package/dist/struct/public.d.ts +2 -0
- package/dist/struct/public.d.ts.map +1 -0
- package/dist/struct/public.js +1 -0
- package/dist/{task.d.ts → task/index.d.ts} +23 -1
- package/dist/task/index.d.ts.map +1 -0
- package/dist/{task.js → task/index.js} +44 -0
- package/dist/task/public.d.ts +2 -0
- package/dist/task/public.d.ts.map +1 -0
- package/dist/task/public.js +1 -0
- package/dist/ui/dialog/index.d.ts +46 -0
- package/dist/ui/dialog/index.d.ts.map +1 -0
- package/dist/ui/dialog/index.js +67 -0
- package/dist/ui/dialog/public.d.ts +3 -0
- package/dist/ui/dialog/public.d.ts.map +1 -0
- package/dist/ui/dialog/public.js +1 -0
- package/dist/ui/disclosure/index.d.ts +47 -0
- package/dist/ui/disclosure/index.d.ts.map +1 -0
- package/dist/ui/disclosure/index.js +90 -0
- package/dist/ui/disclosure/public.d.ts +3 -0
- package/dist/ui/disclosure/public.d.ts.map +1 -0
- package/dist/ui/disclosure/public.js +1 -0
- package/dist/ui/index.d.ts +4 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +3 -0
- package/dist/ui/tabs/index.d.ts +78 -0
- package/dist/ui/tabs/index.d.ts.map +1 -0
- package/dist/ui/tabs/index.js +151 -0
- package/dist/ui/tabs/public.d.ts +3 -0
- package/dist/ui/tabs/public.d.ts.map +1 -0
- package/dist/ui/tabs/public.js +1 -0
- package/dist/{url.d.ts → url/index.d.ts} +4 -1
- package/dist/url/index.d.ts.map +1 -0
- package/dist/{url.js → url/index.js} +4 -1
- package/dist/url/public.d.ts +2 -0
- package/dist/url/public.d.ts.map +1 -0
- package/dist/url/public.js +1 -0
- package/package.json +33 -19
- package/dist/fieldValidation.d.ts.map +0 -1
- package/dist/html.d.ts.map +0 -1
- package/dist/navigation.d.ts +0 -7
- package/dist/navigation.d.ts.map +0 -1
- package/dist/parser.d.ts.map +0 -1
- package/dist/route.d.ts +0 -2
- package/dist/route.d.ts.map +0 -1
- package/dist/schema.d.ts.map +0 -1
- package/dist/struct.d.ts.map +0 -1
- package/dist/struct.js +0 -2
- package/dist/task.d.ts.map +0 -1
- package/dist/url.d.ts.map +0 -1
- /package/dist/{route.js → route/index.js} +0 -0
- /package/dist/{schema.js → schema/index.js} +0 -0
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { Effect, Record, Schema } from 'effect';
|
|
2
|
-
import { Url } from '
|
|
2
|
+
import { Url } from '../url';
|
|
3
3
|
declare const ParseError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
4
4
|
readonly _tag: "ParseError";
|
|
5
5
|
} & Readonly<A>;
|
|
6
|
+
/**
|
|
7
|
+
* Error type for route parsing failures.
|
|
8
|
+
*
|
|
9
|
+
* Includes optional `expected`, `actual`, and `position` fields for
|
|
10
|
+
* diagnostic context when a URL segment does not match.
|
|
11
|
+
*/
|
|
6
12
|
export declare class ParseError extends ParseError_base<{
|
|
7
13
|
readonly message: string;
|
|
8
14
|
readonly expected?: string;
|
|
@@ -10,32 +16,100 @@ export declare class ParseError extends ParseError_base<{
|
|
|
10
16
|
readonly position?: number;
|
|
11
17
|
}> {
|
|
12
18
|
}
|
|
13
|
-
|
|
19
|
+
/**
|
|
20
|
+
* The result of parsing: a tuple of the parsed value and remaining URL segments.
|
|
21
|
+
*/
|
|
22
|
+
export type ParseResult<A> = [A, ReadonlyArray<string>];
|
|
14
23
|
type PrintState = {
|
|
15
24
|
segments: ReadonlyArray<string>;
|
|
16
25
|
queryParams: URLSearchParams;
|
|
17
26
|
};
|
|
18
|
-
|
|
27
|
+
/**
|
|
28
|
+
* A bidirectional parser that can both parse URL segments into a value
|
|
29
|
+
* and print a value back to URL segments.
|
|
30
|
+
*/
|
|
31
|
+
export type Biparser<A> = {
|
|
19
32
|
parse: (segments: ReadonlyArray<string>, search?: string) => Effect.Effect<ParseResult<A>, ParseError>;
|
|
20
33
|
print: (value: A, state: PrintState) => Effect.Effect<PrintState, ParseError>;
|
|
21
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* A parser with a `build` method that can reconstruct URLs from parsed values.
|
|
37
|
+
*
|
|
38
|
+
* Created by applying `mapTo` to a `Biparser`, binding it to a tagged
|
|
39
|
+
* type constructor so parsed values carry a discriminant tag and URLs can be
|
|
40
|
+
* built from tag payloads.
|
|
41
|
+
*/
|
|
22
42
|
export type Router<A> = {
|
|
23
43
|
parse: (segments: ReadonlyArray<string>, search?: string) => Effect.Effect<ParseResult<A>, ParseError>;
|
|
24
44
|
build: (value: A extends {
|
|
25
45
|
_tag: string;
|
|
26
46
|
} ? Omit<A, '_tag'> : never) => string;
|
|
27
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* A `Biparser` that has been terminated (e.g. by `query`) and cannot
|
|
50
|
+
* be extended with `slash`.
|
|
51
|
+
*/
|
|
28
52
|
export type TerminalParser<A> = Biparser<A> & {
|
|
29
53
|
readonly __terminal: true;
|
|
30
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* Creates a parser that matches an exact URL path segment.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* literal('users') // matches /users
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
31
63
|
export declare const literal: (segment: string) => Biparser<{}>;
|
|
64
|
+
/**
|
|
65
|
+
* Creates a parser for a dynamic URL segment with custom parse and print functions.
|
|
66
|
+
*
|
|
67
|
+
* @param label - A descriptive name used in error messages.
|
|
68
|
+
* @param parse - Converts a raw URL segment string into the parsed value.
|
|
69
|
+
* @param print - Converts the parsed value back into a URL segment string.
|
|
70
|
+
*/
|
|
32
71
|
export declare const param: <A>(label: string, parse: (segment: string) => Effect.Effect<A, ParseError>, print: (value: A) => string) => Biparser<A>;
|
|
72
|
+
/**
|
|
73
|
+
* Creates a parser that captures a URL segment as a named string field.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* string('slug') // parses /hello into { slug: "hello" }
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
33
80
|
export declare const string: <K extends string>(name: K) => Biparser<Record<K, string>>;
|
|
81
|
+
/**
|
|
82
|
+
* Creates a parser that captures a URL segment as a named integer field.
|
|
83
|
+
*
|
|
84
|
+
* Fails if the segment is not a valid integer.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* int('id') // parses /42 into { id: 42 }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
34
91
|
export declare const int: <K extends string>(name: K) => Biparser<Record<K, number>>;
|
|
92
|
+
/**
|
|
93
|
+
* A parser that matches the root path with no remaining segments.
|
|
94
|
+
*
|
|
95
|
+
* Succeeds only when the URL path is exactly `/`.
|
|
96
|
+
*/
|
|
35
97
|
export declare const root: Biparser<{}>;
|
|
98
|
+
/**
|
|
99
|
+
* A parse-only parser with no print/build capabilities.
|
|
100
|
+
*
|
|
101
|
+
* Returned by `oneOf`, which combines multiple parsers whose print
|
|
102
|
+
* types may differ and therefore cannot be unified into a single `Biparser`.
|
|
103
|
+
*/
|
|
36
104
|
export type Parser<A> = {
|
|
37
105
|
parse: (segments: ReadonlyArray<string>, search?: string) => Effect.Effect<ParseResult<A>, ParseError>;
|
|
38
106
|
};
|
|
107
|
+
/**
|
|
108
|
+
* Combines multiple parsers, trying each in order until one succeeds.
|
|
109
|
+
*
|
|
110
|
+
* Returns a `Parser` (parse-only) since the union of different route
|
|
111
|
+
* shapes cannot provide a single unified print function.
|
|
112
|
+
*/
|
|
39
113
|
export declare function oneOf<A>(p1: Biparser<A> | Parser<A>): Parser<A>;
|
|
40
114
|
export declare function oneOf<A, B = never>(p1: Biparser<A> | Parser<A>, p2: Biparser<B> | Parser<B>): Parser<A | B>;
|
|
41
115
|
export declare function oneOf<A, B = never, C = never>(p1: Biparser<A> | Parser<A>, p2: Biparser<B> | Parser<B>, p3: Biparser<C> | Parser<C>): Parser<A | B | C>;
|
|
@@ -46,6 +120,18 @@ export declare function oneOf<A, B = never, C = never, D = never, E = never, F =
|
|
|
46
120
|
export declare function oneOf<A, B = never, C = never, D = never, E = never, F = never, G = never, H = never>(p1: Biparser<A> | Parser<A>, p2: Biparser<B> | Parser<B>, p3: Biparser<C> | Parser<C>, p4: Biparser<D> | Parser<D>, p5: Biparser<E> | Parser<E>, p6: Biparser<F> | Parser<F>, p7: Biparser<G> | Parser<G>, p8: Biparser<H> | Parser<H>): Parser<A | B | C | D | E | F | G | H>;
|
|
47
121
|
export declare function oneOf<A, B = never, C = never, D = never, E = never, F = never, G = never, H = never, I = never>(p1: Biparser<A> | Parser<A>, p2: Biparser<B> | Parser<B>, p3: Biparser<C> | Parser<C>, p4: Biparser<D> | Parser<D>, p5: Biparser<E> | Parser<E>, p6: Biparser<F> | Parser<F>, p7: Biparser<G> | Parser<G>, p8: Biparser<H> | Parser<H>, p9: Biparser<I> | Parser<I>): Parser<A | B | C | D | E | F | G | H | I>;
|
|
48
122
|
export declare function oneOf<A, B = never, C = never, D = never, E = never, F = never, G = never, H = never, I = never, J = never>(p1: Biparser<A> | Parser<A>, p2: Biparser<B> | Parser<B>, p3: Biparser<C> | Parser<C>, p4: Biparser<D> | Parser<D>, p5: Biparser<E> | Parser<E>, p6: Biparser<F> | Parser<F>, p7: Biparser<G> | Parser<G>, p8: Biparser<H> | Parser<H>, p9: Biparser<I> | Parser<I>, p10: Biparser<J> | Parser<J>): Parser<A | B | C | D | E | F | G | H | I | J>;
|
|
123
|
+
/**
|
|
124
|
+
* Converts a `Biparser` into a `Router` by mapping parsed values to a
|
|
125
|
+
* tagged type constructor.
|
|
126
|
+
*
|
|
127
|
+
* The resulting `Router` can both parse URLs into tagged route values and
|
|
128
|
+
* build URLs from route payloads.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* pipe(literal('users'), slash(int('id')), mapTo(UserRoute))
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
49
135
|
export declare const mapTo: {
|
|
50
136
|
<T>(appRouteConstructor: {
|
|
51
137
|
make: () => T;
|
|
@@ -54,11 +140,46 @@ export declare const mapTo: {
|
|
|
54
140
|
make: (data: A) => T;
|
|
55
141
|
}): (parser: Biparser<A>) => Router<T>;
|
|
56
142
|
};
|
|
143
|
+
/**
|
|
144
|
+
* Composes two `Biparser`s sequentially, combining their parsed values.
|
|
145
|
+
*
|
|
146
|
+
* Cannot be used after `query` since query parameters are terminal.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* pipe(literal('users'), slash(int('id'))) // matches /users/42
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
57
153
|
export declare const slash: <A extends Record<string, unknown>, B extends Record<string, unknown>>(parserB: Biparser<A>) => (parserA: Biparser<B> & {
|
|
58
154
|
readonly __terminal?: never;
|
|
59
155
|
readonly "Cannot use slash after query - query parameters must be terminal"?: never;
|
|
60
156
|
}) => Biparser<B & A>;
|
|
157
|
+
/**
|
|
158
|
+
* Adds query parameter parsing to a `Biparser` using an Effect `Schema`.
|
|
159
|
+
*
|
|
160
|
+
* Produces a `TerminalParser` that cannot be extended with `slash`,
|
|
161
|
+
* since query parameters must appear at the end of a route definition.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```ts
|
|
165
|
+
* pipe(
|
|
166
|
+
* literal('search'),
|
|
167
|
+
* query(S.Struct({ q: S.String })),
|
|
168
|
+
* mapTo(SearchRoute),
|
|
169
|
+
* )
|
|
170
|
+
* ```
|
|
171
|
+
*
|
|
172
|
+
* @param schema - An Effect Schema describing the expected query parameters.
|
|
173
|
+
*/
|
|
61
174
|
export declare const query: <A, I extends Record.ReadonlyRecord<string, unknown>>(schema: Schema.Schema<A, I>) => <B extends Record<string, unknown>>(parser: Biparser<B>) => TerminalParser<B & A>;
|
|
175
|
+
/**
|
|
176
|
+
* Parses a URL against a parser, falling back to a not-found route if no
|
|
177
|
+
* parser matches.
|
|
178
|
+
*
|
|
179
|
+
* @param parser - The parser (typically from `oneOf`) to attempt.
|
|
180
|
+
* @param notFoundRouteConstructor - Constructor called with `{ path }` when
|
|
181
|
+
* no route matches.
|
|
182
|
+
*/
|
|
62
183
|
export declare const parseUrlWithFallback: <A, B>(parser: Parser<A>, notFoundRouteConstructor: {
|
|
63
184
|
make: (data: {
|
|
64
185
|
path: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/route/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EAGN,MAAM,EACN,MAAM,EAIP,MAAM,QAAQ,CAAA;AAEf,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;;;;AAE5B;;;;;GAKG;AACH,qBAAa,UAAW,SAAQ,gBAA+B;IAC7D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAC3B,CAAC;CAAG;AAEL;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,CAAA;AAEvD,KAAK,UAAU,GAAG;IAChB,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC/B,WAAW,EAAE,eAAe,CAAA;CAC7B,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;IACxB,KAAK,EA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vC,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,KAAK,GACf,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnE,SAAS,QAAQ,CAAC,CAAC,CAAC,MAGpB,SAAS,QAAQ,CAAC,CAAC,CAAC,GAAG;IACrB,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,CAAA;IAC3B,QAAQ,CAAC,kEAAkE,CAAC,EAAE,KAAK,CAAA;CACpF,KACA,QAAQ,CAAC,CAAC,GAAG,CAAC,CAmBf,CAAA;AAEJ;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,KAAK,GACf,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,EAClD,QAAQ,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,MAE5B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,QAAQ,QAAQ,CAAC,CAAC,CAAC,KAClB,cAAc,CAAC,CAAC,GAAG,CAAC,CAiEtB,CAAA;AA6BH;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,GAC9B,CAAC,EAAE,CAAC,EACH,QAAQ,MAAM,CAAC,CAAC,CAAC,EACjB,0BAA0B;IAAE,IAAI,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,CAAC,CAAA;CAAE,MAElE,KAAK,GAAG,KAAG,CAAC,GAAG,CAQb,CAAA"}
|
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import { Array, Data, Effect, Option, Predicate, Record, Schema, String, flow, pipe, } from 'effect';
|
|
2
|
+
/**
|
|
3
|
+
* Error type for route parsing failures.
|
|
4
|
+
*
|
|
5
|
+
* Includes optional `expected`, `actual`, and `position` fields for
|
|
6
|
+
* diagnostic context when a URL segment does not match.
|
|
7
|
+
*/
|
|
2
8
|
export class ParseError extends Data.TaggedError('ParseError') {
|
|
3
9
|
}
|
|
4
10
|
const makeTerminalParser = (parser) =>
|
|
5
11
|
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
|
|
6
12
|
parser;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a parser that matches an exact URL path segment.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* literal('users') // matches /users
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
7
21
|
export const literal = (segment) => ({
|
|
8
22
|
parse: (segments) => Array.matchLeft(segments, {
|
|
9
23
|
onEmpty: () => Effect.fail(new ParseError({
|
|
@@ -26,6 +40,13 @@ export const literal = (segment) => ({
|
|
|
26
40
|
segments: [...state.segments, segment],
|
|
27
41
|
}),
|
|
28
42
|
});
|
|
43
|
+
/**
|
|
44
|
+
* Creates a parser for a dynamic URL segment with custom parse and print functions.
|
|
45
|
+
*
|
|
46
|
+
* @param label - A descriptive name used in error messages.
|
|
47
|
+
* @param parse - Converts a raw URL segment string into the parsed value.
|
|
48
|
+
* @param print - Converts the parsed value back into a URL segment string.
|
|
49
|
+
*/
|
|
29
50
|
export const param = (label, parse, print) => ({
|
|
30
51
|
parse: (segments) => Array.matchLeft(segments, {
|
|
31
52
|
onEmpty: () => Effect.fail(new ParseError({
|
|
@@ -41,9 +62,27 @@ export const param = (label, parse, print) => ({
|
|
|
41
62
|
segments: [...state.segments, print(value)],
|
|
42
63
|
}),
|
|
43
64
|
});
|
|
65
|
+
/**
|
|
66
|
+
* Creates a parser that captures a URL segment as a named string field.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* string('slug') // parses /hello into { slug: "hello" }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
44
73
|
export const string = (name) => param(`string (${name})`,
|
|
45
74
|
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
|
|
46
75
|
(segment) => Effect.succeed({ [name]: segment }), (record) => record[name]);
|
|
76
|
+
/**
|
|
77
|
+
* Creates a parser that captures a URL segment as a named integer field.
|
|
78
|
+
*
|
|
79
|
+
* Fails if the segment is not a valid integer.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* int('id') // parses /42 into { id: 42 }
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
47
86
|
export const int = (name) => param(`integer (${name})`, (segment) => {
|
|
48
87
|
const parsed = parseInt(segment, 10);
|
|
49
88
|
return isNaN(parsed) || parsed.toString() !== segment
|
|
@@ -55,6 +94,11 @@ export const int = (name) => param(`integer (${name})`, (segment) => {
|
|
|
55
94
|
: /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
|
|
56
95
|
Effect.succeed({ [name]: parsed });
|
|
57
96
|
}, (record) => record[name].toString());
|
|
97
|
+
/**
|
|
98
|
+
* A parser that matches the root path with no remaining segments.
|
|
99
|
+
*
|
|
100
|
+
* Succeeds only when the URL path is exactly `/`.
|
|
101
|
+
*/
|
|
58
102
|
export const root = {
|
|
59
103
|
parse: (segments) => Array.matchLeft(segments, {
|
|
60
104
|
onEmpty: () => Effect.succeed([{}, []]),
|
|
@@ -80,6 +124,18 @@ export function oneOf(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) {
|
|
|
80
124
|
}),
|
|
81
125
|
};
|
|
82
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Converts a `Biparser` into a `Router` by mapping parsed values to a
|
|
129
|
+
* tagged type constructor.
|
|
130
|
+
*
|
|
131
|
+
* The resulting `Router` can both parse URLs into tagged route values and
|
|
132
|
+
* build URLs from route payloads.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```ts
|
|
136
|
+
* pipe(literal('users'), slash(int('id')), mapTo(UserRoute))
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
83
139
|
export const mapTo = (appRouteConstructor) => {
|
|
84
140
|
return (parser) => {
|
|
85
141
|
return {
|
|
@@ -93,6 +149,16 @@ export const mapTo = (appRouteConstructor) => {
|
|
|
93
149
|
};
|
|
94
150
|
};
|
|
95
151
|
};
|
|
152
|
+
/**
|
|
153
|
+
* Composes two `Biparser`s sequentially, combining their parsed values.
|
|
154
|
+
*
|
|
155
|
+
* Cannot be used after `query` since query parameters are terminal.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* pipe(literal('users'), slash(int('id'))) // matches /users/42
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
96
162
|
export const slash = (parserB) => (parserA) => ({
|
|
97
163
|
parse: (segments, search) => pipe(parserA.parse(segments, search), Effect.flatMap(([valueA, remainingA]) => pipe(parserB.parse(remainingA, search), Effect.map(([valueB, remainingB]) => [
|
|
98
164
|
{ ...valueA, ...valueB },
|
|
@@ -100,6 +166,23 @@ export const slash = (parserB) => (parserA) => ({
|
|
|
100
166
|
])))),
|
|
101
167
|
print: (value, state) => pipe(parserA.print(value, state), Effect.flatMap((newState) => parserB.print(value, newState))),
|
|
102
168
|
});
|
|
169
|
+
/**
|
|
170
|
+
* Adds query parameter parsing to a `Biparser` using an Effect `Schema`.
|
|
171
|
+
*
|
|
172
|
+
* Produces a `TerminalParser` that cannot be extended with `slash`,
|
|
173
|
+
* since query parameters must appear at the end of a route definition.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```ts
|
|
177
|
+
* pipe(
|
|
178
|
+
* literal('search'),
|
|
179
|
+
* query(S.Struct({ q: S.String })),
|
|
180
|
+
* mapTo(SearchRoute),
|
|
181
|
+
* )
|
|
182
|
+
* ```
|
|
183
|
+
*
|
|
184
|
+
* @param schema - An Effect Schema describing the expected query parameters.
|
|
185
|
+
*/
|
|
103
186
|
export const query = (schema) => (parser) => {
|
|
104
187
|
const queryParser = {
|
|
105
188
|
parse: (segments, search) => {
|
|
@@ -148,6 +231,14 @@ const complete = ([value, remaining]) => Array.match(remaining, {
|
|
|
148
231
|
const parseUrl = (parser) => (url) => {
|
|
149
232
|
return pipe(pathToSegments(url.pathname), (segments) => parser.parse(segments, Option.getOrUndefined(url.search)), Effect.flatMap(complete));
|
|
150
233
|
};
|
|
234
|
+
/**
|
|
235
|
+
* Parses a URL against a parser, falling back to a not-found route if no
|
|
236
|
+
* parser matches.
|
|
237
|
+
*
|
|
238
|
+
* @param parser - The parser (typically from `oneOf`) to attempt.
|
|
239
|
+
* @param notFoundRouteConstructor - Constructor called with `{ path }` when
|
|
240
|
+
* no route matches.
|
|
241
|
+
*/
|
|
151
242
|
export const parseUrlWithFallback = (parser, notFoundRouteConstructor) => (url) => pipe(url, parseUrl(parser), Effect.orElse(() => Effect.succeed(notFoundRouteConstructor.make({ path: url.pathname }))), Effect.runSync);
|
|
152
243
|
const buildUrl = (parser) => (data) => {
|
|
153
244
|
const initialState = {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/route/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,OAAO,EACP,KAAK,EACL,MAAM,EACN,GAAG,EACH,IAAI,EACJ,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,oBAAoB,GACrB,MAAM,SAAS,CAAA;AAEhB,YAAY,EACV,WAAW,EACX,QAAQ,EACR,MAAM,EACN,cAAc,EACd,MAAM,GACP,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ParseError, literal, param, string, int, root, oneOf, mapTo, slash, query, parseUrlWithFallback, } from './index';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { makeElement, makeApplication, run, makeCommandStreams, } from './runtime';
|
|
2
|
+
export type { BrowserConfig, Command, CommandStream, CommandStreams, ElementConfigWithFlags, ElementConfigWithoutFlags, ApplicationConfigWithFlags, ApplicationConfigWithoutFlags, ElementInit, ApplicationInit, MakeRuntimeReturn, } from './runtime';
|
|
3
|
+
export { UrlRequest } from './urlRequest';
|
|
4
|
+
export type { Internal, External } from './urlRequest';
|
|
5
|
+
//# sourceMappingURL=public.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/runtime/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,eAAe,EACf,GAAG,EACH,kBAAkB,GACnB,MAAM,WAAW,CAAA;AAElB,YAAY,EACV,aAAa,EACb,OAAO,EACP,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,EAC1B,6BAA6B,EAC7B,WAAW,EACX,eAAe,EACf,iBAAiB,GAClB,MAAM,WAAW,CAAA;AAElB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -6,13 +6,17 @@ declare const Dispatch_base: Context.TagClass<Dispatch, "@foldkit/Dispatch", {
|
|
|
6
6
|
readonly dispatchAsync: (message: unknown) => Effect.Effect<void>;
|
|
7
7
|
readonly dispatchSync: (message: unknown) => void;
|
|
8
8
|
}>;
|
|
9
|
+
/** Effect service tag that provides message dispatching to the view layer. */
|
|
9
10
|
export declare class Dispatch extends Dispatch_base {
|
|
10
11
|
}
|
|
12
|
+
/** An `Effect` that produces a message, used for side effects in the update function. */
|
|
11
13
|
export type Command<Message> = Effect.Effect<Message>;
|
|
14
|
+
/** Configuration for browser URL integration with handlers for URL requests and URL changes. */
|
|
12
15
|
export type BrowserConfig<Message> = {
|
|
13
16
|
readonly onUrlRequest: (request: UrlRequest) => Message;
|
|
14
17
|
readonly onUrlChange: (url: Url) => Message;
|
|
15
18
|
};
|
|
19
|
+
/** Full runtime configuration including model schema, flags, init, update, view, and optional browser/stream config. */
|
|
16
20
|
export interface RuntimeConfig<Model, Message, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Flags> {
|
|
17
21
|
Model: Schema.Schema<Model, any, never>;
|
|
18
22
|
Flags: Schema.Schema<Flags, any, never>;
|
|
@@ -33,11 +37,13 @@ interface BaseElementConfig<Model, Message, StreamDepsMap extends Schema.Struct<
|
|
|
33
37
|
readonly container: HTMLElement;
|
|
34
38
|
readonly errorView?: (error: Error) => Html;
|
|
35
39
|
}
|
|
40
|
+
/** Configuration for `makeElement` when the element receives initial data via flags. */
|
|
36
41
|
export interface ElementConfigWithFlags<Model, Message, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Flags> extends BaseElementConfig<Model, Message, StreamDepsMap> {
|
|
37
42
|
readonly Flags: Schema.Schema<Flags, any, never>;
|
|
38
43
|
readonly flags: Effect.Effect<Flags>;
|
|
39
44
|
readonly init: (flags: Flags) => [Model, ReadonlyArray<Command<Message>>];
|
|
40
45
|
}
|
|
46
|
+
/** Configuration for `makeElement` without flags. */
|
|
41
47
|
export interface ElementConfigWithoutFlags<Model, Message, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>> extends BaseElementConfig<Model, Message, StreamDepsMap> {
|
|
42
48
|
readonly init: () => [Model, ReadonlyArray<Command<Message>>];
|
|
43
49
|
}
|
|
@@ -50,16 +56,21 @@ interface BaseApplicationConfig<Model, Message, StreamDepsMap extends Schema.Str
|
|
|
50
56
|
readonly browser: BrowserConfig<Message>;
|
|
51
57
|
readonly errorView?: (error: Error) => Html;
|
|
52
58
|
}
|
|
59
|
+
/** Configuration for `makeApplication` when the application receives initial data via flags. */
|
|
53
60
|
export interface ApplicationConfigWithFlags<Model, Message, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Flags> extends BaseApplicationConfig<Model, Message, StreamDepsMap> {
|
|
54
61
|
readonly Flags: Schema.Schema<Flags, any, never>;
|
|
55
62
|
readonly flags: Effect.Effect<Flags>;
|
|
56
63
|
readonly init: (flags: Flags, url: Url) => [Model, ReadonlyArray<Command<Message>>];
|
|
57
64
|
}
|
|
65
|
+
/** Configuration for `makeApplication` without flags. */
|
|
58
66
|
export interface ApplicationConfigWithoutFlags<Model, Message, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>> extends BaseApplicationConfig<Model, Message, StreamDepsMap> {
|
|
59
67
|
readonly init: (url: Url) => [Model, ReadonlyArray<Command<Message>>];
|
|
60
68
|
}
|
|
69
|
+
/** The `init` function type for elements, with an optional `flags` parameter when `Flags` is not `void`. */
|
|
61
70
|
export type ElementInit<Model, Message, Flags = void> = Flags extends void ? () => [Model, ReadonlyArray<Command<Message>>] : (flags: Flags) => [Model, ReadonlyArray<Command<Message>>];
|
|
71
|
+
/** The `init` function type for applications, receives the current URL and optional flags. */
|
|
62
72
|
export type ApplicationInit<Model, Message, Flags = void> = Flags extends void ? (url: Url) => [Model, ReadonlyArray<Command<Message>>] : (flags: Flags, url: Url) => [Model, ReadonlyArray<Command<Message>>];
|
|
73
|
+
/** A reactive stream configuration that maps model changes to a stream of commands. */
|
|
63
74
|
export type CommandStream<Model, Message, StreamDeps> = {
|
|
64
75
|
readonly modelToDeps: (model: Model) => StreamDeps;
|
|
65
76
|
readonly depsToStream: (deps: StreamDeps) => Stream.Stream<Command<Message>>;
|
|
@@ -67,9 +78,11 @@ export type CommandStream<Model, Message, StreamDeps> = {
|
|
|
67
78
|
type CommandStreamConfig<Model, Message, StreamDeps> = {
|
|
68
79
|
readonly schema: Schema.Schema<StreamDeps>;
|
|
69
80
|
} & CommandStream<Model, Message, StreamDeps>;
|
|
81
|
+
/** A record of named command stream configurations, keyed by dependency field name. */
|
|
70
82
|
export type CommandStreams<Model, Message, CommandStreamsDeps extends Schema.Struct<any>> = {
|
|
71
83
|
readonly [K in keyof Schema.Schema.Type<CommandStreamsDeps>]: CommandStreamConfig<Model, Message, Schema.Schema.Type<CommandStreamsDeps>[K]>;
|
|
72
84
|
};
|
|
85
|
+
/** Creates type-safe command stream configurations from a dependency schema. */
|
|
73
86
|
export declare const makeCommandStreams: <CommandStreamsDeps extends Schema.Struct<any>>(CommandStreamsDeps: CommandStreamsDeps) => <Model, Message>(configs: { [K in keyof Schema.Schema.Type<CommandStreamsDeps>]: {
|
|
74
87
|
modelToDeps: (model: Model) => Schema.Schema.Type<CommandStreamsDeps>[K];
|
|
75
88
|
depsToStream: (deps: Schema.Schema.Type<CommandStreamsDeps>[K]) => Stream.Stream<Command<Message>>;
|
|
@@ -78,19 +91,23 @@ export declare const makeCommandStreams: <CommandStreamsDeps extends Schema.Stru
|
|
|
78
91
|
modelToDeps: (model: Model) => Schema.Schema.Type<CommandStreamsDeps>[K];
|
|
79
92
|
depsToStream: (deps: Schema.Schema.Type<CommandStreamsDeps>[K]) => Stream.Stream<Command<Message>>;
|
|
80
93
|
}>;
|
|
81
|
-
|
|
94
|
+
/** A configured Foldkit runtime returned by `makeElement` or `makeApplication`, passed to `run` to start the application. */
|
|
95
|
+
export type MakeRuntimeReturn = (hmrModel?: unknown) => Effect.Effect<void>;
|
|
96
|
+
/** Creates a Foldkit element (no URL routing) and returns a runtime that can be passed to `run`. */
|
|
82
97
|
export declare function makeElement<Model, Message extends {
|
|
83
98
|
_tag: string;
|
|
84
99
|
}, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Flags>(config: ElementConfigWithFlags<Model, Message, StreamDepsMap, Flags>): MakeRuntimeReturn;
|
|
85
100
|
export declare function makeElement<Model, Message extends {
|
|
86
101
|
_tag: string;
|
|
87
102
|
}, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>>(config: ElementConfigWithoutFlags<Model, Message, StreamDepsMap>): MakeRuntimeReturn;
|
|
103
|
+
/** Creates a Foldkit application with URL routing and returns a runtime that can be passed to `run`. */
|
|
88
104
|
export declare function makeApplication<Model, Message extends {
|
|
89
105
|
_tag: string;
|
|
90
106
|
}, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>, Flags>(config: ApplicationConfigWithFlags<Model, Message, StreamDepsMap, Flags>): MakeRuntimeReturn;
|
|
91
107
|
export declare function makeApplication<Model, Message extends {
|
|
92
108
|
_tag: string;
|
|
93
109
|
}, StreamDepsMap extends Schema.Struct<Schema.Struct.Fields>>(config: ApplicationConfigWithoutFlags<Model, Message, StreamDepsMap>): MakeRuntimeReturn;
|
|
110
|
+
/** Starts a Foldkit runtime, with HMR support for development. */
|
|
94
111
|
export declare const run: (foldkitRuntime: MakeRuntimeReturn) => void;
|
|
95
112
|
export {};
|
|
96
113
|
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,OAAO,EACP,MAAM,EASN,MAAM,EACN,MAAM,EAGP,MAAM,QAAQ,CAAA;AAGf,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,GAAG,EAA+B,MAAM,QAAQ,CAAA;AAOzD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,OAAO,EACP,MAAM,EASN,MAAM,EACN,MAAM,EAGP,MAAM,QAAQ,CAAA;AAGf,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,GAAG,EAA+B,MAAM,QAAQ,CAAA;AAOzD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;;4BAMb,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;2BAC1C,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI;;AALrD,8EAA8E;AAC9E,qBAAa,QAAS,SAAQ,aAM3B;CAAG;AAEN,yFAAyF;AACzF,MAAM,MAAM,OAAO,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;AAErD,gGAAgG;AAChG,MAAM,MAAM,aAAa,CAAC,OAAO,IA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AAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAChC,aAAa,SAAS,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EACzD,KAAK,EAEL,MAAM,EAAE,0BAA0B,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,CAAC,GACvE,iBAAiB,CAAA;AAEpB,wBAAgB,eAAe,CAC7B,KAAK,EACL,OAAO,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAChC,aAAa,SAAS,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAEzD,MAAM,EAAE,6BAA6B,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,GACnE,iBAAiB,CAAA;AA+CpB,kEAAkE;AAClE,eAAO,MAAM,GAAG,GAAI,gBAAgB,iBAAiB,KAAG,IAUvD,CAAA"}
|
package/dist/runtime/runtime.js
CHANGED
|
@@ -5,8 +5,10 @@ import { fromString as urlFromString } from '../url';
|
|
|
5
5
|
import { patch, toVNode } from '../vdom';
|
|
6
6
|
import { addBfcacheRestoreListener, addNavigationEventListeners, } from './browserListeners';
|
|
7
7
|
import { defaultErrorView, noOpDispatch } from './errorUI';
|
|
8
|
+
/** Effect service tag that provides message dispatching to the view layer. */
|
|
8
9
|
export class Dispatch extends Context.Tag('@foldkit/Dispatch')() {
|
|
9
10
|
}
|
|
11
|
+
/** Creates type-safe command stream configurations from a dependency schema. */
|
|
10
12
|
export const makeCommandStreams = (CommandStreamsDeps) => (configs) => Record.map(configs, ({ modelToDeps, depsToStream }, key) => ({
|
|
11
13
|
schema: CommandStreamsDeps.fields[key],
|
|
12
14
|
modelToDeps,
|
|
@@ -183,9 +185,7 @@ const preserveModel = (model) => {
|
|
|
183
185
|
import.meta.hot.send('foldkit:preserve-model', model);
|
|
184
186
|
}
|
|
185
187
|
};
|
|
186
|
-
|
|
187
|
-
* Run a Foldkit application
|
|
188
|
-
*/
|
|
188
|
+
/** Starts a Foldkit runtime, with HMR support for development. */
|
|
189
189
|
export const run = (foldkitRuntime) => {
|
|
190
190
|
if (import.meta.hot) {
|
|
191
191
|
import.meta.hot.on('foldkit:restore-model', (model) => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Schema as S } from 'effect';
|
|
2
|
+
/** A URL request to a page within the application (same origin). */
|
|
2
3
|
export declare const Internal: S.TaggedStruct<"Internal", {
|
|
3
4
|
url: S.Struct<{
|
|
4
5
|
protocol: typeof S.String;
|
|
@@ -9,11 +10,15 @@ export declare const Internal: S.TaggedStruct<"Internal", {
|
|
|
9
10
|
hash: S.OptionFromSelf<typeof S.String>;
|
|
10
11
|
}>;
|
|
11
12
|
}>;
|
|
13
|
+
/** A URL request to a page within the application (same origin). */
|
|
12
14
|
export type Internal = typeof Internal.Type;
|
|
15
|
+
/** A URL request to an external page (different origin). */
|
|
13
16
|
export declare const External: S.TaggedStruct<"External", {
|
|
14
17
|
href: typeof S.String;
|
|
15
18
|
}>;
|
|
19
|
+
/** A URL request to an external page (different origin). */
|
|
16
20
|
export type External = typeof External.Type;
|
|
21
|
+
/** Union of `Internal` and `External` URL request types. */
|
|
17
22
|
export declare const UrlRequest: S.Union<[S.TaggedStruct<"Internal", {
|
|
18
23
|
url: S.Struct<{
|
|
19
24
|
protocol: typeof S.String;
|
|
@@ -26,5 +31,6 @@ export declare const UrlRequest: S.Union<[S.TaggedStruct<"Internal", {
|
|
|
26
31
|
}>, S.TaggedStruct<"External", {
|
|
27
32
|
href: typeof S.String;
|
|
28
33
|
}>]>;
|
|
34
|
+
/** Union of `Internal` and `External` URL request types. */
|
|
29
35
|
export type UrlRequest = typeof UrlRequest.Type;
|
|
30
36
|
//# sourceMappingURL=urlRequest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urlRequest.d.ts","sourceRoot":"","sources":["../../src/runtime/urlRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAIpC,eAAO,MAAM,QAAQ;;;;;;;;;EAEnB,CAAA;AACF,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAA;AAE3C,eAAO,MAAM,QAAQ;;EAEnB,CAAA;AACF,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAA;AAE3C,eAAO,MAAM,UAAU;;;;;;;;;;;IAA8B,CAAA;AACrD,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAA"}
|
|
1
|
+
{"version":3,"file":"urlRequest.d.ts","sourceRoot":"","sources":["../../src/runtime/urlRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAIpC,oEAAoE;AACpE,eAAO,MAAM,QAAQ;;;;;;;;;EAEnB,CAAA;AACF,oEAAoE;AACpE,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAA;AAE3C,4DAA4D;AAC5D,eAAO,MAAM,QAAQ;;EAEnB,CAAA;AACF,4DAA4D;AAC5D,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAA;AAE3C,4DAA4D;AAC5D,eAAO,MAAM,UAAU;;;;;;;;;;;IAA8B,CAAA;AACrD,4DAA4D;AAC5D,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAA"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { Schema as S } from 'effect';
|
|
2
2
|
import { Url } from '../url';
|
|
3
|
+
/** A URL request to a page within the application (same origin). */
|
|
3
4
|
export const Internal = S.TaggedStruct('Internal', {
|
|
4
5
|
url: Url,
|
|
5
6
|
});
|
|
7
|
+
/** A URL request to an external page (different origin). */
|
|
6
8
|
export const External = S.TaggedStruct('External', {
|
|
7
9
|
href: S.String,
|
|
8
10
|
});
|
|
11
|
+
/** Union of `Internal` and `External` URL request types. */
|
|
9
12
|
export const UrlRequest = S.Union(Internal, External);
|
|
@@ -17,4 +17,4 @@ export declare const ts: {
|
|
|
17
17
|
<Tag extends string>(tag: Tag): S.TaggedStruct<Tag, {}>;
|
|
18
18
|
<Tag extends string, Fields extends S.Struct.Fields>(tag: Tag, fields: Fields): S.TaggedStruct<Tag, Fields>;
|
|
19
19
|
};
|
|
20
|
-
//# sourceMappingURL=
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAEpC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,EAAE,EAAE;IACf,CAAC,GAAG,SAAS,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,YAAY,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;IACvD,CAAC,GAAG,SAAS,MAAM,EAAE,MAAM,SAAS,CAAC,CAAC,MAAM,CAAC,MAAM,EACjD,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,GACb,CAAC,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;CAIM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/schema/public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ts } from './index';
|
|
@@ -7,9 +7,10 @@ type StrictKeys<O, T> = T extends Record<string, any> ? Exclude<keyof T, keyof O
|
|
|
7
7
|
type Evolved<O, T> = {
|
|
8
8
|
[K in keyof O]: K extends keyof T ? T[K] extends (a: any) => infer R ? R : O[K] : O[K];
|
|
9
9
|
};
|
|
10
|
+
/** Immutably updates fields of a struct by applying transform functions. Wraps Effect's `Struct.evolve` with stricter key checking. */
|
|
10
11
|
export declare const evo: {
|
|
11
12
|
<O, const T extends EvolveTransform<O>>(t: StrictKeys<O, T>): (obj: O) => Evolved<O, T>;
|
|
12
13
|
<O, const T extends EvolveTransform<O>>(obj: O, t: StrictKeys<O, T>): Evolved<O, T>;
|
|
13
14
|
};
|
|
14
15
|
export {};
|
|
15
|
-
//# sourceMappingURL=
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/struct/index.ts"],"names":[],"mappings":"AAEA,KAAK,eAAe,CAAC,CAAC,IAAI,OAAO,CAAC;KAC/B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;CAClC,CAAC,CAAA;AAEF,KAAK,UAAU,CAAC,CAAC,EAAE,CAAC,IAClB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACzB,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,SAAS,KAAK,GACrC,CAAC,GACD,CAAC,GAAG;KACD,CAAC,IAAI,gBAAgB,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,KAAK;CACnE,GACH,KAAK,CAAA;AAEX,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI;KAClB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,GAC7B,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,KAAK,MAAM,CAAC,GAC9B,CAAC,GACD,CAAC,CAAC,CAAC,CAAC,GACN,CAAC,CAAC,CAAC,CAAC;CACT,CAAA;AAED,uIAAuI;AACvI,eAAO,MAAM,GAAG,EAAE;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