@warlock.js/web 5.0.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/CHANGELOG.md +49 -0
- package/LICENSE +21 -0
- package/README.md +125 -0
- package/esm/build/contribution.d.mts +55 -0
- package/esm/build/contribution.mjs +132 -0
- package/esm/build/contribution.mjs.map +1 -0
- package/esm/build/discover-pages.mjs +294 -0
- package/esm/build/discover-pages.mjs.map +1 -0
- package/esm/build/generate-client-registry.mjs +123 -0
- package/esm/build/generate-client-registry.mjs.map +1 -0
- package/esm/build/generate-pages-barrel.mjs +330 -0
- package/esm/build/generate-pages-barrel.mjs.map +1 -0
- package/esm/build/read-route-exports.mjs +212 -0
- package/esm/build/read-route-exports.mjs.map +1 -0
- package/esm/client/build-hydrated-tree.mjs +113 -0
- package/esm/client/build-hydrated-tree.mjs.map +1 -0
- package/esm/client/hydrate-page.mjs +73 -0
- package/esm/client/hydrate-page.mjs.map +1 -0
- package/esm/client/navigation/current-route.d.mts +91 -0
- package/esm/client/navigation/current-route.mjs +66 -0
- package/esm/client/navigation/current-route.mjs.map +1 -0
- package/esm/client/navigation/fetch-page-data.mjs +97 -0
- package/esm/client/navigation/fetch-page-data.mjs.map +1 -0
- package/esm/client/navigation/navigation-root.mjs +196 -0
- package/esm/client/navigation/navigation-root.mjs.map +1 -0
- package/esm/client/navigation/prefetch.mjs +110 -0
- package/esm/client/navigation/prefetch.mjs.map +1 -0
- package/esm/client/navigation/refresh.d.mts +40 -0
- package/esm/client/navigation/refresh.mjs +146 -0
- package/esm/client/navigation/refresh.mjs.map +1 -0
- package/esm/client/navigation/verbs.d.mts +55 -0
- package/esm/client/navigation/verbs.mjs +66 -0
- package/esm/client/navigation/verbs.mjs.map +1 -0
- package/esm/client/runtime/index.d.mts +4 -0
- package/esm/client/runtime/index.mjs +4 -0
- package/esm/client/runtime/manifest.d.mts +8 -0
- package/esm/client/runtime/manifest.mjs +77 -0
- package/esm/client/runtime/manifest.mjs.map +1 -0
- package/esm/client/runtime/matcher.d.mts +7 -0
- package/esm/client/runtime/matcher.mjs +169 -0
- package/esm/client/runtime/matcher.mjs.map +1 -0
- package/esm/client/runtime/types.d.mts +22 -0
- package/esm/components/default-app.mjs +32 -0
- package/esm/components/default-app.mjs.map +1 -0
- package/esm/components/document-context.d.mts +1 -0
- package/esm/components/document-context.mjs +24 -0
- package/esm/components/document-context.mjs.map +1 -0
- package/esm/components/head.d.mts +14 -0
- package/esm/components/head.mjs +63 -0
- package/esm/components/head.mjs.map +1 -0
- package/esm/components/link.d.mts +157 -0
- package/esm/components/link.mjs +194 -0
- package/esm/components/link.mjs.map +1 -0
- package/esm/components/scripts.d.mts +14 -0
- package/esm/components/scripts.mjs +21 -0
- package/esm/components/scripts.mjs.map +1 -0
- package/esm/connector/index.d.mts +6 -0
- package/esm/connector/index.mjs +7 -0
- package/esm/context.d.mts +107 -0
- package/esm/hydration/index.d.mts +1 -0
- package/esm/hydration/index.mjs +33 -0
- package/esm/hydration/index.mjs.map +1 -0
- package/esm/hydration-payload.d.mts +1 -0
- package/esm/hydration-payload.mjs +72 -0
- package/esm/hydration-payload.mjs.map +1 -0
- package/esm/index.d.mts +35 -0
- package/esm/index.mjs +12 -0
- package/esm/loaders.d.mts +47 -0
- package/esm/metadata.d.mts +54 -0
- package/esm/props.d.mts +42 -0
- package/esm/route.d.mts +30 -0
- package/esm/routing/compose-route-path.mjs +33 -0
- package/esm/routing/compose-route-path.mjs.map +1 -0
- package/esm/routing/data-request.mjs +52 -0
- package/esm/routing/data-request.mjs.map +1 -0
- package/esm/routing/layout-policy.mjs +78 -0
- package/esm/routing/layout-policy.mjs.map +1 -0
- package/esm/routing/navigator.mjs +21 -0
- package/esm/routing/navigator.mjs.map +1 -0
- package/esm/routing/query-string.d.mts +250 -0
- package/esm/routing/query-string.mjs +340 -0
- package/esm/routing/query-string.mjs.map +1 -0
- package/esm/routing/route-identity.mjs +68 -0
- package/esm/routing/route-identity.mjs.map +1 -0
- package/esm/routing/route-table.d.mts +34 -0
- package/esm/routing/route-table.mjs +182 -0
- package/esm/routing/route-table.mjs.map +1 -0
- package/esm/routing/router-events.d.mts +159 -0
- package/esm/routing/router-events.mjs +83 -0
- package/esm/routing/router-events.mjs.map +1 -0
- package/esm/server/buffered-response.mjs +115 -0
- package/esm/server/buffered-response.mjs.map +1 -0
- package/esm/server/build-hydration-payload.mjs +27 -0
- package/esm/server/build-hydration-payload.mjs.map +1 -0
- package/esm/server/client-asset-url-prefix.d.mts +22 -0
- package/esm/server/client-asset-url-prefix.mjs +23 -0
- package/esm/server/client-asset-url-prefix.mjs.map +1 -0
- package/esm/server/create-page-module-loader.mjs +49 -0
- package/esm/server/create-page-module-loader.mjs.map +1 -0
- package/esm/server/create-page-route-handler.mjs +107 -0
- package/esm/server/create-page-route-handler.mjs.map +1 -0
- package/esm/server/dev-server.mjs +167 -0
- package/esm/server/dev-server.mjs.map +1 -0
- package/esm/server/execute-page-request.d.mts +1 -0
- package/esm/server/execute-page-request.mjs +166 -0
- package/esm/server/execute-page-request.mjs.map +1 -0
- package/esm/server/execute-page-request.types.d.mts +1 -0
- package/esm/server/hydration-client-url.d.mts +37 -0
- package/esm/server/hydration-client-url.mjs +101 -0
- package/esm/server/hydration-client-url.mjs.map +1 -0
- package/esm/server/index.mjs +13 -0
- package/esm/server/install-page-routes-from-manifest.mjs +133 -0
- package/esm/server/install-page-routes-from-manifest.mjs.map +1 -0
- package/esm/server/install-page-routes.d.mts +1 -0
- package/esm/server/install-page-routes.mjs +6 -0
- package/esm/server/install-production-page-routes.mjs +55 -0
- package/esm/server/install-production-page-routes.mjs.map +1 -0
- package/esm/server/match-page-route.mjs +48 -0
- package/esm/server/match-page-route.mjs.map +1 -0
- package/esm/server/page-context.d.mts +1 -0
- package/esm/server/page-context.mjs +33 -0
- package/esm/server/page-context.mjs.map +1 -0
- package/esm/server/page-manifest.d.mts +102 -0
- package/esm/server/page-manifest.mjs +31 -0
- package/esm/server/page-manifest.mjs.map +1 -0
- package/esm/server/render-page.mjs +214 -0
- package/esm/server/render-page.mjs.map +1 -0
- package/esm/server/resolve-page-metadata.mjs +33 -0
- package/esm/server/resolve-page-metadata.mjs.map +1 -0
- package/esm/server/resolve-validation-data.mjs +27 -0
- package/esm/server/resolve-validation-data.mjs.map +1 -0
- package/esm/server/settle-page-response.d.mts +1 -0
- package/esm/server/settle-page-response.mjs +90 -0
- package/esm/server/settle-page-response.mjs.map +1 -0
- package/esm/server/stylesheet-urls.mjs +65 -0
- package/esm/server/stylesheet-urls.mjs.map +1 -0
- package/esm/server/web-connector-factory.d.mts +25 -0
- package/esm/server/web-connector-factory.mjs +121 -0
- package/esm/server/web-connector-factory.mjs.map +1 -0
- package/esm/server/web-connector.d.mts +34 -0
- package/esm/server/web-connector.mjs +516 -0
- package/esm/server/web-connector.mjs.map +1 -0
- package/esm/shared.d.mts +22 -0
- package/esm/shared.mjs +223 -0
- package/esm/shared.mjs.map +1 -0
- package/esm/validation.d.mts +31 -0
- package/esm/vite/app-convention-aliases.mjs +43 -0
- package/esm/vite/app-convention-aliases.mjs.map +1 -0
- package/esm/vite/build-client.d.mts +38 -0
- package/esm/vite/build-client.mjs +72 -0
- package/esm/vite/build-client.mjs.map +1 -0
- package/esm/vite/gate-a-resolve.d.mts +57 -0
- package/esm/vite/gate-a-resolve.mjs +834 -0
- package/esm/vite/gate-a-resolve.mjs.map +1 -0
- package/esm/vite/gate-b-secrets.d.mts +57 -0
- package/esm/vite/gate-b-secrets.mjs +299 -0
- package/esm/vite/gate-b-secrets.mjs.map +1 -0
- package/esm/vite/gate-c-verify.d.mts +118 -0
- package/esm/vite/gate-c-verify.mjs +263 -0
- package/esm/vite/gate-c-verify.mjs.map +1 -0
- package/esm/vite/hydration-entries.d.mts +17 -0
- package/esm/vite/hydration-entries.mjs +45 -0
- package/esm/vite/hydration-entries.mjs.map +1 -0
- package/esm/vite/index.d.mts +126 -0
- package/esm/vite/index.mjs +146 -0
- package/esm/vite/index.mjs.map +1 -0
- package/esm/vite/page-registry-plugin.d.mts +43 -0
- package/esm/vite/page-registry-plugin.mjs +138 -0
- package/esm/vite/page-registry-plugin.mjs.map +1 -0
- package/esm/vite/projection.d.mts +31 -0
- package/esm/vite/projection.mjs +384 -0
- package/esm/vite/projection.mjs.map +1 -0
- package/llms-full.txt +1041 -0
- package/llms.txt +21 -0
- package/package.json +77 -0
- package/skills/add-web-to-an-app/SKILL.md +103 -0
- package/skills/create-a-page/SKILL.md +141 -0
- package/skills/load-page-data/SKILL.md +183 -0
- package/skills/navigate-on-the-client/SKILL.md +182 -0
- package/skills/serve-styles/SKILL.md +145 -0
- package/skills/use-layouts/SKILL.md +121 -0
- package/skills/write-the-root/SKILL.md +131 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
//#region ../web/src/routing/query-string.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The query string: BOTH directions, one grammar, one file.
|
|
4
|
+
*
|
|
5
|
+
* ── The rule this module exists to obey ──────────────────────────────────────
|
|
6
|
+
*
|
|
7
|
+
* `queryStringOf` is what `href(name, params, query)` appends, and therefore
|
|
8
|
+
* what every `<Link>` puts in the document; `queryString.parse` is what reads it
|
|
9
|
+
* back. They live together because a second, independently-written
|
|
10
|
+
* query-string implementation would mean one thing writes URLs and a different
|
|
11
|
+
* thing reads them. Query-string libraries genuinely disagree about arrays,
|
|
12
|
+
* nested objects and space escaping, so the moment the two drift the round trip
|
|
13
|
+
* loses data SILENTLY — the wrong value renders and no error is raised
|
|
14
|
+
* anywhere. That is the two-route-matchers failure class (canon 9c8f878b) one
|
|
15
|
+
* layer down.
|
|
16
|
+
*
|
|
17
|
+
* Escaping is not two rules that agree today. Both directions stand on
|
|
18
|
+
* `URLSearchParams`: the encoder builds one and calls `.toString()`, the decoder
|
|
19
|
+
* hands the string back to `new URLSearchParams(...)`. `+`-for-space and every
|
|
20
|
+
* percent-encoding rule are therefore ONE rule and cannot drift.
|
|
21
|
+
*
|
|
22
|
+
* ── The grammar, and why it is not ours to choose ────────────────────────────
|
|
23
|
+
*
|
|
24
|
+
* Structure — arrays and nested objects — is the part `URLSearchParams` has no
|
|
25
|
+
* opinion about, so it was read off the SERVER rather than invented. Warlock is
|
|
26
|
+
* a backend framework and core already parses query strings for list endpoints
|
|
27
|
+
* and filters; a client that emitted anything else would not have fixed this
|
|
28
|
+
* module's bug, it would have moved it across the wire where it is harder to
|
|
29
|
+
* see. Measured, with file:line, in
|
|
30
|
+
* `reports/query-grammar-findings-2026-08-24.md`:
|
|
31
|
+
*
|
|
32
|
+
* - `core/src/http/server.ts:14-36` configures Fastify with NO
|
|
33
|
+
* `querystringParser`, so find-my-way's `fast-querystring` default applies:
|
|
34
|
+
* flat keys, `+` is a space, a repeated key collapses to an array.
|
|
35
|
+
* - `core/src/http/request.ts:491` then runs `request.query` through
|
|
36
|
+
* `parseBody` — the SAME bracket-aware parser as the request body.
|
|
37
|
+
* - `core/src/http/request.ts:516-520` reads `key[]` as an array marker, and
|
|
38
|
+
* `:568-575` wraps a single `key[]=a` into the one-element array `["a"]`.
|
|
39
|
+
* - `core/src/http/request.ts:557-561` turns `key[sub]=v` into
|
|
40
|
+
* `{key: {sub: v}}`, one level deep.
|
|
41
|
+
*
|
|
42
|
+
* So: `tags[]=a&tags[]=b` for arrays, `filter[status]=active` for objects,
|
|
43
|
+
* `filter[tags][]=a` for an array inside an object. Bare repeated keys
|
|
44
|
+
* (`tags=a&tags=b`) would also reach core as an array, but only at cardinality
|
|
45
|
+
* two or more — `tags=a` comes back as the scalar `"a"`, and a shape that
|
|
46
|
+
* changes with the number of matches is a `TypeError` waiting for the day a
|
|
47
|
+
* filter matches one item. `[]` is the form core wrote a branch for.
|
|
48
|
+
*
|
|
49
|
+
* ── What is REFUSED, and why refusing is the safe answer ─────────────────────
|
|
50
|
+
*
|
|
51
|
+
* Two levels of nesting is not a gap in core, it is measured data loss:
|
|
52
|
+
* `a[b][c]=x` takes the `][` branch at `core/src/http/request.ts:528-551`,
|
|
53
|
+
* computes `Number("b")` as `NaN`, and the value lands on a `NaN` index and
|
|
54
|
+
* vanishes — core answers `{a: []}`. So the encoder throws
|
|
55
|
+
* {@link UnserializableQueryValueError} rather than write it. `href()` already
|
|
56
|
+
* throws on a missing route parameter rather than emit a link that renders
|
|
57
|
+
* correctly and 404s; this is the same call.
|
|
58
|
+
*
|
|
59
|
+
* ── What the encoder still normalises, and what that costs ───────────────────
|
|
60
|
+
*
|
|
61
|
+
* Leaf values are serialised with `String(value)`, so every value arrives back
|
|
62
|
+
* as a `string`: `href("p", {}, { page: 2 })` writes `?page=2`, and `2` and
|
|
63
|
+
* `"2"` are the same URL. The round-trip law that can actually hold is
|
|
64
|
+
* `parse(encode(query)) === query with String() applied to its leaves and
|
|
65
|
+
* undefined dropped`, and that is what the spec asserts. Asserting anything
|
|
66
|
+
* stronger would be asserting a decoder that guesses types, which is how
|
|
67
|
+
* `?zip=01234` becomes the number `1234`.
|
|
68
|
+
*
|
|
69
|
+
* The decoder does NOT split values on `,`: that would turn the legitimate
|
|
70
|
+
* string `"Doe, John"` into `["Doe", " John"]`, trading a visible limitation for
|
|
71
|
+
* a silent corruption of ordinary data. Arrays are carried by `[]`, which is
|
|
72
|
+
* unambiguous, so there is nothing left to guess at.
|
|
73
|
+
*
|
|
74
|
+
* ── Universal by requirement, not by accident ────────────────────────────────
|
|
75
|
+
*
|
|
76
|
+
* `web` renders on the server first, so every export here is safe to import and
|
|
77
|
+
* to CALL with no DOM. `@mongez/react-router`'s equivalent reads
|
|
78
|
+
* `window.location.search` unguarded (query-string.ts:22) and throws under SSR.
|
|
79
|
+
* Here the browser-only readers return their empty answer instead — see
|
|
80
|
+
* `queryString.all` for the hydration caveat that comes with that.
|
|
81
|
+
*
|
|
82
|
+
* ── Still NOT here: `toQueryString` and `update` ─────────────────────────────
|
|
83
|
+
*
|
|
84
|
+
* MRR exposes `toQueryString(params)` and `update(params)`, which SERIALISE.
|
|
85
|
+
* The serialiser they need is no longer module-private — `queryStringOf` is
|
|
86
|
+
* exported from here — so the old blocker is gone. What remains is that
|
|
87
|
+
* `web/src/index.ts` does not re-export it yet, and the barrel is owned
|
|
88
|
+
* elsewhere. That is a one-line follow-up, not a redesign.
|
|
89
|
+
*/
|
|
90
|
+
/** A decoded leaf. Always a `string` — see the header on `String(value)`. */
|
|
91
|
+
type QueryStringLeaf = string;
|
|
92
|
+
/**
|
|
93
|
+
* The inside of a `key[sub]` bag: one level deep, exactly as far as core parses.
|
|
94
|
+
*
|
|
95
|
+
* There is no deeper case to model. `key[sub][deeper]` is refused by the encoder
|
|
96
|
+
* and carried verbatim as a literal key by the decoder, so a nested bag only
|
|
97
|
+
* ever holds a leaf or an array of leaves.
|
|
98
|
+
*/
|
|
99
|
+
type QueryStringNested = Record<string, QueryStringLeaf | QueryStringLeaf[]>;
|
|
100
|
+
/** A decoded value: a leaf, a `key[]` array, or a `key[sub]` bag. */
|
|
101
|
+
type QueryStringValue = QueryStringLeaf | QueryStringLeaf[] | QueryStringNested;
|
|
102
|
+
/** A decoded query string. */
|
|
103
|
+
type QueryStringObject = Record<string, QueryStringValue>;
|
|
104
|
+
/** What {@link queryStringOf} accepts. Values are validated, not trusted. */
|
|
105
|
+
type QueryStringInput = Readonly<Record<string, unknown>>;
|
|
106
|
+
/**
|
|
107
|
+
* Thrown when a query value has a shape the wire format cannot carry.
|
|
108
|
+
*
|
|
109
|
+
* Deliberately LOUD. The alternative is emitting something core silently
|
|
110
|
+
* mangles — `a[b][c]=x` arrives as `{a: []}` — which is this defect all over
|
|
111
|
+
* again, one layer further from where anyone would look for it.
|
|
112
|
+
*/
|
|
113
|
+
declare class UnserializableQueryValueError extends Error {
|
|
114
|
+
readonly queryKey: string;
|
|
115
|
+
readonly shape: string;
|
|
116
|
+
constructor(queryKey: string, shape: string);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Serialise a query object to a search string, INCLUDING the leading `?`.
|
|
120
|
+
*
|
|
121
|
+
* Returns `""` — not `"?"` — when there is nothing to write, so the result can
|
|
122
|
+
* always be concatenated onto a path. `href()` is the primary caller; the
|
|
123
|
+
* grammar it emits is the one core parses, and the whole justification is in the
|
|
124
|
+
* module header.
|
|
125
|
+
*
|
|
126
|
+
* @throws {UnserializableQueryValueError} when a value nests deeper than the
|
|
127
|
+
* wire format can carry.
|
|
128
|
+
*/
|
|
129
|
+
declare function queryStringOf(query: QueryStringInput | undefined): string;
|
|
130
|
+
/**
|
|
131
|
+
* What to do when the same PLAIN key appears more than once, e.g. `?tag=a&tag=b`.
|
|
132
|
+
*
|
|
133
|
+
* - `"last"` — keep the final occurrence. Matches `URLSearchParams.get()`, the
|
|
134
|
+
* read side of the primitive the encoder writes with, and keeps every value a
|
|
135
|
+
* `string`.
|
|
136
|
+
* - `"first"` — keep the earliest occurrence.
|
|
137
|
+
* - `"array"` — collect every occurrence. Under this strategy a key that occurs
|
|
138
|
+
* ONCE is still an array of one, because a shape that changes with the number
|
|
139
|
+
* of values is a `TypeError` waiting for the day a filter matches a single
|
|
140
|
+
* item.
|
|
141
|
+
*
|
|
142
|
+
* It does NOT govern `key[]` or `key[sub]`; those are shapes the encoder writes
|
|
143
|
+
* deliberately, and their meaning is fixed. See {@link QueryStringOptions}.
|
|
144
|
+
*/
|
|
145
|
+
type RepeatedKeyStrategy = "last" | "first" | "array";
|
|
146
|
+
/**
|
|
147
|
+
* The whole option surface.
|
|
148
|
+
*
|
|
149
|
+
* ── Why this is one flag and not MRR's pluggable parsers ─────────────────────
|
|
150
|
+
*
|
|
151
|
+
* MRR's `setQueryStringOptions` swaps `objectParser` and `stringParser`
|
|
152
|
+
* (query-string.ts:10-15). Neither survives contact with a fixed, shared
|
|
153
|
+
* encoder:
|
|
154
|
+
*
|
|
155
|
+
* - A pluggable `objectParser` is a licence to install a READER that disagrees
|
|
156
|
+
* with the writer. It is precisely the silent round-trip break this module
|
|
157
|
+
* was written to prevent, offered as a supported API.
|
|
158
|
+
* - A pluggable `stringParser` would be worse: it cannot reach `href()`, which
|
|
159
|
+
* calls `queryStringOf` directly with no hook. Setting it would change what
|
|
160
|
+
* this module emits while every `<Link>` on the page kept emitting the old
|
|
161
|
+
* format — two writers, disagreeing, by configuration.
|
|
162
|
+
*
|
|
163
|
+
* `repeatedKeys` is safe for one specific reason, and the reason survived the
|
|
164
|
+
* move to bracket notation: `queryStringOf` iterates `Object.entries`, so it can
|
|
165
|
+
* never emit a duplicate PLAIN key. It now does emit duplicate `key[]` pairs —
|
|
166
|
+
* that is how an array is written — but those go down the array branch of the
|
|
167
|
+
* decoder, which this flag does not touch. Were the flag to govern the bracket
|
|
168
|
+
* forms as well, `repeatedKeys: "array"` would decode `filter[x]=1` as
|
|
169
|
+
* `{filter: {x: ["1"]}}` and break the round trip BY CONFIGURATION.
|
|
170
|
+
*
|
|
171
|
+
* So the flag still decides only something the encoder has no opinion about: a
|
|
172
|
+
* repeated plain key, which can only arrive from a URL this package did not
|
|
173
|
+
* write — hand-typed, external links, `GET` forms.
|
|
174
|
+
*
|
|
175
|
+
* Set it at BOOT, not per request: this is process-global config, and a
|
|
176
|
+
* request-scoped write would be read by whatever request happens to be
|
|
177
|
+
* rendering (the defect catalogued at route-table.ts:10-25).
|
|
178
|
+
*/
|
|
179
|
+
type QueryStringOptions = {
|
|
180
|
+
readonly repeatedKeys?: RepeatedKeyStrategy;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Merge query-string options over the current ones.
|
|
184
|
+
*
|
|
185
|
+
* Named for `@mongez/react-router`'s function so migrating call sites keep
|
|
186
|
+
* compiling; the OPTIONS are deliberately narrower, and `QueryStringOptions`
|
|
187
|
+
* explains exactly which ones were refused and why.
|
|
188
|
+
*/
|
|
189
|
+
declare function setQueryStringOptions(options: QueryStringOptions): void;
|
|
190
|
+
/**
|
|
191
|
+
* Drop back to the defaults.
|
|
192
|
+
*
|
|
193
|
+
* Exists because the options are process-global: a test that set one would
|
|
194
|
+
* otherwise leak it into every later test in the same worker, passing in file
|
|
195
|
+
* order and failing under `--shuffle`. Same reasoning as `resetRouteTable`.
|
|
196
|
+
*/
|
|
197
|
+
declare function resetQueryStringOptions(): void;
|
|
198
|
+
/**
|
|
199
|
+
* Reading the current query string, and any query string.
|
|
200
|
+
*
|
|
201
|
+
* Named for `@mongez/react-router`'s object so the familiar calls keep working;
|
|
202
|
+
* the implementation is not ported — see the module header for what changed and
|
|
203
|
+
* why.
|
|
204
|
+
*/
|
|
205
|
+
declare const queryString: {
|
|
206
|
+
/**
|
|
207
|
+
* The current document's query string, decoded.
|
|
208
|
+
*
|
|
209
|
+
* On the server this is `{}`, because the browser location is the only source
|
|
210
|
+
* this module has and a per-request one would be module state two concurrent
|
|
211
|
+
* requests could race over (route-table.ts:10-25).
|
|
212
|
+
*
|
|
213
|
+
* That makes it a HYDRATION HAZARD in a component: the server renders `{}`
|
|
214
|
+
* and the browser renders the real values, so the two trees differ. In a
|
|
215
|
+
* component, take the query from the page's own props and hand it to
|
|
216
|
+
* {@link queryString.parse}, which is universal. `all()` is for browser-only
|
|
217
|
+
* code — an event handler, an effect, a client-side helper.
|
|
218
|
+
*/
|
|
219
|
+
all(): QueryStringObject;
|
|
220
|
+
/**
|
|
221
|
+
* Decode a query string that was handed to you.
|
|
222
|
+
*
|
|
223
|
+
* Universal: it reads no globals, so this is the entry point that is safe on
|
|
224
|
+
* the server. Accepts a bare pair list, a leading `?`, a path, or a full URL.
|
|
225
|
+
*/
|
|
226
|
+
parse(search: string): QueryStringObject;
|
|
227
|
+
/**
|
|
228
|
+
* One key from the current query string.
|
|
229
|
+
*
|
|
230
|
+
* PRESENCE, not truthiness. MRR returns `all[key] || defaultValue`
|
|
231
|
+
* (query-string.ts:43), which hands back the default for `?a=` — so a
|
|
232
|
+
* deliberately-cleared filter reads as though it was never set, and the page
|
|
233
|
+
* shows the default instead of the empty state. Here `?a=` returns `""`, and
|
|
234
|
+
* only an absent key returns the default.
|
|
235
|
+
*
|
|
236
|
+
* @param defaultValue returned only when the key is absent. Defaults to
|
|
237
|
+
* `null`, as MRR's does.
|
|
238
|
+
*/
|
|
239
|
+
get<T = null>(key: string, defaultValue?: T): QueryStringValue | T;
|
|
240
|
+
/**
|
|
241
|
+
* The current query string verbatim, without the leading `?`.
|
|
242
|
+
*
|
|
243
|
+
* `""` on the server, and `""` when there is no query — the same two cases
|
|
244
|
+
* `queryStringOf` collapses when it writes.
|
|
245
|
+
*/
|
|
246
|
+
toString(): string;
|
|
247
|
+
};
|
|
248
|
+
//#endregion
|
|
249
|
+
export { QueryStringInput, QueryStringLeaf, QueryStringNested, QueryStringObject, QueryStringOptions, QueryStringValue, RepeatedKeyStrategy, UnserializableQueryValueError, queryString, queryStringOf, resetQueryStringOptions, setQueryStringOptions };
|
|
250
|
+
//# sourceMappingURL=query-string.d.mts.map
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
//#region ../web/src/routing/query-string.ts
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when a query value has a shape the wire format cannot carry.
|
|
4
|
+
*
|
|
5
|
+
* Deliberately LOUD. The alternative is emitting something core silently
|
|
6
|
+
* mangles — `a[b][c]=x` arrives as `{a: []}` — which is this defect all over
|
|
7
|
+
* again, one layer further from where anyone would look for it.
|
|
8
|
+
*/
|
|
9
|
+
var UnserializableQueryValueError = class extends Error {
|
|
10
|
+
queryKey;
|
|
11
|
+
shape;
|
|
12
|
+
constructor(queryKey, shape) {
|
|
13
|
+
super(`Warlock cannot put ${shape} in a query string at "${queryKey}". The wire format is the one @warlock.js/core parses (core/src/http/request.ts:503-591): a value may be a scalar, an array of scalars (\`key[]=a&key[]=b\`), or an object one level deep whose values are scalars or arrays of scalars (\`key[sub]=a\`, \`key[sub][]=a\`). Anything deeper is refused rather than written, because core reads \`a[b][c]=x\` back as \`{a: []}\` — the value is destroyed on arrival with no error. Flatten the value, or JSON.stringify it into a single scalar and parse it on the server.`);
|
|
14
|
+
this.queryKey = queryKey;
|
|
15
|
+
this.shape = shape;
|
|
16
|
+
this.name = "UnserializableQueryValueError";
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Is this a BAG of query keys, as opposed to a value with its own string form?
|
|
21
|
+
*
|
|
22
|
+
* A `Date`, a `URL` or anything else carrying its own `toString` is a scalar
|
|
23
|
+
* here — `String(value)` is meaningful for it, and turning it into
|
|
24
|
+
* `since[getTime]=...` would be absurd. A plain object, or a class instance that
|
|
25
|
+
* would otherwise stringify to the useless `"[object Object]"`, is a bag and
|
|
26
|
+
* gets enumerated.
|
|
27
|
+
*
|
|
28
|
+
* The `typeof` check matters for null-prototype objects: they have no
|
|
29
|
+
* `toString` at all, and `String()` on one THROWS.
|
|
30
|
+
*/
|
|
31
|
+
function isKeyBag(value) {
|
|
32
|
+
const stringForm = value.toString;
|
|
33
|
+
return typeof stringForm !== "function" || stringForm === Object.prototype.toString;
|
|
34
|
+
}
|
|
35
|
+
/** Refuse anything that is not a leaf. Used everywhere a leaf is the only legal shape. */
|
|
36
|
+
function requireLeaf(key, value) {
|
|
37
|
+
if (Array.isArray(value)) throw new UnserializableQueryValueError(key, "a nested array");
|
|
38
|
+
if (typeof value === "object" && value !== null && isKeyBag(value)) throw new UnserializableQueryValueError(key, "a nested object");
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Append `key[]=element` per element.
|
|
42
|
+
*
|
|
43
|
+
* An `undefined` element is skipped, matching the top-level rule. Because the
|
|
44
|
+
* `[]` form carries no indices, skipping shortens the array rather than leaving
|
|
45
|
+
* a hole — there is no hole to leave.
|
|
46
|
+
*
|
|
47
|
+
* An EMPTY array appends nothing, so the key is absent from the URL. The format
|
|
48
|
+
* has no way to say "an array with no elements": `key[]=` means the one-element
|
|
49
|
+
* array `[""]`, which is a different value. A visible limitation beats a guess.
|
|
50
|
+
*/
|
|
51
|
+
function appendArray(search, key, value) {
|
|
52
|
+
const arrayKey = `${key}[]`;
|
|
53
|
+
for (const element of value) {
|
|
54
|
+
if (element === void 0) continue;
|
|
55
|
+
requireLeaf(arrayKey, element);
|
|
56
|
+
search.append(arrayKey, String(element));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/** Append `key[sub]=value`, or `key[sub][]=value` when the member is an array. */
|
|
60
|
+
function appendBag(search, key, value) {
|
|
61
|
+
for (const [subKey, subValue] of Object.entries(value)) {
|
|
62
|
+
if (subValue === void 0) continue;
|
|
63
|
+
const nestedKey = `${key}[${subKey}]`;
|
|
64
|
+
if (Array.isArray(subValue)) {
|
|
65
|
+
appendArray(search, nestedKey, subValue);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
requireLeaf(nestedKey, subValue);
|
|
69
|
+
search.append(nestedKey, String(subValue));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Serialise a query object to a search string, INCLUDING the leading `?`.
|
|
74
|
+
*
|
|
75
|
+
* Returns `""` — not `"?"` — when there is nothing to write, so the result can
|
|
76
|
+
* always be concatenated onto a path. `href()` is the primary caller; the
|
|
77
|
+
* grammar it emits is the one core parses, and the whole justification is in the
|
|
78
|
+
* module header.
|
|
79
|
+
*
|
|
80
|
+
* @throws {UnserializableQueryValueError} when a value nests deeper than the
|
|
81
|
+
* wire format can carry.
|
|
82
|
+
*/
|
|
83
|
+
function queryStringOf(query) {
|
|
84
|
+
if (query === void 0) return "";
|
|
85
|
+
const search = new URLSearchParams();
|
|
86
|
+
for (const [key, value] of Object.entries(query)) {
|
|
87
|
+
if (value === void 0) continue;
|
|
88
|
+
if (Array.isArray(value)) {
|
|
89
|
+
appendArray(search, key, value);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (typeof value === "object" && value !== null && isKeyBag(value)) {
|
|
93
|
+
appendBag(search, key, value);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
search.append(key, String(value));
|
|
97
|
+
}
|
|
98
|
+
const serialized = search.toString();
|
|
99
|
+
return serialized === "" ? "" : `?${serialized}`;
|
|
100
|
+
}
|
|
101
|
+
const DEFAULT_OPTIONS = { repeatedKeys: "last" };
|
|
102
|
+
/**
|
|
103
|
+
* Held on `globalThis`, not in a module binding, for the reason measured and
|
|
104
|
+
* written up at route-table.ts:43-65: in dev the process runs two module graphs
|
|
105
|
+
* over these files (tsx/Node and Vite's SSR runner), so a `let` written by boot
|
|
106
|
+
* code is not the `let` a component reads. A split here would be quiet — the
|
|
107
|
+
* second graph would silently fall back to the defaults and decode a repeated
|
|
108
|
+
* key the other way.
|
|
109
|
+
*/
|
|
110
|
+
const OPTIONS_SLOT = Symbol.for("warlock.web.queryStringOptions");
|
|
111
|
+
function currentOptions() {
|
|
112
|
+
return globalThis[OPTIONS_SLOT] ?? DEFAULT_OPTIONS;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Merge query-string options over the current ones.
|
|
116
|
+
*
|
|
117
|
+
* Named for `@mongez/react-router`'s function so migrating call sites keep
|
|
118
|
+
* compiling; the OPTIONS are deliberately narrower, and `QueryStringOptions`
|
|
119
|
+
* explains exactly which ones were refused and why.
|
|
120
|
+
*/
|
|
121
|
+
function setQueryStringOptions(options) {
|
|
122
|
+
globalThis[OPTIONS_SLOT] = {
|
|
123
|
+
...currentOptions(),
|
|
124
|
+
...options
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Drop back to the defaults.
|
|
129
|
+
*
|
|
130
|
+
* Exists because the options are process-global: a test that set one would
|
|
131
|
+
* otherwise leak it into every later test in the same worker, passing in file
|
|
132
|
+
* order and failing under `--shuffle`. Same reasoning as `resetRouteTable`.
|
|
133
|
+
*/
|
|
134
|
+
function resetQueryStringOptions() {
|
|
135
|
+
delete globalThis[OPTIONS_SLOT];
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* The search string of the current document, or `""` when there is no document.
|
|
139
|
+
*
|
|
140
|
+
* The `typeof` guard is the SSR contract: no export in this module may touch a
|
|
141
|
+
* DOM global without one.
|
|
142
|
+
*/
|
|
143
|
+
function browserSearch() {
|
|
144
|
+
if (typeof window === "undefined") return "";
|
|
145
|
+
return window.location?.search ?? "";
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Reduce anything search-shaped to the pairs themselves.
|
|
149
|
+
*
|
|
150
|
+
* Accepts `"?a=1"`, `"a=1"`, `"/path?a=1"` and a full URL, because
|
|
151
|
+
* `location.href`, `location.search` and a hand-written literal all turn up at
|
|
152
|
+
* this door and `new URLSearchParams("/path?a=1")` would answer with the key
|
|
153
|
+
* `"/path?a"` — a wrong answer with no error. Cutting at the first `?` and the
|
|
154
|
+
* first `#` is safe rather than heuristic: `queryStringOf` percent-encodes both
|
|
155
|
+
* characters inside values (`%3F`, `%23`), so a literal one is always a
|
|
156
|
+
* delimiter.
|
|
157
|
+
*/
|
|
158
|
+
function searchPairsOf(source) {
|
|
159
|
+
const withoutHash = source.split("#", 1)[0];
|
|
160
|
+
const questionMark = withoutHash.indexOf("?");
|
|
161
|
+
return questionMark === -1 ? withoutHash : withoutHash.slice(questionMark + 1);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* The three key shapes the encoder writes. Everything else is a literal key.
|
|
165
|
+
*
|
|
166
|
+
* The character classes exclude brackets, so each pattern matches exactly one
|
|
167
|
+
* shape: `tags[]` cannot satisfy `NESTED`, and `a[b][c]` satisfies none of them.
|
|
168
|
+
*/
|
|
169
|
+
const ARRAY_KEY = /^([^[\]]+)\[\]$/;
|
|
170
|
+
const NESTED_KEY = /^([^[\]]+)\[([^[\]]+)\]$/;
|
|
171
|
+
const NESTED_ARRAY_KEY = /^([^[\]]+)\[([^[\]]+)\]\[\]$/;
|
|
172
|
+
/**
|
|
173
|
+
* Classify a decoded key.
|
|
174
|
+
*
|
|
175
|
+
* A shape neither side produces — `a[b][c]`, `items[0][name]`, an unbalanced
|
|
176
|
+
* `a[` — falls through to `"plain"` and is carried VERBATIM. Those can only come
|
|
177
|
+
* from a URL warlock did not write, and guessing at them is exactly how a
|
|
178
|
+
* decoder drifts from its writer. Carrying the key as text loses nothing.
|
|
179
|
+
*/
|
|
180
|
+
function parseKey(key) {
|
|
181
|
+
const nestedArray = NESTED_ARRAY_KEY.exec(key);
|
|
182
|
+
if (nestedArray) return {
|
|
183
|
+
kind: "nestedArray",
|
|
184
|
+
name: nestedArray[1],
|
|
185
|
+
subKey: nestedArray[2]
|
|
186
|
+
};
|
|
187
|
+
const array = ARRAY_KEY.exec(key);
|
|
188
|
+
if (array) return {
|
|
189
|
+
kind: "array",
|
|
190
|
+
name: array[1]
|
|
191
|
+
};
|
|
192
|
+
const nested = NESTED_KEY.exec(key);
|
|
193
|
+
if (nested) return {
|
|
194
|
+
kind: "nested",
|
|
195
|
+
name: nested[1],
|
|
196
|
+
subKey: nested[2]
|
|
197
|
+
};
|
|
198
|
+
return {
|
|
199
|
+
kind: "plain",
|
|
200
|
+
name: key
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/** A fresh bag with NO prototype. See {@link decode} for why that is not optional. */
|
|
204
|
+
function emptyBag() {
|
|
205
|
+
return Object.create(null);
|
|
206
|
+
}
|
|
207
|
+
function isBag(value) {
|
|
208
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* The array living at `container[name]`, created if it is not there yet.
|
|
212
|
+
*
|
|
213
|
+
* A conflicting earlier shape is REPLACED rather than written into. `?a=1&a[]=2`
|
|
214
|
+
* is not something the encoder can emit, so it is a foreign URL contradicting
|
|
215
|
+
* itself; appending to a string would be a silent no-op, and last-shape-wins at
|
|
216
|
+
* least matches how `repeatedKeys: "last"` resolves the scalar version.
|
|
217
|
+
*/
|
|
218
|
+
function arrayAt(container, name) {
|
|
219
|
+
const existing = container[name];
|
|
220
|
+
if (Array.isArray(existing)) return existing;
|
|
221
|
+
const created = [];
|
|
222
|
+
container[name] = created;
|
|
223
|
+
return created;
|
|
224
|
+
}
|
|
225
|
+
/** The bag living at `result[name]`, created if absent. Same last-shape-wins rule. */
|
|
226
|
+
function bagAt(result, name) {
|
|
227
|
+
const existing = result[name];
|
|
228
|
+
if (isBag(existing)) return existing;
|
|
229
|
+
const created = emptyBag();
|
|
230
|
+
result[name] = created;
|
|
231
|
+
return created;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* The single decode path. Every reader below goes through here.
|
|
235
|
+
*
|
|
236
|
+
* Every container has a NULL PROTOTYPE — the result and each `key[sub]` bag.
|
|
237
|
+
* Query keys are attacker-controlled, and assigning `?__proto__=x` onto a `{}`
|
|
238
|
+
* literal hits the inherited setter, which DISCARDS the key: data loss with no
|
|
239
|
+
* error. Bracket parsing makes this sharper than it was when this decoder was
|
|
240
|
+
* flat, because `?filter[__proto__]=x` now reaches a nested container too —
|
|
241
|
+
* which is why `bagAt` builds with `Object.create(null)` rather than `{}`.
|
|
242
|
+
* MRR's parser walks `key.split("[")` onto plain objects and needs the blocklist
|
|
243
|
+
* at query-string-parsers.ts:7 as a result; with no prototype there is no setter
|
|
244
|
+
* to hit and the key is stored as the ordinary data it is.
|
|
245
|
+
*/
|
|
246
|
+
function decode(source) {
|
|
247
|
+
const pairs = searchPairsOf(source);
|
|
248
|
+
const result = emptyBag();
|
|
249
|
+
if (pairs === "") return result;
|
|
250
|
+
const { repeatedKeys } = currentOptions();
|
|
251
|
+
for (const [key, value] of new URLSearchParams(pairs)) {
|
|
252
|
+
const parsed = parseKey(key);
|
|
253
|
+
if (parsed.kind === "array") {
|
|
254
|
+
arrayAt(result, parsed.name).push(value);
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
if (parsed.kind === "nestedArray") {
|
|
258
|
+
arrayAt(bagAt(result, parsed.name), parsed.subKey).push(value);
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
if (parsed.kind === "nested") {
|
|
262
|
+
bagAt(result, parsed.name)[parsed.subKey] = value;
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
if (!(parsed.name in result)) {
|
|
266
|
+
result[parsed.name] = repeatedKeys === "array" ? [value] : value;
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
if (repeatedKeys === "first") continue;
|
|
270
|
+
if (repeatedKeys === "last") {
|
|
271
|
+
result[parsed.name] = value;
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
arrayAt(result, parsed.name).push(value);
|
|
275
|
+
}
|
|
276
|
+
return result;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Reading the current query string, and any query string.
|
|
280
|
+
*
|
|
281
|
+
* Named for `@mongez/react-router`'s object so the familiar calls keep working;
|
|
282
|
+
* the implementation is not ported — see the module header for what changed and
|
|
283
|
+
* why.
|
|
284
|
+
*/
|
|
285
|
+
const queryString = {
|
|
286
|
+
/**
|
|
287
|
+
* The current document's query string, decoded.
|
|
288
|
+
*
|
|
289
|
+
* On the server this is `{}`, because the browser location is the only source
|
|
290
|
+
* this module has and a per-request one would be module state two concurrent
|
|
291
|
+
* requests could race over (route-table.ts:10-25).
|
|
292
|
+
*
|
|
293
|
+
* That makes it a HYDRATION HAZARD in a component: the server renders `{}`
|
|
294
|
+
* and the browser renders the real values, so the two trees differ. In a
|
|
295
|
+
* component, take the query from the page's own props and hand it to
|
|
296
|
+
* {@link queryString.parse}, which is universal. `all()` is for browser-only
|
|
297
|
+
* code — an event handler, an effect, a client-side helper.
|
|
298
|
+
*/
|
|
299
|
+
all() {
|
|
300
|
+
return decode(browserSearch());
|
|
301
|
+
},
|
|
302
|
+
/**
|
|
303
|
+
* Decode a query string that was handed to you.
|
|
304
|
+
*
|
|
305
|
+
* Universal: it reads no globals, so this is the entry point that is safe on
|
|
306
|
+
* the server. Accepts a bare pair list, a leading `?`, a path, or a full URL.
|
|
307
|
+
*/
|
|
308
|
+
parse(search) {
|
|
309
|
+
return decode(search);
|
|
310
|
+
},
|
|
311
|
+
/**
|
|
312
|
+
* One key from the current query string.
|
|
313
|
+
*
|
|
314
|
+
* PRESENCE, not truthiness. MRR returns `all[key] || defaultValue`
|
|
315
|
+
* (query-string.ts:43), which hands back the default for `?a=` — so a
|
|
316
|
+
* deliberately-cleared filter reads as though it was never set, and the page
|
|
317
|
+
* shows the default instead of the empty state. Here `?a=` returns `""`, and
|
|
318
|
+
* only an absent key returns the default.
|
|
319
|
+
*
|
|
320
|
+
* @param defaultValue returned only when the key is absent. Defaults to
|
|
321
|
+
* `null`, as MRR's does.
|
|
322
|
+
*/
|
|
323
|
+
get(key, defaultValue = null) {
|
|
324
|
+
const all = decode(browserSearch());
|
|
325
|
+
return key in all ? all[key] : defaultValue;
|
|
326
|
+
},
|
|
327
|
+
/**
|
|
328
|
+
* The current query string verbatim, without the leading `?`.
|
|
329
|
+
*
|
|
330
|
+
* `""` on the server, and `""` when there is no query — the same two cases
|
|
331
|
+
* `queryStringOf` collapses when it writes.
|
|
332
|
+
*/
|
|
333
|
+
toString() {
|
|
334
|
+
return searchPairsOf(browserSearch());
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
//#endregion
|
|
339
|
+
export { UnserializableQueryValueError, queryString, queryStringOf, resetQueryStringOptions, setQueryStringOptions };
|
|
340
|
+
//# sourceMappingURL=query-string.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-string.mjs","names":[],"sources":["../../../../../../../web/src/routing/query-string.ts"],"sourcesContent":["/**\n * The query string: BOTH directions, one grammar, one file.\n *\n * ── The rule this module exists to obey ──────────────────────────────────────\n *\n * `queryStringOf` is what `href(name, params, query)` appends, and therefore\n * what every `<Link>` puts in the document; `queryString.parse` is what reads it\n * back. They live together because a second, independently-written\n * query-string implementation would mean one thing writes URLs and a different\n * thing reads them. Query-string libraries genuinely disagree about arrays,\n * nested objects and space escaping, so the moment the two drift the round trip\n * loses data SILENTLY — the wrong value renders and no error is raised\n * anywhere. That is the two-route-matchers failure class (canon 9c8f878b) one\n * layer down.\n *\n * Escaping is not two rules that agree today. Both directions stand on\n * `URLSearchParams`: the encoder builds one and calls `.toString()`, the decoder\n * hands the string back to `new URLSearchParams(...)`. `+`-for-space and every\n * percent-encoding rule are therefore ONE rule and cannot drift.\n *\n * ── The grammar, and why it is not ours to choose ────────────────────────────\n *\n * Structure — arrays and nested objects — is the part `URLSearchParams` has no\n * opinion about, so it was read off the SERVER rather than invented. Warlock is\n * a backend framework and core already parses query strings for list endpoints\n * and filters; a client that emitted anything else would not have fixed this\n * module's bug, it would have moved it across the wire where it is harder to\n * see. Measured, with file:line, in\n * `reports/query-grammar-findings-2026-08-24.md`:\n *\n * - `core/src/http/server.ts:14-36` configures Fastify with NO\n * `querystringParser`, so find-my-way's `fast-querystring` default applies:\n * flat keys, `+` is a space, a repeated key collapses to an array.\n * - `core/src/http/request.ts:491` then runs `request.query` through\n * `parseBody` — the SAME bracket-aware parser as the request body.\n * - `core/src/http/request.ts:516-520` reads `key[]` as an array marker, and\n * `:568-575` wraps a single `key[]=a` into the one-element array `[\"a\"]`.\n * - `core/src/http/request.ts:557-561` turns `key[sub]=v` into\n * `{key: {sub: v}}`, one level deep.\n *\n * So: `tags[]=a&tags[]=b` for arrays, `filter[status]=active` for objects,\n * `filter[tags][]=a` for an array inside an object. Bare repeated keys\n * (`tags=a&tags=b`) would also reach core as an array, but only at cardinality\n * two or more — `tags=a` comes back as the scalar `\"a\"`, and a shape that\n * changes with the number of matches is a `TypeError` waiting for the day a\n * filter matches one item. `[]` is the form core wrote a branch for.\n *\n * ── What is REFUSED, and why refusing is the safe answer ─────────────────────\n *\n * Two levels of nesting is not a gap in core, it is measured data loss:\n * `a[b][c]=x` takes the `][` branch at `core/src/http/request.ts:528-551`,\n * computes `Number(\"b\")` as `NaN`, and the value lands on a `NaN` index and\n * vanishes — core answers `{a: []}`. So the encoder throws\n * {@link UnserializableQueryValueError} rather than write it. `href()` already\n * throws on a missing route parameter rather than emit a link that renders\n * correctly and 404s; this is the same call.\n *\n * ── What the encoder still normalises, and what that costs ───────────────────\n *\n * Leaf values are serialised with `String(value)`, so every value arrives back\n * as a `string`: `href(\"p\", {}, { page: 2 })` writes `?page=2`, and `2` and\n * `\"2\"` are the same URL. The round-trip law that can actually hold is\n * `parse(encode(query)) === query with String() applied to its leaves and\n * undefined dropped`, and that is what the spec asserts. Asserting anything\n * stronger would be asserting a decoder that guesses types, which is how\n * `?zip=01234` becomes the number `1234`.\n *\n * The decoder does NOT split values on `,`: that would turn the legitimate\n * string `\"Doe, John\"` into `[\"Doe\", \" John\"]`, trading a visible limitation for\n * a silent corruption of ordinary data. Arrays are carried by `[]`, which is\n * unambiguous, so there is nothing left to guess at.\n *\n * ── Universal by requirement, not by accident ────────────────────────────────\n *\n * `web` renders on the server first, so every export here is safe to import and\n * to CALL with no DOM. `@mongez/react-router`'s equivalent reads\n * `window.location.search` unguarded (query-string.ts:22) and throws under SSR.\n * Here the browser-only readers return their empty answer instead — see\n * `queryString.all` for the hydration caveat that comes with that.\n *\n * ── Still NOT here: `toQueryString` and `update` ─────────────────────────────\n *\n * MRR exposes `toQueryString(params)` and `update(params)`, which SERIALISE.\n * The serialiser they need is no longer module-private — `queryStringOf` is\n * exported from here — so the old blocker is gone. What remains is that\n * `web/src/index.ts` does not re-export it yet, and the barrel is owned\n * elsewhere. That is a one-line follow-up, not a redesign.\n */\n\n/** A decoded leaf. Always a `string` — see the header on `String(value)`. */\nexport type QueryStringLeaf = string;\n\n/**\n * The inside of a `key[sub]` bag: one level deep, exactly as far as core parses.\n *\n * There is no deeper case to model. `key[sub][deeper]` is refused by the encoder\n * and carried verbatim as a literal key by the decoder, so a nested bag only\n * ever holds a leaf or an array of leaves.\n */\nexport type QueryStringNested = Record<string, QueryStringLeaf | QueryStringLeaf[]>;\n\n/** A decoded value: a leaf, a `key[]` array, or a `key[sub]` bag. */\nexport type QueryStringValue = QueryStringLeaf | QueryStringLeaf[] | QueryStringNested;\n\n/** A decoded query string. */\nexport type QueryStringObject = Record<string, QueryStringValue>;\n\n/** What {@link queryStringOf} accepts. Values are validated, not trusted. */\nexport type QueryStringInput = Readonly<Record<string, unknown>>;\n\n/**\n * Thrown when a query value has a shape the wire format cannot carry.\n *\n * Deliberately LOUD. The alternative is emitting something core silently\n * mangles — `a[b][c]=x` arrives as `{a: []}` — which is this defect all over\n * again, one layer further from where anyone would look for it.\n */\nexport class UnserializableQueryValueError extends Error {\n public constructor(\n public readonly queryKey: string,\n public readonly shape: string,\n ) {\n super(\n `Warlock cannot put ${shape} in a query string at \"${queryKey}\". The wire format is the ` +\n \"one @warlock.js/core parses (core/src/http/request.ts:503-591): a value may be a \" +\n \"scalar, an array of scalars (`key[]=a&key[]=b`), or an object one level deep whose \" +\n \"values are scalars or arrays of scalars (`key[sub]=a`, `key[sub][]=a`). Anything \" +\n \"deeper is refused rather than written, because core reads `a[b][c]=x` back as \" +\n \"`{a: []}` — the value is destroyed on arrival with no error. Flatten the value, or \" +\n \"JSON.stringify it into a single scalar and parse it on the server.\",\n );\n this.name = \"UnserializableQueryValueError\";\n }\n}\n\n/**\n * Is this a BAG of query keys, as opposed to a value with its own string form?\n *\n * A `Date`, a `URL` or anything else carrying its own `toString` is a scalar\n * here — `String(value)` is meaningful for it, and turning it into\n * `since[getTime]=...` would be absurd. A plain object, or a class instance that\n * would otherwise stringify to the useless `\"[object Object]\"`, is a bag and\n * gets enumerated.\n *\n * The `typeof` check matters for null-prototype objects: they have no\n * `toString` at all, and `String()` on one THROWS.\n */\nfunction isKeyBag(value: object): boolean {\n const stringForm = (value as { toString?: unknown }).toString;\n\n return typeof stringForm !== \"function\" || stringForm === Object.prototype.toString;\n}\n\n/** Refuse anything that is not a leaf. Used everywhere a leaf is the only legal shape. */\nfunction requireLeaf(key: string, value: unknown): void {\n if (Array.isArray(value)) {\n throw new UnserializableQueryValueError(key, \"a nested array\");\n }\n\n if (typeof value === \"object\" && value !== null && isKeyBag(value)) {\n throw new UnserializableQueryValueError(key, \"a nested object\");\n }\n}\n\n/**\n * Append `key[]=element` per element.\n *\n * An `undefined` element is skipped, matching the top-level rule. Because the\n * `[]` form carries no indices, skipping shortens the array rather than leaving\n * a hole — there is no hole to leave.\n *\n * An EMPTY array appends nothing, so the key is absent from the URL. The format\n * has no way to say \"an array with no elements\": `key[]=` means the one-element\n * array `[\"\"]`, which is a different value. A visible limitation beats a guess.\n */\nfunction appendArray(search: URLSearchParams, key: string, value: readonly unknown[]): void {\n const arrayKey = `${key}[]`;\n\n for (const element of value) {\n if (element === undefined) continue;\n\n requireLeaf(arrayKey, element);\n\n search.append(arrayKey, String(element));\n }\n}\n\n/** Append `key[sub]=value`, or `key[sub][]=value` when the member is an array. */\nfunction appendBag(search: URLSearchParams, key: string, value: object): void {\n for (const [subKey, subValue] of Object.entries(value)) {\n if (subValue === undefined) continue;\n\n const nestedKey = `${key}[${subKey}]`;\n\n if (Array.isArray(subValue)) {\n appendArray(search, nestedKey, subValue);\n continue;\n }\n\n requireLeaf(nestedKey, subValue);\n\n search.append(nestedKey, String(subValue));\n }\n}\n\n/**\n * Serialise a query object to a search string, INCLUDING the leading `?`.\n *\n * Returns `\"\"` — not `\"?\"` — when there is nothing to write, so the result can\n * always be concatenated onto a path. `href()` is the primary caller; the\n * grammar it emits is the one core parses, and the whole justification is in the\n * module header.\n *\n * @throws {UnserializableQueryValueError} when a value nests deeper than the\n * wire format can carry.\n */\nexport function queryStringOf(query: QueryStringInput | undefined): string {\n if (query === undefined) return \"\";\n\n const search = new URLSearchParams();\n\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined) continue;\n\n if (Array.isArray(value)) {\n appendArray(search, key, value);\n continue;\n }\n\n if (typeof value === \"object\" && value !== null && isKeyBag(value)) {\n appendBag(search, key, value);\n continue;\n }\n\n search.append(key, String(value));\n }\n\n const serialized = search.toString();\n\n return serialized === \"\" ? \"\" : `?${serialized}`;\n}\n\n/**\n * What to do when the same PLAIN key appears more than once, e.g. `?tag=a&tag=b`.\n *\n * - `\"last\"` — keep the final occurrence. Matches `URLSearchParams.get()`, the\n * read side of the primitive the encoder writes with, and keeps every value a\n * `string`.\n * - `\"first\"` — keep the earliest occurrence.\n * - `\"array\"` — collect every occurrence. Under this strategy a key that occurs\n * ONCE is still an array of one, because a shape that changes with the number\n * of values is a `TypeError` waiting for the day a filter matches a single\n * item.\n *\n * It does NOT govern `key[]` or `key[sub]`; those are shapes the encoder writes\n * deliberately, and their meaning is fixed. See {@link QueryStringOptions}.\n */\nexport type RepeatedKeyStrategy = \"last\" | \"first\" | \"array\";\n\n/**\n * The whole option surface.\n *\n * ── Why this is one flag and not MRR's pluggable parsers ─────────────────────\n *\n * MRR's `setQueryStringOptions` swaps `objectParser` and `stringParser`\n * (query-string.ts:10-15). Neither survives contact with a fixed, shared\n * encoder:\n *\n * - A pluggable `objectParser` is a licence to install a READER that disagrees\n * with the writer. It is precisely the silent round-trip break this module\n * was written to prevent, offered as a supported API.\n * - A pluggable `stringParser` would be worse: it cannot reach `href()`, which\n * calls `queryStringOf` directly with no hook. Setting it would change what\n * this module emits while every `<Link>` on the page kept emitting the old\n * format — two writers, disagreeing, by configuration.\n *\n * `repeatedKeys` is safe for one specific reason, and the reason survived the\n * move to bracket notation: `queryStringOf` iterates `Object.entries`, so it can\n * never emit a duplicate PLAIN key. It now does emit duplicate `key[]` pairs —\n * that is how an array is written — but those go down the array branch of the\n * decoder, which this flag does not touch. Were the flag to govern the bracket\n * forms as well, `repeatedKeys: \"array\"` would decode `filter[x]=1` as\n * `{filter: {x: [\"1\"]}}` and break the round trip BY CONFIGURATION.\n *\n * So the flag still decides only something the encoder has no opinion about: a\n * repeated plain key, which can only arrive from a URL this package did not\n * write — hand-typed, external links, `GET` forms.\n *\n * Set it at BOOT, not per request: this is process-global config, and a\n * request-scoped write would be read by whatever request happens to be\n * rendering (the defect catalogued at route-table.ts:10-25).\n */\nexport type QueryStringOptions = {\n readonly repeatedKeys?: RepeatedKeyStrategy;\n};\n\ntype ResolvedQueryStringOptions = Required<QueryStringOptions>;\n\nconst DEFAULT_OPTIONS: ResolvedQueryStringOptions = {\n repeatedKeys: \"last\",\n};\n\n/**\n * Held on `globalThis`, not in a module binding, for the reason measured and\n * written up at route-table.ts:43-65: in dev the process runs two module graphs\n * over these files (tsx/Node and Vite's SSR runner), so a `let` written by boot\n * code is not the `let` a component reads. A split here would be quiet — the\n * second graph would silently fall back to the defaults and decode a repeated\n * key the other way.\n */\nconst OPTIONS_SLOT = Symbol.for(\"warlock.web.queryStringOptions\");\n\ntype OptionsHost = typeof globalThis & {\n [OPTIONS_SLOT]?: ResolvedQueryStringOptions;\n};\n\nfunction currentOptions(): ResolvedQueryStringOptions {\n return (globalThis as OptionsHost)[OPTIONS_SLOT] ?? DEFAULT_OPTIONS;\n}\n\n/**\n * Merge query-string options over the current ones.\n *\n * Named for `@mongez/react-router`'s function so migrating call sites keep\n * compiling; the OPTIONS are deliberately narrower, and `QueryStringOptions`\n * explains exactly which ones were refused and why.\n */\nexport function setQueryStringOptions(options: QueryStringOptions): void {\n (globalThis as OptionsHost)[OPTIONS_SLOT] = { ...currentOptions(), ...options };\n}\n\n/**\n * Drop back to the defaults.\n *\n * Exists because the options are process-global: a test that set one would\n * otherwise leak it into every later test in the same worker, passing in file\n * order and failing under `--shuffle`. Same reasoning as `resetRouteTable`.\n */\nexport function resetQueryStringOptions(): void {\n delete (globalThis as OptionsHost)[OPTIONS_SLOT];\n}\n\n/**\n * The search string of the current document, or `\"\"` when there is no document.\n *\n * The `typeof` guard is the SSR contract: no export in this module may touch a\n * DOM global without one.\n */\nfunction browserSearch(): string {\n if (typeof window === \"undefined\") return \"\";\n\n return window.location?.search ?? \"\";\n}\n\n/**\n * Reduce anything search-shaped to the pairs themselves.\n *\n * Accepts `\"?a=1\"`, `\"a=1\"`, `\"/path?a=1\"` and a full URL, because\n * `location.href`, `location.search` and a hand-written literal all turn up at\n * this door and `new URLSearchParams(\"/path?a=1\")` would answer with the key\n * `\"/path?a\"` — a wrong answer with no error. Cutting at the first `?` and the\n * first `#` is safe rather than heuristic: `queryStringOf` percent-encodes both\n * characters inside values (`%3F`, `%23`), so a literal one is always a\n * delimiter.\n */\nfunction searchPairsOf(source: string): string {\n const withoutHash = source.split(\"#\", 1)[0];\n const questionMark = withoutHash.indexOf(\"?\");\n\n return questionMark === -1 ? withoutHash : withoutHash.slice(questionMark + 1);\n}\n\n/**\n * The three key shapes the encoder writes. Everything else is a literal key.\n *\n * The character classes exclude brackets, so each pattern matches exactly one\n * shape: `tags[]` cannot satisfy `NESTED`, and `a[b][c]` satisfies none of them.\n */\nconst ARRAY_KEY = /^([^[\\]]+)\\[\\]$/;\nconst NESTED_KEY = /^([^[\\]]+)\\[([^[\\]]+)\\]$/;\nconst NESTED_ARRAY_KEY = /^([^[\\]]+)\\[([^[\\]]+)\\]\\[\\]$/;\n\ntype ParsedKey =\n | { kind: \"plain\"; name: string }\n | { kind: \"array\"; name: string }\n | { kind: \"nested\"; name: string; subKey: string }\n | { kind: \"nestedArray\"; name: string; subKey: string };\n\n/**\n * Classify a decoded key.\n *\n * A shape neither side produces — `a[b][c]`, `items[0][name]`, an unbalanced\n * `a[` — falls through to `\"plain\"` and is carried VERBATIM. Those can only come\n * from a URL warlock did not write, and guessing at them is exactly how a\n * decoder drifts from its writer. Carrying the key as text loses nothing.\n */\nfunction parseKey(key: string): ParsedKey {\n const nestedArray = NESTED_ARRAY_KEY.exec(key);\n\n if (nestedArray) {\n return { kind: \"nestedArray\", name: nestedArray[1], subKey: nestedArray[2] };\n }\n\n const array = ARRAY_KEY.exec(key);\n\n if (array) return { kind: \"array\", name: array[1] };\n\n const nested = NESTED_KEY.exec(key);\n\n if (nested) return { kind: \"nested\", name: nested[1], subKey: nested[2] };\n\n return { kind: \"plain\", name: key };\n}\n\n/** A fresh bag with NO prototype. See {@link decode} for why that is not optional. */\nfunction emptyBag<T extends object>(): T {\n return Object.create(null) as T;\n}\n\nfunction isBag(value: unknown): value is QueryStringNested {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * The array living at `container[name]`, created if it is not there yet.\n *\n * A conflicting earlier shape is REPLACED rather than written into. `?a=1&a[]=2`\n * is not something the encoder can emit, so it is a foreign URL contradicting\n * itself; appending to a string would be a silent no-op, and last-shape-wins at\n * least matches how `repeatedKeys: \"last\"` resolves the scalar version.\n */\nfunction arrayAt(container: Record<string, unknown>, name: string): string[] {\n const existing = container[name];\n\n if (Array.isArray(existing)) return existing;\n\n const created: string[] = [];\n\n container[name] = created;\n\n return created;\n}\n\n/** The bag living at `result[name]`, created if absent. Same last-shape-wins rule. */\nfunction bagAt(result: QueryStringObject, name: string): QueryStringNested {\n const existing = result[name];\n\n if (isBag(existing)) return existing;\n\n const created = emptyBag<QueryStringNested>();\n\n result[name] = created;\n\n return created;\n}\n\n/**\n * The single decode path. Every reader below goes through here.\n *\n * Every container has a NULL PROTOTYPE — the result and each `key[sub]` bag.\n * Query keys are attacker-controlled, and assigning `?__proto__=x` onto a `{}`\n * literal hits the inherited setter, which DISCARDS the key: data loss with no\n * error. Bracket parsing makes this sharper than it was when this decoder was\n * flat, because `?filter[__proto__]=x` now reaches a nested container too —\n * which is why `bagAt` builds with `Object.create(null)` rather than `{}`.\n * MRR's parser walks `key.split(\"[\")` onto plain objects and needs the blocklist\n * at query-string-parsers.ts:7 as a result; with no prototype there is no setter\n * to hit and the key is stored as the ordinary data it is.\n */\nfunction decode(source: string): QueryStringObject {\n const pairs = searchPairsOf(source);\n const result = emptyBag<QueryStringObject>();\n\n if (pairs === \"\") return result;\n\n const { repeatedKeys } = currentOptions();\n\n for (const [key, value] of new URLSearchParams(pairs)) {\n const parsed = parseKey(key);\n\n if (parsed.kind === \"array\") {\n arrayAt(result, parsed.name).push(value);\n continue;\n }\n\n if (parsed.kind === \"nestedArray\") {\n arrayAt(bagAt(result, parsed.name), parsed.subKey).push(value);\n continue;\n }\n\n if (parsed.kind === \"nested\") {\n // Last wins. The encoder cannot repeat a `key[sub]` pair — `Object.entries`\n // yields each sub-key once — so this only arises from a foreign URL, and\n // `repeatedKeys` deliberately does not reach here (QueryStringOptions).\n bagAt(result, parsed.name)[parsed.subKey] = value;\n continue;\n }\n\n if (!(parsed.name in result)) {\n result[parsed.name] = repeatedKeys === \"array\" ? [value] : value;\n continue;\n }\n\n if (repeatedKeys === \"first\") continue;\n\n if (repeatedKeys === \"last\") {\n result[parsed.name] = value;\n continue;\n }\n\n arrayAt(result, parsed.name).push(value);\n }\n\n return result;\n}\n\n/**\n * Reading the current query string, and any query string.\n *\n * Named for `@mongez/react-router`'s object so the familiar calls keep working;\n * the implementation is not ported — see the module header for what changed and\n * why.\n */\nexport const queryString = {\n /**\n * The current document's query string, decoded.\n *\n * On the server this is `{}`, because the browser location is the only source\n * this module has and a per-request one would be module state two concurrent\n * requests could race over (route-table.ts:10-25).\n *\n * That makes it a HYDRATION HAZARD in a component: the server renders `{}`\n * and the browser renders the real values, so the two trees differ. In a\n * component, take the query from the page's own props and hand it to\n * {@link queryString.parse}, which is universal. `all()` is for browser-only\n * code — an event handler, an effect, a client-side helper.\n */\n all(): QueryStringObject {\n return decode(browserSearch());\n },\n\n /**\n * Decode a query string that was handed to you.\n *\n * Universal: it reads no globals, so this is the entry point that is safe on\n * the server. Accepts a bare pair list, a leading `?`, a path, or a full URL.\n */\n parse(search: string): QueryStringObject {\n return decode(search);\n },\n\n /**\n * One key from the current query string.\n *\n * PRESENCE, not truthiness. MRR returns `all[key] || defaultValue`\n * (query-string.ts:43), which hands back the default for `?a=` — so a\n * deliberately-cleared filter reads as though it was never set, and the page\n * shows the default instead of the empty state. Here `?a=` returns `\"\"`, and\n * only an absent key returns the default.\n *\n * @param defaultValue returned only when the key is absent. Defaults to\n * `null`, as MRR's does.\n */\n get<T = null>(key: string, defaultValue: T = null as T): QueryStringValue | T {\n const all = decode(browserSearch());\n\n return key in all ? all[key] : defaultValue;\n },\n\n /**\n * The current query string verbatim, without the leading `?`.\n *\n * `\"\"` on the server, and `\"\"` when there is no query — the same two cases\n * `queryStringOf` collapses when it writes.\n */\n toString(): string {\n return searchPairsOf(browserSearch());\n },\n};\n"],"mappings":";;;;;;;;AAqHA,IAAa,gC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