sculpted 0.3.3 → 0.3.4

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.
@@ -1,4 +1,4 @@
1
- import { B as SourceLocation, H as SourceRange } from "./types-0a4hNfAF.mjs";
1
+ import { B as SourceLocation, H as SourceRange } from "./types-BWXru9cn.mjs";
2
2
  import ts from "typescript";
3
3
 
4
4
  //#region src/sourceSyntax.d.ts
package/dist/tsrx.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { s as SourceParserAdapter } from "./sourceSyntax-DKIh-VKA.mjs";
1
+ import { s as SourceParserAdapter } from "./sourceSyntax-BpjcDJyk.mjs";
2
2
 
3
3
  //#region src/tsrx.d.ts
4
4
  declare const sourceSyntax: SourceParserAdapter;
@@ -142,6 +142,7 @@ type EditorPropertyMetadata = {
142
142
  readonly aliases: readonly string[];
143
143
  readonly tokenCategory?: string;
144
144
  readonly defaultUnit?: string;
145
+ readonly commonness?: number;
145
146
  };
146
147
  type InspectorEditorMetadata = {
147
148
  readonly version: number;
package/dist/ui.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as RuntimePropertyContext, N as RuntimeCssDeclaration, R as SelectedElementInfo, j as RuntimeComponentLayer } from "./types-0a4hNfAF.mjs";
2
- import { r as SculptedRuntime } from "./runtime-Cpxddehp.mjs";
1
+ import { I as RuntimePropertyContext, N as RuntimeCssDeclaration, R as SelectedElementInfo, j as RuntimeComponentLayer } from "./types-BWXru9cn.mjs";
2
+ import { r as SculptedRuntime } from "./runtime-C5jlEq5d.mjs";
3
3
 
4
4
  //#region src/ui/inspectorPanel.d.ts
5
5
  type ReadonlyInspectorPanelOptions = {
package/dist/ui.mjs CHANGED
@@ -8285,7 +8285,10 @@ function InspectorPanel(props) {
8285
8285
  if (saving.value) return;
8286
8286
  const before = pendingPreviewChanges.value;
8287
8287
  const next = new Map(before);
8288
- next.set(previewChangeKey(editId, path), {
8288
+ const key = previewChangeKey(editId, path);
8289
+ const existingChange = before.get(key);
8290
+ if (existingChange?.op === "set" && existingChange.originalValue === void 0) next.delete(key);
8291
+ else next.set(key, {
8289
8292
  editId,
8290
8293
  path,
8291
8294
  op: "delete",
@@ -9646,7 +9649,7 @@ function EditableTargetsSection(props) {
9646
9649
  onMenuOpenChange: onInputMenuOpenChange
9647
9650
  }) : null]
9648
9651
  }) : null,
9649
- editableTargets.map((target) => /* @__PURE__ */ u("div", {
9652
+ editableTargets.map((target, targetIndex) => /* @__PURE__ */ u("div", {
9650
9653
  "data-editable-target-panel": "true",
9651
9654
  "data-editable-target-id": target.id,
9652
9655
  style: {
@@ -10104,6 +10107,7 @@ function EditableTargetsSection(props) {
10104
10107
  propertyContext: previewPropertyContext,
10105
10108
  saving,
10106
10109
  autoOpen: target.id === pendingInlineSourceTarget?.id,
10110
+ showShortcutHint: targetIndex === 0,
10107
10111
  onAddProperty,
10108
10112
  onMenuOpenChange: onInputMenuOpenChange
10109
10113
  }) : null
@@ -10243,13 +10247,8 @@ function propertySelectorOptions(metadata) {
10243
10247
  label: property.label,
10244
10248
  groupLabel: propertyGroupLabel(property),
10245
10249
  detail: property.cssProperty ?? property.category,
10246
- searchText: [
10247
- property.name,
10248
- property.cssProperty,
10249
- property.category,
10250
- ...property.aliases
10251
- ].filter(Boolean).join(" "),
10252
- defaultValue
10250
+ defaultValue,
10251
+ commonness: property.commonness ?? 1
10253
10252
  }];
10254
10253
  });
10255
10254
  }
@@ -10403,28 +10402,51 @@ function defaultPropertyUnit(property) {
10403
10402
  function preparePropertyOption(option) {
10404
10403
  return {
10405
10404
  option,
10406
- label: prepare(option.label),
10407
- detail: prepare(option.detail),
10408
- searchText: prepare(option.searchText)
10405
+ label: prepare(option.label)
10409
10406
  };
10410
10407
  }
10411
10408
  function filteredPropertyOptions(query, preparedOptions, propertyContext) {
10412
10409
  const queryText = query.trim();
10413
10410
  if (!queryText) return preparedOptions.map((preparedOption) => preparedOption.option).filter((option) => propertyVisibleByContext(option, propertyContext));
10414
- return searchFields(queryText, preparedOptions, [
10415
- {
10416
- key: "label",
10417
- extract: (item) => item.label
10418
- },
10419
- {
10420
- key: "detail",
10421
- extract: (item) => item.detail
10422
- },
10423
- {
10424
- key: "searchText",
10425
- extract: (item) => item.searchText
10426
- }
10427
- ], { limit: preparedOptions.length }).items.map((match) => match.value.option);
10411
+ return searchFields(queryText, preparedOptions, [{
10412
+ key: "label",
10413
+ extract: (item) => item.label
10414
+ }], { limit: preparedOptions.length }).items.map((match, index) => ({
10415
+ match,
10416
+ index
10417
+ })).sort((left, right) => {
10418
+ const leftExactness = propertyOptionExactness(queryText, left.match.value.option, propertyContext);
10419
+ const rightExactness = propertyOptionExactness(queryText, right.match.value.option, propertyContext);
10420
+ if (rightExactness !== leftExactness) return rightExactness - leftExactness;
10421
+ const rightScore = propertyOptionSearchScore(right.match, propertyVisibleByContext(right.match.value.option, propertyContext), propertyDeboostedByContext(right.match.value.option, propertyContext));
10422
+ const leftScore = propertyOptionSearchScore(left.match, propertyVisibleByContext(left.match.value.option, propertyContext), propertyDeboostedByContext(left.match.value.option, propertyContext));
10423
+ if (rightScore !== leftScore) return rightScore - leftScore;
10424
+ return left.index - right.index;
10425
+ }).map(({ match }) => match.value.option);
10426
+ }
10427
+ function propertyOptionExactness(query, option, context) {
10428
+ const normalizedQuery = query.toLowerCase();
10429
+ const exactTargets = [option.label].flatMap((target) => [
10430
+ target,
10431
+ target.replaceAll("-", ""),
10432
+ target.replaceAll(" ", "")
10433
+ ]).map((target) => target.toLowerCase());
10434
+ const exactWordTargets = option.label.split(/[\s-]+/).map((target) => target.toLowerCase()).filter(Boolean);
10435
+ const exactness = exactTargets.some((target) => target === normalizedQuery) ? 4 : exactWordTargets.some((target) => target === normalizedQuery) ? 3 : exactTargets.some((target) => target.startsWith(normalizedQuery)) ? 2 : exactWordTargets.some((target) => target.startsWith(normalizedQuery)) ? 1 : 0;
10436
+ return propertyDeboostedByContext(option, context) ? exactness - 2 : exactness;
10437
+ }
10438
+ function propertyOptionSearchScore(match, applyCommonness, applyContextDeboost) {
10439
+ const contextDeboost = applyContextDeboost ? 1 : 0;
10440
+ if (!applyCommonness || applyContextDeboost) return match.score - contextDeboost;
10441
+ const commonness = match.value.option.commonness;
10442
+ const boundedCommonness = Number.isFinite(commonness) ? Math.max(.25, commonness) : 1;
10443
+ return match.score + Math.log2(boundedCommonness) * .03;
10444
+ }
10445
+ function propertyDeboostedByContext(option, context) {
10446
+ if (!INSET_OFFSET_PROPERTIES.has(option.name)) return false;
10447
+ if (!context) return false;
10448
+ const position = context.position.trim();
10449
+ return position === "static" || position === "relative";
10428
10450
  }
10429
10451
  function propertyVisibleByContext(option, context) {
10430
10452
  if (!context) return true;
@@ -10838,6 +10860,13 @@ const STATIC_POSITIONED_PROPERTIES = new Set([
10838
10860
  "left",
10839
10861
  "zIndex"
10840
10862
  ]);
10863
+ const INSET_OFFSET_PROPERTIES = new Set([
10864
+ "inset",
10865
+ "top",
10866
+ "right",
10867
+ "bottom",
10868
+ "left"
10869
+ ]);
10841
10870
  const FLEX_CONTAINER_PROPERTIES = new Set([
10842
10871
  "flexDirection",
10843
10872
  "flexWrap",
@@ -10909,6 +10938,7 @@ function AddPropertyMenu(props) {
10909
10938
  });
10910
10939
  const preparedOptions = availableOptions.map(preparePropertyOption);
10911
10940
  const filteredOptions = filteredPropertyOptions(query.value, preparedOptions, props.propertyContext);
10941
+ const hasQuery = query.value.trim().length > 0;
10912
10942
  const groupedOptions = groupedPropertyOptions(filteredOptions);
10913
10943
  const activeSelectableOptionId = filteredOptions.some((option) => option.id === activeOptionId.value) ? activeOptionId.value : filteredOptions[0]?.id;
10914
10944
  const selectOption = (option) => {
@@ -10932,6 +10962,42 @@ function AddPropertyMenu(props) {
10932
10962
  const option = filteredOptions.find((item) => item.id === activeSelectableOptionId);
10933
10963
  if (option) selectOption(option);
10934
10964
  };
10965
+ const renderOption = (option) => /* @__PURE__ */ u(ShadowMenuItem, {
10966
+ active: activeSelectableOptionId === option.id,
10967
+ class: "panda-property-selector-menu-item",
10968
+ disabled: props.saving.value,
10969
+ onSelect: () => {
10970
+ selectOption(option);
10971
+ },
10972
+ children: /* @__PURE__ */ u("span", {
10973
+ "data-property-selector-option": "true",
10974
+ "data-property-selector-option-id": option.id,
10975
+ "data-property-selector-active": activeSelectableOptionId === option.id ? "true" : "false",
10976
+ onClick: (event) => {
10977
+ event.stopPropagation();
10978
+ selectOption(option);
10979
+ },
10980
+ style: {
10981
+ minWidth: 0,
10982
+ display: "grid",
10983
+ gridTemplateColumns: "1fr auto",
10984
+ alignItems: "center",
10985
+ gap: "8px"
10986
+ },
10987
+ children: [/* @__PURE__ */ u("span", {
10988
+ style: {
10989
+ minWidth: 0,
10990
+ overflow: "hidden",
10991
+ textOverflow: "ellipsis",
10992
+ whiteSpace: "nowrap"
10993
+ },
10994
+ children: option.label
10995
+ }), /* @__PURE__ */ u("code", {
10996
+ style: { color: "#667085" },
10997
+ children: option.name
10998
+ })]
10999
+ })
11000
+ }, option.id);
10935
11001
  _$2(() => {
10936
11002
  if (menuOpen.value) {
10937
11003
  if (!previousMenuOpen.current) props.onMenuOpenChange(true);
@@ -10973,10 +11039,22 @@ function AddPropertyMenu(props) {
10973
11039
  gap: "6px",
10974
11040
  font: "inherit"
10975
11041
  },
10976
- children: [/* @__PURE__ */ u(Plus, {
10977
- size: 14,
10978
- "aria-hidden": "true"
10979
- }), pathPrefixLabel ? `Add ${statePathLabel(pathPrefixLabel)} property` : "Add property"]
11042
+ children: [
11043
+ /* @__PURE__ */ u(Plus, {
11044
+ size: 14,
11045
+ "aria-hidden": "true"
11046
+ }),
11047
+ pathPrefixLabel ? `Add ${statePathLabel(pathPrefixLabel)} property` : "Add property",
11048
+ props.showShortcutHint ? /* @__PURE__ */ u("span", {
11049
+ style: {
11050
+ color: "#98a2b3",
11051
+ fontSize: "11px",
11052
+ fontWeight: 600,
11053
+ transform: "translateY(2px)"
11054
+ },
11055
+ children: "⇧A"
11056
+ }) : null
11057
+ ]
10980
11058
  })
10981
11059
  }), menuOpen.value ? /* @__PURE__ */ u(ShadowMenu, {
10982
11060
  open: menuOpen,
@@ -11048,7 +11126,7 @@ function AddPropertyMenu(props) {
11048
11126
  padding: "7px 8px"
11049
11127
  },
11050
11128
  children: "No matching properties."
11051
- }) : groupedOptions.map((group) => /* @__PURE__ */ u("div", {
11129
+ }) : hasQuery ? filteredOptions.map((option) => renderOption(option)) : groupedOptions.map((group) => /* @__PURE__ */ u("div", {
11052
11130
  "data-property-selector-group": group.label,
11053
11131
  children: [/* @__PURE__ */ u("div", {
11054
11132
  "data-property-selector-group-label": "true",
@@ -11060,42 +11138,7 @@ function AddPropertyMenu(props) {
11060
11138
  textTransform: "uppercase"
11061
11139
  },
11062
11140
  children: group.label
11063
- }), group.options.map((option) => /* @__PURE__ */ u(ShadowMenuItem, {
11064
- active: activeSelectableOptionId === option.id,
11065
- class: "panda-property-selector-menu-item",
11066
- disabled: props.saving.value,
11067
- onSelect: () => {
11068
- selectOption(option);
11069
- },
11070
- children: /* @__PURE__ */ u("span", {
11071
- "data-property-selector-option": "true",
11072
- "data-property-selector-option-id": option.id,
11073
- "data-property-selector-active": activeSelectableOptionId === option.id ? "true" : "false",
11074
- onClick: (event) => {
11075
- event.stopPropagation();
11076
- selectOption(option);
11077
- },
11078
- style: {
11079
- minWidth: 0,
11080
- display: "grid",
11081
- gridTemplateColumns: "1fr auto",
11082
- alignItems: "center",
11083
- gap: "8px"
11084
- },
11085
- children: [/* @__PURE__ */ u("span", {
11086
- style: {
11087
- minWidth: 0,
11088
- overflow: "hidden",
11089
- textOverflow: "ellipsis",
11090
- whiteSpace: "nowrap"
11091
- },
11092
- children: option.label
11093
- }), /* @__PURE__ */ u("code", {
11094
- style: { color: "#667085" },
11095
- children: option.name
11096
- })]
11097
- })
11098
- }, option.id))]
11141
+ }), group.options.map((option) => renderOption(option))]
11099
11142
  }, group.label))
11100
11143
  })]
11101
11144
  }) : null]
package/dist/vite.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { l as SourceSyntaxOption } from "./sourceSyntax-DKIh-VKA.mjs";
1
+ import { l as SourceSyntaxOption } from "./sourceSyntax-BpjcDJyk.mjs";
2
2
 
3
3
  //#region src/vite/types.d.ts
4
4
  type InspectorVitePluginOptions = {
package/dist/vite.mjs CHANGED
@@ -21,6 +21,61 @@ const DEFAULT_PANDA_CONFIG_FILES = [
21
21
  ];
22
22
  //#endregion
23
23
  //#region src/vite/editorProperties.ts
24
+ const EDITOR_PROPERTY_COMMONNESS = {
25
+ display: 2.2,
26
+ color: 2.1,
27
+ background: 2,
28
+ backgroundColor: 2,
29
+ padding: 2,
30
+ paddingX: 1.9,
31
+ paddingY: 1.9,
32
+ paddingTop: 1.8,
33
+ paddingRight: 1.8,
34
+ paddingBottom: 1.8,
35
+ paddingLeft: 1.8,
36
+ margin: 1.9,
37
+ marginX: 1.8,
38
+ marginY: 1.8,
39
+ marginTop: 1.7,
40
+ marginRight: 1.7,
41
+ marginBottom: 1.7,
42
+ marginLeft: 1.7,
43
+ width: 1.9,
44
+ height: 1.8,
45
+ borderRadius: 1.8,
46
+ gap: 1.8,
47
+ fontSize: 1.8,
48
+ fontWeight: 1.7,
49
+ lineHeight: 1.7,
50
+ position: 1.7,
51
+ opacity: 1.7,
52
+ border: 1.6,
53
+ boxShadow: 1.5,
54
+ alignItems: 1.5,
55
+ justifyContent: 1.5,
56
+ flexDirection: 1.4,
57
+ overflow: 1.4,
58
+ cursor: 1.3,
59
+ transform: 1.3,
60
+ maxWidth: 1.3,
61
+ minWidth: 1.3,
62
+ top: 1.2,
63
+ right: 1.2,
64
+ bottom: 1.2,
65
+ left: 1.2,
66
+ inset: 1.2,
67
+ zIndex: 1.2,
68
+ backgroundImage: 1.1,
69
+ outline: 1.1,
70
+ transition: 1.1,
71
+ pointerEvents: 1.1,
72
+ userSelect: 1.1,
73
+ backdropFilter: .8,
74
+ mixBlendMode: .8,
75
+ backgroundAttachment: .7,
76
+ transitionTimingFunction: .7,
77
+ cornerShape: .6
78
+ };
24
79
  function editorProperty(name, label, category, cssProperty, aliases = [], tokenCategory) {
25
80
  return {
26
81
  name,
@@ -29,9 +84,13 @@ function editorProperty(name, label, category, cssProperty, aliases = [], tokenC
29
84
  cssProperty,
30
85
  aliases,
31
86
  tokenCategory,
32
- defaultUnit: defaultEditorPropertyUnit(name, category)
87
+ defaultUnit: defaultEditorPropertyUnit(name, category),
88
+ commonness: editorPropertyCommonness(name)
33
89
  };
34
90
  }
91
+ function editorPropertyCommonness(name) {
92
+ return EDITOR_PROPERTY_COMMONNESS[name] ?? 1;
93
+ }
35
94
  function defaultEditorPropertyUnit(name, category) {
36
95
  if ([
37
96
  "zIndex",
@@ -24,8 +24,17 @@ framework-rendered document. Add the runtime script explicitly in development:
24
24
 
25
25
  ```tsx
26
26
  // app/root.tsx
27
- <Scripts />
28
- {import.meta.env.DEV && <script src="/@sculpted/runtime" type="module" />}
27
+ export function Layout({ children }: { children: React.ReactNode }) {
28
+ return (
29
+ <html>
30
+ <body>
31
+ {children}
32
+ <Scripts />
33
+ {import.meta.env.DEV ? <script src="/@sculpted/runtime" type="module" /> : null}
34
+ </body>
35
+ </html>
36
+ )
37
+ }
29
38
  ```
30
39
 
31
40
  Keep `sculpted()` before `reactRouter()` in `vite.config.ts` so route modules are instrumented
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sculpted-vite-preact-pandacss",
3
- "private": true,
4
3
  "version": "0.0.0",
4
+ "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "prepare": "panda codegen",
@@ -1,5 +1,5 @@
1
1
  module.exports = {
2
2
  plugins: {
3
- '@pandacss/dev/postcss': {}
4
- }
3
+ '@pandacss/dev/postcss': {},
4
+ },
5
5
  }
@@ -3,6 +3,11 @@
3
3
  body {
4
4
  margin: 0;
5
5
  font-family:
6
- Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
6
+ Inter,
7
+ ui-sans-serif,
8
+ system-ui,
9
+ -apple-system,
10
+ BlinkMacSystemFont,
11
+ 'Segoe UI',
7
12
  sans-serif;
8
13
  }
@@ -2,7 +2,7 @@ import preact from '@preact/preset-vite'
2
2
  import tsrx from '@tsrx/vite-plugin-preact'
3
3
  import { sourceSyntax } from 'sculpted/tsrx'
4
4
  import { sculpted } from 'sculpted/vite'
5
- import { defineConfig, } from 'vite'
5
+ import { defineConfig } from 'vite'
6
6
 
7
7
  export default defineConfig({
8
8
  plugins: [
@@ -11,10 +11,10 @@ export default defineConfig({
11
11
  include: ['src/**/*.{ts,tsx,tsrx}'],
12
12
  sourceSyntax: [sourceSyntax],
13
13
  panda: {
14
- cssImportSources: ['../styled-system/css']
15
- }
14
+ cssImportSources: ['../styled-system/css'],
15
+ },
16
16
  }),
17
17
  tsrx(),
18
- preact()
19
- ]
18
+ preact(),
19
+ ],
20
20
  })
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sculpted-vite-react-pandacss",
3
- "private": true,
4
3
  "version": "0.0.0",
4
+ "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "prepare": "panda codegen",
@@ -3,6 +3,11 @@
3
3
  body {
4
4
  margin: 0;
5
5
  font-family:
6
- Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
6
+ Inter,
7
+ ui-sans-serif,
8
+ system-ui,
9
+ -apple-system,
10
+ BlinkMacSystemFont,
11
+ 'Segoe UI',
7
12
  sans-serif;
8
13
  }
package/package.json CHANGED
@@ -1,18 +1,17 @@
1
1
  {
2
2
  "name": "sculpted",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "Experimental alpha dev inspector for editing Panda CSS styles and writing safe source updates.",
5
- "license": "FSL-1.1-ALv2",
6
- "author": "Alec Larson",
7
- "packageManager": "pnpm@11.5.1",
8
5
  "keywords": [
6
+ "css-editor",
7
+ "inspector",
9
8
  "panda-css",
10
- "vite",
11
9
  "preact",
12
- "inspector",
13
- "css-editor",
14
- "source-writeback"
10
+ "source-writeback",
11
+ "vite"
15
12
  ],
13
+ "license": "FSL-1.1-ALv2",
14
+ "author": "Alec Larson",
16
15
  "repository": {
17
16
  "type": "git",
18
17
  "url": "https://github.com/aleclarson/sculpted.git"
@@ -59,15 +58,6 @@
59
58
  "@pandacss/node": "1.11.1",
60
59
  "zod": "4.4.3"
61
60
  },
62
- "peerDependencies": {
63
- "@tsrx/core": ">=0.1.0",
64
- "typescript": ">=5.0.0"
65
- },
66
- "peerDependenciesMeta": {
67
- "@tsrx/core": {
68
- "optional": true
69
- }
70
- },
71
61
  "devDependencies": {
72
62
  "@goddard-ai/ui-primitives": "0.1.1",
73
63
  "@pandacss/dev": "^1.11.1",
@@ -84,5 +74,15 @@
84
74
  "tsdown": "^0.22.0",
85
75
  "typescript": "^6.0.3",
86
76
  "vitest": "^4.1.7"
87
- }
77
+ },
78
+ "peerDependencies": {
79
+ "@tsrx/core": ">=0.1.0",
80
+ "typescript": ">=5.0.0"
81
+ },
82
+ "peerDependenciesMeta": {
83
+ "@tsrx/core": {
84
+ "optional": true
85
+ }
86
+ },
87
+ "packageManager": "pnpm@11.5.1"
88
88
  }