@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// ../../src/components/search-menu/react.tsx
|
|
2
2
|
import { SearchIcon as SearchIcon2, XIcon as XIcon2 } from "lucide-react";
|
|
3
|
-
import { useCallback
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
4
|
|
|
5
5
|
// ../../src/components/ui/button.tsx
|
|
6
6
|
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
@@ -256,162 +256,8 @@ function CommandShortcut({
|
|
|
256
256
|
|
|
257
257
|
// ../../src/components/search-menu/react.tsx
|
|
258
258
|
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider/react";
|
|
259
|
-
import { Component as Component2, View
|
|
260
|
-
|
|
261
|
-
// ../../src/lib/effect-ui-adapter/use-model.ts
|
|
262
|
-
import { MessageLog as MessageLog2 } from "effect/ui";
|
|
263
|
-
import {
|
|
264
|
-
createContext,
|
|
265
|
-
useCallback,
|
|
266
|
-
useContext,
|
|
267
|
-
useEffect,
|
|
268
|
-
useLayoutEffect,
|
|
269
|
-
useRef,
|
|
270
|
-
useState,
|
|
271
|
-
useSyncExternalStore
|
|
272
|
-
} from "react";
|
|
273
|
-
|
|
274
|
-
// ../../src/lib/effect-ui-adapter/model-runtime.ts
|
|
275
|
-
import { MessageLog, Renderer, View } from "effect/ui";
|
|
276
|
-
import { BrowserHost, Html } from "effect/ui/html";
|
|
277
|
-
import { Cause, Effect, Fiber } from "effect";
|
|
278
|
-
var node = () => ({ children: [] });
|
|
279
|
-
var modelHost = (commit) => {
|
|
280
|
-
const remove = (child) => {
|
|
281
|
-
if (!child.parent)
|
|
282
|
-
return;
|
|
283
|
-
child.parent.children.splice(child.parent.children.indexOf(child), 1);
|
|
284
|
-
delete child.parent;
|
|
285
|
-
};
|
|
286
|
-
return {
|
|
287
|
-
createElement: node,
|
|
288
|
-
createText: node,
|
|
289
|
-
setText: () => {},
|
|
290
|
-
setAttr: () => {},
|
|
291
|
-
setProp: () => {},
|
|
292
|
-
setEvents: () => {},
|
|
293
|
-
insertBefore: (parent, child, before) => {
|
|
294
|
-
if (child === before)
|
|
295
|
-
return;
|
|
296
|
-
remove(child);
|
|
297
|
-
const index = before ? parent.children.indexOf(before) : parent.children.length;
|
|
298
|
-
parent.children.splice(index, 0, child);
|
|
299
|
-
child.parent = parent;
|
|
300
|
-
},
|
|
301
|
-
remove,
|
|
302
|
-
parentOf: (child) => child.parent,
|
|
303
|
-
nextOf: (child) => child.parent?.children[child.parent.children.indexOf(child) + 1],
|
|
304
|
-
elements: ["html"],
|
|
305
|
-
controlled: new Set,
|
|
306
|
-
runsMounts: false,
|
|
307
|
-
commit
|
|
308
|
-
};
|
|
309
|
-
};
|
|
310
|
-
var mountModel = (component, props, publishSnapshot, messageLog, onEmit) => {
|
|
311
|
-
let currentProps = props;
|
|
312
|
-
let root;
|
|
313
|
-
let active = true;
|
|
314
|
-
let failure;
|
|
315
|
-
const publish = () => {
|
|
316
|
-
if (!active)
|
|
317
|
-
return;
|
|
318
|
-
if (failure) {
|
|
319
|
-
publishSnapshot({ error: failure });
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
const current = root?.model();
|
|
323
|
-
if (current !== undefined)
|
|
324
|
-
publishSnapshot({ model: current });
|
|
325
|
-
};
|
|
326
|
-
const fiber = Effect.runFork(Effect.scoped(Effect.gen(function* () {
|
|
327
|
-
const mounted = yield* Renderer.mount(component, Effect.succeed(props), node(), {
|
|
328
|
-
head: false,
|
|
329
|
-
onEmit,
|
|
330
|
-
fallback: ({ cause }) => {
|
|
331
|
-
failure = new Error("Effect UI root failed", {
|
|
332
|
-
cause: Cause.squash(cause)
|
|
333
|
-
});
|
|
334
|
-
return View.text("");
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
if (!active)
|
|
338
|
-
return;
|
|
339
|
-
root = mounted;
|
|
340
|
-
if (props !== currentProps)
|
|
341
|
-
mounted.setProps(currentProps);
|
|
342
|
-
publish();
|
|
343
|
-
return yield* Effect.never;
|
|
344
|
-
}).pipe(Effect.provide(Renderer.layer(modelHost(publish))), Effect.provideService(Html.Host, BrowserHost.htmlHost), Effect.provideService(MessageLog.MessageLog, messageLog))));
|
|
345
|
-
return {
|
|
346
|
-
send: (message) => {
|
|
347
|
-
root?.send(message);
|
|
348
|
-
publish();
|
|
349
|
-
},
|
|
350
|
-
setProps: (next) => {
|
|
351
|
-
currentProps = next;
|
|
352
|
-
root?.setProps(next);
|
|
353
|
-
},
|
|
354
|
-
dispose: () => {
|
|
355
|
-
active = false;
|
|
356
|
-
root = undefined;
|
|
357
|
-
Effect.runFork(Fiber.interrupt(fiber));
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
};
|
|
361
|
-
|
|
362
|
-
// ../../src/lib/effect-ui-adapter/use-model.ts
|
|
363
|
-
"use client";
|
|
364
|
-
var ModelMessageLogContext = createContext(undefined);
|
|
365
|
-
var useModel = (component, props, options = {}) => {
|
|
366
|
-
const contextLog = useContext(ModelMessageLogContext);
|
|
367
|
-
const messageLog = options.messageLog ?? (contextLog === undefined ? MessageLog2.noop : contextLog);
|
|
368
|
-
const [store] = useState(() => {
|
|
369
|
-
const initial = { model: component.init(props).model };
|
|
370
|
-
let snapshot = initial;
|
|
371
|
-
const listeners = new Set;
|
|
372
|
-
return {
|
|
373
|
-
subscribe: (listener) => {
|
|
374
|
-
listeners.add(listener);
|
|
375
|
-
return () => {
|
|
376
|
-
listeners.delete(listener);
|
|
377
|
-
};
|
|
378
|
-
},
|
|
379
|
-
getSnapshot: () => snapshot,
|
|
380
|
-
getServerSnapshot: () => initial,
|
|
381
|
-
publish: (next) => {
|
|
382
|
-
if ("model" in snapshot && "model" in next && Object.is(snapshot.model, next.model))
|
|
383
|
-
return;
|
|
384
|
-
if ("error" in snapshot && "error" in next && snapshot.error === next.error)
|
|
385
|
-
return;
|
|
386
|
-
snapshot = next;
|
|
387
|
-
listeners.forEach((listener) => listener());
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
});
|
|
391
|
-
const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);
|
|
392
|
-
const committed = useRef(props);
|
|
393
|
-
const onEmit = useRef(options.onEmit);
|
|
394
|
-
const runtime = useRef(undefined);
|
|
395
|
-
const send = useCallback((message) => runtime.current?.send(message), []);
|
|
396
|
-
useLayoutEffect(() => {
|
|
397
|
-
onEmit.current = options.onEmit;
|
|
398
|
-
committed.current = props;
|
|
399
|
-
runtime.current?.setProps(props);
|
|
400
|
-
}, [props, options.onEmit]);
|
|
401
|
-
useEffect(() => {
|
|
402
|
-
if (messageLog === null)
|
|
403
|
-
return;
|
|
404
|
-
const mounted = mountModel(component, committed.current, store.publish, messageLog, (event) => onEmit.current?.(event));
|
|
405
|
-
runtime.current = mounted;
|
|
406
|
-
return () => {
|
|
407
|
-
runtime.current = undefined;
|
|
408
|
-
mounted.dispose();
|
|
409
|
-
};
|
|
410
|
-
}, [component, messageLog, store]);
|
|
411
|
-
if ("error" in snapshot)
|
|
412
|
-
throw snapshot.error;
|
|
413
|
-
return { model: snapshot.model, send };
|
|
414
|
-
};
|
|
259
|
+
import { Component as Component2, View } from "effect/ui";
|
|
260
|
+
import { useModel } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
415
261
|
|
|
416
262
|
// ../../src/components/search-menu/classes.ts
|
|
417
263
|
var searchMenuClasses = {
|
|
@@ -534,7 +380,7 @@ var searchMenuBehaviours = {
|
|
|
534
380
|
import { jsx as jsx4, jsxs as jsxs3, Fragment } from "react/jsx-runtime";
|
|
535
381
|
var SearchModel = Component2.define(searchMenuOptions).make({
|
|
536
382
|
...searchMenuBehaviours,
|
|
537
|
-
view: () =>
|
|
383
|
+
view: () => View.text("")
|
|
538
384
|
});
|
|
539
385
|
function SearchMenu({
|
|
540
386
|
classes: classOverrides,
|
|
@@ -568,23 +414,23 @@ function SearchMenu({
|
|
|
568
414
|
const isOpen = open ?? model.open;
|
|
569
415
|
const searchQuery = query ?? model.query;
|
|
570
416
|
const externalGroups = shouldFilter === false ? groups : undefined;
|
|
571
|
-
const [selection, setSelection] =
|
|
417
|
+
const [selection, setSelection] = useState();
|
|
572
418
|
const externalItems = externalGroups?.flatMap(({ items }) => items.filter(({ disabled }) => !disabled));
|
|
573
419
|
const selectedValue = selection?.groups === externalGroups && selection?.query === searchQuery && externalItems?.some(({ label }) => label.trim() === selection?.value) ? selection.value : externalItems?.[0]?.label.trim() ?? "";
|
|
574
|
-
const inputRef =
|
|
575
|
-
const listRef =
|
|
420
|
+
const inputRef = useRef(null);
|
|
421
|
+
const listRef = useRef(null);
|
|
576
422
|
const setQuery = (value) => {
|
|
577
423
|
if (query === undefined)
|
|
578
424
|
send(SearchMenuMessage.SetQuery({ query: value }));
|
|
579
425
|
onQueryChange?.(value);
|
|
580
426
|
};
|
|
581
|
-
|
|
427
|
+
useEffect(() => {
|
|
582
428
|
if (!isOpen) {
|
|
583
429
|
send(SearchMenuMessage.Reset());
|
|
584
430
|
setSelection(undefined);
|
|
585
431
|
}
|
|
586
432
|
}, [isOpen, send]);
|
|
587
|
-
|
|
433
|
+
useEffect(() => {
|
|
588
434
|
const list = listRef.current;
|
|
589
435
|
if (!isOpen || !list)
|
|
590
436
|
return;
|
|
@@ -593,12 +439,12 @@ function SearchMenu({
|
|
|
593
439
|
});
|
|
594
440
|
return () => cancelAnimationFrame(frame);
|
|
595
441
|
}, [isOpen, searchQuery, externalGroups]);
|
|
596
|
-
const setOpen =
|
|
442
|
+
const setOpen = useCallback((value) => {
|
|
597
443
|
if (open === undefined)
|
|
598
444
|
send(SearchMenuMessage.SetOpen({ open: value }));
|
|
599
445
|
onOpenChange?.(value);
|
|
600
446
|
}, [open, onOpenChange, send]);
|
|
601
|
-
|
|
447
|
+
useEffect(() => {
|
|
602
448
|
if (!enableShortcut)
|
|
603
449
|
return;
|
|
604
450
|
const onKeyDown = (event) => {
|
|
@@ -1,161 +1,7 @@
|
|
|
1
1
|
// ../../src/components/sidebar-layout/react.tsx
|
|
2
2
|
import { Link, Outlet } from "@tanstack/react-router";
|
|
3
|
-
import { Component as Component2, View
|
|
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
|
-
};
|
|
3
|
+
import { Component as Component2, View } from "effect/ui";
|
|
4
|
+
import { useModel } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
159
5
|
|
|
160
6
|
// ../../src/components/ui/badge.tsx
|
|
161
7
|
import { mergeProps } from "@base-ui/react/merge-props";
|
|
@@ -878,7 +724,7 @@ var sidebarLayoutBehaviours = {
|
|
|
878
724
|
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
879
725
|
var SidebarModel = Component2.define(sidebarLayoutOptions).make({
|
|
880
726
|
...sidebarLayoutBehaviours,
|
|
881
|
-
view: () =>
|
|
727
|
+
view: () => View.text("")
|
|
882
728
|
});
|
|
883
729
|
var useSidebarLayout = () => {
|
|
884
730
|
const { isMobile } = useSidebar();
|
|
@@ -1,167 +1,13 @@
|
|
|
1
|
-
// ../../src/lib/effect-ui-adapter/use-model.ts
|
|
2
|
-
import { MessageLog as MessageLog2 } from "effect/ui";
|
|
3
|
-
import {
|
|
4
|
-
createContext,
|
|
5
|
-
useCallback,
|
|
6
|
-
useContext,
|
|
7
|
-
useEffect,
|
|
8
|
-
useLayoutEffect,
|
|
9
|
-
useRef,
|
|
10
|
-
useState,
|
|
11
|
-
useSyncExternalStore
|
|
12
|
-
} from "react";
|
|
13
|
-
|
|
14
|
-
// ../../src/lib/effect-ui-adapter/model-runtime.ts
|
|
15
|
-
import { MessageLog, Renderer, View } from "effect/ui";
|
|
16
|
-
import { BrowserHost, Html } from "effect/ui/html";
|
|
17
|
-
import { Cause, Effect, Fiber } from "effect";
|
|
18
|
-
var node = () => ({ children: [] });
|
|
19
|
-
var modelHost = (commit) => {
|
|
20
|
-
const remove = (child) => {
|
|
21
|
-
if (!child.parent)
|
|
22
|
-
return;
|
|
23
|
-
child.parent.children.splice(child.parent.children.indexOf(child), 1);
|
|
24
|
-
delete child.parent;
|
|
25
|
-
};
|
|
26
|
-
return {
|
|
27
|
-
createElement: node,
|
|
28
|
-
createText: node,
|
|
29
|
-
setText: () => {},
|
|
30
|
-
setAttr: () => {},
|
|
31
|
-
setProp: () => {},
|
|
32
|
-
setEvents: () => {},
|
|
33
|
-
insertBefore: (parent, child, before) => {
|
|
34
|
-
if (child === before)
|
|
35
|
-
return;
|
|
36
|
-
remove(child);
|
|
37
|
-
const index = before ? parent.children.indexOf(before) : parent.children.length;
|
|
38
|
-
parent.children.splice(index, 0, child);
|
|
39
|
-
child.parent = parent;
|
|
40
|
-
},
|
|
41
|
-
remove,
|
|
42
|
-
parentOf: (child) => child.parent,
|
|
43
|
-
nextOf: (child) => child.parent?.children[child.parent.children.indexOf(child) + 1],
|
|
44
|
-
elements: ["html"],
|
|
45
|
-
controlled: new Set,
|
|
46
|
-
runsMounts: false,
|
|
47
|
-
commit
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
var mountModel = (component, props, publishSnapshot, messageLog, onEmit) => {
|
|
51
|
-
let currentProps = props;
|
|
52
|
-
let root;
|
|
53
|
-
let active = true;
|
|
54
|
-
let failure;
|
|
55
|
-
const publish = () => {
|
|
56
|
-
if (!active)
|
|
57
|
-
return;
|
|
58
|
-
if (failure) {
|
|
59
|
-
publishSnapshot({ error: failure });
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
const current = root?.model();
|
|
63
|
-
if (current !== undefined)
|
|
64
|
-
publishSnapshot({ model: current });
|
|
65
|
-
};
|
|
66
|
-
const fiber = Effect.runFork(Effect.scoped(Effect.gen(function* () {
|
|
67
|
-
const mounted = yield* Renderer.mount(component, Effect.succeed(props), node(), {
|
|
68
|
-
head: false,
|
|
69
|
-
onEmit,
|
|
70
|
-
fallback: ({ cause }) => {
|
|
71
|
-
failure = new Error("Effect UI root failed", {
|
|
72
|
-
cause: Cause.squash(cause)
|
|
73
|
-
});
|
|
74
|
-
return View.text("");
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
if (!active)
|
|
78
|
-
return;
|
|
79
|
-
root = mounted;
|
|
80
|
-
if (props !== currentProps)
|
|
81
|
-
mounted.setProps(currentProps);
|
|
82
|
-
publish();
|
|
83
|
-
return yield* Effect.never;
|
|
84
|
-
}).pipe(Effect.provide(Renderer.layer(modelHost(publish))), Effect.provideService(Html.Host, BrowserHost.htmlHost), Effect.provideService(MessageLog.MessageLog, messageLog))));
|
|
85
|
-
return {
|
|
86
|
-
send: (message) => {
|
|
87
|
-
root?.send(message);
|
|
88
|
-
publish();
|
|
89
|
-
},
|
|
90
|
-
setProps: (next) => {
|
|
91
|
-
currentProps = next;
|
|
92
|
-
root?.setProps(next);
|
|
93
|
-
},
|
|
94
|
-
dispose: () => {
|
|
95
|
-
active = false;
|
|
96
|
-
root = undefined;
|
|
97
|
-
Effect.runFork(Fiber.interrupt(fiber));
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
// ../../src/lib/effect-ui-adapter/use-model.ts
|
|
103
|
-
"use client";
|
|
104
|
-
var ModelMessageLogContext = createContext(undefined);
|
|
105
|
-
var useModel = (component, props, options = {}) => {
|
|
106
|
-
const contextLog = useContext(ModelMessageLogContext);
|
|
107
|
-
const messageLog = options.messageLog ?? (contextLog === undefined ? MessageLog2.noop : contextLog);
|
|
108
|
-
const [store] = useState(() => {
|
|
109
|
-
const initial = { model: component.init(props).model };
|
|
110
|
-
let snapshot = initial;
|
|
111
|
-
const listeners = new Set;
|
|
112
|
-
return {
|
|
113
|
-
subscribe: (listener) => {
|
|
114
|
-
listeners.add(listener);
|
|
115
|
-
return () => {
|
|
116
|
-
listeners.delete(listener);
|
|
117
|
-
};
|
|
118
|
-
},
|
|
119
|
-
getSnapshot: () => snapshot,
|
|
120
|
-
getServerSnapshot: () => initial,
|
|
121
|
-
publish: (next) => {
|
|
122
|
-
if ("model" in snapshot && "model" in next && Object.is(snapshot.model, next.model))
|
|
123
|
-
return;
|
|
124
|
-
if ("error" in snapshot && "error" in next && snapshot.error === next.error)
|
|
125
|
-
return;
|
|
126
|
-
snapshot = next;
|
|
127
|
-
listeners.forEach((listener) => listener());
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
});
|
|
131
|
-
const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);
|
|
132
|
-
const committed = useRef(props);
|
|
133
|
-
const onEmit = useRef(options.onEmit);
|
|
134
|
-
const runtime = useRef(undefined);
|
|
135
|
-
const send = useCallback((message) => runtime.current?.send(message), []);
|
|
136
|
-
useLayoutEffect(() => {
|
|
137
|
-
onEmit.current = options.onEmit;
|
|
138
|
-
committed.current = props;
|
|
139
|
-
runtime.current?.setProps(props);
|
|
140
|
-
}, [props, options.onEmit]);
|
|
141
|
-
useEffect(() => {
|
|
142
|
-
if (messageLog === null)
|
|
143
|
-
return;
|
|
144
|
-
const mounted = mountModel(component, committed.current, store.publish, messageLog, (event) => onEmit.current?.(event));
|
|
145
|
-
runtime.current = mounted;
|
|
146
|
-
return () => {
|
|
147
|
-
runtime.current = undefined;
|
|
148
|
-
mounted.dispose();
|
|
149
|
-
};
|
|
150
|
-
}, [component, messageLog, store]);
|
|
151
|
-
if ("error" in snapshot)
|
|
152
|
-
throw snapshot.error;
|
|
153
|
-
return { model: snapshot.model, send };
|
|
154
|
-
};
|
|
155
|
-
|
|
156
1
|
// ../../src/components/support/react.tsx
|
|
2
|
+
import { useModel } from "@krak-stack/registry/effect-ui-adapter/react";
|
|
157
3
|
import { Component as Component2 } from "effect/ui";
|
|
158
4
|
import { Option, Redacted as Redacted2, Schema as Schema5 } from "effect";
|
|
159
5
|
import { Check, Image, Paperclip, X } from "lucide-react";
|
|
160
6
|
import {
|
|
161
7
|
useId,
|
|
162
|
-
useLayoutEffect
|
|
163
|
-
useRef
|
|
164
|
-
useState
|
|
8
|
+
useLayoutEffect,
|
|
9
|
+
useRef,
|
|
10
|
+
useState
|
|
165
11
|
} from "react";
|
|
166
12
|
|
|
167
13
|
// ../../src/components/ui/button.tsx
|
|
@@ -430,8 +276,8 @@ function Textarea({ className, ...props }) {
|
|
|
430
276
|
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider/react";
|
|
431
277
|
|
|
432
278
|
// ../../src/components/support/index.ts
|
|
433
|
-
import { Command, Component, UiSchema, View
|
|
434
|
-
import { Effect
|
|
279
|
+
import { Command, Component, UiSchema, View } from "effect/ui";
|
|
280
|
+
import { Effect, Redacted, Schema as Schema3 } from "effect";
|
|
435
281
|
|
|
436
282
|
// ../../src/components/support/form.ts
|
|
437
283
|
import { Result, Schema as Schema2, SchemaIssue } from "effect";
|
|
@@ -693,7 +539,7 @@ class SendSupport extends Command.Service()("support/SendSupport", {
|
|
|
693
539
|
},
|
|
694
540
|
success: SupportMessage2
|
|
695
541
|
}) {
|
|
696
|
-
static layerFromSubmit = (submit) => SendSupport.toLayer(({ request }) =>
|
|
542
|
+
static layerFromSubmit = (submit) => SendSupport.toLayer(({ request }) => Effect.tryPromise(async () => submit(Redacted.value(request))).pipe(Effect.match({
|
|
697
543
|
onSuccess: () => SupportMessage2.SendFinished({ accepted: true }),
|
|
698
544
|
onFailure: () => SupportMessage2.SendFinished({ accepted: false })
|
|
699
545
|
})));
|
|
@@ -738,10 +584,10 @@ var supportBehaviours = {
|
|
|
738
584
|
};
|
|
739
585
|
var SupportDialogModel = SupportDefinition.make({
|
|
740
586
|
...supportBehaviours,
|
|
741
|
-
view: () =>
|
|
587
|
+
view: () => View.text("")
|
|
742
588
|
});
|
|
743
589
|
// ../../src/components/support/multipart.ts
|
|
744
|
-
import { Effect as
|
|
590
|
+
import { Effect as Effect2, FileSystem, Schema as Schema4 } from "effect";
|
|
745
591
|
import { Multipart } from "effect/http";
|
|
746
592
|
import { HttpApiSchema } from "effect/http-api";
|
|
747
593
|
var SupportMultipartPayload = Schema4.Struct({
|
|
@@ -758,9 +604,9 @@ var SupportMultipartPayload = Schema4.Struct({
|
|
|
758
604
|
|
|
759
605
|
class InvalidSupportScreenshot extends Schema4.TaggedError()("InvalidSupportScreenshot", {}) {
|
|
760
606
|
}
|
|
761
|
-
var readSupportScreenshots =
|
|
607
|
+
var readSupportScreenshots = Effect2.fn("Support.readScreenshots")(function* (files) {
|
|
762
608
|
const fs = yield* FileSystem.FileSystem;
|
|
763
|
-
return yield*
|
|
609
|
+
return yield* Effect2.forEach(files, (file, index) => Effect2.gen(function* () {
|
|
764
610
|
const format = screenshotFormats.get(file.contentType);
|
|
765
611
|
if (!format)
|
|
766
612
|
return yield* new InvalidSupportScreenshot;
|
|
@@ -824,7 +670,7 @@ var SupportFormView = ({
|
|
|
824
670
|
}) => {
|
|
825
671
|
const classes = resolveSupportClasses(classOverrides);
|
|
826
672
|
const id = useId();
|
|
827
|
-
const fileInput =
|
|
673
|
+
const fileInput = useRef(null);
|
|
828
674
|
const directEmail = Schema5.decodeUnknownOption(SupportReplyEmail)(supportEmail);
|
|
829
675
|
const pending = status === "pending";
|
|
830
676
|
const messageError = invalidFields?.includes("message") ? copy.invalidMessage ?? copy.invalid : undefined;
|
|
@@ -1081,7 +927,7 @@ var SupportWithSubmit = ({
|
|
|
1081
927
|
onSubmit
|
|
1082
928
|
}) => {
|
|
1083
929
|
const copy = useSupportFormMessages(locale, messages);
|
|
1084
|
-
const [submission] =
|
|
930
|
+
const [submission] = useState(() => {
|
|
1085
931
|
let submit = onSubmit;
|
|
1086
932
|
const component = SupportDialogModel.pipe(Component2.provide(SendSupport.layerFromSubmit((request) => submit(request))));
|
|
1087
933
|
return {
|
|
@@ -1091,7 +937,7 @@ var SupportWithSubmit = ({
|
|
|
1091
937
|
}
|
|
1092
938
|
};
|
|
1093
939
|
});
|
|
1094
|
-
|
|
940
|
+
useLayoutEffect(() => {
|
|
1095
941
|
submission.setSubmit(onSubmit);
|
|
1096
942
|
}, [onSubmit, submission]);
|
|
1097
943
|
return /* @__PURE__ */ jsx7(SupportModelView, {
|