nucleation 0.10.4 → 0.10.7
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/CellExecutor.d.mts +51 -0
- package/CellExecutor.d.ts +51 -0
- package/CellExecutor.mjs +171 -0
- package/Curve3D.mjs +1 -1
- package/DefinitionRegion.mjs +4 -4
- package/Design.d.mts +348 -0
- package/Design.d.ts +348 -0
- package/Design.mjs +1334 -0
- package/Hdl.d.mts +56 -0
- package/Hdl.d.ts +56 -0
- package/Hdl.mjs +163 -0
- package/MchprsWorld.mjs +2 -2
- package/MeshConfig.mjs +4 -4
- package/MeshResult.d.mts +11 -0
- package/MeshResult.d.ts +11 -0
- package/MeshResult.mjs +38 -1
- package/NucleationError.d.mts +12 -0
- package/NucleationError.d.ts +12 -0
- package/NucleationError.mjs +25 -0
- package/Routing.d.mts +66 -0
- package/Routing.d.ts +66 -0
- package/Routing.mjs +220 -0
- package/Schematic.d.mts +73 -1
- package/Schematic.d.ts +73 -1
- package/Schematic.mjs +259 -1
- package/SchematicSplitResult.d.mts +26 -0
- package/SchematicSplitResult.d.ts +26 -0
- package/SchematicSplitResult.mjs +84 -0
- package/Store.d.mts +1 -1
- package/Store.d.ts +1 -1
- package/Store.mjs +1 -1
- package/TickSimulation.d.mts +231 -0
- package/TickSimulation.d.ts +231 -0
- package/TickSimulation.mjs +404 -2
- package/index.d.mts +10 -0
- package/index.d.ts +10 -0
- package/index.mjs +10 -0
- package/nucleation.wasm +0 -0
- package/package.json +6 -1
- package/veneer/design.d.ts +167 -0
- package/veneer/design.mjs +480 -0
package/TickSimulation.mjs
CHANGED
|
@@ -282,7 +282,7 @@ export class TickSimulation {
|
|
|
282
282
|
const result = wasm.TickSimulation_run_until_quiescent(this.ffiValue, budget);
|
|
283
283
|
|
|
284
284
|
try {
|
|
285
|
-
return result;
|
|
285
|
+
return result === 1;
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
finally {
|
|
@@ -314,7 +314,7 @@ export class TickSimulation {
|
|
|
314
314
|
const result = wasm.TickSimulation_is_quiescent(this.ffiValue);
|
|
315
315
|
|
|
316
316
|
try {
|
|
317
|
-
return result;
|
|
317
|
+
return result === 1;
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
finally {
|
|
@@ -381,6 +381,100 @@ export class TickSimulation {
|
|
|
381
381
|
}
|
|
382
382
|
}
|
|
383
383
|
|
|
384
|
+
/**
|
|
385
|
+
* Batched block-state reads: `positions_json` is `[[x,y,z], ...]`,
|
|
386
|
+
* the answer a JSON array of descriptors in the same order
|
|
387
|
+
* (`"minecraft:air"` for empty).
|
|
388
|
+
*
|
|
389
|
+
* A verification sweep over a computational build is thousands of
|
|
390
|
+
* probe reads per settle; one boundary call per sweep instead of one
|
|
391
|
+
* per probe is the difference between the FFI being the throughput
|
|
392
|
+
* ceiling and not.
|
|
393
|
+
*/
|
|
394
|
+
readProbes(positionsJson) {
|
|
395
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
396
|
+
|
|
397
|
+
const positionsJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, positionsJson)));
|
|
398
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
399
|
+
|
|
400
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
const result = wasm.TickSimulation_read_probes(diplomatReceive.buffer, this.ffiValue, positionsJsonSlice.ptr, write.buffer);
|
|
404
|
+
|
|
405
|
+
try {
|
|
406
|
+
if (!diplomatReceive.resultFlag) {
|
|
407
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
408
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
409
|
+
}
|
|
410
|
+
return write.readString8();
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
finally {
|
|
414
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
415
|
+
functionCleanupArena.free();
|
|
416
|
+
|
|
417
|
+
diplomatReceive.free();
|
|
418
|
+
write.free();
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Who powers this cell and why — a power-source tree from the
|
|
424
|
+
* simulation's current state, as JSON.
|
|
425
|
+
*
|
|
426
|
+
* Each node carries `pos`, `state`, `kind` (`wire` / `conductor` /
|
|
427
|
+
* `source` / `block`), the `power` the cell carries or emits, and
|
|
428
|
+
* `inputs`: the per-side contributions that explain it, each with a
|
|
429
|
+
* `mechanism` (`block_signal`, `wire`, `wire_up`, `wire_down`,
|
|
430
|
+
* `strong`, `signal`), the arriving `power`, and a recursive
|
|
431
|
+
* `source` node. Cycles stop with `"cycle": true`. Coordinates are
|
|
432
|
+
* the same structure-local space `get_block` reads.
|
|
433
|
+
*
|
|
434
|
+
* This is the static complement of running the sim: an open (a dead
|
|
435
|
+
* route that settles quiescent) shows up as an empty `inputs` list
|
|
436
|
+
* exactly where the feed should have been.
|
|
437
|
+
*/
|
|
438
|
+
conductionTrace(x, y, z) {
|
|
439
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
440
|
+
|
|
441
|
+
wasm.TickSimulation_conduction_trace(this.ffiValue, x, y, z, write.buffer);
|
|
442
|
+
|
|
443
|
+
try {
|
|
444
|
+
return write.readString8();
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
finally {
|
|
448
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
449
|
+
write.free();
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Write every settled non-air state back into `schematic` — the bulk
|
|
455
|
+
* form of `{simulate=true}`: settle once, keep the world the engine
|
|
456
|
+
* ended on. Returns how many blocks changed.
|
|
457
|
+
*
|
|
458
|
+
* The schematic's bounding-box minimum corresponds to the
|
|
459
|
+
* simulation's `(0, 0, 0)`, which is exactly how `from_schematic`
|
|
460
|
+
* loaded it. A file baked this way carries real wire connections and
|
|
461
|
+
* power in its palette, loads quiescent under `InWorld`, and renders
|
|
462
|
+
* correctly in any static consumer. Cells the simulation turned into
|
|
463
|
+
* air (a popped-off component) are left as the schematic had them.
|
|
464
|
+
*/
|
|
465
|
+
bakeTo(schematic) {
|
|
466
|
+
|
|
467
|
+
const result = wasm.TickSimulation_bake_to(this.ffiValue, schematic.ffiValue);
|
|
468
|
+
|
|
469
|
+
try {
|
|
470
|
+
return result;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
finally {
|
|
474
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
384
478
|
/**
|
|
385
479
|
* Snapshot the entire simulation; returns a checkpoint id.
|
|
386
480
|
*/
|
|
@@ -510,6 +604,196 @@ export class TickSimulation {
|
|
|
510
604
|
}
|
|
511
605
|
}
|
|
512
606
|
|
|
607
|
+
/**
|
|
608
|
+
* Start recording a run timeline from the current tick.
|
|
609
|
+
*
|
|
610
|
+
* A timeline is what makes a span of simulation reviewable after the
|
|
611
|
+
* fact: block deltas, the inputs that caused them and the piston
|
|
612
|
+
* strokes they drove, plus one whole-world frame to replay them from.
|
|
613
|
+
* Off by default — a simulation used for timing should not pay for it.
|
|
614
|
+
*
|
|
615
|
+
* Called again, it restarts from the current tick, and the previously
|
|
616
|
+
* stopped span is released.
|
|
617
|
+
*
|
|
618
|
+
* Starting a recording also wipes the plain block-change log that
|
|
619
|
+
* {@link TickSimulation::changes_json} and {@link TickSimulation::changes_count}
|
|
620
|
+
* read back to empty — a separate reset from
|
|
621
|
+
* {@link TickSimulation::record_updates}/{@link TickSimulation::clear_updates},
|
|
622
|
+
* which govern a different log. A host holding a cursor into the
|
|
623
|
+
* change log (the sim lab keeps a cumulative one) must reset that
|
|
624
|
+
* cursor when it calls this, or it will read past the end of a log
|
|
625
|
+
* that is no longer the one it was walking.
|
|
626
|
+
*/
|
|
627
|
+
recordTimeline() {
|
|
628
|
+
wasm.TickSimulation_record_timeline(this.ffiValue);
|
|
629
|
+
|
|
630
|
+
try {}
|
|
631
|
+
|
|
632
|
+
finally {
|
|
633
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* End the recording, keeping the span readable.
|
|
639
|
+
*
|
|
640
|
+
* This is a host's Stop button, and it is not a rewind: the span stays
|
|
641
|
+
* readable and exportable until the next
|
|
642
|
+
* {@link TickSimulation::record_timeline}, while the simulation is free to
|
|
643
|
+
* run on without the recording following it. No-op if nothing was
|
|
644
|
+
* recording.
|
|
645
|
+
*/
|
|
646
|
+
stopTimeline() {
|
|
647
|
+
wasm.TickSimulation_stop_timeline(this.ffiValue);
|
|
648
|
+
|
|
649
|
+
try {}
|
|
650
|
+
|
|
651
|
+
finally {
|
|
652
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* Where the recorded run was busy, as JSON:
|
|
658
|
+
* `{"start":T,"end":T,"ticks":[{"tick":T,"changes":N,"inputs":N,
|
|
659
|
+
* "pistons":N}]}`.
|
|
660
|
+
*
|
|
661
|
+
* The strip a host draws to let someone pick a span worth exporting.
|
|
662
|
+
* Only ticks that did something appear: an idle tick is **absent**
|
|
663
|
+
* rather than present with zeroes, so a build that sits still does not
|
|
664
|
+
* advance the strip and a long quiet run stays cheap to send.
|
|
665
|
+
*
|
|
666
|
+
* `{"start":0,"end":0,"ticks":[]}` when nothing has been recorded.
|
|
667
|
+
*/
|
|
668
|
+
timelineActivityJson() {
|
|
669
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
670
|
+
|
|
671
|
+
wasm.TickSimulation_timeline_activity_json(this.ffiValue, write.buffer);
|
|
672
|
+
|
|
673
|
+
try {
|
|
674
|
+
return write.readString8();
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
finally {
|
|
678
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
679
|
+
write.free();
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Exact and translated recurrence in the timeline a read query would
|
|
685
|
+
* resolve to (see {@link Self::timeline}), as JSON:
|
|
686
|
+
* `{"exact":{"start":T,"end":T,"period":N,"drift":[x,y,z]}|null,
|
|
687
|
+
* "translated":{...}|null}`.
|
|
688
|
+
*
|
|
689
|
+
* **An absent cycle is `null`, not an error.** Most builds — an
|
|
690
|
+
* adder, a door — never repeat their own state, and that is the
|
|
691
|
+
* ordinary outcome, not a failed search.
|
|
692
|
+
*
|
|
693
|
+
* **O(ticks × blocks): replays the whole recorded span to build one
|
|
694
|
+
* digest per tick boundary**, then rebuilds full frames for the
|
|
695
|
+
* handful of candidates that survive. This is an on-demand "find
|
|
696
|
+
* cycles" action for a host UI button, never something to call per
|
|
697
|
+
* tick or per frame — poll {@link Self::timeline_activity_json} instead.
|
|
698
|
+
*
|
|
699
|
+
* Materialises the whole recorded timeline once to answer this call
|
|
700
|
+
* (an owned `RunTimeline`'s `initial` frame copies every non-air
|
|
701
|
+
* block) — acceptable for one on-demand press, not for a loop.
|
|
702
|
+
*
|
|
703
|
+
* `{"exact":null,"translated":null}` when nothing has been recorded.
|
|
704
|
+
*/
|
|
705
|
+
timelineCyclesJson() {
|
|
706
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
707
|
+
|
|
708
|
+
wasm.TickSimulation_timeline_cycles_json(this.ffiValue, write.buffer);
|
|
709
|
+
|
|
710
|
+
try {
|
|
711
|
+
return write.readString8();
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
finally {
|
|
715
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
716
|
+
write.free();
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* Project `[start_tick, end_tick)` of the timeline a read query would
|
|
722
|
+
* resolve to (see {@link Self::timeline}) into the animated-GLB mesher's
|
|
723
|
+
* `Timeline` JSON — `{"origin":[x,y,z],"tick_ms":F,
|
|
724
|
+
* "events":[{"kind":"set_block"|"piston",...}]}` — via
|
|
725
|
+
* `crate::tick_timeline::mesher_timeline_json`.
|
|
726
|
+
*
|
|
727
|
+
* **Materialises the whole recorded timeline to answer this call**
|
|
728
|
+
* (an owned `RunTimeline`'s `initial` frame copies every non-air
|
|
729
|
+
* block in the world) — this is an on-demand "export this
|
|
730
|
+
* selection" action, not something to call per frame or poll.
|
|
731
|
+
*
|
|
732
|
+
* Fails if no timeline has been recorded, or if `start_tick..
|
|
733
|
+
* end_tick` is empty or outside the recorded span.
|
|
734
|
+
*/
|
|
735
|
+
animationTimelineJson(startTick, endTick, tickMs) {
|
|
736
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
737
|
+
|
|
738
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
const result = wasm.TickSimulation_animation_timeline_json(diplomatReceive.buffer, this.ffiValue, startTick, endTick, tickMs, write.buffer);
|
|
742
|
+
|
|
743
|
+
try {
|
|
744
|
+
if (!diplomatReceive.resultFlag) {
|
|
745
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
746
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
747
|
+
}
|
|
748
|
+
return write.readString8();
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
finally {
|
|
752
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
753
|
+
diplomatReceive.free();
|
|
754
|
+
write.free();
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* The selection's starting scene — `[start_tick, end_tick)` of the
|
|
760
|
+
* timeline a read query would resolve to (see {@link Self::timeline}) —
|
|
761
|
+
* as schematic bytes, base64-encoded.
|
|
762
|
+
*
|
|
763
|
+
* A WASM handle cannot cross a worker boundary, so this exists for a
|
|
764
|
+
* host to hand the bytes to a worker, which rebuilds the schematic
|
|
765
|
+
* with `Schematic.fromData`.
|
|
766
|
+
*
|
|
767
|
+
* **Materialises the whole recorded timeline to answer this call**
|
|
768
|
+
* — see {@link Self::animation_timeline_json}; an on-demand export
|
|
769
|
+
* action, not a per-frame poll.
|
|
770
|
+
*
|
|
771
|
+
* Fails if no timeline has been recorded, or if `start_tick..
|
|
772
|
+
* end_tick` is empty or outside the recorded span.
|
|
773
|
+
*/
|
|
774
|
+
selectionSchematicB64(startTick, endTick) {
|
|
775
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
776
|
+
|
|
777
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
778
|
+
|
|
779
|
+
|
|
780
|
+
const result = wasm.TickSimulation_selection_schematic_b64(diplomatReceive.buffer, this.ffiValue, startTick, endTick, write.buffer);
|
|
781
|
+
|
|
782
|
+
try {
|
|
783
|
+
if (!diplomatReceive.resultFlag) {
|
|
784
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
785
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
786
|
+
}
|
|
787
|
+
return write.readString8();
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
finally {
|
|
791
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
792
|
+
diplomatReceive.free();
|
|
793
|
+
write.free();
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
|
|
513
797
|
/**
|
|
514
798
|
* How many updates have been recorded — page before pulling them.
|
|
515
799
|
*/
|
|
@@ -615,6 +899,93 @@ export class TickSimulation {
|
|
|
615
899
|
}
|
|
616
900
|
}
|
|
617
901
|
|
|
902
|
+
/**
|
|
903
|
+
* Every block a piston currently has in flight, as JSON:
|
|
904
|
+
* `[{"to":[x,y,z],"from":[x,y,z],"state":"...","carried":"...",
|
|
905
|
+
* "carried_short":"..."|null,"remains":"..."|null,"dir":"east",
|
|
906
|
+
* "extending":bool,"started":T,"lands":T,"source_piston":bool}]`.
|
|
907
|
+
*
|
|
908
|
+
* Draw `carried` travelling `from` -> `to`, and `remains` (when it is
|
|
909
|
+
* not null) parked at `to` for the whole move. They differ from
|
|
910
|
+
* `state` — what actually lands — only for a retracting piston, whose
|
|
911
|
+
* body stays put while its head comes home; vanilla's
|
|
912
|
+
* `PistonHeadRenderer` splits exactly these two slots.
|
|
913
|
+
*
|
|
914
|
+
* `carried_short` is the same arm with `short=true`. Draw it while the
|
|
915
|
+
* head is **within half a block of its body** — `progress <= 0.5`
|
|
916
|
+
* extending, `progress >= 0.5` retracting — or the shaft passes
|
|
917
|
+
* visibly through the back of the piston as it comes home. Which form
|
|
918
|
+
* to use is yours; naming the state is the engine's.
|
|
919
|
+
*
|
|
920
|
+
* What a renderer needs to animate a stroke, from the simulator that
|
|
921
|
+
* dispatched it. The block-change stream cannot answer this: it says a
|
|
922
|
+
* cell became a `moving_piston` placeholder, not which block set off,
|
|
923
|
+
* which cell it left, or which tick it arrives — so a host that
|
|
924
|
+
* reconstructs strokes from changes is reimplementing piston mechanics
|
|
925
|
+
* downstream of the engine, and animating on a clock the simulation
|
|
926
|
+
* does not share. That desync is what draws a block twice, leaves a
|
|
927
|
+
* gap where one should be, and shears a piston head off its load.
|
|
928
|
+
*
|
|
929
|
+
* `started` and `lands` are tick numbers in the engine's frame, where
|
|
930
|
+
* {@link Self::tick_count} counts *completed* ticks: after stepping to
|
|
931
|
+
* `tick_count == t`, a flight's progress is
|
|
932
|
+
* `(t - started) / (lands - started)`, clamped to 1. Draw it while it
|
|
933
|
+
* is listed and drop it when it stops being listed — the same call
|
|
934
|
+
* that stops reporting it is the tick the real block is written, so
|
|
935
|
+
* there is no frame with both and none with neither.
|
|
936
|
+
*/
|
|
937
|
+
movingBlocksJson() {
|
|
938
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
939
|
+
|
|
940
|
+
wasm.TickSimulation_moving_blocks_json(this.ffiValue, write.buffer);
|
|
941
|
+
|
|
942
|
+
try {
|
|
943
|
+
return write.readString8();
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
finally {
|
|
947
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
948
|
+
write.free();
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
/**
|
|
953
|
+
* Drop the recorded block changes without stopping recording.
|
|
954
|
+
*
|
|
955
|
+
* The log grows for as long as the simulation runs and nothing
|
|
956
|
+
* empties it, so a long-running host — a browser session driving
|
|
957
|
+
* thousands of ticks — accumulates every block change forever. A
|
|
958
|
+
* host that has already consumed {@link TickSimulation::changes_json}
|
|
959
|
+
* can say so here and keep recording on. A host holding a cursor
|
|
960
|
+
* into the change log must reset that cursor when it calls this, or
|
|
961
|
+
* it will read past the end of a log that is no longer the one it
|
|
962
|
+
* was walking — the same hazard {@link TickSimulation::record_timeline}
|
|
963
|
+
* names for its own reset of this log.
|
|
964
|
+
*
|
|
965
|
+
* Refuses — and leaves the log untouched — while
|
|
966
|
+
* {@link TickSimulation::record_timeline} is recording: a run timeline
|
|
967
|
+
* is a seed frame plus this same log, and every timeline reader
|
|
968
|
+
* trusts that the log describes every mutation since recording
|
|
969
|
+
* began. Clearing it out from under a live recording would make
|
|
970
|
+
* replay silently wrong rather than fail loudly. Returns `true` if
|
|
971
|
+
* the log was cleared, `false` if the call was refused — following
|
|
972
|
+
* {@link TickSimulation::run_until_quiescent}'s convention of reporting
|
|
973
|
+
* whether the call achieved what it was asked, rather than swallowing
|
|
974
|
+
* a no-op.
|
|
975
|
+
*/
|
|
976
|
+
clearChanges() {
|
|
977
|
+
|
|
978
|
+
const result = wasm.TickSimulation_clear_changes(this.ffiValue);
|
|
979
|
+
|
|
980
|
+
try {
|
|
981
|
+
return result === 1;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
finally {
|
|
985
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
|
|
618
989
|
changesJson() {
|
|
619
990
|
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
620
991
|
|
|
@@ -630,6 +1001,37 @@ export class TickSimulation {
|
|
|
630
1001
|
}
|
|
631
1002
|
}
|
|
632
1003
|
|
|
1004
|
+
/**
|
|
1005
|
+
* The same JSON array {@link TickSimulation::changes_json} produces,
|
|
1006
|
+
* but only the entries from index `start` onward.
|
|
1007
|
+
*
|
|
1008
|
+
* Exists for a host draining the log every frame while a run
|
|
1009
|
+
* timeline recording refuses {@link TickSimulation::clear_changes}: the
|
|
1010
|
+
* log only ever grows in that state, so without this,
|
|
1011
|
+
* `changes_json` re-serialises the whole backlog on every single
|
|
1012
|
+
* drain — a cost that climbs for as long as the recording runs,
|
|
1013
|
+
* which is exactly when a session runs longest. Reading from a
|
|
1014
|
+
* cursor keeps a drain's cost to what is actually new.
|
|
1015
|
+
*
|
|
1016
|
+
* `start` at or past the end of the log yields `[]`, not an error —
|
|
1017
|
+
* a host racing a draining cursor against a growing log should not
|
|
1018
|
+
* have to special-case "nothing new yet".
|
|
1019
|
+
*/
|
|
1020
|
+
changesJsonFrom(start) {
|
|
1021
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1022
|
+
|
|
1023
|
+
wasm.TickSimulation_changes_json_from(this.ffiValue, start, write.buffer);
|
|
1024
|
+
|
|
1025
|
+
try {
|
|
1026
|
+
return write.readString8();
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
finally {
|
|
1030
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1031
|
+
write.free();
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
|
|
633
1035
|
/**
|
|
634
1036
|
* Live item entities and minecarts, as JSON:
|
|
635
1037
|
* `{"items":[{"id":N,"item":"...","count":N,"pos":[..],"vel":[..],
|
package/index.d.mts
CHANGED
|
@@ -48,6 +48,8 @@ export { DefinitionRegion } from "./DefinitionRegion.mjs"
|
|
|
48
48
|
|
|
49
49
|
export { SchematicRegions } from "./SchematicRegions.mjs"
|
|
50
50
|
|
|
51
|
+
export { Design } from "./Design.mjs"
|
|
52
|
+
|
|
51
53
|
export { Diff } from "./Diff.mjs"
|
|
52
54
|
|
|
53
55
|
export { Fingerprint } from "./Fingerprint.mjs"
|
|
@@ -58,6 +60,8 @@ export { Field3 } from "./Field3.mjs"
|
|
|
58
60
|
|
|
59
61
|
export { Geo } from "./Geo.mjs"
|
|
60
62
|
|
|
63
|
+
export { Hdl } from "./Hdl.mjs"
|
|
64
|
+
|
|
61
65
|
export { TickSimulation } from "./TickSimulation.mjs"
|
|
62
66
|
|
|
63
67
|
export { ChunkMeshResult } from "./ChunkMeshResult.mjs"
|
|
@@ -90,10 +94,14 @@ export { RenderConfig } from "./RenderConfig.mjs"
|
|
|
90
94
|
|
|
91
95
|
export { Renderer } from "./Renderer.mjs"
|
|
92
96
|
|
|
97
|
+
export { Routing } from "./Routing.mjs"
|
|
98
|
+
|
|
93
99
|
export { BlockState } from "./BlockState.mjs"
|
|
94
100
|
|
|
95
101
|
export { Schematic } from "./Schematic.mjs"
|
|
96
102
|
|
|
103
|
+
export { SchematicSplitResult } from "./SchematicSplitResult.mjs"
|
|
104
|
+
|
|
97
105
|
export { SchematicBuilder } from "./SchematicBuilder.mjs"
|
|
98
106
|
|
|
99
107
|
export { Scripting } from "./Scripting.mjs"
|
|
@@ -104,6 +112,8 @@ export { FieldProgramBuilder } from "./FieldProgramBuilder.mjs"
|
|
|
104
112
|
|
|
105
113
|
export { Sdf } from "./Sdf.mjs"
|
|
106
114
|
|
|
115
|
+
export { CellExecutor } from "./CellExecutor.mjs"
|
|
116
|
+
|
|
107
117
|
export { CircuitBuilder } from "./CircuitBuilder.mjs"
|
|
108
118
|
|
|
109
119
|
export { ExecutionMode } from "./ExecutionMode.mjs"
|
package/index.d.ts
CHANGED
|
@@ -48,6 +48,8 @@ export { DefinitionRegion } from "./DefinitionRegion.mjs"
|
|
|
48
48
|
|
|
49
49
|
export { SchematicRegions } from "./SchematicRegions.mjs"
|
|
50
50
|
|
|
51
|
+
export { Design } from "./Design.mjs"
|
|
52
|
+
|
|
51
53
|
export { Diff } from "./Diff.mjs"
|
|
52
54
|
|
|
53
55
|
export { Fingerprint } from "./Fingerprint.mjs"
|
|
@@ -58,6 +60,8 @@ export { Field3 } from "./Field3.mjs"
|
|
|
58
60
|
|
|
59
61
|
export { Geo } from "./Geo.mjs"
|
|
60
62
|
|
|
63
|
+
export { Hdl } from "./Hdl.mjs"
|
|
64
|
+
|
|
61
65
|
export { TickSimulation } from "./TickSimulation.mjs"
|
|
62
66
|
|
|
63
67
|
export { ChunkMeshResult } from "./ChunkMeshResult.mjs"
|
|
@@ -90,10 +94,14 @@ export { RenderConfig } from "./RenderConfig.mjs"
|
|
|
90
94
|
|
|
91
95
|
export { Renderer } from "./Renderer.mjs"
|
|
92
96
|
|
|
97
|
+
export { Routing } from "./Routing.mjs"
|
|
98
|
+
|
|
93
99
|
export { BlockState } from "./BlockState.mjs"
|
|
94
100
|
|
|
95
101
|
export { Schematic } from "./Schematic.mjs"
|
|
96
102
|
|
|
103
|
+
export { SchematicSplitResult } from "./SchematicSplitResult.mjs"
|
|
104
|
+
|
|
97
105
|
export { SchematicBuilder } from "./SchematicBuilder.mjs"
|
|
98
106
|
|
|
99
107
|
export { Scripting } from "./Scripting.mjs"
|
|
@@ -104,6 +112,8 @@ export { FieldProgramBuilder } from "./FieldProgramBuilder.mjs"
|
|
|
104
112
|
|
|
105
113
|
export { Sdf } from "./Sdf.mjs"
|
|
106
114
|
|
|
115
|
+
export { CellExecutor } from "./CellExecutor.mjs"
|
|
116
|
+
|
|
107
117
|
export { CircuitBuilder } from "./CircuitBuilder.mjs"
|
|
108
118
|
|
|
109
119
|
export { ExecutionMode } from "./ExecutionMode.mjs"
|
package/index.mjs
CHANGED
|
@@ -46,6 +46,8 @@ export { DefinitionRegion } from "./DefinitionRegion.mjs"
|
|
|
46
46
|
|
|
47
47
|
export { SchematicRegions } from "./SchematicRegions.mjs"
|
|
48
48
|
|
|
49
|
+
export { Design } from "./Design.mjs"
|
|
50
|
+
|
|
49
51
|
export { Diff } from "./Diff.mjs"
|
|
50
52
|
|
|
51
53
|
export { Fingerprint } from "./Fingerprint.mjs"
|
|
@@ -56,6 +58,8 @@ export { Field3 } from "./Field3.mjs"
|
|
|
56
58
|
|
|
57
59
|
export { Geo } from "./Geo.mjs"
|
|
58
60
|
|
|
61
|
+
export { Hdl } from "./Hdl.mjs"
|
|
62
|
+
|
|
59
63
|
export { TickSimulation } from "./TickSimulation.mjs"
|
|
60
64
|
|
|
61
65
|
export { ChunkMeshResult } from "./ChunkMeshResult.mjs"
|
|
@@ -88,10 +92,14 @@ export { RenderConfig } from "./RenderConfig.mjs"
|
|
|
88
92
|
|
|
89
93
|
export { Renderer } from "./Renderer.mjs"
|
|
90
94
|
|
|
95
|
+
export { Routing } from "./Routing.mjs"
|
|
96
|
+
|
|
91
97
|
export { BlockState } from "./BlockState.mjs"
|
|
92
98
|
|
|
93
99
|
export { Schematic } from "./Schematic.mjs"
|
|
94
100
|
|
|
101
|
+
export { SchematicSplitResult } from "./SchematicSplitResult.mjs"
|
|
102
|
+
|
|
95
103
|
export { SchematicBuilder } from "./SchematicBuilder.mjs"
|
|
96
104
|
|
|
97
105
|
export { Scripting } from "./Scripting.mjs"
|
|
@@ -102,6 +110,8 @@ export { FieldProgramBuilder } from "./FieldProgramBuilder.mjs"
|
|
|
102
110
|
|
|
103
111
|
export { Sdf } from "./Sdf.mjs"
|
|
104
112
|
|
|
113
|
+
export { CellExecutor } from "./CellExecutor.mjs"
|
|
114
|
+
|
|
105
115
|
export { CircuitBuilder } from "./CircuitBuilder.mjs"
|
|
106
116
|
|
|
107
117
|
export { ExecutionMode } from "./ExecutionMode.mjs"
|
package/nucleation.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nucleation",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.7",
|
|
4
4
|
"description": "A high-performance Minecraft schematic parser and utility library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.mjs",
|
|
@@ -8,12 +8,17 @@
|
|
|
8
8
|
".": {
|
|
9
9
|
"types": "./index.d.ts",
|
|
10
10
|
"default": "./index.mjs"
|
|
11
|
+
},
|
|
12
|
+
"./design": {
|
|
13
|
+
"types": "./veneer/design.d.ts",
|
|
14
|
+
"default": "./veneer/design.mjs"
|
|
11
15
|
}
|
|
12
16
|
},
|
|
13
17
|
"files": [
|
|
14
18
|
"*.mjs",
|
|
15
19
|
"*.d.ts",
|
|
16
20
|
"*.d.mts",
|
|
21
|
+
"veneer/",
|
|
17
22
|
"nucleation.wasm",
|
|
18
23
|
"diplomat.config.mjs"
|
|
19
24
|
],
|