@yugoo-design/dsh-design-studio-ui 0.3.5 → 0.3.11
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 +16 -1
- package/lib/index.d.ts +4 -1
- package/lib/index.js +376 -174
- package/licenses/dsh-distribution.json +97 -97
- package/package.json +3 -2
package/lib/index.js
CHANGED
|
@@ -1152,7 +1152,7 @@ button.ygd-studio-select>span:last-child{display:flex;flex:none;align-items:cent
|
|
|
1152
1152
|
.ygd-studio-sidebar-item .ygd-studio-kitmark svg{width:18px;height:18px}
|
|
1153
1153
|
.ygd-studio-kitmark{background:var(--ds-primary-light);color:var(--ds-primary-dark)}
|
|
1154
1154
|
.ygd-studio-content-pane{display:flex;flex-direction:column;padding:0;overflow:hidden}
|
|
1155
|
-
.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)}
|
|
1156
1156
|
.ygd-studio-document-body{flex:1;min-height:0;overflow:auto;padding:18px 24px}
|
|
1157
1157
|
.ygd-studio-document-body:has(>.ygd-studio-loading),.ygd-studio-live-pane-body:has(>.ygd-studio-loading){display:flex;flex-direction:column}
|
|
1158
1158
|
.ygd-studio-file-metadata{margin-bottom:18px;border-radius:8px;background:var(--ds-primary-light,#f7f4fe);color:var(--ds-text-secondary)}
|
|
@@ -1225,13 +1225,15 @@ button.ygd-studio-select>span:last-child{display:flex;flex:none;align-items:cent
|
|
|
1225
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}
|
|
1226
1226
|
.ygd-studio-editor-heading>span{margin-left:auto;color:var(--ds-text-secondary);font-size:12px}
|
|
1227
1227
|
.ygd-studio-panel-split,.ygd-studio-trial-workarea.with-input{grid-template-columns:minmax(260px,32%) minmax(0,1fr)}
|
|
1228
|
-
.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}
|
|
1229
1229
|
.ygd-studio-yaml-pane,.ygd-studio-live-pane{display:flex;flex-direction:column;min-width:0;min-height:0}
|
|
1230
|
-
.
|
|
1231
|
-
.ygd-studio-
|
|
1232
|
-
.ygd-studio-
|
|
1233
|
-
.ygd-studio-
|
|
1234
|
-
.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}
|
|
1235
1237
|
.ygd-studio-live-pane-body{display:flex;flex-direction:column;flex:1;min-height:0;overflow:auto;padding:0}
|
|
1236
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}
|
|
1237
1239
|
.ygd-studio-trial-input>.ygd-studio-loading{flex:1}
|
|
@@ -1967,15 +1969,16 @@ function BundleCard({ bundle, locale, badge, onBadgeClick, badgeLabel, sourceLab
|
|
|
1967
1969
|
//#region src/mount-save-receipt.ts
|
|
1968
1970
|
const mountKey = (pin) => pin.name;
|
|
1969
1971
|
/** Preserve Bundle identity and unavailable mounts without pinning mutable library content. */
|
|
1970
|
-
function selectedMountPins(record, keys) {
|
|
1972
|
+
function selectedMountPins(record, keys, replacements = /* @__PURE__ */ new Set()) {
|
|
1971
1973
|
return [...keys].map((key) => {
|
|
1972
|
-
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);
|
|
1973
1975
|
if (!source) throw Error("The selected Bundle source is unavailable. Reopen the Kit before saving.");
|
|
1974
1976
|
const { name, version, instanceId } = source;
|
|
1975
1977
|
return {
|
|
1976
1978
|
name,
|
|
1977
1979
|
version,
|
|
1978
|
-
...instanceId === void 0 ? {} : { instanceId }
|
|
1980
|
+
...instanceId === void 0 ? {} : { instanceId },
|
|
1981
|
+
...replacements.has(key) ? { replaceSource: true } : {}
|
|
1979
1982
|
};
|
|
1980
1983
|
});
|
|
1981
1984
|
}
|
|
@@ -1984,7 +1987,8 @@ function mountSaveMatches(value, pending) {
|
|
|
1984
1987
|
const { base, bundles } = pending;
|
|
1985
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) => {
|
|
1986
1989
|
const expected = bundles[index];
|
|
1987
|
-
|
|
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);
|
|
1988
1992
|
});
|
|
1989
1993
|
}
|
|
1990
1994
|
/** Exact S2 rejections before the instance replace; generic transport/parse errors
|
|
@@ -2013,22 +2017,37 @@ function BundleMounts({ client, bundle, installed, locale, onEditKit }) {
|
|
|
2013
2017
|
const owner = useMemo(() => ({
|
|
2014
2018
|
client,
|
|
2015
2019
|
name: bundle.name,
|
|
2016
|
-
version: bundle.version
|
|
2020
|
+
version: bundle.version,
|
|
2021
|
+
instanceId: bundle.instanceId,
|
|
2022
|
+
current: bundle.current
|
|
2017
2023
|
}), [
|
|
2018
2024
|
client,
|
|
2019
2025
|
bundle.name,
|
|
2020
|
-
bundle.version
|
|
2026
|
+
bundle.version,
|
|
2027
|
+
bundle.instanceId,
|
|
2028
|
+
bundle.current
|
|
2021
2029
|
]);
|
|
2022
2030
|
const current = useRef(owner);
|
|
2023
2031
|
current.current = owner;
|
|
2024
2032
|
const live = useRef(true), writing = useRef();
|
|
2025
2033
|
const pending = useRef();
|
|
2034
|
+
const [resolved, setResolved] = useState();
|
|
2026
2035
|
const [query, setQuery] = useState(""), [retry, refresh] = useState(0);
|
|
2027
2036
|
const [catalog, setCatalog] = useState();
|
|
2028
2037
|
const [operation, setOperation] = useState();
|
|
2029
2038
|
const listing = catalog?.owner === owner ? catalog : void 0;
|
|
2030
2039
|
const update = operation?.owner === owner ? operation : void 0;
|
|
2031
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;
|
|
2032
2051
|
const displayedKits = update?.pending && !kits.some((kit) => kit.id === update.pending.base.id) ? [...kits, update.pending.base] : kits;
|
|
2033
2052
|
const zh = locale === "zh";
|
|
2034
2053
|
useEffect(() => {
|
|
@@ -2080,13 +2099,15 @@ function BundleMounts({ client, bundle, installed, locale, onEditKit }) {
|
|
|
2080
2099
|
active = false;
|
|
2081
2100
|
};
|
|
2082
2101
|
}, [owner, retry]);
|
|
2083
|
-
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));
|
|
2084
2104
|
const toggle = async (kit, checked) => {
|
|
2085
2105
|
if (!client?.updateMounts || busy || listing?.error || pending.current?.owner === owner || writing.current === owner) return;
|
|
2086
2106
|
writing.current = owner;
|
|
2087
2107
|
setOperation({
|
|
2088
2108
|
owner,
|
|
2089
|
-
busy: true
|
|
2109
|
+
busy: true,
|
|
2110
|
+
...checked ? { selecting: kit.id } : {}
|
|
2090
2111
|
});
|
|
2091
2112
|
const valid = () => live.current && current.current === owner;
|
|
2092
2113
|
let submitted;
|
|
@@ -2094,9 +2115,46 @@ function BundleMounts({ client, bundle, installed, locale, onEditKit }) {
|
|
|
2094
2115
|
const pins = new Set(kit.mounts.map((m) => mountKey(m.bundle))), key = mountKey(bundle);
|
|
2095
2116
|
if (checked) pins.add(key);
|
|
2096
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
|
+
}
|
|
2097
2155
|
submitted = {
|
|
2098
2156
|
base: structuredClone(kit),
|
|
2099
|
-
bundles
|
|
2157
|
+
bundles
|
|
2100
2158
|
};
|
|
2101
2159
|
pending.current = {
|
|
2102
2160
|
owner,
|
|
@@ -2154,11 +2212,14 @@ function BundleMounts({ client, bundle, installed, locale, onEditKit }) {
|
|
|
2154
2212
|
children: zh ? "编辑" : "Edit"
|
|
2155
2213
|
})]
|
|
2156
2214
|
}, k.name)),
|
|
2157
|
-
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", {
|
|
2158
2216
|
className: "ygd-studio-bundle-mount-choice",
|
|
2159
2217
|
children: [/* @__PURE__ */ jsx("input", {
|
|
2160
2218
|
type: "checkbox",
|
|
2161
|
-
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
|
+
})),
|
|
2162
2223
|
disabled: busy || !!listing?.error || !!update?.pending || !client?.updateMounts,
|
|
2163
2224
|
onChange: (e) => void toggle(k, e.target.checked)
|
|
2164
2225
|
}), k.title[locale]]
|
|
@@ -2745,11 +2806,47 @@ function BundleTrial({ client, source, locale, disabled = false, target, onOpen,
|
|
|
2745
2806
|
}
|
|
2746
2807
|
//#endregion
|
|
2747
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
|
+
}
|
|
2748
2844
|
function MountEditor(props) {
|
|
2749
2845
|
return /* @__PURE__ */ jsx(MountEditorSession, { ...props }, `${props.record.id}:${props.record.revision}`);
|
|
2750
2846
|
}
|
|
2751
2847
|
function MountEditorSession({ client, record, locale, onSaved, onActions, onDirtyChange, onBusyChange }) {
|
|
2752
2848
|
const [selected, setSelected] = useState(() => new Set(record.mounts.map((m) => mountKey(m.bundle))));
|
|
2849
|
+
const [replacements, setReplacements] = useState(() => /* @__PURE__ */ new Set());
|
|
2753
2850
|
const [query, setQuery] = useState(""), [busy, setBusy] = useState(false), [error, setError] = useState("");
|
|
2754
2851
|
const [saveUnverified, setSaveUnverified] = useState(false);
|
|
2755
2852
|
const pending = useRef(), working = useRef(false), live = useRef(true);
|
|
@@ -2776,7 +2873,7 @@ function MountEditorSession({ client, record, locale, onSaved, onActions, onDirt
|
|
|
2776
2873
|
};
|
|
2777
2874
|
const zh = locale === "zh", candidates = record.availableBundles ?? [];
|
|
2778
2875
|
const original = new Set(record.mounts.map((m) => mountKey(m.bundle)));
|
|
2779
|
-
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));
|
|
2780
2877
|
useEffect(() => {
|
|
2781
2878
|
onDirtyChange?.(dirty || saveUnverified);
|
|
2782
2879
|
}, [
|
|
@@ -2817,6 +2914,12 @@ function MountEditorSession({ client, record, locale, onSaved, onActions, onDirt
|
|
|
2817
2914
|
].filter(Boolean).join(" ").toLowerCase().includes(query.trim().toLowerCase()));
|
|
2818
2915
|
const change = (key, add) => {
|
|
2819
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
|
+
});
|
|
2820
2923
|
setSelected((previous) => {
|
|
2821
2924
|
const next = new Set(previous);
|
|
2822
2925
|
if (add) next.add(key);
|
|
@@ -2834,7 +2937,7 @@ function MountEditorSession({ client, record, locale, onSaved, onActions, onDirt
|
|
|
2834
2937
|
try {
|
|
2835
2938
|
const submitted = {
|
|
2836
2939
|
base: structuredClone(record),
|
|
2837
|
-
bundles: selectedMountPins(record, selected)
|
|
2940
|
+
bundles: selectedMountPins(record, selected, replacements)
|
|
2838
2941
|
};
|
|
2839
2942
|
pending.current = submitted;
|
|
2840
2943
|
const saved = await client.updateMounts({
|
|
@@ -2893,10 +2996,11 @@ function MountEditorSession({ client, record, locale, onSaved, onActions, onDirt
|
|
|
2893
2996
|
verifySave,
|
|
2894
2997
|
saveUnverified,
|
|
2895
2998
|
isSaveSubmitted: () => !!pending.current,
|
|
2896
|
-
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"
|
|
2897
3000
|
});
|
|
2898
3001
|
}, [
|
|
2899
3002
|
selected,
|
|
3003
|
+
replacements,
|
|
2900
3004
|
record,
|
|
2901
3005
|
busy,
|
|
2902
3006
|
dirty,
|
|
@@ -3262,6 +3366,17 @@ function SourceFileDiff({ path, before, after }) {
|
|
|
3262
3366
|
//#endregion
|
|
3263
3367
|
//#region src/InstanceWorkbench.tsx
|
|
3264
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
|
+
}
|
|
3265
3380
|
function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, renderPreview, onDirtyChange, renderSupplement, authoringIntent, embedded = false, readOnly = false, onEdit, initialView = "files", initialSelection, sourceChanges }) {
|
|
3266
3381
|
const zh = locale === "zh";
|
|
3267
3382
|
const [record, setRecord] = useState();
|
|
@@ -3282,6 +3397,7 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
3282
3397
|
const [newFileOpen, setNewFileOpen] = useState(false), [newFilePath, setNewFilePath] = useState(""), [newFileError, setNewFileError] = useState("");
|
|
3283
3398
|
const newFileErrorId = useId();
|
|
3284
3399
|
const [preview, setPreview] = useState(), [previewBusy, setPreviewBusy] = useState(false);
|
|
3400
|
+
const [selectedMount, setSelectedMount] = useState();
|
|
3285
3401
|
const [mountsDirty, setMountsDirty] = useState(false), [mountsBusy, setMountsBusy] = useState(false);
|
|
3286
3402
|
const [mountsEpoch, setMountsEpoch] = useState(0);
|
|
3287
3403
|
const busy = sourceBusy || mountsBusy;
|
|
@@ -3289,11 +3405,14 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
3289
3405
|
const generation = useRef(0), fileRequest = useRef(0), previewRequest = useRef(0), prepareRequest = useRef(0);
|
|
3290
3406
|
const sourceDirty = Object.keys(drafts).length > 0;
|
|
3291
3407
|
const dirty = sourceDirty || mountsDirty;
|
|
3292
|
-
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;
|
|
3293
3410
|
const previewBundle = useMemo(() => selectedBundle ? {
|
|
3294
3411
|
name: selectedBundle.name,
|
|
3295
3412
|
version: selectedBundle.version
|
|
3296
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";
|
|
3297
3416
|
const titleDirty = renaming && title !== record?.title[locale];
|
|
3298
3417
|
const notifyDirty = useRef(onDirtyChange);
|
|
3299
3418
|
notifyDirty.current = onDirtyChange;
|
|
@@ -3426,6 +3545,7 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
3426
3545
|
const current = ++generation.current;
|
|
3427
3546
|
++fileRequest.current;
|
|
3428
3547
|
++previewRequest.current;
|
|
3548
|
+
setSelectedMount(void 0);
|
|
3429
3549
|
setRecord(void 0);
|
|
3430
3550
|
setOpening(true);
|
|
3431
3551
|
setPath("");
|
|
@@ -3457,7 +3577,8 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
3457
3577
|
}
|
|
3458
3578
|
setRecord(value);
|
|
3459
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 ?? "");
|
|
3460
|
-
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");
|
|
3461
3582
|
}, (failure) => {
|
|
3462
3583
|
if (generation.current === current) fail(failure);
|
|
3463
3584
|
}).finally(() => {
|
|
@@ -3594,11 +3715,11 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
3594
3715
|
};
|
|
3595
3716
|
const changeTab = (next) => {
|
|
3596
3717
|
if (next === tab || busy || candidateBusy || mountActions?.isSaveSubmitted()) return;
|
|
3597
|
-
if (next === "mounts" || tab === "mounts") {
|
|
3718
|
+
if (!readOnly && (next === "mounts" || tab === "mounts")) {
|
|
3598
3719
|
if (!discard()) return;
|
|
3599
3720
|
restore();
|
|
3600
3721
|
}
|
|
3601
|
-
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;
|
|
3602
3723
|
setTab(next);
|
|
3603
3724
|
};
|
|
3604
3725
|
const mutate = async (action) => {
|
|
@@ -3690,7 +3811,7 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
3690
3811
|
});
|
|
3691
3812
|
};
|
|
3692
3813
|
useEffect(() => {
|
|
3693
|
-
if (tab !== "preview" || record
|
|
3814
|
+
if (tab !== "preview" || !record || record.kind === "kit" && !readOnly || busy || candidatePending || sourceDirty) return;
|
|
3694
3815
|
const bundle = previewBundle;
|
|
3695
3816
|
setPreview(void 0);
|
|
3696
3817
|
if (!bundle) return;
|
|
@@ -3727,7 +3848,8 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
3727
3848
|
locale,
|
|
3728
3849
|
busy,
|
|
3729
3850
|
candidatePending,
|
|
3730
|
-
sourceDirty
|
|
3851
|
+
sourceDirty,
|
|
3852
|
+
readOnly
|
|
3731
3853
|
]);
|
|
3732
3854
|
const file = record?.files?.find((entry) => entry.path === path);
|
|
3733
3855
|
const exportDisabled = !record || record.id !== id || busy || candidateBusy || candidateState?.saveUnverified || mountActions?.isSaveSubmitted();
|
|
@@ -3845,71 +3967,67 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
3845
3967
|
description: zh ? "可在原始文件中查看和编辑技能内容。" : "View and edit this skill in Source Files."
|
|
3846
3968
|
});
|
|
3847
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
|
+
})] });
|
|
3848
4028
|
const sourcePane = /* @__PURE__ */ jsxs("div", {
|
|
3849
4029
|
className: "ygd-studio-content-pane",
|
|
3850
|
-
children: [
|
|
3851
|
-
/* @__PURE__ */ jsxs("div", {
|
|
3852
|
-
className: "ygd-studio-doc-toolbar",
|
|
3853
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
3854
|
-
className: "ygd-studio-file-heading",
|
|
3855
|
-
children: /* @__PURE__ */ jsx(FileName, {
|
|
3856
|
-
path,
|
|
3857
|
-
locale
|
|
3858
|
-
})
|
|
3859
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
3860
|
-
className: "ygd-studio-doc-toggle-group",
|
|
3861
|
-
children: readOnly && /\.md$/i.test(path) ? /* @__PURE__ */ jsx("button", {
|
|
3862
|
-
type: "button",
|
|
3863
|
-
className: "ygd-studio-doc-toggle",
|
|
3864
|
-
"aria-pressed": reading,
|
|
3865
|
-
onClick: () => setReading(!reading),
|
|
3866
|
-
children: reading ? zh ? "原文" : "Source" : zh ? "阅读" : "Read"
|
|
3867
|
-
}) : !readOnly && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("button", {
|
|
3868
|
-
type: "button",
|
|
3869
|
-
className: "ygd-studio-doc-toggle",
|
|
3870
|
-
"aria-pressed": fileView === "edit",
|
|
3871
|
-
onClick: () => setFileView("edit"),
|
|
3872
|
-
children: zh ? "编辑" : "Edit"
|
|
3873
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
3874
|
-
type: "button",
|
|
3875
|
-
className: "ygd-studio-doc-toggle",
|
|
3876
|
-
"aria-pressed": fileView === "diff",
|
|
3877
|
-
onClick: () => setFileView("diff"),
|
|
3878
|
-
children: zh ? "对比" : "Diff"
|
|
3879
|
-
})] })
|
|
3880
|
-
})]
|
|
3881
|
-
}),
|
|
3882
|
-
/* @__PURE__ */ jsx("div", {
|
|
3883
|
-
className: "ygd-studio-document-body ygd-studio-source-body",
|
|
3884
|
-
children: file?.editable === false ? /* @__PURE__ */ jsx("p", {
|
|
3885
|
-
role: "status",
|
|
3886
|
-
children: zh ? "此文件不支持文本编辑,复制时会完整保留。" : "This file is not available for text editing. Copies preserve it in full."
|
|
3887
|
-
}) : !loaded ? /* @__PURE__ */ jsx("p", {
|
|
3888
|
-
role: "status",
|
|
3889
|
-
children: error ? zh ? "无法读取此文件。" : "Could not load this file." : path ? zh ? "读取中…" : "Loading…" : zh ? "没有可读取的文件。" : "No readable files."
|
|
3890
|
-
}) : !readOnly && fileView === "diff" ? /* @__PURE__ */ jsx(SourceFileDiff, {
|
|
3891
|
-
path,
|
|
3892
|
-
before: fileChange?.before ?? saved,
|
|
3893
|
-
after: fileChange && !Object.hasOwn(drafts, path) ? fileChange.after : content
|
|
3894
|
-
}) : readOnly && reading && /\.md$/i.test(path) ? /* @__PURE__ */ jsx("div", { children: renderStudioDocument(content, { locale }) }) : /* @__PURE__ */ jsx("textarea", {
|
|
3895
|
-
ref: sourceEditor,
|
|
3896
|
-
"aria-label": path || "Source file",
|
|
3897
|
-
spellCheck: false,
|
|
3898
|
-
value: content,
|
|
3899
|
-
readOnly: readOnly || sourceLocked,
|
|
3900
|
-
onChange: (event) => editSource(event.target.value),
|
|
3901
|
-
className: "ygd-studio-source-input"
|
|
3902
|
-
})
|
|
3903
|
-
}),
|
|
3904
|
-
/* @__PURE__ */ jsxs("footer", {
|
|
3905
|
-
className: "ygd-studio-doc-footer",
|
|
3906
|
-
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: [
|
|
3907
|
-
loaded ? new TextEncoder().encode(content).length : fileChange ? new TextEncoder().encode(fileChange.after ?? "").length : file?.bytes ?? 0,
|
|
3908
|
-
" ",
|
|
3909
|
-
zh ? "字节" : "bytes"
|
|
3910
|
-
] })]
|
|
3911
|
-
})
|
|
3912
|
-
]
|
|
4030
|
+
children: [sourceToolbar, sourceDocument]
|
|
3913
4031
|
});
|
|
3914
4032
|
const mountGeneration = generation.current;
|
|
3915
4033
|
return /* @__PURE__ */ jsxs(embedded ? "section" : "main", {
|
|
@@ -4016,7 +4134,10 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
4016
4134
|
className: "ygd-studio-btn-primary",
|
|
4017
4135
|
disabled: busy || candidatePending,
|
|
4018
4136
|
onClick: () => {
|
|
4019
|
-
if (!busy && !candidatePending)
|
|
4137
|
+
if (!busy && !candidatePending) {
|
|
4138
|
+
if (record.kind === "kit" && tab === "preview") setTab("files");
|
|
4139
|
+
onEdit();
|
|
4140
|
+
}
|
|
4020
4141
|
},
|
|
4021
4142
|
children: zh ? "编辑" : "Edit"
|
|
4022
4143
|
}),
|
|
@@ -4105,7 +4226,7 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
4105
4226
|
intent: authoringIntent,
|
|
4106
4227
|
proposalReplacement
|
|
4107
4228
|
}),
|
|
4108
|
-
record &&
|
|
4229
|
+
record && /* @__PURE__ */ jsxs("div", {
|
|
4109
4230
|
className: "ygd-studio-workplane-bar",
|
|
4110
4231
|
"aria-label": record.kind === "kit" ? "Kit content" : "Bundle content",
|
|
4111
4232
|
children: [/* @__PURE__ */ jsx("button", {
|
|
@@ -4118,10 +4239,10 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
4118
4239
|
}), record.kind === "kit" ? /* @__PURE__ */ jsx("button", {
|
|
4119
4240
|
type: "button",
|
|
4120
4241
|
className: "ygd-studio-workplane-tab",
|
|
4121
|
-
"aria-pressed": tab === "mounts",
|
|
4122
|
-
disabled: sourceLocked || candidatePending || !client.updateMounts,
|
|
4242
|
+
"aria-pressed": tab === "mounts" || tab === "preview",
|
|
4243
|
+
disabled: busy || candidateBusy || !readOnly && (sourceLocked || candidatePending || !client.updateMounts),
|
|
4123
4244
|
onClick: () => changeTab("mounts"),
|
|
4124
|
-
children: zh ? "挂载管理" : "Mount management"
|
|
4245
|
+
children: readOnly ? zh ? "挂载内容" : "Mounted Bundles" : zh ? "挂载管理" : "Mount management"
|
|
4125
4246
|
}) : /* @__PURE__ */ jsx("button", {
|
|
4126
4247
|
type: "button",
|
|
4127
4248
|
className: "ygd-studio-workplane-tab",
|
|
@@ -4150,8 +4271,12 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
4150
4271
|
feedbackId: `source:${error}`,
|
|
4151
4272
|
tone: "error",
|
|
4152
4273
|
locale,
|
|
4153
|
-
title: zh ? "操作未完成" : "The operation could not be completed",
|
|
4154
|
-
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
|
|
4155
4280
|
})]
|
|
4156
4281
|
}),
|
|
4157
4282
|
tab === "mounts" && !readOnly && record?.kind === "kit" && /* @__PURE__ */ jsx(MountEditor, {
|
|
@@ -4168,6 +4293,17 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
4168
4293
|
onChanged(value);
|
|
4169
4294
|
}
|
|
4170
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
|
+
}),
|
|
4171
4307
|
tab === "files" && (record?.id === id ? /* @__PURE__ */ jsxs("div", {
|
|
4172
4308
|
className: "ygd-studio-workspace-body ygd-studio-files-layout",
|
|
4173
4309
|
children: [
|
|
@@ -4257,30 +4393,75 @@ function InstanceWorkbench({ client, id, locale, onBack, onChanged, onExport, re
|
|
|
4257
4393
|
})
|
|
4258
4394
|
]
|
|
4259
4395
|
}) : opening ? /* @__PURE__ */ jsx(LoadingIndicator, { label: zh ? "正在打开内容" : "Opening content" }) : null),
|
|
4260
|
-
tab === "preview" && record
|
|
4396
|
+
tab === "preview" && record && (record.kind === "bundle" || readOnly && record.kind === "kit" && previewBundle) && /* @__PURE__ */ jsxs("section", {
|
|
4261
4397
|
className: "ygd-studio-panel-split",
|
|
4262
|
-
children: [
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
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
|
+
})
|
|
4269
4463
|
})
|
|
4270
|
-
|
|
4271
|
-
className: "ygd-studio-live-pane",
|
|
4272
|
-
"aria-label": zh ? "实时面板预览" : "Live Panel preview",
|
|
4273
|
-
children: [/* @__PURE__ */ jsxs("header", { children: [/* @__PURE__ */ jsx("strong", { children: zh ? "面板预览" : "Panel Preview" }), /* @__PURE__ */ jsx("span", { children: zh ? "随源码更新 · 样例数据" : "Live source · sample data" })] }), /* @__PURE__ */ jsx("div", {
|
|
4274
|
-
className: "ygd-studio-live-pane-body",
|
|
4275
|
-
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, () => {}, {
|
|
4276
|
-
readOnly: true,
|
|
4277
|
-
toolbarTarget: null
|
|
4278
|
-
}) : 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, () => {}, {
|
|
4279
|
-
readOnly,
|
|
4280
|
-
toolbarTarget: null
|
|
4281
|
-
}) : !previewBusy && previewState(preview?.diagnostics ?? [], noPanelRequired)] })
|
|
4282
|
-
})]
|
|
4283
|
-
})]
|
|
4464
|
+
]
|
|
4284
4465
|
})
|
|
4285
4466
|
]
|
|
4286
4467
|
});
|
|
@@ -5187,67 +5368,82 @@ function InstalledPreview({ authoring, renderPreview: render, client, kit, bundl
|
|
|
5187
5368
|
]);
|
|
5188
5369
|
return /* @__PURE__ */ jsxs("section", {
|
|
5189
5370
|
className: "ygd-studio-panel-split",
|
|
5190
|
-
children: [
|
|
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
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
className: "ygd-studio-live-pane-body",
|
|
5220
|
-
children: [
|
|
5221
|
-
!previewInstalled && /* @__PURE__ */ jsx(StudioEmptyState, { title: locale === "zh" ? "此处暂不支持面板预览" : "Panel preview is unavailable here" }),
|
|
5222
|
-
busy && /* @__PURE__ */ jsx(LoadingIndicator, { label: locale === "zh" ? "正在加载预览" : "Loading preview" }),
|
|
5223
|
-
error && /* @__PURE__ */ jsx(StudioFeedback, {
|
|
5224
|
-
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}`,
|
|
5225
5400
|
tone: "error",
|
|
5226
5401
|
locale,
|
|
5227
|
-
title: locale === "zh" ? "
|
|
5228
|
-
message:
|
|
5402
|
+
title: locale === "zh" ? "无法读取面板定义" : "Could not read Panel source",
|
|
5403
|
+
message: sourceError,
|
|
5229
5404
|
actions: [{
|
|
5230
5405
|
label: locale === "zh" ? "重试" : "Retry",
|
|
5231
5406
|
onClick: () => setRetry((value) => value + 1)
|
|
5232
5407
|
}]
|
|
5233
|
-
}),
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
title: locale === "zh" ? "
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
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
|
+
})
|
|
5249
5445
|
})
|
|
5250
|
-
|
|
5446
|
+
]
|
|
5251
5447
|
});
|
|
5252
5448
|
}
|
|
5253
5449
|
/** Read-only Studio surface: one complete page with global nav, sidebar, and workspace main. */
|
|
@@ -6636,7 +6832,13 @@ function StudioWorkspace({ client, controller: supplied, authoring, renderPrevie
|
|
|
6636
6832
|
editInstalled("kit", kit);
|
|
6637
6833
|
} : void 0,
|
|
6638
6834
|
client: instances,
|
|
6639
|
-
bundle:
|
|
6835
|
+
bundle: {
|
|
6836
|
+
...mountBundle,
|
|
6837
|
+
...localMountRecord ? {
|
|
6838
|
+
instanceId: localMountRecord.id,
|
|
6839
|
+
current: localMountRecord.current
|
|
6840
|
+
} : {}
|
|
6841
|
+
},
|
|
6640
6842
|
installed: localMountRecord ? [] : snapshot.view?.bundles.find((bundle) => bundle.name === mountBundle.name && bundle.version === mountBundle.version)?.usedBy ?? [],
|
|
6641
6843
|
locale
|
|
6642
6844
|
})
|