foldkit 0.152.0 → 0.153.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.
Files changed (56) hide show
  1. package/dist/asyncData/asyncData.d.ts.map +1 -1
  2. package/dist/asyncData/asyncData.js +10 -7
  3. package/dist/canvas/shape.d.ts.map +1 -1
  4. package/dist/canvas/shape.js +11 -11
  5. package/dist/command/interruptible/interruptible.d.ts +12 -23
  6. package/dist/command/interruptible/interruptible.d.ts.map +1 -1
  7. package/dist/command/interruptible/interruptible.js +12 -16
  8. package/dist/command/interruptible/public.d.ts +1 -1
  9. package/dist/command/interruptible/public.d.ts.map +1 -1
  10. package/dist/command/interruptible/public.js +1 -1
  11. package/dist/devTools/protocol.d.ts +391 -527
  12. package/dist/devTools/protocol.d.ts.map +1 -1
  13. package/dist/devTools/protocol.js +96 -192
  14. package/dist/devTools/public.d.ts +1 -1
  15. package/dist/devTools/public.d.ts.map +1 -1
  16. package/dist/devTools/public.js +1 -1
  17. package/dist/devTools/summarize.d.ts +19 -25
  18. package/dist/devTools/summarize.d.ts.map +1 -1
  19. package/dist/devTools/summarize.js +19 -24
  20. package/dist/devTools/webSocketBridge.d.ts +1 -1
  21. package/dist/devTools/webSocketBridge.d.ts.map +1 -1
  22. package/dist/devTools/webSocketBridge.js +45 -41
  23. package/dist/navigation/index.d.ts +1 -1
  24. package/dist/navigation/index.d.ts.map +1 -1
  25. package/dist/navigation/index.js +1 -1
  26. package/dist/navigation/public.d.ts +1 -1
  27. package/dist/navigation/public.d.ts.map +1 -1
  28. package/dist/navigation/public.js +1 -1
  29. package/dist/navigation/urlRequest.d.ts +15 -31
  30. package/dist/navigation/urlRequest.d.ts.map +1 -1
  31. package/dist/navigation/urlRequest.js +5 -10
  32. package/dist/route/index.d.ts +2 -1
  33. package/dist/route/index.d.ts.map +1 -1
  34. package/dist/route/index.js +1 -1
  35. package/dist/route/public.d.ts +2 -2
  36. package/dist/route/public.d.ts.map +1 -1
  37. package/dist/route/public.js +1 -1
  38. package/dist/runtime/browserListeners.d.ts.map +1 -1
  39. package/dist/runtime/browserListeners.js +3 -3
  40. package/dist/schema/index.d.ts +140 -49
  41. package/dist/schema/index.d.ts.map +1 -1
  42. package/dist/schema/index.js +132 -31
  43. package/dist/schema/public.d.ts +2 -2
  44. package/dist/schema/public.d.ts.map +1 -1
  45. package/dist/schema/public.js +1 -1
  46. package/dist/test/apps/contextMenu.d.ts +10 -7
  47. package/dist/test/apps/contextMenu.d.ts.map +1 -1
  48. package/dist/test/apps/contextMenu.js +6 -7
  49. package/dist/test/apps/formChild.d.ts +0 -16
  50. package/dist/test/apps/formChild.d.ts.map +1 -1
  51. package/dist/test/apps/formChild.js +0 -3
  52. package/dist/test/apps/uploads.d.ts +4 -1
  53. package/dist/test/apps/uploads.d.ts.map +1 -1
  54. package/dist/test/scene.d.ts +1 -1
  55. package/dist/test/scene.d.ts.map +1 -1
  56. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { Array, Cause, Effect, Exit, HashMap, Match, Option, Order, Schema as S, SubscriptionRef, pipe, } from 'effect';
2
2
  import { OptionExt } from '../effectExtensions/index.js';
3
3
  import { collectMatchingEntries, countEntriesByTag, findUnanchoredPattern, formatIndexNotReadable, isIndexReadable, matchesAnyPathPattern, pageMatchingEntries, pathOrder, readSummarizedValueAt, } from './historyQuery.js';
4
- import { DiffValueAbsent, DiffValuePresent, EventConnected, EventDisconnected, EventFrame, KeyframeInfo, MAX_DISPATCH_BATCH_SIZE, MessageSchemaDocumentResult, MessageSchemaIndexResult, RequestFrame, ResponseDispatched, ResponseDispatchedBatch, ResponseError, ResponseFrame, ResponseInit, ResponseKeyframes, ResponseMessage, ResponseMessageCounts, ResponseMessageSchema, ResponseMessages, ResponseModel, ResponseModelDiff, ResponseReplayed, ResponseResumed, ResponseRuntimeState, RuntimeInfo, } from './protocol.js';
4
+ import { DiffValue, Event, EventFrame, KeyframeInfo, MAX_DISPATCH_BATCH_SIZE, MessageSchemaResult, RequestFrame, Response, ResponseFrame, RuntimeInfo, } from './protocol.js';
5
5
  import { diagnoseVariantPath, indexMessageSchemaDocument, narrowToVariant, splitVariantPath, } from './schemaSummarize.js';
6
6
  import { toInspectableValue, toSerializedCommand, toSerializedEntry, toSerializedMount, } from './serialize.js';
7
7
  import { INIT_INDEX, computeDiff, latestEntryIndex, nextEntryIndex, } from './store.js';
@@ -71,7 +71,7 @@ export const startWebSocketBridge = (store, hot, dispatch, maybeMessageSchema) =
71
71
  hot.send(RESPONSE_CHANNEL, encodeResponseFrame({ id, response }));
72
72
  };
73
73
  const announceConnected = () => {
74
- sendEvent(EventConnected({
74
+ sendEvent(Event.EventConnected({
75
75
  runtime: RuntimeInfo.make({
76
76
  connectionId,
77
77
  url: window.location.href,
@@ -106,7 +106,7 @@ export const startWebSocketBridge = (store, hot, dispatch, maybeMessageSchema) =
106
106
  return;
107
107
  }
108
108
  hasEmittedDisconnect = true;
109
- sendEvent(EventDisconnected({ connectionId }));
109
+ sendEvent(Event.EventDisconnected({ connectionId }));
110
110
  };
111
111
  hot.dispose(() => {
112
112
  emitDisconnect();
@@ -138,41 +138,43 @@ export const startWebSocketBridge = (store, hot, dispatch, maybeMessageSchema) =
138
138
  window.removeEventListener('pageshow', announceOnRestore);
139
139
  }));
140
140
  });
141
- const presentResolution = (resolution, expand) => Match.value(resolution).pipe(Match.tag('Found', ({ value, atPath }) => ResponseModel({
141
+ const presentResolution = (resolution, expand) => Match.value(resolution).pipe(Match.tag('Found', ({ value, atPath }) => Response.ResponseModel({
142
142
  value: expand ? value : summarizeValue(value),
143
143
  atPath,
144
144
  summarized: !expand,
145
- })), Match.orElse(notFound => ResponseError({ reason: formatPathNotFound(notFound) })));
145
+ })), Match.orElse(notFound => Response.ResponseError({ reason: formatPathNotFound(notFound) })));
146
146
  const readModelResponse = (store, index, maybePath, expand) => Effect.gen(function* () {
147
147
  const model = yield* store.getModelAtIndex(index);
148
148
  const path = Option.getOrElse(maybePath, () => 'root');
149
149
  return presentResolution(resolvePath(toInspectableValue(model), path), expand);
150
- }).pipe(Effect.catchCause(cause => Effect.succeed(ResponseError({
150
+ }).pipe(Effect.catchCause(cause => Effect.succeed(Response.ResponseError({
151
151
  reason: `Failed to read Model at index ${index}: ${Cause.pretty(cause)}`,
152
152
  }))));
153
- const maybePatternError = (maybeChangedPathsMatch) => pipe(maybeChangedPathsMatch, Option.flatMap(findUnanchoredPattern), Option.map(pattern => ResponseError({
153
+ const maybePatternError = (maybeChangedPathsMatch) => pipe(maybeChangedPathsMatch, Option.flatMap(findUnanchoredPattern), Option.map(pattern => Response.ResponseError({
154
154
  reason: `Invalid changed_paths_match pattern '${pattern}': patterns must start with 'root' or '*', matching the changedPaths alphabet (e.g. 'root.grid', 'root.cards.*.title').`,
155
155
  })));
156
156
  const toDiffValue = (maybeValue) => Option.match(maybeValue, {
157
- onNone: () => DiffValueAbsent(),
158
- onSome: value => DiffValuePresent({ value: value ?? null }),
157
+ onNone: () => DiffValue.Absent(),
158
+ onSome: value => DiffValue.Present({ value: value ?? null }),
159
159
  });
160
160
  const indexResponse = (document) => Option.match(indexMessageSchemaDocument(document), {
161
- onNone: () => ResponseError({
161
+ onNone: () => Response.ResponseError({
162
162
  reason: "Could not index Message Schema: the top-level shape is not a discriminated union of '_tag'-keyed structs. Open an issue if you see this against an Effect Schema released after foldkit's last sync.",
163
163
  }),
164
- onSome: variants => ResponseMessageSchema({
165
- maybeResult: Option.some(MessageSchemaIndexResult({ index: { variants } })),
164
+ onSome: variants => Response.ResponseMessageSchema({
165
+ maybeResult: Option.some(MessageSchemaResult.MessageSchemaIndexResult({ index: { variants } })),
166
166
  }),
167
167
  });
168
168
  const narrowResponse = (document, variantPath) => Option.match(narrowToVariant(document, variantPath), {
169
169
  onNone: () => formatUnknownVariantError(document, variantPath),
170
- onSome: narrowed => ResponseMessageSchema({
171
- maybeResult: Option.some(MessageSchemaDocumentResult({ document: narrowed })),
170
+ onSome: narrowed => Response.ResponseMessageSchema({
171
+ maybeResult: Option.some(MessageSchemaResult.MessageSchemaDocumentResult({
172
+ document: narrowed,
173
+ })),
172
174
  }),
173
175
  });
174
176
  const buildMessageSchemaResponse = (maybeJsonSchemaDocument, maybeVariantTag) => Option.match(maybeJsonSchemaDocument, {
175
- onNone: () => ResponseMessageSchema({ maybeResult: Option.none() }),
177
+ onNone: () => Response.ResponseMessageSchema({ maybeResult: Option.none() }),
176
178
  onSome: document => Option.match(maybeVariantTag, {
177
179
  onNone: () => indexResponse(document),
178
180
  onSome: variantTag => narrowResponse(document, variantTag),
@@ -181,7 +183,7 @@ const buildMessageSchemaResponse = (maybeJsonSchemaDocument, maybeVariantTag) =>
181
183
  const formatUnknownVariantError = (document, variantPath) => {
182
184
  const segments = splitVariantPath(variantPath);
183
185
  return Option.match(diagnoseVariantPath(document, segments), {
184
- onNone: () => ResponseError({
186
+ onNone: () => Response.ResponseError({
185
187
  reason: `No Message variant at path '${variantPath}'. The runtime's Message Schema is not a discriminated union of '_tag'-keyed structs.`,
186
188
  }),
187
189
  onSome: ({ prefix, failingSegment, available }) => {
@@ -193,11 +195,11 @@ const formatUnknownVariantError = (document, variantPath) => {
193
195
  const reason = failingIsKnownTag
194
196
  ? `No further structure to drill into at path '${variantPath}'. The variant '${failingTag}' at ${prefixLabel} does not carry exactly one tagged-union payload field, which is what the walker steps through. Idiomatic Foldkit Messages have at most one tagged-union field per variant (the 'message' field on Submodel wrappers, or a single value-type union); state surrounding a Submodel call belongs as an argument to the child's update/view, not as a sibling field on the parent Message.`
195
197
  : `No Message variant at path '${variantPath}'. Available variants at ${prefixLabel}: ${available.join(', ')}.`;
196
- return ResponseError({ reason });
198
+ return Response.ResponseError({ reason });
197
199
  },
198
200
  });
199
201
  };
200
- const missingMessageSchemaResponse = ResponseError({
202
+ const missingMessageSchemaResponse = Response.ResponseError({
201
203
  reason: 'Cannot dispatch: DevToolsConfig.Message not configured. Pass your Message Schema to enable dispatch.',
202
204
  });
203
205
  const formatInvalidMessageReason = (error, message) => `${error instanceof Error ? error.message : String(error)}\n\nReceived (typeof ${typeof message}): ${JSON.stringify(message)}`;
@@ -215,7 +217,7 @@ export const dispatchRequest = (store, dispatch, maybeDispatchSchema, maybeJsonS
215
217
  RequestGetModelAt: ({ index, maybePath, expand }) => Effect.gen(function* () {
216
218
  const state = yield* SubscriptionRef.get(store.stateRef);
217
219
  if (!isIndexReadable(state, index)) {
218
- return ResponseError({
220
+ return Response.ResponseError({
219
221
  reason: formatIndexNotReadable(state, index),
220
222
  });
221
223
  }
@@ -223,7 +225,7 @@ export const dispatchRequest = (store, dispatch, maybeDispatchSchema, maybeJsonS
223
225
  }),
224
226
  RequestListMessages: ({ limit, maybeSinceIndex, maybeChangedPathsMatch, fromEnd, }) => Effect.gen(function* () {
225
227
  if (fromEnd && Option.isSome(maybeSinceIndex)) {
226
- return ResponseError({
228
+ return Response.ResponseError({
227
229
  reason: 'from_end cannot be combined with since_index. Use from_end alone to read the latest entries, or since_index to page forward.',
228
230
  });
229
231
  }
@@ -235,7 +237,7 @@ export const dispatchRequest = (store, dispatch, maybeDispatchSchema, maybeJsonS
235
237
  const candidates = collectMatchingEntries(state, maybeSinceIndex, maybeChangedPathsMatch);
236
238
  const { page, maybeNextIndex } = pageMatchingEntries(candidates, limit, fromEnd);
237
239
  const entries = Array.map(page, ({ entry, index }) => toSerializedEntry(entry, index));
238
- return ResponseMessages({ entries, maybeNextIndex });
240
+ return Response.ResponseMessages({ entries, maybeNextIndex });
239
241
  }),
240
242
  RequestCountMessagesByTag: ({ maybeSinceIndex, maybeChangedPathsMatch, }) => Effect.gen(function* () {
241
243
  const maybeInvalidPattern = maybePatternError(maybeChangedPathsMatch);
@@ -245,7 +247,7 @@ export const dispatchRequest = (store, dispatch, maybeDispatchSchema, maybeJsonS
245
247
  const state = yield* SubscriptionRef.get(store.stateRef);
246
248
  const candidates = collectMatchingEntries(state, maybeSinceIndex, maybeChangedPathsMatch);
247
249
  const scannedFromIndex = Math.max(Option.getOrElse(maybeSinceIndex, () => state.startIndex), state.startIndex);
248
- return ResponseMessageCounts({
250
+ return Response.ResponseMessageCounts({
249
251
  counts: countEntriesByTag(candidates),
250
252
  totalCount: candidates.length,
251
253
  scannedFromIndex,
@@ -260,7 +262,7 @@ export const dispatchRequest = (store, dispatch, maybeDispatchSchema, maybeJsonS
260
262
  const state = yield* SubscriptionRef.get(store.stateRef);
261
263
  const maybeUnreadableIndex = Array.findFirst([fromIndex, toIndex], index => !isIndexReadable(state, index));
262
264
  if (Option.isSome(maybeUnreadableIndex)) {
263
- return ResponseError({
265
+ return Response.ResponseError({
264
266
  reason: formatIndexNotReadable(state, maybeUnreadableIndex.value),
265
267
  });
266
268
  }
@@ -281,8 +283,8 @@ export const dispatchRequest = (store, dispatch, maybeDispatchSchema, maybeJsonS
281
283
  before: toDiffValue(readSummarizedValueAt(beforeModel, path)),
282
284
  after: toDiffValue(readSummarizedValueAt(afterModel, path)),
283
285
  })));
284
- return ResponseModelDiff({ fromIndex, toIndex, changes });
285
- }).pipe(Effect.catchCause(cause => Effect.succeed(ResponseError({
286
+ return Response.ResponseModelDiff({ fromIndex, toIndex, changes });
287
+ }).pipe(Effect.catchCause(cause => Effect.succeed(Response.ResponseError({
286
288
  reason: `Failed to diff Models between ${fromIndex} and ${toIndex}: ${Cause.pretty(cause)}`,
287
289
  })))),
288
290
  RequestGetMessage: ({ index }) => Effect.gen(function* () {
@@ -290,10 +292,10 @@ export const dispatchRequest = (store, dispatch, maybeDispatchSchema, maybeJsonS
290
292
  const relative = index - state.startIndex;
291
293
  const maybeEntry = Array.get(state.entries, relative);
292
294
  return yield* Option.match(maybeEntry, {
293
- onNone: () => Effect.succeed(ResponseError({
295
+ onNone: () => Effect.succeed(Response.ResponseError({
294
296
  reason: `No entry at index ${index} (have ${state.startIndex} to ${state.startIndex + state.entries.length - 1})`,
295
297
  })),
296
- onSome: entry => Effect.succeed(ResponseMessage({
298
+ onSome: entry => Effect.succeed(Response.ResponseMessage({
297
299
  entry: toSerializedEntry(entry, index),
298
300
  })),
299
301
  });
@@ -306,25 +308,27 @@ export const dispatchRequest = (store, dispatch, maybeDispatchSchema, maybeJsonS
306
308
  onSome: () => [INIT_INDEX, ...sortedKeyframeIndices],
307
309
  });
308
310
  const keyframes = indicesWithInit.map(index => KeyframeInfo.make({ index }));
309
- return ResponseKeyframes({ keyframes });
311
+ return Response.ResponseKeyframes({ keyframes });
310
312
  }),
311
313
  RequestReplayToKeyframe: ({ keyframeIndex }) => pipe(Effect.gen(function* () {
312
314
  const state = yield* SubscriptionRef.get(store.stateRef);
313
315
  if (!isIndexReadable(state, keyframeIndex)) {
314
- return ResponseError({
316
+ return Response.ResponseError({
315
317
  reason: formatIndexNotReadable(state, keyframeIndex),
316
318
  });
317
319
  }
318
320
  yield* store.jumpTo(keyframeIndex);
319
321
  const model = yield* store.getModelAtIndex(keyframeIndex);
320
- return ResponseReplayed({ model: toInspectableValue(model) });
321
- }), Effect.catchCause(cause => Effect.succeed(ResponseError({
322
+ return Response.ResponseReplayed({
323
+ model: toInspectableValue(model),
324
+ });
325
+ }), Effect.catchCause(cause => Effect.succeed(Response.ResponseError({
322
326
  reason: `Failed to replay to keyframe ${keyframeIndex}: ${Cause.pretty(cause)}`,
323
327
  })))),
324
328
  RequestResume: () => Effect.gen(function* () {
325
329
  yield* store.resume;
326
- return ResponseResumed();
327
- }).pipe(Effect.catchCause(cause => Effect.succeed(ResponseError({
330
+ return Response.ResponseResumed();
331
+ }).pipe(Effect.catchCause(cause => Effect.succeed(Response.ResponseError({
328
332
  reason: `Failed to resume: ${Cause.pretty(cause)}`,
329
333
  })))),
330
334
  RequestDispatchMessage: ({ message }) => Option.match(maybeDispatchSchema, {
@@ -334,14 +338,14 @@ export const dispatchRequest = (store, dispatch, maybeDispatchSchema, maybeJsonS
334
338
  const stateBefore = yield* SubscriptionRef.get(store.stateRef);
335
339
  const acceptedAtIndex = nextEntryIndex(stateBefore);
336
340
  yield* dispatch(decodedMessage);
337
- return ResponseDispatched({ acceptedAtIndex });
338
- }).pipe(Effect.catch(error => Effect.succeed(ResponseError({
341
+ return Response.ResponseDispatched({ acceptedAtIndex });
342
+ }).pipe(Effect.catch(error => Effect.succeed(Response.ResponseError({
339
343
  reason: `Invalid Message: ${formatInvalidMessageReason(error, message)}`,
340
344
  })))),
341
345
  }),
342
346
  RequestDispatchMessages: ({ messages }) => {
343
347
  if (messages.length > MAX_DISPATCH_BATCH_SIZE) {
344
- return Effect.succeed(ResponseError({
348
+ return Effect.succeed(Response.ResponseError({
345
349
  reason: `Batch too large: ${messages.length} Messages exceeds the limit of ${MAX_DISPATCH_BATCH_SIZE}. No Messages from the batch were dispatched.`,
346
350
  }));
347
351
  }
@@ -354,19 +358,19 @@ export const dispatchRequest = (store, dispatch, maybeDispatchSchema, maybeJsonS
354
358
  const firstAcceptedIndex = nextEntryIndex(stateBefore);
355
359
  yield* Effect.forEach(decodedMessages, dispatch);
356
360
  const acceptedAtIndices = Array.map(decodedMessages, (_decodedMessage, offset) => firstAcceptedIndex + offset);
357
- return ResponseDispatchedBatch({ acceptedAtIndices });
358
- }).pipe(Effect.catch(error => Effect.succeed(ResponseError({
361
+ return Response.ResponseDispatchedBatch({ acceptedAtIndices });
362
+ }).pipe(Effect.catch(error => Effect.succeed(Response.ResponseError({
359
363
  reason: error instanceof Error ? error.message : String(error),
360
364
  })))),
361
365
  });
362
366
  },
363
367
  RequestGetMessageSchema: ({ maybeVariantTag }) => Effect.succeed(buildMessageSchemaResponse(maybeJsonSchemaDocument, maybeVariantTag)),
364
- RequestListRuntimes: () => Effect.succeed(ResponseError({
368
+ RequestListRuntimes: () => Effect.succeed(Response.ResponseError({
365
369
  reason: 'RequestListRuntimes is plugin-handled and should not reach the runtime bridge',
366
370
  })),
367
371
  RequestGetInit: () => Effect.gen(function* () {
368
372
  const state = yield* SubscriptionRef.get(store.stateRef);
369
- return ResponseInit({
373
+ return Response.ResponseInit({
370
374
  maybeModel: Option.map(state.maybeInitModel, toInspectableValue),
371
375
  commands: Array.map(state.initCommands, toSerializedCommand),
372
376
  mountStarts: Array.map(state.initMountStarts, toSerializedMount),
@@ -375,7 +379,7 @@ export const dispatchRequest = (store, dispatch, maybeDispatchSchema, maybeJsonS
375
379
  RequestGetRuntimeState: () => Effect.gen(function* () {
376
380
  const state = yield* SubscriptionRef.get(store.stateRef);
377
381
  const currentIndex = latestEntryIndex(state);
378
- return ResponseRuntimeState({
382
+ return Response.ResponseRuntimeState({
379
383
  currentIndex,
380
384
  startIndex: state.startIndex,
381
385
  totalEntries: state.entries.length,
@@ -1,5 +1,5 @@
1
1
  import { Effect } from 'effect';
2
- export { UrlRequest, Internal, External } from './urlRequest.js';
2
+ export { UrlRequest } from './urlRequest.js';
3
3
  /** Pushes a new URL to browser history and triggers Foldkit's URL change handling. */
4
4
  export declare const pushUrl: (url: string) => Effect.Effect<void>;
5
5
  /** Replaces the current URL in browser history and triggers Foldkit's URL change handling. */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/navigation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAEhE,sFAAsF;AACtF,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAIpD,CAAA;AAEJ,8FAA8F;AAC9F,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAIvD,CAAA;AAEJ,yCAAyC;AACzC,eAAO,MAAM,IAAI,QAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CACA,CAAA;AAE1C,4CAA4C;AAC5C,eAAO,MAAM,OAAO,QAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CACA,CAAA;AAE7C,yDAAyD;AACzD,eAAO,MAAM,IAAI,GAAI,MAAM,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CACL,CAAA;AAEjD;4GAC4G;AAC5G,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAGrD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/navigation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,sFAAsF;AACtF,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAIpD,CAAA;AAEJ,8FAA8F;AAC9F,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAIvD,CAAA;AAEJ,yCAAyC;AACzC,eAAO,MAAM,IAAI,QAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CACA,CAAA;AAE1C,4CAA4C;AAC5C,eAAO,MAAM,OAAO,QAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CACA,CAAA;AAE7C,yDAAyD;AACzD,eAAO,MAAM,IAAI,GAAI,MAAM,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CACL,CAAA;AAEjD;4GAC4G;AAC5G,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAGrD,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { Effect } from 'effect';
2
- export { UrlRequest, Internal, External } from './urlRequest.js';
2
+ export { UrlRequest } from './urlRequest.js';
3
3
  /** Pushes a new URL to browser history and triggers Foldkit's URL change handling. */
4
4
  export const pushUrl = (url) => Effect.sync(() => {
5
5
  window.history.pushState({}, '', url);
@@ -1,2 +1,2 @@
1
- export { pushUrl, replaceUrl, back, forward, load, openUrl, UrlRequest, Internal, External, } from './index.js';
1
+ export { pushUrl, replaceUrl, back, forward, load, openUrl, UrlRequest, } from './index.js';
2
2
  //# sourceMappingURL=public.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/navigation/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,UAAU,EACV,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,OAAO,EACP,UAAU,EACV,QAAQ,EACR,QAAQ,GACT,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/navigation/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,UAAU,EACV,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,OAAO,EACP,UAAU,GACX,MAAM,YAAY,CAAA"}
@@ -1 +1 @@
1
- export { pushUrl, replaceUrl, back, forward, load, openUrl, UrlRequest, Internal, External, } from './index.js';
1
+ export { pushUrl, replaceUrl, back, forward, load, openUrl, UrlRequest, } from './index.js';
@@ -1,36 +1,20 @@
1
1
  import { Schema as S } from 'effect';
2
- /** A URL request to a page within the application (same origin). */
3
- export declare const Internal: import("../schema/index.js").CallableTaggedStruct<"Internal", {
4
- url: S.Struct<{
5
- readonly protocol: S.String;
6
- readonly host: S.String;
7
- readonly port: S.Option<S.String>;
8
- readonly pathname: S.String;
9
- readonly search: S.Option<S.String>;
10
- readonly hash: S.Option<S.String>;
11
- }>;
12
- }>;
13
- /** A URL request to a page within the application (same origin). */
14
- export type Internal = typeof Internal.Type;
15
- /** A URL request to an external page (different origin). */
16
- export declare const External: import("../schema/index.js").CallableTaggedStruct<"External", {
17
- href: S.String;
18
- }>;
19
- /** A URL request to an external page (different origin). */
20
- export type External = typeof External.Type;
21
2
  /** Union of `Internal` and `External` URL request types. */
22
- export declare const UrlRequest: S.Union<readonly [import("../schema/index.js").CallableTaggedStruct<"Internal", {
23
- url: S.Struct<{
24
- readonly protocol: S.String;
25
- readonly host: S.String;
26
- readonly port: S.Option<S.String>;
27
- readonly pathname: S.String;
28
- readonly search: S.Option<S.String>;
29
- readonly hash: S.Option<S.String>;
30
- }>;
31
- }>, import("../schema/index.js").CallableTaggedStruct<"External", {
32
- href: S.String;
33
- }>]>;
3
+ export declare const UrlRequest: import("../schema/index.js").TaggedUnion<{
4
+ readonly Internal: {
5
+ readonly url: S.Struct<{
6
+ readonly protocol: S.String;
7
+ readonly host: S.String;
8
+ readonly port: S.Option<S.String>;
9
+ readonly pathname: S.String;
10
+ readonly search: S.Option<S.String>;
11
+ readonly hash: S.Option<S.String>;
12
+ }>;
13
+ };
14
+ readonly External: {
15
+ readonly href: S.String;
16
+ };
17
+ }>;
34
18
  /** Union of `Internal` and `External` URL request types. */
35
19
  export type UrlRequest = typeof UrlRequest.Type;
36
20
  //# sourceMappingURL=urlRequest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"urlRequest.d.ts","sourceRoot":"","sources":["../../src/navigation/urlRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAKpC,oEAAoE;AACpE,eAAO,MAAM,QAAQ;;;;;;;;;EAEnB,CAAA;AACF,oEAAoE;AACpE,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAA;AAE3C,4DAA4D;AAC5D,eAAO,MAAM,QAAQ;;EAEnB,CAAA;AACF,4DAA4D;AAC5D,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAA;AAE3C,4DAA4D;AAC5D,eAAO,MAAM,UAAU;;;;;;;;;;;IAAgC,CAAA;AACvD,4DAA4D;AAC5D,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAA"}
1
+ {"version":3,"file":"urlRequest.d.ts","sourceRoot":"","sources":["../../src/navigation/urlRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAKpC,4DAA4D;AAC5D,eAAO,MAAM,UAAU;;;;;;;;;;;;;;EAGrB,CAAA;AACF,4DAA4D;AAC5D,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAA"}
@@ -1,13 +1,8 @@
1
1
  import { Schema as S } from 'effect';
2
- import { ts } from '../schema/index.js';
2
+ import { defineTaggedUnion } from '../schema/index.js';
3
3
  import { Url } from '../url/index.js';
4
- /** A URL request to a page within the application (same origin). */
5
- export const Internal = ts('Internal', {
6
- url: Url,
7
- });
8
- /** A URL request to an external page (different origin). */
9
- export const External = ts('External', {
10
- href: S.String,
11
- });
12
4
  /** Union of `Internal` and `External` URL request types. */
13
- export const UrlRequest = S.Union([Internal, External]);
5
+ export const UrlRequest = defineTaggedUnion({
6
+ Internal: { url: Url },
7
+ External: { href: S.String },
8
+ });
@@ -1,4 +1,5 @@
1
1
  export * from './parser.js';
2
2
  export * as Transition from './transition.js';
3
- export { r } from '../schema/index.js';
3
+ export { defineRouteUnion } from '../schema/index.js';
4
+ export type { RouteUnion } from '../schema/index.js';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/route/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/route/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA"}
@@ -1,3 +1,3 @@
1
1
  export * from './parser.js';
2
2
  export * as Transition from './transition.js';
3
- export { r } from '../schema/index.js';
3
+ export { defineRouteUnion } from '../schema/index.js';
@@ -1,4 +1,4 @@
1
- export { ParseError, literal, param, string, int, schemaSegment, root, rest, restString, oneOf, mapTo, slash, query, parseUrlWithFallback, r, } from './index.js';
2
- export type { ParseResult, Biparser, Router, TerminalParser, ExtendableBiparser, Parser, } from './index.js';
1
+ export { ParseError, literal, param, string, int, schemaSegment, root, rest, restString, oneOf, mapTo, slash, query, parseUrlWithFallback, defineRouteUnion, } from './index.js';
2
+ export type { ParseResult, Biparser, Router, TerminalParser, ExtendableBiparser, Parser, RouteUnion, } from './index.js';
3
3
  export * as Transition from './transition.js';
4
4
  //# sourceMappingURL=public.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/route/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,OAAO,EACP,KAAK,EACL,MAAM,EACN,GAAG,EACH,aAAa,EACb,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,oBAAoB,EACpB,CAAC,GACF,MAAM,YAAY,CAAA;AAEnB,YAAY,EACV,WAAW,EACX,QAAQ,EACR,MAAM,EACN,cAAc,EACd,kBAAkB,EAClB,MAAM,GACP,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/route/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,OAAO,EACP,KAAK,EACL,MAAM,EACN,GAAG,EACH,aAAa,EACb,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,YAAY,CAAA;AAEnB,YAAY,EACV,WAAW,EACX,QAAQ,EACR,MAAM,EACN,cAAc,EACd,kBAAkB,EAClB,MAAM,EACN,UAAU,GACX,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA"}
@@ -1,2 +1,2 @@
1
- export { ParseError, literal, param, string, int, schemaSegment, root, rest, restString, oneOf, mapTo, slash, query, parseUrlWithFallback, r, } from './index.js';
1
+ export { ParseError, literal, param, string, int, schemaSegment, root, rest, restString, oneOf, mapTo, slash, query, parseUrlWithFallback, defineRouteUnion, } from './index.js';
2
2
  export * as Transition from './transition.js';
@@ -1 +1 @@
1
- {"version":3,"file":"browserListeners.d.ts","sourceRoot":"","sources":["../../src/runtime/browserListeners.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAE5C,eAAO,MAAM,2BAA2B,GAAI,OAAO,EACjD,UAAU,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,EACpC,eAAe,aAAa,CAAC,OAAO,CAAC,KACpC,CAAC,MAAM,IAAI,CAWb,CAAA;AAgBD,eAAO,MAAM,oBAAoB,GAAI,OAAO,EAC1C,UAAU,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,EACpC,eAAe,aAAa,CAAC,OAAO,CAAC,KACpC,CAAC,MAAM,IAAI,CAsDb,CAAA"}
1
+ {"version":3,"file":"browserListeners.d.ts","sourceRoot":"","sources":["../../src/runtime/browserListeners.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAE5C,eAAO,MAAM,2BAA2B,GAAI,OAAO,EACjD,UAAU,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,EACpC,eAAe,aAAa,CAAC,OAAO,CAAC,KACpC,CAAC,MAAM,IAAI,CAWb,CAAA;AAgBD,eAAO,MAAM,oBAAoB,GAAI,OAAO,EAC1C,UAAU,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,EACpC,eAAe,aAAa,CAAC,OAAO,CAAC,KACpC,CAAC,MAAM,IAAI,CAwDb,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { Option, String } from 'effect';
2
2
  import { OptionExt, StringExt } from '../effectExtensions/index.js';
3
- import { External, Internal } from '../navigation/urlRequest.js';
3
+ import { UrlRequest } from '../navigation/urlRequest.js';
4
4
  export const addNavigationEventListeners = (dispatch, routingConfig) => {
5
5
  const removePopStateListener = addPopStateListener(dispatch, routingConfig);
6
6
  const removeLinkClickListener = addLinkClickListener(dispatch, routingConfig);
@@ -50,10 +50,10 @@ export const addLinkClickListener = (dispatch, routingConfig) => {
50
50
  const linkUrl = new URL(href);
51
51
  const currentUrl = new URL(window.location.href);
52
52
  if (linkUrl.origin !== currentUrl.origin) {
53
- dispatch(routingConfig.onUrlRequest(External({ href })));
53
+ dispatch(routingConfig.onUrlRequest(UrlRequest.External({ href })));
54
54
  return;
55
55
  }
56
- dispatch(routingConfig.onUrlRequest(Internal({ url: urlToFoldkitUrl(linkUrl) })));
56
+ dispatch(routingConfig.onUrlRequest(UrlRequest.Internal({ url: urlToFoldkitUrl(linkUrl) })));
57
57
  };
58
58
  document.addEventListener('click', onLinkClick);
59
59
  return () => {