@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// ../../src/components/agent/react.tsx
|
|
2
|
-
import { useEffect
|
|
2
|
+
import { useEffect, useId, useRef as useRef2, useState as useState2 } from "react";
|
|
3
3
|
import { Dialog as DialogPrimitive2 } from "@base-ui/react/dialog";
|
|
4
4
|
import {
|
|
5
5
|
ArrowDownIcon as ArrowDownIcon2,
|
|
@@ -66,167 +66,13 @@ function Button({
|
|
|
66
66
|
import { Check, Copy, TriangleAlert } from "lucide-react";
|
|
67
67
|
import { Redacted as Redacted2 } from "effect";
|
|
68
68
|
import { Component as Component2 } from "effect/ui";
|
|
69
|
-
import { useLayoutEffect
|
|
69
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
70
70
|
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider/react";
|
|
71
|
-
|
|
72
|
-
// ../../src/lib/effect-ui-adapter/use-model.ts
|
|
73
|
-
import { MessageLog as MessageLog2 } from "effect/ui";
|
|
74
|
-
import {
|
|
75
|
-
createContext,
|
|
76
|
-
useCallback,
|
|
77
|
-
useContext,
|
|
78
|
-
useEffect,
|
|
79
|
-
useLayoutEffect,
|
|
80
|
-
useRef,
|
|
81
|
-
useState,
|
|
82
|
-
useSyncExternalStore
|
|
83
|
-
} from "react";
|
|
84
|
-
|
|
85
|
-
// ../../src/lib/effect-ui-adapter/model-runtime.ts
|
|
86
|
-
import { MessageLog, Renderer, View } from "effect/ui";
|
|
87
|
-
import { BrowserHost, Html } from "effect/ui/html";
|
|
88
|
-
import { Cause, Effect, Fiber } from "effect";
|
|
89
|
-
var node = () => ({ children: [] });
|
|
90
|
-
var modelHost = (commit) => {
|
|
91
|
-
const remove = (child) => {
|
|
92
|
-
if (!child.parent)
|
|
93
|
-
return;
|
|
94
|
-
child.parent.children.splice(child.parent.children.indexOf(child), 1);
|
|
95
|
-
delete child.parent;
|
|
96
|
-
};
|
|
97
|
-
return {
|
|
98
|
-
createElement: node,
|
|
99
|
-
createText: node,
|
|
100
|
-
setText: () => {},
|
|
101
|
-
setAttr: () => {},
|
|
102
|
-
setProp: () => {},
|
|
103
|
-
setEvents: () => {},
|
|
104
|
-
insertBefore: (parent, child, before) => {
|
|
105
|
-
if (child === before)
|
|
106
|
-
return;
|
|
107
|
-
remove(child);
|
|
108
|
-
const index = before ? parent.children.indexOf(before) : parent.children.length;
|
|
109
|
-
parent.children.splice(index, 0, child);
|
|
110
|
-
child.parent = parent;
|
|
111
|
-
},
|
|
112
|
-
remove,
|
|
113
|
-
parentOf: (child) => child.parent,
|
|
114
|
-
nextOf: (child) => child.parent?.children[child.parent.children.indexOf(child) + 1],
|
|
115
|
-
elements: ["html"],
|
|
116
|
-
controlled: new Set,
|
|
117
|
-
runsMounts: false,
|
|
118
|
-
commit
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
|
-
var mountModel = (component, props, publishSnapshot, messageLog, onEmit) => {
|
|
122
|
-
let currentProps = props;
|
|
123
|
-
let root;
|
|
124
|
-
let active = true;
|
|
125
|
-
let failure;
|
|
126
|
-
const publish = () => {
|
|
127
|
-
if (!active)
|
|
128
|
-
return;
|
|
129
|
-
if (failure) {
|
|
130
|
-
publishSnapshot({ error: failure });
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
const current = root?.model();
|
|
134
|
-
if (current !== undefined)
|
|
135
|
-
publishSnapshot({ model: current });
|
|
136
|
-
};
|
|
137
|
-
const fiber = Effect.runFork(Effect.scoped(Effect.gen(function* () {
|
|
138
|
-
const mounted = yield* Renderer.mount(component, Effect.succeed(props), node(), {
|
|
139
|
-
head: false,
|
|
140
|
-
onEmit,
|
|
141
|
-
fallback: ({ cause }) => {
|
|
142
|
-
failure = new Error("Effect UI root failed", {
|
|
143
|
-
cause: Cause.squash(cause)
|
|
144
|
-
});
|
|
145
|
-
return View.text("");
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
if (!active)
|
|
149
|
-
return;
|
|
150
|
-
root = mounted;
|
|
151
|
-
if (props !== currentProps)
|
|
152
|
-
mounted.setProps(currentProps);
|
|
153
|
-
publish();
|
|
154
|
-
return yield* Effect.never;
|
|
155
|
-
}).pipe(Effect.provide(Renderer.layer(modelHost(publish))), Effect.provideService(Html.Host, BrowserHost.htmlHost), Effect.provideService(MessageLog.MessageLog, messageLog))));
|
|
156
|
-
return {
|
|
157
|
-
send: (message) => {
|
|
158
|
-
root?.send(message);
|
|
159
|
-
publish();
|
|
160
|
-
},
|
|
161
|
-
setProps: (next) => {
|
|
162
|
-
currentProps = next;
|
|
163
|
-
root?.setProps(next);
|
|
164
|
-
},
|
|
165
|
-
dispose: () => {
|
|
166
|
-
active = false;
|
|
167
|
-
root = undefined;
|
|
168
|
-
Effect.runFork(Fiber.interrupt(fiber));
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
// ../../src/lib/effect-ui-adapter/use-model.ts
|
|
174
|
-
"use client";
|
|
175
|
-
var ModelMessageLogContext = createContext(undefined);
|
|
176
|
-
var useModel = (component, props, options = {}) => {
|
|
177
|
-
const contextLog = useContext(ModelMessageLogContext);
|
|
178
|
-
const messageLog = options.messageLog ?? (contextLog === undefined ? MessageLog2.noop : contextLog);
|
|
179
|
-
const [store] = useState(() => {
|
|
180
|
-
const initial = { model: component.init(props).model };
|
|
181
|
-
let snapshot = initial;
|
|
182
|
-
const listeners = new Set;
|
|
183
|
-
return {
|
|
184
|
-
subscribe: (listener) => {
|
|
185
|
-
listeners.add(listener);
|
|
186
|
-
return () => {
|
|
187
|
-
listeners.delete(listener);
|
|
188
|
-
};
|
|
189
|
-
},
|
|
190
|
-
getSnapshot: () => snapshot,
|
|
191
|
-
getServerSnapshot: () => initial,
|
|
192
|
-
publish: (next) => {
|
|
193
|
-
if ("model" in snapshot && "model" in next && Object.is(snapshot.model, next.model))
|
|
194
|
-
return;
|
|
195
|
-
if ("error" in snapshot && "error" in next && snapshot.error === next.error)
|
|
196
|
-
return;
|
|
197
|
-
snapshot = next;
|
|
198
|
-
listeners.forEach((listener) => listener());
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
});
|
|
202
|
-
const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);
|
|
203
|
-
const committed = useRef(props);
|
|
204
|
-
const onEmit = useRef(options.onEmit);
|
|
205
|
-
const runtime = useRef(undefined);
|
|
206
|
-
const send = useCallback((message) => runtime.current?.send(message), []);
|
|
207
|
-
useLayoutEffect(() => {
|
|
208
|
-
onEmit.current = options.onEmit;
|
|
209
|
-
committed.current = props;
|
|
210
|
-
runtime.current?.setProps(props);
|
|
211
|
-
}, [props, options.onEmit]);
|
|
212
|
-
useEffect(() => {
|
|
213
|
-
if (messageLog === null)
|
|
214
|
-
return;
|
|
215
|
-
const mounted = mountModel(component, committed.current, store.publish, messageLog, (event) => onEmit.current?.(event));
|
|
216
|
-
runtime.current = mounted;
|
|
217
|
-
return () => {
|
|
218
|
-
runtime.current = undefined;
|
|
219
|
-
mounted.dispose();
|
|
220
|
-
};
|
|
221
|
-
}, [component, messageLog, store]);
|
|
222
|
-
if ("error" in snapshot)
|
|
223
|
-
throw snapshot.error;
|
|
224
|
-
return { model: snapshot.model, send };
|
|
225
|
-
};
|
|
71
|
+
import { useModel } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
226
72
|
|
|
227
73
|
// ../../src/components/copy-button/index.ts
|
|
228
|
-
import { Effect
|
|
229
|
-
import { Command, Component, UiSchema, View
|
|
74
|
+
import { Effect, Redacted, Schema as Schema2 } from "effect";
|
|
75
|
+
import { Command, Component, UiSchema, View } from "effect/ui";
|
|
230
76
|
|
|
231
77
|
// ../../src/components/copy-button/schema.ts
|
|
232
78
|
import { Schema } from "effect";
|
|
@@ -281,13 +127,13 @@ class WriteClipboard extends Command.Service()("copy-button/WriteClipboard", {
|
|
|
281
127
|
},
|
|
282
128
|
success: CopyButtonMessage
|
|
283
129
|
}) {
|
|
284
|
-
static layerFromWrite = (write) => WriteClipboard.toLayer(({ value }) =>
|
|
130
|
+
static layerFromWrite = (write) => WriteClipboard.toLayer(({ value }) => Effect.tryPromise(() => write(Redacted.value(value))).pipe(Effect.match({
|
|
285
131
|
onSuccess: () => CopyButtonMessage.Finished({ success: true }),
|
|
286
132
|
onFailure: () => CopyButtonMessage.Finished({ success: false })
|
|
287
133
|
})));
|
|
288
134
|
static browser = WriteClipboard.layerFromWrite((value) => navigator.clipboard.writeText(value));
|
|
289
135
|
}
|
|
290
|
-
var ResetClipboardFeedback = Command.make("copy-button/ResetFeedback", { args: { delay: Schema2.Number }, mode: "switch" }, ({ delay }) =>
|
|
136
|
+
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())));
|
|
291
137
|
var copyButtonOptions = {
|
|
292
138
|
name: "CopyButton",
|
|
293
139
|
props: CopyButtonModelProps,
|
|
@@ -309,7 +155,7 @@ var copyButtonBehaviours = {
|
|
|
309
155
|
};
|
|
310
156
|
var CopyButtonModel = Definition.make({
|
|
311
157
|
...copyButtonBehaviours,
|
|
312
|
-
view: () =>
|
|
158
|
+
view: () => View.text("")
|
|
313
159
|
});
|
|
314
160
|
var copyButtonStatus = (status, copy, description) => {
|
|
315
161
|
if (status === "idle")
|
|
@@ -337,19 +183,19 @@ function CopyButton({
|
|
|
337
183
|
}) {
|
|
338
184
|
const locale = useKrakstackLocale(localeOverride);
|
|
339
185
|
const labels = copyButtonMessages(locale, messages);
|
|
340
|
-
const callbacks =
|
|
186
|
+
const callbacks = useRef({
|
|
341
187
|
onCopied,
|
|
342
188
|
onCopyError,
|
|
343
189
|
failureLabel: labels.copyFailed
|
|
344
190
|
});
|
|
345
|
-
|
|
191
|
+
useLayoutEffect(() => {
|
|
346
192
|
callbacks.current = {
|
|
347
193
|
onCopied,
|
|
348
194
|
onCopyError,
|
|
349
195
|
failureLabel: labels.copyFailed
|
|
350
196
|
};
|
|
351
197
|
}, [onCopied, onCopyError, labels.copyFailed]);
|
|
352
|
-
const [component] =
|
|
198
|
+
const [component] = useState(() => CopyButtonModel.pipe(Component2.provide(WriteClipboard.layerFromWrite(async (text) => {
|
|
353
199
|
const { onCopied, onCopyError, failureLabel } = callbacks.current;
|
|
354
200
|
try {
|
|
355
201
|
await navigator.clipboard.writeText(text);
|
|
@@ -1521,7 +1367,7 @@ var AgentStreamError = Schema3.Struct({
|
|
|
1521
1367
|
import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider/react";
|
|
1522
1368
|
|
|
1523
1369
|
// ../../src/components/agent/index.ts
|
|
1524
|
-
import { Context, Effect as
|
|
1370
|
+
import { Context, Effect as Effect2, Layer, Redacted as Redacted3, Schema as Schema5, Stream } from "effect";
|
|
1525
1371
|
import { AtomRegistry } from "effect/reactivity";
|
|
1526
1372
|
import { Command as Command3, Component as Component3, Subscription, UiSchema as UiSchema2 } from "effect/ui";
|
|
1527
1373
|
|
|
@@ -1584,7 +1430,7 @@ var AgentWidgetIntentSchema = Schema4.Union([
|
|
|
1584
1430
|
|
|
1585
1431
|
// ../../src/components/agent/index.ts
|
|
1586
1432
|
class ConversationHost extends Context.Service()("agent/ConversationHost") {
|
|
1587
|
-
static layer = (host) => Layer.merge(Layer.succeed(ConversationHost, host), DispatchIntent.toLayer(({ intent }) =>
|
|
1433
|
+
static layer = (host) => Layer.merge(Layer.succeed(ConversationHost, host), DispatchIntent.toLayer(({ intent }) => Effect2.suspend(() => host.dispatch(intent)).pipe(Effect2.match({
|
|
1588
1434
|
onSuccess: () => AgentWidgetMessage.Delivered({ success: true }),
|
|
1589
1435
|
onFailure: () => AgentWidgetMessage.Delivered({ success: false })
|
|
1590
1436
|
}))));
|
|
@@ -1729,7 +1575,7 @@ var agentWidgetBehaviours = {
|
|
|
1729
1575
|
maximized: false
|
|
1730
1576
|
}),
|
|
1731
1577
|
subscriptions: () => [
|
|
1732
|
-
Subscription.make("agent/conversation", Stream.unwrap(
|
|
1578
|
+
Subscription.make("agent/conversation", Stream.unwrap(Effect2.map(ConversationHost, (host) => host.snapshots.pipe(Stream.map((snapshot) => AgentWidgetMessage.Received({
|
|
1733
1579
|
snapshot: Redacted3.make(snapshot)
|
|
1734
1580
|
})), Stream.concat(Stream.make(AgentWidgetMessage.Disconnected()))))))
|
|
1735
1581
|
],
|
|
@@ -2027,7 +1873,7 @@ function ToolActivityLog({
|
|
|
2027
1873
|
tools,
|
|
2028
1874
|
workedSeconds
|
|
2029
1875
|
}) {
|
|
2030
|
-
const [open, setOpen] =
|
|
1876
|
+
const [open, setOpen] = useState2();
|
|
2031
1877
|
const approvals = tools.filter((tool) => tool.status === "approval-required");
|
|
2032
1878
|
const activity = tools.filter((tool) => tool.status !== "approval-required");
|
|
2033
1879
|
const currentTool = activity.at(-1);
|
|
@@ -2104,12 +1950,12 @@ function AgentMessageRow({
|
|
|
2104
1950
|
pending
|
|
2105
1951
|
}) {
|
|
2106
1952
|
const isUser = message.role === "user";
|
|
2107
|
-
const activeStartedAt =
|
|
2108
|
-
const activeMilliseconds =
|
|
2109
|
-
const wasPending =
|
|
2110
|
-
const [workedSeconds, setWorkedSeconds] =
|
|
1953
|
+
const activeStartedAt = useRef2(undefined);
|
|
1954
|
+
const activeMilliseconds = useRef2(0);
|
|
1955
|
+
const wasPending = useRef2(pending);
|
|
1956
|
+
const [workedSeconds, setWorkedSeconds] = useState2();
|
|
2111
1957
|
const hasPendingApproval = message.tools.some((tool) => tool.status === "approval-required");
|
|
2112
|
-
|
|
1958
|
+
useEffect(() => {
|
|
2113
1959
|
const isWorking = pending && !hasPendingApproval;
|
|
2114
1960
|
if (isWorking) {
|
|
2115
1961
|
wasPending.current = true;
|
|
@@ -2194,15 +2040,15 @@ function AgentWidget({
|
|
|
2194
2040
|
const labels = agentWidgetMessages(locale, messageOverrides);
|
|
2195
2041
|
const referenceInputId = useId();
|
|
2196
2042
|
const referenceListId = `${referenceInputId}-list`;
|
|
2197
|
-
const [open, setOpen] =
|
|
2198
|
-
const [maximized, setMaximized] =
|
|
2199
|
-
const [referencePickerOpen, setReferencePickerOpen] =
|
|
2200
|
-
const [activeReferenceKey, setActiveReferenceKey] =
|
|
2201
|
-
const [activeReferenceSearch, setActiveReferenceSearch] =
|
|
2202
|
-
const [input, setInput] =
|
|
2203
|
-
const inputRef =
|
|
2204
|
-
const inputOverlayRef =
|
|
2205
|
-
const [references, setReferences] =
|
|
2043
|
+
const [open, setOpen] = useState2(false);
|
|
2044
|
+
const [maximized, setMaximized] = useState2(false);
|
|
2045
|
+
const [referencePickerOpen, setReferencePickerOpen] = useState2(false);
|
|
2046
|
+
const [activeReferenceKey, setActiveReferenceKey] = useState2("");
|
|
2047
|
+
const [activeReferenceSearch, setActiveReferenceSearch] = useState2();
|
|
2048
|
+
const [input, setInput] = useState2("");
|
|
2049
|
+
const inputRef = useRef2(null);
|
|
2050
|
+
const inputOverlayRef = useRef2(null);
|
|
2051
|
+
const [references, setReferences] = useState2([]);
|
|
2206
2052
|
const activeContext = state.contextLocked ? state.context ? {
|
|
2207
2053
|
...state.context,
|
|
2208
2054
|
icon: availableReferences.find(({ key }) => key === state.context?.key)?.icon
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// ../../src/components/animated-list/react.tsx
|
|
2
2
|
import {
|
|
3
|
-
useEffect as
|
|
3
|
+
useEffect as useEffect2,
|
|
4
4
|
useEffectEvent as useEffectEvent2,
|
|
5
5
|
useId,
|
|
6
|
-
useRef as
|
|
7
|
-
useState as
|
|
6
|
+
useRef as useRef2,
|
|
7
|
+
useState as useState2
|
|
8
8
|
} from "react";
|
|
9
9
|
import { GripVertical } from "lucide-react";
|
|
10
|
-
import { Component as Component2, View
|
|
10
|
+
import { Component as Component2, View } from "effect/ui";
|
|
11
11
|
import { cn } from "cn";
|
|
12
12
|
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider/react";
|
|
13
13
|
|
|
@@ -208,160 +208,8 @@ var useVerticalDrag = ({
|
|
|
208
208
|
};
|
|
209
209
|
};
|
|
210
210
|
|
|
211
|
-
// ../../src/
|
|
212
|
-
import {
|
|
213
|
-
import {
|
|
214
|
-
createContext,
|
|
215
|
-
useCallback,
|
|
216
|
-
useContext,
|
|
217
|
-
useEffect as useEffect2,
|
|
218
|
-
useLayoutEffect as useLayoutEffect2,
|
|
219
|
-
useRef as useRef2,
|
|
220
|
-
useState as useState2,
|
|
221
|
-
useSyncExternalStore as useSyncExternalStore2
|
|
222
|
-
} from "react";
|
|
223
|
-
|
|
224
|
-
// ../../src/lib/effect-ui-adapter/model-runtime.ts
|
|
225
|
-
import { MessageLog, Renderer, View } from "effect/ui";
|
|
226
|
-
import { BrowserHost, Html } from "effect/ui/html";
|
|
227
|
-
import { Cause, Effect, Fiber } from "effect";
|
|
228
|
-
var node = () => ({ children: [] });
|
|
229
|
-
var modelHost = (commit) => {
|
|
230
|
-
const remove = (child) => {
|
|
231
|
-
if (!child.parent)
|
|
232
|
-
return;
|
|
233
|
-
child.parent.children.splice(child.parent.children.indexOf(child), 1);
|
|
234
|
-
delete child.parent;
|
|
235
|
-
};
|
|
236
|
-
return {
|
|
237
|
-
createElement: node,
|
|
238
|
-
createText: node,
|
|
239
|
-
setText: () => {},
|
|
240
|
-
setAttr: () => {},
|
|
241
|
-
setProp: () => {},
|
|
242
|
-
setEvents: () => {},
|
|
243
|
-
insertBefore: (parent, child, before) => {
|
|
244
|
-
if (child === before)
|
|
245
|
-
return;
|
|
246
|
-
remove(child);
|
|
247
|
-
const index = before ? parent.children.indexOf(before) : parent.children.length;
|
|
248
|
-
parent.children.splice(index, 0, child);
|
|
249
|
-
child.parent = parent;
|
|
250
|
-
},
|
|
251
|
-
remove,
|
|
252
|
-
parentOf: (child) => child.parent,
|
|
253
|
-
nextOf: (child) => child.parent?.children[child.parent.children.indexOf(child) + 1],
|
|
254
|
-
elements: ["html"],
|
|
255
|
-
controlled: new Set,
|
|
256
|
-
runsMounts: false,
|
|
257
|
-
commit
|
|
258
|
-
};
|
|
259
|
-
};
|
|
260
|
-
var mountModel = (component, props, publishSnapshot, messageLog, onEmit) => {
|
|
261
|
-
let currentProps = props;
|
|
262
|
-
let root;
|
|
263
|
-
let active = true;
|
|
264
|
-
let failure;
|
|
265
|
-
const publish = () => {
|
|
266
|
-
if (!active)
|
|
267
|
-
return;
|
|
268
|
-
if (failure) {
|
|
269
|
-
publishSnapshot({ error: failure });
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
const current = root?.model();
|
|
273
|
-
if (current !== undefined)
|
|
274
|
-
publishSnapshot({ model: current });
|
|
275
|
-
};
|
|
276
|
-
const fiber = Effect.runFork(Effect.scoped(Effect.gen(function* () {
|
|
277
|
-
const mounted = yield* Renderer.mount(component, Effect.succeed(props), node(), {
|
|
278
|
-
head: false,
|
|
279
|
-
onEmit,
|
|
280
|
-
fallback: ({ cause }) => {
|
|
281
|
-
failure = new Error("Effect UI root failed", {
|
|
282
|
-
cause: Cause.squash(cause)
|
|
283
|
-
});
|
|
284
|
-
return View.text("");
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
if (!active)
|
|
288
|
-
return;
|
|
289
|
-
root = mounted;
|
|
290
|
-
if (props !== currentProps)
|
|
291
|
-
mounted.setProps(currentProps);
|
|
292
|
-
publish();
|
|
293
|
-
return yield* Effect.never;
|
|
294
|
-
}).pipe(Effect.provide(Renderer.layer(modelHost(publish))), Effect.provideService(Html.Host, BrowserHost.htmlHost), Effect.provideService(MessageLog.MessageLog, messageLog))));
|
|
295
|
-
return {
|
|
296
|
-
send: (message) => {
|
|
297
|
-
root?.send(message);
|
|
298
|
-
publish();
|
|
299
|
-
},
|
|
300
|
-
setProps: (next) => {
|
|
301
|
-
currentProps = next;
|
|
302
|
-
root?.setProps(next);
|
|
303
|
-
},
|
|
304
|
-
dispose: () => {
|
|
305
|
-
active = false;
|
|
306
|
-
root = undefined;
|
|
307
|
-
Effect.runFork(Fiber.interrupt(fiber));
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
// ../../src/lib/effect-ui-adapter/use-model.ts
|
|
313
|
-
"use client";
|
|
314
|
-
var ModelMessageLogContext = createContext(undefined);
|
|
315
|
-
var useModel = (component, props, options = {}) => {
|
|
316
|
-
const contextLog = useContext(ModelMessageLogContext);
|
|
317
|
-
const messageLog = options.messageLog ?? (contextLog === undefined ? MessageLog2.noop : contextLog);
|
|
318
|
-
const [store] = useState2(() => {
|
|
319
|
-
const initial = { model: component.init(props).model };
|
|
320
|
-
let snapshot = initial;
|
|
321
|
-
const listeners = new Set;
|
|
322
|
-
return {
|
|
323
|
-
subscribe: (listener) => {
|
|
324
|
-
listeners.add(listener);
|
|
325
|
-
return () => {
|
|
326
|
-
listeners.delete(listener);
|
|
327
|
-
};
|
|
328
|
-
},
|
|
329
|
-
getSnapshot: () => snapshot,
|
|
330
|
-
getServerSnapshot: () => initial,
|
|
331
|
-
publish: (next) => {
|
|
332
|
-
if ("model" in snapshot && "model" in next && Object.is(snapshot.model, next.model))
|
|
333
|
-
return;
|
|
334
|
-
if ("error" in snapshot && "error" in next && snapshot.error === next.error)
|
|
335
|
-
return;
|
|
336
|
-
snapshot = next;
|
|
337
|
-
listeners.forEach((listener) => listener());
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
});
|
|
341
|
-
const snapshot = useSyncExternalStore2(store.subscribe, store.getSnapshot, store.getServerSnapshot);
|
|
342
|
-
const committed = useRef2(props);
|
|
343
|
-
const onEmit = useRef2(options.onEmit);
|
|
344
|
-
const runtime = useRef2(undefined);
|
|
345
|
-
const send = useCallback((message) => runtime.current?.send(message), []);
|
|
346
|
-
useLayoutEffect2(() => {
|
|
347
|
-
onEmit.current = options.onEmit;
|
|
348
|
-
committed.current = props;
|
|
349
|
-
runtime.current?.setProps(props);
|
|
350
|
-
}, [props, options.onEmit]);
|
|
351
|
-
useEffect2(() => {
|
|
352
|
-
if (messageLog === null)
|
|
353
|
-
return;
|
|
354
|
-
const mounted = mountModel(component, committed.current, store.publish, messageLog, (event) => onEmit.current?.(event));
|
|
355
|
-
runtime.current = mounted;
|
|
356
|
-
return () => {
|
|
357
|
-
runtime.current = undefined;
|
|
358
|
-
mounted.dispose();
|
|
359
|
-
};
|
|
360
|
-
}, [component, messageLog, store]);
|
|
361
|
-
if ("error" in snapshot)
|
|
362
|
-
throw snapshot.error;
|
|
363
|
-
return { model: snapshot.model, send };
|
|
364
|
-
};
|
|
211
|
+
// ../../src/components/animated-list/react.tsx
|
|
212
|
+
import { useModel } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
365
213
|
|
|
366
214
|
// ../../src/components/animated-list/classes.ts
|
|
367
215
|
var animatedListClasses = {
|
|
@@ -516,7 +364,7 @@ var animatedListBehaviours = {
|
|
|
516
364
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
517
365
|
var Model = Component2.define(animatedListOptions).make({
|
|
518
366
|
...animatedListBehaviours,
|
|
519
|
-
view: () =>
|
|
367
|
+
view: () => View.text("")
|
|
520
368
|
});
|
|
521
369
|
var AnimatedList = ({
|
|
522
370
|
classes: classOverrides,
|
|
@@ -537,7 +385,7 @@ var AnimatedList = ({
|
|
|
537
385
|
const locale = useKrakstackLocale(override);
|
|
538
386
|
const copy = animatedListCopy(locale, messages);
|
|
539
387
|
const instructions = useId();
|
|
540
|
-
const container =
|
|
388
|
+
const container = useRef2(null);
|
|
541
389
|
const descriptors = items.map((item) => ({
|
|
542
390
|
key: getKey(item),
|
|
543
391
|
label: getItemLabel?.(item)
|
|
@@ -548,7 +396,7 @@ var AnimatedList = ({
|
|
|
548
396
|
});
|
|
549
397
|
const retained = retainedRows(descriptors, model.rows);
|
|
550
398
|
const current = new Map(items.map((item) => [getKey(item), { item }]));
|
|
551
|
-
const [previous, setPrevious] =
|
|
399
|
+
const [previous, setPrevious] = useState2(() => ({
|
|
552
400
|
items,
|
|
553
401
|
rows: model.rows,
|
|
554
402
|
rendered: current
|
|
@@ -560,8 +408,8 @@ var AnimatedList = ({
|
|
|
560
408
|
if (previous.items !== items || previous.rows !== model.rows) {
|
|
561
409
|
setPrevious({ items, rows: model.rows, rendered });
|
|
562
410
|
}
|
|
563
|
-
const committed =
|
|
564
|
-
|
|
411
|
+
const committed = useRef2(false);
|
|
412
|
+
useEffect2(() => {
|
|
565
413
|
committed.current = true;
|
|
566
414
|
}, []);
|
|
567
415
|
useListLayout(container, duration);
|
|
@@ -643,10 +491,10 @@ var ListItem = ({
|
|
|
643
491
|
onKeyMove,
|
|
644
492
|
children
|
|
645
493
|
}) => {
|
|
646
|
-
const ref =
|
|
647
|
-
const mounted =
|
|
648
|
-
const lastPresent =
|
|
649
|
-
const transitioning =
|
|
494
|
+
const ref = useRef2(null);
|
|
495
|
+
const mounted = useRef2(false);
|
|
496
|
+
const lastPresent = useRef2(present);
|
|
497
|
+
const transitioning = useRef2(false);
|
|
650
498
|
const exit = useEffectEvent2(onExit);
|
|
651
499
|
const reduced = useReducedMotion();
|
|
652
500
|
const drag = useVerticalDrag({
|
|
@@ -656,7 +504,7 @@ var ListItem = ({
|
|
|
656
504
|
overflow: dragOverflow,
|
|
657
505
|
onMove
|
|
658
506
|
});
|
|
659
|
-
|
|
507
|
+
useEffect2(() => {
|
|
660
508
|
const element = ref.current;
|
|
661
509
|
const first = !mounted.current;
|
|
662
510
|
mounted.current = true;
|