@wildshard/sdk 0.2.11 → 0.2.13

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/GUIDE.md CHANGED
@@ -104,6 +104,11 @@ hero:
104
104
  Build then refuses a shard file whose content changed after the hero was stamped (`hero-stale`), and upload refuses a
105
105
  new version whose hero is the same as the previous version's (`hero-unchanged`). Section 6 has every hero refusal.
106
106
 
107
+ **A curated hero** is hand-picked art, not a capture. Put `"curated": true` in `hero.json` and the art is kept: after a
108
+ content change, `wildshard hero . --stamp-existing` re-stamps the images already there, and `wildshard hero . --base`
109
+ refuses rather than shoot the spawn view over them. A new version still needs a new picture (`hero-unchanged`): swap
110
+ the art, then `--stamp-existing`. Remove `curated` to capture again.
111
+
107
112
  ### Uploading
108
113
 
109
114
  An upload sends one shard file to the API (`https://api.wildshard.io`) and names its channel. Do these in order,
@@ -498,7 +503,8 @@ Codes `declared-costs`, `performance-targets` (shard-format checking the costs t
498
503
 
499
504
  The shard's content changed after its hero was captured, or the card names images `hero.json` has no stamp for. The
500
505
  hero must show the current world: capture it again (`wildshard hero . --base <url>`). Only if the images already show
501
- the current world, `wildshard hero . --stamp-existing`.
506
+ the current world, `wildshard hero . --stamp-existing`. A curated hero (`"curated": true` in `hero.json`, "The hero")
507
+ keeps its art: re-stamp it with `wildshard hero . --stamp-existing`.
502
508
 
503
509
  #### hero-not-in-product
504
510
 
@@ -1,7 +1,32 @@
1
1
  {
2
2
  "version": 1,
3
3
  "products": {
4
- "_template": {},
4
+ "_template": {
5
+ "tile/0/3/3/resident": 5250188,
6
+ "tile/0/3/3/compressed": 2569008,
7
+ "tile/0/3/3/draws": 11,
8
+ "tile/0/3/4/compressed": 1541492,
9
+ "tile/0/4/3/compressed": 1939692,
10
+ "tile/0/4/3/draws": 10,
11
+ "tile/0/4/4/compressed": 1388148,
12
+ "tile/1/2/1/compressed": 253704,
13
+ "window/2/2/compressed": 8463160,
14
+ "window/2/3/compressed": 8432224,
15
+ "window/2/4/compressed": 8472284,
16
+ "window/2/5/compressed": 8512940,
17
+ "window/3/2/compressed": 8412040,
18
+ "window/3/3/compressed": 8441060,
19
+ "window/3/4/compressed": 8454888,
20
+ "window/3/5/compressed": 8456068,
21
+ "window/4/2/compressed": 8435332,
22
+ "window/4/3/compressed": 8479180,
23
+ "window/4/4/compressed": 8444912,
24
+ "window/4/5/compressed": 8412132,
25
+ "window/5/2/compressed": 8420460,
26
+ "window/5/3/compressed": 8430040,
27
+ "window/5/4/compressed": 8401416,
28
+ "window/5/5/compressed": 8401560
29
+ },
5
30
  "blender-template": {
6
31
  "missing/0/0/0": 1,
7
32
  "missing/0/0/1": 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildshard/sdk",
3
- "version": "0.2.11",
3
+ "version": "0.2.13",
4
4
  "description": "The author's toolbox: the `wildshard` CLI that bakes shard source into a shardfile, the author SDK, the local dev server (engine client against engine server), the explorers, arena and drafts tool.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -84,7 +84,7 @@
84
84
  "@typescript/typescript6": "6.0.2",
85
85
  "@valibot/to-json-schema": "1.8.0",
86
86
  "@wildshard/engine": "0.1.18",
87
- "@wildshard/format": "npm:@wildshard/shard-format@0.4.9",
87
+ "@wildshard/format": "npm:@wildshard/shard-format@0.4.10",
88
88
  "ajv": "6.15.0",
89
89
  "assemblyscript": "0.28.20",
90
90
  "binaryen": "132.0.0",
@@ -198,7 +198,7 @@
198
198
  "overrides": {
199
199
  "binaryen": "npm:@pre-bundled/binaryen@132.0.0-patch-1",
200
200
  "assemblyscript>binaryen": "npm:@pre-bundled/binaryen@131.0.0-nightly.20260721-patch-1",
201
- "@wildshard/format": "npm:@wildshard/shard-format@0.4.9"
201
+ "@wildshard/format": "npm:@wildshard/shard-format@0.4.10"
202
202
  }
203
203
  },
204
204
  "exports": {
@@ -81,6 +81,11 @@ async function selectCard(page, base, name) {
81
81
  }
82
82
 
83
83
  export async function captureHero(shard, given, { name = servedName(shard), log = console.info } = {}) {
84
+ // A curated card (hero.json "curated": true) is hand-picked art: a capture would put the spawn view over it.
85
+ const stampPath = join(shard, 'hero.json');
86
+ if (existsSync(stampPath) && JSON.parse(readFileSync(stampPath, 'utf8')).curated === true) {
87
+ throw new Error(`${stampPath}: this hero is curated ("curated": true), hand-picked art that is never recaptured; re-stamp it for new content with \`wildshard hero <source> --stamp-existing\`, or remove "curated" to capture this view`);
88
+ }
84
89
  const base = servedRoot(given);
85
90
  // Loaded here, so --stamp-existing needs no browser or engine to resolve.
86
91
  const [{ chromium }, { NAME_ASKED, saveFixture }, { KEYCHAIN_ARGS }] = await Promise.all([
@@ -25,6 +25,10 @@ export async function preparationPreview(client,dir,{clientPage}){
25
25
  const recorded=existsSync(resolve(dir,'programs',`${slug}.json`));
26
26
  const page=clientPage(readFileSync(resolve(client,'index.html'),'utf8'),header.trim().replaceAll('<','\\u003c'),slug,recorded);
27
27
  const shardRoot=`/shardfiles/${slug}/`;
28
+ // S12f: the candidate's mounts (its discovery.json under mounts/shardfiles/<slug>/, the public files it owns) are
29
+ // served at their URLs from where cook.json says the product keeps them (mounts/, or the blob with the same bytes).
30
+ const cook=existsSync(resolve(dir,'cook.json'))?JSON.parse(readFileSync(resolve(dir,'cook.json'),'utf8')):{};
31
+ const mounts=new Map((Array.isArray(cook.mounts)?cook.mounts:[]).filter(row=>typeof row?.url==='string'&&typeof row.path==='string').map(row=>[row.url,row.path]));
28
32
  const server=createServer((request,response)=>{
29
33
  response.setHeader('Cache-Control','no-store');
30
34
  try{
@@ -33,7 +37,8 @@ export async function preparationPreview(client,dir,{clientPage}){
33
37
  if(path==='/'||path==='/index.html'){response.setHeader('Content-Type','text/html');response.end(request.method==='HEAD'?undefined:page);return;}
34
38
  // The inline product reads beside the page, as `wildshard build` lays the client over the product folder (the
35
39
  // client's file wins); the in-page server reads where a release serves the shard.
36
- const file=path.startsWith(shardRoot)?inside(dir,path.slice(shardRoot.length)):inside(client,path.slice(1))??inside(dir,path.slice(1));
40
+ const mounted=mounts.get(path);
41
+ const file=mounted!==undefined?inside(dir,mounted):path.startsWith(shardRoot)?inside(dir,path.slice(shardRoot.length)):inside(client,path.slice(1))??inside(dir,path.slice(1));
37
42
  if(file===undefined){response.writeHead(404);response.end();return;}
38
43
  response.setHeader('Content-Type',MIME[extname(file)]??'application/octet-stream');
39
44
  if(request.method==='HEAD')response.end();else createReadStream(file).on('error',()=>{response.destroy();}).pipe(response);
@@ -91,7 +91,13 @@ async function stampExistingHero(shard: string): Promise<Adopted> {
91
91
  if (hero.state === 'fresh') {
92
92
  return { written: false, content: hero.content }
93
93
  }
94
- if (hero.stamped !== undefined && hero.stamped !== hero.content) {
94
+ // A curated hero (hero.json "curated": true) is hand-picked art that no
95
+ // spawn-view capture should replace: it is re-stamped over new content.
96
+ if (
97
+ hero.curated !== true &&
98
+ hero.stamped !== undefined &&
99
+ hero.stamped !== hero.content
100
+ ) {
95
101
  throw new Error(
96
102
  `the hero of ${path.basename(shard)} was stamped for other content (captured ${hero.captured ?? 'at an unknown time'}); the world has changed since, so only a capture fixes it, nothing stamped`,
97
103
  )
@@ -71,6 +71,9 @@ function refusal(shard: string, hero: HeroState): string {
71
71
  const name = path.basename(shard)
72
72
  const capture = `serve this candidate in an engine build, then capture it: ${captureCommand(shard)}`
73
73
  const adopt = `; or, only if the images already there show this content, stamp them with no capture: ${stampExistingCommand(shard)}`
74
+ if (hero.curated === true) {
75
+ return `the hero of ${name} is curated (${STAMP} "curated": true) and its stamp does not match this content or these images; keep the art and re-stamp it with no capture: ${stampExistingCommand(shard)}`
76
+ }
74
77
  if (hero.state === 'unstamped') {
75
78
  return `the hero of ${name} has no ${STAMP} stamp, so nothing says it shows this content; ${capture}${adopt}`
76
79
  }
@@ -20,22 +20,12 @@ const MANIFEST = 'manifest.json'
20
20
  const SLOTS = ['thumb', 'portrait', 'landscape'] as const
21
21
  // Generated, ignored, test or prose files are not the world a hero shows.
22
22
  // The directories are skipped at the shard folder's top level only.
23
- const SKIPPED_DIRECTORIES = new Set([
24
- '.cache',
25
- '.git',
26
- '.worktrees',
27
- 'dist',
28
- 'node_modules',
29
- 'public',
30
- 'tmp',
31
- ])
32
- const SKIPPED_SUFFIXES = [
33
- '.generated.ts',
34
- '.test.ts',
35
- '.test.mjs',
36
- '.md',
37
- '.DS_Store',
38
- ]
23
+ const SKIPPED_DIRECTORIES = new Set(
24
+ '.cache .git .worktrees dist node_modules public tmp'.split(' '),
25
+ )
26
+ const SKIPPED_SUFFIXES = '.generated.ts .test.ts .test.mjs .md .DS_Store'.split(
27
+ ' ',
28
+ )
39
29
  const NOT_FOUND = 'ENOENT'
40
30
  const VALUE = 1
41
31
  const NONE = 0
@@ -52,6 +42,7 @@ interface HeroState {
52
42
  readonly stamped?: string | undefined
53
43
  /** When the stamp says the hero was captured. */
54
44
  readonly captured?: string | undefined
45
+ readonly curated?: boolean | undefined
55
46
  }
56
47
 
57
48
  interface HeroStamp {
@@ -60,6 +51,8 @@ interface HeroStamp {
60
51
  readonly base: string
61
52
  readonly card: Readonly<Record<string, string>>
62
53
  readonly camera?: unknown
54
+ /** `"curated": true`: hand-picked art, re-stamped, never recaptured. */
55
+ readonly curated?: true
63
56
  }
64
57
 
65
58
  function sha256(bytes: Readonly<Uint8Array> | string): string {
@@ -242,16 +235,21 @@ async function heroState(shard: string): Promise<HeroState> {
242
235
  return { state: 'generated', content }
243
236
  }
244
237
  const stamp = await readStamp(shard)
238
+ const curated = field(stamp, 'curated') === true
245
239
  const stamped = field(stamp, 'content')
246
240
  if (typeof stamped !== 'string') {
247
- return { state: 'unstamped', content }
241
+ return { state: 'unstamped', content, curated }
248
242
  }
249
- const same = sameCard(field(stamp, 'card'), await cardHashes(shard))
250
243
  return {
251
- state: stamped === content && same ? 'fresh' : 'stale',
244
+ state:
245
+ stamped === content &&
246
+ sameCard(field(stamp, 'card'), await cardHashes(shard))
247
+ ? 'fresh'
248
+ : 'stale',
252
249
  content,
253
250
  stamped,
254
251
  captured: textOf(field(stamp, 'captured')),
252
+ curated,
255
253
  }
256
254
  }
257
255
 
@@ -262,12 +260,14 @@ async function writeHeroStamp(
262
260
  ): Promise<HeroStamp> {
263
261
  const previous = await readStamp(shard)
264
262
  const camera = options.camera ?? field(previous, 'camera')
263
+ const curated = field(previous, 'curated') === true
265
264
  const stamp: HeroStamp = {
266
265
  content: await heroContentHash(shard),
267
266
  captured: options.captured ?? new Date().toISOString(),
268
267
  base: options.base,
269
268
  card: await cardHashes(shard),
270
269
  ...(camera === undefined ? {} : { camera }),
270
+ ...(curated ? { curated: true } : {}),
271
271
  }
272
272
  const partial = path.join(shard, `${STAMP}.${randomUUID()}.partial`)
273
273
  try {
Binary file
@@ -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": [
@@ -308,9 +308,9 @@
308
308
  "kind": "particles",
309
309
  "id": "template.warden-ring.1",
310
310
  "at": [
311
- -18.0,
311
+ 24.5,
312
312
  0.2,
313
- 19.5
313
+ 1.5
314
314
  ]
315
315
  },
316
316
  "reads": [
@@ -359,9 +359,9 @@
359
359
  "kind": "particles",
360
360
  "id": "template.warden-ring.2",
361
361
  "at": [
362
- -16.25,
362
+ 26.25,
363
363
  0.2,
364
- 19.031
364
+ 1.031
365
365
  ]
366
366
  },
367
367
  "reads": [
@@ -410,9 +410,9 @@
410
410
  "kind": "particles",
411
411
  "id": "template.warden-ring.3",
412
412
  "at": [
413
- -14.969,
413
+ 27.531,
414
414
  0.2,
415
- 17.75
415
+ -0.25
416
416
  ]
417
417
  },
418
418
  "reads": [
@@ -461,9 +461,9 @@
461
461
  "kind": "particles",
462
462
  "id": "template.warden-ring.4",
463
463
  "at": [
464
- -14.5,
464
+ 28.0,
465
465
  0.2,
466
- 16.0
466
+ -2.0
467
467
  ]
468
468
  },
469
469
  "reads": [
@@ -512,9 +512,9 @@
512
512
  "kind": "particles",
513
513
  "id": "template.warden-ring.5",
514
514
  "at": [
515
- -14.969,
515
+ 27.531,
516
516
  0.2,
517
- 14.25
517
+ -3.75
518
518
  ]
519
519
  },
520
520
  "reads": [
@@ -563,9 +563,9 @@
563
563
  "kind": "particles",
564
564
  "id": "template.warden-ring.6",
565
565
  "at": [
566
- -16.25,
566
+ 26.25,
567
567
  0.2,
568
- 12.969
568
+ -5.031
569
569
  ]
570
570
  },
571
571
  "reads": [
@@ -614,9 +614,9 @@
614
614
  "kind": "particles",
615
615
  "id": "template.warden-ring.7",
616
616
  "at": [
617
- -18.0,
617
+ 24.5,
618
618
  0.2,
619
- 12.5
619
+ -5.5
620
620
  ]
621
621
  },
622
622
  "reads": [
@@ -665,9 +665,9 @@
665
665
  "kind": "particles",
666
666
  "id": "template.warden-ring.8",
667
667
  "at": [
668
- -19.75,
668
+ 22.75,
669
669
  0.2,
670
- 12.969
670
+ -5.031
671
671
  ]
672
672
  },
673
673
  "reads": [
@@ -716,9 +716,9 @@
716
716
  "kind": "particles",
717
717
  "id": "template.warden-ring.9",
718
718
  "at": [
719
- -21.031,
719
+ 21.469,
720
720
  0.2,
721
- 14.25
721
+ -3.75
722
722
  ]
723
723
  },
724
724
  "reads": [
@@ -767,9 +767,9 @@
767
767
  "kind": "particles",
768
768
  "id": "template.warden-ring.10",
769
769
  "at": [
770
- -21.5,
770
+ 21.0,
771
771
  0.2,
772
- 16.0
772
+ -2.0
773
773
  ]
774
774
  },
775
775
  "reads": [
@@ -818,9 +818,9 @@
818
818
  "kind": "particles",
819
819
  "id": "template.warden-ring.11",
820
820
  "at": [
821
- -21.031,
821
+ 21.469,
822
822
  0.2,
823
- 17.75
823
+ -0.25
824
824
  ]
825
825
  },
826
826
  "reads": [
@@ -869,9 +869,9 @@
869
869
  "kind": "particles",
870
870
  "id": "template.warden-ring.12",
871
871
  "at": [
872
- -19.75,
872
+ 22.75,
873
873
  0.2,
874
- 19.031
874
+ 1.031
875
875
  ]
876
876
  },
877
877
  "reads": [
@@ -920,9 +920,9 @@
920
920
  "kind": "particles",
921
921
  "id": "template.warden-core",
922
922
  "at": [
923
- -18,
924
- 3.5,
925
- 16
923
+ 24.5,
924
+ 4.6,
925
+ -2
926
926
  ]
927
927
  },
928
928
  "reads": [
@@ -25,9 +25,9 @@
25
25
  "seed": 435,
26
26
  "scale": 1,
27
27
  "at": [
28
+ 2.5,
28
29
  0,
29
- 0,
30
- -19
30
+ -16.5
31
31
  ],
32
32
  "yaw": 0
33
33
  },
@@ -53,11 +53,11 @@
53
53
  "brain": null,
54
54
  "strike": "template.warden.slam",
55
55
  "seed": 437,
56
- "scale": 2.2,
56
+ "scale": 3.0,
57
57
  "at": [
58
- -18,
58
+ 24.5,
59
59
  0,
60
- 16
60
+ -2
61
61
  ],
62
62
  "yaw": 0
63
63
  }
@@ -47,9 +47,9 @@
47
47
  "retry": "Try the Barrow Warden again",
48
48
  "arena": {
49
49
  "at": [
50
- -18,
50
+ 24.5,
51
51
  0,
52
- 16
52
+ -2
53
53
  ],
54
54
  "radius": 8
55
55
  },
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "HUT": {
3
- "x": 0,
4
- "z": -12,
5
- "doorZ": -9
3
+ "x": -4,
4
+ "z": -14.5,
5
+ "doorZ": -11.5
6
6
  },
7
7
  "BLOB": {
8
- "x": 0,
9
- "z": -19
8
+ "x": 2.5,
9
+ "z": -16.5
10
10
  },
11
11
  "ELITE": {
12
12
  "x": 15,
13
13
  "z": -12
14
14
  },
15
15
  "BOSS": {
16
- "x": -18,
17
- "z": 16
16
+ "x": 24.5,
17
+ "z": -2
18
18
  },
19
19
  "TRAIL": [
20
20
  [
@@ -23,44 +23,75 @@
23
23
  0
24
24
  ],
25
25
  [
26
- 0,
26
+ -0.6,
27
+ -4
28
+ ],
29
+ [
30
+ -2.6,
27
31
  -9
28
32
  ],
29
33
  [
30
- 0,
31
- -19
34
+ -4,
35
+ -11.5
32
36
  ]
33
37
  ]
34
38
  ],
35
39
  "BRAZIERS": [
36
40
  [
37
- -6.8,
38
- -1.4
41
+ 5.9,
42
+ -12.8
39
43
  ],
40
44
  [
41
- 32.5,
42
- 22.5
45
+ -27.6,
46
+ 0.2
43
47
  ],
44
48
  [
45
- -6.6,
46
- 10.7
49
+ 9.6,
50
+ -5.4
51
+ ]
52
+ ],
53
+ "ROW": [
54
+ [
55
+ 8.3,
56
+ -12.8
57
+ ],
58
+ [
59
+ 10.7,
60
+ -12.8
47
61
  ]
48
62
  ],
49
63
  "MOSSGATE": {
50
- "x": -9,
51
- "z": -5
64
+ "x": -10,
65
+ "z": 0
52
66
  },
53
67
  "POND": {
54
- "x": 25,
55
- "z": 20
68
+ "x": -19.4,
69
+ "z": 0,
70
+ "hx": 6.6,
71
+ "hz": 5.4,
72
+ "r": 2.2
56
73
  },
57
74
  "ARENA": {
58
- "x": -18,
59
- "z": 16,
75
+ "x": 25.5,
76
+ "z": -2,
60
77
  "radius": 9.5
61
78
  },
62
79
  "LAMPLIGHTER": {
63
- "x": 2.6,
64
- "z": -2.2
65
- }
80
+ "x": 1.1,
81
+ "z": -6.4
82
+ },
83
+ "SIGN": [
84
+ -6.8,
85
+ -8.8
86
+ ],
87
+ "YARD": [
88
+ [
89
+ -10,
90
+ -18.6
91
+ ],
92
+ [
93
+ 12.5,
94
+ 8
95
+ ]
96
+ ]
66
97
  }