@wildshard/sdk 0.2.12 → 0.3.0

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.
Files changed (72) hide show
  1. package/GUIDE.md +16 -11
  2. package/bin/wildshard.mjs +2 -1
  3. package/docs/api/EXPORT-TIERS.md +12 -3
  4. package/lint/export-tiers.json +9 -0
  5. package/lint/tile-bake-debt.json +26 -1
  6. package/package.json +17 -5
  7. package/scripts/build-shardfiles.mjs +7 -2
  8. package/scripts/preparation-preview.mjs +6 -1
  9. package/scripts/prepare-product.mjs +2 -2
  10. package/scripts/scratch-sweep.mjs +180 -0
  11. package/scripts/wildshard.mjs +1 -1
  12. package/skills/wildshard-mockup-to-model/SKILL.md +5 -3
  13. package/skills/wildshard-upgrade/SKILL.md +4 -4
  14. package/src/cli/help.ts +9 -5
  15. package/src/cli/upload/validate.ts +7 -5
  16. package/src/sharddev/assets.ts +1 -1
  17. package/src/sharddev/bake/compactGlb.ts +1 -1
  18. package/src/sharddev/bake/glbCompression.ts +1 -1
  19. package/src/sharddev/bake/gltfSource.ts +1 -1
  20. package/src/sharddev/bake/placeholders.ts +1 -1
  21. package/src/sharddev/bake/terrain.ts +1 -1
  22. package/src/sharddev/blobBytes.ts +1 -1
  23. package/src/sharddev/blobs.ts +2 -2
  24. package/src/sharddev/cli.ts +17 -4
  25. package/src/sharddev/formatJsonSchema.ts +1 -1
  26. package/src/sharddev/materialGraphFiles.ts +1 -1
  27. package/src/sharddev/newProject.ts +18 -10
  28. package/src/sharddev/outputProduct.ts +2 -2
  29. package/src/sharddev/productOutput.ts +2 -2
  30. package/src/sharddev/project.ts +1 -1
  31. package/src/sharddev/projectMap.ts +1 -1
  32. package/src/sharddev/refusals.ts +4 -2
  33. package/src/sharddev/reportCard.ts +1 -1
  34. package/src/sharddev/scene/author.ts +79 -0
  35. package/src/sharddev/scene/canvas.ts +213 -0
  36. package/src/sharddev/scene/description.ts +170 -0
  37. package/src/sharddev/scene/hash.ts +23 -0
  38. package/src/sharddev/scene/lower.ts +226 -0
  39. package/src/sharddev/scene/shard.ts +38 -0
  40. package/src/sharddev/scene/shardfile.ts +328 -0
  41. package/src/sharddev/threeGate.mjs +14 -0
  42. package/src/sharddev/threePin.mjs +40 -0
  43. package/src/sharddev/watch/page.ts +197 -0
  44. package/src/sharddev/watch/pageEntry.ts +23 -0
  45. package/src/sharddev/watch/proof.mjs +92 -0
  46. package/src/sharddev/watch/protocol.ts +108 -0
  47. package/src/sharddev/watch/socket.ts +57 -0
  48. package/src/sharddev/watch/watch.ts +209 -0
  49. package/src/shards/_template/card/landscape.jpg +0 -0
  50. package/src/shards/_template/card/portrait.jpg +0 -0
  51. package/src/shards/_template/card/thumb.jpg +0 -0
  52. package/src/shards/_template/data/card.json +21 -14
  53. package/src/shards/_template/data/clientScripts.json +27 -27
  54. package/src/shards/_template/data/creatures.json +5 -5
  55. package/src/shards/_template/data/encounters.json +2 -2
  56. package/src/shards/_template/data/layout.json +56 -25
  57. package/src/shards/_template/data/look.json +450 -220
  58. package/src/shards/_template/data/quests.json +2 -2
  59. package/src/shards/_template/data/water.json +131 -4
  60. package/src/shards/_template/generators/landscape.ts +19 -7
  61. package/src/shards/_template/generators/product.ts +7 -5
  62. package/src/shards/_template/generators/templatePropsSource.ts +3 -1
  63. package/src/shards/_template/generators/terrain.ts +28 -4
  64. package/src/shards/_template/generators/weather.ts +128 -0
  65. package/src/shards/_template/generators/world.ts +274 -98
  66. package/src/shards/_template/hero.json +6 -6
  67. package/src/shards/_template/manifest.json +21 -14
  68. package/src/shards/authoring-slice/generators/shard.ts +6 -0
  69. package/src/shards/authoring-slice/generators/textures.ts +173 -0
  70. package/src/shards/authoring-slice/generators/world.ts +415 -0
  71. package/src/shards/authoring-slice/shard.config.ts +7 -0
  72. package/src/shards/_template/assets/f2db05998615ce1cb79ea96be32c168842eb6a2b34ec01feb86d36404603ee54 +0 -0
@@ -1,10 +1,10 @@
1
1
  {
2
- "content": "e2447d207a4d8377654dbb02d1c70227db0e8d75920c4624fef3a6617c297755",
3
- "captured": "2026-11-13T06:51:06.351Z",
4
- "base": "http://127.0.0.1:4787",
2
+ "content": "da9e8f46215b485b582901179bf5823a2234362f6606c13e471412292d60e5f3",
3
+ "captured": "2026-11-14T01:06:36.105Z",
4
+ "base": "http://127.0.0.1:4473",
5
5
  "card": {
6
- "card/thumb.jpg": "dc9a8377361faa8bac9005387e4ef8a8e6a35ab987c72b50b756a65de8cf22cc",
7
- "card/portrait.jpg": "0c71efe0318e567c61c90b528b1bf5f617a99a213b08c6315ed0c5d28ebb6e43",
8
- "card/landscape.jpg": "8783b5913142480c3c91be78ab5bf35e72783c2ddbee114f4c6b6258c0f03809"
6
+ "card/thumb.jpg": "17bd4bb0ea1da525b384cd64d855a819185c7621155870c4b59d1f9b1400bab5",
7
+ "card/portrait.jpg": "fda8c38ef932b68653395ad6be1e463a42f5fbb87d10b2c2d587c2328ad339d4",
8
+ "card/landscape.jpg": "019a8a89659ce3620b838b7c564d4c25c5584f9d0175a21697b3084089834276"
9
9
  }
10
10
  }
@@ -30,8 +30,8 @@
30
30
  {
31
31
  "id": "hut",
32
32
  "name": "Grey hut",
33
- "x": 0,
34
- "z": -9,
33
+ "x": -4,
34
+ "z": -11.5,
35
35
  "r": 6
36
36
  },
37
37
  {
@@ -44,44 +44,51 @@
44
44
  {
45
45
  "id": "barrow-warden",
46
46
  "name": "Barrow Warden",
47
- "x": -18,
48
- "z": 16,
47
+ "x": 24.5,
48
+ "z": -2,
49
49
  "r": 8
50
50
  },
51
51
  {
52
52
  "id": "blob",
53
53
  "name": "Grey blob",
54
- "x": 0,
55
- "z": -19,
54
+ "x": 2.5,
55
+ "z": -16.5,
56
56
  "r": 4
57
57
  },
58
58
  {
59
59
  "id": "mossgate",
60
60
  "name": "Moss gate",
61
- "x": -9,
62
- "z": -5,
61
+ "x": -10,
62
+ "z": 0,
63
63
  "r": 3
64
64
  },
65
65
  {
66
66
  "id": "brazier-a",
67
67
  "name": "Brazier A",
68
- "x": -6.8,
69
- "z": -1.4,
68
+ "x": 5.9,
69
+ "z": -12.8,
70
70
  "r": 2
71
71
  },
72
72
  {
73
73
  "id": "brazier-c",
74
74
  "name": "Brazier C",
75
- "x": -6.6,
76
- "z": 10.7,
75
+ "x": 9.6,
76
+ "z": -5.4,
77
77
  "r": 2
78
78
  },
79
79
  {
80
80
  "id": "lamplighter",
81
81
  "name": "Lamplighter",
82
- "x": 2.6,
83
- "z": -2.2,
82
+ "x": 1.1,
83
+ "z": -6.4,
84
84
  "r": 2
85
+ },
86
+ {
87
+ "id": "pond",
88
+ "name": "Moss pond",
89
+ "x": -19.4,
90
+ "z": 0,
91
+ "r": 3
85
92
  }
86
93
  ],
87
94
  "assetGlobs": [
@@ -0,0 +1,6 @@
1
+ // AUTHORING-PARITY AP7: the slice is one scene module. `wildshard build` runs this as the shard's generator (the
2
+ // shardfile back end); `wildshard watch` calls its describe() and streams the parts to a running page.
3
+ import { defineShard } from '@wildshard/sdk/scene/shard';
4
+ import { buildSlice } from './world';
5
+
6
+ export const slice = defineShard({ slug: 'authoring-slice', name: 'Authoring Slice', author: 'Wildshard', revision: 1, seed: 357 }, buildSlice);
@@ -0,0 +1,173 @@
1
+ // Procedural textures, ported from the Mossgate cleanroom (mossgate-cleanroom eac5bb8 src/textures.js). The painters are the
2
+ // cleanroom's own lines; only `canvas()` / `new CanvasTexture(c)` became `paint` / `paintCanvas`, which run at compile time.
3
+ import type { DataTexture } from 'three';
4
+ import { paint } from '@wildshard/sdk/scene/author';
5
+ import { paintCanvas, type PaintContext } from '@wildshard/sdk/scene/canvas';
6
+
7
+ export function rng(seed = 1): () => number {
8
+ let s = seed >>> 0;
9
+ return () => {
10
+ s = (s + 0x6d2b79f5) >>> 0;
11
+ let t = s;
12
+ t = Math.imul(t ^ (t >>> 15), t | 1);
13
+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
14
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
15
+ };
16
+ }
17
+
18
+ export interface Noise { (x: number, y: number): number; fbm: (x: number, y: number, oct?: number) => number }
19
+ // Smooth value noise, 2D, tileable over `period`.
20
+ export function makeNoise(seed = 7): Noise {
21
+ const r = rng(seed);
22
+ const N = 256;
23
+ const g = new Float32Array(N * N);
24
+ for (let i = 0; i < g.length; i++) g[i] = r();
25
+ const at = (x: number, y: number): number => g[((y & (N - 1)) * N) + (x & (N - 1))] ?? 0;
26
+ const sm = (t: number): number => t * t * (3 - 2 * t);
27
+ const n = (x: number, y: number): number => {
28
+ const xi = Math.floor(x), yi = Math.floor(y);
29
+ const xf = sm(x - xi), yf = sm(y - yi);
30
+ const a = at(xi, yi), b = at(xi + 1, yi), c = at(xi, yi + 1), d = at(xi + 1, yi + 1);
31
+ return a + (b - a) * xf + (c - a) * yf + (a - b - c + d) * xf * yf;
32
+ };
33
+ const fbm = (x: number, y: number, oct = 4): number => {
34
+ let s = 0, amp = 0.5, f = 1;
35
+ for (let i = 0; i < oct; i++) { s += amp * n(x * f, y * f); amp *= 0.5; f *= 2; }
36
+ return s;
37
+ };
38
+ return Object.assign(n, { fbm });
39
+ }
40
+
41
+ type Rgb = [number, number, number];
42
+ const mix = (a: number, b: number, t: number): number => a + (b - a) * t;
43
+ const mix3 = (a: readonly number[], b: readonly number[], t: number): Rgb => [mix(a[0] ?? 0, b[0] ?? 0, t), mix(a[1] ?? 0, b[1] ?? 0, t), mix(a[2] ?? 0, b[2] ?? 0, t)];
44
+ const clamp = (v: number, lo = 0, hi = 1): number => Math.max(lo, Math.min(hi, v));
45
+
46
+ // Weathered warm-grey stone with moss blotches and edge darkening.
47
+ export function stone(seed = 3, { moss = 0.35 } = {}): DataTexture {
48
+ const n = makeNoise(seed);
49
+ const S = 512;
50
+ const g1 = [106, 102, 94], g2 = [150, 145, 134], mossC = [84, 104, 38];
51
+ return paint(S, S, (u, v) => {
52
+ const a = n.fbm(u * 8, v * 8, 5);
53
+ const sp = n(u * 120, v * 120);
54
+ let col = mix3(g1, g2, clamp(a * 1.6 - 0.3));
55
+ col = col.map((x) => x * (0.85 + sp * 0.25)) as Rgb;
56
+ // cracks
57
+ const cr = Math.abs(n.fbm(u * 6 + 5, v * 6 + 2, 3) - 0.5);
58
+ if (cr < 0.012) col = col.map((x) => x * 0.6) as Rgb;
59
+ // moss: favours the top of a face (v small)
60
+ const m = n.fbm(u * 10 + 3, v * 10 + 7, 4) + (1 - v) * 0.25 * moss * 2;
61
+ const t = clamp((m - (1 - moss)) * 6);
62
+ col = mix3(col, mossC.map((x) => x * (0.8 + sp * 0.4)), t);
63
+ // edge darkening for bevel read
64
+ const e = Math.min(u, v, 1 - u, 1 - v);
65
+ const ed = clamp(e * 18, 0.7, 1);
66
+ return col.map((x) => x * ed);
67
+ });
68
+ }
69
+
70
+ // Flat slab stone for the path: lighter, pink-grey, no moss on top.
71
+ export function slab(): DataTexture {
72
+ const n = makeNoise(21);
73
+ const S = 256;
74
+ return paint(S, S, (u, v) => {
75
+ const a = n.fbm(u * 6, v * 6, 4);
76
+ const sp = n(u * 90, v * 90);
77
+ const col = mix3([126, 120, 110], [164, 156, 142], clamp(a * 1.5 - 0.2));
78
+ const e = Math.min(u, v, 1 - u, 1 - v);
79
+ const ed = clamp(e * 14, 0.72, 1);
80
+ return col.map((x) => x * (0.88 + sp * 0.2) * ed);
81
+ });
82
+ }
83
+
84
+ export function wood(): DataTexture {
85
+ const n = makeNoise(5);
86
+ const S = 256;
87
+ return paint(S, S, (u, v) => {
88
+ const grain = n(u * 4, v * 60) * 0.6 + n(u * 2, v * 140) * 0.4;
89
+ return mix3([84, 58, 38], [138, 98, 62], grain);
90
+ });
91
+ }
92
+
93
+ export function shingle(): DataTexture {
94
+ const n = makeNoise(9);
95
+ const S = 256;
96
+ return paint(S, S, (u, v) => {
97
+ const a = n.fbm(u * 8, v * 8, 4);
98
+ const sp = n(u * 100, v * 100);
99
+ let col = mix3([104, 96, 78], [128, 120, 96], a);
100
+ col = mix3(col, [112, 130, 50], clamp((n.fbm(u * 5 + 3, v * 5, 3) - 0.5) * 3));
101
+ return col.map((x) => x * (0.85 + sp * 0.3));
102
+ });
103
+ }
104
+
105
+ // Painted floor/wall stencil ("A", "3x3"), white on transparent.
106
+ export function stencil(text: string, { w = 256, h = 128, font = 'bold 96px monospace', alpha = 0.75 } = {}): DataTexture {
107
+ return paintCanvas(w, h, (ctx) => {
108
+ ctx.clearRect(0, 0, w, h);
109
+ ctx.fillStyle = `rgba(235,228,214,${alpha})`;
110
+ ctx.font = font;
111
+ ctx.textAlign = 'center';
112
+ ctx.textBaseline = 'middle';
113
+ ctx.fillText(text, w / 2, h / 2 + 4);
114
+ // scuff it
115
+ const r = rng(text.length * 31);
116
+ ctx.globalCompositeOperation = 'destination-out';
117
+ for (let i = 0; i < 260; i++) {
118
+ ctx.fillStyle = `rgba(0,0,0,${r() * 0.6})`;
119
+ ctx.fillRect(r() * w, r() * h, 1 + r() * 4, 1 + r() * 3);
120
+ }
121
+ });
122
+ }
123
+
124
+ // Soft round glow sprite.
125
+ export function glow(): DataTexture {
126
+ return paintCanvas(128, 128, (ctx) => {
127
+ const g = ctx.createRadialGradient(64, 64, 0, 64, 64, 64);
128
+ g.addColorStop(0, 'rgba(255,240,200,1)');
129
+ g.addColorStop(0.25, 'rgba(255,190,90,0.6)');
130
+ g.addColorStop(1, 'rgba(255,140,40,0)');
131
+ ctx.fillStyle = g;
132
+ ctx.fillRect(0, 0, 128, 128);
133
+ });
134
+ }
135
+
136
+ // Ivy strand: a wavy stem with heart-shaped leaves, top to bottom.
137
+ export function ivy(): DataTexture {
138
+ return paintCanvas(128, 512, (ctx: PaintContext) => {
139
+ ctx.clearRect(0, 0, 128, 512);
140
+ const r = rng(13);
141
+ ctx.strokeStyle = '#4a5a22'; ctx.lineWidth = 3;
142
+ ctx.beginPath(); ctx.moveTo(64, 0);
143
+ for (let y = 0; y <= 512; y += 16) ctx.lineTo(64 + Math.sin(y / 40) * 14, y);
144
+ ctx.stroke();
145
+ for (let y = 8; y < 500; y += 13) {
146
+ const x = 64 + Math.sin(y / 40) * 14, s = r() < 0.5 ? -1 : 1, sz = 10 + r() * 9 - y / 120;
147
+ const l = 0.7 + r() * 0.4;
148
+ ctx.fillStyle = `rgb(${Math.round(92 * l)},${Math.round(128 * l)},${Math.round(40 * l)})`;
149
+ ctx.save(); ctx.translate(x + s * sz * 0.8, y); ctx.rotate(s * (0.4 + r() * 0.6));
150
+ ctx.beginPath(); ctx.moveTo(0, -sz * 0.2);
151
+ ctx.bezierCurveTo(sz, -sz, sz * 1.1, sz * 0.4, 0, sz); ctx.bezierCurveTo(-sz * 1.1, sz * 0.4, -sz, -sz, 0, -sz * 0.2);
152
+ ctx.fill(); ctx.restore();
153
+ }
154
+ });
155
+ }
156
+
157
+ // Hanging moss: shaggy strands, dense at the top, thinning to wisps.
158
+ export function hangingMoss(): DataTexture {
159
+ return paintCanvas(256, 256, (ctx) => {
160
+ ctx.clearRect(0, 0, 256, 256);
161
+ const r = rng(29);
162
+ for (let i = 0; i < 90; i++) {
163
+ const x = r() * 256, len = 40 + r() * 200 * r(), w = 3 + r() * 6;
164
+ const l = 0.75 + r() * 0.35;
165
+ const g = ctx.createLinearGradient(0, 0, 0, len);
166
+ g.addColorStop(0, `rgba(${Math.round(98 * l)},${Math.round(118 * l)},${Math.round(40 * l)},1)`);
167
+ g.addColorStop(1, `rgba(${Math.round(130 * l)},${Math.round(142 * l)},${Math.round(60 * l)},0)`);
168
+ ctx.fillStyle = g;
169
+ ctx.beginPath(); ctx.moveTo(x - w, 0); ctx.quadraticCurveTo(x + (r() - 0.5) * 10, len * 0.6, x + (r() - 0.5) * 8, len); ctx.lineTo(x + w, 0); ctx.fill();
170
+ }
171
+ ctx.fillStyle = 'rgb(84,104,36)'; ctx.fillRect(0, 0, 256, 10);
172
+ });
173
+ }