Skip to content

Commit 7e561e7

Browse files
committed
refactor(json): replace json-to-ast with @socketsecurity/json wasm
json-to-ast was the JS dep used to parse package.json with location info for hover/diagnostic ranges. Replaced with the new Rust+WASM JSON parser (vendored under vendor/json-wasm/, mirroring the acorn-wasm pattern) — same byte-span surface, smaller wasm, faster parse. Adapter changes in parse-externals.ts: - jsonToAST(src, { loc: true }) → parseJson(src).root - pkg.children / .Property → .members - Array.children → .items - Literal type+value branches → typed scalar arms - loc.start/end (line, column) → byte spans + buildLineTable + spanToRange (binary-search line-start lookup) Bundle: 4.2MB → 4.1MB. Smoke test passes. Drops the json-to-ast + @types/json-to-ast deps; adds workspace pkg vendor/json-wasm.
1 parent 77c14d4 commit 7e561e7

11 files changed

Lines changed: 433 additions & 110 deletions

File tree

assets/README.md

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ marketplace icon, web page favicon, README banner, …).
88

99
### SVG variants
1010

11-
| File | Layers | Color | viewBox |
12-
|---|---|---|---|
13-
| `socket-icon.svg` | 1 (bolt is a cutout) | `currentColor` | `0 0 181.41 240` |
14-
| `socket-icon-square.svg` | 1 | `currentColor` | `-29.295 0 240 240` |
15-
| `socket-icon-shield.svg` | 2 (shield + bolt) | shield: `currentColor`, bolt: `#fff` | `0 0 181.41 240` |
16-
| `socket-icon-shield-square.svg` | 2 | shield: `currentColor`, bolt: `#fff` | `-29.295 0 240 240` |
17-
| `socket-icon-brand.svg`| 2 | shield: pink→purple gradient, bolt: `#fff` | `0 0 181.41 240` |
18-
| `socket-icon-brand-square.svg`| 2 | shield: pink→purple gradient, bolt: `#fff` | `-29.295 0 240 240` |
11+
| File | Layers | Color | viewBox |
12+
| -------------------------------- | -------------------- | ------------------------------------------ | ------------------- |
13+
| `socket-icon.svg` | 1 (bolt is a cutout) | `currentColor` | `0 0 181.41 240` |
14+
| `socket-icon-square.svg` | 1 | `currentColor` | `-29.295 0 240 240` |
15+
| `socket-icon-shield.svg` | 2 (shield + bolt) | shield: `currentColor`, bolt: `#fff` | `0 0 181.41 240` |
16+
| `socket-icon-shield-square.svg` | 2 | shield: `currentColor`, bolt: `#fff` | `-29.295 0 240 240` |
17+
| `socket-icon-brand.svg` | 2 | shield: pink→purple gradient, bolt: `#fff` | `0 0 181.41 240` |
18+
| `socket-icon-brand-square.svg`| 2 | shield: pink→purple gradient, bolt: `#fff` | `-29.295 0 240 240` |
1919

2020
### Wordmark variants (shield + "Socket" text, 840×240 landscape)
2121

22-
| File | Layers | viewBox |
23-
|---|---|---|
22+
| File | Layers | viewBox |
23+
| ----------------------- | --------------------------------------------------- | ------------- |
2424
| `socket-logo-light.svg` | shield (gradient) + bolt (white) + text (slate-900) | `0 0 840 240` |
25-
| `socket-logo-dark.svg` | shield (gradient) + bolt (white) + text (slate-50) | `0 0 840 240` |
25+
| `socket-logo-dark.svg` | shield (gradient) + bolt (white) + text (slate-50) | `0 0 840 240` |
2626

2727
"Light" and "dark" refer to the **page background** the wordmark sits
2828
on — light wordmark has dark text (for use on white/light bg); dark
@@ -33,32 +33,38 @@ color-scheme preference:
3333

3434
```html
3535
<picture>
36-
<source media="(prefers-color-scheme: dark)" srcset="assets/socket-logo-dark-840.png">
37-
<source media="(prefers-color-scheme: light)" srcset="assets/socket-logo-light-840.png">
38-
<img alt="Socket" width="420" src="assets/socket-logo-light-840.png">
36+
<source
37+
media="(prefers-color-scheme: dark)"
38+
srcset="assets/socket-logo-dark-840.png"
39+
/>
40+
<source
41+
media="(prefers-color-scheme: light)"
42+
srcset="assets/socket-logo-light-840.png"
43+
/>
44+
<img alt="Socket" width="420" src="assets/socket-logo-light-840.png" />
3945
</picture>
4046
```
4147

4248
### PNG variants
4349

4450
Brand-square (favicons + marketplace listing):
4551

46-
| File | Use |
47-
|---|---|
48-
| `socket-icon-brand-16.png` | Favicon (small) |
49-
| `socket-icon-brand-32.png` | Favicon (standard) |
50-
| `socket-icon-brand-64.png` | README badges, GitHub social previews |
51-
| `socket-icon-brand-128.png` | Docs, OG cards |
52-
| `socket-icon-brand-256.png` | VSCode marketplace listing |
53-
| `socket-icon-brand-512.png` | High-DPI, hero images, press kit |
52+
| File | Use |
53+
| --------------------------- | ------------------------------------- |
54+
| `socket-icon-brand-16.png` | Favicon (small) |
55+
| `socket-icon-brand-32.png` | Favicon (standard) |
56+
| `socket-icon-brand-64.png` | README badges, GitHub social previews |
57+
| `socket-icon-brand-128.png` | Docs, OG cards |
58+
| `socket-icon-brand-256.png` | VSCode marketplace listing |
59+
| `socket-icon-brand-512.png` | High-DPI, hero images, press kit |
5460

5561
Wordmark (README hero banners, in light/dark pairs):
5662

57-
| File | Width | Use |
58-
|---|---|---|
59-
| `socket-logo-{light,dark}-420.png` | 420×120 | README hero (1× display) |
60-
| `socket-logo-{light,dark}-840.png` | 840×240 | README hero (2× / Retina) |
61-
| `socket-logo-{light,dark}-1680.png` | 1680×480 | Press kit, hero images |
63+
| File | Width | Use |
64+
| ----------------------------------- | -------- | ------------------------- |
65+
| `socket-logo-{light,dark}-420.png` | 420×120 | README hero (1× display) |
66+
| `socket-logo-{light,dark}-840.png` | 840×240 | README hero (2× / Retina) |
67+
| `socket-logo-{light,dark}-1680.png` | 1680×480 | Press kit, hero images |
6268

6369
## Variant semantics
6470

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,11 @@
118118
"@vscode/python-extension": "1.0.6",
119119
"acorn-wasm": "workspace:*",
120120
"ini": "6.0.0",
121-
"json-to-ast": "2.1.0",
121+
"json-wasm": "workspace:*",
122122
"toml-eslint-parser": "1.0.3"
123123
},
124124
"devDependencies": {
125125
"@types/ini": "4.1.1",
126-
"@types/json-to-ast": "2.1.4",
127126
"@types/node": "catalog:",
128127
"@types/vscode": "1.118.0",
129128
"@typescript/native-preview": "7.0.0-dev.20260415.1",

pnpm-lock.yaml

Lines changed: 5 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
# Register .claude/hooks/* as workspace packages so taze (run via
66
# `pnpm run update`) sees and bumps their package.json manifests
77
# alongside the root. Keeps hook deps in lockstep with the parent.
8-
# vendor/acorn-wasm is registered too so the bundle imports it as a
9-
# package by name (acorn-wasm) rather than via a brittle relative
10-
# `.mts` path that tsc/tsgo refuse without allowImportingTsExtensions.
8+
# vendor/acorn-wasm + vendor/json-wasm are registered too so the
9+
# bundle imports them as packages by name rather than via brittle
10+
# relative `.mts` paths that tsc/tsgo refuse without
11+
# allowImportingTsExtensions.
1112
packages:
1213
- .claude/hooks/*
1314
- vendor/acorn-wasm
15+
- vendor/json-wasm
1416

1517
# Catalog entries shared across hook workspaces. Pinning them here
1618
# keeps the entire hook tree in lockstep with the parent without each

scripts/lockstep.mts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ function loadManifestTree(rootManifestPath: string): {
184184
for (const rel of includes) {
185185
const subPath = path.resolve(baseDir, rel)
186186
const sub = readManifest(subPath)
187-
const area = sub.area ?? path.basename(rel, '.json').replace(/^lockstep-/, '')
187+
const area =
188+
sub.area ?? path.basename(rel, '.json').replace(/^lockstep-/, '')
188189
areas.push({ area, manifest: sub })
189190
}
190191

scripts/socket-repo-template-emit-schema.mts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ const rootDir = path.resolve(__dirname, '..')
2323
// Schema lives in `.config/` next to the per-repo
2424
// `.config/socket-repo-template.json` it describes — the marker's
2525
// `$schema` ref is `./socket-repo-template-schema.json`.
26-
const outPath = path.join(rootDir, '.config', 'socket-repo-template-schema.json')
26+
const outPath = path.join(
27+
rootDir,
28+
'.config',
29+
'socket-repo-template-schema.json',
30+
)
2731

2832
const enriched = {
2933
$schema: 'https://json-schema.org/draft/2020-12/schema',

0 commit comments

Comments
 (0)