@yugoo-design/dsh-design-studio-ui 0.3.3 → 0.3.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/README.md +20 -3
- package/lib/index.d.ts +11 -2
- package/lib/index.js +405 -200
- package/licenses/dsh-distribution.json +103 -103
- package/package.json +3 -2
package/lib/index.js
CHANGED
|
@@ -545,7 +545,7 @@ function ConversationActivity({ rows, active, terminal, locale = "zh", renderTex
|
|
|
545
545
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
546
546
|
className: "companion-message-label",
|
|
547
547
|
children: [
|
|
548
|
-
row.label,
|
|
548
|
+
row.labelText ? row.labelText[locale] : row.label,
|
|
549
549
|
" · ",
|
|
550
550
|
status(row.status)
|
|
551
551
|
]
|
|
@@ -553,7 +553,7 @@ function ConversationActivity({ rows, active, terminal, locale = "zh", renderTex
|
|
|
553
553
|
}, row.id)) })]
|
|
554
554
|
});
|
|
555
555
|
}
|
|
556
|
-
function ConversationMessage({ row, renderText = renderStudioMarkdown, children }) {
|
|
556
|
+
function ConversationMessage({ row, locale = "zh", renderText = renderStudioMarkdown, children }) {
|
|
557
557
|
return /* @__PURE__ */ jsxs("article", {
|
|
558
558
|
className: "companion-message",
|
|
559
559
|
"data-role": row.role,
|
|
@@ -561,7 +561,7 @@ function ConversationMessage({ row, renderText = renderStudioMarkdown, children
|
|
|
561
561
|
children: [
|
|
562
562
|
/* @__PURE__ */ jsxs("div", {
|
|
563
563
|
className: "companion-message-label",
|
|
564
|
-
children: [row.label, row.role === "tool" ? ` · ${row.status}` : ""]
|
|
564
|
+
children: [row.labelText ? row.labelText[locale] : row.label, row.role === "tool" ? ` · ${row.status}` : ""]
|
|
565
565
|
}),
|
|
566
566
|
row.text && /* @__PURE__ */ jsx("div", {
|
|
567
567
|
className: "companion-message-content",
|
|
@@ -593,7 +593,10 @@ function ConversationMessages({ rows, active, terminal, locale }) {
|
|
|
593
593
|
active: active && entry === latest,
|
|
594
594
|
terminal,
|
|
595
595
|
locale
|
|
596
|
-
}, entry.rows[0].id) : /* @__PURE__ */ jsx(ConversationMessage, {
|
|
596
|
+
}, entry.rows[0].id) : /* @__PURE__ */ jsx(ConversationMessage, {
|
|
597
|
+
row: entry.row,
|
|
598
|
+
locale
|
|
599
|
+
}, entry.row.id)) });
|
|
597
600
|
}
|
|
598
601
|
const CONVERSATION_ACTIVITY_CSS = `
|
|
599
602
|
.companion-message{padding:12px 0;border:0;min-width:0;overflow-wrap:anywhere}
|
|
@@ -733,6 +736,7 @@ ${CONVERSATION_ACTIVITY_CSS}
|
|
|
733
736
|
--ds-density-padding:12px;
|
|
734
737
|
--ds-duration-fast:120ms;--ds-duration-normal:200ms;
|
|
735
738
|
--ds-space-1:4px;--ds-space-2:8px;--ds-space-3:12px;--ds-space-4:16px;--ds-space-5:24px;--ds-space-6:32px;
|
|
739
|
+
--ds-file-toolbar-height:51px;
|
|
736
740
|
--ds-z-drawer:30;
|
|
737
741
|
box-sizing:border-box;position:relative;display:flex;flex-direction:column;width:100%;height:100%;min-height:24rem;
|
|
738
742
|
background:var(--ds-background);color:var(--ds-text);
|
|
@@ -906,7 +910,7 @@ button.ygd-studio-select>span:last-child{display:flex;flex:none;align-items:cent
|
|
|
906
910
|
.ygd-studio-bundle-actions{flex-shrink:0}
|
|
907
911
|
|
|
908
912
|
/* Document toolbar (rich/source toggle) */
|
|
909
|
-
.ygd-studio-doc-toolbar{display:flex;align-items:center;gap:var(--ds-space-2);margin-bottom:var(--ds-space-3);flex-shrink:0}
|
|
913
|
+
.ygd-studio-doc-toolbar{display:flex;align-items:center;min-height:var(--ds-file-toolbar-height);gap:var(--ds-space-2);margin-bottom:var(--ds-space-3);flex-shrink:0}
|
|
910
914
|
.ygd-studio-doc-toggle-group{display:inline-flex;border:1px solid var(--ds-border);border-radius:var(--ds-radius);
|
|
911
915
|
overflow:hidden;background:var(--ds-surface)}
|
|
912
916
|
.ygd-studio-doc-toggle{padding:var(--ds-space-1) var(--ds-space-3);font-size:12px;line-height:18px;border:none;
|
|
@@ -976,9 +980,9 @@ button.ygd-studio-select>span:last-child{display:flex;flex:none;align-items:cent
|
|
|
976
980
|
/* Bundle workspace two-pane body */
|
|
977
981
|
.ygd-studio-workspace-body{flex:1;display:flex;min-height:0;overflow:hidden;background:var(--ds-surface)}
|
|
978
982
|
.ygd-studio-workspace [hidden]{display:none!important}
|
|
979
|
-
.ygd-studio-file-tree-pane{width:
|
|
983
|
+
.ygd-studio-file-tree-pane{width:230px;min-width:180px;flex-shrink:0;background:var(--ds-background);border-right:1px solid var(--ds-border);
|
|
980
984
|
display:flex;flex-direction:column;overflow:hidden}
|
|
981
|
-
.ygd-studio-file-tree-header{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:var(--ds-space-2) var(--ds-space-3);font-size:11px;font-weight:600;
|
|
985
|
+
.ygd-studio-file-tree-header{display:flex;align-items:center;justify-content:space-between;min-height:var(--ds-file-toolbar-height);flex-shrink:0;gap:8px;padding:var(--ds-space-2) var(--ds-space-3);font-size:11px;font-weight:600;
|
|
982
986
|
color:var(--ds-text-secondary);border-bottom:1px solid var(--ds-border)}
|
|
983
987
|
.ygd-studio-new-file{display:flex;flex-direction:column;gap:8px;padding:12px;border-bottom:1px solid var(--ds-border)}
|
|
984
988
|
.ygd-studio-new-file .ygd-studio-text-input{width:100%;box-sizing:border-box}
|
|
@@ -1010,16 +1014,14 @@ button.ygd-studio-select>span:last-child{display:flex;flex:none;align-items:cent
|
|
|
1010
1014
|
.ygd-studio-hero-actions .ygd-studio-trial:has([aria-expanded="true"]){width:auto}
|
|
1011
1015
|
.ygd-studio-hero-actions .ygd-studio-trial>.ygd-studio-summary-card{position:absolute;right:0;top:100%;z-index:20;width:min(480px,75vw);max-height:65vh;overflow:auto;box-shadow:0 8px 30px #0002}
|
|
1012
1016
|
.ygd-studio-content-header .ygd-studio-btn-primary,.ygd-studio-content-header .ygd-studio-btn-link{margin-top:8px;margin-right:6px}
|
|
1013
|
-
.ygd-studio-
|
|
1014
|
-
.ygd-studio-file-tree{padding:8px 0}
|
|
1015
|
-
.ygd-studio-tree-node,.ygd-studio-tree-folder>summary{height:28px;min-height:28px;display:flex;align-items:center;gap:6px;padding:0 10px;font:400 13px/28px var(--ds-body-font);color:#404957;white-space:nowrap;cursor:pointer}
|
|
1017
|
+
.ygd-studio-tree-node,.ygd-studio-tree-folder>summary{height:28px;min-height:28px;display:flex;align-items:center;gap:6px;padding:0 10px;font:400 13px/28px var(--ds-body-font);color:var(--ds-text);white-space:nowrap;cursor:pointer}
|
|
1016
1018
|
.ygd-studio-tree-folder>summary{list-style:none}
|
|
1017
1019
|
.ygd-studio-tree-folder>summary::-webkit-details-marker{display:none}
|
|
1018
|
-
.ygd-studio-tree-folder>summary:hover,.ygd-studio-tree-node:hover{background
|
|
1019
|
-
.ygd-studio-tree-children{margin-left:14px;padding-left:8px;border-left:1px solid
|
|
1020
|
-
.ygd-studio-chevron{width:10px;flex:0 0 10px;color
|
|
1020
|
+
.ygd-studio-tree-folder>summary:hover,.ygd-studio-tree-node:hover{background:var(--ds-bg-hover)}
|
|
1021
|
+
.ygd-studio-tree-children{margin-left:14px;padding-left:8px;border-left:1px solid var(--ds-border)}
|
|
1022
|
+
.ygd-studio-chevron{width:10px;flex:0 0 10px;color:var(--ds-text-secondary);font-size:16px}
|
|
1021
1023
|
.ygd-studio-tree-folder[open]>summary .ygd-studio-chevron{transform:rotate(90deg)}
|
|
1022
|
-
.ygd-studio-file-icon{width:16px;height:16px;flex:0 0 16px;fill:none;stroke:currentColor;stroke-width:1.3;stroke-linecap:round;stroke-linejoin:round;color
|
|
1024
|
+
.ygd-studio-file-icon{width:16px;height:16px;flex:0 0 16px;fill:none;stroke:currentColor;stroke-width:1.3;stroke-linecap:round;stroke-linejoin:round;color:var(--ds-text-secondary)}
|
|
1023
1025
|
.ygd-studio-file-icon.markdown{color:#698aaf}.ygd-studio-file-icon.config{color:#a98e4e}
|
|
1024
1026
|
.ygd-studio-tree-node[aria-current="true"]{background:var(--ds-primary-light);box-shadow:inset 2px 0 var(--ds-primary);color:var(--ds-primary-dark)}
|
|
1025
1027
|
.ygd-studio-file-path{font:12px var(--ds-body-font);color:var(--ds-text-secondary);padding-bottom:12px;overflow-wrap:anywhere}
|
|
@@ -1047,8 +1049,8 @@ button.ygd-studio-select>span:last-child{display:flex;flex:none;align-items:cent
|
|
|
1047
1049
|
.ygd-studio-conversation-composer textarea{min-height:88px;max-height:200px;resize:vertical;font:13px/1.7 var(--ds-body-font)}
|
|
1048
1050
|
.ygd-studio-conversation-send{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px}
|
|
1049
1051
|
.ygd-studio-authoring-content{container:studio-authoring-content / inline-size;display:flex;min-width:0;min-height:0;overflow:hidden}
|
|
1050
|
-
@media(max-width:1100px){.ygd-studio-authoring-layout{grid-template-columns:300px minmax(0,1fr)}.ygd-studio-authoring-content .ygd-studio-file-tree-pane{width:
|
|
1051
|
-
@container studio-authoring-content (max-width:800px){.ygd-studio-authoring-content .ygd-studio-files-layout{display:grid;grid-template-columns:
|
|
1052
|
+
@media(max-width:1100px){.ygd-studio-authoring-layout{grid-template-columns:300px minmax(0,1fr)}.ygd-studio-authoring-content .ygd-studio-file-tree-pane{width:180px}}
|
|
1053
|
+
@container studio-authoring-content (max-width:800px){.ygd-studio-authoring-content .ygd-studio-files-layout{display:grid;grid-template-columns:180px minmax(0,1fr);grid-template-rows:minmax(0,1fr) auto}.ygd-studio-authoring-content .ygd-studio-file-tree-pane{grid-row:1 / 3;width:180px}.ygd-studio-authoring-content .ygd-studio-files-layout>.ygd-studio-content-pane{grid-column:2;grid-row:1;min-height:0}.ygd-studio-authoring-content .ygd-studio-file-info{grid-column:2;grid-row:2;border-left:0;border-top:1px solid var(--ds-border);max-height:140px}}
|
|
1052
1054
|
@media(max-width:700px){.ygd-studio-authoring-layout{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(240px,45%) minmax(0,1fr)}.ygd-studio-conversation{border-right:0;border-bottom:1px solid var(--ds-border)}.ygd-studio-conversation-header{padding:8px 12px}.ygd-studio-conversation-header p{display:none}.ygd-studio-conversation-log{padding:12px}.ygd-studio-conversation-composer{padding:8px 12px;max-height:70%}.ygd-studio-conversation-composer textarea{min-height:60px}}
|
|
1053
1055
|
.ygd-studio-document-name{font:500 13px var(--ds-mono-font);margin-right:auto}
|
|
1054
1056
|
.ygd-studio-file-heading{display:flex;align-items:baseline;flex-wrap:wrap;gap:4px 10px;flex:1;min-width:180px}
|
|
@@ -1061,16 +1063,15 @@ button.ygd-studio-select>span:last-child{display:flex;flex:none;align-items:cent
|
|
|
1061
1063
|
.ygd-studio-card-meta{font-size:11px;line-height:1.6;color:var(--ds-text-secondary);margin:0 0 12px}
|
|
1062
1064
|
@media(max-width:1100px){.ygd-studio-file-info{flex-basis:180px;padding:12px}}
|
|
1063
1065
|
@media(max-width:800px){
|
|
1064
|
-
.ygd-studio-files-layout{display:grid;grid-template-columns:
|
|
1065
|
-
.ygd-studio-files-layout>.ygd-studio-file-tree-pane{grid-row:1 / 3;width:
|
|
1066
|
+
.ygd-studio-files-layout{display:grid;grid-template-columns:180px minmax(0,1fr);grid-template-rows:minmax(0,1fr) auto}
|
|
1067
|
+
.ygd-studio-files-layout>.ygd-studio-file-tree-pane{grid-row:1 / 3;width:180px}
|
|
1066
1068
|
.ygd-studio-files-layout>.ygd-studio-content-pane{grid-column:2;grid-row:1;min-height:0}
|
|
1067
1069
|
.ygd-studio-files-layout>.ygd-studio-file-info{grid-column:2;grid-row:2;border-left:0;border-top:1px solid var(--ds-border);max-height:140px}
|
|
1068
1070
|
}
|
|
1069
1071
|
.ygd-studio-doc-meta{margin-left:0}
|
|
1070
1072
|
.ygd-studio-kitmark{width:43px;height:43px;border-radius:11px;background:#ededed;color:#575757;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0}
|
|
1071
1073
|
.ygd-studio-kitmark svg{width:24px;height:24px}
|
|
1072
|
-
.ygd-studio-btn-secondary{border:1px solid var(--ds-border);border-radius:8px;padding:6px 11px;background:
|
|
1073
|
-
.ygd-studio-btn-secondary:disabled{color:#aaa;cursor:not-allowed;background:#fafafa}
|
|
1074
|
+
.ygd-studio-btn-secondary{border:1px solid var(--ds-border);border-radius:8px;padding:6px 11px;background:var(--ds-surface);font:500 13px var(--ds-body-font);color:var(--ds-text);cursor:pointer;white-space:nowrap}
|
|
1074
1075
|
.ygd-studio-instance-actions{display:flex;gap:6px}
|
|
1075
1076
|
.ygd-studio-modal{width:min(640px,90vw);max-height:82vh;overflow:auto;margin:auto;padding:22px;border:1px solid var(--ds-border);border-radius:12px;background:var(--ds-surface);color:var(--ds-text);font:14px/1.6 var(--ds-body-font)}
|
|
1076
1077
|
.ygd-studio-modal::backdrop{background:#0005}
|
|
@@ -1151,7 +1152,7 @@ button.ygd-studio-select>span:last-child{display:flex;flex:none;align-items:cent
|
|
|
1151
1152
|
.ygd-studio-sidebar-item .ygd-studio-kitmark svg{width:18px;height:18px}
|
|
1152
1153
|
.ygd-studio-kitmark{background:var(--ds-primary-light);color:var(--ds-primary-dark)}
|
|
1153
1154
|
.ygd-studio-content-pane{display:flex;flex-direction:column;padding:0;overflow:hidden}
|
|
1154
|
-
.ygd-studio-content-pane>.ygd-studio-doc-toolbar{margin:0;padding:9px 14px;border-bottom:1px solid var(--ds-border)}
|
|
1155
|
+
.ygd-studio-content-pane>.ygd-studio-doc-toolbar,.ygd-studio-panel-split>.ygd-studio-doc-toolbar{min-width:0;margin:0;padding:9px 14px;border-bottom:1px solid var(--ds-border)}
|
|
1155
1156
|
.ygd-studio-document-body{flex:1;min-height:0;overflow:auto;padding:18px 24px}
|
|
1156
1157
|
.ygd-studio-document-body:has(>.ygd-studio-loading),.ygd-studio-live-pane-body:has(>.ygd-studio-loading){display:flex;flex-direction:column}
|
|
1157
1158
|
.ygd-studio-file-metadata{margin-bottom:18px;border-radius:8px;background:var(--ds-primary-light,#f7f4fe);color:var(--ds-text-secondary)}
|
|
@@ -1161,7 +1162,7 @@ button.ygd-studio-select>span:last-child{display:flex;flex:none;align-items:cent
|
|
|
1161
1162
|
.ygd-studio-mindset-document .ygd-studio-markdown,.ygd-studio-document-body .ygd-studio-markdown{max-width:none}
|
|
1162
1163
|
.ygd-studio-mindset-document .ygd-studio-markdown h1,.ygd-studio-document-body .ygd-studio-markdown h1{font-size:22px;margin-bottom:14px}
|
|
1163
1164
|
.ygd-studio-mindset-document .ygd-studio-markdown h2,.ygd-studio-document-body .ygd-studio-markdown h2{font-size:17px;margin:23px 0 10px;padding-bottom:6px;border-bottom:1px solid var(--ds-border)}
|
|
1164
|
-
.ygd-studio-doc-toolbar{
|
|
1165
|
+
.ygd-studio-doc-toolbar{gap:10px;flex-wrap:wrap}
|
|
1165
1166
|
.ygd-studio-doc-toggle-group{border:0;background:var(--ds-background);padding:3px;gap:2px}
|
|
1166
1167
|
.ygd-studio-doc-toggle{background:transparent;border-radius:5px;padding:4px 9px}
|
|
1167
1168
|
.ygd-studio-doc-toggle+.ygd-studio-doc-toggle{border:0}
|
|
@@ -1224,13 +1225,15 @@ button.ygd-studio-select>span:last-child{display:flex;flex:none;align-items:cent
|
|
|
1224
1225
|
.ygd-studio-editor-heading{display:flex;align-items:center;gap:12px;padding:8px 12px;border-bottom:1px solid var(--ds-border);font-size:13px}
|
|
1225
1226
|
.ygd-studio-editor-heading>span{margin-left:auto;color:var(--ds-text-secondary);font-size:12px}
|
|
1226
1227
|
.ygd-studio-panel-split,.ygd-studio-trial-workarea.with-input{grid-template-columns:minmax(260px,32%) minmax(0,1fr)}
|
|
1227
|
-
.ygd-studio-panel-split{display:grid;grid-template-rows:minmax(0,1fr);flex:1;min-width:0;min-height:0;overflow:hidden}
|
|
1228
|
+
.ygd-studio-panel-split{display:grid;grid-template-rows:auto minmax(0,1fr);flex:1;min-width:0;min-height:0;overflow:hidden}
|
|
1228
1229
|
.ygd-studio-yaml-pane,.ygd-studio-live-pane{display:flex;flex-direction:column;min-width:0;min-height:0}
|
|
1229
|
-
.
|
|
1230
|
-
.ygd-studio-
|
|
1231
|
-
.ygd-studio-
|
|
1232
|
-
.ygd-studio-
|
|
1233
|
-
.ygd-studio-
|
|
1230
|
+
/* Both dividers belong to one grid row, including when either toolbar wraps. */
|
|
1231
|
+
.ygd-studio-panel-split>.ygd-studio-source-toolbar{grid-area:1/1;border-right:1px solid var(--ds-border)}
|
|
1232
|
+
.ygd-studio-source-toolbar>.ygd-studio-btn-secondary{margin-left:auto}
|
|
1233
|
+
.ygd-studio-panel-split>.ygd-studio-preview-toolbar{grid-area:1/2;font-size:12px}
|
|
1234
|
+
.ygd-studio-preview-toolbar>span{color:var(--ds-text-secondary);font-size:11px}
|
|
1235
|
+
.ygd-studio-yaml-pane{grid-area:2/1;border-right:1px solid var(--ds-border)}
|
|
1236
|
+
.ygd-studio-live-pane{grid-area:2/2}
|
|
1234
1237
|
.ygd-studio-live-pane-body{display:flex;flex-direction:column;flex:1;min-height:0;overflow:auto;padding:0}
|
|
1235
1238
|
.ygd-studio-workspace .ygd-studio-trial-availability{padding:16px;max-width:400px;margin:auto;text-align:center;color:var(--ds-text-secondary);font-size:13px;line-height:1.6}
|
|
1236
1239
|
.ygd-studio-trial-input>.ygd-studio-loading{flex:1}
|
|
@@ -1239,7 +1242,7 @@ button.ygd-studio-select>span:last-child{display:flex;flex:none;align-items:cent
|
|
|
1239
1242
|
.ygd-studio-trial-columns>section{min-width:0;padding:16px;border:1px solid var(--ds-border);border-radius:10px;font-size:13px}
|
|
1240
1243
|
.ygd-studio-trial-columns h3{margin:0 0 12px;font-size:14px}.ygd-studio-trial-columns textarea{display:block;box-sizing:border-box;width:100%;margin:8px 0 12px;resize:vertical;font:inherit;line-height:1.6;padding:10px;border:1px solid var(--ds-border);border-radius:8px}
|
|
1241
1244
|
.ygd-studio-trial-columns pre{white-space:pre-wrap;overflow-wrap:anywhere;font:inherit}.ygd-studio-trial-columns details{margin:12px 0}.ygd-studio-trial-hint{color:var(--ds-text-secondary);font-size:12px}
|
|
1242
|
-
@media(max-width:650px){.ygd-studio-trial-columns{grid-template-columns:minmax(0,1fr)}.ygd-studio-file-tree-pane{width:
|
|
1245
|
+
@media(max-width:650px){.ygd-studio-trial-columns{grid-template-columns:minmax(0,1fr)}.ygd-studio-file-tree-pane{width:180px}}
|
|
1243
1246
|
|
|
1244
1247
|
.ygd-studio-inline-diff{flex:1;min-height:0;overflow:auto;margin:0;padding:12px 0;background:var(--ds-surface);font:13px/1.7 var(--ds-mono-font);tab-size:2}
|
|
1245
1248
|
.ygd-studio-diff-line{display:flex;min-width:max-content;min-height:1.7em;padding:0 16px 0 8px}
|
|
@@ -1966,15 +1969,16 @@ function BundleCard({ bundle, locale, badge, onBadgeClick, badgeLabel, sourceLab
|
|
|
1966
1969
|
//#region src/mount-save-receipt.ts
|
|
1967
1970
|
const mountKey = (pin) => pin.name;
|
|
1968
1971
|
/** Preserve Bundle identity and unavailable mounts without pinning mutable library content. */
|
|
1969
|
-
function selectedMountPins(record, keys) {
|
|
1972
|
+
function selectedMountPins(record, keys, replacements = /* @__PURE__ */ new Set()) {
|
|
1970
1973
|
return [...keys].map((key) => {
|
|
1971
|
-
const source = record.
|
|
1974
|
+
const source = (replacements.has(key) ? void 0 : record.mounts.find((mount) => mountKey(mount.bundle) === key)?.bundle) ?? record.availableBundles?.find((bundle) => mountKey(bundle) === key);
|
|
1972
1975
|
if (!source) throw Error("The selected Bundle source is unavailable. Reopen the Kit before saving.");
|
|
1973
1976
|
const { name, version, instanceId } = source;
|
|
1974
1977
|
return {
|
|
1975
1978
|
name,
|
|
1976
1979
|
version,
|
|
1977
|
-
...instanceId === void 0 ? {} : { instanceId }
|
|
1980
|
+
...instanceId === void 0 ? {} : { instanceId },
|
|
1981
|
+
...replacements.has(key) ? { replaceSource: true } : {}
|
|
1978
1982
|
};
|
|
1979
1983
|
});
|
|
1980
1984
|
}
|
|
@@ -1983,7 +1987,8 @@ function mountSaveMatches(value, pending) {
|
|
|
1983
1987
|
const { base, bundles } = pending;
|
|
1984
1988
|
return !!value && value.id === base.id && value.kind === "kit" && value.revision === base.revision + 1 && !value.deletedAt && samePin(value.kit, base.kit) && samePin(value.source?.kit, base.source?.kit) && value.title?.zh === base.title.zh && value.title?.en === base.title.en && Array.isArray(value.mounts) && value.mounts.length === bundles.length && value.mounts.every((mount, index) => {
|
|
1985
1989
|
const expected = bundles[index];
|
|
1986
|
-
|
|
1990
|
+
const retained = !expected.replaceSource && expected.instanceId === void 0 ? base.mounts.find((value) => mountKey(value.bundle) === mountKey(expected))?.bundle.source : void 0;
|
|
1991
|
+
return samePin(mount?.bundle, expected) && mount.bundle.instanceId === expected.instanceId && (!retained || mount.bundle.source?.snapshot === retained.snapshot && mount.bundle.source.sourceId === retained.sourceId);
|
|
1987
1992
|
});
|
|
1988
1993
|
}
|
|
1989
1994
|
/** Exact S2 rejections before the instance replace; generic transport/parse errors
|
|
@@ -2012,22 +2017,37 @@ function BundleMounts({ client, bundle, installed, locale, onEditKit }) {
|
|
|
2012
2017
|
const owner = useMemo(() => ({
|
|
2013
2018
|
client,
|
|
2014
2019
|
name: bundle.name,
|
|
2015
|
-
version: bundle.version
|
|
2020
|
+
version: bundle.version,
|
|
2021
|
+
instanceId: bundle.instanceId,
|
|
2022
|
+
current: bundle.current
|
|
2016
2023
|
}), [
|
|
2017
2024
|
client,
|
|
2018
2025
|
bundle.name,
|
|
2019
|
-
bundle.version
|
|
2026
|
+
bundle.version,
|
|
2027
|
+
bundle.instanceId,
|
|
2028
|
+
bundle.current
|
|
2020
2029
|
]);
|
|
2021
2030
|
const current = useRef(owner);
|
|
2022
2031
|
current.current = owner;
|
|
2023
2032
|
const live = useRef(true), writing = useRef();
|
|
2024
2033
|
const pending = useRef();
|
|
2034
|
+
const [resolved, setResolved] = useState();
|
|
2025
2035
|
const [query, setQuery] = useState(""), [retry, refresh] = useState(0);
|
|
2026
2036
|
const [catalog, setCatalog] = useState();
|
|
2027
2037
|
const [operation, setOperation] = useState();
|
|
2028
2038
|
const listing = catalog?.owner === owner ? catalog : void 0;
|
|
2029
2039
|
const update = operation?.owner === owner ? operation : void 0;
|
|
2030
2040
|
const kits = listing?.kits ?? [], loading = listing?.busy ?? !!client, busy = loading || !!update?.busy;
|
|
2041
|
+
const discovered = bundle.instanceId === void 0 ? kits.flatMap((kit) => kit.availableBundles ?? []).find((pin) => pin.name === bundle.name && pin.instanceId) : void 0;
|
|
2042
|
+
const target = resolved?.owner === owner ? {
|
|
2043
|
+
...bundle,
|
|
2044
|
+
instanceId: resolved.record.id,
|
|
2045
|
+
current: true
|
|
2046
|
+
} : discovered ? {
|
|
2047
|
+
...bundle,
|
|
2048
|
+
instanceId: discovered.instanceId,
|
|
2049
|
+
current: true
|
|
2050
|
+
} : bundle;
|
|
2031
2051
|
const displayedKits = update?.pending && !kits.some((kit) => kit.id === update.pending.base.id) ? [...kits, update.pending.base] : kits;
|
|
2032
2052
|
const zh = locale === "zh";
|
|
2033
2053
|
useEffect(() => {
|
|
@@ -2079,13 +2099,15 @@ function BundleMounts({ client, bundle, installed, locale, onEditKit }) {
|
|
|
2079
2099
|
active = false;
|
|
2080
2100
|
};
|
|
2081
2101
|
}, [owner, retry]);
|
|
2082
|
-
const
|
|
2102
|
+
const availableTarget = (kit) => kit.availableBundles?.find((pin) => pin.name === target.name && (pin.instanceId === target.instanceId || !pin.instanceId && target.current === true));
|
|
2103
|
+
const matches = (kit, pin) => pin.name === target.name && (pin.instanceId !== void 0 ? pin.instanceId === target.instanceId : pin.replaceSource === true ? target.instanceId === void 0 : !kit.importedFromSnapshot && (target.instanceId === void 0 || target.current === true));
|
|
2083
2104
|
const toggle = async (kit, checked) => {
|
|
2084
2105
|
if (!client?.updateMounts || busy || listing?.error || pending.current?.owner === owner || writing.current === owner) return;
|
|
2085
2106
|
writing.current = owner;
|
|
2086
2107
|
setOperation({
|
|
2087
2108
|
owner,
|
|
2088
|
-
busy: true
|
|
2109
|
+
busy: true,
|
|
2110
|
+
...checked ? { selecting: kit.id } : {}
|
|
2089
2111
|
});
|
|
2090
2112
|
const valid = () => live.current && current.current === owner;
|
|
2091
2113
|
let submitted;
|
|
@@ -2093,9 +2115,46 @@ function BundleMounts({ client, bundle, installed, locale, onEditKit }) {
|
|
|
2093
2115
|
const pins = new Set(kit.mounts.map((m) => mountKey(m.bundle))), key = mountKey(bundle);
|
|
2094
2116
|
if (checked) pins.add(key);
|
|
2095
2117
|
else pins.delete(key);
|
|
2118
|
+
let bundles = selectedMountPins(kit, pins);
|
|
2119
|
+
if (checked) {
|
|
2120
|
+
let selected = availableTarget(kit);
|
|
2121
|
+
if (!selected) throw Error("The selected Bundle source is unavailable. Reopen the Kit before saving.");
|
|
2122
|
+
if (bundle.instanceId === void 0 && resolved?.owner !== owner && client.editCurrent) {
|
|
2123
|
+
const record = await client.editCurrent({
|
|
2124
|
+
kind: "bundle",
|
|
2125
|
+
bundle: {
|
|
2126
|
+
name: bundle.name,
|
|
2127
|
+
version: bundle.version
|
|
2128
|
+
}
|
|
2129
|
+
});
|
|
2130
|
+
if (!valid()) return;
|
|
2131
|
+
const pin = record.bundle ?? record.source.bundle;
|
|
2132
|
+
if (record.kind !== "bundle" || !record.id || record.current !== true || pin?.name !== bundle.name || record.deletedAt) throw Error("The current Bundle does not match the selected source.");
|
|
2133
|
+
setResolved({
|
|
2134
|
+
owner,
|
|
2135
|
+
record
|
|
2136
|
+
});
|
|
2137
|
+
selected = {
|
|
2138
|
+
...selected,
|
|
2139
|
+
...pin,
|
|
2140
|
+
instanceId: record.id
|
|
2141
|
+
};
|
|
2142
|
+
} else if (target.instanceId !== void 0) selected = {
|
|
2143
|
+
...selected,
|
|
2144
|
+
instanceId: target.instanceId
|
|
2145
|
+
};
|
|
2146
|
+
else if (kit.importedFromSnapshot) throw Error(zh ? "此宿主暂不支持编辑当前技能包,未更改挂载。" : "This host cannot edit the current Bundle. The mount was not changed.");
|
|
2147
|
+
const { name, version, instanceId } = selected;
|
|
2148
|
+
bundles = bundles.map((pin) => pin.name === name ? {
|
|
2149
|
+
name,
|
|
2150
|
+
version,
|
|
2151
|
+
...instanceId === void 0 ? {} : { instanceId },
|
|
2152
|
+
replaceSource: true
|
|
2153
|
+
} : pin);
|
|
2154
|
+
}
|
|
2096
2155
|
submitted = {
|
|
2097
2156
|
base: structuredClone(kit),
|
|
2098
|
-
bundles
|
|
2157
|
+
bundles
|
|
2099
2158
|
};
|
|
2100
2159
|
pending.current = {
|
|
2101
2160
|
owner,
|
|
@@ -2153,11 +2212,14 @@ function BundleMounts({ client, bundle, installed, locale, onEditKit }) {
|
|
|
2153
2212
|
children: zh ? "编辑" : "Edit"
|
|
2154
2213
|
})]
|
|
2155
2214
|
}, k.name)),
|
|
2156
|
-
displayedKits.filter((k) => includes(k.title[locale]) && k.
|
|
2215
|
+
displayedKits.filter((k) => includes(k.title[locale]) && (availableTarget(k) || k.mounts.some((m) => matches(k, m.bundle)))).map((k) => /* @__PURE__ */ jsxs("label", {
|
|
2157
2216
|
className: "ygd-studio-bundle-mount-choice",
|
|
2158
2217
|
children: [/* @__PURE__ */ jsx("input", {
|
|
2159
2218
|
type: "checkbox",
|
|
2160
|
-
checked: update?.pending?.base.id === k.id ? update.pending.bundles.some(matches) : k.mounts.some((m) => matches(
|
|
2219
|
+
checked: update?.busy && update.selecting === k.id ? true : update?.pending?.base.id === k.id ? update.pending.bundles.some((pin) => matches(k, pin)) : k.mounts.some((m) => matches(k, {
|
|
2220
|
+
...m.bundle,
|
|
2221
|
+
instanceId: m.bundle.instanceId ?? m.instanceId
|
|
2222
|
+
})),
|
|
2161
2223
|
disabled: busy || !!listing?.error || !!update?.pending || !client?.updateMounts,
|
|
2162
2224
|
onChange: (e) => void toggle(k, e.target.checked)
|
|
2163
2225
|
}), k.title[locale]]
|
|
@@ -2744,11 +2806,47 @@ function BundleTrial({ client, source, locale, disabled = false, target, onOpen,
|
|
|
2744
2806
|
}
|
|
2745
2807
|
//#endregion
|
|
2746
2808
|
//#region src/MountEditor.tsx
|
|
2809
|
+
/** Read the Kit's saved bindings without activating mount editing. */
|
|
2810
|
+
function MountedBundleBrowser({ record, locale, onPreview }) {
|
|
2811
|
+
const zh = locale === "zh";
|
|
2812
|
+
return /* @__PURE__ */ jsx("section", {
|
|
2813
|
+
className: "ygd-studio-content-body",
|
|
2814
|
+
"aria-label": zh ? "已挂载技能包" : "Mounted Bundles",
|
|
2815
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
2816
|
+
className: "ygd-studio-bundles-list",
|
|
2817
|
+
children: [record.mounts.map((mount, index) => {
|
|
2818
|
+
const bundle = {
|
|
2819
|
+
...mount.bundle,
|
|
2820
|
+
...mount.display
|
|
2821
|
+
};
|
|
2822
|
+
const label = bundle.title?.[locale] ?? bundle.name;
|
|
2823
|
+
return /* @__PURE__ */ jsx(BundleCard, {
|
|
2824
|
+
bundle,
|
|
2825
|
+
locale,
|
|
2826
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
2827
|
+
type: "button",
|
|
2828
|
+
className: "ygd-studio-btn-secondary",
|
|
2829
|
+
"aria-label": `${label} · ${zh ? "面板预览" : "Panel Preview"}`,
|
|
2830
|
+
onClick: () => onPreview({
|
|
2831
|
+
name: bundle.name,
|
|
2832
|
+
version: bundle.version
|
|
2833
|
+
}),
|
|
2834
|
+
children: zh ? "面板预览" : "Panel Preview"
|
|
2835
|
+
})
|
|
2836
|
+
}, `${bundle.name}@${bundle.version}:${index}`);
|
|
2837
|
+
}), !record.mounts.length && /* @__PURE__ */ jsx("p", {
|
|
2838
|
+
className: "ygd-studio-empty",
|
|
2839
|
+
children: zh ? "此套件尚未挂载技能包。" : "This Kit has no mounted Bundles yet."
|
|
2840
|
+
})]
|
|
2841
|
+
})
|
|
2842
|
+
});
|
|
2843
|
+
}
|
|
2747
2844
|
function MountEditor(props) {
|
|
2748
2845
|
return /* @__PURE__ */ jsx(MountEditorSession, { ...props }, `${props.record.id}:${props.record.revision}`);
|
|
2749
2846
|
}
|
|
2750
2847
|
function MountEditorSession({ client, record, locale, onSaved, onActions, onDirtyChange, onBusyChange }) {
|
|
2751
2848
|
const [selected, setSelected] = useState(() => new Set(record.mounts.map((m) => mountKey(m.bundle))));
|
|
2849
|
+
const [replacements, setReplacements] = useState(() => /* @__PURE__ */ new Set());
|
|
2752
2850
|
const [query, setQuery] = useState(""), [busy, setBusy] = useState(false), [error, setError] = useState("");
|
|
2753
2851
|
const [saveUnverified, setSaveUnverified] = useState(false);
|
|
2754
2852
|
const pending = useRef(), working = useRef(false), live = useRef(true);
|
|
@@ -2775,7 +2873,7 @@ function MountEditorSession({ client, record, locale, onSaved, onActions, onDirt
|
|
|
2775
2873
|
};
|
|
2776
2874
|
const zh = locale === "zh", candidates = record.availableBundles ?? [];
|
|
2777
2875
|
const original = new Set(record.mounts.map((m) => mountKey(m.bundle)));
|
|
2778
|
-
const dirty = selected.size !== original.size || [...selected].some((key) => !original.has(key));
|
|
2876
|
+
const dirty = replacements.size > 0 || selected.size !== original.size || [...selected].some((key) => !original.has(key));
|
|
2779
2877
|
useEffect(() => {
|
|
2780
2878
|
onDirtyChange?.(dirty || saveUnverified);
|
|
2781
2879
|
}, [
|
|
@@ -2816,6 +2914,12 @@ function MountEditorSession({ client, record, locale, onSaved, onActions, onDirt
|
|
|
2816
2914
|
].filter(Boolean).join(" ").toLowerCase().includes(query.trim().toLowerCase()));
|
|
2817
2915
|
const change = (key, add) => {
|
|
2818
2916
|
if (working.current || pending.current) return;
|
|
2917
|
+
setReplacements((previous) => {
|
|
2918
|
+
const next = new Set(previous);
|
|
2919
|
+
if (add && original.has(key)) next.add(key);
|
|
2920
|
+
else next.delete(key);
|
|
2921
|
+
return next;
|
|
2922
|
+
});
|
|
2819
2923
|
setSelected((previous) => {
|
|
2820
2924
|
const next = new Set(previous);
|
|
2821
2925
|
if (add) next.add(key);
|
|
@@ -2833,7 +2937,7 @@ function MountEditorSession({ client, record, locale, onSaved, onActions, onDirt
|
|
|
2833
2937
|
try {
|
|
2834
2938
|
const submitted = {
|
|
2835
2939
|
base: structuredClone(record),
|
|
2836
|
-
bundles: selectedMountPins(record, selected)
|
|
2940
|
+
bundles: selectedMountPins(record, selected, replacements)
|
|
2837
2941
|
};
|
|
2838
2942
|
pending.current = submitted;
|
|
2839
2943
|
const saved = await client.updateMounts({
|
|
@@ -2892,10 +2996,11 @@ function MountEditorSession({ client, record, locale, onSaved, onActions, onDirt
|
|
|
2892
2996
|
verifySave,
|
|
2893
2997
|
saveUnverified,
|
|
2894
2998
|
isSaveSubmitted: () => !!pending.current,
|
|
2895
|
-
status: saveUnverified ? zh ? "保存结果待核对" : "Save needs verification" : dirty ? zh ? `未保存 · 新增 ${[...selected].filter((key) => !original.has(key)).length} · 移除 ${[...original].filter((key) => !selected.has(key)).length}` : `Unsaved · ${[...selected].filter((key) => !original.has(key)).length} added · ${[...original].filter((key) => !selected.has(key)).length} removed` : zh ? "已保存" : "Saved"
|
|
2999
|
+
status: saveUnverified ? zh ? "保存结果待核对" : "Save needs verification" : dirty ? (zh ? `未保存 · 新增 ${[...selected].filter((key) => !original.has(key)).length} · 移除 ${[...original].filter((key) => !selected.has(key)).length}` : `Unsaved · ${[...selected].filter((key) => !original.has(key)).length} added · ${[...original].filter((key) => !selected.has(key)).length} removed`) + (replacements.size ? zh ? ` · 重新选择 ${replacements.size}` : ` · ${replacements.size} reselected` : "") : zh ? "已保存" : "Saved"
|
|
2896
3000
|
});
|
|
2897
3001
|
}, [
|
|
2898
3002
|
selected,
|
|
3003
|
+
replacements,
|
|
2899
3004
|
record,
|
|
2900
3005
|
busy,
|
|
2901
3006
|
dirty,
|
|
@@ -3261,6 +3366,17 @@ function SourceFileDiff({ path, before, after }) {
|
|
|
3261
3366
|
//#endregion
|
|
3262
3367
|
//#region src/InstanceWorkbench.tsx
|
|
3263
3368
|
/** Editable local source instances. Persistence and preview remain host capabilities. */
|
|
3369
|
+
function SourceTextArea({ label, content, readOnly, inputRef, onChange }) {
|
|
3370
|
+
return /* @__PURE__ */ jsx("textarea", {
|
|
3371
|
+
ref: inputRef,
|
|
3372
|
+
"aria-label": label,
|
|
3373
|
+
spellCheck: false,
|
|
3374
|
+
value: content,
|
|
3375
|
+
readOnly,
|
|
3376
|
+
onChange: onChange ? (event) => onChange(event.target.value) : void 0,
|
|
3377
|
+
className: "ygd-studio-source-input"
|
|
3378
|
+
});
|
|
3379
|
+
}
|
|
3264
3380
|
function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, renderPreview, onDirtyChange, renderSupplement, authoringIntent, embedded = false, readOnly = false, onEdit, initialView = "files", initialSelection, sourceChanges }) {
|
|
3265
3381
|
const zh = locale === "zh";
|
|
3266
3382
|
const [record, setRecord] = useState();
|
|
@@ -3281,6 +3397,7 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
3281
3397
|
const [newFileOpen, setNewFileOpen] = useState(false), [newFilePath, setNewFilePath] = useState(""), [newFileError, setNewFileError] = useState("");
|
|
3282
3398
|
const newFileErrorId = useId();
|
|
3283
3399
|
const [preview, setPreview] = useState(), [previewBusy, setPreviewBusy] = useState(false);
|
|
3400
|
+
const [selectedMount, setSelectedMount] = useState();
|
|
3284
3401
|
const [mountsDirty, setMountsDirty] = useState(false), [mountsBusy, setMountsBusy] = useState(false);
|
|
3285
3402
|
const [mountsEpoch, setMountsEpoch] = useState(0);
|
|
3286
3403
|
const busy = sourceBusy || mountsBusy;
|
|
@@ -3288,11 +3405,14 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
3288
3405
|
const generation = useRef(0), fileRequest = useRef(0), previewRequest = useRef(0), prepareRequest = useRef(0);
|
|
3289
3406
|
const sourceDirty = Object.keys(drafts).length > 0;
|
|
3290
3407
|
const dirty = sourceDirty || mountsDirty;
|
|
3291
|
-
const
|
|
3408
|
+
const mountedSelection = selectedMount ?? initialSelection?.bundle;
|
|
3409
|
+
const selectedBundle = record?.kind === "bundle" ? record.bundle ?? record.source.bundle : record?.mounts.find((mount) => mount.bundle.name === mountedSelection?.name && mount.bundle.version === mountedSelection.version)?.bundle;
|
|
3292
3410
|
const previewBundle = useMemo(() => selectedBundle ? {
|
|
3293
3411
|
name: selectedBundle.name,
|
|
3294
3412
|
version: selectedBundle.version
|
|
3295
3413
|
} : void 0, [selectedBundle?.name, selectedBundle?.version]);
|
|
3414
|
+
const mountedPreviewTitle = record?.mounts.find((mount) => mount.bundle.name === previewBundle?.name && mount.bundle.version === previewBundle.version)?.display?.title?.[locale] ?? previewBundle?.name;
|
|
3415
|
+
const readingMountedPreview = readOnly && record?.kind === "kit" && tab === "preview";
|
|
3296
3416
|
const titleDirty = renaming && title !== record?.title[locale];
|
|
3297
3417
|
const notifyDirty = useRef(onDirtyChange);
|
|
3298
3418
|
notifyDirty.current = onDirtyChange;
|
|
@@ -3425,6 +3545,7 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
3425
3545
|
const current = ++generation.current;
|
|
3426
3546
|
++fileRequest.current;
|
|
3427
3547
|
++previewRequest.current;
|
|
3548
|
+
setSelectedMount(void 0);
|
|
3428
3549
|
setRecord(void 0);
|
|
3429
3550
|
setOpening(true);
|
|
3430
3551
|
setPath("");
|
|
@@ -3456,7 +3577,8 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
3456
3577
|
}
|
|
3457
3578
|
setRecord(value);
|
|
3458
3579
|
setPath(initialView === "preview" && value.kind === "bundle" && value.files?.some((file) => file.path === "panel.yaml") ? "panel.yaml" : value.files?.find((file) => /(^|\/)(mindset|SKILL)\.md$/.test(file.path))?.path ?? value.files?.[0]?.path ?? "");
|
|
3459
|
-
if (value.kind === "kit"
|
|
3580
|
+
if (value.kind === "kit") setTab(readOnly && initialView === "preview" && selected ? "preview" : "files");
|
|
3581
|
+
else if (!value.files?.some((file) => file.path === "panel.yaml")) setTab("files");
|
|
3460
3582
|
}, (failure) => {
|
|
3461
3583
|
if (generation.current === current) fail(failure);
|
|
3462
3584
|
}).finally(() => {
|
|
@@ -3593,11 +3715,11 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
3593
3715
|
};
|
|
3594
3716
|
const changeTab = (next) => {
|
|
3595
3717
|
if (next === tab || busy || candidateBusy || mountActions?.isSaveSubmitted()) return;
|
|
3596
|
-
if (next === "mounts" || tab === "mounts") {
|
|
3718
|
+
if (!readOnly && (next === "mounts" || tab === "mounts")) {
|
|
3597
3719
|
if (!discard()) return;
|
|
3598
3720
|
restore();
|
|
3599
3721
|
}
|
|
3600
|
-
if (next === "preview" && filePaths.includes("panel.yaml") && !openFile("panel.yaml")) return;
|
|
3722
|
+
if (next === "preview" && record?.kind === "bundle" && filePaths.includes("panel.yaml") && !openFile("panel.yaml")) return;
|
|
3601
3723
|
setTab(next);
|
|
3602
3724
|
};
|
|
3603
3725
|
const mutate = async (action) => {
|
|
@@ -3689,7 +3811,7 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
3689
3811
|
});
|
|
3690
3812
|
};
|
|
3691
3813
|
useEffect(() => {
|
|
3692
|
-
if (tab !== "preview" || record
|
|
3814
|
+
if (tab !== "preview" || !record || record.kind === "kit" && !readOnly || busy || candidatePending || sourceDirty) return;
|
|
3693
3815
|
const bundle = previewBundle;
|
|
3694
3816
|
setPreview(void 0);
|
|
3695
3817
|
if (!bundle) return;
|
|
@@ -3726,7 +3848,8 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
3726
3848
|
locale,
|
|
3727
3849
|
busy,
|
|
3728
3850
|
candidatePending,
|
|
3729
|
-
sourceDirty
|
|
3851
|
+
sourceDirty,
|
|
3852
|
+
readOnly
|
|
3730
3853
|
]);
|
|
3731
3854
|
const file = record?.files?.find((entry) => entry.path === path);
|
|
3732
3855
|
const exportDisabled = !record || record.id !== id || busy || candidateBusy || candidateState?.saveUnverified || mountActions?.isSaveSubmitted();
|
|
@@ -3754,7 +3877,9 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
3754
3877
|
restore();
|
|
3755
3878
|
if (candidatePending) dismissChanges();
|
|
3756
3879
|
};
|
|
3757
|
-
const
|
|
3880
|
+
const sourceChangeCount = currentPrepared?.candidate.diff.length ?? (!batchSource ? Object.keys(drafts).length : void 0);
|
|
3881
|
+
const selectedFileChanged = currentPrepared ? currentPrepared.candidate.diff.some((change) => change.path === path) : Object.hasOwn(drafts, path) || !!fileChange;
|
|
3882
|
+
const sourceStatus = candidateState?.saveUnverified ? zh ? "保存结果待确认" : "Save needs verification" : !sourcePending ? zh ? "已保存" : "Saved" : sourceChangeCount === void 0 ? preparingDraft ? zh ? "正在准备修改…" : "Preparing changes…" : zh ? "修改未保存" : "Unsaved changes" : sourceChangeCount === 0 ? zh ? "没有文件修改" : "No file changes" : zh ? `${sourceChangeCount} 个文件未保存` : `${sourceChangeCount} unsaved ${sourceChangeCount === 1 ? "file" : "files"}`;
|
|
3758
3883
|
const exportDisabledReason = !exportDisabled ? void 0 : !record || record.id !== id ? zh ? "正在打开内容,请稍后再导出。" : "Wait for the content to open before exporting." : candidateState?.saveUnverified || mountActions?.saveUnverified ? zh ? "请先核对保存结果,再导出。" : "Verify the save result before exporting." : zh ? "请等待当前操作完成,再导出。" : "Wait for the current operation to finish before exporting.";
|
|
3759
3884
|
const editSource = (text) => {
|
|
3760
3885
|
if (sourceLocked || !loaded || readOnly || text === content) return;
|
|
@@ -3842,71 +3967,67 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
3842
3967
|
description: zh ? "可在原始文件中查看和编辑技能内容。" : "View and edit this skill in Source Files."
|
|
3843
3968
|
});
|
|
3844
3969
|
const noPanelRequired = sourcePending ? !!candidateState?.matches && candidateState.prepared.candidate.valid && !candidateState.prepared.candidate.preview : !!preview && !preview.diagnostics.length && !preview.preview;
|
|
3970
|
+
const sourceToolbar = /* @__PURE__ */ jsxs("div", {
|
|
3971
|
+
className: "ygd-studio-doc-toolbar ygd-studio-source-toolbar",
|
|
3972
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
3973
|
+
className: "ygd-studio-file-heading",
|
|
3974
|
+
children: /* @__PURE__ */ jsx(FileName, {
|
|
3975
|
+
path,
|
|
3976
|
+
locale
|
|
3977
|
+
})
|
|
3978
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
3979
|
+
className: "ygd-studio-doc-toggle-group",
|
|
3980
|
+
children: readOnly && /\.md$/i.test(path) ? /* @__PURE__ */ jsx("button", {
|
|
3981
|
+
type: "button",
|
|
3982
|
+
className: "ygd-studio-doc-toggle",
|
|
3983
|
+
"aria-pressed": reading,
|
|
3984
|
+
onClick: () => setReading(!reading),
|
|
3985
|
+
children: reading ? zh ? "原文" : "Source" : zh ? "阅读" : "Read"
|
|
3986
|
+
}) : !readOnly && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("button", {
|
|
3987
|
+
type: "button",
|
|
3988
|
+
className: "ygd-studio-doc-toggle",
|
|
3989
|
+
"aria-pressed": fileView === "edit",
|
|
3990
|
+
onClick: () => setFileView("edit"),
|
|
3991
|
+
children: zh ? "编辑" : "Edit"
|
|
3992
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
3993
|
+
type: "button",
|
|
3994
|
+
className: "ygd-studio-doc-toggle",
|
|
3995
|
+
"aria-pressed": fileView === "diff",
|
|
3996
|
+
onClick: () => setFileView("diff"),
|
|
3997
|
+
children: zh ? "对比" : "Diff"
|
|
3998
|
+
})] })
|
|
3999
|
+
})]
|
|
4000
|
+
});
|
|
4001
|
+
const sourceDocument = /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
|
|
4002
|
+
className: "ygd-studio-document-body ygd-studio-source-body",
|
|
4003
|
+
children: file?.editable === false ? /* @__PURE__ */ jsx("p", {
|
|
4004
|
+
role: "status",
|
|
4005
|
+
children: zh ? "此文件不支持文本编辑,复制时会完整保留。" : "This file is not available for text editing. Copies preserve it in full."
|
|
4006
|
+
}) : !loaded ? /* @__PURE__ */ jsx("p", {
|
|
4007
|
+
role: "status",
|
|
4008
|
+
children: error ? zh ? "无法读取此文件。" : "Could not load this file." : path ? zh ? "读取中…" : "Loading…" : zh ? "没有可读取的文件。" : "No readable files."
|
|
4009
|
+
}) : !readOnly && fileView === "diff" ? /* @__PURE__ */ jsx(SourceFileDiff, {
|
|
4010
|
+
path,
|
|
4011
|
+
before: fileChange?.before ?? saved,
|
|
4012
|
+
after: fileChange && !Object.hasOwn(drafts, path) ? fileChange.after : content
|
|
4013
|
+
}) : readOnly && reading && /\.md$/i.test(path) ? /* @__PURE__ */ jsx("div", { children: renderStudioDocument(content, { locale }) }) : /* @__PURE__ */ jsx(SourceTextArea, {
|
|
4014
|
+
inputRef: sourceEditor,
|
|
4015
|
+
label: path || "Source file",
|
|
4016
|
+
content,
|
|
4017
|
+
readOnly: readOnly || sourceLocked,
|
|
4018
|
+
onChange: editSource
|
|
4019
|
+
})
|
|
4020
|
+
}), /* @__PURE__ */ jsxs("footer", {
|
|
4021
|
+
className: "ygd-studio-doc-footer",
|
|
4022
|
+
children: [/* @__PURE__ */ jsx("span", { children: candidateState?.saveUnverified ? zh ? "保存结果待确认,请刷新内容核对;不会自动重试" : "Save result needs verification. Refresh the content; saving will not retry automatically." : selectedFileChanged ? candidatePending && !Object.hasOwn(drafts, path) ? zh ? "待保存修改" : "Proposed changes · not saved" : zh ? "未保存" : "Unsaved" : !readOnly && file?.editable ? zh ? "已保存 · 可编辑" : "Saved · editable" : zh ? "只读文件" : "Read-only file" }), /* @__PURE__ */ jsxs("span", { children: [
|
|
4023
|
+
loaded ? new TextEncoder().encode(content).length : fileChange ? new TextEncoder().encode(fileChange.after ?? "").length : file?.bytes ?? 0,
|
|
4024
|
+
" ",
|
|
4025
|
+
zh ? "字节" : "bytes"
|
|
4026
|
+
] })]
|
|
4027
|
+
})] });
|
|
3845
4028
|
const sourcePane = /* @__PURE__ */ jsxs("div", {
|
|
3846
4029
|
className: "ygd-studio-content-pane",
|
|
3847
|
-
children: [
|
|
3848
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3849
|
-
className: "ygd-studio-doc-toolbar",
|
|
3850
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
3851
|
-
className: "ygd-studio-file-heading",
|
|
3852
|
-
children: /* @__PURE__ */ jsx(FileName, {
|
|
3853
|
-
path,
|
|
3854
|
-
locale
|
|
3855
|
-
})
|
|
3856
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
3857
|
-
className: "ygd-studio-doc-toggle-group",
|
|
3858
|
-
children: readOnly && /\.md$/i.test(path) ? /* @__PURE__ */ jsx("button", {
|
|
3859
|
-
type: "button",
|
|
3860
|
-
className: "ygd-studio-doc-toggle",
|
|
3861
|
-
"aria-pressed": reading,
|
|
3862
|
-
onClick: () => setReading(!reading),
|
|
3863
|
-
children: reading ? zh ? "原文" : "Source" : zh ? "阅读" : "Read"
|
|
3864
|
-
}) : !readOnly && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("button", {
|
|
3865
|
-
type: "button",
|
|
3866
|
-
className: "ygd-studio-doc-toggle",
|
|
3867
|
-
"aria-pressed": fileView === "edit",
|
|
3868
|
-
onClick: () => setFileView("edit"),
|
|
3869
|
-
children: zh ? "编辑" : "Edit"
|
|
3870
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
3871
|
-
type: "button",
|
|
3872
|
-
className: "ygd-studio-doc-toggle",
|
|
3873
|
-
"aria-pressed": fileView === "diff",
|
|
3874
|
-
onClick: () => setFileView("diff"),
|
|
3875
|
-
children: zh ? "对比" : "Diff"
|
|
3876
|
-
})] })
|
|
3877
|
-
})]
|
|
3878
|
-
}),
|
|
3879
|
-
/* @__PURE__ */ jsx("div", {
|
|
3880
|
-
className: "ygd-studio-document-body ygd-studio-source-body",
|
|
3881
|
-
children: file?.editable === false ? /* @__PURE__ */ jsx("p", {
|
|
3882
|
-
role: "status",
|
|
3883
|
-
children: zh ? "此文件不支持文本编辑,复制时会完整保留。" : "This file is not available for text editing. Copies preserve it in full."
|
|
3884
|
-
}) : !loaded ? /* @__PURE__ */ jsx("p", {
|
|
3885
|
-
role: "status",
|
|
3886
|
-
children: error ? zh ? "无法读取此文件。" : "Could not load this file." : path ? zh ? "读取中…" : "Loading…" : zh ? "没有可读取的文件。" : "No readable files."
|
|
3887
|
-
}) : !readOnly && fileView === "diff" ? /* @__PURE__ */ jsx(SourceFileDiff, {
|
|
3888
|
-
path,
|
|
3889
|
-
before: fileChange?.before ?? saved,
|
|
3890
|
-
after: fileChange && !Object.hasOwn(drafts, path) ? fileChange.after : content
|
|
3891
|
-
}) : readOnly && reading && /\.md$/i.test(path) ? /* @__PURE__ */ jsx("div", { children: renderStudioDocument(content, { locale }) }) : /* @__PURE__ */ jsx("textarea", {
|
|
3892
|
-
ref: sourceEditor,
|
|
3893
|
-
"aria-label": path || "Source file",
|
|
3894
|
-
spellCheck: false,
|
|
3895
|
-
value: content,
|
|
3896
|
-
readOnly: readOnly || sourceLocked,
|
|
3897
|
-
onChange: (event) => editSource(event.target.value),
|
|
3898
|
-
className: "ygd-studio-source-input"
|
|
3899
|
-
})
|
|
3900
|
-
}),
|
|
3901
|
-
/* @__PURE__ */ jsxs("footer", {
|
|
3902
|
-
className: "ygd-studio-doc-footer",
|
|
3903
|
-
children: [/* @__PURE__ */ jsx("span", { children: candidateState?.saveUnverified ? zh ? "保存结果待确认,请刷新内容核对;不会自动重试" : "Save result needs verification. Refresh the content; saving will not retry automatically." : candidatePending ? zh ? "待保存修改" : "Proposed changes · not saved" : dirty ? zh ? "未保存" : "Unsaved" : !readOnly && file?.editable ? zh ? "已保存 · 可编辑" : "Saved · editable" : zh ? "只读文件" : "Read-only file" }), /* @__PURE__ */ jsxs("span", { children: [
|
|
3904
|
-
loaded ? new TextEncoder().encode(content).length : fileChange ? new TextEncoder().encode(fileChange.after ?? "").length : file?.bytes ?? 0,
|
|
3905
|
-
" ",
|
|
3906
|
-
zh ? "字节" : "bytes"
|
|
3907
|
-
] })]
|
|
3908
|
-
})
|
|
3909
|
-
]
|
|
4030
|
+
children: [sourceToolbar, sourceDocument]
|
|
3910
4031
|
});
|
|
3911
4032
|
const mountGeneration = generation.current;
|
|
3912
4033
|
return /* @__PURE__ */ jsxs(embedded ? "section" : "main", {
|
|
@@ -4013,7 +4134,10 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
4013
4134
|
className: "ygd-studio-btn-primary",
|
|
4014
4135
|
disabled: busy || candidatePending,
|
|
4015
4136
|
onClick: () => {
|
|
4016
|
-
if (!busy && !candidatePending)
|
|
4137
|
+
if (!busy && !candidatePending) {
|
|
4138
|
+
if (record.kind === "kit" && tab === "preview") setTab("files");
|
|
4139
|
+
onEdit();
|
|
4140
|
+
}
|
|
4017
4141
|
},
|
|
4018
4142
|
children: zh ? "编辑" : "Edit"
|
|
4019
4143
|
}),
|
|
@@ -4102,7 +4226,7 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
4102
4226
|
intent: authoringIntent,
|
|
4103
4227
|
proposalReplacement
|
|
4104
4228
|
}),
|
|
4105
|
-
record &&
|
|
4229
|
+
record && /* @__PURE__ */ jsxs("div", {
|
|
4106
4230
|
className: "ygd-studio-workplane-bar",
|
|
4107
4231
|
"aria-label": record.kind === "kit" ? "Kit content" : "Bundle content",
|
|
4108
4232
|
children: [/* @__PURE__ */ jsx("button", {
|
|
@@ -4115,10 +4239,10 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
4115
4239
|
}), record.kind === "kit" ? /* @__PURE__ */ jsx("button", {
|
|
4116
4240
|
type: "button",
|
|
4117
4241
|
className: "ygd-studio-workplane-tab",
|
|
4118
|
-
"aria-pressed": tab === "mounts",
|
|
4119
|
-
disabled: sourceLocked || candidatePending || !client.updateMounts,
|
|
4242
|
+
"aria-pressed": tab === "mounts" || tab === "preview",
|
|
4243
|
+
disabled: busy || candidateBusy || !readOnly && (sourceLocked || candidatePending || !client.updateMounts),
|
|
4120
4244
|
onClick: () => changeTab("mounts"),
|
|
4121
|
-
children: zh ? "挂载管理" : "Mount management"
|
|
4245
|
+
children: readOnly ? zh ? "挂载内容" : "Mounted Bundles" : zh ? "挂载管理" : "Mount management"
|
|
4122
4246
|
}) : /* @__PURE__ */ jsx("button", {
|
|
4123
4247
|
type: "button",
|
|
4124
4248
|
className: "ygd-studio-workplane-tab",
|
|
@@ -4147,8 +4271,12 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
4147
4271
|
feedbackId: `source:${error}`,
|
|
4148
4272
|
tone: "error",
|
|
4149
4273
|
locale,
|
|
4150
|
-
title: zh ? "操作未完成" : "The operation could not be completed",
|
|
4151
|
-
message: error
|
|
4274
|
+
title: readingMountedPreview ? zh ? "面板预览未能读取" : "Panel preview could not be loaded" : zh ? "操作未完成" : "The operation could not be completed",
|
|
4275
|
+
message: error,
|
|
4276
|
+
actions: readingMountedPreview ? [{
|
|
4277
|
+
label: zh ? "返回挂载内容" : "Back to Mounted Bundles",
|
|
4278
|
+
onClick: () => changeTab("mounts")
|
|
4279
|
+
}] : void 0
|
|
4152
4280
|
})]
|
|
4153
4281
|
}),
|
|
4154
4282
|
tab === "mounts" && !readOnly && record?.kind === "kit" && /* @__PURE__ */ jsx(MountEditor, {
|
|
@@ -4165,6 +4293,17 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
4165
4293
|
onChanged(value);
|
|
4166
4294
|
}
|
|
4167
4295
|
}, `${id}:${record.revision}:${mountsEpoch}`),
|
|
4296
|
+
tab === "mounts" && readOnly && record?.kind === "kit" && /* @__PURE__ */ jsx(MountedBundleBrowser, {
|
|
4297
|
+
record,
|
|
4298
|
+
locale,
|
|
4299
|
+
onPreview: (bundle) => {
|
|
4300
|
+
setPreview(void 0);
|
|
4301
|
+
setPreviewBusy(true);
|
|
4302
|
+
setError("");
|
|
4303
|
+
setSelectedMount(bundle);
|
|
4304
|
+
setTab("preview");
|
|
4305
|
+
}
|
|
4306
|
+
}),
|
|
4168
4307
|
tab === "files" && (record?.id === id ? /* @__PURE__ */ jsxs("div", {
|
|
4169
4308
|
className: "ygd-studio-workspace-body ygd-studio-files-layout",
|
|
4170
4309
|
children: [
|
|
@@ -4254,30 +4393,75 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
4254
4393
|
})
|
|
4255
4394
|
]
|
|
4256
4395
|
}) : opening ? /* @__PURE__ */ jsx(LoadingIndicator, { label: zh ? "正在打开内容" : "Opening content" }) : null),
|
|
4257
|
-
tab === "preview" && record
|
|
4396
|
+
tab === "preview" && record && (record.kind === "bundle" || readOnly && record.kind === "kit" && previewBundle) && /* @__PURE__ */ jsxs("section", {
|
|
4258
4397
|
className: "ygd-studio-panel-split",
|
|
4259
|
-
children: [
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4398
|
+
children: [
|
|
4399
|
+
record.kind === "kit" ? /* @__PURE__ */ jsxs("header", {
|
|
4400
|
+
className: "ygd-studio-doc-toolbar ygd-studio-source-toolbar",
|
|
4401
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
4402
|
+
type: "button",
|
|
4403
|
+
className: "ygd-studio-btn-link",
|
|
4404
|
+
onClick: () => changeTab("mounts"),
|
|
4405
|
+
children: zh ? "返回挂载内容" : "Back to Mounted Bundles"
|
|
4406
|
+
}), /* @__PURE__ */ jsx(FileName, {
|
|
4407
|
+
path: "panel.yaml",
|
|
4408
|
+
locale
|
|
4409
|
+
})]
|
|
4410
|
+
}) : filePaths.includes("panel.yaml") ? sourceToolbar : /* @__PURE__ */ jsx("header", {
|
|
4411
|
+
className: "ygd-studio-doc-toolbar ygd-studio-source-toolbar",
|
|
4412
|
+
children: zh ? "面板源码" : "Panel source"
|
|
4413
|
+
}),
|
|
4414
|
+
/* @__PURE__ */ jsxs("header", {
|
|
4415
|
+
className: "ygd-studio-doc-toolbar ygd-studio-preview-toolbar",
|
|
4416
|
+
children: [/* @__PURE__ */ jsx("strong", { children: record.kind === "kit" ? mountedPreviewTitle : zh ? "面板预览" : "Panel Preview" }), /* @__PURE__ */ jsx("span", { children: record.kind === "kit" ? zh ? "已保存源码 · 样例数据" : "Saved source · sample data" : zh ? "随源码更新 · 样例数据" : "Live source · sample data" })]
|
|
4417
|
+
}),
|
|
4418
|
+
/* @__PURE__ */ jsx("section", {
|
|
4419
|
+
className: "ygd-studio-yaml-pane",
|
|
4420
|
+
"aria-label": zh ? "面板源码" : "Panel source",
|
|
4421
|
+
children: record.kind === "kit" ? /* @__PURE__ */ jsx("div", {
|
|
4422
|
+
className: "ygd-studio-content-pane",
|
|
4423
|
+
children: previewBusy || !preview && !error ? /* @__PURE__ */ jsx(LoadingIndicator, { label: zh ? "正在读取面板源码" : "Loading Panel source" }) : error ? null : preview?.panelSource !== void 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
|
|
4424
|
+
className: "ygd-studio-document-body ygd-studio-source-body",
|
|
4425
|
+
children: /* @__PURE__ */ jsx(SourceTextArea, {
|
|
4426
|
+
label: "panel.yaml",
|
|
4427
|
+
content: preview.panelSource,
|
|
4428
|
+
readOnly: true
|
|
4429
|
+
})
|
|
4430
|
+
}), /* @__PURE__ */ jsxs("footer", {
|
|
4431
|
+
className: "ygd-studio-doc-footer",
|
|
4432
|
+
children: [/* @__PURE__ */ jsx("span", { children: zh ? "只读文件" : "Read-only file" }), /* @__PURE__ */ jsxs("span", { children: [
|
|
4433
|
+
new TextEncoder().encode(preview.panelSource).length,
|
|
4434
|
+
" ",
|
|
4435
|
+
zh ? "字节" : "bytes"
|
|
4436
|
+
] })]
|
|
4437
|
+
})] }) : /* @__PURE__ */ jsx(StudioEmptyState, {
|
|
4438
|
+
tone: "info",
|
|
4439
|
+
title: zh ? "原始源码暂不可用" : "Original Panel source is unavailable"
|
|
4440
|
+
})
|
|
4441
|
+
}) : filePaths.includes("panel.yaml") ? /* @__PURE__ */ jsx("div", {
|
|
4442
|
+
className: "ygd-studio-content-pane",
|
|
4443
|
+
children: sourceDocument
|
|
4444
|
+
}) : /* @__PURE__ */ jsx(StudioEmptyState, {
|
|
4445
|
+
tone: noPanelRequired ? "info" : "warning",
|
|
4446
|
+
title: zh ? "未提供面板源码" : "No Panel source",
|
|
4447
|
+
description: zh ? "此技能包没有 panel.yaml 文件。" : "This Bundle has no panel.yaml file."
|
|
4448
|
+
})
|
|
4449
|
+
}),
|
|
4450
|
+
/* @__PURE__ */ jsx("section", {
|
|
4451
|
+
className: "ygd-studio-live-pane",
|
|
4452
|
+
"aria-label": zh ? "实时面板预览" : "Live Panel preview",
|
|
4453
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
4454
|
+
className: "ygd-studio-live-pane-body",
|
|
4455
|
+
children: sourcePending ? /* @__PURE__ */ jsx(Fragment$1, { children: preparingDraft ? /* @__PURE__ */ jsx(LoadingIndicator, { label: zh ? "正在更新预览" : "Updating preview" }) : /* @__PURE__ */ jsx(Fragment$1, { children: candidateState?.matches && candidateState.prepared.candidate.preview && renderPreview ? renderPreview(candidateState.prepared.candidate.preview, () => {}, {
|
|
4456
|
+
readOnly: true,
|
|
4457
|
+
toolbarTarget: null
|
|
4458
|
+
}) : previewState(candidateState?.prepared.candidate.diagnostics ?? [], noPanelRequired) }) }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [previewBusy && /* @__PURE__ */ jsx(LoadingIndicator, { label: zh ? "正在准备预览" : "Preparing preview" }), preview?.preview && renderPreview ? renderPreview(preview.preview, () => {}, {
|
|
4459
|
+
readOnly,
|
|
4460
|
+
toolbarTarget: null
|
|
4461
|
+
}) : !previewBusy && !(readingMountedPreview && error) && previewState(preview?.diagnostics ?? [], noPanelRequired)] })
|
|
4462
|
+
})
|
|
4266
4463
|
})
|
|
4267
|
-
|
|
4268
|
-
className: "ygd-studio-live-pane",
|
|
4269
|
-
"aria-label": zh ? "实时面板预览" : "Live Panel preview",
|
|
4270
|
-
children: [/* @__PURE__ */ jsxs("header", { children: [/* @__PURE__ */ jsx("strong", { children: zh ? "面板预览" : "Panel Preview" }), /* @__PURE__ */ jsx("span", { children: zh ? "随源码更新 · 样例数据" : "Live source · sample data" })] }), /* @__PURE__ */ jsx("div", {
|
|
4271
|
-
className: "ygd-studio-live-pane-body",
|
|
4272
|
-
children: sourcePending ? /* @__PURE__ */ jsx(Fragment$1, { children: preparingDraft ? /* @__PURE__ */ jsx(LoadingIndicator, { label: zh ? "正在更新预览" : "Updating preview" }) : /* @__PURE__ */ jsx(Fragment$1, { children: candidateState?.matches && candidateState.prepared.candidate.preview && renderPreview ? renderPreview(candidateState.prepared.candidate.preview, () => {}, {
|
|
4273
|
-
readOnly: true,
|
|
4274
|
-
toolbarTarget: null
|
|
4275
|
-
}) : previewState(candidateState?.prepared.candidate.diagnostics ?? [], noPanelRequired) }) }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [previewBusy && /* @__PURE__ */ jsx(LoadingIndicator, { label: zh ? "正在准备预览" : "Preparing preview" }), preview?.preview && renderPreview ? renderPreview(preview.preview, () => {}, {
|
|
4276
|
-
readOnly,
|
|
4277
|
-
toolbarTarget: null
|
|
4278
|
-
}) : !previewBusy && previewState(preview?.diagnostics ?? [], noPanelRequired)] })
|
|
4279
|
-
})]
|
|
4280
|
-
})]
|
|
4464
|
+
]
|
|
4281
4465
|
})
|
|
4282
4466
|
]
|
|
4283
4467
|
});
|
|
@@ -4695,7 +4879,7 @@ function encodeStudioContentZip(source) {
|
|
|
4695
4879
|
if (entries[name]) throw Error("Duplicate ZIP file path.");
|
|
4696
4880
|
entries[name] = fromBase64(base64);
|
|
4697
4881
|
sourceBytes += entries[name].byteLength;
|
|
4698
|
-
if (sourceBytes > STUDIO_SOURCE_MAX_BYTES) throw Error("ZIP source content exceeds
|
|
4882
|
+
if (sourceBytes > STUDIO_SOURCE_MAX_BYTES) throw Error("ZIP source content exceeds 64 MiB.");
|
|
4699
4883
|
return file;
|
|
4700
4884
|
});
|
|
4701
4885
|
entries[MANIFEST] = encoder.encode(JSON.stringify({
|
|
@@ -4775,7 +4959,7 @@ function decodeStudioContentZip(bytes) {
|
|
|
4775
4959
|
if (data.length !== file.bytes) throw Error(`ZIP file size mismatch: ${file.path}`);
|
|
4776
4960
|
used.add(name);
|
|
4777
4961
|
sourceBytes += data.byteLength;
|
|
4778
|
-
if (sourceBytes > STUDIO_SOURCE_MAX_BYTES) throw Error("ZIP source content exceeds
|
|
4962
|
+
if (sourceBytes > STUDIO_SOURCE_MAX_BYTES) throw Error("ZIP source content exceeds 64 MiB.");
|
|
4779
4963
|
return {
|
|
4780
4964
|
...file,
|
|
4781
4965
|
base64: toBase64(data)
|
|
@@ -4817,7 +5001,7 @@ function checkSources(input) {
|
|
|
4817
5001
|
names.add(key);
|
|
4818
5002
|
sourceBytes += file.base64.length / 4 * 3 - (file.base64.endsWith("==") ? 2 : file.base64.endsWith("=") ? 1 : 0);
|
|
4819
5003
|
}
|
|
4820
|
-
if (input.files.length > 4096 || sourceBytes > STUDIO_SOURCE_MAX_BYTES) throw Error("Import source exceeds
|
|
5004
|
+
if (input.files.length > 4096 || sourceBytes > STUDIO_SOURCE_MAX_BYTES) throw Error("Import source exceeds 64 MiB or 4096 files. No content was truncated.");
|
|
4821
5005
|
if (new TextEncoder().encode(JSON.stringify({
|
|
4822
5006
|
method: "studioInstanceImportSources",
|
|
4823
5007
|
params: input
|
|
@@ -5184,67 +5368,82 @@ function InstalledPreview({ authoring, renderPreview: render, client, kit, bundl
|
|
|
5184
5368
|
]);
|
|
5185
5369
|
return /* @__PURE__ */ jsxs("section", {
|
|
5186
5370
|
className: "ygd-studio-panel-split",
|
|
5187
|
-
children: [
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
className: "ygd-studio-live-pane-body",
|
|
5217
|
-
children: [
|
|
5218
|
-
!previewInstalled && /* @__PURE__ */ jsx(StudioEmptyState, { title: locale === "zh" ? "此处暂不支持面板预览" : "Panel preview is unavailable here" }),
|
|
5219
|
-
busy && /* @__PURE__ */ jsx(LoadingIndicator, { label: locale === "zh" ? "正在加载预览" : "Loading preview" }),
|
|
5220
|
-
error && /* @__PURE__ */ jsx(StudioFeedback, {
|
|
5221
|
-
feedbackId: `preview:${retry}:${error}`,
|
|
5371
|
+
children: [
|
|
5372
|
+
/* @__PURE__ */ jsxs("header", {
|
|
5373
|
+
className: "ygd-studio-doc-toolbar ygd-studio-source-toolbar",
|
|
5374
|
+
children: [/* @__PURE__ */ jsx(FileName, {
|
|
5375
|
+
path: "panel.yaml",
|
|
5376
|
+
locale
|
|
5377
|
+
}), onEdit && /* @__PURE__ */ jsx("button", {
|
|
5378
|
+
className: "ygd-studio-btn-secondary",
|
|
5379
|
+
type: "button",
|
|
5380
|
+
onClick: onEdit,
|
|
5381
|
+
children: locale === "zh" ? "编辑" : "Edit"
|
|
5382
|
+
})]
|
|
5383
|
+
}),
|
|
5384
|
+
/* @__PURE__ */ jsxs("header", {
|
|
5385
|
+
className: "ygd-studio-doc-toolbar ygd-studio-preview-toolbar",
|
|
5386
|
+
children: [/* @__PURE__ */ jsx("strong", { children: locale === "zh" ? "面板预览" : "Panel Preview" }), /* @__PURE__ */ jsx("span", { children: locale === "zh" ? "随源码更新 · 样例数据" : "Live source · sample data" })]
|
|
5387
|
+
}),
|
|
5388
|
+
/* @__PURE__ */ jsx("section", {
|
|
5389
|
+
className: "ygd-studio-yaml-pane",
|
|
5390
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
5391
|
+
className: "ygd-studio-document-body ygd-studio-source-body",
|
|
5392
|
+
children: panelSource !== void 0 ? /* @__PURE__ */ jsx("textarea", {
|
|
5393
|
+
className: "ygd-studio-source-input",
|
|
5394
|
+
"aria-label": "Panel YAML",
|
|
5395
|
+
spellCheck: false,
|
|
5396
|
+
value: panelSource,
|
|
5397
|
+
readOnly: true
|
|
5398
|
+
}) : sourceError ? /* @__PURE__ */ jsx(StudioFeedback, {
|
|
5399
|
+
feedbackId: `source:${retry}:${sourceError}`,
|
|
5222
5400
|
tone: "error",
|
|
5223
5401
|
locale,
|
|
5224
|
-
title: locale === "zh" ? "
|
|
5225
|
-
message:
|
|
5402
|
+
title: locale === "zh" ? "无法读取面板定义" : "Could not read Panel source",
|
|
5403
|
+
message: sourceError,
|
|
5226
5404
|
actions: [{
|
|
5227
5405
|
label: locale === "zh" ? "重试" : "Retry",
|
|
5228
5406
|
onClick: () => setRetry((value) => value + 1)
|
|
5229
5407
|
}]
|
|
5230
|
-
}),
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
title: locale === "zh" ? "
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5408
|
+
}) : declarative ? /* @__PURE__ */ jsx(LoadingIndicator, { label: locale === "zh" ? "正在读取面板定义" : "Loading Panel definition" }) : /* @__PURE__ */ jsx(StudioEmptyState, { title: locale === "zh" ? "此面板由原生组件提供" : "This is a native Panel" })
|
|
5409
|
+
})
|
|
5410
|
+
}),
|
|
5411
|
+
/* @__PURE__ */ jsx("section", {
|
|
5412
|
+
className: "ygd-studio-live-pane",
|
|
5413
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
5414
|
+
className: "ygd-studio-live-pane-body",
|
|
5415
|
+
children: [
|
|
5416
|
+
!previewInstalled && /* @__PURE__ */ jsx(StudioEmptyState, { title: locale === "zh" ? "此处暂不支持面板预览" : "Panel preview is unavailable here" }),
|
|
5417
|
+
busy && /* @__PURE__ */ jsx(LoadingIndicator, { label: locale === "zh" ? "正在加载预览" : "Loading preview" }),
|
|
5418
|
+
error && /* @__PURE__ */ jsx(StudioFeedback, {
|
|
5419
|
+
feedbackId: `preview:${retry}:${error}`,
|
|
5420
|
+
tone: "error",
|
|
5421
|
+
locale,
|
|
5422
|
+
title: locale === "zh" ? "无法载入面板预览" : "Could not load Panel preview",
|
|
5423
|
+
message: error,
|
|
5424
|
+
actions: [{
|
|
5425
|
+
label: locale === "zh" ? "重试" : "Retry",
|
|
5426
|
+
onClick: () => setRetry((value) => value + 1)
|
|
5427
|
+
}]
|
|
5428
|
+
}),
|
|
5429
|
+
!!result?.diagnostics.length && (result.diagnostics.every((item) => item.code === "preview.sample_missing") ? /* @__PURE__ */ jsx(StudioEmptyState, {
|
|
5430
|
+
title: locale === "zh" ? "缺少预览样例" : "Preview sample is missing",
|
|
5431
|
+
description: locale === "zh" ? "添加 reference/preview.json 后,可在这里查看面板效果。" : "Add reference/preview.json to preview the Panel here."
|
|
5432
|
+
}) : /* @__PURE__ */ jsx(StudioFeedback, {
|
|
5433
|
+
feedbackId: `preview:${retry}:${JSON.stringify(result.diagnostics)}`,
|
|
5434
|
+
tone: "error",
|
|
5435
|
+
locale,
|
|
5436
|
+
title: locale === "zh" ? "面板预览未能生成" : "Panel preview could not be generated",
|
|
5437
|
+
details: result.diagnostics.map((item) => ({ message: item.message }))
|
|
5438
|
+
})),
|
|
5439
|
+
result?.preview && renderPreview?.(result.preview, () => {}, {
|
|
5440
|
+
readOnly: true,
|
|
5441
|
+
toolbarTarget: null
|
|
5442
|
+
})
|
|
5443
|
+
]
|
|
5444
|
+
})
|
|
5246
5445
|
})
|
|
5247
|
-
|
|
5446
|
+
]
|
|
5248
5447
|
});
|
|
5249
5448
|
}
|
|
5250
5449
|
/** Read-only Studio surface: one complete page with global nav, sidebar, and workspace main. */
|
|
@@ -6633,7 +6832,13 @@ function StudioWorkspace({ client, controller: supplied, authoring, renderPrevie
|
|
|
6633
6832
|
editInstalled("kit", kit);
|
|
6634
6833
|
} : void 0,
|
|
6635
6834
|
client: instances,
|
|
6636
|
-
bundle:
|
|
6835
|
+
bundle: {
|
|
6836
|
+
...mountBundle,
|
|
6837
|
+
...localMountRecord ? {
|
|
6838
|
+
instanceId: localMountRecord.id,
|
|
6839
|
+
current: localMountRecord.current
|
|
6840
|
+
} : {}
|
|
6841
|
+
},
|
|
6637
6842
|
installed: localMountRecord ? [] : snapshot.view?.bundles.find((bundle) => bundle.name === mountBundle.name && bundle.version === mountBundle.version)?.usedBy ?? [],
|
|
6638
6843
|
locale
|
|
6639
6844
|
})
|