foldkit 0.81.1 → 0.82.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/calendar/calendarDate.d.ts +11 -11
- package/dist/calendar/calendarDate.d.ts.map +1 -1
- package/dist/calendar/calendarDate.js +14 -13
- package/dist/calendar/comparison.d.ts +3 -3
- package/dist/calendar/comparison.d.ts.map +1 -1
- package/dist/calendar/comparison.js +5 -5
- package/dist/calendar/info.d.ts +1 -1
- package/dist/calendar/info.d.ts.map +1 -1
- package/dist/calendar/info.js +9 -1
- package/dist/calendar/locale.d.ts +5 -5
- package/dist/calendar/locale.js +23 -2
- package/dist/command/index.d.ts +2 -2
- package/dist/command/index.d.ts.map +1 -1
- package/dist/devTools/overlay.d.ts.map +1 -1
- package/dist/devTools/overlay.js +49 -27
- package/dist/devTools/protocol.d.ts +192 -192
- package/dist/devTools/protocol.d.ts.map +1 -1
- package/dist/devTools/protocol.js +36 -12
- package/dist/devTools/serialize.d.ts.map +1 -1
- package/dist/devTools/serialize.js +4 -4
- package/dist/devTools/store.d.ts.map +1 -1
- package/dist/devTools/store.js +1 -2
- package/dist/devTools/submodelPath.d.ts +1 -1
- package/dist/devTools/summarize.d.ts +6 -6
- package/dist/devTools/summarize.d.ts.map +1 -1
- package/dist/devTools/summarize.js +6 -6
- package/dist/devTools/webSocketBridge.d.ts +1 -1
- package/dist/devTools/webSocketBridge.d.ts.map +1 -1
- package/dist/devTools/webSocketBridge.js +19 -18
- package/dist/fieldValidation/index.d.ts +11 -11
- package/dist/fieldValidation/index.d.ts.map +1 -1
- package/dist/fieldValidation/index.js +8 -7
- package/dist/file/error.d.ts +1 -1
- package/dist/file/file.d.ts +1 -1
- package/dist/file/file.js +1 -1
- package/dist/file/reader.d.ts +4 -4
- package/dist/file/reader.js +5 -5
- package/dist/file/select.js +1 -1
- package/dist/html/index.d.ts.map +1 -1
- package/dist/html/index.js +4 -3
- package/dist/html/lazy.d.ts.map +1 -1
- package/dist/html/lazy.js +6 -7
- package/dist/managedResource/index.d.ts +2 -2
- package/dist/managedResource/index.d.ts.map +1 -1
- package/dist/managedResource/index.js +2 -2
- package/dist/mount/index.d.ts +1 -1
- package/dist/mount/index.d.ts.map +1 -1
- package/dist/route/parser.d.ts +2 -2
- package/dist/route/parser.d.ts.map +1 -1
- package/dist/route/parser.js +5 -5
- package/dist/runtime/browserListeners.d.ts.map +1 -1
- package/dist/runtime/browserListeners.js +6 -7
- package/dist/runtime/deepFreeze.d.ts +1 -1
- package/dist/runtime/deepFreeze.js +2 -2
- package/dist/runtime/hmrProtocol.d.ts +22 -0
- package/dist/runtime/hmrProtocol.d.ts.map +1 -0
- package/dist/runtime/hmrProtocol.js +15 -0
- package/dist/runtime/hmrProtocolPublic.d.ts +2 -0
- package/dist/runtime/hmrProtocolPublic.d.ts.map +1 -0
- package/dist/runtime/hmrProtocolPublic.js +1 -0
- package/dist/runtime/runtime.d.ts +10 -7
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +116 -114
- package/dist/runtime/subscription.d.ts +5 -5
- package/dist/runtime/subscription.d.ts.map +1 -1
- package/dist/runtime/urlRequest.d.ts +15 -15
- package/dist/runtime/urlRequest.d.ts.map +1 -1
- package/dist/runtime/urlRequest.js +1 -1
- package/dist/schema/index.d.ts +3 -3
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +10 -4
- package/dist/task/dom.js +1 -1
- package/dist/task/elementMovement.js +1 -1
- package/dist/task/error.d.ts +2 -2
- package/dist/task/inert.d.ts.map +1 -1
- package/dist/task/inert.js +4 -7
- package/dist/task/time.d.ts +1 -1
- package/dist/task/time.js +1 -1
- package/dist/task/timing.d.ts +1 -1
- package/dist/task/timing.d.ts.map +1 -1
- package/dist/task/timing.js +2 -2
- package/dist/test/apps/bubbling.d.ts +3 -3
- package/dist/test/apps/bubbling.d.ts.map +1 -1
- package/dist/test/apps/bubbling.js +1 -1
- package/dist/test/apps/counter.d.ts +6 -6
- package/dist/test/apps/counter.d.ts.map +1 -1
- package/dist/test/apps/counter.js +7 -1
- package/dist/test/apps/disabledButton.d.ts +11 -11
- package/dist/test/apps/disabledButton.d.ts.map +1 -1
- package/dist/test/apps/disabledButton.js +1 -1
- package/dist/test/apps/fileUpload.d.ts +4 -4
- package/dist/test/apps/fileUpload.d.ts.map +1 -1
- package/dist/test/apps/fileUpload.js +1 -1
- package/dist/test/apps/formChild.d.ts +16 -16
- package/dist/test/apps/formChild.d.ts.map +1 -1
- package/dist/test/apps/formChild.js +9 -4
- package/dist/test/apps/interactions.d.ts +8 -8
- package/dist/test/apps/interactions.d.ts.map +1 -1
- package/dist/test/apps/interactions.js +8 -1
- package/dist/test/apps/keypress.d.ts +7 -7
- package/dist/test/apps/keypress.d.ts.map +1 -1
- package/dist/test/apps/keypress.js +1 -1
- package/dist/test/apps/login.d.ts +14 -14
- package/dist/test/apps/login.d.ts.map +1 -1
- package/dist/test/apps/login.js +9 -2
- package/dist/test/apps/logoutButton.d.ts +3 -3
- package/dist/test/apps/logoutButton.d.ts.map +1 -1
- package/dist/test/apps/logoutButton.js +2 -2
- package/dist/test/apps/multiRole.d.ts +2 -2
- package/dist/test/apps/multiRole.d.ts.map +1 -1
- package/dist/test/apps/multiRole.js +1 -1
- package/dist/test/apps/pointer.d.ts +6 -6
- package/dist/test/apps/pointer.d.ts.map +1 -1
- package/dist/test/apps/pointer.js +1 -1
- package/dist/test/apps/resumeUpload.d.ts +8 -8
- package/dist/test/apps/resumeUpload.d.ts.map +1 -1
- package/dist/test/apps/resumeUpload.js +12 -5
- package/dist/test/internal.js +10 -10
- package/dist/test/matchers.js +1 -1
- package/dist/test/query.d.ts.map +1 -1
- package/dist/test/query.js +13 -13
- package/dist/test/scene.d.ts.map +1 -1
- package/dist/test/scene.js +3 -3
- package/dist/test/story.js +1 -1
- package/dist/ui/animation/schema.d.ts +5 -5
- package/dist/ui/animation/schema.d.ts.map +1 -1
- package/dist/ui/animation/schema.js +9 -3
- package/dist/ui/calendar/index.d.ts +77 -77
- package/dist/ui/calendar/index.d.ts.map +1 -1
- package/dist/ui/calendar/index.js +26 -11
- package/dist/ui/checkbox/index.d.ts +2 -2
- package/dist/ui/combobox/multi.d.ts +38 -42
- package/dist/ui/combobox/multi.d.ts.map +1 -1
- package/dist/ui/combobox/multi.js +4 -1
- package/dist/ui/combobox/shared.d.ts +31 -31
- package/dist/ui/combobox/shared.d.ts.map +1 -1
- package/dist/ui/combobox/shared.js +34 -12
- package/dist/ui/combobox/single.d.ts +39 -43
- package/dist/ui/combobox/single.d.ts.map +1 -1
- package/dist/ui/combobox/single.js +7 -6
- package/dist/ui/datePicker/index.d.ts +86 -86
- package/dist/ui/datePicker/index.d.ts.map +1 -1
- package/dist/ui/datePicker/index.js +10 -3
- package/dist/ui/dialog/index.d.ts +8 -8
- package/dist/ui/dialog/index.d.ts.map +1 -1
- package/dist/ui/dialog/index.js +9 -3
- package/dist/ui/disclosure/index.d.ts +2 -2
- package/dist/ui/disclosure/index.d.ts.map +1 -1
- package/dist/ui/disclosure/index.js +1 -1
- package/dist/ui/dragAndDrop/index.d.ts +76 -76
- package/dist/ui/dragAndDrop/index.d.ts.map +1 -1
- package/dist/ui/dragAndDrop/index.js +47 -29
- package/dist/ui/fileDrop/index.d.ts +8 -8
- package/dist/ui/fileDrop/index.d.ts.map +1 -1
- package/dist/ui/fileDrop/index.js +7 -2
- package/dist/ui/listbox/multi.d.ts +36 -40
- package/dist/ui/listbox/multi.d.ts.map +1 -1
- package/dist/ui/listbox/multi.js +4 -1
- package/dist/ui/listbox/shared.d.ts +32 -32
- package/dist/ui/listbox/shared.d.ts.map +1 -1
- package/dist/ui/listbox/shared.js +36 -11
- package/dist/ui/listbox/single.d.ts +36 -40
- package/dist/ui/listbox/single.d.ts.map +1 -1
- package/dist/ui/listbox/single.js +5 -2
- package/dist/ui/menu/index.d.ts +40 -40
- package/dist/ui/menu/index.d.ts.map +1 -1
- package/dist/ui/menu/index.js +38 -11
- package/dist/ui/popover/index.d.ts +12 -12
- package/dist/ui/popover/index.d.ts.map +1 -1
- package/dist/ui/popover/index.js +17 -2
- package/dist/ui/radioGroup/index.d.ts +6 -6
- package/dist/ui/radioGroup/index.d.ts.map +1 -1
- package/dist/ui/radioGroup/index.js +5 -5
- package/dist/ui/slider/index.d.ts +26 -26
- package/dist/ui/slider/index.d.ts.map +1 -1
- package/dist/ui/slider/index.js +30 -16
- package/dist/ui/switch/index.d.ts +2 -2
- package/dist/ui/tabs/index.d.ts +8 -8
- package/dist/ui/tabs/index.d.ts.map +1 -1
- package/dist/ui/tabs/index.js +3 -3
- package/dist/ui/toast/index.d.ts +75 -75
- package/dist/ui/toast/index.d.ts.map +1 -1
- package/dist/ui/toast/index.js +1 -1
- package/dist/ui/toast/schema.d.ts +63 -63
- package/dist/ui/toast/schema.d.ts.map +1 -1
- package/dist/ui/toast/schema.js +19 -4
- package/dist/ui/toast/update.d.ts +67 -67
- package/dist/ui/toast/update.d.ts.map +1 -1
- package/dist/ui/toast/update.js +2 -2
- package/dist/ui/tooltip/index.d.ts +15 -15
- package/dist/ui/tooltip/index.d.ts.map +1 -1
- package/dist/ui/tooltip/index.js +14 -4
- package/dist/ui/virtualList/index.d.ts +16 -16
- package/dist/ui/virtualList/index.d.ts.map +1 -1
- package/dist/ui/virtualList/index.js +46 -42
- package/dist/url/index.d.ts +8 -8
- package/dist/url/index.d.ts.map +1 -1
- package/dist/url/index.js +14 -14
- package/package.json +12 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Array, Effect, Match as M, Number, Option, Schema as S, Stream, pipe, } from 'effect';
|
|
1
|
+
import { Array, Effect, Match as M, Number, Option, Queue, Schema as S, Stream, pipe, } from 'effect';
|
|
2
2
|
import * as Command from '../../command/index.js';
|
|
3
3
|
import { createLazy, html, } from '../../html/index.js';
|
|
4
4
|
import { m } from '../../message/index.js';
|
|
@@ -15,14 +15,14 @@ const Measured = ts('Measured', { containerHeight: S.Number });
|
|
|
15
15
|
* `Unmeasured` explicitly, typically by rendering a placeholder until the
|
|
16
16
|
* first measurement arrives.
|
|
17
17
|
*/
|
|
18
|
-
const Measurement = S.Union(Unmeasured, Measured);
|
|
18
|
+
const Measurement = S.Union([Unmeasured, Measured]);
|
|
19
19
|
const Idle = ts('Idle');
|
|
20
20
|
const ScrollingToIndex = ts('ScrollingToIndex', {
|
|
21
21
|
index: S.Number,
|
|
22
22
|
version: S.Number,
|
|
23
23
|
});
|
|
24
24
|
/** State of a programmatic scroll initiated by `scrollToIndex`. */
|
|
25
|
-
const PendingScroll = S.Union(Idle, ScrollingToIndex);
|
|
25
|
+
const PendingScroll = S.Union([Idle, ScrollingToIndex]);
|
|
26
26
|
/** Schema for the virtual list's state. Tracks scroll position, container
|
|
27
27
|
* measurement, and any in-flight programmatic scroll. */
|
|
28
28
|
export const Model = S.Struct({
|
|
@@ -50,7 +50,7 @@ export const CompletedApplyScroll = m('CompletedApplyScroll', {
|
|
|
50
50
|
version: S.Number,
|
|
51
51
|
});
|
|
52
52
|
/** Union of all messages the virtual list component can produce. */
|
|
53
|
-
export const Message = S.Union(ScrolledContainer, MeasuredContainer, CompletedApplyScroll);
|
|
53
|
+
export const Message = S.Union([ScrolledContainer, MeasuredContainer, CompletedApplyScroll]);
|
|
54
54
|
/** Creates an initial virtual list model from a config. The container starts
|
|
55
55
|
* in `Unmeasured` state. The first `ResizeObserver` entry transitions it to
|
|
56
56
|
* `Measured`. */
|
|
@@ -204,11 +204,11 @@ export const visibleWindowVariable = (model, items, itemToRowHeightPx, overscan)
|
|
|
204
204
|
const itemCount = items.length;
|
|
205
205
|
const cumulativeOffsets = prefixSum(items, itemToRowHeightPx);
|
|
206
206
|
const totalHeight = lastOrZero(cumulativeOffsets);
|
|
207
|
-
const firstVisibleIndex = pipe(cumulativeOffsets, Array.findFirstIndex(Number.
|
|
207
|
+
const firstVisibleIndex = pipe(cumulativeOffsets, Array.findFirstIndex(Number.isGreaterThan(model.scrollTop)), Option.match({
|
|
208
208
|
onNone: () => itemCount,
|
|
209
209
|
onSome: index => Math.max(0, index - 1),
|
|
210
210
|
}));
|
|
211
|
-
const lastVisibleIndex = pipe(cumulativeOffsets, Array.findFirstIndex(Number.
|
|
211
|
+
const lastVisibleIndex = pipe(cumulativeOffsets, Array.findFirstIndex(Number.isGreaterThanOrEqualTo(model.scrollTop + containerHeight)), Option.getOrElse(() => itemCount));
|
|
212
212
|
const startIndex = clampIndex(firstVisibleIndex - overscan, itemCount);
|
|
213
213
|
const endIndex = clampIndex(lastVisibleIndex + overscan, itemCount);
|
|
214
214
|
const topSpacerHeight = pipe(cumulativeOffsets, Array.get(startIndex), Option.getOrElse(() => 0));
|
|
@@ -223,7 +223,7 @@ export const visibleWindowVariable = (model, items, itemToRowHeightPx, overscan)
|
|
|
223
223
|
},
|
|
224
224
|
}));
|
|
225
225
|
// SUBSCRIPTION
|
|
226
|
-
const containerElement = (id) => Option.
|
|
226
|
+
const containerElement = (id) => Option.fromNullishOr(document.getElementById(id));
|
|
227
227
|
/** Schema describing the subscription dependencies for container scroll and
|
|
228
228
|
* resize tracking. */
|
|
229
229
|
export const SubscriptionDeps = S.Struct({
|
|
@@ -247,46 +247,49 @@ export const SubscriptionDeps = S.Struct({
|
|
|
247
247
|
export const subscriptions = makeSubscriptions(SubscriptionDeps)({
|
|
248
248
|
containerEvents: {
|
|
249
249
|
modelToDependencies: model => ({ id: model.id }),
|
|
250
|
-
dependenciesToStream: ({ id }) => Stream.
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
250
|
+
dependenciesToStream: ({ id }) => Stream.callback(queue => Effect.acquireRelease(Effect.sync(() => {
|
|
251
|
+
const state = {
|
|
252
|
+
scrollListener: null,
|
|
253
|
+
resizeObserver: null,
|
|
254
|
+
observedElement: null,
|
|
255
|
+
pendingFrame: null,
|
|
256
|
+
};
|
|
255
257
|
const detach = () => {
|
|
256
|
-
if (resizeObserver !== null) {
|
|
257
|
-
resizeObserver.disconnect();
|
|
258
|
-
resizeObserver = null;
|
|
258
|
+
if (state.resizeObserver !== null) {
|
|
259
|
+
state.resizeObserver.disconnect();
|
|
260
|
+
state.resizeObserver = null;
|
|
259
261
|
}
|
|
260
|
-
if (observedElement !== null &&
|
|
261
|
-
|
|
262
|
+
if (state.observedElement !== null &&
|
|
263
|
+
state.scrollListener !== null) {
|
|
264
|
+
state.observedElement.removeEventListener('scroll', state.scrollListener);
|
|
262
265
|
}
|
|
263
|
-
observedElement = null;
|
|
264
|
-
scrollListener = null;
|
|
266
|
+
state.observedElement = null;
|
|
267
|
+
state.scrollListener = null;
|
|
265
268
|
};
|
|
266
269
|
const attach = (element) => {
|
|
267
|
-
const listener = () =>
|
|
270
|
+
const listener = () => Queue.offerUnsafe(queue, ScrolledContainer({ scrollTop: element.scrollTop }));
|
|
268
271
|
element.addEventListener('scroll', listener, { passive: true });
|
|
269
|
-
scrollListener = listener;
|
|
270
|
-
observedElement = element;
|
|
271
|
-
resizeObserver = new ResizeObserver(entries => {
|
|
272
|
+
state.scrollListener = listener;
|
|
273
|
+
state.observedElement = element;
|
|
274
|
+
state.resizeObserver = new ResizeObserver(entries => {
|
|
272
275
|
const lastEntry = Array.last(entries);
|
|
273
276
|
if (Option.isSome(lastEntry)) {
|
|
274
|
-
|
|
277
|
+
Queue.offerUnsafe(queue, MeasuredContainer({
|
|
275
278
|
containerHeight: lastEntry.value.contentRect.height,
|
|
276
279
|
}));
|
|
277
280
|
}
|
|
278
281
|
});
|
|
279
|
-
resizeObserver.observe(element);
|
|
282
|
+
state.resizeObserver.observe(element);
|
|
280
283
|
};
|
|
281
284
|
const reconcile = () => {
|
|
282
285
|
const maybeElement = containerElement(id);
|
|
283
286
|
if (Option.isNone(maybeElement)) {
|
|
284
|
-
if (observedElement !== null) {
|
|
287
|
+
if (state.observedElement !== null) {
|
|
285
288
|
detach();
|
|
286
289
|
}
|
|
287
290
|
return;
|
|
288
291
|
}
|
|
289
|
-
if (observedElement === maybeElement.value) {
|
|
292
|
+
if (state.observedElement === maybeElement.value) {
|
|
290
293
|
return;
|
|
291
294
|
}
|
|
292
295
|
detach();
|
|
@@ -295,16 +298,17 @@ export const subscriptions = makeSubscriptions(SubscriptionDeps)({
|
|
|
295
298
|
reconcile();
|
|
296
299
|
// NOTE: observes the entire document subtree because the container
|
|
297
300
|
// can be inserted/removed by any parent the consumer chooses (route
|
|
298
|
-
// changes, conditional renders, modal mounts), and the framework
|
|
299
|
-
// no way to know that hierarchy in advance. Reconcile is gated
|
|
300
|
-
// and short-circuits when the cached observedElement is
|
|
301
|
-
// DOM, so per-mutation cost stays low even with
|
|
301
|
+
// changes, conditional renders, modal mounts), and the framework
|
|
302
|
+
// has no way to know that hierarchy in advance. Reconcile is gated
|
|
303
|
+
// by rAF and short-circuits when the cached observedElement is
|
|
304
|
+
// still in the DOM, so per-mutation cost stays low even with
|
|
305
|
+
// subtree: true.
|
|
302
306
|
const mutationObserver = new MutationObserver(() => {
|
|
303
|
-
if (pendingFrame !== null) {
|
|
307
|
+
if (state.pendingFrame !== null) {
|
|
304
308
|
return;
|
|
305
309
|
}
|
|
306
|
-
pendingFrame = requestAnimationFrame(() => {
|
|
307
|
-
pendingFrame = null;
|
|
310
|
+
state.pendingFrame = requestAnimationFrame(() => {
|
|
311
|
+
state.pendingFrame = null;
|
|
308
312
|
reconcile();
|
|
309
313
|
});
|
|
310
314
|
});
|
|
@@ -312,14 +316,14 @@ export const subscriptions = makeSubscriptions(SubscriptionDeps)({
|
|
|
312
316
|
childList: true,
|
|
313
317
|
subtree: true,
|
|
314
318
|
});
|
|
315
|
-
return
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
}),
|
|
319
|
+
return { state, detach, mutationObserver };
|
|
320
|
+
}), ({ state, detach, mutationObserver }) => Effect.sync(() => {
|
|
321
|
+
mutationObserver.disconnect();
|
|
322
|
+
if (state.pendingFrame !== null) {
|
|
323
|
+
cancelAnimationFrame(state.pendingFrame);
|
|
324
|
+
}
|
|
325
|
+
detach();
|
|
326
|
+
})).pipe(Effect.flatMap(() => Effect.never))),
|
|
323
327
|
},
|
|
324
328
|
});
|
|
325
329
|
// VIEW
|
package/dist/url/index.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { Option, Schema as S } from 'effect';
|
|
2
2
|
/** Schema representing a parsed URL with protocol, host, port, pathname, search, and hash fields. */
|
|
3
3
|
export declare const Url: S.Struct<{
|
|
4
|
-
protocol:
|
|
5
|
-
host:
|
|
6
|
-
port: S.
|
|
7
|
-
pathname:
|
|
8
|
-
search: S.
|
|
9
|
-
hash: S.
|
|
4
|
+
readonly protocol: S.String;
|
|
5
|
+
readonly host: S.String;
|
|
6
|
+
readonly port: S.Option<S.String>;
|
|
7
|
+
readonly pathname: S.String;
|
|
8
|
+
readonly search: S.Option<S.String>;
|
|
9
|
+
readonly hash: S.Option<S.String>;
|
|
10
10
|
}>;
|
|
11
11
|
export type Url = typeof Url.Type;
|
|
12
12
|
/** Parses a URL string into a `Url`, returning `Option.None` if invalid. */
|
|
13
13
|
export declare const fromString: (str: string) => Option.Option<{
|
|
14
14
|
readonly search: Option.Option<string>;
|
|
15
|
+
readonly port: Option.Option<string>;
|
|
16
|
+
readonly hash: Option.Option<string>;
|
|
15
17
|
readonly protocol: string;
|
|
16
18
|
readonly host: string;
|
|
17
|
-
readonly port: Option.Option<string>;
|
|
18
19
|
readonly pathname: string;
|
|
19
|
-
readonly hash: Option.Option<string>;
|
|
20
20
|
}>;
|
|
21
21
|
/** Serializes a `Url` back to a string. */
|
|
22
22
|
export declare const toString: (url: Url) => string;
|
package/dist/url/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/url/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/url/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EACN,MAAM,IAAI,CAAC,EAIZ,MAAM,QAAQ,CAAA;AAIf,qGAAqG;AACrG,eAAO,MAAM,GAAG;;;;;;;EAOd,CAAA;AACF,MAAM,MAAM,GAAG,GAAG,OAAO,GAAG,CAAC,IAAI,CAAA;AAwFjC,4EAA4E;AAC5E,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM;;;;;;;EAAuC,CAAA;AAC7E,2CAA2C;AAC3C,eAAO,MAAM,QAAQ,GAAI,KAAK,GAAG,WAAqC,CAAA"}
|
package/dist/url/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Effect, Option,
|
|
1
|
+
import { Effect, Option, Schema as S, SchemaIssue, SchemaTransformation, String, } from 'effect';
|
|
2
2
|
import { OptionExt } from '../effectExtensions/index.js';
|
|
3
3
|
/** Schema representing a parsed URL with protocol, host, port, pathname, search, and hash fields. */
|
|
4
4
|
export const Url = S.Struct({
|
|
5
5
|
protocol: S.String,
|
|
6
6
|
host: S.String,
|
|
7
|
-
port: S.
|
|
7
|
+
port: S.Option(S.String),
|
|
8
8
|
pathname: S.String,
|
|
9
|
-
search: S.
|
|
10
|
-
hash: S.
|
|
9
|
+
search: S.Option(S.String),
|
|
10
|
+
hash: S.Option(S.String),
|
|
11
11
|
});
|
|
12
12
|
const LocationAndHref = S.Struct({
|
|
13
13
|
href: S.String,
|
|
@@ -17,9 +17,8 @@ const LocationAndHref = S.Struct({
|
|
|
17
17
|
port: S.String,
|
|
18
18
|
}),
|
|
19
19
|
});
|
|
20
|
-
const LocationAndHrefFromString = S.
|
|
21
|
-
|
|
22
|
-
decode: (urlString, _options, ast) => Effect.try({
|
|
20
|
+
const LocationAndHrefFromString = S.String.pipe(S.decodeTo(LocationAndHref, SchemaTransformation.transformOrFail({
|
|
21
|
+
decode: urlString => Effect.try({
|
|
23
22
|
try: () => {
|
|
24
23
|
const url = new URL(urlString);
|
|
25
24
|
return {
|
|
@@ -31,15 +30,16 @@ const LocationAndHrefFromString = S.transformOrFail(S.String, LocationAndHref, {
|
|
|
31
30
|
},
|
|
32
31
|
};
|
|
33
32
|
},
|
|
34
|
-
catch:
|
|
33
|
+
catch: () => new SchemaIssue.InvalidValue(Option.some(urlString), {
|
|
34
|
+
description: `Invalid URL: ${urlString}`,
|
|
35
|
+
}),
|
|
35
36
|
}),
|
|
36
37
|
encode: ({ href, location }) => {
|
|
37
38
|
const portString = location.port ? `:${location.port}` : '';
|
|
38
|
-
return
|
|
39
|
+
return Effect.succeed(`${location.protocol}//${location.host}${portString}${href}`);
|
|
39
40
|
},
|
|
40
|
-
});
|
|
41
|
-
const UrlFromLocationAndHref = S.
|
|
42
|
-
strict: true,
|
|
41
|
+
})));
|
|
42
|
+
const UrlFromLocationAndHref = LocationAndHref.pipe(S.decodeTo(Url, SchemaTransformation.transform({
|
|
43
43
|
decode: ({ href, location }) => {
|
|
44
44
|
const [pathAndQuery, hashPart] = String.split(href, '#');
|
|
45
45
|
const [pathname, searchPart] = String.split(pathAndQuery, '?');
|
|
@@ -71,8 +71,8 @@ const UrlFromLocationAndHref = S.transform(LocationAndHref, Url, {
|
|
|
71
71
|
},
|
|
72
72
|
};
|
|
73
73
|
},
|
|
74
|
-
});
|
|
75
|
-
const UrlFromString = S.
|
|
74
|
+
})));
|
|
75
|
+
const UrlFromString = LocationAndHrefFromString.pipe(S.decodeTo(UrlFromLocationAndHref));
|
|
76
76
|
/** Parses a URL string into a `Url`, returning `Option.None` if invalid. */
|
|
77
77
|
export const fromString = (str) => S.decodeOption(UrlFromString)(str);
|
|
78
78
|
/** Serializes a `Url` back to a string. */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foldkit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "A frontend framework
|
|
3
|
+
"version": "0.82.1",
|
|
4
|
+
"description": "A TypeScript frontend framework, built on Effect and architected like Elm",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -47,6 +47,10 @@
|
|
|
47
47
|
"types": "./dist/runtime/public.d.ts",
|
|
48
48
|
"import": "./dist/runtime/public.js"
|
|
49
49
|
},
|
|
50
|
+
"./hmr-protocol": {
|
|
51
|
+
"types": "./dist/runtime/hmrProtocolPublic.d.ts",
|
|
52
|
+
"import": "./dist/runtime/hmrProtocolPublic.js"
|
|
53
|
+
},
|
|
50
54
|
"./fieldValidation": {
|
|
51
55
|
"types": "./dist/fieldValidation/public.d.ts",
|
|
52
56
|
"import": "./dist/fieldValidation/public.js"
|
|
@@ -180,14 +184,14 @@
|
|
|
180
184
|
"dist"
|
|
181
185
|
],
|
|
182
186
|
"peerDependencies": {
|
|
183
|
-
"@effect/platform-browser": "
|
|
184
|
-
"effect": "
|
|
187
|
+
"@effect/platform-browser": "4.0.0-beta.59",
|
|
188
|
+
"effect": "4.0.0-beta.59"
|
|
185
189
|
},
|
|
186
190
|
"devDependencies": {
|
|
187
|
-
"@effect/platform-browser": "
|
|
188
|
-
"@effect/vitest": "
|
|
189
|
-
"effect": "
|
|
190
|
-
"happy-dom": "^
|
|
191
|
+
"@effect/platform-browser": "4.0.0-beta.59",
|
|
192
|
+
"@effect/vitest": "4.0.0-beta.59",
|
|
193
|
+
"effect": "4.0.0-beta.59",
|
|
194
|
+
"happy-dom": "^20.0.0",
|
|
191
195
|
"typescript": "^6.0.2",
|
|
192
196
|
"vitest": "^3.2.4"
|
|
193
197
|
},
|