dynim-core 1.0.10 → 1.0.12
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.
|
@@ -32,6 +32,10 @@ export interface Builder {
|
|
|
32
32
|
enter: () => void;
|
|
33
33
|
exit: () => void;
|
|
34
34
|
isActive: () => boolean;
|
|
35
|
+
isPreviewMode: () => boolean;
|
|
36
|
+
togglePreview: () => void;
|
|
37
|
+
enterPreviewMode: () => void;
|
|
38
|
+
exitPreviewMode: () => void;
|
|
35
39
|
getEditorState: () => unknown;
|
|
36
40
|
getTreeState: () => unknown;
|
|
37
41
|
destroy: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/builder/builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAA6B,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAQxE,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAIlE,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wCAAwC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrE,+FAA+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AAE,CAAC,CAAC;IACrE,+FAA+F;IAC/F,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,mEAAmE;IACnE,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,QAAQ,EAAE,MAAM,OAAO,CAAC;IACxB,aAAa,EAAE,MAAM,OAAO,CAAC;IAC7B,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,cAAc,EAAE,MAAM,OAAO,CAAC;IAC9B,YAAY,EAAE,MAAM,OAAO,CAAC;IAC5B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,wBAAgB,aAAa,CAAC,MAAM,GAAE,aAAkB,GAAG,OAAO,CAikBjE;;;;AAMD,wBAAyC"}
|
package/dist/builder/builder.js
CHANGED
|
@@ -17,6 +17,7 @@ import { buildElementIdentifier, getRelevantStyles } from './element-utils';
|
|
|
17
17
|
export function createBuilder(config = {}) {
|
|
18
18
|
const { logo = 'Builder', onExit, onEnter, onExitStart, chatConfig = {}, contentRoot = document.body, pageId = window.location.pathname, apiBase = 'http://localhost:8080', sessionToken, refreshToken, getSession, codeClient: externalCodeClient, loadBundle } = config;
|
|
19
19
|
let isActive = false;
|
|
20
|
+
let isPreviewMode = false;
|
|
20
21
|
let chatWidget = null;
|
|
21
22
|
let state = null;
|
|
22
23
|
let client = null;
|
|
@@ -37,12 +38,18 @@ export function createBuilder(config = {}) {
|
|
|
37
38
|
<span>${logo}</span>
|
|
38
39
|
</div>
|
|
39
40
|
<div class="builder-bar__divider"></div>
|
|
41
|
+
<span class="builder-bar__preview-badge" style="display: none;">
|
|
42
|
+
<svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor">
|
|
43
|
+
<path d="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"/>
|
|
44
|
+
</svg>
|
|
45
|
+
PREVIEWING
|
|
46
|
+
</span>
|
|
40
47
|
<div class="builder-bar__actions">
|
|
41
48
|
<button class="builder-bar__btn builder-bar__btn--preview">
|
|
42
49
|
<svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor">
|
|
43
50
|
<path d="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"/>
|
|
44
51
|
</svg>
|
|
45
|
-
Preview
|
|
52
|
+
<span class="builder-bar__btn-text">Preview</span>
|
|
46
53
|
</button>
|
|
47
54
|
<button class="builder-bar__btn builder-bar__btn--save" disabled>
|
|
48
55
|
<svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor">
|
|
@@ -318,6 +325,11 @@ export function createBuilder(config = {}) {
|
|
|
318
325
|
async function exit() {
|
|
319
326
|
if (!isActive)
|
|
320
327
|
return;
|
|
328
|
+
// Exit preview mode first if active
|
|
329
|
+
if (isPreviewMode) {
|
|
330
|
+
isPreviewMode = false;
|
|
331
|
+
updateBarForPreviewMode(false);
|
|
332
|
+
}
|
|
321
333
|
isActive = false;
|
|
322
334
|
// Notify IMMEDIATELY before any async work
|
|
323
335
|
// This allows BuilderProvider to set isExitingRef before streaming events can interfere
|
|
@@ -404,6 +416,63 @@ export function createBuilder(config = {}) {
|
|
|
404
416
|
console.error('[Builder] Save failed:', error);
|
|
405
417
|
}
|
|
406
418
|
}
|
|
419
|
+
function updateBarForPreviewMode(isPreviewing) {
|
|
420
|
+
const btnText = root.querySelector('.builder-bar__btn--preview .builder-bar__btn-text');
|
|
421
|
+
const previewBadge = root.querySelector('.builder-bar__preview-badge');
|
|
422
|
+
if (btnText) {
|
|
423
|
+
btnText.textContent = isPreviewing ? 'Edit' : 'Preview';
|
|
424
|
+
}
|
|
425
|
+
if (previewBadge) {
|
|
426
|
+
previewBadge.style.display = isPreviewing ? 'flex' : 'none';
|
|
427
|
+
}
|
|
428
|
+
// Add/remove preview mode class for styling
|
|
429
|
+
root.classList.toggle('builder-bar--preview-mode', isPreviewing);
|
|
430
|
+
}
|
|
431
|
+
function enterPreviewMode() {
|
|
432
|
+
if (!isActive || isPreviewMode)
|
|
433
|
+
return;
|
|
434
|
+
isPreviewMode = true;
|
|
435
|
+
console.log('[Builder] Entering preview mode');
|
|
436
|
+
// Hide editing UI
|
|
437
|
+
freezeOverlay?.unmount();
|
|
438
|
+
overlays?.hideAll();
|
|
439
|
+
interactionEngine?.detach();
|
|
440
|
+
aiPromptPopover?.unmount();
|
|
441
|
+
// Hide chat
|
|
442
|
+
chatWidget?.close();
|
|
443
|
+
if (chatWidget?.root) {
|
|
444
|
+
chatWidget.root.style.display = 'none';
|
|
445
|
+
}
|
|
446
|
+
// Clear any selection
|
|
447
|
+
editorState?.clearSelection();
|
|
448
|
+
// Update bar UI
|
|
449
|
+
updateBarForPreviewMode(true);
|
|
450
|
+
}
|
|
451
|
+
function exitPreviewMode() {
|
|
452
|
+
if (!isActive || !isPreviewMode)
|
|
453
|
+
return;
|
|
454
|
+
isPreviewMode = false;
|
|
455
|
+
console.log('[Builder] Exiting preview mode');
|
|
456
|
+
// Restore editing UI
|
|
457
|
+
freezeOverlay?.mount();
|
|
458
|
+
overlays?.mount();
|
|
459
|
+
interactionEngine?.attach();
|
|
460
|
+
aiPromptPopover?.mount();
|
|
461
|
+
// Show chat
|
|
462
|
+
if (chatWidget?.root) {
|
|
463
|
+
chatWidget.root.style.display = '';
|
|
464
|
+
}
|
|
465
|
+
// Update bar UI
|
|
466
|
+
updateBarForPreviewMode(false);
|
|
467
|
+
}
|
|
468
|
+
function togglePreview() {
|
|
469
|
+
if (isPreviewMode) {
|
|
470
|
+
exitPreviewMode();
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
enterPreviewMode();
|
|
474
|
+
}
|
|
475
|
+
}
|
|
407
476
|
root.addEventListener('click', (e) => {
|
|
408
477
|
const target = e.target;
|
|
409
478
|
if (target.closest('.builder-bar__btn--exit')) {
|
|
@@ -413,7 +482,7 @@ export function createBuilder(config = {}) {
|
|
|
413
482
|
}
|
|
414
483
|
if (target.closest('.builder-bar__btn--preview')) {
|
|
415
484
|
e.stopPropagation();
|
|
416
|
-
|
|
485
|
+
togglePreview();
|
|
417
486
|
return;
|
|
418
487
|
}
|
|
419
488
|
if (target.closest('.builder-bar__btn--save')) {
|
|
@@ -435,6 +504,10 @@ export function createBuilder(config = {}) {
|
|
|
435
504
|
enter,
|
|
436
505
|
exit,
|
|
437
506
|
isActive: () => isActive,
|
|
507
|
+
isPreviewMode: () => isPreviewMode,
|
|
508
|
+
togglePreview,
|
|
509
|
+
enterPreviewMode,
|
|
510
|
+
exitPreviewMode,
|
|
438
511
|
getEditorState: () => editorState?.getState(),
|
|
439
512
|
getTreeState: () => treeState?.getState(),
|
|
440
513
|
destroy: () => {
|
package/package.json
CHANGED
package/src/styles/builder.css
CHANGED
|
@@ -70,6 +70,32 @@
|
|
|
70
70
|
margin: 0 4px;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/* Preview badge */
|
|
74
|
+
.builder-bar__preview-badge {
|
|
75
|
+
display: flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
gap: 6px;
|
|
78
|
+
padding: 4px 12px;
|
|
79
|
+
background: #3b82f6;
|
|
80
|
+
color: white;
|
|
81
|
+
border-radius: 4px;
|
|
82
|
+
font-size: 12px;
|
|
83
|
+
font-weight: 600;
|
|
84
|
+
text-transform: uppercase;
|
|
85
|
+
letter-spacing: 0.5px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.builder-bar__preview-badge svg {
|
|
89
|
+
width: 14px;
|
|
90
|
+
height: 14px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* Preview mode bar styling */
|
|
94
|
+
.builder-bar--preview-mode .builder-bar {
|
|
95
|
+
background: linear-gradient(to right, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
|
|
96
|
+
border-bottom: 2px solid #3b82f6;
|
|
97
|
+
}
|
|
98
|
+
|
|
73
99
|
/* Actions section */
|
|
74
100
|
.builder-bar__actions {
|
|
75
101
|
display: flex;
|