sculpted 0.3.0 → 0.3.1
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 +2 -5
- package/dist/vite.d.mts +0 -11
- package/dist/vite.mjs +5 -8
- package/docs/examples.md +4 -4
- package/docs/source-syntax-adapters.md +6 -49
- package/docs/source-writeback.md +5 -10
- package/docs/vite-plugin.md +6 -85
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -117,13 +117,10 @@ instead of pretending the full cascade can be edited safely.
|
|
|
117
117
|
|
|
118
118
|
## Documentation
|
|
119
119
|
|
|
120
|
-
- [Vite plugin options](docs/vite-plugin.md) covers setup, defaults,
|
|
121
|
-
dev/prod behavior.
|
|
120
|
+
- [Vite plugin options](docs/vite-plugin.md) covers setup, defaults, and dev/prod behavior.
|
|
122
121
|
- [Source writeback](docs/source-writeback.md) covers the safety model, supported edit shapes, and
|
|
123
122
|
common failure modes.
|
|
124
|
-
- [Source syntax adapters](docs/source-syntax-adapters.md) covers TSRX
|
|
125
|
-
- [Example apps](docs/examples.md) covers the React and Preact Panda CSS examples used for manual
|
|
126
|
-
verification.
|
|
123
|
+
- [Source syntax adapters](docs/source-syntax-adapters.md) covers opt-in TSRX support.
|
|
127
124
|
|
|
128
125
|
## Troubleshooting
|
|
129
126
|
|
package/dist/vite.d.mts
CHANGED
|
@@ -9,12 +9,8 @@ type InspectorVitePluginOptions = {
|
|
|
9
9
|
readonly panda?: {
|
|
10
10
|
readonly configPath?: string;
|
|
11
11
|
readonly cssImportSources?: readonly string[];
|
|
12
|
-
readonly recipeImportSources?: readonly string[];
|
|
13
|
-
readonly cssFunctionNames?: readonly string[];
|
|
14
|
-
readonly cxFunctionNames?: readonly string[];
|
|
15
12
|
};
|
|
16
13
|
readonly manifest?: {
|
|
17
|
-
readonly outFile?: string;
|
|
18
14
|
readonly virtualEndpoint?: string;
|
|
19
15
|
};
|
|
20
16
|
readonly metadata?: {
|
|
@@ -22,13 +18,6 @@ type InspectorVitePluginOptions = {
|
|
|
22
18
|
};
|
|
23
19
|
readonly runtime?: {
|
|
24
20
|
readonly inject?: boolean;
|
|
25
|
-
readonly globalName?: string;
|
|
26
|
-
};
|
|
27
|
-
readonly attributes?: {
|
|
28
|
-
readonly editId?: string;
|
|
29
|
-
readonly source?: string;
|
|
30
|
-
readonly jsxSource?: string;
|
|
31
|
-
readonly component?: string;
|
|
32
21
|
};
|
|
33
22
|
readonly sourceSyntax?: SourceSyntaxOption;
|
|
34
23
|
};
|
package/dist/vite.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as markerClassForEditId, c as DEFAULT_OPEN_SOURCE_ENDPOINT, d as DEFAULT_TOKEN_WRITEBACK_ENDPOINT, f as DEFAULT_WRITEBACK_ENDPOINT, p as SCULPTED_EVENTS, u as DEFAULT_STYLE_MODULE_ENDPOINT } from "./protocol-D5heR2QM.mjs";
|
|
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, l as DEFAULT_SOURCE_ATTRIBUTE, p as SCULPTED_EVENTS, r as DEFAULT_EDIT_ID_ATTRIBUTE, t as DEFAULT_COMPONENT_ATTRIBUTE, u as DEFAULT_STYLE_MODULE_ENDPOINT } from "./protocol-D5heR2QM.mjs";
|
|
2
2
|
import { S as resolveSourceParserAdapter, _ as analyzePandaCssSource, a as createStyleModuleSourcePatch, b as parsePandaSource, c as resolveProjectPath, d as toRelativeProjectPath$1, f as trustedManifestFilePath, g as createInlineCssSourcePatch, h as createStaticCssPatch, i as createStyleModuleDetachPatch, l as safeProjectSourcePath, m as createStaticCssBatchPatch, n as componentStyleModulePaths, o as readComponentStyleModule, p as trustedTokenSourceFilePath, r as createStyleModuleAttachPatch, s as normalizePath$1, t as createTokenConfigPatch, u as stripViteQuery, v as hashSource } from "./patcher-DQgKdozw.mjs";
|
|
3
3
|
import ts from "typescript";
|
|
4
4
|
import { access, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
@@ -998,7 +998,6 @@ function registerRuntimeModuleRoutes(server, options) {
|
|
|
998
998
|
response.end(runtimeBootstrapSource({
|
|
999
999
|
manifestEndpoint: options.manifestEndpoint,
|
|
1000
1000
|
editorMetadataEndpoint: options.editorMetadataEndpoint,
|
|
1001
|
-
globalName: options.globalName,
|
|
1002
1001
|
runtimeModuleEndpoint: options.runtimeModuleEndpoint,
|
|
1003
1002
|
uiModuleEndpoint: options.uiModuleEndpoint
|
|
1004
1003
|
}));
|
|
@@ -1084,7 +1083,6 @@ function registerRuntimeModuleRoutes(server, options) {
|
|
|
1084
1083
|
}
|
|
1085
1084
|
function runtimeBootstrapSource(options) {
|
|
1086
1085
|
const runtimeOptions = JSON.stringify({
|
|
1087
|
-
globalName: options.globalName,
|
|
1088
1086
|
manifestEndpoint: options.manifestEndpoint,
|
|
1089
1087
|
editorMetadataEndpoint: options.editorMetadataEndpoint
|
|
1090
1088
|
});
|
|
@@ -2189,10 +2187,10 @@ function sculpted(options = {}) {
|
|
|
2189
2187
|
const uiModuleEndpoint = DEFAULT_UI_MODULE_ENDPOINT;
|
|
2190
2188
|
const runtimeChunkEndpoint = DEFAULT_RUNTIME_CHUNK_ENDPOINT;
|
|
2191
2189
|
const attributes = {
|
|
2192
|
-
editId:
|
|
2193
|
-
source:
|
|
2194
|
-
jsxSource:
|
|
2195
|
-
component:
|
|
2190
|
+
editId: DEFAULT_EDIT_ID_ATTRIBUTE,
|
|
2191
|
+
source: DEFAULT_SOURCE_ATTRIBUTE,
|
|
2192
|
+
jsxSource: DEFAULT_JSX_SOURCE_ATTRIBUTE,
|
|
2193
|
+
component: DEFAULT_COMPONENT_ATTRIBUTE
|
|
2196
2194
|
};
|
|
2197
2195
|
let projectRoot = normalizePath$1(options.projectRoot ?? "");
|
|
2198
2196
|
let devEnabled = options.enabled !== false;
|
|
@@ -2273,7 +2271,6 @@ function sculpted(options = {}) {
|
|
|
2273
2271
|
registerRuntimeModuleRoutes(nextServer, {
|
|
2274
2272
|
manifestEndpoint: endpoint,
|
|
2275
2273
|
editorMetadataEndpoint,
|
|
2276
|
-
globalName: options.runtime?.globalName,
|
|
2277
2274
|
runtimeBootstrapEndpoint,
|
|
2278
2275
|
runtimeModuleEndpoint,
|
|
2279
2276
|
uiModuleEndpoint,
|
package/docs/examples.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Example Apps
|
|
2
2
|
|
|
3
|
-
Sculpted includes minimal Vite + Panda CSS apps for
|
|
4
|
-
writeback while the package
|
|
3
|
+
Sculpted includes minimal Vite + Panda CSS apps for contributors who need to manually verify
|
|
4
|
+
inspector behavior and source writeback while developing the package.
|
|
5
5
|
|
|
6
6
|
## React
|
|
7
7
|
|
|
@@ -26,5 +26,5 @@ pnpm install
|
|
|
26
26
|
pnpm dev
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
These apps intentionally include edge cases and maintainer-focused checks. Most users should start
|
|
30
|
+
with the setup examples in the main README instead.
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
# Source Syntax Adapters
|
|
2
2
|
|
|
3
|
-
Sculpted can support non-standard source syntax when
|
|
4
|
-
the original authoring
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Sourcemaps are not the writeback authority. A future fallback may use sourcemaps to explain
|
|
8
|
-
generated-code provenance, but safe writes still require an original-source parser and patchable
|
|
9
|
-
target. If the adapter cannot provide stable original ranges for a source shape, Sculpted should
|
|
10
|
-
report that target as read-only.
|
|
3
|
+
Sculpted can support non-standard source syntax when that syntax can be parsed back to stable
|
|
4
|
+
locations in the original authoring file. Unsupported source shapes are shown as read-only instead
|
|
5
|
+
of guessed.
|
|
11
6
|
|
|
12
7
|
## TSRX Support
|
|
13
8
|
|
|
@@ -30,17 +25,6 @@ export default defineConfig({
|
|
|
30
25
|
})
|
|
31
26
|
```
|
|
32
27
|
|
|
33
|
-
When a config imports more than one syntax adapter, alias the TSRX export at the import site:
|
|
34
|
-
|
|
35
|
-
```ts
|
|
36
|
-
import { sourceSyntax as tsrx } from 'sculpted/tsrx'
|
|
37
|
-
|
|
38
|
-
sculpted({
|
|
39
|
-
include: ['src/**/*.{ts,tsx,tsrx,view}'],
|
|
40
|
-
sourceSyntax: [tsrx, customViewSyntax],
|
|
41
|
-
})
|
|
42
|
-
```
|
|
43
|
-
|
|
44
28
|
The supported TSRX authoring shape is a TSRX component with a static Panda `css({ ... })` object:
|
|
45
29
|
|
|
46
30
|
```ts
|
|
@@ -56,38 +40,11 @@ export function Card() {
|
|
|
56
40
|
TSRX support covers:
|
|
57
41
|
|
|
58
42
|
- static `css({ ... })` object literal analysis;
|
|
59
|
-
-
|
|
60
|
-
- existing literal
|
|
43
|
+
- element selection in the inspector;
|
|
44
|
+
- saving edits to existing literal values in the original `.tsrx` source.
|
|
61
45
|
|
|
62
46
|
TSRX support does not cover:
|
|
63
47
|
|
|
64
|
-
- direct `data-panda-*` metadata insertion;
|
|
65
48
|
- inline source creation;
|
|
66
49
|
- add, delete, or rename operations;
|
|
67
|
-
- generated TSX or sourcemap-based writeback
|
|
68
|
-
|
|
69
|
-
## Custom Adapters
|
|
70
|
-
|
|
71
|
-
Languages that can expose original source ranges can opt into the same writeback lane with a
|
|
72
|
-
`sourceSyntax` parser adapter. The option accepts one adapter or an ordered adapter list.
|
|
73
|
-
|
|
74
|
-
```ts
|
|
75
|
-
sculpted({
|
|
76
|
-
include: ['src/**/*.view'],
|
|
77
|
-
sourceSyntax: {
|
|
78
|
-
languageId: 'my-tsx-superset',
|
|
79
|
-
kind: 'typescript',
|
|
80
|
-
isSupportedFile: (file) => file.endsWith('.view'),
|
|
81
|
-
parse({ filePath, sourceText }) {
|
|
82
|
-
return {
|
|
83
|
-
kind: 'typescript',
|
|
84
|
-
languageId: 'my-tsx-superset',
|
|
85
|
-
sourceFile: parseToTypeScriptCompatibleSourceFile(filePath, sourceText),
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
})
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
Parser adapters must expose node ranges as offsets into the original authoring source text. Use
|
|
93
|
-
read-only failures for any syntax that cannot provide stable original ranges for a source shape.
|
|
50
|
+
- generated TSX or sourcemap-based writeback.
|
package/docs/source-writeback.md
CHANGED
|
@@ -31,17 +31,12 @@ Sculpted does not edit:
|
|
|
31
31
|
|
|
32
32
|
## Safety Model
|
|
33
33
|
|
|
34
|
-
Source writes are revalidated on the dev server before writing
|
|
34
|
+
Source writes are revalidated on the dev server before writing. Sculpted only writes to files inside
|
|
35
|
+
the configured project root, re-checks the current source before saving, and rejects stale source,
|
|
36
|
+
unsupported shapes, duplicate keys, parser errors, and unsafe paths.
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
- the patcher re-reads source and validates project-root containment;
|
|
39
|
-
- stale source hashes, unsupported source shapes, duplicate keys, parse errors, and path escapes are
|
|
40
|
-
rejected;
|
|
41
|
-
- batched saves apply same-file edits against one source snapshot before writing.
|
|
42
|
-
|
|
43
|
-
The UI saves immediately after clicking Save. The writeback endpoint still supports dry-run patch
|
|
44
|
-
responses with focused diffs for tests and tooling.
|
|
38
|
+
The UI saves immediately after clicking Save. If a save cannot be applied confidently, Sculpted
|
|
39
|
+
shows the failure instead of guessing at a source edit.
|
|
45
40
|
|
|
46
41
|
## Supported Edit Example
|
|
47
42
|
|
package/docs/vite-plugin.md
CHANGED
|
@@ -68,12 +68,8 @@ type InspectorVitePluginOptions = {
|
|
|
68
68
|
readonly panda?: {
|
|
69
69
|
readonly configPath?: string
|
|
70
70
|
readonly cssImportSources?: readonly string[]
|
|
71
|
-
readonly recipeImportSources?: readonly string[]
|
|
72
|
-
readonly cssFunctionNames?: readonly string[]
|
|
73
|
-
readonly cxFunctionNames?: readonly string[]
|
|
74
71
|
}
|
|
75
72
|
readonly manifest?: {
|
|
76
|
-
readonly outFile?: string
|
|
77
73
|
readonly virtualEndpoint?: string
|
|
78
74
|
}
|
|
79
75
|
readonly metadata?: {
|
|
@@ -81,13 +77,6 @@ type InspectorVitePluginOptions = {
|
|
|
81
77
|
}
|
|
82
78
|
readonly runtime?: {
|
|
83
79
|
readonly inject?: boolean
|
|
84
|
-
readonly globalName?: string
|
|
85
|
-
}
|
|
86
|
-
readonly attributes?: {
|
|
87
|
-
readonly editId?: string
|
|
88
|
-
readonly source?: string
|
|
89
|
-
readonly jsxSource?: string
|
|
90
|
-
readonly component?: string
|
|
91
80
|
}
|
|
92
81
|
readonly sourceSyntax?: SourceSyntaxOption
|
|
93
82
|
}
|
|
@@ -169,12 +158,6 @@ sculpted({
|
|
|
169
158
|
})
|
|
170
159
|
```
|
|
171
160
|
|
|
172
|
-
### Reserved Panda Options
|
|
173
|
-
|
|
174
|
-
`panda.recipeImportSources`, `panda.cssFunctionNames`, and `panda.cxFunctionNames` are part of the
|
|
175
|
-
public option type but are not wired into the Vite plugin implementation. Recipes, patterns,
|
|
176
|
-
`cva()`, and broader function-name customization are not supported.
|
|
177
|
-
|
|
178
161
|
### `manifest.virtualEndpoint`
|
|
179
162
|
|
|
180
163
|
Defaults to `/@sculpted/manifest`.
|
|
@@ -190,10 +173,6 @@ sculpted({
|
|
|
190
173
|
})
|
|
191
174
|
```
|
|
192
175
|
|
|
193
|
-
### `manifest.outFile`
|
|
194
|
-
|
|
195
|
-
Reserved. The option is typed but not wired into the Vite plugin implementation.
|
|
196
|
-
|
|
197
176
|
### `metadata.virtualEndpoint`
|
|
198
177
|
|
|
199
178
|
Defaults to `/@sculpted/editor-metadata`.
|
|
@@ -223,46 +202,10 @@ sculpted({
|
|
|
223
202
|
})
|
|
224
203
|
```
|
|
225
204
|
|
|
226
|
-
### `runtime.globalName`
|
|
227
|
-
|
|
228
|
-
Overrides the browser global name used by the installed runtime.
|
|
229
|
-
|
|
230
|
-
```ts
|
|
231
|
-
sculpted({
|
|
232
|
-
runtime: {
|
|
233
|
-
globalName: '__mySculptedRuntime',
|
|
234
|
-
},
|
|
235
|
-
})
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
### `attributes`
|
|
239
|
-
|
|
240
|
-
Overrides the DOM attributes used for inspector metadata.
|
|
241
|
-
|
|
242
|
-
Defaults:
|
|
243
|
-
|
|
244
|
-
- `editId`: `data-sculpted-edit-id`
|
|
245
|
-
- `source`: `data-sculpted-source`
|
|
246
|
-
- `jsxSource`: `data-sculpted-jsx-source`
|
|
247
|
-
- `component`: `data-sculpted-component`
|
|
248
|
-
|
|
249
|
-
Use these only when the defaults collide with app-specific tooling.
|
|
250
|
-
|
|
251
|
-
```ts
|
|
252
|
-
sculpted({
|
|
253
|
-
attributes: {
|
|
254
|
-
editId: 'data-dev-edit-id',
|
|
255
|
-
source: 'data-dev-source',
|
|
256
|
-
jsxSource: 'data-dev-jsx-source',
|
|
257
|
-
component: 'data-dev-component',
|
|
258
|
-
},
|
|
259
|
-
})
|
|
260
|
-
```
|
|
261
|
-
|
|
262
205
|
### `sourceSyntax`
|
|
263
206
|
|
|
264
|
-
Adds
|
|
265
|
-
|
|
207
|
+
Adds source parsing support for non-standard source syntax. Sculpted currently documents this for
|
|
208
|
+
the bundled TSRX adapter. See [source syntax adapters](source-syntax-adapters.md).
|
|
266
209
|
|
|
267
210
|
```ts
|
|
268
211
|
import { sourceSyntax } from 'sculpted/tsrx'
|
|
@@ -273,30 +216,8 @@ sculpted({
|
|
|
273
216
|
})
|
|
274
217
|
```
|
|
275
218
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
```ts
|
|
279
|
-
import { sourceSyntax as tsrx } from 'sculpted/tsrx'
|
|
280
|
-
|
|
281
|
-
sculpted({
|
|
282
|
-
include: ['src/**/*.{ts,tsx,tsrx,view}'],
|
|
283
|
-
sourceSyntax: [tsrx, customViewSyntax],
|
|
284
|
-
})
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
## Endpoint Defaults
|
|
288
|
-
|
|
289
|
-
These endpoint defaults are fixed unless an option above says otherwise:
|
|
290
|
-
|
|
291
|
-
- Manifest: `/@sculpted/manifest`
|
|
292
|
-
- Editor metadata: `/@sculpted/editor-metadata`
|
|
293
|
-
- Source writeback: `/@sculpted/writeback`
|
|
294
|
-
- Token writeback: `/@sculpted/token-writeback`
|
|
295
|
-
- Open source location: `/@sculpted/open-source`
|
|
296
|
-
- Style module route: `/@sculpted/style-module`
|
|
297
|
-
- Runtime bootstrap: `/@sculpted/runtime`
|
|
298
|
-
- Runtime module: `/@sculpted/runtime-module`
|
|
299
|
-
- UI module: `/@sculpted/ui-module`
|
|
219
|
+
## Development Routes
|
|
300
220
|
|
|
301
|
-
|
|
302
|
-
|
|
221
|
+
Sculpted reserves development-only routes under `/@sculpted/*`. The manifest and editor metadata
|
|
222
|
+
routes can be customized with `manifest.virtualEndpoint` and `metadata.virtualEndpoint`; other
|
|
223
|
+
routes are internal runtime details and should not be treated as public integration points.
|