@dithrkit/sdk 0.1.7 → 0.4.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/lib/binary.js CHANGED
@@ -3,6 +3,7 @@
3
3
  const PLATFORMS = {
4
4
  "win32-x64": "@dithrkit/win32-x64",
5
5
  "linux-x64": "@dithrkit/linux-x64",
6
+ "linux-arm64": "@dithrkit/linux-arm64",
6
7
  "darwin-arm64": "@dithrkit/darwin-arm64",
7
8
  };
8
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dithrkit/sdk",
3
- "version": "0.1.7",
3
+ "version": "0.4.1",
4
4
  "description": "SDK and CLI for the dithr fantasy console",
5
5
  "license": "MIT",
6
6
  "author": "dithrkit",
@@ -44,9 +44,10 @@
44
44
  "esbuild": "^0.24.0"
45
45
  },
46
46
  "optionalDependencies": {
47
- "@dithrkit/win32-x64": "0.1.7",
48
- "@dithrkit/linux-x64": "0.1.7",
49
- "@dithrkit/darwin-arm64": "0.1.7",
50
- "@dithrkit/wasm": "0.1.7"
47
+ "@dithrkit/win32-x64": "0.4.1",
48
+ "@dithrkit/linux-x64": "0.4.1",
49
+ "@dithrkit/linux-arm64": "0.4.1",
50
+ "@dithrkit/darwin-arm64": "0.4.1",
51
+ "@dithrkit/wasm": "0.4.1"
51
52
  }
52
53
  }
package/types/dithr.d.ts CHANGED
@@ -102,6 +102,10 @@ interface DithrGfx {
102
102
  print(text: string | number, x?: number, y?: number, col?: number): void;
103
103
  textWidth(text: string): number;
104
104
  textHeight(text: string): number;
105
+ /** Draw text with word-wrap within maxW pixels. Returns total pixel height consumed. */
106
+ printWrapped(text: string, x: number, y: number, maxW: number, col?: number): number;
107
+ /** Measure the pixel height printWrapped would consume without drawing. */
108
+ textWrapHeight(text: string, maxW: number): number;
105
109
  font(sx?: number, sy?: number, char_w?: number, char_h?: number, first?: number, count?: number): void;
106
110
 
107
111
  // Sprites
@@ -493,6 +497,10 @@ interface DithrMath {
493
497
  dist(x1: number, y1: number, x2: number, y2: number): number;
494
498
  angle(x1: number, y1: number, x2: number, y2: number): number;
495
499
 
500
+ // Perlin noise (Ken Perlin's improved noise, deterministic, returns ~-1..1)
501
+ noise2d(x: number, y: number): number;
502
+ noise3d(x: number, y: number, z: number): number;
503
+
496
504
  // Constants
497
505
  readonly PI: number;
498
506
  readonly TAU: number;
@@ -572,6 +580,7 @@ interface DithrSys {
572
580
  // File I/O (sandboxed to cart directory)
573
581
  readFile(path: string): string | undefined;
574
582
  writeFile(path: string, content: string): boolean;
583
+ deleteFile(path: string): boolean;
575
584
  listFiles(dir?: string): string[];
576
585
  listDirs(dir?: string): string[];
577
586
 
@@ -605,6 +614,14 @@ interface DithrCol {
605
614
  // ui — UI Layout Helpers
606
615
  // ---------------------------------------------------------------------------
607
616
 
617
+ /** Handle returned by ui.group() — call .end() when drawing is complete. */
618
+ interface DithrUiGroup {
619
+ /** The rect this group was pushed with. */
620
+ readonly rect: DithrRect;
621
+ /** Pop the group (and restore clip if clip was requested). */
622
+ end(): void;
623
+ }
624
+
608
625
  interface DithrUi {
609
626
  rect(x: number, y: number, w: number, h: number): DithrRect;
610
627
  inset(rect: DithrRect, n: number): DithrRect;
@@ -614,6 +631,16 @@ interface DithrUi {
614
631
  hstack(rect: DithrRect, n: number, gap?: number): DithrRect[];
615
632
  vstack(rect: DithrRect, n: number, gap?: number): DithrRect[];
616
633
  place(parent: DithrRect, ax: number, ay: number, w: number, h: number): DithrRect;
634
+ /** Push a group rect onto the stack. Returns true on success. */
635
+ groupPush(rect: DithrRect, clip?: boolean): boolean;
636
+ /** Pop the innermost group (safe to call on empty stack). */
637
+ groupPop(): void;
638
+ /** Return the current group rect, or {x:0,y:0,w:0,h:0} if no group is active. */
639
+ groupRect(): DithrRect;
640
+ /** Clamp child to the intersection with the current group rect. */
641
+ fit(child: DithrRect): DithrRect;
642
+ /** Push a group, call fn, then pop. opts.clip applies gfx.clip automatically. */
643
+ withGroup(rect: DithrRect, fn: () => void, opts?: { clip?: boolean }): void;
617
644
  }
618
645
 
619
646
  // ---------------------------------------------------------------------------
@@ -681,6 +708,52 @@ interface DithrSynth {
681
708
  fxNames(): string[];
682
709
  }
683
710
 
711
+ // ---------------------------------------------------------------------------
712
+ // particles — Fixed-pool particle system
713
+ // ---------------------------------------------------------------------------
714
+
715
+ interface DithrParticleSpawn {
716
+ x?: number;
717
+ y?: number;
718
+ vx?: number;
719
+ vy?: number;
720
+ ax?: number;
721
+ ay?: number;
722
+ /** Per-second velocity decay, 0 (none) .. 1 (instant). */
723
+ drag?: number;
724
+ /** Lifetime in seconds (default 1). */
725
+ life?: number;
726
+ /** Palette index at birth (default 7). */
727
+ color?: number;
728
+ /** Optional palette index at death (interpolates from `color`). */
729
+ color1?: number;
730
+ /** Render size in pixels (default 1). */
731
+ size?: number;
732
+ /** Render kind: particles.PIXEL | RECT | CIRCLE. */
733
+ kind?: number;
734
+ /** Burst size; > 1 enables `spread`/`speedMin`/`speedMax`. */
735
+ count?: number;
736
+ /** Cone half-angle (radians) around the (vx,vy) direction. */
737
+ spread?: number;
738
+ speedMin?: number;
739
+ speedMax?: number;
740
+ }
741
+
742
+ interface DithrParticles {
743
+ readonly PIXEL: number;
744
+ readonly RECT: number;
745
+ readonly CIRCLE: number;
746
+
747
+ /** Spawn one or more particles; returns the count actually emitted. */
748
+ emit(cfg: DithrParticleSpawn): number;
749
+ /** Advance simulation; defaults to `sys.delta()` when omitted. */
750
+ update(dt?: number): void;
751
+ /** Render every active particle via gfx primitives. */
752
+ draw(): void;
753
+ clear(): void;
754
+ count(): number;
755
+ }
756
+
684
757
  // ---------------------------------------------------------------------------
685
758
  // Global declarations
686
759
  // ---------------------------------------------------------------------------
@@ -704,6 +777,7 @@ declare const ui: DithrUi;
704
777
  declare const tween: DithrTween;
705
778
  declare const cam: DithrCam;
706
779
  declare const synth: DithrSynth;
780
+ declare const particles: DithrParticles;
707
781
 
708
782
  // ---------------------------------------------------------------------------
709
783
  // Global callbacks (implement these in your cart)