sculpted 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{runtime-C911j-aR.d.mts → runtime-C1gUOAc9.d.mts} +2 -1
- package/dist/runtime.d.mts +1 -1
- package/dist/runtime.mjs +5 -1
- package/dist/ui.d.mts +1 -1
- package/dist/ui.mjs +147 -10
- package/package.json +1 -1
|
@@ -45,7 +45,8 @@ declare class SculptedRuntime {
|
|
|
45
45
|
requestTokenConfigEdit(request: TokenConfigEditRequest, write: boolean): Promise<TokenConfigEditResponse>;
|
|
46
46
|
openSourceLocation(request: OpenSourceLocationRequest): Promise<OpenSourceLocationResponse>;
|
|
47
47
|
selectElement(element: Element): Promise<SelectedElementInfo>;
|
|
48
|
-
|
|
48
|
+
inspectElementEvidence(element: Element): SelectedElementInfo['evidence'];
|
|
49
|
+
startInspecting(onSelect?: (info: SelectedElementInfo, element: Element) => void, onStop?: () => void, onInspect?: (element: Element, evidence: SelectedElementInfo['evidence']) => void): () => void;
|
|
49
50
|
stopInspecting(): void;
|
|
50
51
|
highlightElement(element: Element): void;
|
|
51
52
|
highlightElements(elements: readonly Element[]): void;
|
package/dist/runtime.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as installSculptedRuntime, n as RuntimeInspectorOptions, r as SculptedRuntime, t as RuntimeEnvironment } from "./runtime-
|
|
1
|
+
import { i as installSculptedRuntime, n as RuntimeInspectorOptions, r as SculptedRuntime, t as RuntimeEnvironment } from "./runtime-C1gUOAc9.mjs";
|
|
2
2
|
export { RuntimeEnvironment, RuntimeInspectorOptions, SculptedRuntime, installSculptedRuntime };
|
package/dist/runtime.mjs
CHANGED
|
@@ -262,7 +262,10 @@ var SculptedRuntime = class {
|
|
|
262
262
|
message: target?.reason ?? "Selected Panda source target is not editable."
|
|
263
263
|
};
|
|
264
264
|
}
|
|
265
|
-
|
|
265
|
+
inspectElementEvidence(element) {
|
|
266
|
+
return this.#elementEvidence(element);
|
|
267
|
+
}
|
|
268
|
+
startInspecting(onSelect, onStop, onInspect) {
|
|
266
269
|
this.stopInspecting();
|
|
267
270
|
const { window } = this.#environment;
|
|
268
271
|
const onPointerMove = (event) => {
|
|
@@ -279,6 +282,7 @@ var SculptedRuntime = class {
|
|
|
279
282
|
event.preventDefault();
|
|
280
283
|
event.stopPropagation();
|
|
281
284
|
this.stopInspecting();
|
|
285
|
+
onInspect?.(element, this.#elementEvidence(element));
|
|
282
286
|
this.selectElement(element).then((info) => {
|
|
283
287
|
onSelect?.(info, element);
|
|
284
288
|
});
|
package/dist/ui.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { F as RuntimePropertyContext, L as SelectedElementInfo, N as RuntimeCssDeclaration, j as RuntimeComponentLayer } from "./types-CdByW0ji.mjs";
|
|
2
|
-
import { r as SculptedRuntime } from "./runtime-
|
|
2
|
+
import { r as SculptedRuntime } from "./runtime-C1gUOAc9.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/ui/inspectorPanel.d.ts
|
|
5
5
|
type ReadonlyInspectorPanelOptions = {
|
package/dist/ui.mjs
CHANGED
|
@@ -1011,6 +1011,23 @@ const RefreshCw = createLucideIcon("refresh-cw", [
|
|
|
1011
1011
|
}]
|
|
1012
1012
|
]);
|
|
1013
1013
|
//#endregion
|
|
1014
|
+
//#region node_modules/.pnpm/lucide-preact@1.16.0_preact@10.29.2/node_modules/lucide-preact/dist/esm/icons/settings.mjs
|
|
1015
|
+
/**
|
|
1016
|
+
* @license lucide-preact v1.16.0 - ISC
|
|
1017
|
+
*
|
|
1018
|
+
* This source code is licensed under the ISC license.
|
|
1019
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
1020
|
+
*/
|
|
1021
|
+
const Settings = createLucideIcon("settings", [["path", {
|
|
1022
|
+
d: "M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",
|
|
1023
|
+
key: "1i5ecw"
|
|
1024
|
+
}], ["circle", {
|
|
1025
|
+
cx: "12",
|
|
1026
|
+
cy: "12",
|
|
1027
|
+
r: "3",
|
|
1028
|
+
key: "1v7zrd"
|
|
1029
|
+
}]]);
|
|
1030
|
+
//#endregion
|
|
1014
1031
|
//#region node_modules/.pnpm/lucide-preact@1.16.0_preact@10.29.2/node_modules/lucide-preact/dist/esm/icons/square-dashed-mouse-pointer.mjs
|
|
1015
1032
|
/**
|
|
1016
1033
|
* @license lucide-preact v1.16.0 - ISC
|
|
@@ -7461,6 +7478,9 @@ const INSPECTOR_DIALOG_PORTAL_ROOT = "data-sculpted-dialog-root";
|
|
|
7461
7478
|
const INSPECTOR_MENU_PORTAL_ROOT = "data-sculpted-menu-root";
|
|
7462
7479
|
const INLINE_SOURCE_PREVIEW_PATH = ["__inlineSource"];
|
|
7463
7480
|
const STYLE_MODULE_ACTION_PREVIEW_PATH = ["__styleModuleAction"];
|
|
7481
|
+
const COPY_ELEMENT_PATH_AFTER_INSPECT_STORAGE_KEY = "sculpted.copyElementPathAfterInspect";
|
|
7482
|
+
const PANEL_DOCKED_STORAGE_KEY = "sculpted.panelDocked";
|
|
7483
|
+
const PANEL_SIDE_STORAGE_KEY = "sculpted.panelSide";
|
|
7464
7484
|
function installReadonlyInspectorPanel(runtime, options = {}) {
|
|
7465
7485
|
let panel = null;
|
|
7466
7486
|
let previousBodyMarginLeft;
|
|
@@ -7575,14 +7595,41 @@ function applyInspectorPanelFrame(panel, state) {
|
|
|
7575
7595
|
panel.style.borderRadius = "8px";
|
|
7576
7596
|
panel.style.boxShadow = "0 18px 54px rgba(15, 23, 42, 0.18)";
|
|
7577
7597
|
}
|
|
7598
|
+
function loadBooleanPreference(storageKey, defaultValue) {
|
|
7599
|
+
try {
|
|
7600
|
+
const stored = window.localStorage.getItem(storageKey);
|
|
7601
|
+
if (stored === "true") return true;
|
|
7602
|
+
if (stored === "false") return false;
|
|
7603
|
+
} catch {}
|
|
7604
|
+
return defaultValue;
|
|
7605
|
+
}
|
|
7606
|
+
function saveBooleanPreference(storageKey, value) {
|
|
7607
|
+
try {
|
|
7608
|
+
window.localStorage.setItem(storageKey, value ? "true" : "false");
|
|
7609
|
+
} catch {}
|
|
7610
|
+
}
|
|
7611
|
+
function loadPanelSidePreference(defaultValue) {
|
|
7612
|
+
try {
|
|
7613
|
+
const stored = window.localStorage.getItem(PANEL_SIDE_STORAGE_KEY);
|
|
7614
|
+
if (stored === "left" || stored === "right") return stored;
|
|
7615
|
+
} catch {}
|
|
7616
|
+
return defaultValue;
|
|
7617
|
+
}
|
|
7618
|
+
function savePanelSidePreference(value) {
|
|
7619
|
+
try {
|
|
7620
|
+
window.localStorage.setItem(PANEL_SIDE_STORAGE_KEY, value);
|
|
7621
|
+
} catch {}
|
|
7622
|
+
}
|
|
7578
7623
|
function InspectorPanel(props) {
|
|
7579
7624
|
const { runtime, title, onFrameChange } = props;
|
|
7580
7625
|
const selected = useSignal();
|
|
7581
7626
|
const visible = useSignal(false);
|
|
7582
|
-
const docked = useSignal(false);
|
|
7583
|
-
const side = useSignal("right");
|
|
7627
|
+
const docked = useSignal(loadBooleanPreference(PANEL_DOCKED_STORAGE_KEY, false));
|
|
7628
|
+
const side = useSignal(loadPanelSidePreference("right"));
|
|
7584
7629
|
const isInspecting = useSignal(false);
|
|
7630
|
+
const settingsOpen = useSignal(false);
|
|
7585
7631
|
const previewEnabled = useSignal(true);
|
|
7632
|
+
const copyElementPathAfterInspect = useSignal(loadBooleanPreference(COPY_ELEMENT_PATH_AFTER_INSPECT_STORAGE_KEY, false));
|
|
7586
7633
|
const forcedPreviewStates = useSignal(/* @__PURE__ */ new Set());
|
|
7587
7634
|
const pendingPreviewChanges = useSignal(/* @__PURE__ */ new Map());
|
|
7588
7635
|
const expandedShorthandInputs = useSignal(/* @__PURE__ */ new Set());
|
|
@@ -7593,6 +7640,7 @@ function InspectorPanel(props) {
|
|
|
7593
7640
|
const elementStyleModule = useSignal({ status: "idle" });
|
|
7594
7641
|
const showingStyleModulePage = useComputed(() => styleModulePanel.value.status !== "idle");
|
|
7595
7642
|
const panelHeaderTitle = useComputed(() => {
|
|
7643
|
+
if (settingsOpen.value) return "Settings";
|
|
7596
7644
|
return styleModulePanel.value.status === "idle" ? title : "Style List";
|
|
7597
7645
|
});
|
|
7598
7646
|
const editorMetadata = useSignal();
|
|
@@ -7923,6 +7971,11 @@ function InspectorPanel(props) {
|
|
|
7923
7971
|
isInspecting.value = false;
|
|
7924
7972
|
clearInspectCursor();
|
|
7925
7973
|
};
|
|
7974
|
+
const copyInspectedElementPath = (evidence) => {
|
|
7975
|
+
if (!copyElementPathAfterInspect.value) return;
|
|
7976
|
+
const identity = inspectedElementIdentityFromLayers(evidence?.componentLayers ?? []);
|
|
7977
|
+
if (identity) navigator.clipboard?.writeText(identity).catch(() => {});
|
|
7978
|
+
};
|
|
7926
7979
|
const isPanelEditableFocused = () => {
|
|
7927
7980
|
const root = shell.current?.getRootNode();
|
|
7928
7981
|
const active = root && isShadowRoot(root) ? root.activeElement : document.activeElement;
|
|
@@ -7971,6 +8024,7 @@ function InspectorPanel(props) {
|
|
|
7971
8024
|
document.getSelection()?.removeAllRanges();
|
|
7972
8025
|
stopActiveInspecting();
|
|
7973
8026
|
clearModifierPreview();
|
|
8027
|
+
copyInspectedElementPath(typeof runtime.inspectElementEvidence === "function" ? runtime.inspectElementEvidence(element) : void 0);
|
|
7974
8028
|
runtime.selectElement(element).then((info) => {
|
|
7975
8029
|
selectedElement.current = element;
|
|
7976
8030
|
selectedElementAutofocusRevision.value += 1;
|
|
@@ -8015,9 +8069,12 @@ function InspectorPanel(props) {
|
|
|
8015
8069
|
selectedElement.current = element;
|
|
8016
8070
|
selectedElementAutofocusRevision.value += 1;
|
|
8017
8071
|
selected.value = info;
|
|
8072
|
+
settingsOpen.value = false;
|
|
8018
8073
|
applyPreviewChanges(pendingPreviewChanges.value, previewEnabled.value);
|
|
8019
8074
|
setPanelVisible(true);
|
|
8020
|
-
}, onStopInspecting)
|
|
8075
|
+
}, onStopInspecting, (_element, evidence) => {
|
|
8076
|
+
copyInspectedElementPath(evidence);
|
|
8077
|
+
});
|
|
8021
8078
|
isInspecting.value = true;
|
|
8022
8079
|
setInspectCursor();
|
|
8023
8080
|
};
|
|
@@ -8050,6 +8107,7 @@ function InspectorPanel(props) {
|
|
|
8050
8107
|
};
|
|
8051
8108
|
const toggleDocked = () => {
|
|
8052
8109
|
docked.value = !docked.value;
|
|
8110
|
+
saveBooleanPreference(PANEL_DOCKED_STORAGE_KEY, docked.value);
|
|
8053
8111
|
onFrameChange({
|
|
8054
8112
|
visible: visible.value,
|
|
8055
8113
|
docked: docked.value,
|
|
@@ -8059,12 +8117,20 @@ function InspectorPanel(props) {
|
|
|
8059
8117
|
const snapPanelSide = (nextSide) => {
|
|
8060
8118
|
if (side.value === nextSide) return;
|
|
8061
8119
|
side.value = nextSide;
|
|
8120
|
+
savePanelSidePreference(nextSide);
|
|
8062
8121
|
onFrameChange({
|
|
8063
8122
|
visible: visible.value,
|
|
8064
8123
|
docked: docked.value,
|
|
8065
8124
|
side: nextSide
|
|
8066
8125
|
});
|
|
8067
8126
|
};
|
|
8127
|
+
const openSettings = () => {
|
|
8128
|
+
settingsOpen.value = true;
|
|
8129
|
+
};
|
|
8130
|
+
const updateCopyElementPathAfterInspect = (enabled) => {
|
|
8131
|
+
copyElementPathAfterInspect.value = enabled;
|
|
8132
|
+
saveBooleanPreference(COPY_ELEMENT_PATH_AFTER_INSPECT_STORAGE_KEY, enabled);
|
|
8133
|
+
};
|
|
8068
8134
|
const togglePreview = (enabled) => {
|
|
8069
8135
|
previewEnabled.value = enabled;
|
|
8070
8136
|
applyPreviewChanges(pendingPreviewChanges.value, enabled);
|
|
@@ -8469,8 +8535,10 @@ function InspectorPanel(props) {
|
|
|
8469
8535
|
title: panelHeaderTitle,
|
|
8470
8536
|
isInspecting,
|
|
8471
8537
|
docked,
|
|
8472
|
-
showInspect: !showingStyleModulePage.value,
|
|
8473
|
-
onBack:
|
|
8538
|
+
showInspect: !showingStyleModulePage.value && !settingsOpen.value,
|
|
8539
|
+
onBack: settingsOpen.value ? () => {
|
|
8540
|
+
settingsOpen.value = false;
|
|
8541
|
+
} : showingStyleModulePage.value ? () => {
|
|
8474
8542
|
styleModulePanel.value = { status: "idle" };
|
|
8475
8543
|
} : void 0,
|
|
8476
8544
|
onInspect: toggleInspecting,
|
|
@@ -8481,6 +8549,7 @@ function InspectorPanel(props) {
|
|
|
8481
8549
|
disabled: saving,
|
|
8482
8550
|
onUndoPreview: undoPreviewChange,
|
|
8483
8551
|
onRedoPreview: redoPreviewChange,
|
|
8552
|
+
onSettings: openSettings,
|
|
8484
8553
|
onToggleDocked: toggleDocked,
|
|
8485
8554
|
onToggleSide: () => {
|
|
8486
8555
|
snapPanelSide(side.value === "right" ? "left" : "right");
|
|
@@ -8494,11 +8563,15 @@ function InspectorPanel(props) {
|
|
|
8494
8563
|
flex: "1 1 auto",
|
|
8495
8564
|
padding: "12px",
|
|
8496
8565
|
display: "grid",
|
|
8566
|
+
alignContent: "start",
|
|
8497
8567
|
gap: "12px",
|
|
8498
8568
|
overflow: "auto",
|
|
8499
8569
|
minHeight: 0
|
|
8500
8570
|
},
|
|
8501
|
-
children: [/* @__PURE__ */ u(SaveStatusSection, { saveFlow }),
|
|
8571
|
+
children: [/* @__PURE__ */ u(SaveStatusSection, { saveFlow }), settingsOpen.value ? /* @__PURE__ */ u(SettingsSection, {
|
|
8572
|
+
copyElementPathAfterInspect,
|
|
8573
|
+
onCopyElementPathAfterInspectChange: updateCopyElementPathAfterInspect
|
|
8574
|
+
}) : showingStyleModulePage.value ? /* @__PURE__ */ u(StyleModuleSection, {
|
|
8502
8575
|
state: styleModulePanel,
|
|
8503
8576
|
pendingChanges: pendingPreviewChanges,
|
|
8504
8577
|
preview,
|
|
@@ -9015,6 +9088,22 @@ function PanelHeader(props) {
|
|
|
9015
9088
|
children: "Clear"
|
|
9016
9089
|
})]
|
|
9017
9090
|
})
|
|
9091
|
+
}),
|
|
9092
|
+
/* @__PURE__ */ u(ShadowMenuItem, {
|
|
9093
|
+
class: "sculpted-menu-item",
|
|
9094
|
+
disabled: props.disabled.value,
|
|
9095
|
+
onSelect: props.onSettings,
|
|
9096
|
+
children: /* @__PURE__ */ u("span", {
|
|
9097
|
+
"data-menu-action": "settings",
|
|
9098
|
+
style: { display: "contents" },
|
|
9099
|
+
children: [/* @__PURE__ */ u(Settings, {
|
|
9100
|
+
size: 15,
|
|
9101
|
+
"aria-hidden": "true"
|
|
9102
|
+
}), /* @__PURE__ */ u("span", {
|
|
9103
|
+
style: { font: "inherit" },
|
|
9104
|
+
children: "Settings"
|
|
9105
|
+
})]
|
|
9106
|
+
})
|
|
9018
9107
|
})
|
|
9019
9108
|
]
|
|
9020
9109
|
})]
|
|
@@ -9064,6 +9153,39 @@ function SaveStatusSection(props) {
|
|
|
9064
9153
|
children: /* @__PURE__ */ u("div", { children: state.message })
|
|
9065
9154
|
});
|
|
9066
9155
|
}
|
|
9156
|
+
function SettingsSection(props) {
|
|
9157
|
+
return /* @__PURE__ */ u("section", {
|
|
9158
|
+
"data-settings-section": "true",
|
|
9159
|
+
style: {
|
|
9160
|
+
display: "grid",
|
|
9161
|
+
gap: "10px"
|
|
9162
|
+
},
|
|
9163
|
+
children: /* @__PURE__ */ u("label", {
|
|
9164
|
+
style: {
|
|
9165
|
+
display: "flex",
|
|
9166
|
+
alignItems: "center",
|
|
9167
|
+
justifyContent: "space-between",
|
|
9168
|
+
gap: "12px",
|
|
9169
|
+
border: "1px solid #d6dde8",
|
|
9170
|
+
borderRadius: "6px",
|
|
9171
|
+
padding: "10px",
|
|
9172
|
+
cursor: "pointer"
|
|
9173
|
+
},
|
|
9174
|
+
children: [/* @__PURE__ */ u("span", {
|
|
9175
|
+
style: { fontWeight: 700 },
|
|
9176
|
+
children: "Copy element path after inspect"
|
|
9177
|
+
}), /* @__PURE__ */ u("input", {
|
|
9178
|
+
type: "checkbox",
|
|
9179
|
+
"data-setting": "copy-element-path-after-inspect",
|
|
9180
|
+
checked: props.copyElementPathAfterInspect.value,
|
|
9181
|
+
onChange: (event) => {
|
|
9182
|
+
props.onCopyElementPathAfterInspectChange(event.currentTarget.checked);
|
|
9183
|
+
},
|
|
9184
|
+
style: { margin: 0 }
|
|
9185
|
+
})]
|
|
9186
|
+
})
|
|
9187
|
+
});
|
|
9188
|
+
}
|
|
9067
9189
|
function StyleModuleSection(props) {
|
|
9068
9190
|
const { state, pendingChanges, preview, forcedPreviewStates, expandedShorthandInputs, shorthandFocusRequest, colorTokenOptions, fontTokenOptions, tokenSources, propertyOptions, saving, addedInputActivationRequest, onPreviewInput, onCreateColorToken, onAddedInputActivationHandled, onAddProperty, onRemoveProperty, onFocusRestoreButton, onFocusPreviewControl, onRestoreProperty, onHighlightSourceTarget, onClearHighlight, onOpenSource, onInputMenuOpenChange, onToggleShorthandInput, onExpandShorthandInput, onCollapseShorthandInput, onRequestShorthandFocus, onShorthandFocusRequestHandled, onAddSource } = props;
|
|
9069
9191
|
if (state.value.status === "idle") return null;
|
|
@@ -10977,11 +11099,19 @@ function ComponentLayersSection(props) {
|
|
|
10977
11099
|
})] });
|
|
10978
11100
|
}
|
|
10979
11101
|
function componentLayerElementIdentity(view, layerIndex, elementIndex, jsxSource) {
|
|
10980
|
-
|
|
11102
|
+
return componentLayerElementIdentityFromLayers(view.componentLayers, layerIndex, elementIndex, jsxSource);
|
|
11103
|
+
}
|
|
11104
|
+
function componentLayerElementIdentityFromLayers(layers, layerIndex, elementIndex, jsxSource) {
|
|
10981
11105
|
const parentComponents = layers.slice(layerIndex).toReversed().map((layer) => layer.component);
|
|
10982
11106
|
const elementPath = layers[layerIndex]?.elements.slice(elementIndex).toReversed().map((element) => element.tagName);
|
|
10983
11107
|
return `I want to edit the following JSX element:\n ${[...parentComponents, ...elementPath ?? []].join(" → ")}${sourceLocationAvailable(jsxSource) ? `\n (found at ${jsxSource})` : ""}\n\n\n`;
|
|
10984
11108
|
}
|
|
11109
|
+
function inspectedElementIdentityFromLayers(layers) {
|
|
11110
|
+
for (const [layerIndex, layer] of layers.entries()) {
|
|
11111
|
+
const elementIndex = layer.elements.findIndex((element) => element.inspected === true);
|
|
11112
|
+
if (elementIndex !== -1) return componentLayerElementIdentityFromLayers(layers, layerIndex, elementIndex, layer.elements[elementIndex]?.source);
|
|
11113
|
+
}
|
|
11114
|
+
}
|
|
10985
11115
|
function componentLayerSource(layer) {
|
|
10986
11116
|
return layer.elements.find((element) => sourceLocationAvailable(element.source))?.source;
|
|
10987
11117
|
}
|
|
@@ -11031,12 +11161,19 @@ function ComputedRowsSection(props) {
|
|
|
11031
11161
|
gridTemplateColumns: "120px 1fr",
|
|
11032
11162
|
gap: "8px",
|
|
11033
11163
|
marginTop: "4px",
|
|
11034
|
-
color: "#526070"
|
|
11164
|
+
color: "#526070",
|
|
11165
|
+
userSelect: "text"
|
|
11035
11166
|
},
|
|
11036
|
-
children: [/* @__PURE__ */ u("code", {
|
|
11167
|
+
children: [/* @__PURE__ */ u("code", {
|
|
11168
|
+
"data-computed-css-property": "true",
|
|
11169
|
+
style: { userSelect: "text" },
|
|
11170
|
+
children: row.property
|
|
11171
|
+
}), /* @__PURE__ */ u("code", {
|
|
11172
|
+
"data-computed-css-value": "true",
|
|
11037
11173
|
style: {
|
|
11038
11174
|
whiteSpace: "normal",
|
|
11039
|
-
wordBreak: "break-word"
|
|
11175
|
+
wordBreak: "break-word",
|
|
11176
|
+
userSelect: "text"
|
|
11040
11177
|
},
|
|
11041
11178
|
children: row.value
|
|
11042
11179
|
})]
|