@june-ai/june-ui 0.2.8 → 0.2.10
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 +5 -0
- package/dist/{chunk-3NVO336D.cjs → chunk-GS4J6OAF.cjs} +477 -201
- package/dist/{chunk-H26BMR5S.js → chunk-JFIMNFNJ.js} +375 -99
- package/dist/entry-core.cjs +2 -2
- package/dist/entry-core.js +1 -1
- package/dist/index.cjs +24 -7
- package/dist/index.d.cts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +20 -3
- package/dist/june.css +41 -0
- package/docs/troubleshooting.md +1 -1
- package/package.json +1 -1
|
@@ -22,55 +22,126 @@
|
|
|
22
22
|
var _chunkG6YPSE6Jcjs = require('./chunk-G6YPSE6J.cjs');
|
|
23
23
|
|
|
24
24
|
// src/engine/openui-devtools.tsx
|
|
25
|
+
var _react = require('react');
|
|
25
26
|
var _devtools = require('@openuidev/devtools');
|
|
26
27
|
var _jsxruntime = require('react/jsx-runtime');
|
|
27
28
|
var AUTO_MOUNT_FLAG = /* @__PURE__ */ Symbol.for("openui.devtools.autoMount");
|
|
28
29
|
var BLOCKED_BY_JUNE = /* @__PURE__ */ Symbol.for("openui.devtools.blockedByJune");
|
|
30
|
+
var AUTO_MOUNT_HOST = "data-openui-devtools-auto-mount";
|
|
29
31
|
var flags = globalThis;
|
|
30
|
-
var scheduledByOpenUI = flags[AUTO_MOUNT_FLAG] === true && flags[BLOCKED_BY_JUNE] !== true;
|
|
31
32
|
flags[AUTO_MOUNT_FLAG] = true;
|
|
32
33
|
flags[BLOCKED_BY_JUNE] = true;
|
|
33
34
|
var DEVTOOLS_BUNDLE = "https://cdn.jsdelivr.net/npm/@openuidev/devtools@0/dist/devtools.browser.js";
|
|
34
35
|
var ALIAS_CACHE_MS = 5 * 60 * 1e3;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
36
|
+
var LOCAL_WIDGET = "../../node_modules/@openuidev/devtools/dist/devtools.browser.js";
|
|
37
|
+
var loadFromCdn = () => {
|
|
38
38
|
const url = `${DEVTOOLS_BUNDLE}?t=${Math.floor(Date.now() / ALIAS_CACHE_MS)}`;
|
|
39
|
-
|
|
40
|
-
let unmount = () => {
|
|
41
|
-
cancelled = true;
|
|
42
|
-
};
|
|
43
|
-
void Promise.all([
|
|
39
|
+
return Promise.all([
|
|
44
40
|
Promise.resolve().then(() => _interopRequireWildcard(require(
|
|
41
|
+
/* webpackIgnore: true */
|
|
45
42
|
/* @vite-ignore */
|
|
46
43
|
url
|
|
47
44
|
))),
|
|
48
45
|
Promise.resolve().then(() => _interopRequireWildcard(require("react"))),
|
|
49
46
|
Promise.resolve().then(() => _interopRequireWildcard(require("react-dom"))),
|
|
50
47
|
Promise.resolve().then(() => _interopRequireWildcard(require("react-dom/client")))
|
|
51
|
-
])
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
]);
|
|
49
|
+
};
|
|
50
|
+
var loadInstalledOrCdn = async () => {
|
|
51
|
+
const [react, reactDom, reactDomClient] = await Promise.all([
|
|
52
|
+
Promise.resolve().then(() => _interopRequireWildcard(require("react"))),
|
|
53
|
+
Promise.resolve().then(() => _interopRequireWildcard(require("react-dom"))),
|
|
54
|
+
Promise.resolve().then(() => _interopRequireWildcard(require("react-dom/client")))
|
|
55
|
+
]);
|
|
56
|
+
try {
|
|
57
|
+
const devtools = await Promise.resolve().then(() => _interopRequireWildcard(require(LOCAL_WIDGET)));
|
|
58
|
+
return [devtools, react, reactDom, reactDomClient];
|
|
59
|
+
} catch (e2) {
|
|
60
|
+
const [devtools] = await loadFromCdn();
|
|
61
|
+
return [devtools, react, reactDom, reactDomClient];
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
function nodeEnv() {
|
|
65
|
+
try {
|
|
66
|
+
return process.env.NODE_ENV;
|
|
67
|
+
} catch (e3) {
|
|
68
|
+
return void 0;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
var isAutoMountHost = (node) => node instanceof Element && node.hasAttribute(AUTO_MOUNT_HOST);
|
|
72
|
+
function createDevtoolsGuard(load = loadInstalledOrCdn) {
|
|
73
|
+
let started = false;
|
|
74
|
+
let claimed = false;
|
|
75
|
+
let observer = null;
|
|
76
|
+
let unmount = null;
|
|
77
|
+
let stopped = false;
|
|
78
|
+
const claim = () => {
|
|
79
|
+
if (claimed) return;
|
|
80
|
+
claimed = true;
|
|
81
|
+
_optionalChain([observer, 'optionalAccess', _2 => _2.disconnect, 'call', _3 => _3()]);
|
|
82
|
+
observer = null;
|
|
83
|
+
load().then(([devtools, react, reactDom, reactDomClient]) => {
|
|
84
|
+
if (stopped) return;
|
|
85
|
+
unmount = devtools.mountOpenUIDevtools({
|
|
86
|
+
React: react,
|
|
87
|
+
ReactDOM: reactDom,
|
|
88
|
+
ReactDOMClient: reactDomClient,
|
|
89
|
+
loadReactLang: () => Promise.resolve().then(() => _interopRequireWildcard(require("@openuidev/react-lang"))),
|
|
90
|
+
props: { enabled: false }
|
|
91
|
+
});
|
|
92
|
+
}).catch(() => {
|
|
59
93
|
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
94
|
+
};
|
|
95
|
+
const watch = () => {
|
|
96
|
+
const body = document.body;
|
|
97
|
+
if (!body) return;
|
|
98
|
+
if (Array.from(body.children).some(isAutoMountHost)) {
|
|
99
|
+
claim();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (typeof MutationObserver === "undefined") return;
|
|
103
|
+
observer = new MutationObserver((records) => {
|
|
104
|
+
if (records.some((r) => Array.from(r.addedNodes).some(isAutoMountHost))) claim();
|
|
105
|
+
});
|
|
106
|
+
observer.observe(body, { childList: true });
|
|
107
|
+
};
|
|
108
|
+
return {
|
|
109
|
+
/** Starts watching (browser only). Safe to call many times. */
|
|
110
|
+
start() {
|
|
111
|
+
if (started || typeof document === "undefined") return;
|
|
112
|
+
started = true;
|
|
113
|
+
if (document.body) watch();
|
|
114
|
+
else document.addEventListener("DOMContentLoaded", watch, { once: true });
|
|
115
|
+
},
|
|
116
|
+
/** True once the disabled widget has been requested. */
|
|
117
|
+
get claimed() {
|
|
118
|
+
return claimed;
|
|
119
|
+
},
|
|
120
|
+
/** Stops watching and removes the disabled widget (tests, teardown). */
|
|
121
|
+
stop() {
|
|
122
|
+
stopped = true;
|
|
123
|
+
_optionalChain([observer, 'optionalAccess', _4 => _4.disconnect, 'call', _5 => _5()]);
|
|
124
|
+
observer = null;
|
|
125
|
+
_optionalChain([unmount, 'optionalCall', _6 => _6()]);
|
|
126
|
+
unmount = null;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
63
129
|
}
|
|
64
|
-
|
|
65
|
-
|
|
130
|
+
var guard = createDevtoolsGuard();
|
|
131
|
+
function hideOpenUIDevtools() {
|
|
132
|
+
if (nodeEnv() === "development") guard.start();
|
|
66
133
|
}
|
|
134
|
+
hideOpenUIDevtools();
|
|
67
135
|
function OpenUIDevtoolsGate() {
|
|
136
|
+
_react.useEffect.call(void 0, () => {
|
|
137
|
+
hideOpenUIDevtools();
|
|
138
|
+
}, []);
|
|
68
139
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _devtools.OpenUIDevtools, { enabled: false });
|
|
69
140
|
}
|
|
70
141
|
|
|
71
142
|
// src/engine/renderer/june-renderer.tsx
|
|
72
143
|
var _reactlang = require('@openuidev/react-lang');
|
|
73
|
-
|
|
144
|
+
|
|
74
145
|
|
|
75
146
|
// src/core/context.ts
|
|
76
147
|
|
|
@@ -108,7 +179,7 @@ async function runAction(event, options) {
|
|
|
108
179
|
const parsed = parseEvent(event);
|
|
109
180
|
const action = parsed && Object.prototype.hasOwnProperty.call(actions, parsed.name) ? actions[parsed.name] : void 0;
|
|
110
181
|
if (!parsed || !action) {
|
|
111
|
-
_optionalChain([onUnhandled, 'optionalCall',
|
|
182
|
+
_optionalChain([onUnhandled, 'optionalCall', _7 => _7(event)]);
|
|
112
183
|
return "unhandled";
|
|
113
184
|
}
|
|
114
185
|
const { name } = parsed;
|
|
@@ -116,7 +187,7 @@ async function runAction(event, options) {
|
|
|
116
187
|
if (action.schema) {
|
|
117
188
|
const result = action.schema.safeParse(payload);
|
|
118
189
|
if (!result.success) {
|
|
119
|
-
_optionalChain([onError, 'optionalCall',
|
|
190
|
+
_optionalChain([onError, 'optionalCall', _8 => _8(
|
|
120
191
|
new (0, _chunkG6YPSE6Jcjs.JuneError)("ACTION_VALIDATION_ERROR", `Invalid payload for action "${name}"`, {
|
|
121
192
|
details: result.error
|
|
122
193
|
})
|
|
@@ -129,7 +200,7 @@ async function runAction(event, options) {
|
|
|
129
200
|
if (action.sensitive || action.confirm) {
|
|
130
201
|
const ask = _nullishCoalesce(action.confirm, () => ( confirm));
|
|
131
202
|
if (!ask) {
|
|
132
|
-
_optionalChain([onError, 'optionalCall',
|
|
203
|
+
_optionalChain([onError, 'optionalCall', _9 => _9(
|
|
133
204
|
new (0, _chunkG6YPSE6Jcjs.JuneError)(
|
|
134
205
|
"ACTION_REJECTED",
|
|
135
206
|
`Action "${name}" requires confirmation but no confirm handler was provided`
|
|
@@ -143,7 +214,7 @@ async function runAction(event, options) {
|
|
|
143
214
|
await action.handler(payload, { name, event });
|
|
144
215
|
return "handled";
|
|
145
216
|
} catch (error) {
|
|
146
|
-
_optionalChain([onError, 'optionalCall',
|
|
217
|
+
_optionalChain([onError, 'optionalCall', _10 => _10(_chunkG6YPSE6Jcjs.toJuneError.call(void 0, error, "ACTION_ERROR"))]);
|
|
147
218
|
return "failed";
|
|
148
219
|
}
|
|
149
220
|
}
|
|
@@ -351,7 +422,7 @@ function createDocumentStore() {
|
|
|
351
422
|
},
|
|
352
423
|
resolve(id, choice) {
|
|
353
424
|
const current = records.get(id);
|
|
354
|
-
const pending = _optionalChain([current, 'optionalAccess',
|
|
425
|
+
const pending = _optionalChain([current, 'optionalAccess', _11 => _11.pending]);
|
|
355
426
|
if (!current || !pending) return;
|
|
356
427
|
if (choice === "keep") {
|
|
357
428
|
put({ ...current, baseJson: pending.json, baseTitle: pending.title, pending: null });
|
|
@@ -387,7 +458,7 @@ function rememberDocumentEcho(store, id, content) {
|
|
|
387
458
|
byId.set(id, list2);
|
|
388
459
|
}
|
|
389
460
|
function isDocumentEcho(store, id, content) {
|
|
390
|
-
return !!content && !!_optionalChain([echoes, 'access',
|
|
461
|
+
return !!content && !!_optionalChain([echoes, 'access', _12 => _12.get, 'call', _13 => _13(store), 'optionalAccess', _14 => _14.get, 'call', _15 => _15(id), 'optionalAccess', _16 => _16.includes, 'call', _17 => _17(content)]);
|
|
391
462
|
}
|
|
392
463
|
var defaultStore = null;
|
|
393
464
|
function getDefaultDocumentStore() {
|
|
@@ -440,7 +511,7 @@ function updateDocumentInProgram(program, documentId, update, componentName = "D
|
|
|
440
511
|
if (program[i] === ",") i++;
|
|
441
512
|
else break;
|
|
442
513
|
}
|
|
443
|
-
if (_optionalChain([args, 'access',
|
|
514
|
+
if (_optionalChain([args, 'access', _18 => _18[0], 'optionalAccess', _19 => _19.value]) !== documentId) continue;
|
|
444
515
|
const edits = [];
|
|
445
516
|
if (update.title !== void 0 && args[1] && args[1].value !== update.title) {
|
|
446
517
|
edits.push({ start: args[1].start, end: args[1].end, text: toLangString(update.title) });
|
|
@@ -472,7 +543,7 @@ function readDocumentFromProgram(program, documentId, componentName = "DocumentE
|
|
|
472
543
|
if (program[i] === ",") i++;
|
|
473
544
|
else break;
|
|
474
545
|
}
|
|
475
|
-
if (_optionalChain([args, 'access',
|
|
546
|
+
if (_optionalChain([args, 'access', _20 => _20[0], 'optionalAccess', _21 => _21.value]) === documentId && args[1] && args[2]) return { title: args[1].value, content: args[2].value };
|
|
476
547
|
}
|
|
477
548
|
return null;
|
|
478
549
|
}
|
|
@@ -493,8 +564,8 @@ function useDocumentBridge(options) {
|
|
|
493
564
|
const syncProgram = _react.useCallback.call(void 0, async (change, store) => {
|
|
494
565
|
if (!latest.current.onResponseChange || typeof latest.current.response !== "string") return;
|
|
495
566
|
const record = store.get(change.documentId);
|
|
496
|
-
const title = _nullishCoalesce(_optionalChain([record, 'optionalAccess',
|
|
497
|
-
const json = _nullishCoalesce(_optionalChain([record, 'optionalAccess',
|
|
567
|
+
const title = _nullishCoalesce(_optionalChain([record, 'optionalAccess', _22 => _22.title]), () => ( change.title));
|
|
568
|
+
const json = _nullishCoalesce(_optionalChain([record, 'optionalAccess', _23 => _23.json]), () => ( change.json));
|
|
498
569
|
try {
|
|
499
570
|
const { docToMarkdown: docToMarkdown2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./document-engine-GXZH2LNW.cjs")));
|
|
500
571
|
const markdown = docToMarkdown2(json);
|
|
@@ -503,18 +574,18 @@ function useDocumentBridge(options) {
|
|
|
503
574
|
const next = updateDocumentInProgram(program, change.documentId, { title, content: markdown });
|
|
504
575
|
if (next === null || next === program) return;
|
|
505
576
|
rememberDocumentEcho(store, change.documentId, markdown);
|
|
506
|
-
_optionalChain([latest, 'access',
|
|
577
|
+
_optionalChain([latest, 'access', _24 => _24.current, 'access', _25 => _25.onResponseChange, 'optionalCall', _26 => _26(next, { documentId: change.documentId, title, markdown, source: change.source })]);
|
|
507
578
|
} catch (error) {
|
|
508
|
-
_optionalChain([latest, 'access',
|
|
579
|
+
_optionalChain([latest, 'access', _27 => _27.current, 'access', _28 => _28.onJuneError, 'optionalCall', _29 => _29(_chunkG6YPSE6Jcjs.toJuneError.call(void 0, error, "DOCUMENT_ERROR", "Updating the program failed"))]);
|
|
509
580
|
}
|
|
510
581
|
}, []);
|
|
511
582
|
return _react.useMemo.call(void 0,
|
|
512
583
|
() => ({
|
|
513
584
|
...documents,
|
|
514
585
|
onDocumentChange: (change) => {
|
|
515
|
-
_optionalChain([documents, 'optionalAccess',
|
|
586
|
+
_optionalChain([documents, 'optionalAccess', _30 => _30.onDocumentChange, 'optionalCall', _31 => _31(change)]);
|
|
516
587
|
if (!latest.current.onResponseChange || change.source === "ai") return;
|
|
517
|
-
const store = _nullishCoalesce(_optionalChain([documents, 'optionalAccess',
|
|
588
|
+
const store = _nullishCoalesce(_optionalChain([documents, 'optionalAccess', _32 => _32.store]), () => ( getDefaultDocumentStore()));
|
|
518
589
|
const timers = timersRef.current;
|
|
519
590
|
const prev = timers.get(change.documentId);
|
|
520
591
|
if (prev) clearTimeout(prev);
|
|
@@ -527,8 +598,8 @@ function useDocumentBridge(options) {
|
|
|
527
598
|
);
|
|
528
599
|
},
|
|
529
600
|
onError: (error) => {
|
|
530
|
-
_optionalChain([documents, 'optionalAccess',
|
|
531
|
-
_optionalChain([latest, 'access',
|
|
601
|
+
_optionalChain([documents, 'optionalAccess', _33 => _33.onError, 'optionalCall', _34 => _34(error)]);
|
|
602
|
+
_optionalChain([latest, 'access', _35 => _35.current, 'access', _36 => _36.onJuneError, 'optionalCall', _37 => _37(error)]);
|
|
532
603
|
}
|
|
533
604
|
}),
|
|
534
605
|
[documents, syncProgram]
|
|
@@ -592,7 +663,7 @@ function subscribe(onChange) {
|
|
|
592
663
|
}
|
|
593
664
|
function getSnapshot() {
|
|
594
665
|
if (typeof window === "undefined") return "light";
|
|
595
|
-
return _optionalChain([window, 'access',
|
|
666
|
+
return _optionalChain([window, 'access', _38 => _38.matchMedia, 'optionalCall', _39 => _39(QUERY), 'optionalAccess', _40 => _40.matches]) ? "dark" : "light";
|
|
596
667
|
}
|
|
597
668
|
function getServerSnapshot() {
|
|
598
669
|
return "light";
|
|
@@ -652,8 +723,10 @@ var ATTACHABLE = /* @__PURE__ */ new Set([
|
|
|
652
723
|
"ImageGallery",
|
|
653
724
|
"InlineHeader",
|
|
654
725
|
"LineChart",
|
|
726
|
+
"FollowUpBlock",
|
|
655
727
|
"ListBlock",
|
|
656
728
|
"MarkDownRenderer",
|
|
729
|
+
"SectionBlock",
|
|
657
730
|
"Modal",
|
|
658
731
|
"OverviewCardBlock",
|
|
659
732
|
"PieChart",
|
|
@@ -674,7 +747,7 @@ var ATTACHABLE = /* @__PURE__ */ new Set([
|
|
|
674
747
|
]);
|
|
675
748
|
function normalizeProgram(source) {
|
|
676
749
|
const rewritten = rewriteCalls(source);
|
|
677
|
-
return attachOrphans(rewritten);
|
|
750
|
+
return liftStackRoot(attachOrphans(rewritten));
|
|
678
751
|
}
|
|
679
752
|
function rewriteCalls(source) {
|
|
680
753
|
let out = "";
|
|
@@ -818,19 +891,31 @@ function attachOrphans(source) {
|
|
|
818
891
|
if (orphans.length === 0) return source;
|
|
819
892
|
const names = orphans.map((stmt) => stmt.name);
|
|
820
893
|
const root = stmts.find((stmt) => stmt.name === "root");
|
|
821
|
-
if (!root) return `root =
|
|
894
|
+
if (!root) return `root = Card([${names.join(", ")}])
|
|
822
895
|
${text}`;
|
|
823
896
|
const rawRhs = text.slice(root.rhsStart, root.end);
|
|
824
|
-
const lead = _nullishCoalesce(_optionalChain([/^\s*/, 'access',
|
|
897
|
+
const lead = _nullishCoalesce(_optionalChain([/^\s*/, 'access', _41 => _41.exec, 'call', _42 => _42(rawRhs), 'optionalAccess', _43 => _43[0]]), () => ( ""));
|
|
825
898
|
const spliced = spliceFirstArray(rawRhs.trim(), names);
|
|
826
899
|
if (spliced !== null) {
|
|
827
900
|
return text.slice(0, root.rhsStart) + lead + spliced + text.slice(root.end);
|
|
828
901
|
}
|
|
829
902
|
const body = fresh(new Set(stmts.map((stmt) => stmt.name)), "rootBody");
|
|
830
|
-
const wrapped = `root =
|
|
903
|
+
const wrapped = `root = Card([${body}, ${names.join(", ")}])
|
|
831
904
|
${body} = ${rawRhs.trim()}`;
|
|
832
905
|
return text.slice(0, root.start) + wrapped + text.slice(root.end);
|
|
833
906
|
}
|
|
907
|
+
function liftStackRoot(source) {
|
|
908
|
+
const stmts = parseStatements(source);
|
|
909
|
+
if (!stmts) return source;
|
|
910
|
+
const root = stmts.find((stmt) => stmt.name === "root");
|
|
911
|
+
if (!root) return source;
|
|
912
|
+
const rhs = source.slice(root.rhsStart, root.end).trim();
|
|
913
|
+
if (!/^Stack\s*\(/.test(rhs)) return source;
|
|
914
|
+
const body = fresh(new Set(stmts.map((stmt) => stmt.name)), "rootLayout");
|
|
915
|
+
const wrapped = `root = Card([${body}])
|
|
916
|
+
${body} = ${rhs}`;
|
|
917
|
+
return source.slice(0, root.start) + wrapped + source.slice(root.end);
|
|
918
|
+
}
|
|
834
919
|
function spliceFirstArray(rhs, names) {
|
|
835
920
|
const match = /^([A-Za-z_]\w*)\s*\(/.exec(rhs);
|
|
836
921
|
if (!match || match[1] !== "Stack" && match[1] !== "Card") return null;
|
|
@@ -971,7 +1056,7 @@ var STATEMENT_START = /^\$?[A-Za-z_]\w*\s*=/;
|
|
|
971
1056
|
var PENDING_IDENTIFIER = /^\s*\$?[A-Za-z_]\w*\s*$/;
|
|
972
1057
|
var FENCE = /^(`{3,})\s*([\w-]*)/;
|
|
973
1058
|
var OPENUI_FENCE_LANGS = /* @__PURE__ */ new Set(["", "openui", "openui-lang", "openuilang"]);
|
|
974
|
-
function scan(line, state) {
|
|
1059
|
+
function scan(line, state, preserveQuote = false) {
|
|
975
1060
|
for (let i = 0; i < line.length; i++) {
|
|
976
1061
|
const ch = line[i];
|
|
977
1062
|
if (state.quote) {
|
|
@@ -985,7 +1070,95 @@ function scan(line, state) {
|
|
|
985
1070
|
state.depth = Math.max(0, state.depth - 1);
|
|
986
1071
|
}
|
|
987
1072
|
}
|
|
988
|
-
state.quote = null;
|
|
1073
|
+
if (!preserveQuote) state.quote = null;
|
|
1074
|
+
}
|
|
1075
|
+
function quoteClosesLater(lines, from, state) {
|
|
1076
|
+
const probe = { depth: state.depth, quote: state.quote };
|
|
1077
|
+
for (let i = from; i < lines.length; i++) {
|
|
1078
|
+
const line = lines[i];
|
|
1079
|
+
if (probe.depth === 0 && STATEMENT_START.test(line.trim())) return false;
|
|
1080
|
+
scan(line, probe, true);
|
|
1081
|
+
if (!probe.quote) return true;
|
|
1082
|
+
}
|
|
1083
|
+
return false;
|
|
1084
|
+
}
|
|
1085
|
+
function decodeLangString(raw) {
|
|
1086
|
+
let out = "";
|
|
1087
|
+
for (let i = 0; i < raw.length; i++) {
|
|
1088
|
+
const ch = raw[i];
|
|
1089
|
+
if (ch === "\\" && i + 1 < raw.length) {
|
|
1090
|
+
const next = raw[i + 1];
|
|
1091
|
+
out += next === "n" ? "\n" : next === "t" ? " " : next === "r" ? "\r" : next === "b" ? "\b" : next === "f" ? "\f" : next;
|
|
1092
|
+
i++;
|
|
1093
|
+
continue;
|
|
1094
|
+
}
|
|
1095
|
+
out += ch;
|
|
1096
|
+
}
|
|
1097
|
+
return out.replace(/\r/g, "");
|
|
1098
|
+
}
|
|
1099
|
+
function foldMultilineStrings(source) {
|
|
1100
|
+
let out = "";
|
|
1101
|
+
let i = 0;
|
|
1102
|
+
while (i < source.length) {
|
|
1103
|
+
if (source.startsWith('"""', i)) {
|
|
1104
|
+
const end = source.indexOf('"""', i + 3);
|
|
1105
|
+
if (end < 0) {
|
|
1106
|
+
const nl = source.indexOf("\n", i);
|
|
1107
|
+
if (nl < 0) {
|
|
1108
|
+
out += source.slice(i);
|
|
1109
|
+
break;
|
|
1110
|
+
}
|
|
1111
|
+
out += source.slice(i, nl + 1);
|
|
1112
|
+
i = nl + 1;
|
|
1113
|
+
continue;
|
|
1114
|
+
}
|
|
1115
|
+
out += JSON.stringify(source.slice(i + 3, end).replace(/\r/g, ""));
|
|
1116
|
+
i = end + 3;
|
|
1117
|
+
continue;
|
|
1118
|
+
}
|
|
1119
|
+
if (source[i] !== '"') {
|
|
1120
|
+
out += source[i];
|
|
1121
|
+
i++;
|
|
1122
|
+
continue;
|
|
1123
|
+
}
|
|
1124
|
+
let j = i + 1;
|
|
1125
|
+
let closed = false;
|
|
1126
|
+
let hasNewline = false;
|
|
1127
|
+
while (j < source.length) {
|
|
1128
|
+
const ch = source[j];
|
|
1129
|
+
if (ch === "\\") {
|
|
1130
|
+
j += 2;
|
|
1131
|
+
continue;
|
|
1132
|
+
}
|
|
1133
|
+
if (ch === "\n") {
|
|
1134
|
+
if (STATEMENT_START.test(source.slice(j + 1))) break;
|
|
1135
|
+
hasNewline = true;
|
|
1136
|
+
}
|
|
1137
|
+
if (ch === '"') {
|
|
1138
|
+
closed = true;
|
|
1139
|
+
break;
|
|
1140
|
+
}
|
|
1141
|
+
j++;
|
|
1142
|
+
}
|
|
1143
|
+
if (!closed) {
|
|
1144
|
+
const nl = source.indexOf("\n", i);
|
|
1145
|
+
if (nl < 0) {
|
|
1146
|
+
out += source.slice(i);
|
|
1147
|
+
break;
|
|
1148
|
+
}
|
|
1149
|
+
out += source.slice(i, nl + 1);
|
|
1150
|
+
i = nl + 1;
|
|
1151
|
+
continue;
|
|
1152
|
+
}
|
|
1153
|
+
if (!hasNewline) {
|
|
1154
|
+
out += source.slice(i, j + 1);
|
|
1155
|
+
i = j + 1;
|
|
1156
|
+
continue;
|
|
1157
|
+
}
|
|
1158
|
+
out += JSON.stringify(decodeLangString(source.slice(i + 1, j)));
|
|
1159
|
+
i = j + 1;
|
|
1160
|
+
}
|
|
1161
|
+
return out;
|
|
989
1162
|
}
|
|
990
1163
|
function splitResponse(source, options = {}) {
|
|
991
1164
|
const markdown = options.markdown === true;
|
|
@@ -1007,8 +1180,15 @@ function splitResponse(source, options = {}) {
|
|
|
1007
1180
|
text = [];
|
|
1008
1181
|
if (joined) (seenUi ? after : before).push(joined);
|
|
1009
1182
|
};
|
|
1010
|
-
|
|
1183
|
+
const lines = input.split(/\r?\n/);
|
|
1184
|
+
for (let index = 0; index < lines.length; index++) {
|
|
1185
|
+
const line = lines[index];
|
|
1011
1186
|
const trimmed = line.trim();
|
|
1187
|
+
if (state.quote) {
|
|
1188
|
+
ui.push(line);
|
|
1189
|
+
scan(line, state, true);
|
|
1190
|
+
continue;
|
|
1191
|
+
}
|
|
1012
1192
|
if (codeFence !== null) {
|
|
1013
1193
|
text.push(line);
|
|
1014
1194
|
if (trimmed.startsWith(codeFence)) {
|
|
@@ -1037,7 +1217,8 @@ function splitResponse(source, options = {}) {
|
|
|
1037
1217
|
flushText();
|
|
1038
1218
|
seenUi = true;
|
|
1039
1219
|
ui.push(line);
|
|
1040
|
-
scan(line, state);
|
|
1220
|
+
scan(line, state, true);
|
|
1221
|
+
if (state.quote && !quoteClosesLater(lines, index + 1, state)) state.quote = null;
|
|
1041
1222
|
continue;
|
|
1042
1223
|
}
|
|
1043
1224
|
if (trimmed === "") {
|
|
@@ -1049,7 +1230,7 @@ function splitResponse(source, options = {}) {
|
|
|
1049
1230
|
flushText();
|
|
1050
1231
|
return {
|
|
1051
1232
|
before,
|
|
1052
|
-
ui: ui.join("\n"),
|
|
1233
|
+
ui: foldMultilineStrings(ui.join("\n")),
|
|
1053
1234
|
after,
|
|
1054
1235
|
pure: !sawFence && before.length === 0 && after.length === 0
|
|
1055
1236
|
};
|
|
@@ -1059,10 +1240,10 @@ function splitResponse(source, options = {}) {
|
|
|
1059
1240
|
function resolveMixedContent(response, options = {}) {
|
|
1060
1241
|
const { mixedContent = true, isStreaming = false, repair = true, markdown = false } = options;
|
|
1061
1242
|
const parts = mixedContent && response ? splitResponse(response, { streaming: isStreaming, markdown }) : null;
|
|
1062
|
-
const raw = parts && !parts.pure ? parts.ui : response;
|
|
1243
|
+
const raw = parts && !parts.pure ? parts.ui : typeof response === "string" ? foldMultilineStrings(response) : response;
|
|
1063
1244
|
const ui = !repair || !mixedContent || isStreaming || typeof raw !== "string" || raw.length === 0 ? raw : normalizeProgram(raw);
|
|
1064
|
-
const before = _nullishCoalesce(_optionalChain([parts, 'optionalAccess',
|
|
1065
|
-
const after = _nullishCoalesce(_optionalChain([parts, 'optionalAccess',
|
|
1245
|
+
const before = _nullishCoalesce(_optionalChain([parts, 'optionalAccess', _44 => _44.before]), () => ( []));
|
|
1246
|
+
const after = _nullishCoalesce(_optionalChain([parts, 'optionalAccess', _45 => _45.after]), () => ( []));
|
|
1066
1247
|
return {
|
|
1067
1248
|
before,
|
|
1068
1249
|
ui,
|
|
@@ -1090,7 +1271,7 @@ var JuneErrorBoundary = class extends _react.Component {
|
|
|
1090
1271
|
return { error };
|
|
1091
1272
|
}
|
|
1092
1273
|
componentDidCatch(error, info) {
|
|
1093
|
-
_optionalChain([this, 'access',
|
|
1274
|
+
_optionalChain([this, 'access', _46 => _46.props, 'access', _47 => _47.onError, 'optionalCall', _48 => _48(error, info)]);
|
|
1094
1275
|
}
|
|
1095
1276
|
componentDidUpdate(prev) {
|
|
1096
1277
|
if (this.state.error && keysChanged(prev.resetKeys, this.props.resetKeys)) {
|
|
@@ -1151,37 +1332,37 @@ function JuneRenderer(props) {
|
|
|
1151
1332
|
latest.current = { actions, confirmAction, parseActionEvent, onAction, onError, onJuneError };
|
|
1152
1333
|
const handleAction = _react.useCallback.call(void 0, (event) => {
|
|
1153
1334
|
const l = latest.current;
|
|
1154
|
-
_optionalChain([l, 'access',
|
|
1335
|
+
_optionalChain([l, 'access', _49 => _49.onAction, 'optionalCall', _50 => _50(event)]);
|
|
1155
1336
|
if (l.actions) {
|
|
1156
1337
|
void runAction(event, {
|
|
1157
1338
|
actions: l.actions,
|
|
1158
1339
|
parseEvent: l.parseActionEvent,
|
|
1159
1340
|
confirm: l.confirmAction,
|
|
1160
|
-
onError: (e) => _optionalChain([l, 'access',
|
|
1341
|
+
onError: (e) => _optionalChain([l, 'access', _51 => _51.onJuneError, 'optionalCall', _52 => _52(e)])
|
|
1161
1342
|
});
|
|
1162
1343
|
}
|
|
1163
1344
|
}, []);
|
|
1164
1345
|
const handleParserErrors = _react.useCallback.call(void 0, (errors) => {
|
|
1165
1346
|
const list2 = Array.isArray(errors) ? errors : [];
|
|
1166
1347
|
const l = latest.current;
|
|
1167
|
-
_optionalChain([l, 'access',
|
|
1168
|
-
const real = list2.filter((e) => _optionalChain([e, 'optionalAccess',
|
|
1348
|
+
_optionalChain([l, 'access', _53 => _53.onError, 'optionalCall', _54 => _54(list2)]);
|
|
1349
|
+
const real = list2.filter((e) => _optionalChain([e, 'optionalAccess', _55 => _55.severity]) !== "warning");
|
|
1169
1350
|
if (real.length > 0) {
|
|
1170
|
-
_optionalChain([l, 'access',
|
|
1351
|
+
_optionalChain([l, 'access', _56 => _56.onJuneError, 'optionalCall', _57 => _57(new (0, _chunkG6YPSE6Jcjs.JuneError)("PARSE_ERROR", `OpenUI reported ${real.length} error(s)`, { details: real }))]);
|
|
1171
1352
|
}
|
|
1172
1353
|
if (list2.length > 0 && !l.onError && !l.onJuneError) {
|
|
1173
1354
|
console.warn("[june-ui] OpenUI reported errors:", list2);
|
|
1174
1355
|
}
|
|
1175
1356
|
}, []);
|
|
1176
1357
|
const handleBoundaryError = _react.useCallback.call(void 0, (error, info) => {
|
|
1177
|
-
_optionalChain([latest, 'access',
|
|
1358
|
+
_optionalChain([latest, 'access', _58 => _58.current, 'access', _59 => _59.onJuneError, 'optionalCall', _60 => _60(
|
|
1178
1359
|
new (0, _chunkG6YPSE6Jcjs.JuneError)("RENDER_ERROR", error.message, {
|
|
1179
1360
|
cause: error,
|
|
1180
1361
|
details: { componentStack: info.componentStack }
|
|
1181
1362
|
})
|
|
1182
1363
|
)]);
|
|
1183
1364
|
}, []);
|
|
1184
|
-
const handleDocumentError = _react.useCallback.call(void 0, (error) => _optionalChain([latest, 'access',
|
|
1365
|
+
const handleDocumentError = _react.useCallback.call(void 0, (error) => _optionalChain([latest, 'access', _61 => _61.current, 'access', _62 => _62.onJuneError, 'optionalCall', _63 => _63(error)]), []);
|
|
1185
1366
|
const runtime = _react.useMemo.call(void 0, () => ({ isStreaming }), [isStreaming]);
|
|
1186
1367
|
const content = _react.useMemo.call(void 0,
|
|
1187
1368
|
() => resolveMixedContent(response, { mixedContent, isStreaming, repair, markdown: textFormat === "markdown" }),
|
|
@@ -1227,8 +1408,8 @@ function JuneRenderer(props) {
|
|
|
1227
1408
|
|
|
1228
1409
|
var NAME = /^[A-Z][A-Za-z0-9_]*$/;
|
|
1229
1410
|
function isZodObject(value) {
|
|
1230
|
-
const def = _optionalChain([value, 'optionalAccess',
|
|
1231
|
-
return _optionalChain([def, 'optionalAccess',
|
|
1411
|
+
const def = _optionalChain([value, 'optionalAccess', _64 => _64._zod, 'optionalAccess', _65 => _65.def]);
|
|
1412
|
+
return _optionalChain([def, 'optionalAccess', _66 => _66.type]) === "object";
|
|
1232
1413
|
}
|
|
1233
1414
|
function validateComponentDefinition(definition) {
|
|
1234
1415
|
const { name } = definition;
|
|
@@ -1291,7 +1472,7 @@ function isJuneComponent(value) {
|
|
|
1291
1472
|
// src/engine/registry/component-registry.ts
|
|
1292
1473
|
|
|
1293
1474
|
function nameOf(component) {
|
|
1294
|
-
const name = _optionalChain([component, 'optionalAccess',
|
|
1475
|
+
const name = _optionalChain([component, 'optionalAccess', _67 => _67.name]);
|
|
1295
1476
|
if (typeof name !== "string" || name.length === 0) {
|
|
1296
1477
|
throw new (0, _chunkG6YPSE6Jcjs.JuneError)("LIBRARY_ERROR", "Every component needs a non-empty string name");
|
|
1297
1478
|
}
|
|
@@ -1300,7 +1481,7 @@ function nameOf(component) {
|
|
|
1300
1481
|
function slotsOf(component) {
|
|
1301
1482
|
return isJuneComponent(component) ? component.june.slots : void 0;
|
|
1302
1483
|
}
|
|
1303
|
-
var isDev = () => typeof process !== "undefined" && _optionalChain([process, 'access',
|
|
1484
|
+
var isDev = () => typeof process !== "undefined" && _optionalChain([process, 'access', _68 => _68.env, 'optionalAccess', _69 => _69.NODE_ENV]) === "development";
|
|
1304
1485
|
var ComponentRegistry = class {
|
|
1305
1486
|
constructor(options = {}) {
|
|
1306
1487
|
this.added = /* @__PURE__ */ new Map();
|
|
@@ -1413,7 +1594,7 @@ var ComponentRegistry = class {
|
|
|
1413
1594
|
if (!inBase || this.removed.has(name)) {
|
|
1414
1595
|
throw new (0, _chunkG6YPSE6Jcjs.JuneError)("LIBRARY_ERROR", `Cannot remove "${name}": no component with that name.`);
|
|
1415
1596
|
}
|
|
1416
|
-
if (_optionalChain([this, 'access',
|
|
1597
|
+
if (_optionalChain([this, 'access', _70 => _70.base, 'optionalAccess', _71 => _71.root]) === name) {
|
|
1417
1598
|
throw new (0, _chunkG6YPSE6Jcjs.JuneError)("LIBRARY_ERROR", `Cannot remove "${name}": it is the root component.`);
|
|
1418
1599
|
}
|
|
1419
1600
|
this.removed.add(name);
|
|
@@ -1467,17 +1648,17 @@ var ComponentRegistry = class {
|
|
|
1467
1648
|
try {
|
|
1468
1649
|
return base.extend(extension(true));
|
|
1469
1650
|
} catch (first) {
|
|
1470
|
-
if (added.some((c) => _optionalChain([slotsOf, 'call',
|
|
1651
|
+
if (added.some((c) => _optionalChain([slotsOf, 'call', _72 => _72(c), 'optionalAccess', _73 => _73.length]))) {
|
|
1471
1652
|
try {
|
|
1472
1653
|
const library = base.extend(extension(false));
|
|
1473
1654
|
if (isDev()) console.warn("[june-ui] Component slots were skipped (they need Zod 4.1+):", first);
|
|
1474
1655
|
return library;
|
|
1475
|
-
} catch (
|
|
1656
|
+
} catch (e4) {
|
|
1476
1657
|
}
|
|
1477
1658
|
}
|
|
1478
1659
|
try {
|
|
1479
1660
|
return this.rebuild(added, overrides);
|
|
1480
|
-
} catch (
|
|
1661
|
+
} catch (e5) {
|
|
1481
1662
|
throw first;
|
|
1482
1663
|
}
|
|
1483
1664
|
}
|
|
@@ -1486,7 +1667,7 @@ var ComponentRegistry = class {
|
|
|
1486
1667
|
const base = this.base;
|
|
1487
1668
|
const replace = new Map(overrides.map((c) => [nameOf(c), c]));
|
|
1488
1669
|
const components = Object.values(base.components).filter((c) => !this.removed.has(c.name)).map((c) => _nullishCoalesce(replace.get(c.name), () => ( c))).concat(added);
|
|
1489
|
-
const componentGroups = _optionalChain([base, 'access',
|
|
1670
|
+
const componentGroups = _optionalChain([base, 'access', _74 => _74.componentGroups, 'optionalAccess', _75 => _75.map, 'call', _76 => _76((g) => ({ ...g, components: g.components.filter((n) => !this.removed.has(n)) })), 'access', _77 => _77.filter, 'call', _78 => _78((g) => g.components.length > 0)]);
|
|
1490
1671
|
return _reactlang.createLibrary.call(void 0, {
|
|
1491
1672
|
components,
|
|
1492
1673
|
componentGroups,
|
|
@@ -1517,7 +1698,7 @@ function createJuneLibrary(options) {
|
|
|
1517
1698
|
const components = _nullishCoalesce(raw.components, () => ( []));
|
|
1518
1699
|
const names = /* @__PURE__ */ new Set();
|
|
1519
1700
|
for (const component of components) {
|
|
1520
|
-
if (typeof _optionalChain([component, 'optionalAccess',
|
|
1701
|
+
if (typeof _optionalChain([component, 'optionalAccess', _79 => _79.name]) !== "string" || component.name.length === 0) {
|
|
1521
1702
|
throw new (0, _chunkG6YPSE6Jcjs.JuneError)("LIBRARY_ERROR", "Every component needs a non-empty string name");
|
|
1522
1703
|
}
|
|
1523
1704
|
if (names.has(component.name)) {
|
|
@@ -1570,7 +1751,7 @@ async function* iterateReadable(stream, signal) {
|
|
|
1570
1751
|
void reader.cancel().catch(() => {
|
|
1571
1752
|
});
|
|
1572
1753
|
};
|
|
1573
|
-
_optionalChain([signal, 'optionalAccess',
|
|
1754
|
+
_optionalChain([signal, 'optionalAccess', _80 => _80.addEventListener, 'call', _81 => _81("abort", onAbort, { once: true })]);
|
|
1574
1755
|
try {
|
|
1575
1756
|
while (true) {
|
|
1576
1757
|
const { done, value } = await reader.read();
|
|
@@ -1578,10 +1759,10 @@ async function* iterateReadable(stream, signal) {
|
|
|
1578
1759
|
yield value;
|
|
1579
1760
|
}
|
|
1580
1761
|
} finally {
|
|
1581
|
-
_optionalChain([signal, 'optionalAccess',
|
|
1762
|
+
_optionalChain([signal, 'optionalAccess', _82 => _82.removeEventListener, 'call', _83 => _83("abort", onAbort)]);
|
|
1582
1763
|
try {
|
|
1583
1764
|
reader.releaseLock();
|
|
1584
|
-
} catch (
|
|
1765
|
+
} catch (e6) {
|
|
1585
1766
|
}
|
|
1586
1767
|
}
|
|
1587
1768
|
}
|
|
@@ -1593,7 +1774,7 @@ function abortedError(partial) {
|
|
|
1593
1774
|
}
|
|
1594
1775
|
async function consumeStream(source, options = {}) {
|
|
1595
1776
|
const { signal, onText, allowEmpty = false } = options;
|
|
1596
|
-
if (_optionalChain([signal, 'optionalAccess',
|
|
1777
|
+
if (_optionalChain([signal, 'optionalAccess', _84 => _84.aborted])) throw abortedError("");
|
|
1597
1778
|
const decoder = new TextDecoder();
|
|
1598
1779
|
let text = "";
|
|
1599
1780
|
let received = false;
|
|
@@ -1601,23 +1782,23 @@ async function consumeStream(source, options = {}) {
|
|
|
1601
1782
|
if (!delta) return;
|
|
1602
1783
|
received = true;
|
|
1603
1784
|
text += delta;
|
|
1604
|
-
_optionalChain([onText, 'optionalCall',
|
|
1785
|
+
_optionalChain([onText, 'optionalCall', _85 => _85(delta, text)]);
|
|
1605
1786
|
};
|
|
1606
1787
|
try {
|
|
1607
1788
|
for await (const chunk of toAsyncIterable(source, signal)) {
|
|
1608
|
-
if (_optionalChain([signal, 'optionalAccess',
|
|
1789
|
+
if (_optionalChain([signal, 'optionalAccess', _86 => _86.aborted])) break;
|
|
1609
1790
|
push(typeof chunk === "string" ? chunk : decoder.decode(chunk, { stream: true }));
|
|
1610
1791
|
}
|
|
1611
1792
|
push(decoder.decode());
|
|
1612
1793
|
} catch (error) {
|
|
1613
|
-
if (_optionalChain([signal, 'optionalAccess',
|
|
1794
|
+
if (_optionalChain([signal, 'optionalAccess', _87 => _87.aborted])) throw abortedError(text);
|
|
1614
1795
|
if (error instanceof _chunkG6YPSE6Jcjs.JuneError) throw error;
|
|
1615
1796
|
throw new (0, _chunkG6YPSE6Jcjs.JuneError)("STREAM_ERROR", "Stream was interrupted", {
|
|
1616
1797
|
cause: error,
|
|
1617
1798
|
details: { partial: text }
|
|
1618
1799
|
});
|
|
1619
1800
|
}
|
|
1620
|
-
if (_optionalChain([signal, 'optionalAccess',
|
|
1801
|
+
if (_optionalChain([signal, 'optionalAccess', _88 => _88.aborted])) throw abortedError(text);
|
|
1621
1802
|
if (!received && !allowEmpty) {
|
|
1622
1803
|
throw new (0, _chunkG6YPSE6Jcjs.JuneError)("STREAM_EMPTY", "Stream completed without any content");
|
|
1623
1804
|
}
|
|
@@ -1686,7 +1867,7 @@ function jsonFieldExtractor(path) {
|
|
|
1686
1867
|
current = current[key];
|
|
1687
1868
|
}
|
|
1688
1869
|
return typeof current === "string" ? current : null;
|
|
1689
|
-
} catch (
|
|
1870
|
+
} catch (e7) {
|
|
1690
1871
|
return null;
|
|
1691
1872
|
}
|
|
1692
1873
|
};
|
|
@@ -1699,7 +1880,7 @@ async function fetchStream(input, options = {}) {
|
|
|
1699
1880
|
try {
|
|
1700
1881
|
response = await fetch(input, init);
|
|
1701
1882
|
} catch (error) {
|
|
1702
|
-
if (_optionalChain([init, 'access',
|
|
1883
|
+
if (_optionalChain([init, 'access', _89 => _89.signal, 'optionalAccess', _90 => _90.aborted])) {
|
|
1703
1884
|
throw new (0, _chunkG6YPSE6Jcjs.JuneError)("STREAM_ABORTED", "Request was aborted", { cause: error });
|
|
1704
1885
|
}
|
|
1705
1886
|
throw new (0, _chunkG6YPSE6Jcjs.JuneError)("NETWORK_ERROR", "Network request failed", { cause: error });
|
|
@@ -1756,7 +1937,7 @@ function useJuneStream(options = {}) {
|
|
|
1756
1937
|
}, []);
|
|
1757
1938
|
const start = _react.useCallback.call(void 0,
|
|
1758
1939
|
async (input) => {
|
|
1759
|
-
_optionalChain([controllerRef, 'access',
|
|
1940
|
+
_optionalChain([controllerRef, 'access', _91 => _91.current, 'optionalAccess', _92 => _92.abort, 'call', _93 => _93()]);
|
|
1760
1941
|
const controller = new AbortController();
|
|
1761
1942
|
controllerRef.current = controller;
|
|
1762
1943
|
const runId = ++runIdRef.current;
|
|
@@ -1779,7 +1960,7 @@ function useJuneStream(options = {}) {
|
|
|
1779
1960
|
if (stale()) return null;
|
|
1780
1961
|
clearTimer();
|
|
1781
1962
|
setState({ response: text, isStreaming: false, status: "done", error: null });
|
|
1782
|
-
_optionalChain([optionsRef, 'access',
|
|
1963
|
+
_optionalChain([optionsRef, 'access', _94 => _94.current, 'access', _95 => _95.onComplete, 'optionalCall', _96 => _96(text)]);
|
|
1783
1964
|
return text;
|
|
1784
1965
|
} catch (caught) {
|
|
1785
1966
|
if (stale()) return null;
|
|
@@ -1793,7 +1974,7 @@ function useJuneStream(options = {}) {
|
|
|
1793
1974
|
status: aborted ? "aborted" : "error",
|
|
1794
1975
|
error: aborted ? null : error
|
|
1795
1976
|
});
|
|
1796
|
-
if (!aborted) _optionalChain([optionsRef, 'access',
|
|
1977
|
+
if (!aborted) _optionalChain([optionsRef, 'access', _97 => _97.current, 'access', _98 => _98.onError, 'optionalCall', _99 => _99(error)]);
|
|
1797
1978
|
return null;
|
|
1798
1979
|
}
|
|
1799
1980
|
},
|
|
@@ -1804,10 +1985,10 @@ function useJuneStream(options = {}) {
|
|
|
1804
1985
|
[start]
|
|
1805
1986
|
);
|
|
1806
1987
|
const abort = _react.useCallback.call(void 0, () => {
|
|
1807
|
-
_optionalChain([controllerRef, 'access',
|
|
1988
|
+
_optionalChain([controllerRef, 'access', _100 => _100.current, 'optionalAccess', _101 => _101.abort, 'call', _102 => _102()]);
|
|
1808
1989
|
}, []);
|
|
1809
1990
|
const reset = _react.useCallback.call(void 0, () => {
|
|
1810
|
-
_optionalChain([controllerRef, 'access',
|
|
1991
|
+
_optionalChain([controllerRef, 'access', _103 => _103.current, 'optionalAccess', _104 => _104.abort, 'call', _105 => _105()]);
|
|
1811
1992
|
runIdRef.current++;
|
|
1812
1993
|
textRef.current = "";
|
|
1813
1994
|
clearTimer();
|
|
@@ -1816,7 +1997,7 @@ function useJuneStream(options = {}) {
|
|
|
1816
1997
|
_react.useEffect.call(void 0,
|
|
1817
1998
|
() => () => {
|
|
1818
1999
|
runIdRef.current++;
|
|
1819
|
-
_optionalChain([controllerRef, 'access',
|
|
2000
|
+
_optionalChain([controllerRef, 'access', _106 => _106.current, 'optionalAccess', _107 => _107.abort, 'call', _108 => _108()]);
|
|
1820
2001
|
clearTimer();
|
|
1821
2002
|
},
|
|
1822
2003
|
[clearTimer]
|
|
@@ -2030,6 +2211,10 @@ var PATHS = {
|
|
|
2030
2211
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M18 6 6 18" }),
|
|
2031
2212
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "m6 6 12 12" })
|
|
2032
2213
|
] }),
|
|
2214
|
+
pencil: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2215
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" }),
|
|
2216
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "m15 5 4 4" })
|
|
2217
|
+
] }),
|
|
2033
2218
|
maximize: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2034
2219
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M8 3H5a2 2 0 0 0-2 2v3" }),
|
|
2035
2220
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M21 8V5a2 2 0 0 0-2-2h-3" }),
|
|
@@ -2096,7 +2281,7 @@ function Dropdown({ trigger, children, align = "start", className, onOpen }) {
|
|
|
2096
2281
|
return () => document.removeEventListener("mousedown", onDown);
|
|
2097
2282
|
}, [open]);
|
|
2098
2283
|
const toggle = () => setOpen((v) => {
|
|
2099
|
-
if (!v) _optionalChain([onOpen, 'optionalCall',
|
|
2284
|
+
if (!v) _optionalChain([onOpen, 'optionalCall', _109 => _109()]);
|
|
2100
2285
|
return !v;
|
|
2101
2286
|
});
|
|
2102
2287
|
const close = () => setOpen(false);
|
|
@@ -2230,7 +2415,7 @@ function ColorPicker({ label, icon, colors, current, disabled, resetLabel, onPic
|
|
|
2230
2415
|
style: { background: c },
|
|
2231
2416
|
"aria-label": c,
|
|
2232
2417
|
title: c,
|
|
2233
|
-
"data-active": _optionalChain([current, 'optionalAccess',
|
|
2418
|
+
"data-active": _optionalChain([current, 'optionalAccess', _110 => _110.toLowerCase, 'call', _111 => _111()]) === c ? true : void 0,
|
|
2234
2419
|
onMouseDown: (e) => e.preventDefault(),
|
|
2235
2420
|
onClick: () => {
|
|
2236
2421
|
onPick(c);
|
|
@@ -2344,7 +2529,7 @@ function ImagePanel({ editor, close, onNotice }) {
|
|
|
2344
2529
|
{
|
|
2345
2530
|
type: "button",
|
|
2346
2531
|
className: "june-doc__dropzone",
|
|
2347
|
-
onClick: () => _optionalChain([file, 'access',
|
|
2532
|
+
onClick: () => _optionalChain([file, 'access', _112 => _112.current, 'optionalAccess', _113 => _113.click, 'call', _114 => _114()]),
|
|
2348
2533
|
onDragOver: (e) => e.preventDefault(),
|
|
2349
2534
|
onDrop: (e) => {
|
|
2350
2535
|
e.preventDefault();
|
|
@@ -2363,7 +2548,7 @@ function ImagePanel({ editor, close, onNotice }) {
|
|
|
2363
2548
|
type: "file",
|
|
2364
2549
|
accept: "image/*",
|
|
2365
2550
|
hidden: true,
|
|
2366
|
-
onChange: (e) => fromFile(_optionalChain([e, 'access',
|
|
2551
|
+
onChange: (e) => fromFile(_optionalChain([e, 'access', _115 => _115.target, 'access', _116 => _116.files, 'optionalAccess', _117 => _117[0]]))
|
|
2367
2552
|
}
|
|
2368
2553
|
),
|
|
2369
2554
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "june-doc__or", children: "or" }),
|
|
@@ -2468,9 +2653,9 @@ function DocumentToolbar(props) {
|
|
|
2468
2653
|
};
|
|
2469
2654
|
}
|
|
2470
2655
|
});
|
|
2471
|
-
const run = () => _optionalChain([editor, 'optionalAccess',
|
|
2656
|
+
const run = () => _optionalChain([editor, 'optionalAccess', _118 => _118.chain, 'call', _119 => _119(), 'access', _120 => _120.focus, 'call', _121 => _121()]);
|
|
2472
2657
|
const off = !editor || !editable;
|
|
2473
|
-
const style = _optionalChain([s, 'optionalAccess',
|
|
2658
|
+
const style = _optionalChain([s, 'optionalAccess', _122 => _122.codeBlock]) ? "code" : _optionalChain([s, 'optionalAccess', _123 => _123.h1]) ? "1" : _optionalChain([s, 'optionalAccess', _124 => _124.h2]) ? "2" : _optionalChain([s, 'optionalAccess', _125 => _125.h3]) ? "3" : _optionalChain([s, 'optionalAccess', _126 => _126.quote]) ? "quote" : "p";
|
|
2474
2659
|
const setStyle = (v) => {
|
|
2475
2660
|
if (!editor || !s) return;
|
|
2476
2661
|
let c = editor.chain().focus();
|
|
@@ -2484,35 +2669,35 @@ function DocumentToolbar(props) {
|
|
|
2484
2669
|
}
|
|
2485
2670
|
c.run();
|
|
2486
2671
|
};
|
|
2487
|
-
const fontKnown = FONT_FAMILIES.some((f) => f.value === _optionalChain([s, 'optionalAccess',
|
|
2488
|
-
const sizes = _optionalChain([s, 'optionalAccess',
|
|
2672
|
+
const fontKnown = FONT_FAMILIES.some((f) => f.value === _optionalChain([s, 'optionalAccess', _127 => _127.fontFamily]));
|
|
2673
|
+
const sizes = _optionalChain([s, 'optionalAccess', _128 => _128.fontSize]) && !FONT_SIZES.includes(Number(s.fontSize)) ? [...FONT_SIZES, Number(s.fontSize)].sort((a, b) => a - b) : FONT_SIZES;
|
|
2489
2674
|
if (!editable) return null;
|
|
2490
2675
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "june-doc__ribbon", role: "toolbar", "aria-label": "Document formatting", children: [
|
|
2491
2676
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "june-doc__row", children: [
|
|
2492
2677
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Group, { label: "History", children: [
|
|
2493
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Undo", icon: "undo", disabled: off || !_optionalChain([s, 'optionalAccess',
|
|
2494
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Redo", icon: "redo", disabled: off || !_optionalChain([s, 'optionalAccess',
|
|
2678
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Undo", icon: "undo", disabled: off || !_optionalChain([s, 'optionalAccess', _129 => _129.canUndo]), onClick: () => _optionalChain([run, 'call', _130 => _130(), 'optionalAccess', _131 => _131.undo, 'call', _132 => _132(), 'access', _133 => _133.run, 'call', _134 => _134()]) }),
|
|
2679
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Redo", icon: "redo", disabled: off || !_optionalChain([s, 'optionalAccess', _135 => _135.canRedo]), onClick: () => _optionalChain([run, 'call', _136 => _136(), 'optionalAccess', _137 => _137.redo, 'call', _138 => _138(), 'access', _139 => _139.run, 'call', _140 => _140()]) })
|
|
2495
2680
|
] }),
|
|
2496
2681
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Group, { label: "Format", children: [
|
|
2497
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Bold", icon: "bold", toggle: true, active: _optionalChain([s, 'optionalAccess',
|
|
2498
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Italic", icon: "italic", toggle: true, active: _optionalChain([s, 'optionalAccess',
|
|
2499
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Underline", icon: "underline", toggle: true, active: _optionalChain([s, 'optionalAccess',
|
|
2500
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Strikethrough", icon: "strike", toggle: true, active: _optionalChain([s, 'optionalAccess',
|
|
2501
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Inline code", icon: "code", toggle: true, active: _optionalChain([s, 'optionalAccess',
|
|
2502
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Superscript", icon: "superscript", toggle: true, active: _optionalChain([s, 'optionalAccess',
|
|
2503
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Subscript", icon: "subscript", toggle: true, active: _optionalChain([s, 'optionalAccess',
|
|
2682
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Bold", icon: "bold", toggle: true, active: _optionalChain([s, 'optionalAccess', _141 => _141.bold]), disabled: off, onClick: () => _optionalChain([run, 'call', _142 => _142(), 'optionalAccess', _143 => _143.toggleBold, 'call', _144 => _144(), 'access', _145 => _145.run, 'call', _146 => _146()]) }),
|
|
2683
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Italic", icon: "italic", toggle: true, active: _optionalChain([s, 'optionalAccess', _147 => _147.italic]), disabled: off, onClick: () => _optionalChain([run, 'call', _148 => _148(), 'optionalAccess', _149 => _149.toggleItalic, 'call', _150 => _150(), 'access', _151 => _151.run, 'call', _152 => _152()]) }),
|
|
2684
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Underline", icon: "underline", toggle: true, active: _optionalChain([s, 'optionalAccess', _153 => _153.underline]), disabled: off, onClick: () => _optionalChain([run, 'call', _154 => _154(), 'optionalAccess', _155 => _155.toggleUnderline, 'call', _156 => _156(), 'access', _157 => _157.run, 'call', _158 => _158()]) }),
|
|
2685
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Strikethrough", icon: "strike", toggle: true, active: _optionalChain([s, 'optionalAccess', _159 => _159.strike]), disabled: off, onClick: () => _optionalChain([run, 'call', _160 => _160(), 'optionalAccess', _161 => _161.toggleStrike, 'call', _162 => _162(), 'access', _163 => _163.run, 'call', _164 => _164()]) }),
|
|
2686
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Inline code", icon: "code", toggle: true, active: _optionalChain([s, 'optionalAccess', _165 => _165.code]), disabled: off, onClick: () => _optionalChain([run, 'call', _166 => _166(), 'optionalAccess', _167 => _167.toggleCode, 'call', _168 => _168(), 'access', _169 => _169.run, 'call', _170 => _170()]) }),
|
|
2687
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Superscript", icon: "superscript", toggle: true, active: _optionalChain([s, 'optionalAccess', _171 => _171.sup]), disabled: off, onClick: () => _optionalChain([run, 'call', _172 => _172(), 'optionalAccess', _173 => _173.toggleSuperscript, 'call', _174 => _174(), 'access', _175 => _175.run, 'call', _176 => _176()]) }),
|
|
2688
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Subscript", icon: "subscript", toggle: true, active: _optionalChain([s, 'optionalAccess', _177 => _177.sub]), disabled: off, onClick: () => _optionalChain([run, 'call', _178 => _178(), 'optionalAccess', _179 => _179.toggleSubscript, 'call', _180 => _180(), 'access', _181 => _181.run, 'call', _182 => _182()]) })
|
|
2504
2689
|
] }),
|
|
2505
2690
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Group, { label: "Align", children: [
|
|
2506
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Align left", icon: "alignLeft", toggle: true, active: _optionalChain([s, 'optionalAccess',
|
|
2507
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Align center", icon: "alignCenter", toggle: true, active: _optionalChain([s, 'optionalAccess',
|
|
2508
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Align right", icon: "alignRight", toggle: true, active: _optionalChain([s, 'optionalAccess',
|
|
2509
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Justify", icon: "alignJustify", toggle: true, active: _optionalChain([s, 'optionalAccess',
|
|
2691
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Align left", icon: "alignLeft", toggle: true, active: _optionalChain([s, 'optionalAccess', _183 => _183.left]), disabled: off, onClick: () => _optionalChain([run, 'call', _184 => _184(), 'optionalAccess', _185 => _185.setTextAlign, 'call', _186 => _186("left"), 'access', _187 => _187.run, 'call', _188 => _188()]) }),
|
|
2692
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Align center", icon: "alignCenter", toggle: true, active: _optionalChain([s, 'optionalAccess', _189 => _189.center]), disabled: off, onClick: () => _optionalChain([run, 'call', _190 => _190(), 'optionalAccess', _191 => _191.setTextAlign, 'call', _192 => _192("center"), 'access', _193 => _193.run, 'call', _194 => _194()]) }),
|
|
2693
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Align right", icon: "alignRight", toggle: true, active: _optionalChain([s, 'optionalAccess', _195 => _195.right]), disabled: off, onClick: () => _optionalChain([run, 'call', _196 => _196(), 'optionalAccess', _197 => _197.setTextAlign, 'call', _198 => _198("right"), 'access', _199 => _199.run, 'call', _200 => _200()]) }),
|
|
2694
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Justify", icon: "alignJustify", toggle: true, active: _optionalChain([s, 'optionalAccess', _201 => _201.justify]), disabled: off, onClick: () => _optionalChain([run, 'call', _202 => _202(), 'optionalAccess', _203 => _203.setTextAlign, 'call', _204 => _204("justify"), 'access', _205 => _205.run, 'call', _206 => _206()]) })
|
|
2510
2695
|
] }),
|
|
2511
2696
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Group, { label: "Lists", children: [
|
|
2512
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Bullet list", icon: "list", toggle: true, active: _optionalChain([s, 'optionalAccess',
|
|
2513
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Numbered list", icon: "listOrdered", toggle: true, active: _optionalChain([s, 'optionalAccess',
|
|
2514
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Decrease indent", icon: "outdent", disabled: off || !_optionalChain([s, 'optionalAccess',
|
|
2515
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Increase indent", icon: "indent", disabled: off || !_optionalChain([s, 'optionalAccess',
|
|
2697
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Bullet list", icon: "list", toggle: true, active: _optionalChain([s, 'optionalAccess', _207 => _207.bullet]), disabled: off, onClick: () => _optionalChain([run, 'call', _208 => _208(), 'optionalAccess', _209 => _209.toggleBulletList, 'call', _210 => _210(), 'access', _211 => _211.run, 'call', _212 => _212()]) }),
|
|
2698
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Numbered list", icon: "listOrdered", toggle: true, active: _optionalChain([s, 'optionalAccess', _213 => _213.ordered]), disabled: off, onClick: () => _optionalChain([run, 'call', _214 => _214(), 'optionalAccess', _215 => _215.toggleOrderedList, 'call', _216 => _216(), 'access', _217 => _217.run, 'call', _218 => _218()]) }),
|
|
2699
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Decrease indent", icon: "outdent", disabled: off || !_optionalChain([s, 'optionalAccess', _219 => _219.canLift]), onClick: () => _optionalChain([run, 'call', _220 => _220(), 'optionalAccess', _221 => _221.liftListItem, 'call', _222 => _222("listItem"), 'access', _223 => _223.run, 'call', _224 => _224()]) }),
|
|
2700
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Increase indent", icon: "indent", disabled: off || !_optionalChain([s, 'optionalAccess', _225 => _225.canSink]), onClick: () => _optionalChain([run, 'call', _226 => _226(), 'optionalAccess', _227 => _227.sinkListItem, 'call', _228 => _228("listItem"), 'access', _229 => _229.run, 'call', _230 => _230()]) })
|
|
2516
2701
|
] }),
|
|
2517
2702
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2518
2703
|
"button",
|
|
@@ -2546,15 +2731,15 @@ function DocumentToolbar(props) {
|
|
|
2546
2731
|
className: "june-doc__select june-doc__select--font",
|
|
2547
2732
|
"aria-label": "Font family",
|
|
2548
2733
|
disabled: off,
|
|
2549
|
-
value: _nullishCoalesce(_optionalChain([s, 'optionalAccess',
|
|
2734
|
+
value: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _231 => _231.fontFamily]), () => ( "")),
|
|
2550
2735
|
onChange: (e) => {
|
|
2551
2736
|
const v = e.target.value;
|
|
2552
|
-
if (v) _optionalChain([run, 'call',
|
|
2553
|
-
else _optionalChain([run, 'call',
|
|
2737
|
+
if (v) _optionalChain([run, 'call', _232 => _232(), 'optionalAccess', _233 => _233.setFontFamily, 'call', _234 => _234(v), 'access', _235 => _235.run, 'call', _236 => _236()]);
|
|
2738
|
+
else _optionalChain([run, 'call', _237 => _237(), 'optionalAccess', _238 => _238.unsetFontFamily, 'call', _239 => _239(), 'access', _240 => _240.run, 'call', _241 => _241()]);
|
|
2554
2739
|
},
|
|
2555
2740
|
children: [
|
|
2556
2741
|
FONT_FAMILIES.map((f) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "option", { value: f.value, style: { fontFamily: f.value || void 0 }, children: f.label }, f.label)),
|
|
2557
|
-
!fontKnown && _optionalChain([s, 'optionalAccess',
|
|
2742
|
+
!fontKnown && _optionalChain([s, 'optionalAccess', _242 => _242.fontFamily]) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "option", { value: s.fontFamily, children: s.fontFamily.split(",")[0].replace(/['"]/g, "") }) : null
|
|
2558
2743
|
]
|
|
2559
2744
|
}
|
|
2560
2745
|
) }),
|
|
@@ -2564,11 +2749,11 @@ function DocumentToolbar(props) {
|
|
|
2564
2749
|
className: "june-doc__select june-doc__select--size",
|
|
2565
2750
|
"aria-label": "Font size",
|
|
2566
2751
|
disabled: off,
|
|
2567
|
-
value: _nullishCoalesce(_optionalChain([s, 'optionalAccess',
|
|
2752
|
+
value: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _243 => _243.fontSize]), () => ( "")),
|
|
2568
2753
|
onChange: (e) => {
|
|
2569
2754
|
const v = e.target.value;
|
|
2570
|
-
if (v) _optionalChain([run, 'call',
|
|
2571
|
-
else _optionalChain([run, 'call',
|
|
2755
|
+
if (v) _optionalChain([run, 'call', _244 => _244(), 'optionalAccess', _245 => _245.setFontSize, 'call', _246 => _246(`${v}px`), 'access', _247 => _247.run, 'call', _248 => _248()]);
|
|
2756
|
+
else _optionalChain([run, 'call', _249 => _249(), 'optionalAccess', _250 => _250.unsetFontSize, 'call', _251 => _251(), 'access', _252 => _252.run, 'call', _253 => _253()]);
|
|
2572
2757
|
},
|
|
2573
2758
|
children: [
|
|
2574
2759
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "option", { value: "", children: "Auto" }),
|
|
@@ -2579,8 +2764,8 @@ function DocumentToolbar(props) {
|
|
|
2579
2764
|
] }),
|
|
2580
2765
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Show formatting marks", icon: "pilcrow", toggle: true, active: showMarks, onClick: onToggleMarks, text: true, className: "june-doc__btn--marks", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Paragraph" }) }),
|
|
2581
2766
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Group, { label: "Document", children: [
|
|
2582
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Insert page break", icon: "pageBreak", disabled: off, onClick: () => _optionalChain([run, 'call',
|
|
2583
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Insert divider", icon: "divider", disabled: off, onClick: () => _optionalChain([run, 'call',
|
|
2767
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Insert page break", icon: "pageBreak", disabled: off, onClick: () => _optionalChain([run, 'call', _254 => _254(), 'optionalAccess', _255 => _255.setPageBreak, 'call', _256 => _256(), 'access', _257 => _257.run, 'call', _258 => _258()]) }),
|
|
2768
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Insert divider", icon: "divider", disabled: off, onClick: () => _optionalChain([run, 'call', _259 => _259(), 'optionalAccess', _260 => _260.setHorizontalRule, 'call', _261 => _261(), 'access', _262 => _262.run, 'call', _263 => _263()]) }),
|
|
2584
2769
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: layout === "page" ? "Switch to full-width layout" : "Switch to page layout", icon: "layout", toggle: true, active: layout === "fluid", onClick: onToggleLayout }),
|
|
2585
2770
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Find and replace", icon: "search", toggle: true, active: findOpen, onClick: onToggleFind })
|
|
2586
2771
|
] }),
|
|
@@ -2591,11 +2776,11 @@ function DocumentToolbar(props) {
|
|
|
2591
2776
|
label: "Text color",
|
|
2592
2777
|
icon: "palette",
|
|
2593
2778
|
colors: TEXT_COLORS,
|
|
2594
|
-
current: _nullishCoalesce(_optionalChain([s, 'optionalAccess',
|
|
2779
|
+
current: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _264 => _264.color]), () => ( null)),
|
|
2595
2780
|
disabled: off,
|
|
2596
2781
|
resetLabel: "Default color",
|
|
2597
|
-
onPick: (c) => _optionalChain([run, 'call',
|
|
2598
|
-
onReset: () => _optionalChain([run, 'call',
|
|
2782
|
+
onPick: (c) => _optionalChain([run, 'call', _265 => _265(), 'optionalAccess', _266 => _266.setColor, 'call', _267 => _267(c), 'access', _268 => _268.run, 'call', _269 => _269()]),
|
|
2783
|
+
onReset: () => _optionalChain([run, 'call', _270 => _270(), 'optionalAccess', _271 => _271.unsetColor, 'call', _272 => _272(), 'access', _273 => _273.run, 'call', _274 => _274()])
|
|
2599
2784
|
}
|
|
2600
2785
|
),
|
|
2601
2786
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -2604,11 +2789,11 @@ function DocumentToolbar(props) {
|
|
|
2604
2789
|
label: "Highlight",
|
|
2605
2790
|
icon: "highlighter",
|
|
2606
2791
|
colors: HIGHLIGHT_COLORS,
|
|
2607
|
-
current: _nullishCoalesce(_optionalChain([s, 'optionalAccess',
|
|
2792
|
+
current: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _275 => _275.highlight]), () => ( null)),
|
|
2608
2793
|
disabled: off,
|
|
2609
2794
|
resetLabel: "No highlight",
|
|
2610
|
-
onPick: (c) => _optionalChain([run, 'call',
|
|
2611
|
-
onReset: () => _optionalChain([run, 'call',
|
|
2795
|
+
onPick: (c) => _optionalChain([run, 'call', _276 => _276(), 'optionalAccess', _277 => _277.setHighlight, 'call', _278 => _278({ color: c }), 'access', _279 => _279.run, 'call', _280 => _280()]),
|
|
2796
|
+
onReset: () => _optionalChain([run, 'call', _281 => _281(), 'optionalAccess', _282 => _282.unsetHighlight, 'call', _283 => _283(), 'access', _284 => _284.run, 'call', _285 => _285()])
|
|
2612
2797
|
}
|
|
2613
2798
|
)
|
|
2614
2799
|
] }),
|
|
@@ -2616,24 +2801,24 @@ function DocumentToolbar(props) {
|
|
|
2616
2801
|
editor ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2617
2802
|
Dropdown,
|
|
2618
2803
|
{
|
|
2619
|
-
trigger: ({ open, toggle }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Link", icon: "link", toggle: true, active: _optionalChain([s, 'optionalAccess',
|
|
2620
|
-
children: (close) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LinkPanel, { editor, href: _nullishCoalesce(_optionalChain([s, 'optionalAccess',
|
|
2804
|
+
trigger: ({ open, toggle }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Link", icon: "link", toggle: true, active: _optionalChain([s, 'optionalAccess', _286 => _286.link]) || open, disabled: off, onClick: toggle }),
|
|
2805
|
+
children: (close) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LinkPanel, { editor, href: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _287 => _287.linkHref]), () => ( "")), isLink: !!_optionalChain([s, 'optionalAccess', _288 => _288.link]), close })
|
|
2621
2806
|
}
|
|
2622
2807
|
) : null,
|
|
2623
2808
|
editor ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Dropdown, { trigger: ({ open, toggle }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Insert image", icon: "image", active: open, disabled: off, onClick: toggle }), children: (close) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ImagePanel, { editor, close, onNotice }) }) : null,
|
|
2624
2809
|
editor ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Dropdown, { trigger: ({ open, toggle }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Insert table", icon: "table", active: open, disabled: off, onClick: toggle }), children: (close) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TablePanel, { editor, close }) }) : null
|
|
2625
2810
|
] }),
|
|
2626
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Group, { label: "Actions", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Clear formatting", icon: "eraser", disabled: off, onClick: () => _optionalChain([run, 'call',
|
|
2811
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Group, { label: "Actions", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Clear formatting", icon: "eraser", disabled: off, onClick: () => _optionalChain([run, 'call', _289 => _289(), 'optionalAccess', _290 => _290.unsetAllMarks, 'call', _291 => _291(), 'access', _292 => _292.clearNodes, 'call', _293 => _293(), 'access', _294 => _294.run, 'call', _295 => _295()]) }) })
|
|
2627
2812
|
] }) : null,
|
|
2628
|
-
_optionalChain([s, 'optionalAccess',
|
|
2629
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Add row below", disabled: off, onClick: () => _optionalChain([run, 'call',
|
|
2630
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Add column right", disabled: off, onClick: () => _optionalChain([run, 'call',
|
|
2631
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Delete row", disabled: off, onClick: () => _optionalChain([run, 'call',
|
|
2632
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Delete column", disabled: off, onClick: () => _optionalChain([run, 'call',
|
|
2633
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Merge cells", disabled: off || !_optionalChain([s, 'optionalAccess',
|
|
2634
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Split cell", disabled: off || !_optionalChain([s, 'optionalAccess',
|
|
2635
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Toggle header row", disabled: off, onClick: () => _optionalChain([run, 'call',
|
|
2636
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Delete table", disabled: off, onClick: () => _optionalChain([run, 'call',
|
|
2813
|
+
_optionalChain([s, 'optionalAccess', _296 => _296.inTable]) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "june-doc__row june-doc__row--context", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Group, { label: "Table", children: [
|
|
2814
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Add row below", disabled: off, onClick: () => _optionalChain([run, 'call', _297 => _297(), 'optionalAccess', _298 => _298.addRowAfter, 'call', _299 => _299(), 'access', _300 => _300.run, 'call', _301 => _301()]), children: "+ Row" }),
|
|
2815
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Add column right", disabled: off, onClick: () => _optionalChain([run, 'call', _302 => _302(), 'optionalAccess', _303 => _303.addColumnAfter, 'call', _304 => _304(), 'access', _305 => _305.run, 'call', _306 => _306()]), children: "+ Column" }),
|
|
2816
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Delete row", disabled: off, onClick: () => _optionalChain([run, 'call', _307 => _307(), 'optionalAccess', _308 => _308.deleteRow, 'call', _309 => _309(), 'access', _310 => _310.run, 'call', _311 => _311()]), children: "\u2212 Row" }),
|
|
2817
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Delete column", disabled: off, onClick: () => _optionalChain([run, 'call', _312 => _312(), 'optionalAccess', _313 => _313.deleteColumn, 'call', _314 => _314(), 'access', _315 => _315.run, 'call', _316 => _316()]), children: "\u2212 Column" }),
|
|
2818
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Merge cells", disabled: off || !_optionalChain([s, 'optionalAccess', _317 => _317.canMerge]), onClick: () => _optionalChain([run, 'call', _318 => _318(), 'optionalAccess', _319 => _319.mergeCells, 'call', _320 => _320(), 'access', _321 => _321.run, 'call', _322 => _322()]), children: "Merge" }),
|
|
2819
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Split cell", disabled: off || !_optionalChain([s, 'optionalAccess', _323 => _323.canSplit]), onClick: () => _optionalChain([run, 'call', _324 => _324(), 'optionalAccess', _325 => _325.splitCell, 'call', _326 => _326(), 'access', _327 => _327.run, 'call', _328 => _328()]), children: "Split" }),
|
|
2820
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Toggle header row", disabled: off, onClick: () => _optionalChain([run, 'call', _329 => _329(), 'optionalAccess', _330 => _330.toggleHeaderRow, 'call', _331 => _331(), 'access', _332 => _332.run, 'call', _333 => _333()]), children: "Header row" }),
|
|
2821
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Delete table", disabled: off, onClick: () => _optionalChain([run, 'call', _334 => _334(), 'optionalAccess', _335 => _335.deleteTable, 'call', _336 => _336(), 'access', _337 => _337.run, 'call', _338 => _338()]), className: "june-doc__btn--danger", children: "Delete table" })
|
|
2637
2822
|
] }) }) : null
|
|
2638
2823
|
] });
|
|
2639
2824
|
}
|
|
@@ -2774,7 +2959,7 @@ function DocumentContent({ editor, layout = "page", zoom = 1, showMarks = false,
|
|
|
2774
2959
|
const page = paged ? Math.min(total, Math.max(1, Math.floor(y / stride) + 1)) : 1;
|
|
2775
2960
|
if (last.current.page !== page || last.current.pages !== total) {
|
|
2776
2961
|
last.current = { page, pages: total };
|
|
2777
|
-
_optionalChain([metricsRef, 'access',
|
|
2962
|
+
_optionalChain([metricsRef, 'access', _339 => _339.current, 'optionalCall', _340 => _340({ page, pages: total })]);
|
|
2778
2963
|
}
|
|
2779
2964
|
};
|
|
2780
2965
|
report();
|
|
@@ -2783,12 +2968,12 @@ function DocumentContent({ editor, layout = "page", zoom = 1, showMarks = false,
|
|
|
2783
2968
|
const onLoad = () => _chunkG6YPSE6Jcjs.remeasurePagination.call(void 0, editor);
|
|
2784
2969
|
prose.addEventListener("load", onLoad, true);
|
|
2785
2970
|
const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(report) : null;
|
|
2786
|
-
_optionalChain([ro, 'optionalAccess',
|
|
2971
|
+
_optionalChain([ro, 'optionalAccess', _341 => _341.observe, 'call', _342 => _342(s)]);
|
|
2787
2972
|
return () => {
|
|
2788
2973
|
editor.off("transaction", report);
|
|
2789
2974
|
c.removeEventListener("scroll", report);
|
|
2790
2975
|
prose.removeEventListener("load", onLoad, true);
|
|
2791
|
-
_optionalChain([ro, 'optionalAccess',
|
|
2976
|
+
_optionalChain([ro, 'optionalAccess', _343 => _343.disconnect, 'call', _344 => _344()]);
|
|
2792
2977
|
};
|
|
2793
2978
|
}, [editor, paged, zoom, stride]);
|
|
2794
2979
|
const minHeight = paged ? pages * g.height + (pages - 1) * PAGE_GAP : void 0;
|
|
@@ -2829,12 +3014,12 @@ function DocumentFindBar({ editor, editable, onClose, onNotice }) {
|
|
|
2829
3014
|
editor,
|
|
2830
3015
|
selector: ({ editor: ed }) => {
|
|
2831
3016
|
const s = _chunkG6YPSE6Jcjs.getSearchState.call(void 0, ed);
|
|
2832
|
-
return { count: _nullishCoalesce(_optionalChain([s, 'optionalAccess',
|
|
3017
|
+
return { count: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _345 => _345.matches, 'access', _346 => _346.length]), () => ( 0)), current: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _347 => _347.current]), () => ( -1)) };
|
|
2833
3018
|
}
|
|
2834
3019
|
});
|
|
2835
3020
|
_react.useEffect.call(void 0, () => {
|
|
2836
|
-
_optionalChain([input, 'access',
|
|
2837
|
-
_optionalChain([input, 'access',
|
|
3021
|
+
_optionalChain([input, 'access', _348 => _348.current, 'optionalAccess', _349 => _349.focus, 'call', _350 => _350()]);
|
|
3022
|
+
_optionalChain([input, 'access', _351 => _351.current, 'optionalAccess', _352 => _352.select, 'call', _353 => _353()]);
|
|
2838
3023
|
}, []);
|
|
2839
3024
|
_react.useEffect.call(void 0, () => {
|
|
2840
3025
|
_chunkG6YPSE6Jcjs.setSearch.call(void 0, editor, { term, caseSensitive, current: 0 });
|
|
@@ -2842,8 +3027,8 @@ function DocumentFindBar({ editor, editable, onClose, onNotice }) {
|
|
|
2842
3027
|
_react.useEffect.call(void 0, () => () => {
|
|
2843
3028
|
if (!editor.isDestroyed) _chunkG6YPSE6Jcjs.setSearch.call(void 0, editor, { term: "" });
|
|
2844
3029
|
}, [editor]);
|
|
2845
|
-
const count = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
2846
|
-
const current = _nullishCoalesce(_optionalChain([info, 'optionalAccess',
|
|
3030
|
+
const count = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _354 => _354.count]), () => ( 0));
|
|
3031
|
+
const current = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _355 => _355.current]), () => ( -1));
|
|
2847
3032
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2848
3033
|
"div",
|
|
2849
3034
|
{
|
|
@@ -3121,12 +3306,12 @@ function toHalfPoints(value) {
|
|
|
3121
3306
|
if (!m) return void 0;
|
|
3122
3307
|
const n = Number(m[1]);
|
|
3123
3308
|
if (!Number.isFinite(n) || n <= 0) return void 0;
|
|
3124
|
-
const pt = _optionalChain([m, 'access',
|
|
3309
|
+
const pt = _optionalChain([m, 'access', _356 => _356[2], 'optionalAccess', _357 => _357.toLowerCase, 'call', _358 => _358()]) === "pt" ? n : n * 0.75;
|
|
3125
3310
|
return Math.round(pt * 2);
|
|
3126
3311
|
}
|
|
3127
3312
|
function firstFontFamily(value) {
|
|
3128
3313
|
if (typeof value !== "string") return void 0;
|
|
3129
|
-
const first = _optionalChain([value, 'access',
|
|
3314
|
+
const first = _optionalChain([value, 'access', _359 => _359.split, 'call', _360 => _360(","), 'access', _361 => _361[0], 'optionalAccess', _362 => _362.trim, 'call', _363 => _363(), 'access', _364 => _364.replace, 'call', _365 => _365(/^['"]|['"]$/g, "")]);
|
|
3130
3315
|
return first || void 0;
|
|
3131
3316
|
}
|
|
3132
3317
|
var ORDERED_REF = "june-ordered";
|
|
@@ -3142,9 +3327,9 @@ function runs(d, node, fmt) {
|
|
|
3142
3327
|
const marks = _nullishCoalesce(child.marks, () => ( []));
|
|
3143
3328
|
const has = (type) => marks.some((m) => m.type === type);
|
|
3144
3329
|
const link = marks.find((m) => m.type === "link");
|
|
3145
|
-
const style = _nullishCoalesce(_optionalChain([marks, 'access',
|
|
3330
|
+
const style = _nullishCoalesce(_optionalChain([marks, 'access', _366 => _366.find, 'call', _367 => _367((m) => m.type === "textStyle"), 'optionalAccess', _368 => _368.attrs]), () => ( {}));
|
|
3146
3331
|
const highlight = marks.find((m) => m.type === "highlight");
|
|
3147
|
-
const fill = highlight ? _nullishCoalesce(toDocxColor(_optionalChain([highlight, 'access',
|
|
3332
|
+
const fill = highlight ? _nullishCoalesce(toDocxColor(_optionalChain([highlight, 'access', _369 => _369.attrs, 'optionalAccess', _370 => _370.color])), () => ( "FFF59D")) : void 0;
|
|
3148
3333
|
const run = new d.TextRun({
|
|
3149
3334
|
text: child.text,
|
|
3150
3335
|
bold: fmt.bold || has("bold") || void 0,
|
|
@@ -3158,13 +3343,13 @@ function runs(d, node, fmt) {
|
|
|
3158
3343
|
color: _nullishCoalesce(toDocxColor(style.color), () => ( (link ? "0563C1" : void 0))),
|
|
3159
3344
|
shading: fill ? { type: d.ShadingType.CLEAR, fill, color: "auto" } : void 0
|
|
3160
3345
|
});
|
|
3161
|
-
const href = typeof _optionalChain([link, 'optionalAccess',
|
|
3346
|
+
const href = typeof _optionalChain([link, 'optionalAccess', _371 => _371.attrs, 'optionalAccess', _372 => _372.href]) === "string" ? _chunkG6YPSE6Jcjs.sanitizeHref.call(void 0, link.attrs.href) : null;
|
|
3162
3347
|
out.push(href ? new d.ExternalHyperlink({ link: href, children: [run] }) : run);
|
|
3163
3348
|
}
|
|
3164
3349
|
return out;
|
|
3165
3350
|
}
|
|
3166
3351
|
function paragraph(d, node, fmt, extra = {}) {
|
|
3167
|
-
const align = _optionalChain([node, 'access',
|
|
3352
|
+
const align = _optionalChain([node, 'access', _373 => _373.attrs, 'optionalAccess', _374 => _374.textAlign]);
|
|
3168
3353
|
return new d.Paragraph({
|
|
3169
3354
|
children: runs(d, node, fmt),
|
|
3170
3355
|
alignment: align === "center" ? d.AlignmentType.CENTER : align === "right" ? d.AlignmentType.RIGHT : align === "justify" ? d.AlignmentType.JUSTIFIED : void 0,
|
|
@@ -3226,8 +3411,8 @@ function table(d, node, state) {
|
|
|
3226
3411
|
return new d.Table({ rows, width: { size: 100, type: d.WidthType.PERCENTAGE } });
|
|
3227
3412
|
}
|
|
3228
3413
|
function image(d, node, state) {
|
|
3229
|
-
const src = typeof _optionalChain([node, 'access',
|
|
3230
|
-
const alt = typeof _optionalChain([node, 'access',
|
|
3414
|
+
const src = typeof _optionalChain([node, 'access', _375 => _375.attrs, 'optionalAccess', _376 => _376.src]) === "string" ? node.attrs.src : "";
|
|
3415
|
+
const alt = typeof _optionalChain([node, 'access', _377 => _377.attrs, 'optionalAccess', _378 => _378.alt]) === "string" ? node.attrs.alt : "";
|
|
3231
3416
|
const img = state.images.get(src);
|
|
3232
3417
|
if (img) {
|
|
3233
3418
|
return [
|
|
@@ -3259,7 +3444,7 @@ function image(d, node, state) {
|
|
|
3259
3444
|
}
|
|
3260
3445
|
function collectImages(nodes, out) {
|
|
3261
3446
|
for (const node of _nullishCoalesce(nodes, () => ( []))) {
|
|
3262
|
-
const src = _optionalChain([node, 'access',
|
|
3447
|
+
const src = _optionalChain([node, 'access', _379 => _379.attrs, 'optionalAccess', _380 => _380.src]);
|
|
3263
3448
|
if (node.type === "image" && typeof src === "string" && src && !out.has(src)) out.set(src, node.attrs);
|
|
3264
3449
|
if (node.content) collectImages(node.content, out);
|
|
3265
3450
|
}
|
|
@@ -3296,14 +3481,14 @@ async function loadImage(src, attrs) {
|
|
|
3296
3481
|
const type = IMAGE_TYPES[blob.type.toLowerCase()];
|
|
3297
3482
|
if (!type) return null;
|
|
3298
3483
|
const natural = await naturalSize(blob);
|
|
3299
|
-
let width = Number(_optionalChain([attrs, 'optionalAccess',
|
|
3300
|
-
let height = Number(_optionalChain([attrs, 'optionalAccess',
|
|
3484
|
+
let width = Number(_optionalChain([attrs, 'optionalAccess', _381 => _381.width])) || natural.width;
|
|
3485
|
+
let height = Number(_optionalChain([attrs, 'optionalAccess', _382 => _382.height])) || natural.height * width / natural.width;
|
|
3301
3486
|
if (width > MAX_IMAGE_WIDTH) {
|
|
3302
3487
|
height = height * MAX_IMAGE_WIDTH / width;
|
|
3303
3488
|
width = MAX_IMAGE_WIDTH;
|
|
3304
3489
|
}
|
|
3305
3490
|
return { data: new Uint8Array(await blob.arrayBuffer()), type, width: Math.round(width), height: Math.round(height) };
|
|
3306
|
-
} catch (
|
|
3491
|
+
} catch (e8) {
|
|
3307
3492
|
return null;
|
|
3308
3493
|
}
|
|
3309
3494
|
}
|
|
@@ -3328,7 +3513,7 @@ function blocks(d, nodes, fmt, state) {
|
|
|
3328
3513
|
out.push(paragraph(d, node, fmt));
|
|
3329
3514
|
break;
|
|
3330
3515
|
case "heading": {
|
|
3331
|
-
const level = Math.min(Math.max(Number(_optionalChain([node, 'access',
|
|
3516
|
+
const level = Math.min(Math.max(Number(_optionalChain([node, 'access', _383 => _383.attrs, 'optionalAccess', _384 => _384.level])) || 1, 1), 3);
|
|
3332
3517
|
out.push(paragraph(d, node, fmt, { heading: headings[level - 1] }));
|
|
3333
3518
|
break;
|
|
3334
3519
|
}
|
|
@@ -3462,7 +3647,7 @@ async function copyDocumentToClipboard(doc) {
|
|
|
3462
3647
|
|
|
3463
3648
|
${docToText(doc.json)}`;
|
|
3464
3649
|
try {
|
|
3465
|
-
if (typeof ClipboardItem !== "undefined" && _optionalChain([navigator, 'access',
|
|
3650
|
+
if (typeof ClipboardItem !== "undefined" && _optionalChain([navigator, 'access', _385 => _385.clipboard, 'optionalAccess', _386 => _386.write])) {
|
|
3466
3651
|
await navigator.clipboard.write([
|
|
3467
3652
|
new ClipboardItem({
|
|
3468
3653
|
"text/html": new Blob([html], { type: "text/html" }),
|
|
@@ -3473,7 +3658,7 @@ ${docToText(doc.json)}`;
|
|
|
3473
3658
|
}
|
|
3474
3659
|
await navigator.clipboard.writeText(text);
|
|
3475
3660
|
return true;
|
|
3476
|
-
} catch (
|
|
3661
|
+
} catch (e9) {
|
|
3477
3662
|
return false;
|
|
3478
3663
|
}
|
|
3479
3664
|
}
|
|
@@ -3535,12 +3720,12 @@ function DocumentEditorImpl(props) {
|
|
|
3535
3720
|
}
|
|
3536
3721
|
}, [contentKey]);
|
|
3537
3722
|
_react.useEffect.call(void 0, () => {
|
|
3538
|
-
if (parsed.error) _optionalChain([optionsRef, 'access',
|
|
3723
|
+
if (parsed.error) _optionalChain([optionsRef, 'access', _387 => _387.current, 'access', _388 => _388.onError, 'optionalCall', _389 => _389(parsed.error)]);
|
|
3539
3724
|
}, [parsed.error]);
|
|
3540
|
-
const title = useDocumentValue(store, documentId, (r) => _nullishCoalesce(_optionalChain([r, 'optionalAccess',
|
|
3541
|
-
const pending = useDocumentValue(store, documentId, (r) => _nullishCoalesce(_optionalChain([r, 'optionalAccess',
|
|
3725
|
+
const title = useDocumentValue(store, documentId, (r) => _nullishCoalesce(_optionalChain([r, 'optionalAccess', _390 => _390.title]), () => ( titleProp)));
|
|
3726
|
+
const pending = useDocumentValue(store, documentId, (r) => _nullishCoalesce(_optionalChain([r, 'optionalAccess', _391 => _391.pending]), () => ( null)));
|
|
3542
3727
|
const words = useDocumentValue(store, documentId, (r) => r ? _chunkG6YPSE6Jcjs.wordCountOf.call(void 0, r.json) : 0);
|
|
3543
|
-
const recordStatus = useDocumentValue(store, documentId, (r) => _nullishCoalesce(_optionalChain([r, 'optionalAccess',
|
|
3728
|
+
const recordStatus = useDocumentValue(store, documentId, (r) => _nullishCoalesce(_optionalChain([r, 'optionalAccess', _392 => _392.status]), () => ( status)));
|
|
3544
3729
|
const [saveState, setSaveState] = _react.useState.call(void 0, "idle");
|
|
3545
3730
|
const [notice, setNotice] = _react.useState.call(void 0, null);
|
|
3546
3731
|
const [fullscreen, setFullscreen] = _react.useState.call(void 0, false);
|
|
@@ -3559,7 +3744,7 @@ function DocumentEditorImpl(props) {
|
|
|
3559
3744
|
};
|
|
3560
3745
|
}, [fullscreen]);
|
|
3561
3746
|
const lastSavedKey = _react.useRef.call(void 0, "");
|
|
3562
|
-
const seenRevision = _react.useRef.call(void 0, _nullishCoalesce(_optionalChain([store, 'access',
|
|
3747
|
+
const seenRevision = _react.useRef.call(void 0, _nullishCoalesce(_optionalChain([store, 'access', _393 => _393.get, 'call', _394 => _394(documentId), 'optionalAccess', _395 => _395.revision]), () => ( 0)));
|
|
3563
3748
|
const readyRef = _react.useRef.call(void 0, false);
|
|
3564
3749
|
const flash = _react.useCallback.call(void 0, (message) => {
|
|
3565
3750
|
setNotice(message);
|
|
@@ -3572,7 +3757,7 @@ function DocumentEditorImpl(props) {
|
|
|
3572
3757
|
const emitChange = _react.useCallback.call(void 0,
|
|
3573
3758
|
(source) => {
|
|
3574
3759
|
const record = store.get(documentId);
|
|
3575
|
-
if (record) _optionalChain([optionsRef, 'access',
|
|
3760
|
+
if (record) _optionalChain([optionsRef, 'access', _396 => _396.current, 'access', _397 => _397.onDocumentChange, 'optionalCall', _398 => _398({ ...snapshotOf(record), source })]);
|
|
3576
3761
|
},
|
|
3577
3762
|
[store, documentId]
|
|
3578
3763
|
);
|
|
@@ -3582,7 +3767,7 @@ function DocumentEditorImpl(props) {
|
|
|
3582
3767
|
const delay = _nullishCoalesce(options.autosaveDelay, () => ( 1500));
|
|
3583
3768
|
return delay > 0 ? _chunkG6YPSE6Jcjs.debounce.call(void 0, () => void saveRef.current(), delay) : null;
|
|
3584
3769
|
}, [options.autosaveDelay]);
|
|
3585
|
-
_react.useEffect.call(void 0, () => () => _optionalChain([autosave, 'optionalAccess',
|
|
3770
|
+
_react.useEffect.call(void 0, () => () => _optionalChain([autosave, 'optionalAccess', _399 => _399.flush, 'call', _400 => _400()]), [autosave]);
|
|
3586
3771
|
saveRef.current = async () => {
|
|
3587
3772
|
const record = store.get(documentId);
|
|
3588
3773
|
const onSave = optionsRef.current.onSave;
|
|
@@ -3610,7 +3795,7 @@ function DocumentEditorImpl(props) {
|
|
|
3610
3795
|
setSaveState(latestKey === key ? "saved" : "dirty");
|
|
3611
3796
|
} catch (error) {
|
|
3612
3797
|
setSaveState("error");
|
|
3613
|
-
_optionalChain([optionsRef, 'access',
|
|
3798
|
+
_optionalChain([optionsRef, 'access', _401 => _401.current, 'access', _402 => _402.onError, 'optionalCall', _403 => _403(_chunkG6YPSE6Jcjs.toJuneError.call(void 0, error, "DOCUMENT_ERROR", "Saving the document failed"))]);
|
|
3614
3799
|
}
|
|
3615
3800
|
};
|
|
3616
3801
|
const markDirty = _react.useCallback.call(void 0,
|
|
@@ -3620,7 +3805,7 @@ function DocumentEditorImpl(props) {
|
|
|
3620
3805
|
return;
|
|
3621
3806
|
}
|
|
3622
3807
|
setSaveState("dirty");
|
|
3623
|
-
_optionalChain([autosave, 'optionalCall',
|
|
3808
|
+
_optionalChain([autosave, 'optionalCall', _404 => _404()]);
|
|
3624
3809
|
},
|
|
3625
3810
|
[autosave]
|
|
3626
3811
|
);
|
|
@@ -3629,7 +3814,7 @@ function DocumentEditorImpl(props) {
|
|
|
3629
3814
|
const t = setTimeout(() => setSaveState((s) => s === "saved" ? "idle" : s), 2500);
|
|
3630
3815
|
return () => clearTimeout(t);
|
|
3631
3816
|
}, [saveState, options.onSave]);
|
|
3632
|
-
const [initialJson] = _react.useState.call(void 0, () => _nullishCoalesce(_nullishCoalesce(_optionalChain([store, 'access',
|
|
3817
|
+
const [initialJson] = _react.useState.call(void 0, () => _nullishCoalesce(_nullishCoalesce(_optionalChain([store, 'access', _405 => _405.get, 'call', _406 => _406(documentId), 'optionalAccess', _407 => _407.json]), () => ( parsed.json)), () => ( _chunkG6YPSE6Jcjs.emptyDoc.call(void 0, ))));
|
|
3633
3818
|
const extensions = _react.useMemo.call(void 0, () => _chunkG6YPSE6Jcjs.createDocumentExtensions.call(void 0, ), []);
|
|
3634
3819
|
const onUpdateRef = _react.useRef.call(void 0, () => {
|
|
3635
3820
|
});
|
|
@@ -3672,10 +3857,10 @@ function DocumentEditorImpl(props) {
|
|
|
3672
3857
|
markDirty(false);
|
|
3673
3858
|
} else if (outcome === "conflict") {
|
|
3674
3859
|
const record = store.get(documentId);
|
|
3675
|
-
_optionalChain([optionsRef, 'access',
|
|
3860
|
+
_optionalChain([optionsRef, 'access', _408 => _408.current, 'access', _409 => _409.onConflict, 'optionalCall', _410 => _410({
|
|
3676
3861
|
documentId,
|
|
3677
|
-
title: _nullishCoalesce(_optionalChain([record, 'optionalAccess',
|
|
3678
|
-
conflicts: _nullishCoalesce(_optionalChain([record, 'optionalAccess',
|
|
3862
|
+
title: _nullishCoalesce(_optionalChain([record, 'optionalAccess', _411 => _411.title]), () => ( titleProp)),
|
|
3863
|
+
conflicts: _nullishCoalesce(_optionalChain([record, 'optionalAccess', _412 => _412.pending, 'optionalAccess', _413 => _413.conflicts]), () => ( 1))
|
|
3679
3864
|
})]);
|
|
3680
3865
|
}
|
|
3681
3866
|
}, [store, documentId, titleProp, parsed.json, documentType, status, emitChange, markDirty]);
|
|
@@ -3702,7 +3887,7 @@ function DocumentEditorImpl(props) {
|
|
|
3702
3887
|
if (!record) return;
|
|
3703
3888
|
readyRef.current = true;
|
|
3704
3889
|
lastSavedKey.current = JSON.stringify([record.title, _chunkG6YPSE6Jcjs.docKey.call(void 0, record.json)]);
|
|
3705
|
-
_optionalChain([optionsRef, 'access',
|
|
3890
|
+
_optionalChain([optionsRef, 'access', _414 => _414.current, 'access', _415 => _415.onDocumentReady, 'optionalCall', _416 => _416(snapshotOf(record))]);
|
|
3706
3891
|
}, [editor, store, documentId, title]);
|
|
3707
3892
|
const handleTitle = (value) => {
|
|
3708
3893
|
store.setTitle(documentId, value);
|
|
@@ -3727,9 +3912,9 @@ function DocumentEditorImpl(props) {
|
|
|
3727
3912
|
// always the latest editor content
|
|
3728
3913
|
});
|
|
3729
3914
|
if (result.blob) downloadResult(result);
|
|
3730
|
-
_optionalChain([optionsRef, 'access',
|
|
3915
|
+
_optionalChain([optionsRef, 'access', _417 => _417.current, 'access', _418 => _418.onExport, 'optionalCall', _419 => _419({ documentId, format: format2, ...result })]);
|
|
3731
3916
|
} catch (error) {
|
|
3732
|
-
_optionalChain([optionsRef, 'access',
|
|
3917
|
+
_optionalChain([optionsRef, 'access', _420 => _420.current, 'access', _421 => _421.onError, 'optionalCall', _422 => _422(_chunkG6YPSE6Jcjs.toJuneError.call(void 0, error, "EXPORT_ERROR"))]);
|
|
3733
3918
|
flash("Export failed");
|
|
3734
3919
|
}
|
|
3735
3920
|
};
|
|
@@ -3855,6 +4040,96 @@ function DocumentEditorImpl(props) {
|
|
|
3855
4040
|
);
|
|
3856
4041
|
}
|
|
3857
4042
|
|
|
4043
|
+
// src/features/document-editor/document-preview.tsx
|
|
4044
|
+
|
|
4045
|
+
var _reactdom = require('react-dom');
|
|
4046
|
+
|
|
4047
|
+
function DocumentPreview(props) {
|
|
4048
|
+
const { documentId, title = "Untitled document", content, editable = true } = props;
|
|
4049
|
+
const { theme: contextTheme } = useJuneTheme();
|
|
4050
|
+
const resolvedTheme = props.theme && props.theme !== "auto" ? props.theme : contextTheme;
|
|
4051
|
+
const ctxOptions = useDocumentOptions();
|
|
4052
|
+
const store = _react.useMemo.call(void 0, () => _nullishCoalesce(_nullishCoalesce(_optionalChain([props, 'access', _423 => _423.options, 'optionalAccess', _424 => _424.store]), () => ( ctxOptions.store)), () => ( getDefaultDocumentStore())), [_optionalChain([props, 'access', _425 => _425.options, 'optionalAccess', _426 => _426.store]), ctxOptions.store]);
|
|
4053
|
+
const storedJson = useDocumentValue(store, documentId, (record) => _optionalChain([record, 'optionalAccess', _427 => _427.json]));
|
|
4054
|
+
const [open, setOpen] = _react.useState.call(void 0, false);
|
|
4055
|
+
const [preferStore, setPreferStore] = _react.useState.call(void 0, false);
|
|
4056
|
+
const contentKey = typeof content === "string" ? content : content ? JSON.stringify(content) : "";
|
|
4057
|
+
_react.useEffect.call(void 0, () => {
|
|
4058
|
+
setPreferStore(false);
|
|
4059
|
+
}, [contentKey]);
|
|
4060
|
+
const html = _react.useMemo.call(void 0, () => {
|
|
4061
|
+
try {
|
|
4062
|
+
const fromContent = contentKey ? _chunkG6YPSE6Jcjs.parseDocumentContent.call(void 0, contentKey) : null;
|
|
4063
|
+
const doc = preferStore && storedJson ? storedJson : fromContent;
|
|
4064
|
+
return doc ? _chunkG6YPSE6Jcjs.docToHtml.call(void 0, doc) : "";
|
|
4065
|
+
} catch (e10) {
|
|
4066
|
+
return "";
|
|
4067
|
+
}
|
|
4068
|
+
}, [contentKey, preferStore, storedJson]);
|
|
4069
|
+
_react.useEffect.call(void 0, () => {
|
|
4070
|
+
if (!open || typeof document === "undefined") return;
|
|
4071
|
+
const prev = document.body.style.overflow;
|
|
4072
|
+
document.body.style.overflow = "hidden";
|
|
4073
|
+
return () => {
|
|
4074
|
+
document.body.style.overflow = prev;
|
|
4075
|
+
};
|
|
4076
|
+
}, [open]);
|
|
4077
|
+
const close = () => {
|
|
4078
|
+
setPreferStore(true);
|
|
4079
|
+
setOpen(false);
|
|
4080
|
+
};
|
|
4081
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
4082
|
+
!open ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "section", { className: "june-doc june-doc-card", "data-theme": resolvedTheme, "aria-label": title, children: [
|
|
4083
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "june-doc-card__bar", children: [
|
|
4084
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "june-doc-card__title", children: title }),
|
|
4085
|
+
editable ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "june-doc__btn june-doc__btn--icon june-doc__btn--ghost", "aria-label": "Edit document", title: "Edit", onClick: () => setOpen(true), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "pencil", size: 16 }) }) : null
|
|
4086
|
+
] }),
|
|
4087
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "june-doc-card__canvas", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "june-doc-card__sheet", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "june-doc__prose", dangerouslySetInnerHTML: { __html: html } }) }) })
|
|
4088
|
+
] }) : null,
|
|
4089
|
+
open && typeof document !== "undefined" ? _reactdom.createPortal.call(void 0,
|
|
4090
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "june-doc-modal", "data-theme": resolvedTheme, onMouseDown: close, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
4091
|
+
"div",
|
|
4092
|
+
{
|
|
4093
|
+
className: "june-doc june-doc-modal__panel",
|
|
4094
|
+
role: "dialog",
|
|
4095
|
+
"aria-modal": "true",
|
|
4096
|
+
"aria-label": title,
|
|
4097
|
+
tabIndex: -1,
|
|
4098
|
+
"data-theme": resolvedTheme,
|
|
4099
|
+
onMouseDown: (event) => event.stopPropagation(),
|
|
4100
|
+
onKeyDown: (event) => {
|
|
4101
|
+
if (event.key !== "Escape" || event.defaultPrevented) return;
|
|
4102
|
+
if (event.currentTarget.querySelector(".june-doc--fullscreen")) return;
|
|
4103
|
+
close();
|
|
4104
|
+
},
|
|
4105
|
+
children: [
|
|
4106
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "june-doc-modal__bar", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "button", { type: "button", className: "june-doc__btn june-doc__btn--ghost", "aria-label": "Close document", onClick: close, children: [
|
|
4107
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "close", size: 16 }),
|
|
4108
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Close" })
|
|
4109
|
+
] }) }),
|
|
4110
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "june-doc-modal__body", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
4111
|
+
DocumentEditorImpl,
|
|
4112
|
+
{
|
|
4113
|
+
documentId: props.documentId,
|
|
4114
|
+
title: props.title,
|
|
4115
|
+
content: props.content,
|
|
4116
|
+
documentType: props.documentType,
|
|
4117
|
+
status: props.status,
|
|
4118
|
+
editable: props.editable,
|
|
4119
|
+
exportFormats: props.exportFormats,
|
|
4120
|
+
theme: props.theme,
|
|
4121
|
+
generating: props.generating,
|
|
4122
|
+
options: props.options
|
|
4123
|
+
}
|
|
4124
|
+
) })
|
|
4125
|
+
]
|
|
4126
|
+
}
|
|
4127
|
+
) }),
|
|
4128
|
+
document.body
|
|
4129
|
+
) : null
|
|
4130
|
+
] });
|
|
4131
|
+
}
|
|
4132
|
+
|
|
3858
4133
|
// src/features/document-editor/document-component.tsx
|
|
3859
4134
|
|
|
3860
4135
|
var DOCUMENT_COMPONENT_DESCRIPTION = 'Custom component. An editable document. DocumentEditor(documentId, title, content, documentType?, status?, editable?, exportFormats?). Place it in the root container (Card or Stack). "content" is the full document body as one Markdown string. Reuse documentId when revising the same document. Use it only when the user asks to create or revise a document.';
|
|
@@ -3875,18 +4150,19 @@ function DocumentEditor(props) {
|
|
|
3875
4150
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DocumentEditorImpl, { ...props });
|
|
3876
4151
|
}
|
|
3877
4152
|
function OpenUIDocument({ props }) {
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
);
|
|
4153
|
+
const { isStreaming } = useJuneRuntime();
|
|
4154
|
+
const shared = {
|
|
4155
|
+
documentId: props.documentId,
|
|
4156
|
+
title: props.title,
|
|
4157
|
+
content: props.content,
|
|
4158
|
+
documentType: props.documentType,
|
|
4159
|
+
status: props.status,
|
|
4160
|
+
editable: props.editable,
|
|
4161
|
+
exportFormats: props.exportFormats
|
|
4162
|
+
};
|
|
4163
|
+
if (isStreaming) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DocumentDraft, { title: props.title, state: "drafting" });
|
|
4164
|
+
if (props.editable === false) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DocumentEditor, { ...shared });
|
|
4165
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DocumentPreview, { ...shared });
|
|
3890
4166
|
}
|
|
3891
4167
|
var JuneDocumentEditorComponent = _reactlang.defineComponent.call(void 0, {
|
|
3892
4168
|
name: "DocumentEditor",
|
|
@@ -3901,7 +4177,7 @@ function withDocumentEditor(library) {
|
|
|
3901
4177
|
add: [{ component: JuneDocumentEditorComponent, slots: ["Card"] }]
|
|
3902
4178
|
}
|
|
3903
4179
|
});
|
|
3904
|
-
} catch (
|
|
4180
|
+
} catch (e11) {
|
|
3905
4181
|
return library.extend({ components: { add: [JuneDocumentEditorComponent] } });
|
|
3906
4182
|
}
|
|
3907
4183
|
}
|
|
@@ -3937,8 +4213,8 @@ function getDocumentEditorInstructions(options = {}) {
|
|
|
3937
4213
|
const rules = getDocumentEditorRules(options);
|
|
3938
4214
|
return ["Document drafting:", ...rules.map((rule, i) => `${i + 1}. ${rule}`)].join("\n");
|
|
3939
4215
|
}
|
|
3940
|
-
var EXAMPLE_NEW = 'root =
|
|
3941
|
-
var EXAMPLE_EDIT = 'root =
|
|
4216
|
+
var EXAMPLE_NEW = 'root = Card([doc])\ndoc = DocumentEditor("business-proposal", "Business Proposal", "## Executive Summary\\n\\nThis proposal outlines [SERVICE] for [CLIENT NAME].\\n\\n## Scope of Work\\n\\n- Discovery\\n- Delivery\\n\\n## Pricing\\n\\n| Item | Cost |\\n| --- | --- |\\n| Discovery | [AMOUNT] |", "proposal", "draft")';
|
|
4217
|
+
var EXAMPLE_EDIT = 'root = Card([doc])\ndoc = DocumentEditor("business-proposal", "Business Proposal", "## Executive Summary\\n\\nThis proposal outlines [SERVICE] for [CLIENT NAME].\\n\\n## Scope of Work\\n\\n- Discovery\\n- Delivery\\n\\n## Pricing\\n\\n| Item | Cost |\\n| --- | --- |\\n| Discovery | [AMOUNT] |\\n| Delivery | [AMOUNT] |", "proposal", "draft")';
|
|
3942
4218
|
function documentPromptOptions(options = {}) {
|
|
3943
4219
|
return {
|
|
3944
4220
|
additionalRules: getDocumentEditorRules(options),
|
|
@@ -3981,7 +4257,7 @@ var defaultToolApprovalLabels = {
|
|
|
3981
4257
|
var format = (value) => {
|
|
3982
4258
|
try {
|
|
3983
4259
|
return _nullishCoalesce(JSON.stringify(value, null, 2), () => ( String(value)));
|
|
3984
|
-
} catch (
|
|
4260
|
+
} catch (e12) {
|
|
3985
4261
|
return String(value);
|
|
3986
4262
|
}
|
|
3987
4263
|
};
|
|
@@ -3997,19 +4273,19 @@ function ToolApproval({
|
|
|
3997
4273
|
className
|
|
3998
4274
|
}) {
|
|
3999
4275
|
const labels = { ...defaultToolApprovalLabels, ...labelOverrides };
|
|
4000
|
-
const options = _optionalChain([request, 'access',
|
|
4276
|
+
const options = _optionalChain([request, 'access', _428 => _428.options, 'optionalAccess', _429 => _429.length]) ? request.options : ["approve", "reject"];
|
|
4001
4277
|
const [draft, setDraft] = _react.useState.call(void 0, null);
|
|
4002
4278
|
const [draftError, setDraftError] = _react.useState.call(void 0, null);
|
|
4003
4279
|
const titleId = _react.useId.call(void 0, );
|
|
4004
4280
|
const pending = status === "pending";
|
|
4005
4281
|
const decide = (decision) => {
|
|
4006
|
-
if (!disabled && pending) _optionalChain([onDecide, 'optionalCall',
|
|
4282
|
+
if (!disabled && pending) _optionalChain([onDecide, 'optionalCall', _430 => _430(decision)]);
|
|
4007
4283
|
};
|
|
4008
4284
|
const saveEdit = () => {
|
|
4009
4285
|
let editedArguments;
|
|
4010
4286
|
try {
|
|
4011
4287
|
editedArguments = JSON.parse(_nullishCoalesce(draft, () => ( "null")));
|
|
4012
|
-
} catch (
|
|
4288
|
+
} catch (e13) {
|
|
4013
4289
|
setDraftError(labels.invalidJson);
|
|
4014
4290
|
return;
|
|
4015
4291
|
}
|
|
@@ -4098,7 +4374,7 @@ function useToolApproval() {
|
|
|
4098
4374
|
const settle = _react.useCallback.call(void 0, (id, decision) => {
|
|
4099
4375
|
const resolve = waiters.current.get(id);
|
|
4100
4376
|
waiters.current.delete(id);
|
|
4101
|
-
_optionalChain([resolve, 'optionalCall',
|
|
4377
|
+
_optionalChain([resolve, 'optionalCall', _431 => _431(decision)]);
|
|
4102
4378
|
}, []);
|
|
4103
4379
|
const request = _react.useCallback.call(void 0, (input) => {
|
|
4104
4380
|
const id = _nullishCoalesce(input.id, () => ( nextId()));
|
|
@@ -4173,7 +4449,7 @@ function messageContentToText(content) {
|
|
|
4173
4449
|
function parse(data) {
|
|
4174
4450
|
try {
|
|
4175
4451
|
return JSON.parse(data);
|
|
4176
|
-
} catch (
|
|
4452
|
+
} catch (e14) {
|
|
4177
4453
|
return void 0;
|
|
4178
4454
|
}
|
|
4179
4455
|
}
|
|
@@ -4187,7 +4463,7 @@ function createLangGraphExtractor(options = {}) {
|
|
|
4187
4463
|
if (!Array.isArray(parsed)) return null;
|
|
4188
4464
|
const [chunk, metadata] = parsed;
|
|
4189
4465
|
if (!chunk || typeof chunk !== "object" || !isAiMessage(chunk)) return null;
|
|
4190
|
-
if (nodes && !(typeof _optionalChain([metadata, 'optionalAccess',
|
|
4466
|
+
if (nodes && !(typeof _optionalChain([metadata, 'optionalAccess', _432 => _432.langgraph_node]) === "string" && nodes.has(metadata.langgraph_node))) return null;
|
|
4191
4467
|
return messageContentToText(chunk.content) || null;
|
|
4192
4468
|
}
|
|
4193
4469
|
if (base === "messages/partial" || base === "messages/complete") {
|
|
@@ -4226,8 +4502,8 @@ function interruptToApprovalRequests(value, idPrefix = "interrupt") {
|
|
|
4226
4502
|
const configs = Array.isArray(hitl.review_configs) ? hitl.review_configs : [];
|
|
4227
4503
|
return hitl.action_requests.flatMap((action, index) => {
|
|
4228
4504
|
if (!action || typeof action.name !== "string") return [];
|
|
4229
|
-
const config = configs.find((c) => _optionalChain([c, 'optionalAccess',
|
|
4230
|
-
const allowed = Array.isArray(_optionalChain([config, 'optionalAccess',
|
|
4505
|
+
const config = configs.find((c) => _optionalChain([c, 'optionalAccess', _433 => _433.action_name]) === action.name);
|
|
4506
|
+
const allowed = Array.isArray(_optionalChain([config, 'optionalAccess', _434 => _434.allowed_decisions])) ? config.allowed_decisions.filter(
|
|
4231
4507
|
(d) => d === "approve" || d === "reject" || d === "edit"
|
|
4232
4508
|
) : void 0;
|
|
4233
4509
|
return [
|