@krak-stack/registry 0.11.1 → 0.11.2
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 +6 -0
- package/dist/components/agent/react.js +29 -183
- package/dist/components/animated-list/react.js +16 -168
- package/dist/components/animated-number/react.js +8 -162
- package/dist/components/async-action-button/react.js +10 -164
- package/dist/components/audit-log-table/react.js +59 -213
- package/dist/components/code-block/react.js +10 -164
- package/dist/components/copy-button/react.js +10 -164
- package/dist/components/copy-value/html.js +4 -4
- package/dist/components/copy-value/react.js +20 -172
- package/dist/components/danger-confirmation/react.js +13 -167
- package/dist/components/data-table/react.js +59 -213
- package/dist/components/editable-text/react.js +14 -168
- package/dist/components/email-composer/react.js +25 -174
- package/dist/components/email-editor/react.js +34 -186
- package/dist/components/error-component/react.js +15 -169
- package/dist/components/icon-input/react.js +7 -161
- package/dist/components/image-crop-editor/react.js +19 -173
- package/dist/components/markdown/react.js +10 -164
- package/dist/components/presence-transition/react.js +9 -163
- package/dist/components/registry-previews/component-example.js +10 -164
- package/dist/components/rich-text-editor/react.js +9 -161
- package/dist/components/search-menu/react.js +11 -165
- package/dist/components/sidebar-layout/react.js +3 -157
- package/dist/components/support/react.js +14 -168
- package/dist/components/timezone-input/react.js +9 -163
- package/dist/components/webhook-delivery-table/react.js +74 -226
- package/dist/lib/docs.integrations.server.js +16 -35
- package/dist/lib/docs.js +31 -183
- package/dist/lib/docs.server.js +16 -35
- package/dist/lib/documentation-toolkit.js +19 -38
- package/dist/lib/effect-ui-adapter/use-model.js +158 -0
- package/dist/services/agent/client/index.js +29 -183
- package/package.json +5 -1
|
@@ -4,8 +4,8 @@ import { Popover } from "@base-ui/react/popover";
|
|
|
4
4
|
import {
|
|
5
5
|
useId as useId3,
|
|
6
6
|
useMemo,
|
|
7
|
-
useRef as
|
|
8
|
-
useState as
|
|
7
|
+
useRef as useRef3,
|
|
8
|
+
useState as useState4
|
|
9
9
|
} from "react";
|
|
10
10
|
import {
|
|
11
11
|
Type,
|
|
@@ -242,14 +242,14 @@ function PopoverTitle({ className, ...props }) {
|
|
|
242
242
|
|
|
243
243
|
// ../../src/components/animated-list/react.tsx
|
|
244
244
|
import {
|
|
245
|
-
useEffect as
|
|
245
|
+
useEffect as useEffect2,
|
|
246
246
|
useEffectEvent as useEffectEvent2,
|
|
247
247
|
useId,
|
|
248
|
-
useRef as
|
|
249
|
-
useState as
|
|
248
|
+
useRef as useRef2,
|
|
249
|
+
useState as useState2
|
|
250
250
|
} from "react";
|
|
251
251
|
import { GripVertical } from "lucide-react";
|
|
252
|
-
import { Component as Component2, View
|
|
252
|
+
import { Component as Component2, View } from "effect/ui";
|
|
253
253
|
import { cn as cn2 } from "cn";
|
|
254
254
|
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider/react";
|
|
255
255
|
|
|
@@ -450,160 +450,8 @@ var useVerticalDrag = ({
|
|
|
450
450
|
};
|
|
451
451
|
};
|
|
452
452
|
|
|
453
|
-
// ../../src/
|
|
454
|
-
import {
|
|
455
|
-
import {
|
|
456
|
-
createContext,
|
|
457
|
-
useCallback,
|
|
458
|
-
useContext,
|
|
459
|
-
useEffect as useEffect2,
|
|
460
|
-
useLayoutEffect as useLayoutEffect2,
|
|
461
|
-
useRef as useRef2,
|
|
462
|
-
useState as useState2,
|
|
463
|
-
useSyncExternalStore as useSyncExternalStore2
|
|
464
|
-
} from "react";
|
|
465
|
-
|
|
466
|
-
// ../../src/lib/effect-ui-adapter/model-runtime.ts
|
|
467
|
-
import { MessageLog, Renderer, View } from "effect/ui";
|
|
468
|
-
import { BrowserHost, Html } from "effect/ui/html";
|
|
469
|
-
import { Cause, Effect, Fiber } from "effect";
|
|
470
|
-
var node = () => ({ children: [] });
|
|
471
|
-
var modelHost = (commit) => {
|
|
472
|
-
const remove = (child) => {
|
|
473
|
-
if (!child.parent)
|
|
474
|
-
return;
|
|
475
|
-
child.parent.children.splice(child.parent.children.indexOf(child), 1);
|
|
476
|
-
delete child.parent;
|
|
477
|
-
};
|
|
478
|
-
return {
|
|
479
|
-
createElement: node,
|
|
480
|
-
createText: node,
|
|
481
|
-
setText: () => {},
|
|
482
|
-
setAttr: () => {},
|
|
483
|
-
setProp: () => {},
|
|
484
|
-
setEvents: () => {},
|
|
485
|
-
insertBefore: (parent, child, before) => {
|
|
486
|
-
if (child === before)
|
|
487
|
-
return;
|
|
488
|
-
remove(child);
|
|
489
|
-
const index = before ? parent.children.indexOf(before) : parent.children.length;
|
|
490
|
-
parent.children.splice(index, 0, child);
|
|
491
|
-
child.parent = parent;
|
|
492
|
-
},
|
|
493
|
-
remove,
|
|
494
|
-
parentOf: (child) => child.parent,
|
|
495
|
-
nextOf: (child) => child.parent?.children[child.parent.children.indexOf(child) + 1],
|
|
496
|
-
elements: ["html"],
|
|
497
|
-
controlled: new Set,
|
|
498
|
-
runsMounts: false,
|
|
499
|
-
commit
|
|
500
|
-
};
|
|
501
|
-
};
|
|
502
|
-
var mountModel = (component, props, publishSnapshot, messageLog, onEmit) => {
|
|
503
|
-
let currentProps = props;
|
|
504
|
-
let root;
|
|
505
|
-
let active = true;
|
|
506
|
-
let failure;
|
|
507
|
-
const publish = () => {
|
|
508
|
-
if (!active)
|
|
509
|
-
return;
|
|
510
|
-
if (failure) {
|
|
511
|
-
publishSnapshot({ error: failure });
|
|
512
|
-
return;
|
|
513
|
-
}
|
|
514
|
-
const current = root?.model();
|
|
515
|
-
if (current !== undefined)
|
|
516
|
-
publishSnapshot({ model: current });
|
|
517
|
-
};
|
|
518
|
-
const fiber = Effect.runFork(Effect.scoped(Effect.gen(function* () {
|
|
519
|
-
const mounted = yield* Renderer.mount(component, Effect.succeed(props), node(), {
|
|
520
|
-
head: false,
|
|
521
|
-
onEmit,
|
|
522
|
-
fallback: ({ cause }) => {
|
|
523
|
-
failure = new Error("Effect UI root failed", {
|
|
524
|
-
cause: Cause.squash(cause)
|
|
525
|
-
});
|
|
526
|
-
return View.text("");
|
|
527
|
-
}
|
|
528
|
-
});
|
|
529
|
-
if (!active)
|
|
530
|
-
return;
|
|
531
|
-
root = mounted;
|
|
532
|
-
if (props !== currentProps)
|
|
533
|
-
mounted.setProps(currentProps);
|
|
534
|
-
publish();
|
|
535
|
-
return yield* Effect.never;
|
|
536
|
-
}).pipe(Effect.provide(Renderer.layer(modelHost(publish))), Effect.provideService(Html.Host, BrowserHost.htmlHost), Effect.provideService(MessageLog.MessageLog, messageLog))));
|
|
537
|
-
return {
|
|
538
|
-
send: (message) => {
|
|
539
|
-
root?.send(message);
|
|
540
|
-
publish();
|
|
541
|
-
},
|
|
542
|
-
setProps: (next) => {
|
|
543
|
-
currentProps = next;
|
|
544
|
-
root?.setProps(next);
|
|
545
|
-
},
|
|
546
|
-
dispose: () => {
|
|
547
|
-
active = false;
|
|
548
|
-
root = undefined;
|
|
549
|
-
Effect.runFork(Fiber.interrupt(fiber));
|
|
550
|
-
}
|
|
551
|
-
};
|
|
552
|
-
};
|
|
553
|
-
|
|
554
|
-
// ../../src/lib/effect-ui-adapter/use-model.ts
|
|
555
|
-
"use client";
|
|
556
|
-
var ModelMessageLogContext = createContext(undefined);
|
|
557
|
-
var useModel = (component, props, options = {}) => {
|
|
558
|
-
const contextLog = useContext(ModelMessageLogContext);
|
|
559
|
-
const messageLog = options.messageLog ?? (contextLog === undefined ? MessageLog2.noop : contextLog);
|
|
560
|
-
const [store] = useState2(() => {
|
|
561
|
-
const initial = { model: component.init(props).model };
|
|
562
|
-
let snapshot = initial;
|
|
563
|
-
const listeners = new Set;
|
|
564
|
-
return {
|
|
565
|
-
subscribe: (listener) => {
|
|
566
|
-
listeners.add(listener);
|
|
567
|
-
return () => {
|
|
568
|
-
listeners.delete(listener);
|
|
569
|
-
};
|
|
570
|
-
},
|
|
571
|
-
getSnapshot: () => snapshot,
|
|
572
|
-
getServerSnapshot: () => initial,
|
|
573
|
-
publish: (next) => {
|
|
574
|
-
if ("model" in snapshot && "model" in next && Object.is(snapshot.model, next.model))
|
|
575
|
-
return;
|
|
576
|
-
if ("error" in snapshot && "error" in next && snapshot.error === next.error)
|
|
577
|
-
return;
|
|
578
|
-
snapshot = next;
|
|
579
|
-
listeners.forEach((listener) => listener());
|
|
580
|
-
}
|
|
581
|
-
};
|
|
582
|
-
});
|
|
583
|
-
const snapshot = useSyncExternalStore2(store.subscribe, store.getSnapshot, store.getServerSnapshot);
|
|
584
|
-
const committed = useRef2(props);
|
|
585
|
-
const onEmit = useRef2(options.onEmit);
|
|
586
|
-
const runtime = useRef2(undefined);
|
|
587
|
-
const send = useCallback((message) => runtime.current?.send(message), []);
|
|
588
|
-
useLayoutEffect2(() => {
|
|
589
|
-
onEmit.current = options.onEmit;
|
|
590
|
-
committed.current = props;
|
|
591
|
-
runtime.current?.setProps(props);
|
|
592
|
-
}, [props, options.onEmit]);
|
|
593
|
-
useEffect2(() => {
|
|
594
|
-
if (messageLog === null)
|
|
595
|
-
return;
|
|
596
|
-
const mounted = mountModel(component, committed.current, store.publish, messageLog, (event) => onEmit.current?.(event));
|
|
597
|
-
runtime.current = mounted;
|
|
598
|
-
return () => {
|
|
599
|
-
runtime.current = undefined;
|
|
600
|
-
mounted.dispose();
|
|
601
|
-
};
|
|
602
|
-
}, [component, messageLog, store]);
|
|
603
|
-
if ("error" in snapshot)
|
|
604
|
-
throw snapshot.error;
|
|
605
|
-
return { model: snapshot.model, send };
|
|
606
|
-
};
|
|
453
|
+
// ../../src/components/animated-list/react.tsx
|
|
454
|
+
import { useModel } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
607
455
|
|
|
608
456
|
// ../../src/components/animated-list/classes.ts
|
|
609
457
|
var animatedListClasses = {
|
|
@@ -758,7 +606,7 @@ var animatedListBehaviours = {
|
|
|
758
606
|
import { jsx as jsx5, jsxs as jsxs2, Fragment } from "react/jsx-runtime";
|
|
759
607
|
var Model = Component2.define(animatedListOptions).make({
|
|
760
608
|
...animatedListBehaviours,
|
|
761
|
-
view: () =>
|
|
609
|
+
view: () => View.text("")
|
|
762
610
|
});
|
|
763
611
|
var AnimatedList = ({
|
|
764
612
|
classes: classOverrides,
|
|
@@ -779,7 +627,7 @@ var AnimatedList = ({
|
|
|
779
627
|
const locale = useKrakstackLocale(override);
|
|
780
628
|
const copy = animatedListCopy(locale, messages);
|
|
781
629
|
const instructions = useId();
|
|
782
|
-
const container =
|
|
630
|
+
const container = useRef2(null);
|
|
783
631
|
const descriptors = items.map((item) => ({
|
|
784
632
|
key: getKey(item),
|
|
785
633
|
label: getItemLabel?.(item)
|
|
@@ -790,7 +638,7 @@ var AnimatedList = ({
|
|
|
790
638
|
});
|
|
791
639
|
const retained = retainedRows(descriptors, model.rows);
|
|
792
640
|
const current = new Map(items.map((item) => [getKey(item), { item }]));
|
|
793
|
-
const [previous, setPrevious] =
|
|
641
|
+
const [previous, setPrevious] = useState2(() => ({
|
|
794
642
|
items,
|
|
795
643
|
rows: model.rows,
|
|
796
644
|
rendered: current
|
|
@@ -802,8 +650,8 @@ var AnimatedList = ({
|
|
|
802
650
|
if (previous.items !== items || previous.rows !== model.rows) {
|
|
803
651
|
setPrevious({ items, rows: model.rows, rendered });
|
|
804
652
|
}
|
|
805
|
-
const committed =
|
|
806
|
-
|
|
653
|
+
const committed = useRef2(false);
|
|
654
|
+
useEffect2(() => {
|
|
807
655
|
committed.current = true;
|
|
808
656
|
}, []);
|
|
809
657
|
useListLayout(container, duration);
|
|
@@ -885,10 +733,10 @@ var ListItem = ({
|
|
|
885
733
|
onKeyMove,
|
|
886
734
|
children
|
|
887
735
|
}) => {
|
|
888
|
-
const ref =
|
|
889
|
-
const mounted =
|
|
890
|
-
const lastPresent =
|
|
891
|
-
const transitioning =
|
|
736
|
+
const ref = useRef2(null);
|
|
737
|
+
const mounted = useRef2(false);
|
|
738
|
+
const lastPresent = useRef2(present);
|
|
739
|
+
const transitioning = useRef2(false);
|
|
892
740
|
const exit = useEffectEvent2(onExit);
|
|
893
741
|
const reduced = useReducedMotion();
|
|
894
742
|
const drag = useVerticalDrag({
|
|
@@ -898,7 +746,7 @@ var ListItem = ({
|
|
|
898
746
|
overflow: dragOverflow,
|
|
899
747
|
onMove
|
|
900
748
|
});
|
|
901
|
-
|
|
749
|
+
useEffect2(() => {
|
|
902
750
|
const element = ref.current;
|
|
903
751
|
const first = !mounted.current;
|
|
904
752
|
mounted.current = true;
|
|
@@ -954,10 +802,10 @@ import { EditorContent, useEditor } from "@tiptap/react";
|
|
|
954
802
|
import { EditorState } from "@tiptap/pm/state";
|
|
955
803
|
import { closeHistory } from "@tiptap/pm/history";
|
|
956
804
|
import {
|
|
957
|
-
useEffect as
|
|
805
|
+
useEffect as useEffect3,
|
|
958
806
|
useEffectEvent as useEffectEvent3,
|
|
959
807
|
useId as useId2,
|
|
960
|
-
useState as
|
|
808
|
+
useState as useState3
|
|
961
809
|
} from "react";
|
|
962
810
|
import {
|
|
963
811
|
Bold,
|
|
@@ -1393,11 +1241,11 @@ var RichTextEditor = ({
|
|
|
1393
1241
|
...messages?.[locale.split("-")[0] ?? locale],
|
|
1394
1242
|
...messages?.[locale]
|
|
1395
1243
|
};
|
|
1396
|
-
const [error, setError] =
|
|
1397
|
-
const [linkOpen, setLinkOpen] =
|
|
1398
|
-
const [link, setLink] =
|
|
1399
|
-
const [linkError, setLinkError] =
|
|
1400
|
-
const [revision, setRevision] =
|
|
1244
|
+
const [error, setError] = useState3(false);
|
|
1245
|
+
const [linkOpen, setLinkOpen] = useState3(false);
|
|
1246
|
+
const [link, setLink] = useState3("");
|
|
1247
|
+
const [linkError, setLinkError] = useState3(false);
|
|
1248
|
+
const [revision, setRevision] = useState3(0);
|
|
1401
1249
|
const id = useId2();
|
|
1402
1250
|
const getMaxLength = useEffectEvent3(() => maxLength);
|
|
1403
1251
|
const getVariables = useEffectEvent3(() => variables);
|
|
@@ -1491,7 +1339,7 @@ var RichTextEditor = ({
|
|
|
1491
1339
|
editor.chain().insertContent({ type: "variable", attrs: { key } }).run();
|
|
1492
1340
|
editor.view.dispatch(closeHistory(editor.state.tr));
|
|
1493
1341
|
};
|
|
1494
|
-
|
|
1342
|
+
useEffect3(() => {
|
|
1495
1343
|
if (!editor)
|
|
1496
1344
|
return;
|
|
1497
1345
|
const incoming = editor.schema.nodeFromJSON(toTiptapDocument(value, singleLine));
|
|
@@ -1504,12 +1352,12 @@ var RichTextEditor = ({
|
|
|
1504
1352
|
editor.view.dispatch(editor.state.tr.setMeta(externalReplacementMeta, true));
|
|
1505
1353
|
}
|
|
1506
1354
|
}, [editor, value, singleLine]);
|
|
1507
|
-
|
|
1355
|
+
useEffect3(() => {
|
|
1508
1356
|
if (!editor)
|
|
1509
1357
|
return;
|
|
1510
1358
|
editor.setEditable(!disabled, false);
|
|
1511
1359
|
}, [editor, disabled]);
|
|
1512
|
-
|
|
1360
|
+
useEffect3(() => {
|
|
1513
1361
|
if (!editor)
|
|
1514
1362
|
return;
|
|
1515
1363
|
for (const chip of editor.view.dom.querySelectorAll("[data-rich-variable]")) {
|
|
@@ -2395,12 +2243,12 @@ var EmailEditor = ({
|
|
|
2395
2243
|
const emailEditorClasses = resolveEmailEditorClasses(classOverrides);
|
|
2396
2244
|
const locale = useKrakstackLocale3(override);
|
|
2397
2245
|
const copy = emailEditorMessages(locale, messages);
|
|
2398
|
-
const [active, setActive] =
|
|
2246
|
+
const [active, setActive] = useState4(() => initialActive(value));
|
|
2399
2247
|
const selected = value.elements.find((element) => element.id === active);
|
|
2400
|
-
const [view, setView] =
|
|
2401
|
-
const canvas =
|
|
2402
|
-
const elementSurfaces =
|
|
2403
|
-
const [settingsOpen, setSettingsOpen] =
|
|
2248
|
+
const [view, setView] = useState4("design");
|
|
2249
|
+
const canvas = useRef3(null);
|
|
2250
|
+
const elementSurfaces = useRef3(new Map);
|
|
2251
|
+
const [settingsOpen, setSettingsOpen] = useState4(false);
|
|
2404
2252
|
const settingsAnchor = useMemo(() => settingsOpen ? {
|
|
2405
2253
|
get contextElement() {
|
|
2406
2254
|
return canvas.current ?? undefined;
|
|
@@ -2412,7 +2260,7 @@ var EmailEditor = ({
|
|
|
2412
2260
|
}
|
|
2413
2261
|
} : null, [active, settingsOpen]);
|
|
2414
2262
|
const id = useId3();
|
|
2415
|
-
const [insertOpen, setInsertOpen] =
|
|
2263
|
+
const [insertOpen, setInsertOpen] = useState4(false);
|
|
2416
2264
|
const update = (element) => {
|
|
2417
2265
|
if (!disabled)
|
|
2418
2266
|
onChange(replaceElement(value, element));
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
useRouterState
|
|
5
5
|
} from "@tanstack/react-router";
|
|
6
6
|
import { CircleAlert, RefreshCw } from "lucide-react";
|
|
7
|
-
import { useState as
|
|
7
|
+
import { useState as useState2 } from "react";
|
|
8
8
|
import { Option, Schema as Schema5 } from "effect";
|
|
9
9
|
import { HttpClientError, HttpTraceContext } from "effect/http";
|
|
10
10
|
|
|
@@ -60,167 +60,13 @@ function Button({
|
|
|
60
60
|
import { Check, Copy, TriangleAlert } from "lucide-react";
|
|
61
61
|
import { Redacted as Redacted2 } from "effect";
|
|
62
62
|
import { Component as Component2 } from "effect/ui";
|
|
63
|
-
import { useLayoutEffect
|
|
63
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
64
64
|
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider/react";
|
|
65
|
-
|
|
66
|
-
// ../../src/lib/effect-ui-adapter/use-model.ts
|
|
67
|
-
import { MessageLog as MessageLog2 } from "effect/ui";
|
|
68
|
-
import {
|
|
69
|
-
createContext,
|
|
70
|
-
useCallback,
|
|
71
|
-
useContext,
|
|
72
|
-
useEffect,
|
|
73
|
-
useLayoutEffect,
|
|
74
|
-
useRef,
|
|
75
|
-
useState,
|
|
76
|
-
useSyncExternalStore
|
|
77
|
-
} from "react";
|
|
78
|
-
|
|
79
|
-
// ../../src/lib/effect-ui-adapter/model-runtime.ts
|
|
80
|
-
import { MessageLog, Renderer, View } from "effect/ui";
|
|
81
|
-
import { BrowserHost, Html } from "effect/ui/html";
|
|
82
|
-
import { Cause, Effect, Fiber } from "effect";
|
|
83
|
-
var node = () => ({ children: [] });
|
|
84
|
-
var modelHost = (commit) => {
|
|
85
|
-
const remove = (child) => {
|
|
86
|
-
if (!child.parent)
|
|
87
|
-
return;
|
|
88
|
-
child.parent.children.splice(child.parent.children.indexOf(child), 1);
|
|
89
|
-
delete child.parent;
|
|
90
|
-
};
|
|
91
|
-
return {
|
|
92
|
-
createElement: node,
|
|
93
|
-
createText: node,
|
|
94
|
-
setText: () => {},
|
|
95
|
-
setAttr: () => {},
|
|
96
|
-
setProp: () => {},
|
|
97
|
-
setEvents: () => {},
|
|
98
|
-
insertBefore: (parent, child, before) => {
|
|
99
|
-
if (child === before)
|
|
100
|
-
return;
|
|
101
|
-
remove(child);
|
|
102
|
-
const index = before ? parent.children.indexOf(before) : parent.children.length;
|
|
103
|
-
parent.children.splice(index, 0, child);
|
|
104
|
-
child.parent = parent;
|
|
105
|
-
},
|
|
106
|
-
remove,
|
|
107
|
-
parentOf: (child) => child.parent,
|
|
108
|
-
nextOf: (child) => child.parent?.children[child.parent.children.indexOf(child) + 1],
|
|
109
|
-
elements: ["html"],
|
|
110
|
-
controlled: new Set,
|
|
111
|
-
runsMounts: false,
|
|
112
|
-
commit
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
var mountModel = (component, props, publishSnapshot, messageLog, onEmit) => {
|
|
116
|
-
let currentProps = props;
|
|
117
|
-
let root;
|
|
118
|
-
let active = true;
|
|
119
|
-
let failure;
|
|
120
|
-
const publish = () => {
|
|
121
|
-
if (!active)
|
|
122
|
-
return;
|
|
123
|
-
if (failure) {
|
|
124
|
-
publishSnapshot({ error: failure });
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
const current = root?.model();
|
|
128
|
-
if (current !== undefined)
|
|
129
|
-
publishSnapshot({ model: current });
|
|
130
|
-
};
|
|
131
|
-
const fiber = Effect.runFork(Effect.scoped(Effect.gen(function* () {
|
|
132
|
-
const mounted = yield* Renderer.mount(component, Effect.succeed(props), node(), {
|
|
133
|
-
head: false,
|
|
134
|
-
onEmit,
|
|
135
|
-
fallback: ({ cause }) => {
|
|
136
|
-
failure = new Error("Effect UI root failed", {
|
|
137
|
-
cause: Cause.squash(cause)
|
|
138
|
-
});
|
|
139
|
-
return View.text("");
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
if (!active)
|
|
143
|
-
return;
|
|
144
|
-
root = mounted;
|
|
145
|
-
if (props !== currentProps)
|
|
146
|
-
mounted.setProps(currentProps);
|
|
147
|
-
publish();
|
|
148
|
-
return yield* Effect.never;
|
|
149
|
-
}).pipe(Effect.provide(Renderer.layer(modelHost(publish))), Effect.provideService(Html.Host, BrowserHost.htmlHost), Effect.provideService(MessageLog.MessageLog, messageLog))));
|
|
150
|
-
return {
|
|
151
|
-
send: (message) => {
|
|
152
|
-
root?.send(message);
|
|
153
|
-
publish();
|
|
154
|
-
},
|
|
155
|
-
setProps: (next) => {
|
|
156
|
-
currentProps = next;
|
|
157
|
-
root?.setProps(next);
|
|
158
|
-
},
|
|
159
|
-
dispose: () => {
|
|
160
|
-
active = false;
|
|
161
|
-
root = undefined;
|
|
162
|
-
Effect.runFork(Fiber.interrupt(fiber));
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
// ../../src/lib/effect-ui-adapter/use-model.ts
|
|
168
|
-
"use client";
|
|
169
|
-
var ModelMessageLogContext = createContext(undefined);
|
|
170
|
-
var useModel = (component, props, options = {}) => {
|
|
171
|
-
const contextLog = useContext(ModelMessageLogContext);
|
|
172
|
-
const messageLog = options.messageLog ?? (contextLog === undefined ? MessageLog2.noop : contextLog);
|
|
173
|
-
const [store] = useState(() => {
|
|
174
|
-
const initial = { model: component.init(props).model };
|
|
175
|
-
let snapshot = initial;
|
|
176
|
-
const listeners = new Set;
|
|
177
|
-
return {
|
|
178
|
-
subscribe: (listener) => {
|
|
179
|
-
listeners.add(listener);
|
|
180
|
-
return () => {
|
|
181
|
-
listeners.delete(listener);
|
|
182
|
-
};
|
|
183
|
-
},
|
|
184
|
-
getSnapshot: () => snapshot,
|
|
185
|
-
getServerSnapshot: () => initial,
|
|
186
|
-
publish: (next) => {
|
|
187
|
-
if ("model" in snapshot && "model" in next && Object.is(snapshot.model, next.model))
|
|
188
|
-
return;
|
|
189
|
-
if ("error" in snapshot && "error" in next && snapshot.error === next.error)
|
|
190
|
-
return;
|
|
191
|
-
snapshot = next;
|
|
192
|
-
listeners.forEach((listener) => listener());
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
});
|
|
196
|
-
const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);
|
|
197
|
-
const committed = useRef(props);
|
|
198
|
-
const onEmit = useRef(options.onEmit);
|
|
199
|
-
const runtime = useRef(undefined);
|
|
200
|
-
const send = useCallback((message) => runtime.current?.send(message), []);
|
|
201
|
-
useLayoutEffect(() => {
|
|
202
|
-
onEmit.current = options.onEmit;
|
|
203
|
-
committed.current = props;
|
|
204
|
-
runtime.current?.setProps(props);
|
|
205
|
-
}, [props, options.onEmit]);
|
|
206
|
-
useEffect(() => {
|
|
207
|
-
if (messageLog === null)
|
|
208
|
-
return;
|
|
209
|
-
const mounted = mountModel(component, committed.current, store.publish, messageLog, (event) => onEmit.current?.(event));
|
|
210
|
-
runtime.current = mounted;
|
|
211
|
-
return () => {
|
|
212
|
-
runtime.current = undefined;
|
|
213
|
-
mounted.dispose();
|
|
214
|
-
};
|
|
215
|
-
}, [component, messageLog, store]);
|
|
216
|
-
if ("error" in snapshot)
|
|
217
|
-
throw snapshot.error;
|
|
218
|
-
return { model: snapshot.model, send };
|
|
219
|
-
};
|
|
65
|
+
import { useModel } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
220
66
|
|
|
221
67
|
// ../../src/components/copy-button/index.ts
|
|
222
|
-
import { Effect
|
|
223
|
-
import { Command, Component, UiSchema, View
|
|
68
|
+
import { Effect, Redacted, Schema as Schema2 } from "effect";
|
|
69
|
+
import { Command, Component, UiSchema, View } from "effect/ui";
|
|
224
70
|
|
|
225
71
|
// ../../src/components/copy-button/schema.ts
|
|
226
72
|
import { Schema } from "effect";
|
|
@@ -275,13 +121,13 @@ class WriteClipboard extends Command.Service()("copy-button/WriteClipboard", {
|
|
|
275
121
|
},
|
|
276
122
|
success: CopyButtonMessage
|
|
277
123
|
}) {
|
|
278
|
-
static layerFromWrite = (write) => WriteClipboard.toLayer(({ value }) =>
|
|
124
|
+
static layerFromWrite = (write) => WriteClipboard.toLayer(({ value }) => Effect.tryPromise(() => write(Redacted.value(value))).pipe(Effect.match({
|
|
279
125
|
onSuccess: () => CopyButtonMessage.Finished({ success: true }),
|
|
280
126
|
onFailure: () => CopyButtonMessage.Finished({ success: false })
|
|
281
127
|
})));
|
|
282
128
|
static browser = WriteClipboard.layerFromWrite((value) => navigator.clipboard.writeText(value));
|
|
283
129
|
}
|
|
284
|
-
var ResetClipboardFeedback = Command.make("copy-button/ResetFeedback", { args: { delay: Schema2.Number }, mode: "switch" }, ({ delay }) =>
|
|
130
|
+
var ResetClipboardFeedback = Command.make("copy-button/ResetFeedback", { args: { delay: Schema2.Number }, mode: "switch" }, ({ delay }) => Effect.sleep(Math.max(0, delay)).pipe(Effect.as(CopyButtonMessage.Reset())));
|
|
285
131
|
var copyButtonOptions = {
|
|
286
132
|
name: "CopyButton",
|
|
287
133
|
props: CopyButtonModelProps,
|
|
@@ -303,7 +149,7 @@ var copyButtonBehaviours = {
|
|
|
303
149
|
};
|
|
304
150
|
var CopyButtonModel = Definition.make({
|
|
305
151
|
...copyButtonBehaviours,
|
|
306
|
-
view: () =>
|
|
152
|
+
view: () => View.text("")
|
|
307
153
|
});
|
|
308
154
|
var copyButtonStatus = (status, copy, description) => {
|
|
309
155
|
if (status === "idle")
|
|
@@ -331,19 +177,19 @@ function CopyButton({
|
|
|
331
177
|
}) {
|
|
332
178
|
const locale = useKrakstackLocale(localeOverride);
|
|
333
179
|
const labels = copyButtonMessages(locale, messages);
|
|
334
|
-
const callbacks =
|
|
180
|
+
const callbacks = useRef({
|
|
335
181
|
onCopied,
|
|
336
182
|
onCopyError,
|
|
337
183
|
failureLabel: labels.copyFailed
|
|
338
184
|
});
|
|
339
|
-
|
|
185
|
+
useLayoutEffect(() => {
|
|
340
186
|
callbacks.current = {
|
|
341
187
|
onCopied,
|
|
342
188
|
onCopyError,
|
|
343
189
|
failureLabel: labels.copyFailed
|
|
344
190
|
};
|
|
345
191
|
}, [onCopied, onCopyError, labels.copyFailed]);
|
|
346
|
-
const [component] =
|
|
192
|
+
const [component] = useState(() => CopyButtonModel.pipe(Component2.provide(WriteClipboard.layerFromWrite(async (text) => {
|
|
347
193
|
const { onCopied, onCopyError, failureLabel } = callbacks.current;
|
|
348
194
|
try {
|
|
349
195
|
await navigator.clipboard.writeText(text);
|
|
@@ -481,7 +327,7 @@ var resolveErrorComponentClasses = (overrides) => ({
|
|
|
481
327
|
});
|
|
482
328
|
|
|
483
329
|
// ../../src/components/error-component/index.ts
|
|
484
|
-
import { Effect as
|
|
330
|
+
import { Effect as Effect2, Redacted as Redacted3, Schema as Schema4 } from "effect";
|
|
485
331
|
import { Command as Command2, Component as Component3, UiSchema as UiSchema2 } from "effect/ui";
|
|
486
332
|
|
|
487
333
|
// ../../src/components/error-component/schema.ts
|
|
@@ -600,7 +446,7 @@ var ErrorComponentMessage = UiSchema2.TaggedEnum({
|
|
|
600
446
|
Copied: { report: Report, success: Schema4.Boolean }
|
|
601
447
|
});
|
|
602
448
|
var ErrorComponentEvents = UiSchema2.TaggedEnum({ Retry: {} });
|
|
603
|
-
var CopyReport = Command2.make("error-component/CopyReport", { args: { report: Report }, mode: "switch" }, ({ report }) =>
|
|
449
|
+
var CopyReport = Command2.make("error-component/CopyReport", { args: { report: Report }, mode: "switch" }, ({ report }) => Effect2.tryPromise(() => navigator.clipboard.writeText(Redacted3.value(report))).pipe(Effect2.match({
|
|
604
450
|
onSuccess: () => ErrorComponentMessage.Copied({ report, success: true }),
|
|
605
451
|
onFailure: () => ErrorComponentMessage.Copied({ report, success: false })
|
|
606
452
|
})));
|
|
@@ -658,13 +504,13 @@ var ErrorComponent = ({
|
|
|
658
504
|
const standardError = error instanceof Error ? error : undefined;
|
|
659
505
|
const errorMessage = standardError?.message.trim() || labels.description;
|
|
660
506
|
const reference = diagnostics?.reference ?? (standardError ? getErrorTraceId(standardError) : undefined);
|
|
661
|
-
const [reportedAt] =
|
|
507
|
+
const [reportedAt] = useState2(() => new Date().toISOString());
|
|
662
508
|
const report = errorComponentReport({
|
|
663
509
|
error: standardError,
|
|
664
510
|
pathname,
|
|
665
511
|
diagnostics: { ...diagnostics, reference }
|
|
666
512
|
}, labels, locale, reportedAt);
|
|
667
|
-
const [copyResult, setCopyResult] =
|
|
513
|
+
const [copyResult, setCopyResult] = useState2(null);
|
|
668
514
|
const copyStatus = copyResult?.report === report ? copyResult.status : undefined;
|
|
669
515
|
return /* @__PURE__ */ jsx5("main", {
|
|
670
516
|
className: cn("flex min-h-[60vh] items-center justify-center p-6", className),
|