@dithrkit/sdk 0.4.1 → 0.5.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.
@@ -6,8 +6,6 @@
6
6
  "strict": true,
7
7
  "noEmit": true,
8
8
  "esModuleInterop": true,
9
- "skipLibCheck": true,
10
- "rootDir": "src"
11
- },
12
- "include": ["src/**/*.ts", "node_modules/@dithrkit/sdk/types/**/*.d.ts"]
9
+ "skipLibCheck": true
10
+ }
13
11
  }
@@ -3,6 +3,7 @@
3
3
 
4
4
  const fs = require("node:fs");
5
5
  const path = require("node:path");
6
+ const { version: SDK_VERSION } = require("../../package.json");
6
7
 
7
8
  const TEMPLATES_DIR = path.join(__dirname, "..", "..", "templates");
8
9
 
@@ -102,7 +103,7 @@ if (useTypescript) {
102
103
  // tsconfig.json — extends the shared SDK config
103
104
  const tsconfig = {
104
105
  extends: "@dithrkit/sdk/configs/tsconfig.base.json",
105
- include: ["src/**/*.ts"],
106
+ include: ["src/**/*.ts", "node_modules/@dithrkit/sdk/types/**/*.d.ts"],
106
107
  };
107
108
  fs.writeFileSync(path.join(dir, "tsconfig.json"), JSON.stringify(tsconfig, null, 4) + "\n");
108
109
  }
@@ -149,7 +150,7 @@ const pkg = {
149
150
  typecheck: useTypescript ? "tsc --noEmit" : undefined,
150
151
  },
151
152
  devDependencies: {
152
- "@dithrkit/sdk": "^0.1.0",
153
+ "@dithrkit/sdk": `^${SDK_VERSION}`,
153
154
  eslint: "^9.0.0",
154
155
  prettier: "^3.0.0",
155
156
  ...(useTypescript
package/lib/packager.js CHANGED
@@ -3,6 +3,8 @@
3
3
  const fs = require("node:fs");
4
4
  const path = require("node:path");
5
5
 
6
+ const EXCLUDED_DIRECTORIES = new Set([".git", "build", "node_modules"]);
7
+
6
8
  /**
7
9
  * Pack a directory tree into the Emscripten preload data format.
8
10
  *
@@ -39,6 +41,10 @@ function packDirectory(dir, mount) {
39
41
  continue;
40
42
  }
41
43
 
44
+ if (entry.isDirectory() && EXCLUDED_DIRECTORIES.has(entry.name)) {
45
+ continue;
46
+ }
47
+
42
48
  if (entry.isDirectory()) {
43
49
  walk(fullPath, relPath);
44
50
  } else if (entry.isFile()) {
@@ -80,7 +86,10 @@ function generatePackageLoader(dataFilename, files) {
80
86
  for (const f of files) {
81
87
  const parts = f.filename.split("/");
82
88
  for (let i = 1; i < parts.length; i++) {
83
- dirs.add(parts.slice(0, i).join("/"));
89
+ const dir = parts.slice(0, i).join("/");
90
+ if (dir) {
91
+ dirs.add(dir);
92
+ }
84
93
  }
85
94
  }
86
95
 
@@ -114,14 +123,14 @@ function generatePackageLoader(dataFilename, files) {
114
123
  " // Create directories",
115
124
  ...dirList.map(
116
125
  (d) =>
117
- ` Module['FS_createPath']('${path.dirname("/" + d).replace(/\\/g, "/")}', '${path.basename(d)}', true, true);`,
126
+ ` Module.FS.createPath('${path.posix.dirname(d)}', '${path.posix.basename(d)}', true, true);`,
118
127
  ),
119
128
  "",
120
129
  " // Create files",
121
130
  " PACKAGE_INFO.files.forEach(function(fileInfo) {",
122
131
  " var data = byteArray.subarray(fileInfo.start, fileInfo.end);",
123
132
  " var dir = fileInfo.filename.substring(0, fileInfo.filename.lastIndexOf('/'));",
124
- " Module['FS_createDataFile'](dir, fileInfo.filename.split('/').pop(), data, true, true, true);",
133
+ " Module.FS.createDataFile(dir, fileInfo.filename.split('/').pop(), data, true, true, true);",
125
134
  " });",
126
135
  " }",
127
136
  "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dithrkit/sdk",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "SDK and CLI for the dithr fantasy console",
5
5
  "license": "MIT",
6
6
  "author": "dithrkit",
@@ -25,9 +25,13 @@
25
25
  "bin": {
26
26
  "dithrkit": "bin/dithrkit.js"
27
27
  },
28
+ "scripts": {
29
+ "test": "node --test test/*.test.js"
30
+ },
28
31
  "exports": {
29
32
  "./configs/tsconfig.base.json": "./configs/tsconfig.base.json",
30
33
  "./configs/eslint": "./configs/eslint.config.js",
34
+ "./lib/commands/create.js": "./lib/commands/create.js",
31
35
  "./types/*": "./types/*"
32
36
  },
33
37
  "files": [
@@ -38,16 +42,16 @@
38
42
  "configs/"
39
43
  ],
40
44
  "engines": {
41
- "node": ">=18"
45
+ "node": ">=22.14.0"
42
46
  },
43
47
  "dependencies": {
44
48
  "esbuild": "^0.24.0"
45
49
  },
46
50
  "optionalDependencies": {
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
+ "@dithrkit/win32-x64": "0.5.0",
52
+ "@dithrkit/linux-x64": "0.5.0",
53
+ "@dithrkit/linux-arm64": "0.5.0",
54
+ "@dithrkit/darwin-arm64": "0.5.0",
55
+ "@dithrkit/wasm": "0.5.0"
52
56
  }
53
57
  }
@@ -4,7 +4,7 @@ function _init() {
4
4
  gfx.cls(0);
5
5
  }
6
6
 
7
- function _update(dt) {
7
+ function _update(_dt) {
8
8
  // Update logic here
9
9
  }
10
10
 
@@ -4,11 +4,11 @@ export function _init(): void {
4
4
  gfx.cls(0);
5
5
  }
6
6
 
7
- export function _update(dt: number): void {
7
+ export function _update(_dt: number): void {
8
8
  // Update logic here
9
9
  }
10
10
 
11
11
  export function _draw(): void {
12
12
  gfx.cls(0);
13
- gfx.print('hello, dithr!', 4, 4, 7);
13
+ gfx.print("hello, dithr!", 4, 4, 7);
14
14
  }
package/types/dithr.d.ts CHANGED
@@ -112,6 +112,8 @@ interface DithrGfx {
112
112
  spr(idx?: number, x?: number, y?: number, w?: number, h?: number, flip_x?: boolean, flip_y?: boolean): void;
113
113
  sprBatch(data: Int32Array, count?: number): void;
114
114
  sspr(sx?: number, sy?: number, sw?: number, sh?: number, dx?: number, dy?: number, dw?: number, dh?: number): void;
115
+ /** Draw a 9-slice / 9-patch from the sprite sheet into the destination rect. */
116
+ nineSlice(sx?: number, sy?: number, sw?: number, sh?: number, dx?: number, dy?: number, dw?: number, dh?: number, border?: number): void;
115
117
  sprRot(idx?: number, x?: number, y?: number, angle?: number, cx?: number, cy?: number): void;
116
118
  sprAffine(idx?: number, x?: number, y?: number, origin_x?: number, origin_y?: number, rot_x?: number, rot_y?: number): void;
117
119
 
@@ -163,6 +165,8 @@ interface DithrGfx {
163
165
  dlEnd(): void;
164
166
  dlSpr(layer: number, idx: number, x: number, y: number, w?: number, h?: number, flip_x?: boolean, flip_y?: boolean): void;
165
167
  dlSspr(layer: number, sx: number, sy: number, sw: number, sh: number, dx: number, dy: number, dw: number, dh: number): void;
168
+ /** Enqueue a 9-slice draw command on the draw list at the given layer. */
169
+ dlNineSlice(layer: number, sx: number, sy: number, sw: number, sh: number, dx: number, dy: number, dw: number, dh: number, border: number): void;
166
170
  dlSprRot(layer: number, idx: number, x: number, y: number, angle?: number, cx?: number, cy?: number): void;
167
171
  dlSprAffine(layer: number, idx: number, x: number, y: number, origin_x?: number, origin_y?: number, rot_x?: number, rot_y?: number): void;
168
172
  }
@@ -639,6 +643,8 @@ interface DithrUi {
639
643
  groupRect(): DithrRect;
640
644
  /** Clamp child to the intersection with the current group rect. */
641
645
  fit(child: DithrRect): DithrRect;
646
+ /** Draw a 9-slice panel from the sprite sheet, clamped to the active group bounds. */
647
+ panel(rect: DithrRect, sx: number, sy: number, sw: number, sh: number, border: number): void;
642
648
  /** Push a group, call fn, then pop. opts.clip applies gfx.clip automatically. */
643
649
  withGroup(rect: DithrRect, fn: () => void, opts?: { clip?: boolean }): void;
644
650
  }