@sjcx/vorma 0.0.0-pre.2 → 0.0.0-pre.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/build/assemble-artifacts.d.ts +1 -1
  2. package/dist/build/bundle-client.d.ts +1 -1
  3. package/dist/build/cli.js +27 -37
  4. package/dist/build/compile-application.d.ts +2 -2
  5. package/dist/build/development-artifacts.d.ts +1 -1
  6. package/dist/build/development-build.d.ts +3 -6
  7. package/dist/build/development-work.d.ts +2 -3
  8. package/dist/build/generate-application.d.ts +2 -2
  9. package/dist/build/index.d.ts +2 -3
  10. package/dist/build/index.js +1 -1
  11. package/dist/build/inspect-projects.d.ts +3 -3
  12. package/dist/build/load-config.d.ts +0 -2
  13. package/dist/build/publish-artifacts.d.ts +1 -4
  14. package/dist/build/render-client-transport.d.ts +1 -1
  15. package/dist/build/render-server-generated.d.ts +1 -12
  16. package/dist/build/render-types.d.ts +1 -1
  17. package/dist/build/resolve-config.d.ts +2 -4
  18. package/dist/build/source-layout.d.ts +1 -1
  19. package/dist/{build-DcP5_DUV.js → build-sHSh5zaX.js} +67 -282
  20. package/package.json +5 -36
  21. package/dist/build/compile-server.d.ts +0 -42
  22. package/dist/client/assembly.d.ts +0 -40
  23. package/dist/client/browser-http-client.d.ts +0 -10
  24. package/dist/client/client-loaders.d.ts +0 -93
  25. package/dist/client/commit.d.ts +0 -41
  26. package/dist/client/contracts.d.ts +0 -192
  27. package/dist/client/core.d.ts +0 -45
  28. package/dist/client/development.d.ts +0 -16
  29. package/dist/client/document-recovery.d.ts +0 -4
  30. package/dist/client/endpoints.d.ts +0 -54
  31. package/dist/client/errors.d.ts +0 -87
  32. package/dist/client/freshness.d.ts +0 -51
  33. package/dist/client/head.d.ts +0 -14
  34. package/dist/client/history.d.ts +0 -25
  35. package/dist/client/index.d.ts +0 -80
  36. package/dist/client/index.js +0 -150
  37. package/dist/client/links.d.ts +0 -48
  38. package/dist/client/materialize.d.ts +0 -21
  39. package/dist/client/modules.d.ts +0 -2
  40. package/dist/client/navigation.d.ts +0 -47
  41. package/dist/client/payload.d.ts +0 -54
  42. package/dist/client/prefetch.d.ts +0 -28
  43. package/dist/client/prepare.d.ts +0 -47
  44. package/dist/client/projections.d.ts +0 -26
  45. package/dist/client/queries.d.ts +0 -33
  46. package/dist/client/react/application.d.ts +0 -87
  47. package/dist/client/react/hooks.d.ts +0 -36
  48. package/dist/client/react/index.d.ts +0 -5
  49. package/dist/client/react/index.js +0 -3237
  50. package/dist/client/react/link.d.ts +0 -27
  51. package/dist/client/react/view.d.ts +0 -86
  52. package/dist/client/request.d.ts +0 -16
  53. package/dist/client/route-context.d.ts +0 -31
  54. package/dist/client/route-matching.d.ts +0 -22
  55. package/dist/client/route-synchronization.d.ts +0 -30
  56. package/dist/client/route-url.d.ts +0 -5
  57. package/dist/client/runtime.d.ts +0 -82
  58. package/dist/client/scroll.d.ts +0 -16
  59. package/dist/client/services.d.ts +0 -34
  60. package/dist/client/state.d.ts +0 -102
  61. package/dist/client/static-assets.d.ts +0 -3
  62. package/dist/client/stylesheets.d.ts +0 -7
  63. package/dist/client/transport-type-entries.d.ts +0 -2
  64. package/dist/client/types.d.ts +0 -152
  65. package/dist/client/view-definition.d.ts +0 -24
  66. package/dist/client/work-indicator.d.ts +0 -18
  67. package/dist/compile-Me8EOyMK.js +0 -870
  68. package/dist/development-B_rxuwY7.js +0 -128
  69. package/dist/hash-set-BPx3iXec.js +0 -141
  70. package/dist/href-Cqyax8Y0.js +0 -357
  71. package/dist/materialize-DZ7VSLFk.js +0 -739
  72. package/dist/metadata-BoPKo-G2.js +0 -32
  73. package/dist/primitives/tasks/index.d.ts +0 -1
  74. package/dist/primitives/tasks/index.js +0 -1
  75. package/dist/route-context-CtY_9U_W.js +0 -559
  76. package/dist/route-matching-D_uSG2P9.js +0 -33
  77. package/dist/search-parse-0f7oqVsG.js +0 -375
  78. package/dist/server/config/index.d.ts +0 -36
  79. package/dist/server/config/index.js +0 -30
  80. package/dist/server/development/metadata.d.ts +0 -11
  81. package/dist/server/document.d.ts +0 -37
  82. package/dist/server/form-data.d.ts +0 -21
  83. package/dist/server/graph/compile.d.ts +0 -118
  84. package/dist/server/graph/declarations.d.ts +0 -117
  85. package/dist/server/graph/literal-error-tag.d.ts +0 -14
  86. package/dist/server/graph/pattern-conflicts.d.ts +0 -36
  87. package/dist/server/graph/search-schema.d.ts +0 -13
  88. package/dist/server/graph/transport-schema.d.ts +0 -11
  89. package/dist/server/index.d.ts +0 -310
  90. package/dist/server/index.js +0 -2311
  91. package/dist/server/public-assets.d.ts +0 -18
  92. package/dist/server/runtime/application.d.ts +0 -15
  93. package/dist/server/runtime/assets.d.ts +0 -15
  94. package/dist/server/runtime/context.d.ts +0 -96
  95. package/dist/server/runtime/domain-errors.d.ts +0 -11
  96. package/dist/server/runtime/effects.d.ts +0 -83
  97. package/dist/server/runtime/execute.d.ts +0 -13
  98. package/dist/server/runtime/finalize.d.ts +0 -44
  99. package/dist/server/runtime/handler.d.ts +0 -106
  100. package/dist/server/runtime/head.d.ts +0 -22
  101. package/dist/server/runtime/payload.d.ts +0 -50
  102. package/dist/server/runtime/pipeline.d.ts +0 -27
  103. package/dist/server/runtime/plan.d.ts +0 -98
  104. package/dist/server/runtime/render-document.d.ts +0 -16
  105. package/dist/server/runtime/startup-error.d.ts +0 -11
  106. package/dist/server/runtime/transport-type-entries.d.ts +0 -2
  107. package/dist/server/runtime/vercel-deployment.d.ts +0 -2
  108. package/dist/server/url-pathname.d.ts +0 -13
  109. package/dist/static-assets-BrH3O0M8.js +0 -199
  110. package/dist/universal/generated-types.d.ts +0 -9
  111. package/dist/universal/href.d.ts +0 -17
  112. package/dist/universal/http-method.d.ts +0 -4
  113. package/dist/universal/json-transport.d.ts +0 -14
  114. package/dist/universal/null-prototype-record.d.ts +0 -7
  115. package/dist/universal/path-wire.d.ts +0 -71
  116. package/dist/universal/pattern-language.d.ts +0 -4
  117. package/dist/universal/protocol-schemas.d.ts +0 -99
  118. package/dist/universal/protocol.d.ts +0 -162
  119. package/dist/universal/search-grammar.d.ts +0 -7
  120. package/dist/universal/search-parse.d.ts +0 -22
  121. package/dist/universal/search-serialize.d.ts +0 -16
  122. package/dist/universal/search-shape.d.ts +0 -32
  123. package/dist/universal/static-assets.d.ts +0 -2
  124. package/dist/universal/transport-types/big-decimal.d.ts +0 -13
  125. package/dist/universal/transport-types/chunk.d.ts +0 -8
  126. package/dist/universal/transport-types/date-time-utc.d.ts +0 -13
  127. package/dist/universal/transport-types/date-time-zoned.d.ts +0 -13
  128. package/dist/universal/transport-types/duration.d.ts +0 -13
  129. package/dist/universal/transport-types/hash-map.d.ts +0 -8
  130. package/dist/universal/transport-types/hash-set.d.ts +0 -8
  131. package/dist/universal/transport-types/option.d.ts +0 -10
  132. package/dist/universal/transport-types/redacted.d.ts +0 -9
  133. package/dist/universal/value-transport.d.ts +0 -117
  134. package/dist/value-transport-Bst4Hk-n.js +0 -864
  135. /package/dist/{universal → build}/content-digest.d.ts +0 -0
@@ -1,32 +0,0 @@
1
- import { Effect } from "effect";
2
- import { readFile } from "node:fs/promises";
3
- //#region src/server/development/metadata.ts
4
- /** Reads each atomic development publication; unchanged bytes retain the same snapshot. */
5
- function createDevelopmentMetadataReader(input) {
6
- let previousText;
7
- let previous = input.initial;
8
- return Effect.tryPromise({
9
- try: async (signal) => {
10
- const text = await readFile(input.url, {
11
- encoding: "utf8",
12
- signal
13
- });
14
- if (text !== previousText) {
15
- previous = {
16
- ...JSON.parse(text),
17
- publicAssetDirectoryUrl: input.initial.publicAssetDirectoryUrl
18
- };
19
- previousText = text;
20
- }
21
- return previous;
22
- },
23
- catch: (cause) => {
24
- return {
25
- _tag: "DevelopmentMetadataIssue",
26
- cause
27
- };
28
- }
29
- });
30
- }
31
- //#endregion
32
- export { createDevelopmentMetadataReader };
@@ -1 +0,0 @@
1
- export * from "@vorma/primitives/tasks";
@@ -1 +0,0 @@
1
- export * from "@vorma/primitives/tasks";
@@ -1,559 +0,0 @@
1
- import { o as canonicalizeRequestPathForMatcher } from "./value-transport-Bst4Hk-n.js";
2
- import { t as buildHref } from "./href-Cqyax8Y0.js";
3
- import { Cause, Context, Data, Effect, Layer, Option, Result, Scope, Stream } from "effect";
4
- import { AsyncResult, Atom } from "effect/unstable/reactivity";
5
- import { transportTypeEntries } from "virtual:vorma/client-transport-types";
6
- //#region src/client/errors.ts
7
- var InputError = class extends Data.TaggedError("InputError") {};
8
- var BuildMismatchError = class extends Data.TaggedError("BuildMismatchError") {};
9
- var TransportError = class extends Data.TaggedError("TransportError") {};
10
- var HandlerError = class extends Data.TaggedError("HandlerError") {};
11
- /** A later endpoint call with the same dedupe key cancelled this call's request. */
12
- var CancelledByDedupeKeyError = class extends Data.TaggedError("CancelledByDedupeKeyError") {};
13
- var NavigationError = class extends Data.TaggedError("NavigationError") {};
14
- var RevalidationError = class extends Data.TaggedError("RevalidationError") {};
15
- var PrefetchError = class extends Data.TaggedError("PrefetchError") {};
16
- var QueryRedirected = class extends Data.TaggedError("QueryRedirected") {};
17
- function unwrapSingleFailure(error) {
18
- if (!Cause.isCause(error)) return error;
19
- const reason = error.reasons.length === 1 ? error.reasons[0] : void 0;
20
- return reason?._tag === "Fail" ? reason.error : void 0;
21
- }
22
- /** The sanitized presentation of any failure: explicit public fields, or a generic 500. */
23
- function sanitizeRouteError(error) {
24
- const value = unwrapSingleFailure(error);
25
- if (typeof value === "object" && value !== null && "status" in value && "clientMessage" in value && typeof value.status === "number" && typeof value.clientMessage === "string") return {
26
- status: value.status,
27
- clientMessage: value.clientMessage
28
- };
29
- return {
30
- status: 500,
31
- clientMessage: "An unexpected error occurred."
32
- };
33
- }
34
- /** Recognizes typed navigation control without consuming defects or composite failures. */
35
- function getQueryRedirect(error) {
36
- const value = unwrapSingleFailure(error);
37
- return value instanceof QueryRedirected ? value : void 0;
38
- }
39
- //#endregion
40
- //#region src/client/state.ts
41
- const INITIAL_CLIENT_STATE = {
42
- lifecycle: { _tag: "PreBoot" },
43
- frame: null,
44
- navigation: {
45
- pending: null,
46
- latest: AsyncResult.initial()
47
- },
48
- freshness: {
49
- demand: null,
50
- epoch: 0,
51
- attempt: {
52
- coveredSequence: null,
53
- phase: "idle",
54
- skipWorkIndicator: false,
55
- waiters: [],
56
- latest: AsyncResult.initial()
57
- }
58
- },
59
- operations: /* @__PURE__ */ new Map(),
60
- prefetch: /* @__PURE__ */ new Map(),
61
- buildMismatch: Option.none(),
62
- generation: 0,
63
- sequence: 0
64
- };
65
- /** Registry-local state; private to the package. Public atoms are projections. */
66
- const clientStateAtom = Atom.make(INITIAL_CLIENT_STATE).pipe(Atom.keepAlive);
67
- //#endregion
68
- //#region src/client/projections.ts
69
- const frameAtom = Atom.readable((get) => get(clientStateAtom).frame);
70
- const navigationAtom = Atom.readable((get) => get(clientStateAtom).navigation);
71
- const freshnessAtom = Atom.readable((get) => get(clientStateAtom).freshness);
72
- const operationsAtom = Atom.readable((get) => get(clientStateAtom).operations);
73
- const prefetchAtom = Atom.readable((get) => get(clientStateAtom).prefetch);
74
- Atom.readable((get) => get(clientStateAtom).lifecycle);
75
- const committedFrameAtom = frameAtom;
76
- /** Projects server-public fields or preserves a browser-local cause according to its source. */
77
- function projectRouteError(error) {
78
- const presentation = sanitizeRouteError(error.error);
79
- if (error.source === "serverLoader") return {
80
- ...presentation,
81
- pattern: error.pattern,
82
- source: error.source
83
- };
84
- return {
85
- ...presentation,
86
- pattern: error.pattern,
87
- source: error.source,
88
- cause: Cause.isCause(error.error) ? error.error : Cause.die(error.error)
89
- };
90
- }
91
- /** The public route state of a frame. */
92
- function projectRouteState(frame) {
93
- return {
94
- href: frame.href,
95
- historyState: Option.fromUndefinedOr(frame.historyState),
96
- matches: frame.entries.map((entry) => {
97
- return {
98
- pattern: entry.pattern,
99
- params: entry.params,
100
- splatValues: entry.splatValues
101
- };
102
- }),
103
- error: Option.map(Option.fromNullOr(frame.error), projectRouteError)
104
- };
105
- }
106
- const routeStateAtom = Atom.map(frameAtom, (frame) => {
107
- return frame === null ? Option.none() : Option.some(projectRouteState(frame));
108
- });
109
- const navigationStateAtom = Atom.map(navigationAtom, (navigation) => {
110
- return {
111
- pending: Option.fromNullOr(navigation.pending),
112
- latestAttempt: navigation.latest
113
- };
114
- });
115
- const revalidationStateAtom = Atom.map(freshnessAtom, (freshness) => {
116
- return {
117
- requiresRevalidation: freshness.demand !== null,
118
- pending: freshness.attempt.phase === "running" ? Option.some({
119
- phase: "running",
120
- skipWorkIndicator: freshness.attempt.skipWorkIndicator && (freshness.demand === null || freshness.demand.skipWorkIndicator)
121
- }) : freshness.attempt.phase === "retrying" ? Option.some({
122
- phase: "scheduled",
123
- skipWorkIndicator: freshness.attempt.skipWorkIndicator
124
- }) : freshness.demand !== null && freshness.attempt.phase === "idle" ? Option.some({
125
- phase: "scheduled",
126
- skipWorkIndicator: freshness.demand.skipWorkIndicator
127
- }) : Option.none(),
128
- latestAttempt: freshness.attempt.latest
129
- };
130
- });
131
- /**
132
- * Active queries depend on this; it changes only when a demand registers. It
133
- * is eager because its dependents are lazy runtime computations behind
134
- * wrappers, and the registry recomputes a lazy atom's lazy dependents only
135
- * when the atom itself is recomputed.
136
- */
137
- const refreshEpochAtom = Atom.readable((get) => get(clientStateAtom).freshness.epoch).pipe(Atom.setLazy(false), Atom.keepAlive);
138
- const buildMismatchAtom = Atom.readable((get) => get(clientStateAtom).buildMismatch);
139
- const workStateAtom = Atom.readable((get) => {
140
- const navigation = get(navigationStateAtom);
141
- const revalidation = get(revalidationStateAtom);
142
- const prefetch = get(prefetchAtom);
143
- const operations = get(operationsAtom);
144
- return {
145
- navigation: navigation.pending,
146
- revalidation: revalidation.pending,
147
- prefetches: [...prefetch.values()].map((pending) => {
148
- return {
149
- href: pending.href,
150
- phase: "preparing",
151
- skipWorkIndicator: pending.skipWorkIndicator
152
- };
153
- }),
154
- operations: [...operations.values()]
155
- };
156
- });
157
- /** One operation's state while it is tracked; the observer retains the settled value afterward. */
158
- const getOperationStateAtom = Atom.family((id) => {
159
- return Atom.readable((get) => {
160
- const tracked = get(operationsAtom).get(id);
161
- if (tracked !== void 0) return Option.some(tracked);
162
- const previous = Option.flatten(get.self());
163
- return Option.filter(previous, (value) => value.phase === "settled");
164
- });
165
- });
166
- //#endregion
167
- //#region src/client/links.ts
168
- const NO_MATCH = {
169
- active: {
170
- exact: false,
171
- ancestor: false
172
- },
173
- pending: {
174
- exact: false,
175
- ancestor: false
176
- }
177
- };
178
- const NO_LINK_STATE_ATOM = Atom.make(NO_MATCH);
179
- function parseCandidate(href) {
180
- const url = new URL(href, window.location.href);
181
- return {
182
- url,
183
- path: Result.getOrNull(canonicalizeRequestPathForMatcher(url.pathname))
184
- };
185
- }
186
- function matchesExactly(input) {
187
- const { target, candidate, rules } = input;
188
- return target.path !== null && target.path === candidate.path && (rules.includeSearch !== true || target.url.search === candidate.url.search) && (rules.includeHash !== true || target.url.hash === candidate.url.hash);
189
- }
190
- function matchesAncestor(input) {
191
- const { target, candidate, targetPattern, candidatePatterns } = input;
192
- if (target.path === null || candidate.path === null) return false;
193
- const prefix = target.path === "/" ? "/" : `${target.path}/`;
194
- return target.path !== candidate.path && (prefix === "/" || candidate.path.startsWith(prefix)) && (targetPattern === void 0 || candidatePatterns === void 0 || candidatePatterns.includes(targetPattern));
195
- }
196
- function equalsLinkState(current, next) {
197
- return current.active.exact === next.active.exact && current.active.ancestor === next.active.ancestor && current.pending.exact === next.pending.exact && current.pending.ancestor === next.pending.ancestor;
198
- }
199
- const getLinkStateAtomByKey = Atom.family((key) => {
200
- const { href, pattern } = key;
201
- const rules = key;
202
- return Atom.readable((get) => {
203
- const route = get(routeStateAtom);
204
- if (Option.isNone(route)) return NO_MATCH;
205
- const target = parseCandidate(href);
206
- if (target.url.origin !== window.location.origin) return NO_MATCH;
207
- const committed = parseCandidate(route.value.href);
208
- const patterns = route.value.matches.map((match) => match.pattern);
209
- const pendingHref = Option.map(get(navigationStateAtom).pending, (pending) => pending.href);
210
- const pending = Option.map(pendingHref, parseCandidate);
211
- return {
212
- active: {
213
- exact: matchesExactly({
214
- target,
215
- candidate: committed,
216
- rules
217
- }),
218
- ancestor: matchesAncestor({
219
- target,
220
- candidate: committed,
221
- targetPattern: pattern,
222
- candidatePatterns: patterns
223
- })
224
- },
225
- pending: {
226
- exact: Option.isSome(pending) ? matchesExactly({
227
- target,
228
- candidate: pending.value,
229
- rules
230
- }) : false,
231
- ancestor: Option.isSome(pending) ? matchesAncestor({
232
- target,
233
- candidate: pending.value,
234
- targetPattern: pattern,
235
- candidatePatterns: void 0
236
- }) : false
237
- }
238
- };
239
- }).pipe(Atom.withEquality(equalsLinkState));
240
- });
241
- /** The active and pending facts of a resolved link target under its match rules. */
242
- function getLinkStateAtomFor(input) {
243
- if (input.rules?.skip === true) return NO_LINK_STATE_ATOM;
244
- return getLinkStateAtomByKey({
245
- href: input.href,
246
- pattern: input.pattern,
247
- includeSearch: input.rules?.includeSearch === true,
248
- includeHash: input.rules?.includeHash === true
249
- });
250
- }
251
- /** Whether a click may be intercepted: unmodified, primary, and targeting this browsing context. */
252
- function allowsInterception(event, targetAttribute) {
253
- return !(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey) && (event.button === void 0 || event.button === 0) && (targetAttribute === void 0 || targetAttribute === "" || targetAttribute === "_self");
254
- }
255
- /** Whether the device's last pointer input was touch. */
256
- let touchActive = false;
257
- /** Tracks whether the last pointer input was touch; the returned function detaches. */
258
- function attachPointerModalityTracking() {
259
- function handleTouchStart() {
260
- touchActive = true;
261
- }
262
- function handlePointerInput(event) {
263
- if (event.pointerType === "touch") touchActive = true;
264
- else if (event.pointerType === "mouse" || event.pointerType === "pen") touchActive = false;
265
- }
266
- window.addEventListener("touchstart", handleTouchStart);
267
- window.addEventListener("pointerdown", handlePointerInput);
268
- window.addEventListener("pointermove", handlePointerInput);
269
- return () => {
270
- window.removeEventListener("touchstart", handleTouchStart);
271
- window.removeEventListener("pointerdown", handlePointerInput);
272
- window.removeEventListener("pointermove", handlePointerInput);
273
- };
274
- }
275
- /** One link's prefetch intent: an observer handle held from a pointer's or focus's arrival until either leaves. */
276
- function createLinkIntent(input) {
277
- let timer;
278
- let release;
279
- function acquirePrefetchHold() {
280
- const url = Result.try(() => new URL(input.getHrefFn(), window.location.href));
281
- if (Result.isFailure(url) || url.success.origin !== window.location.origin) return;
282
- const fiber = input.coordinator.fork(input.coordinator.prefetch.holdUntilInterrupted(url.success, { skipWorkIndicator: input.skipWorkIndicator }));
283
- release = () => fiber.interruptUnsafe();
284
- }
285
- function releasePrefetchHold() {
286
- if (timer !== void 0) {
287
- window.clearTimeout(timer);
288
- timer = void 0;
289
- }
290
- release?.();
291
- release = void 0;
292
- }
293
- return {
294
- begin: (_source, delayMs) => {
295
- if (release !== void 0 || timer !== void 0) return;
296
- timer = window.setTimeout(() => {
297
- timer = void 0;
298
- acquirePrefetchHold();
299
- }, delayMs ?? 100);
300
- },
301
- end: (source) => {
302
- if (source === "pointer" && touchActive) return;
303
- releasePrefetchHold();
304
- },
305
- reset: releasePrefetchHold
306
- };
307
- }
308
- //#endregion
309
- //#region src/client/transport-type-entries.ts
310
- /** The Effect data types that occur in this application's contracts. */
311
- const CLIENT_TRANSPORT_TYPE_ENTRIES = transportTypeEntries;
312
- //#endregion
313
- //#region src/client/route-url.ts
314
- /** Returns a raw href unchanged or encodes a typed destination as an origin-relative URL. */
315
- function toHref(input) {
316
- if (input.href !== void 0) return Result.succeed(input.href);
317
- const href = buildHref({
318
- kind: "ui",
319
- pattern: input.pattern,
320
- transportTypeEntries: CLIENT_TRANSPORT_TYPE_ENTRIES,
321
- ...input.params === void 0 ? {} : { params: input.params },
322
- ...input.splatValues === void 0 ? {} : { splatValues: input.splatValues },
323
- ...input.input === void 0 ? {} : { search: input.input },
324
- ...input.hash === void 0 ? {} : { hash: input.hash }
325
- });
326
- return Result.isFailure(href) ? Result.fail(new InputError({
327
- pattern: input.pattern,
328
- message: href.failure.reason,
329
- cause: href.failure
330
- })) : Result.succeed(href.success);
331
- }
332
- //#endregion
333
- //#region src/client/runtime.ts
334
- const CLIENT_UNAVAILABLE_ERROR = { _tag: "ClientUnavailableError" };
335
- const ClientCoordinator = Context.Service("vorma/client/ClientCoordinator");
336
- const applicationContextsAtom = Atom.make(Option.none());
337
- function publishApplicationContexts(input) {
338
- input.registry.set(applicationContextsAtom, Option.some(input.contexts));
339
- }
340
- /** Browser operations and both service groups. Asynchronous computations stay Initial before boot. */
341
- const clientRuntime = Atom.runtime((get) => {
342
- return Option.match(get(applicationContextsAtom), {
343
- onNone: () => Layer.effectContext(Effect.fail(CLIENT_UNAVAILABLE_ERROR)),
344
- onSome: (contexts) => Layer.succeedContext(contexts.client)
345
- });
346
- });
347
- /** Provides only the application's universal service group. */
348
- const universalRuntime = Atom.runtime((get) => {
349
- return Option.match(get(applicationContextsAtom), {
350
- onNone: () => Layer.effectContext(Effect.fail(CLIENT_UNAVAILABLE_ERROR)),
351
- onSome: (contexts) => Layer.succeedContext(contexts.universal)
352
- });
353
- });
354
- /** Runs an Effect with the mounted application's client context. */
355
- function provideClientContext(contexts, effect) {
356
- return Effect.provide(effect, contexts.client);
357
- }
358
- //#endregion
359
- //#region src/client/work-indicator.ts
360
- const optionsAtom = Atom.make(void 0).pipe(Atom.keepAlive);
361
- const applicationWorkCountAtom = Atom.make(0);
362
- /** Whether included framework work or explicitly tracked application work is unfinished. */
363
- const workIndicatorActiveAtom = Atom.readable((get) => {
364
- if (get(applicationWorkCountAtom) > 0) return true;
365
- const options = get(optionsAtom);
366
- if (options === void 0) return false;
367
- const work = get(workStateAtom);
368
- return options.skipNavigations !== true && Option.isSome(work.navigation) && !work.navigation.value.skipWorkIndicator || options.skipRevalidations !== true && Option.isSome(work.revalidation) && !work.revalidation.value.skipWorkIndicator || options.skipApiRequests !== true && work.operations.some((operation) => {
369
- return operation.phase !== "settled" && !operation.skipWorkIndicator;
370
- });
371
- });
372
- function createWorkIndicator(core, options) {
373
- core.registry.set(optionsAtom, options);
374
- function track(effect) {
375
- return Effect.acquireUseRelease(Effect.sync(() => {
376
- core.registry.update(applicationWorkCountAtom, (count) => count + 1);
377
- }), () => effect, () => {
378
- return Effect.sync(() => {
379
- core.registry.update(applicationWorkCountAtom, (count) => count - 1);
380
- });
381
- });
382
- }
383
- function start() {
384
- if (options === void 0) return Effect.void;
385
- const configured = options;
386
- return Effect.gen(function* () {
387
- let visible = false;
388
- let pending;
389
- const unsubscribe = core.registry.subscribe(workIndicatorActiveAtom, (active) => {
390
- pending?.interruptUnsafe();
391
- pending = void 0;
392
- if (visible === active) return;
393
- pending = core.forkFiber(Effect.sleep(active ? configured.startDelayMs : configured.stopDelayMs).pipe(Effect.andThen(Effect.sync(() => {
394
- visible = active;
395
- if (active) configured.startFn();
396
- else configured.stopFn();
397
- }))));
398
- }, { immediate: true });
399
- yield* Scope.addFinalizer(core.scope, Effect.sync(() => {
400
- unsubscribe();
401
- pending?.interruptUnsafe();
402
- if (visible) configured.stopFn();
403
- }));
404
- });
405
- }
406
- return {
407
- start,
408
- track
409
- };
410
- }
411
- //#endregion
412
- //#region src/client/route-synchronization.ts
413
- function makeTargetError(cause) {
414
- return new NavigationError({
415
- stage: "target",
416
- cause: Cause.isCause(cause) ? cause : Cause.fail(cause)
417
- });
418
- }
419
- function resolveSynchronizationTarget(input) {
420
- const href = input.href;
421
- if (Result.isFailure(href)) return Result.fail(makeTargetError(href.failure));
422
- const url = Result.try(() => new URL(href.success, window.location.href));
423
- return Result.isFailure(url) ? Result.fail(makeTargetError(url.failure)) : Result.succeed({
424
- href: url.success.href,
425
- navigationOptions: input.navigationOptions
426
- });
427
- }
428
- function matchesEquivalentRoute(coordinator, href) {
429
- const route = coordinator.registry.get(routeStateAtom);
430
- if (Option.isSome(route) && route.value.href === href) return true;
431
- const navigation = coordinator.registry.get(navigationStateAtom);
432
- return Option.isSome(navigation.pending) && navigation.pending.value.href === href;
433
- }
434
- function runSynchronizationTarget(input) {
435
- if (matchesEquivalentRoute(input.coordinator, input.target.href)) return Effect.void;
436
- const delay = input.debounceDelay === void 0 ? Effect.void : Effect.sleep(input.debounceDelay);
437
- return Effect.andThen(delay, Effect.suspend(() => {
438
- return matchesEquivalentRoute(input.coordinator, input.target.href) ? Effect.void : Effect.asVoid(input.coordinator.navigation.navigate(input.target.href, input.target.navigationOptions));
439
- }));
440
- }
441
- function readSynchronizationTarget(input) {
442
- return Effect.suspend(() => {
443
- const resolved = resolveSynchronizationTarget({
444
- href: input.href,
445
- navigationOptions: {
446
- replace: input.options.replace ?? true,
447
- scrollToTop: input.options.scrollToTop ?? false,
448
- scrollToFragment: input.options.scrollToFragment ?? false,
449
- ...input.options.skipWorkIndicator === void 0 ? {} : { skipWorkIndicator: input.options.skipWorkIndicator }
450
- }
451
- });
452
- if (Result.isFailure(resolved)) input.coordinator.navigation.recordTargetFailure(resolved.failure);
453
- return Effect.fromResult(resolved);
454
- });
455
- }
456
- /** Keeps a route synchronized with the latest target from a native Stream. */
457
- function synchronizeRoute(input) {
458
- return Effect.flatMap(ClientCoordinator, (coordinator) => {
459
- return input.targets.pipe(Stream.mapEffect((target) => {
460
- return readSynchronizationTarget({
461
- coordinator,
462
- href: toHref(target),
463
- options: input
464
- });
465
- }), Stream.switchMap((target) => {
466
- return Stream.fromEffect(runSynchronizationTarget({
467
- coordinator,
468
- target,
469
- debounceDelay: input.debounceDelay
470
- }));
471
- }), Stream.runDrain);
472
- });
473
- }
474
- //#endregion
475
- //#region src/client/route-context.ts
476
- const ROUTE_CONTEXT = Symbol("vorma/client/RouteContext");
477
- function selectMatch(entry) {
478
- return {
479
- pattern: entry.pattern,
480
- params: entry.params,
481
- splatValues: entry.splatValues,
482
- input: entry.input
483
- };
484
- }
485
- /**
486
- * The value for the entry the context currently sees, or for the entry it
487
- * last saw: a context outlives its entry by one render when a commit replaces
488
- * the position, and before any computation it saw the entry it was created
489
- * from.
490
- */
491
- function selectRetainedValue(get, own, creation, selectFn) {
492
- const entry = get(own);
493
- if (entry !== void 0) return selectFn(entry);
494
- const previous = get.self();
495
- return Option.isSome(previous) ? previous.value : selectFn(creation);
496
- }
497
- /** The route context of a view mounted at `index` for `entry`; its atoms follow that position while it holds the entry's pattern. */
498
- function createRouteContext(index, entry) {
499
- const own = Atom.readable((get) => {
500
- const committed = get(committedFrameAtom);
501
- if (committed !== null && committed.error !== null && committed.error.index <= index) return;
502
- const current = committed === null ? void 0 : committed.entries[index];
503
- return current?.pattern === entry.pattern ? current : void 0;
504
- });
505
- return { [ROUTE_CONTEXT]: {
506
- pattern: entry.pattern,
507
- index,
508
- loaderDataAtom: Atom.readable((get) => {
509
- return selectRetainedValue(get, own, entry, (current) => {
510
- return current.loaderData;
511
- });
512
- }),
513
- clientLoaderDataAtom: Atom.readable((get) => {
514
- return selectRetainedValue(get, own, entry, (current) => {
515
- return AsyncResult.isSuccess(current.clientLoaderData) ? current.clientLoaderData.value : void 0;
516
- });
517
- }),
518
- matchAtom: Atom.readable((get) => {
519
- return selectRetainedValue(get, own, entry, selectMatch);
520
- })
521
- } };
522
- }
523
- /** The committed entry with `pattern`, wherever it sits in the chain. */
524
- const getPatternEntryAtom = Atom.family((pattern) => {
525
- return Atom.readable((get) => {
526
- const committed = get(committedFrameAtom);
527
- return Option.fromNullishOr(committed === null ? void 0 : committed.entries.find((entry) => entry.pattern === pattern));
528
- });
529
- });
530
- const getLoaderDataAtomByPattern = Atom.family((pattern) => {
531
- return Atom.readable((get) => {
532
- return Option.map(get(getPatternEntryAtom(pattern)), (entry) => {
533
- return entry.loaderData;
534
- });
535
- });
536
- });
537
- const getClientLoaderDataAtomByPattern = Atom.family((pattern) => {
538
- return Atom.readable((get) => {
539
- return Option.map(get(getPatternEntryAtom(pattern)), (entry) => {
540
- return entry.clientLoaderData;
541
- });
542
- });
543
- });
544
- const getMatchAtomByPattern = Atom.family((pattern) => {
545
- return Atom.readable((get) => {
546
- return Option.map(get(getPatternEntryAtom(pattern)), selectMatch);
547
- });
548
- });
549
- function getLoaderDataAtom(input) {
550
- return typeof input === "string" ? getLoaderDataAtomByPattern(input) : input[ROUTE_CONTEXT].loaderDataAtom;
551
- }
552
- function getClientLoaderDataAtom(input) {
553
- return typeof input === "string" ? getClientLoaderDataAtomByPattern(input) : input[ROUTE_CONTEXT].clientLoaderDataAtom;
554
- }
555
- function getRouteMatchAtom(input) {
556
- return typeof input === "string" ? getMatchAtomByPattern(input) : input[ROUTE_CONTEXT].matchAtom;
557
- }
558
- //#endregion
559
- export { routeStateAtom as A, RevalidationError as B, committedFrameAtom as C, projectRouteState as D, projectRouteError as E, HandlerError as F, getQueryRedirect as H, InputError as I, NavigationError as L, clientStateAtom as M, BuildMismatchError as N, refreshEpochAtom as O, CancelledByDedupeKeyError as P, PrefetchError as R, buildMismatchAtom as S, navigationStateAtom as T, TransportError as V, CLIENT_TRANSPORT_TYPE_ENTRIES as _, readSynchronizationTarget as a, createLinkIntent as b, createWorkIndicator as c, ClientCoordinator as d, clientRuntime as f, toHref as g, universalRuntime as h, getRouteMatchAtom as i, workStateAtom as j, revalidationStateAtom as k, workIndicatorActiveAtom as l, publishApplicationContexts as m, getClientLoaderDataAtom as n, runSynchronizationTarget as o, provideClientContext as p, getLoaderDataAtom as r, synchronizeRoute as s, createRouteContext as t, CLIENT_UNAVAILABLE_ERROR as u, allowsInterception as v, getOperationStateAtom as w, getLinkStateAtomFor as x, attachPointerModalityTracking as y, QueryRedirected as z };
@@ -1,33 +0,0 @@
1
- import { l as decodeMatchCaptures } from "./value-transport-Bst4Hk-n.js";
2
- import { _ as CLIENT_TRANSPORT_TYPE_ENTRIES } from "./route-context-CtY_9U_W.js";
3
- import { t as parseSearchParams } from "./search-parse-0f7oqVsG.js";
4
- import { Option, Result } from "effect";
5
- import { createNestedValueMatcher, findNestedValueMatches } from "@vorma/primitives/matcher";
6
- //#region src/client/route-matching.ts
7
- function createLearnedMatcher(registrations) {
8
- const matcher = createNestedValueMatcher(registrations);
9
- return { matchPath: (path) => {
10
- const matches = findNestedValueMatches(matcher, path);
11
- if (Option.isNone(matches)) return null;
12
- const chain = [];
13
- for (const match of matches.value) {
14
- const captures = decodeMatchCaptures(match);
15
- if (Result.isFailure(captures)) return null;
16
- chain.push({
17
- value: match.value,
18
- ...captures.success
19
- });
20
- }
21
- return chain;
22
- } };
23
- }
24
- /** Parses a destination's search through the decoded contract structure, without validating its checks. */
25
- function parseSearch(input) {
26
- return parseSearchParams({
27
- document: input.document,
28
- params: input.searchParams,
29
- typeEntries: CLIENT_TRANSPORT_TYPE_ENTRIES
30
- });
31
- }
32
- //#endregion
33
- export { createLearnedMatcher, parseSearch };