sculpted 0.3.2 → 0.3.3

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 CHANGED
@@ -30,8 +30,10 @@ Sculpted does not edit:
30
30
  - adding, deleting, or renaming style properties;
31
31
  - converting computed CSS values back to design tokens;
32
32
  - broad property-specific editors;
33
- - inline source creation for TSRX;
34
- - cross-file rollback if one file write succeeds and a later file write fails.
33
+ - inline source creation for TSRX.
34
+
35
+ Batched saves are prepared before writing. When a multi-file batch write fails after an earlier file
36
+ was written, Sculpted attempts to restore the earlier file before reporting the save failure.
35
37
 
36
38
  ## Install
37
39
 
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { $ as StyleModuleEditRequest, A as RuntimeAttribute, B as SourcePosition, C as OpenSourceLocationRequest, D as PreviewStyleCondition, E as PandaStyleObject, F as RuntimePropertyContext, G as StyleEdit, H as SourceTarget, I as RuntimeStyleEvidence, J as StyleEditError, K as StyleEditBatchRequest, L as SelectedElementInfo, M as RuntimeComponentLayerElement, N as RuntimeCssDeclaration, O as PreviewStyleRule, P as RuntimeElementBounds, Q as StyleEditResponse, R as SelectedElementState, S as OpenSourceLocationErrorCode, T as PandaCssSourceTarget, U as SourceTargetBase, V as SourceRange, W as SourceTargetKind, X as StyleEditOptions, Y as StyleEditErrorCode, Z as StyleEditRequest, _ as InspectorManifest, a as EditorColorTokenMetadata, at as TokenConfigEditResponse, b as JsonValue, c as EditorMetadataUnavailableReason, d as EditorPropertyMetadata, et as StyleModuleSourceAttachRequest, f as EditorTokenSourceSection, g as InspectorEditorMetadata, h as InlineCssSourceCreateRequest, i as DynamicSourceTarget, it as TokenConfigEditRequest, j as RuntimeComponentLayer, k as PreviewStyleSheet, l as EditorMetadataUpdateEvent, m as ExternalSourceTarget, n as ComponentStyleModuleSource, nt as StyleModuleSourceDetachRequest, o as EditorFontTokenMetadata, ot as UnsupportedReason, p as EditorTokenSourceTarget, q as StyleEditBatchResponse, r as Confidence, rt as StyleValueSource, s as EditorMetadataSection, st as UnsupportedSourceTarget, t as ComponentStyleModuleResponse, tt as StyleModuleSourceCreateRequest, u as EditorPropertyCategory, v as InspectorManifestEntry, w as OpenSourceLocationResponse, x as ManifestUpdateEvent, y as JsonPrimitive, z as SourceLocation } from "./types-CdByW0ji.mjs";
2
- import { a as SourceAstKind, c as SourceSyntaxAdapter, d as parsePandaSource, f as parseWithSourceParserAdapter, g as typescriptPandaAstAdapter, h as tsxSourceSyntaxAdapter, i as ParsedPandaSource, l as SourceSyntaxOption, m as tsxSourceParserAdapter, n as PandaSourceAstAdapter, o as SourceParseResult, p as resolveSourceParserAdapter, r as ParseSourceSyntaxOptions, s as SourceParserAdapter, t as EstreeNode, u as createEstreePandaAstAdapter } from "./sourceSyntax-U2iybN9L.mjs";
1
+ import { $ as StyleEditResponse, A as RuntimeAttribute, B as SourceLocation, C as OpenSourceLocationRequest, D as PreviewStyleCondition, E as PandaStyleObject, F as RuntimeInheritedStyleSource, G as SourceTargetKind, H as SourceRange, I as RuntimePropertyContext, J as StyleEditBatchResponse, K as StyleEdit, L as RuntimeStyleEvidence, M as RuntimeComponentLayerElement, N as RuntimeCssDeclaration, O as PreviewStyleRule, P as RuntimeElementBounds, Q as StyleEditRequest, R as SelectedElementInfo, S as OpenSourceLocationErrorCode, T as PandaCssSourceTarget, U as SourceTarget, V as SourcePosition, W as SourceTargetBase, X as StyleEditErrorCode, Y as StyleEditError, Z as StyleEditOptions, _ as InspectorManifest, a as EditorColorTokenMetadata, at as TokenConfigEditRequest, b as JsonValue, c as EditorMetadataUnavailableReason, ct as UnsupportedSourceTarget, d as EditorPropertyMetadata, et as StyleModuleEditRequest, f as EditorTokenSourceSection, g as InspectorEditorMetadata, h as InlineCssSourceCreateRequest, i as DynamicSourceTarget, it as StyleValueSource, j as RuntimeComponentLayer, k as PreviewStyleSheet, l as EditorMetadataUpdateEvent, m as ExternalSourceTarget, n as ComponentStyleModuleSource, nt as StyleModuleSourceCreateRequest, o as EditorFontTokenMetadata, ot as TokenConfigEditResponse, p as EditorTokenSourceTarget, q as StyleEditBatchRequest, r as Confidence, rt as StyleModuleSourceDetachRequest, s as EditorMetadataSection, st as UnsupportedReason, t as ComponentStyleModuleResponse, tt as StyleModuleSourceAttachRequest, u as EditorPropertyCategory, v as InspectorManifestEntry, w as OpenSourceLocationResponse, x as ManifestUpdateEvent, y as JsonPrimitive, z as SelectedElementState } from "./types-0a4hNfAF.mjs";
2
+ import { a as SourceAstKind, c as SourceSyntaxAdapter, d as parsePandaSource, f as parseWithSourceParserAdapter, g as typescriptPandaAstAdapter, h as tsxSourceSyntaxAdapter, i as ParsedPandaSource, l as SourceSyntaxOption, m as tsxSourceParserAdapter, n as PandaSourceAstAdapter, o as SourceParseResult, p as resolveSourceParserAdapter, r as ParseSourceSyntaxOptions, s as SourceParserAdapter, t as EstreeNode, u as createEstreePandaAstAdapter } from "./sourceSyntax-DKIh-VKA.mjs";
3
3
 
4
4
  //#region src/analyzer/pandaCssAnalyzer.d.ts
5
5
  type AnalyzePandaCssSourceOptions = {
@@ -126,4 +126,4 @@ declare const SCULPTED_EVENTS: {
126
126
  };
127
127
  type SculptedEventName = (typeof SCULPTED_EVENTS)[keyof typeof SCULPTED_EVENTS];
128
128
  //#endregion
129
- export { AnalyzePandaCssSourceOptions, AnalyzePandaCssSourceResult, ComponentStyleModulePaths, ComponentStyleModuleResponse, ComponentStyleModuleSource, Confidence, CreateInlineCssSourcePatchOptions, CreateStaticCssPatchOptions, CreateTokenConfigPatchOptions, DEFAULT_COMPONENT_ATTRIBUTE, DEFAULT_EDITOR_METADATA_ENDPOINT, DEFAULT_EDIT_ID_ATTRIBUTE, DEFAULT_FORCED_STATE_ATTRIBUTE, DEFAULT_JSX_SOURCE_ATTRIBUTE, DEFAULT_MANIFEST_ENDPOINT, DEFAULT_MARKER_CLASS_PREFIX, DEFAULT_OPEN_SOURCE_ENDPOINT, DEFAULT_SOURCE_ATTRIBUTE, DEFAULT_STYLE_MODULE_ENDPOINT, DEFAULT_TOKEN_WRITEBACK_ENDPOINT, DEFAULT_WRITEBACK_ENDPOINT, DynamicSourceTarget, EditorColorTokenMetadata, EditorFontTokenMetadata, EditorMetadataSection, EditorMetadataUnavailableReason, EditorMetadataUpdateEvent, EditorPropertyCategory, EditorPropertyMetadata, EditorTokenSourceSection, EditorTokenSourceTarget, EstreeNode, ExternalSourceTarget, InlineCssSourceCreateRequest, InspectorEditorMetadata, InspectorManifest, InspectorManifestEntry, JsonPrimitive, JsonValue, ManifestUpdateEvent, OpenSourceLocationErrorCode, OpenSourceLocationRequest, OpenSourceLocationResponse, PandaCssSourceTarget, PandaSourceAstAdapter, PandaStyleObject, ParseSourceSyntaxOptions, ParsedPandaSource, PreviewStyleCondition, PreviewStyleRule, PreviewStyleSheet, RuntimeAttribute, RuntimeComponentLayer, RuntimeComponentLayerElement, RuntimeCssDeclaration, RuntimeElementBounds, RuntimePropertyContext, RuntimeStyleEvidence, SCULPTED_EVENTS, SCULPTED_PROTOCOL_VERSION, SculptedEventName, SelectedElementInfo, SelectedElementState, SourceAstKind, SourceLocation, SourceParseResult, SourceParserAdapter, SourcePosition, SourceRange, SourceSyntaxAdapter, SourceSyntaxOption, SourceTarget, SourceTargetBase, SourceTargetKind, StyleEdit, StyleEditBatchRequest, StyleEditBatchResponse, StyleEditError, StyleEditErrorCode, StyleEditOptions, StyleEditRequest, StyleEditResponse, StyleModuleEditRequest, StyleModuleSourceAttachRequest, StyleModuleSourceCreateRequest, StyleModuleSourceDetachRequest, StyleValueSource, TokenConfigEditRequest, TokenConfigEditResponse, UnsupportedReason, UnsupportedSourceTarget, analyzePandaCssSource, componentStyleModulePaths, createEstreePandaAstAdapter, createInlineCssSourcePatch, createStaticCssBatchPatch, createStaticCssPatch, createStyleModuleAttachPatch, createStyleModuleDetachPatch, createStyleModuleSourcePatch, createTokenConfigPatch, editIdFromMarkerClass, editIdsFromMarkerClassList, hashSource, markerClassForEditId, parsePandaSource, parseWithSourceParserAdapter, readComponentStyleModule, resolveSourceParserAdapter, tsxSourceParserAdapter, tsxSourceSyntaxAdapter, typescriptPandaAstAdapter };
129
+ export { AnalyzePandaCssSourceOptions, AnalyzePandaCssSourceResult, ComponentStyleModulePaths, ComponentStyleModuleResponse, ComponentStyleModuleSource, Confidence, CreateInlineCssSourcePatchOptions, CreateStaticCssPatchOptions, CreateTokenConfigPatchOptions, DEFAULT_COMPONENT_ATTRIBUTE, DEFAULT_EDITOR_METADATA_ENDPOINT, DEFAULT_EDIT_ID_ATTRIBUTE, DEFAULT_FORCED_STATE_ATTRIBUTE, DEFAULT_JSX_SOURCE_ATTRIBUTE, DEFAULT_MANIFEST_ENDPOINT, DEFAULT_MARKER_CLASS_PREFIX, DEFAULT_OPEN_SOURCE_ENDPOINT, DEFAULT_SOURCE_ATTRIBUTE, DEFAULT_STYLE_MODULE_ENDPOINT, DEFAULT_TOKEN_WRITEBACK_ENDPOINT, DEFAULT_WRITEBACK_ENDPOINT, DynamicSourceTarget, EditorColorTokenMetadata, EditorFontTokenMetadata, EditorMetadataSection, EditorMetadataUnavailableReason, EditorMetadataUpdateEvent, EditorPropertyCategory, EditorPropertyMetadata, EditorTokenSourceSection, EditorTokenSourceTarget, EstreeNode, ExternalSourceTarget, InlineCssSourceCreateRequest, InspectorEditorMetadata, InspectorManifest, InspectorManifestEntry, JsonPrimitive, JsonValue, ManifestUpdateEvent, OpenSourceLocationErrorCode, OpenSourceLocationRequest, OpenSourceLocationResponse, PandaCssSourceTarget, PandaSourceAstAdapter, PandaStyleObject, ParseSourceSyntaxOptions, ParsedPandaSource, PreviewStyleCondition, PreviewStyleRule, PreviewStyleSheet, RuntimeAttribute, RuntimeComponentLayer, RuntimeComponentLayerElement, RuntimeCssDeclaration, RuntimeElementBounds, RuntimeInheritedStyleSource, RuntimePropertyContext, RuntimeStyleEvidence, SCULPTED_EVENTS, SCULPTED_PROTOCOL_VERSION, SculptedEventName, SelectedElementInfo, SelectedElementState, SourceAstKind, SourceLocation, SourceParseResult, SourceParserAdapter, SourcePosition, SourceRange, SourceSyntaxAdapter, SourceSyntaxOption, SourceTarget, SourceTargetBase, SourceTargetKind, StyleEdit, StyleEditBatchRequest, StyleEditBatchResponse, StyleEditError, StyleEditErrorCode, StyleEditOptions, StyleEditRequest, StyleEditResponse, StyleModuleEditRequest, StyleModuleSourceAttachRequest, StyleModuleSourceCreateRequest, StyleModuleSourceDetachRequest, StyleValueSource, TokenConfigEditRequest, TokenConfigEditResponse, UnsupportedReason, UnsupportedSourceTarget, analyzePandaCssSource, componentStyleModulePaths, createEstreePandaAstAdapter, createInlineCssSourcePatch, createStaticCssBatchPatch, createStaticCssPatch, createStyleModuleAttachPatch, createStyleModuleDetachPatch, createStyleModuleSourcePatch, createTokenConfigPatch, editIdFromMarkerClass, editIdsFromMarkerClassList, hashSource, markerClassForEditId, parsePandaSource, parseWithSourceParserAdapter, readComponentStyleModule, resolveSourceParserAdapter, tsxSourceParserAdapter, tsxSourceSyntaxAdapter, typescriptPandaAstAdapter };
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  import { _ as markerClassForEditId, a as DEFAULT_JSX_SOURCE_ATTRIBUTE, c as DEFAULT_OPEN_SOURCE_ENDPOINT, d as DEFAULT_TOKEN_WRITEBACK_ENDPOINT, f as DEFAULT_WRITEBACK_ENDPOINT, g as editIdsFromMarkerClassList, h as editIdFromMarkerClass, i as DEFAULT_FORCED_STATE_ATTRIBUTE, l as DEFAULT_SOURCE_ATTRIBUTE, m as SCULPTED_PROTOCOL_VERSION, n as DEFAULT_EDITOR_METADATA_ENDPOINT, o as DEFAULT_MANIFEST_ENDPOINT, p as SCULPTED_EVENTS, r as DEFAULT_EDIT_ID_ATTRIBUTE, s as DEFAULT_MARKER_CLASS_PREFIX, t as DEFAULT_COMPONENT_ATTRIBUTE, u as DEFAULT_STYLE_MODULE_ENDPOINT } from "./protocol-D5heR2QM.mjs";
2
- import { C as tsxSourceParserAdapter, S as resolveSourceParserAdapter, T as typescriptPandaAstAdapter, _ as analyzePandaCssSource, a as createStyleModuleSourcePatch, b as parsePandaSource, g as createInlineCssSourcePatch, h as createStaticCssPatch, i as createStyleModuleDetachPatch, m as createStaticCssBatchPatch, n as componentStyleModulePaths, o as readComponentStyleModule, r as createStyleModuleAttachPatch, t as createTokenConfigPatch, v as hashSource, w as tsxSourceSyntaxAdapter, x as parseWithSourceParserAdapter, y as createEstreePandaAstAdapter } from "./patcher-DQgKdozw.mjs";
2
+ import { C as parseWithSourceParserAdapter, D as typescriptPandaAstAdapter, E as tsxSourceSyntaxAdapter, S as parsePandaSource, T as tsxSourceParserAdapter, _ as createStaticCssPatch, a as createStyleModuleSourcePatch, b as hashSource, g as createStaticCssBatchPatch, i as createStyleModuleDetachPatch, n as componentStyleModulePaths, o as readComponentStyleModule, r as createStyleModuleAttachPatch, t as createTokenConfigPatch, v as createInlineCssSourcePatch, w as resolveSourceParserAdapter, x as createEstreePandaAstAdapter, y as analyzePandaCssSource } from "./patcher-nj9VhRT-.mjs";
3
3
  export { DEFAULT_COMPONENT_ATTRIBUTE, DEFAULT_EDITOR_METADATA_ENDPOINT, DEFAULT_EDIT_ID_ATTRIBUTE, DEFAULT_FORCED_STATE_ATTRIBUTE, DEFAULT_JSX_SOURCE_ATTRIBUTE, DEFAULT_MANIFEST_ENDPOINT, DEFAULT_MARKER_CLASS_PREFIX, DEFAULT_OPEN_SOURCE_ENDPOINT, DEFAULT_SOURCE_ATTRIBUTE, DEFAULT_STYLE_MODULE_ENDPOINT, DEFAULT_TOKEN_WRITEBACK_ENDPOINT, DEFAULT_WRITEBACK_ENDPOINT, SCULPTED_EVENTS, SCULPTED_PROTOCOL_VERSION, analyzePandaCssSource, componentStyleModulePaths, createEstreePandaAstAdapter, createInlineCssSourcePatch, createStaticCssBatchPatch, createStaticCssPatch, createStyleModuleAttachPatch, createStyleModuleDetachPatch, createStyleModuleSourcePatch, createTokenConfigPatch, editIdFromMarkerClass, editIdsFromMarkerClassList, hashSource, markerClassForEditId, parsePandaSource, parseWithSourceParserAdapter, readComponentStyleModule, resolveSourceParserAdapter, tsxSourceParserAdapter, tsxSourceSyntaxAdapter, typescriptPandaAstAdapter };
@@ -1,5 +1,7 @@
1
1
  import "./protocol-D5heR2QM.mjs";
2
2
  import ts from "typescript";
3
+ import { realpath } from "node:fs/promises";
4
+ import { posix } from "node:path";
3
5
  //#region src/sourceSyntax.ts
4
6
  function parseWithSourceParserAdapter(adapter, options) {
5
7
  return resolveSourceParserAdapter(options.filePath, adapter).parse(options);
@@ -599,8 +601,10 @@ function createInlineCssSourcePatch(options) {
599
601
  if (!element) return failure$3(request.editId, "stale-source", "JSX source location no longer points to a JSX element.");
600
602
  const existingImport = findCssImportBinding$1(sourceFile, options.cssImportSources);
601
603
  const cssLocalName = existingImport?.localName ?? availableCssLocalName(sourceFile);
604
+ const styleObject = styleObjectTextForInlineCreateEdits(request.edits);
605
+ if (!styleObject.ok) return failure$3(request.editId, styleObject.code, styleObject.message);
602
606
  const replacements = [];
603
- const attributeReplacement = inlineCssAttributeReplacement(sourceFile, sourceText, element, cssLocalName, existingImport?.localName);
607
+ const attributeReplacement = inlineCssAttributeReplacement(sourceFile, sourceText, element, cssLocalName, existingImport?.localName, styleObject.text);
604
608
  if (!attributeReplacement.ok) return failure$3(request.editId, attributeReplacement.code, attributeReplacement.message, attributeReplacement.details);
605
609
  replacements.push(attributeReplacement.replacement);
606
610
  if (!existingImport) replacements.push({
@@ -621,7 +625,7 @@ function createInlineCssSourcePatch(options) {
621
625
  written: false
622
626
  };
623
627
  }
624
- function inlineCssAttributeReplacement(sourceFile, sourceText, element, cssLocalName, existingCssLocalName) {
628
+ function inlineCssAttributeReplacement(sourceFile, sourceText, element, cssLocalName, existingCssLocalName, styleObjectText) {
625
629
  let classAttribute;
626
630
  for (const property of element.attributes.properties) {
627
631
  if (!ts.isJsxAttribute(property) || !ts.isIdentifier(property.name)) continue;
@@ -644,7 +648,7 @@ function inlineCssAttributeReplacement(sourceFile, sourceText, element, cssLocal
644
648
  start: insertPosition,
645
649
  end: insertPosition
646
650
  },
647
- text: ` class={${cssLocalName}({})}`
651
+ text: ` class={${cssLocalName}(${styleObjectText})}`
648
652
  }
649
653
  };
650
654
  }
@@ -654,7 +658,7 @@ function inlineCssAttributeReplacement(sourceFile, sourceText, element, cssLocal
654
658
  message: "Namespaced JSX class attributes cannot receive inline css() sources."
655
659
  };
656
660
  const attributeName = classAttribute.name.text;
657
- const inlineCssCall = `${cssLocalName}({})`;
661
+ const inlineCssCall = `${cssLocalName}(${styleObjectText})`;
658
662
  if (!classAttribute.initializer) return {
659
663
  ok: true,
660
664
  replacement: {
@@ -693,6 +697,36 @@ function inlineCssAttributeReplacement(sourceFile, sourceText, element, cssLocal
693
697
  }
694
698
  };
695
699
  }
700
+ function styleObjectTextForInlineCreateEdits(edits) {
701
+ if (!edits || edits.length === 0) return {
702
+ ok: true,
703
+ text: "{}"
704
+ };
705
+ const properties = [];
706
+ for (const edit of edits) {
707
+ if (edit.op !== "set") return {
708
+ ok: false,
709
+ code: "invalid-edit",
710
+ message: "New inline sources only support setting initial properties."
711
+ };
712
+ if (edit.path.length !== 1) return {
713
+ ok: false,
714
+ code: "unsupported-operation",
715
+ message: "New inline sources only support top-level initial properties."
716
+ };
717
+ const property = edit.path[0];
718
+ if (!property || !/^[A-Za-z_$][\w$]*$/.test(property)) return {
719
+ ok: false,
720
+ code: "invalid-edit",
721
+ message: "New inline source property names must be valid identifiers."
722
+ };
723
+ properties.push(`${property}: ${JSON.stringify(edit.value)}`);
724
+ }
725
+ return {
726
+ ok: true,
727
+ text: `{ ${properties.join(", ")} }`
728
+ };
729
+ }
696
730
  function jsxAttributeExpression$2(initializer) {
697
731
  if (ts.isJsxExpression(initializer)) return initializer.expression;
698
732
  }
@@ -760,9 +794,9 @@ function importInsertionPosition$2(sourceFile) {
760
794
  function parseJsxSource(source) {
761
795
  const match = /^(.*):(\d+):(\d+)$/.exec(source.trim());
762
796
  const file = match?.[1]?.trim();
763
- const line = match?.[2] ? Number.parseInt(match[2], 10) : void 0;
764
- const column = match?.[3] ? Number.parseInt(match[3], 10) : void 0;
765
- if (!match || !file || line === void 0 || column === void 0 || line < 1 || column < 1) return {
797
+ const line = parsePositiveInteger$1(match?.[2]);
798
+ const column = parsePositiveInteger$1(match?.[3]);
799
+ if (!match || !file || line === void 0 || column === void 0) return {
766
800
  ok: false,
767
801
  code: "invalid-edit",
768
802
  message: "Inline source creation requires a JSX source path with line and column.",
@@ -775,6 +809,11 @@ function parseJsxSource(source) {
775
809
  column
776
810
  };
777
811
  }
812
+ function parsePositiveInteger$1(value) {
813
+ if (value === void 0) return void 0;
814
+ const parsed = Number(value);
815
+ return Number.isSafeInteger(parsed) && parsed >= 1 ? parsed : void 0;
816
+ }
778
817
  function positionForLineColumn$1(sourceFile, line, column) {
779
818
  const lineStart = sourceFile.getLineStarts()[line - 1];
780
819
  if (lineStart === void 0) return void 0;
@@ -1515,6 +1554,82 @@ function safeProjectSourcePath(projectRoot, filePath) {
1515
1554
  file
1516
1555
  };
1517
1556
  }
1557
+ async function verifyProjectWritePath(projectRoot, filePath) {
1558
+ const root = normalizePath$2(projectRoot).replace(/\/$/, "");
1559
+ const file = normalizePath$2(filePath).replace(/\/$/, "");
1560
+ let realRoot;
1561
+ let realTarget;
1562
+ try {
1563
+ realRoot = normalizePath$2(await realpath(root)).replace(/\/$/, "");
1564
+ realTarget = normalizePath$2(await realpath(file)).replace(/\/$/, "");
1565
+ } catch {
1566
+ const parent = posix.dirname(file);
1567
+ try {
1568
+ realRoot = normalizePath$2(await realpath(root)).replace(/\/$/, "");
1569
+ realTarget = normalizePath$2(await realpath(parent)).replace(/\/$/, "");
1570
+ } catch {
1571
+ return {
1572
+ ok: false,
1573
+ code: "path-outside-project",
1574
+ message: "Source path could not be resolved inside the project root.",
1575
+ details: {
1576
+ file,
1577
+ projectRoot: root
1578
+ }
1579
+ };
1580
+ }
1581
+ }
1582
+ if (!root || !realRoot || file !== root && !file.startsWith(`${root}/`) || realTarget !== realRoot && !realTarget.startsWith(`${realRoot}/`)) return {
1583
+ ok: false,
1584
+ code: "path-outside-project",
1585
+ message: "Source path resolves outside the project root.",
1586
+ details: {
1587
+ file,
1588
+ resolvedFile: realTarget,
1589
+ projectRoot: root,
1590
+ resolvedProjectRoot: realRoot
1591
+ }
1592
+ };
1593
+ return {
1594
+ ok: true,
1595
+ file
1596
+ };
1597
+ }
1598
+ async function verifyProjectExistingPath(projectRoot, filePath) {
1599
+ const root = normalizePath$2(projectRoot).replace(/\/$/, "");
1600
+ const file = normalizePath$2(filePath).replace(/\/$/, "");
1601
+ let realRoot;
1602
+ let realTarget;
1603
+ try {
1604
+ realRoot = normalizePath$2(await realpath(root)).replace(/\/$/, "");
1605
+ realTarget = normalizePath$2(await realpath(file)).replace(/\/$/, "");
1606
+ } catch {
1607
+ return {
1608
+ ok: false,
1609
+ code: "path-outside-project",
1610
+ message: "Source path could not be resolved inside the project root.",
1611
+ details: {
1612
+ file,
1613
+ projectRoot: root
1614
+ }
1615
+ };
1616
+ }
1617
+ if (!root || !realRoot || file !== root && !file.startsWith(`${root}/`) || realTarget !== realRoot && !realTarget.startsWith(`${realRoot}/`)) return {
1618
+ ok: false,
1619
+ code: "path-outside-project",
1620
+ message: "Source path resolves outside the project root.",
1621
+ details: {
1622
+ file,
1623
+ resolvedFile: realTarget,
1624
+ projectRoot: root,
1625
+ resolvedProjectRoot: realRoot
1626
+ }
1627
+ };
1628
+ return {
1629
+ ok: true,
1630
+ file
1631
+ };
1632
+ }
1518
1633
  function stripViteQuery(id) {
1519
1634
  return id.split("?")[0] ?? id;
1520
1635
  }
@@ -2111,9 +2226,9 @@ function cssImportText(cssLocalName, cssImportSources) {
2111
2226
  function parseSourceRef(source, message) {
2112
2227
  const match = /^(.*):(\d+):(\d+)$/.exec(source.trim());
2113
2228
  const file = match?.[1]?.trim();
2114
- const line = match?.[2] ? Number.parseInt(match[2], 10) : void 0;
2115
- const column = match?.[3] ? Number.parseInt(match[3], 10) : void 0;
2116
- if (!match || !file || line === void 0 || column === void 0 || line < 1 || column < 1) return {
2229
+ const line = parsePositiveInteger(match?.[2]);
2230
+ const column = parsePositiveInteger(match?.[3]);
2231
+ if (!match || !file || line === void 0 || column === void 0) return {
2117
2232
  ok: false,
2118
2233
  code: "invalid-edit",
2119
2234
  message,
@@ -2126,6 +2241,11 @@ function parseSourceRef(source, message) {
2126
2241
  column
2127
2242
  };
2128
2243
  }
2244
+ function parsePositiveInteger(value) {
2245
+ if (value === void 0) return void 0;
2246
+ const parsed = Number(value);
2247
+ return Number.isSafeInteger(parsed) && parsed >= 1 ? parsed : void 0;
2248
+ }
2129
2249
  function positionForLineColumn(sourceFile, line, column) {
2130
2250
  const lineStart = sourceFile.getLineStarts()[line - 1];
2131
2251
  if (lineStart === void 0) return void 0;
@@ -2591,4 +2711,4 @@ function failure(editId, code, message, details) {
2591
2711
  };
2592
2712
  }
2593
2713
  //#endregion
2594
- export { tsxSourceParserAdapter as C, resolveSourceParserAdapter as S, typescriptPandaAstAdapter as T, analyzePandaCssSource as _, createStyleModuleSourcePatch as a, parsePandaSource as b, resolveProjectPath as c, toRelativeProjectPath as d, trustedManifestFilePath as f, createInlineCssSourcePatch as g, createStaticCssPatch as h, createStyleModuleDetachPatch as i, safeProjectSourcePath as l, createStaticCssBatchPatch as m, componentStyleModulePaths as n, readComponentStyleModule as o, trustedTokenSourceFilePath as p, createStyleModuleAttachPatch as r, normalizePath$2 as s, createTokenConfigPatch as t, stripViteQuery as u, hashSource as v, tsxSourceSyntaxAdapter as w, parseWithSourceParserAdapter as x, createEstreePandaAstAdapter as y };
2714
+ export { parseWithSourceParserAdapter as C, typescriptPandaAstAdapter as D, tsxSourceSyntaxAdapter as E, parsePandaSource as S, tsxSourceParserAdapter as T, createStaticCssPatch as _, createStyleModuleSourcePatch as a, hashSource as b, resolveProjectPath as c, toRelativeProjectPath as d, trustedManifestFilePath as f, createStaticCssBatchPatch as g, verifyProjectWritePath as h, createStyleModuleDetachPatch as i, safeProjectSourcePath as l, verifyProjectExistingPath as m, componentStyleModulePaths as n, readComponentStyleModule as o, trustedTokenSourceFilePath as p, createStyleModuleAttachPatch as r, normalizePath$2 as s, createTokenConfigPatch as t, stripViteQuery as u, createInlineCssSourcePatch as v, resolveSourceParserAdapter as w, createEstreePandaAstAdapter as x, analyzePandaCssSource as y };
@@ -1,4 +1,4 @@
1
- import { $ as StyleModuleEditRequest, C as OpenSourceLocationRequest, L as SelectedElementInfo, Q as StyleEditResponse, Z as StyleEditRequest, _ as InspectorManifest, at as TokenConfigEditResponse, g as InspectorEditorMetadata, h as InlineCssSourceCreateRequest, it as TokenConfigEditRequest, k as PreviewStyleSheet, t as ComponentStyleModuleResponse, v as InspectorManifestEntry, w as OpenSourceLocationResponse } from "./types-CdByW0ji.mjs";
1
+ import { $ as StyleEditResponse, C as OpenSourceLocationRequest, Q as StyleEditRequest, R as SelectedElementInfo, _ as InspectorManifest, at as TokenConfigEditRequest, et as StyleModuleEditRequest, g as InspectorEditorMetadata, h as InlineCssSourceCreateRequest, k as PreviewStyleSheet, ot as TokenConfigEditResponse, t as ComponentStyleModuleResponse, v as InspectorManifestEntry, w as OpenSourceLocationResponse } from "./types-0a4hNfAF.mjs";
2
2
 
3
3
  //#region src/runtime.d.ts
4
4
  type RuntimeInspectorOptions = {
@@ -1,2 +1,2 @@
1
- import { i as installSculptedRuntime, n as RuntimeInspectorOptions, r as SculptedRuntime, t as RuntimeEnvironment } from "./runtime-C1gUOAc9.mjs";
1
+ import { i as installSculptedRuntime, n as RuntimeInspectorOptions, r as SculptedRuntime, t as RuntimeEnvironment } from "./runtime-Cpxddehp.mjs";
2
2
  export { RuntimeEnvironment, RuntimeInspectorOptions, SculptedRuntime, installSculptedRuntime };