@krak-stack/registry 0.11.1 → 0.11.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 (76) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +22 -0
  3. package/dist/components/agent/react.js +29 -183
  4. package/dist/components/animated-list/html.js +1 -105
  5. package/dist/components/animated-list/react.js +16 -168
  6. package/dist/components/animated-number/react.js +8 -162
  7. package/dist/components/app-switcher/html.js +1 -103
  8. package/dist/components/async-action-button/html.js +1 -101
  9. package/dist/components/async-action-button/react.js +10 -164
  10. package/dist/components/audit-log-table/react.js +59 -213
  11. package/dist/components/bulk-list-input/html.js +2 -102
  12. package/dist/components/choice-cards/html.js +1 -101
  13. package/dist/components/code-block/html.js +1 -101
  14. package/dist/components/code-block/react.js +10 -164
  15. package/dist/components/copy-button/html.d.ts +2 -2
  16. package/dist/components/copy-button/html.js +1 -101
  17. package/dist/components/copy-button/react.js +10 -164
  18. package/dist/components/copy-value/html.js +6 -105
  19. package/dist/components/copy-value/react.js +20 -172
  20. package/dist/components/danger-confirmation/react.js +13 -167
  21. package/dist/components/data-table/html.d.ts +51 -51
  22. package/dist/components/data-table/html.js +28 -101
  23. package/dist/components/data-table/react.js +59 -213
  24. package/dist/components/date-input/html.js +2 -105
  25. package/dist/components/editable-text/html.d.ts +2 -2
  26. package/dist/components/editable-text/html.js +4 -102
  27. package/dist/components/editable-text/react.js +14 -168
  28. package/dist/components/editing-locale-switcher/html.js +2 -102
  29. package/dist/components/email-composer/react.js +25 -174
  30. package/dist/components/email-editor/html.js +8 -107
  31. package/dist/components/email-editor/react.js +34 -186
  32. package/dist/components/error-component/html.d.ts +4 -4
  33. package/dist/components/error-component/html.js +10 -107
  34. package/dist/components/error-component/react.js +15 -169
  35. package/dist/components/file-input/html.js +6 -106
  36. package/dist/components/icon-input/html.js +3 -103
  37. package/dist/components/icon-input/react.js +7 -161
  38. package/dist/components/image-crop-editor/html.js +1 -101
  39. package/dist/components/image-crop-editor/react.js +19 -173
  40. package/dist/components/loading/html.js +1 -101
  41. package/dist/components/locale-switcher/html.js +1 -103
  42. package/dist/components/map-menu/html.d.ts +8 -8
  43. package/dist/components/map-menu/html.js +7 -106
  44. package/dist/components/markdown/html.js +1 -101
  45. package/dist/components/markdown/react.js +10 -164
  46. package/dist/components/notification-menu/html.js +7 -114
  47. package/dist/components/pagination/html.js +5 -100
  48. package/dist/components/presence-transition/react.js +9 -163
  49. package/dist/components/registry-previews/component-example.js +10 -164
  50. package/dist/components/rich-text-editor/html.js +14 -108
  51. package/dist/components/rich-text-editor/react.js +9 -161
  52. package/dist/components/search-menu/html.js +1 -103
  53. package/dist/components/search-menu/react.js +11 -165
  54. package/dist/components/sidebar-layout/html.js +2 -102
  55. package/dist/components/sidebar-layout/react.js +3 -157
  56. package/dist/components/stepper/html.js +4 -102
  57. package/dist/components/support/html.js +1 -101
  58. package/dist/components/support/react.js +14 -168
  59. package/dist/components/theme-switcher/html.js +4 -105
  60. package/dist/components/time-input/html.d.ts +2 -2
  61. package/dist/components/time-input/html.js +1 -103
  62. package/dist/components/timezone-input/react.js +9 -163
  63. package/dist/components/toast/html.js +11 -104
  64. package/dist/components/upload-attachment/html.d.ts +4 -4
  65. package/dist/components/upload-attachment/html.js +7 -102
  66. package/dist/components/webhook-delivery-table/html.js +28 -101
  67. package/dist/components/webhook-delivery-table/react.js +74 -226
  68. package/dist/lib/docs.integrations.server.js +16 -35
  69. package/dist/lib/docs.js +31 -183
  70. package/dist/lib/docs.server.js +16 -35
  71. package/dist/lib/documentation-toolkit.js +19 -38
  72. package/dist/lib/effect-ui-adapter/use-model.js +158 -0
  73. package/dist/lib/lucide-effect.d.ts +2432 -0
  74. package/dist/lib/lucide-effect.js +7428 -0
  75. package/dist/services/agent/client/index.js +29 -183
  76. package/package.json +10 -2
@@ -1,14 +1,6 @@
1
1
  // ../../src/components/notification-menu/html.ts
2
2
  import { Html } from "effect/ui/html";
3
3
  import { Popover, ScrollArea, makeTabs } from "effect/ui/kit";
4
- import {
5
- Archive,
6
- ArchiveRestore,
7
- Bell,
8
- BellDot,
9
- Inbox,
10
- TriangleAlert as TriangleAlert2
11
- } from "lucide";
12
4
 
13
5
  // ../../src/components/effectcn/button.ts
14
6
  import {
@@ -61,107 +53,14 @@ var ScrollAreaScrollbar = (h, area) => area.scrollbar({
61
53
 
62
54
  // ../../src/components/notification-menu/html.ts
63
55
  import { krakstackLocaleRead } from "@krak-stack/registry/krakstack-provider/html";
64
-
65
- // ../../src/lib/lucide-effect.ts
66
56
  import {
67
- ArrowDown as arrowDown,
68
- ArrowUp as arrowUp,
69
- ListFilter as listFilter,
70
- Check as check,
71
- ChevronLeft as chevronLeft,
72
- ChevronDown as chevronDown,
73
- ChevronRight as chevronRight,
74
- ChevronsLeft as chevronsLeft,
75
- ChevronsRight as chevronsRight,
76
- ChevronsUpDown as chevronsUpDown,
77
- Copy as copy,
78
- Download as download,
79
- Eye as eye,
80
- EyeOff as eyeOff,
81
- Ellipsis as ellipsis,
82
- FileJson as fileJson,
83
- FileText as fileText,
84
- GripVertical as gripVertical,
85
- Image as image,
86
- LayoutGrid as layoutGrid,
87
- LoaderCircle as loaderCircle,
88
- Mail as mail,
89
- Paperclip as paperclip,
90
- RefreshCw as refreshCw,
91
- RotateCcw as rotateCcw,
92
- Rows3 as rows3,
93
- Search as search,
94
- Settings2 as settings2,
95
- TriangleAlert as triangleAlert,
96
- X as x
97
- } from "lucide";
98
- var createLucideIcon = (icon) => (h, {
99
- size = 24,
100
- color = "currentColor",
101
- strokeWidth = 2,
102
- className
103
- } = {}) => h.svg.attrs({
104
- class: className,
105
- width: String(size),
106
- height: String(size),
107
- viewBox: "0 0 24 24",
108
- fill: "none",
109
- stroke: color,
110
- "stroke-width": String(strokeWidth),
111
- "stroke-linecap": "round",
112
- "stroke-linejoin": "round",
113
- "aria-hidden": "true"
114
- }).children(...icon.map(([tag, attributes]) => {
115
- const attrs = Object.fromEntries(Object.entries(attributes).flatMap(([name, value]) => value === undefined ? [] : [[name, String(value)]]));
116
- switch (tag) {
117
- case "path":
118
- return h.path.attrs(attrs);
119
- case "circle":
120
- return h.circle.attrs(attrs);
121
- case "ellipse":
122
- return h.ellipse.attrs(attrs);
123
- case "line":
124
- return h.line.attrs(attrs);
125
- case "polyline":
126
- return h.polyline.attrs(attrs);
127
- case "polygon":
128
- return h.polygon.attrs(attrs);
129
- case "rect":
130
- return h.rect.attrs(attrs);
131
- default:
132
- throw new Error(`Unsupported Lucide SVG element: ${tag}`);
133
- }
134
- }));
135
- var Check = createLucideIcon(check);
136
- var ArrowDown = createLucideIcon(arrowDown);
137
- var ArrowUp = createLucideIcon(arrowUp);
138
- var ListFilter = createLucideIcon(listFilter);
139
- var ChevronLeft = createLucideIcon(chevronLeft);
140
- var ChevronDown = createLucideIcon(chevronDown);
141
- var ChevronRight = createLucideIcon(chevronRight);
142
- var ChevronsLeft = createLucideIcon(chevronsLeft);
143
- var ChevronsRight = createLucideIcon(chevronsRight);
144
- var ChevronsUpDown = createLucideIcon(chevronsUpDown);
145
- var Copy = createLucideIcon(copy);
146
- var Download = createLucideIcon(download);
147
- var Eye = createLucideIcon(eye);
148
- var EyeOff = createLucideIcon(eyeOff);
149
- var Ellipsis = createLucideIcon(ellipsis);
150
- var FileJson = createLucideIcon(fileJson);
151
- var FileText = createLucideIcon(fileText);
152
- var GripVertical = createLucideIcon(gripVertical);
153
- var Image = createLucideIcon(image);
154
- var LayoutGrid = createLucideIcon(layoutGrid);
155
- var LoaderCircle = createLucideIcon(loaderCircle);
156
- var Mail = createLucideIcon(mail);
157
- var Paperclip = createLucideIcon(paperclip);
158
- var RefreshCw = createLucideIcon(refreshCw);
159
- var RotateCcw = createLucideIcon(rotateCcw);
160
- var Rows3 = createLucideIcon(rows3);
161
- var Search = createLucideIcon(search);
162
- var Settings2 = createLucideIcon(settings2);
163
- var TriangleAlert = createLucideIcon(triangleAlert);
164
- var X = createLucideIcon(x);
57
+ Archive as ArchiveIcon,
58
+ ArchiveRestore as ArchiveTabIcon,
59
+ Bell as BellIcon,
60
+ BellDot as BellDotIcon,
61
+ Inbox as InboxIcon,
62
+ TriangleAlert as AlertIcon
63
+ } from "@krak-stack/registry/lucide-effect";
165
64
 
166
65
  // ../../src/components/notification-menu/classes.ts
167
66
  var notificationMenuClasses = {
@@ -330,12 +229,6 @@ var notificationMenuBehaviours = {
330
229
  };
331
230
 
332
231
  // ../../src/components/notification-menu/html.ts
333
- var BellIcon = createLucideIcon(Bell);
334
- var BellDotIcon = createLucideIcon(BellDot);
335
- var ArchiveIcon = createLucideIcon(Archive);
336
- var InboxIcon = createLucideIcon(Inbox);
337
- var ArchiveTabIcon = createLucideIcon(ArchiveRestore);
338
- var AlertIcon = createLucideIcon(TriangleAlert2);
339
232
  var MenuTabs = makeTabs({ value: NotificationMenuTab });
340
233
  var tabClass = "relative z-10 inline-flex h-7 min-w-0 flex-1 cursor-pointer items-center justify-center gap-1.5 rounded-sm px-3 text-[13px] font-medium whitespace-nowrap text-muted-foreground outline-offset-0 select-none transition-colors duration-150 hover:text-foreground data-[active]:text-foreground";
341
234
  var NotificationMenu = Html.component({
@@ -76,107 +76,12 @@ var SelectScrollDownArrow = (h, select, options = {}) => select.scrollDownArrow(
76
76
 
77
77
  // ../../src/components/pagination/html.ts
78
78
  import { krakstackLocaleRead } from "@krak-stack/registry/krakstack-provider/html";
79
-
80
- // ../../src/lib/lucide-effect.ts
81
79
  import {
82
- ArrowDown as arrowDown,
83
- ArrowUp as arrowUp,
84
- ListFilter as listFilter,
85
- Check as check,
86
- ChevronLeft as chevronLeft,
87
- ChevronDown as chevronDown,
88
- ChevronRight as chevronRight,
89
- ChevronsLeft as chevronsLeft,
90
- ChevronsRight as chevronsRight,
91
- ChevronsUpDown as chevronsUpDown,
92
- Copy as copy,
93
- Download as download,
94
- Eye as eye,
95
- EyeOff as eyeOff,
96
- Ellipsis as ellipsis,
97
- FileJson as fileJson,
98
- FileText as fileText,
99
- GripVertical as gripVertical,
100
- Image as image,
101
- LayoutGrid as layoutGrid,
102
- LoaderCircle as loaderCircle,
103
- Mail as mail,
104
- Paperclip as paperclip,
105
- RefreshCw as refreshCw,
106
- RotateCcw as rotateCcw,
107
- Rows3 as rows3,
108
- Search as search,
109
- Settings2 as settings2,
110
- TriangleAlert as triangleAlert,
111
- X as x
112
- } from "lucide";
113
- var createLucideIcon = (icon) => (h, {
114
- size = 24,
115
- color = "currentColor",
116
- strokeWidth = 2,
117
- className
118
- } = {}) => h.svg.attrs({
119
- class: className,
120
- width: String(size),
121
- height: String(size),
122
- viewBox: "0 0 24 24",
123
- fill: "none",
124
- stroke: color,
125
- "stroke-width": String(strokeWidth),
126
- "stroke-linecap": "round",
127
- "stroke-linejoin": "round",
128
- "aria-hidden": "true"
129
- }).children(...icon.map(([tag, attributes]) => {
130
- const attrs = Object.fromEntries(Object.entries(attributes).flatMap(([name, value]) => value === undefined ? [] : [[name, String(value)]]));
131
- switch (tag) {
132
- case "path":
133
- return h.path.attrs(attrs);
134
- case "circle":
135
- return h.circle.attrs(attrs);
136
- case "ellipse":
137
- return h.ellipse.attrs(attrs);
138
- case "line":
139
- return h.line.attrs(attrs);
140
- case "polyline":
141
- return h.polyline.attrs(attrs);
142
- case "polygon":
143
- return h.polygon.attrs(attrs);
144
- case "rect":
145
- return h.rect.attrs(attrs);
146
- default:
147
- throw new Error(`Unsupported Lucide SVG element: ${tag}`);
148
- }
149
- }));
150
- var Check = createLucideIcon(check);
151
- var ArrowDown = createLucideIcon(arrowDown);
152
- var ArrowUp = createLucideIcon(arrowUp);
153
- var ListFilter = createLucideIcon(listFilter);
154
- var ChevronLeft = createLucideIcon(chevronLeft);
155
- var ChevronDown = createLucideIcon(chevronDown);
156
- var ChevronRight = createLucideIcon(chevronRight);
157
- var ChevronsLeft = createLucideIcon(chevronsLeft);
158
- var ChevronsRight = createLucideIcon(chevronsRight);
159
- var ChevronsUpDown = createLucideIcon(chevronsUpDown);
160
- var Copy = createLucideIcon(copy);
161
- var Download = createLucideIcon(download);
162
- var Eye = createLucideIcon(eye);
163
- var EyeOff = createLucideIcon(eyeOff);
164
- var Ellipsis = createLucideIcon(ellipsis);
165
- var FileJson = createLucideIcon(fileJson);
166
- var FileText = createLucideIcon(fileText);
167
- var GripVertical = createLucideIcon(gripVertical);
168
- var Image = createLucideIcon(image);
169
- var LayoutGrid = createLucideIcon(layoutGrid);
170
- var LoaderCircle = createLucideIcon(loaderCircle);
171
- var Mail = createLucideIcon(mail);
172
- var Paperclip = createLucideIcon(paperclip);
173
- var RefreshCw = createLucideIcon(refreshCw);
174
- var RotateCcw = createLucideIcon(rotateCcw);
175
- var Rows3 = createLucideIcon(rows3);
176
- var Search = createLucideIcon(search);
177
- var Settings2 = createLucideIcon(settings2);
178
- var TriangleAlert = createLucideIcon(triangleAlert);
179
- var X = createLucideIcon(x);
80
+ ChevronLeft,
81
+ ChevronRight,
82
+ ChevronsLeft,
83
+ ChevronsRight
84
+ } from "@krak-stack/registry/lucide-effect";
180
85
 
181
86
  // ../../src/components/pagination/classes.ts
182
87
  var paginationClasses = {
@@ -1,161 +1,7 @@
1
1
  // ../../src/components/presence-transition/react.tsx
2
- import { Component as Component2, View as View2 } from "effect/ui";
3
- import { useLayoutEffect as useLayoutEffect2, useRef as useRef2 } from "react";
4
-
5
- // ../../src/lib/effect-ui-adapter/use-model.ts
6
- import { MessageLog as MessageLog2 } from "effect/ui";
7
- import {
8
- createContext,
9
- useCallback,
10
- useContext,
11
- useEffect,
12
- useLayoutEffect,
13
- useRef,
14
- useState,
15
- useSyncExternalStore
16
- } from "react";
17
-
18
- // ../../src/lib/effect-ui-adapter/model-runtime.ts
19
- import { MessageLog, Renderer, View } from "effect/ui";
20
- import { BrowserHost, Html } from "effect/ui/html";
21
- import { Cause, Effect, Fiber } from "effect";
22
- var node = () => ({ children: [] });
23
- var modelHost = (commit) => {
24
- const remove = (child) => {
25
- if (!child.parent)
26
- return;
27
- child.parent.children.splice(child.parent.children.indexOf(child), 1);
28
- delete child.parent;
29
- };
30
- return {
31
- createElement: node,
32
- createText: node,
33
- setText: () => {},
34
- setAttr: () => {},
35
- setProp: () => {},
36
- setEvents: () => {},
37
- insertBefore: (parent, child, before) => {
38
- if (child === before)
39
- return;
40
- remove(child);
41
- const index = before ? parent.children.indexOf(before) : parent.children.length;
42
- parent.children.splice(index, 0, child);
43
- child.parent = parent;
44
- },
45
- remove,
46
- parentOf: (child) => child.parent,
47
- nextOf: (child) => child.parent?.children[child.parent.children.indexOf(child) + 1],
48
- elements: ["html"],
49
- controlled: new Set,
50
- runsMounts: false,
51
- commit
52
- };
53
- };
54
- var mountModel = (component, props, publishSnapshot, messageLog, onEmit) => {
55
- let currentProps = props;
56
- let root;
57
- let active = true;
58
- let failure;
59
- const publish = () => {
60
- if (!active)
61
- return;
62
- if (failure) {
63
- publishSnapshot({ error: failure });
64
- return;
65
- }
66
- const current = root?.model();
67
- if (current !== undefined)
68
- publishSnapshot({ model: current });
69
- };
70
- const fiber = Effect.runFork(Effect.scoped(Effect.gen(function* () {
71
- const mounted = yield* Renderer.mount(component, Effect.succeed(props), node(), {
72
- head: false,
73
- onEmit,
74
- fallback: ({ cause }) => {
75
- failure = new Error("Effect UI root failed", {
76
- cause: Cause.squash(cause)
77
- });
78
- return View.text("");
79
- }
80
- });
81
- if (!active)
82
- return;
83
- root = mounted;
84
- if (props !== currentProps)
85
- mounted.setProps(currentProps);
86
- publish();
87
- return yield* Effect.never;
88
- }).pipe(Effect.provide(Renderer.layer(modelHost(publish))), Effect.provideService(Html.Host, BrowserHost.htmlHost), Effect.provideService(MessageLog.MessageLog, messageLog))));
89
- return {
90
- send: (message) => {
91
- root?.send(message);
92
- publish();
93
- },
94
- setProps: (next) => {
95
- currentProps = next;
96
- root?.setProps(next);
97
- },
98
- dispose: () => {
99
- active = false;
100
- root = undefined;
101
- Effect.runFork(Fiber.interrupt(fiber));
102
- }
103
- };
104
- };
105
-
106
- // ../../src/lib/effect-ui-adapter/use-model.ts
107
- "use client";
108
- var ModelMessageLogContext = createContext(undefined);
109
- var useModel = (component, props, options = {}) => {
110
- const contextLog = useContext(ModelMessageLogContext);
111
- const messageLog = options.messageLog ?? (contextLog === undefined ? MessageLog2.noop : contextLog);
112
- const [store] = useState(() => {
113
- const initial = { model: component.init(props).model };
114
- let snapshot = initial;
115
- const listeners = new Set;
116
- return {
117
- subscribe: (listener) => {
118
- listeners.add(listener);
119
- return () => {
120
- listeners.delete(listener);
121
- };
122
- },
123
- getSnapshot: () => snapshot,
124
- getServerSnapshot: () => initial,
125
- publish: (next) => {
126
- if ("model" in snapshot && "model" in next && Object.is(snapshot.model, next.model))
127
- return;
128
- if ("error" in snapshot && "error" in next && snapshot.error === next.error)
129
- return;
130
- snapshot = next;
131
- listeners.forEach((listener) => listener());
132
- }
133
- };
134
- });
135
- const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);
136
- const committed = useRef(props);
137
- const onEmit = useRef(options.onEmit);
138
- const runtime = useRef(undefined);
139
- const send = useCallback((message) => runtime.current?.send(message), []);
140
- useLayoutEffect(() => {
141
- onEmit.current = options.onEmit;
142
- committed.current = props;
143
- runtime.current?.setProps(props);
144
- }, [props, options.onEmit]);
145
- useEffect(() => {
146
- if (messageLog === null)
147
- return;
148
- const mounted = mountModel(component, committed.current, store.publish, messageLog, (event) => onEmit.current?.(event));
149
- runtime.current = mounted;
150
- return () => {
151
- runtime.current = undefined;
152
- mounted.dispose();
153
- };
154
- }, [component, messageLog, store]);
155
- if ("error" in snapshot)
156
- throw snapshot.error;
157
- return { model: snapshot.model, send };
158
- };
2
+ import { Component as Component2, View } from "effect/ui";
3
+ import { useLayoutEffect, useRef } from "react";
4
+ import { useModel } from "@krak-stack/registry/effect-ui-adapter/react";
159
5
 
160
6
  // ../../src/components/presence-transition/index.ts
161
7
  import { Schema as Schema2, Stream } from "effect";
@@ -251,7 +97,7 @@ var presenceMotion = (element, exited) => {
251
97
  import { jsx } from "react/jsx-runtime";
252
98
  var Model = Component2.define(presenceTransitionOptions).make({
253
99
  ...presenceTransitionBehaviours,
254
- view: () => View2.text("")
100
+ view: () => View.text("")
255
101
  });
256
102
  var PresenceTransition = ({
257
103
  open,
@@ -260,11 +106,11 @@ var PresenceTransition = ({
260
106
  className
261
107
  }) => {
262
108
  const { model, send } = useModel(Model, { open, duration });
263
- const ref = useRef2(null);
264
- const controller = useRef2(undefined);
265
- const seen = useRef2(false);
109
+ const ref = useRef(null);
110
+ const controller = useRef(undefined);
111
+ const seen = useRef(false);
266
112
  const mounted = open || model.retained;
267
- useLayoutEffect2(() => {
113
+ useLayoutEffect(() => {
268
114
  if (!ref.current) {
269
115
  seen.current = true;
270
116
  return;
@@ -275,7 +121,7 @@ var PresenceTransition = ({
275
121
  controller.current = undefined;
276
122
  };
277
123
  }, [mounted, send]);
278
- useLayoutEffect2(() => {
124
+ useLayoutEffect(() => {
279
125
  controller.current?.update(open, duration, open && seen.current);
280
126
  seen.current = !open;
281
127
  }, [open, duration]);
@@ -53,167 +53,13 @@ function Button({
53
53
  import { Check, Copy, TriangleAlert } from "lucide-react";
54
54
  import { Redacted as Redacted2 } from "effect";
55
55
  import { Component as Component2 } from "effect/ui";
56
- import { useLayoutEffect as useLayoutEffect2, useRef as useRef2, useState as useState2 } from "react";
56
+ import { useLayoutEffect, useRef, useState } from "react";
57
57
  import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider/react";
58
-
59
- // ../../src/lib/effect-ui-adapter/use-model.ts
60
- import { MessageLog as MessageLog2 } from "effect/ui";
61
- import {
62
- createContext,
63
- useCallback,
64
- useContext,
65
- useEffect,
66
- useLayoutEffect,
67
- useRef,
68
- useState,
69
- useSyncExternalStore
70
- } from "react";
71
-
72
- // ../../src/lib/effect-ui-adapter/model-runtime.ts
73
- import { MessageLog, Renderer, View } from "effect/ui";
74
- import { BrowserHost, Html } from "effect/ui/html";
75
- import { Cause, Effect, Fiber } from "effect";
76
- var node = () => ({ children: [] });
77
- var modelHost = (commit) => {
78
- const remove = (child) => {
79
- if (!child.parent)
80
- return;
81
- child.parent.children.splice(child.parent.children.indexOf(child), 1);
82
- delete child.parent;
83
- };
84
- return {
85
- createElement: node,
86
- createText: node,
87
- setText: () => {},
88
- setAttr: () => {},
89
- setProp: () => {},
90
- setEvents: () => {},
91
- insertBefore: (parent, child, before) => {
92
- if (child === before)
93
- return;
94
- remove(child);
95
- const index = before ? parent.children.indexOf(before) : parent.children.length;
96
- parent.children.splice(index, 0, child);
97
- child.parent = parent;
98
- },
99
- remove,
100
- parentOf: (child) => child.parent,
101
- nextOf: (child) => child.parent?.children[child.parent.children.indexOf(child) + 1],
102
- elements: ["html"],
103
- controlled: new Set,
104
- runsMounts: false,
105
- commit
106
- };
107
- };
108
- var mountModel = (component, props, publishSnapshot, messageLog, onEmit) => {
109
- let currentProps = props;
110
- let root;
111
- let active = true;
112
- let failure;
113
- const publish = () => {
114
- if (!active)
115
- return;
116
- if (failure) {
117
- publishSnapshot({ error: failure });
118
- return;
119
- }
120
- const current = root?.model();
121
- if (current !== undefined)
122
- publishSnapshot({ model: current });
123
- };
124
- const fiber = Effect.runFork(Effect.scoped(Effect.gen(function* () {
125
- const mounted = yield* Renderer.mount(component, Effect.succeed(props), node(), {
126
- head: false,
127
- onEmit,
128
- fallback: ({ cause }) => {
129
- failure = new Error("Effect UI root failed", {
130
- cause: Cause.squash(cause)
131
- });
132
- return View.text("");
133
- }
134
- });
135
- if (!active)
136
- return;
137
- root = mounted;
138
- if (props !== currentProps)
139
- mounted.setProps(currentProps);
140
- publish();
141
- return yield* Effect.never;
142
- }).pipe(Effect.provide(Renderer.layer(modelHost(publish))), Effect.provideService(Html.Host, BrowserHost.htmlHost), Effect.provideService(MessageLog.MessageLog, messageLog))));
143
- return {
144
- send: (message) => {
145
- root?.send(message);
146
- publish();
147
- },
148
- setProps: (next) => {
149
- currentProps = next;
150
- root?.setProps(next);
151
- },
152
- dispose: () => {
153
- active = false;
154
- root = undefined;
155
- Effect.runFork(Fiber.interrupt(fiber));
156
- }
157
- };
158
- };
159
-
160
- // ../../src/lib/effect-ui-adapter/use-model.ts
161
- "use client";
162
- var ModelMessageLogContext = createContext(undefined);
163
- var useModel = (component, props, options = {}) => {
164
- const contextLog = useContext(ModelMessageLogContext);
165
- const messageLog = options.messageLog ?? (contextLog === undefined ? MessageLog2.noop : contextLog);
166
- const [store] = useState(() => {
167
- const initial = { model: component.init(props).model };
168
- let snapshot = initial;
169
- const listeners = new Set;
170
- return {
171
- subscribe: (listener) => {
172
- listeners.add(listener);
173
- return () => {
174
- listeners.delete(listener);
175
- };
176
- },
177
- getSnapshot: () => snapshot,
178
- getServerSnapshot: () => initial,
179
- publish: (next) => {
180
- if ("model" in snapshot && "model" in next && Object.is(snapshot.model, next.model))
181
- return;
182
- if ("error" in snapshot && "error" in next && snapshot.error === next.error)
183
- return;
184
- snapshot = next;
185
- listeners.forEach((listener) => listener());
186
- }
187
- };
188
- });
189
- const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);
190
- const committed = useRef(props);
191
- const onEmit = useRef(options.onEmit);
192
- const runtime = useRef(undefined);
193
- const send = useCallback((message) => runtime.current?.send(message), []);
194
- useLayoutEffect(() => {
195
- onEmit.current = options.onEmit;
196
- committed.current = props;
197
- runtime.current?.setProps(props);
198
- }, [props, options.onEmit]);
199
- useEffect(() => {
200
- if (messageLog === null)
201
- return;
202
- const mounted = mountModel(component, committed.current, store.publish, messageLog, (event) => onEmit.current?.(event));
203
- runtime.current = mounted;
204
- return () => {
205
- runtime.current = undefined;
206
- mounted.dispose();
207
- };
208
- }, [component, messageLog, store]);
209
- if ("error" in snapshot)
210
- throw snapshot.error;
211
- return { model: snapshot.model, send };
212
- };
58
+ import { useModel } from "@krak-stack/registry/effect-ui-adapter/react";
213
59
 
214
60
  // ../../src/components/copy-button/index.ts
215
- import { Effect as Effect2, Redacted, Schema as Schema2 } from "effect";
216
- import { Command, Component, UiSchema, View as View2 } from "effect/ui";
61
+ import { Effect, Redacted, Schema as Schema2 } from "effect";
62
+ import { Command, Component, UiSchema, View } from "effect/ui";
217
63
 
218
64
  // ../../src/components/copy-button/schema.ts
219
65
  import { Schema } from "effect";
@@ -268,13 +114,13 @@ class WriteClipboard extends Command.Service()("copy-button/WriteClipboard", {
268
114
  },
269
115
  success: CopyButtonMessage
270
116
  }) {
271
- static layerFromWrite = (write) => WriteClipboard.toLayer(({ value }) => Effect2.tryPromise(() => write(Redacted.value(value))).pipe(Effect2.match({
117
+ static layerFromWrite = (write) => WriteClipboard.toLayer(({ value }) => Effect.tryPromise(() => write(Redacted.value(value))).pipe(Effect.match({
272
118
  onSuccess: () => CopyButtonMessage.Finished({ success: true }),
273
119
  onFailure: () => CopyButtonMessage.Finished({ success: false })
274
120
  })));
275
121
  static browser = WriteClipboard.layerFromWrite((value) => navigator.clipboard.writeText(value));
276
122
  }
277
- var ResetClipboardFeedback = Command.make("copy-button/ResetFeedback", { args: { delay: Schema2.Number }, mode: "switch" }, ({ delay }) => Effect2.sleep(Math.max(0, delay)).pipe(Effect2.as(CopyButtonMessage.Reset())));
123
+ 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())));
278
124
  var copyButtonOptions = {
279
125
  name: "CopyButton",
280
126
  props: CopyButtonModelProps,
@@ -296,7 +142,7 @@ var copyButtonBehaviours = {
296
142
  };
297
143
  var CopyButtonModel = Definition.make({
298
144
  ...copyButtonBehaviours,
299
- view: () => View2.text("")
145
+ view: () => View.text("")
300
146
  });
301
147
  var copyButtonStatus = (status, copy, description) => {
302
148
  if (status === "idle")
@@ -324,19 +170,19 @@ function CopyButton({
324
170
  }) {
325
171
  const locale = useKrakstackLocale(localeOverride);
326
172
  const labels = copyButtonMessages(locale, messages);
327
- const callbacks = useRef2({
173
+ const callbacks = useRef({
328
174
  onCopied,
329
175
  onCopyError,
330
176
  failureLabel: labels.copyFailed
331
177
  });
332
- useLayoutEffect2(() => {
178
+ useLayoutEffect(() => {
333
179
  callbacks.current = {
334
180
  onCopied,
335
181
  onCopyError,
336
182
  failureLabel: labels.copyFailed
337
183
  };
338
184
  }, [onCopied, onCopyError, labels.copyFailed]);
339
- const [component] = useState2(() => CopyButtonModel.pipe(Component2.provide(WriteClipboard.layerFromWrite(async (text) => {
185
+ const [component] = useState(() => CopyButtonModel.pipe(Component2.provide(WriteClipboard.layerFromWrite(async (text) => {
340
186
  const { onCopied, onCopyError, failureLabel } = callbacks.current;
341
187
  try {
342
188
  await navigator.clipboard.writeText(text);