@zaisma/cli 0.70.0 → 0.72.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.
package/README.md CHANGED
@@ -8,6 +8,8 @@ Before anything else, `zaisma check ./build` lists anything in the game Zaisma w
8
8
 
9
9
  To play a multiplayer game on your own computer before uploading it, run `zaisma play-locally` in its folder: the game and its game server run here, and the test bench's Add a player opens another tab as a new player, each on Zaisma's own game page. It needs no key and no internet.
10
10
 
11
+ To build a game from shared building blocks, add pieces: `zaisma pieces add <name>` brings a piece with what it needs, never a second copy of what the game has; `zaisma pieces` lists what the game holds, with each piece's settings and hooks; `zaisma pieces newer` shows what has a newer version, and `zaisma pieces update <name>` moves one when you say so. Making a piece of your own: `zaisma pieces check <folder>` before you publish it. Anyone publishes pieces, for any engine: [docs/PIECES.md](https://github.com/zaisma/zaisma-sdk/blob/main/docs/PIECES.md).
12
+
11
13
  1. Make an API key at https://zaisma.com/dashboard/settings, under Keys, and set it: `export ZAISMA_KEY=zsk_…`
12
14
  2. Make a game: `zaisma new "Sky Hopper"`
13
15
  3. Upload your build folder (the one with `index.html`): `zaisma upload ./build --game sky-hopper --patch-notes "First version"`. Only new or changed files are sent. It runs the check first, and in what it sends (never in your folder) it downloads scripts, styles and fonts the game loads from other sites and unpacks pre-compressed builds (`.gz`, `.br`, `.unityweb`), then says what it changed. Once the scan passes you get a private preview link.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zaisma/cli",
3
- "version": "0.70.0",
3
+ "version": "0.72.0",
4
4
  "description": "Upload and publish browser games on Zaisma from the command line.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://zaisma.com",
@@ -31,6 +31,8 @@
31
31
  "fixed-checks.d.mts",
32
32
  "performance.mjs",
33
33
  "performance.d.mts",
34
+ "pieces.mjs",
35
+ "pieces.d.mts",
34
36
  "shader-check.mjs",
35
37
  "chrome.mjs",
36
38
  "skill/",
package/pieces.d.mts ADDED
@@ -0,0 +1,201 @@
1
+ /** A piece's piece.json, read and checked (docs/PIECES.md, "What a piece states"). */
2
+ export interface PieceStatement {
3
+ statement_version_number: number;
4
+ name: string;
5
+ piece_version: string;
6
+ kind: "foundation" | "extension" | "game_system" | "template";
7
+ standard: string;
8
+ summary: string;
9
+ license: string;
10
+ entry_path: string | null;
11
+ server_entry_path: string | null;
12
+ file_paths: string[];
13
+ server_file_paths: string[];
14
+ needs: PieceNeed[];
15
+ settings: StatedSetting[];
16
+ hooks: StatedHook[];
17
+ }
18
+ export interface PieceNeed {
19
+ name: string;
20
+ version_range: string;
21
+ kind: "piece" | "library" | "engine";
22
+ }
23
+ export interface StatedSetting {
24
+ name: string;
25
+ value_kind: "number" | "integer" | "boolean" | "choice" | "text" | "color";
26
+ default_value: number | boolean | string;
27
+ minimum_number: number | null;
28
+ maximum_number: number | null;
29
+ maximum_character_count: number | null;
30
+ choices: string[] | null;
31
+ summary: string;
32
+ }
33
+ export interface StatedHook {
34
+ name: string;
35
+ hook_kind: "event" | "decision";
36
+ summary: string;
37
+ }
38
+ /** A library a game's pieces brought, as its record keeps it. */
39
+ export interface RecordedLibrary {
40
+ name: string;
41
+ library_version: string;
42
+ summary: string;
43
+ license: string | null;
44
+ entry_path: string;
45
+ file_paths: string[];
46
+ source_kind: SourceKind;
47
+ files_sha256: string;
48
+ }
49
+ export type SourceKind = "folder" | "tarball" | "npm";
50
+ /** A game's pieces/pieces.json. */
51
+ export interface PiecesRecord {
52
+ about: string;
53
+ record_version_number: number;
54
+ pieces: { statement: PieceStatement; source_kind: SourceKind; files_sha256: string | null }[];
55
+ libraries: RecordedLibrary[];
56
+ }
57
+ /** One thing a game can hold in its pieces folder: a piece (with its statement) or a library that isn't one. */
58
+ export interface Unit {
59
+ name: string;
60
+ version: string;
61
+ kind: PieceStatement["kind"] | "library";
62
+ needs: PieceNeed[];
63
+ statement: PieceStatement | null;
64
+ library: Omit<RecordedLibrary, "source_kind" | "files_sha256"> | null;
65
+ files: Record<string, Uint8Array> | null;
66
+ sourceKind: SourceKind;
67
+ source: string | null;
68
+ }
69
+ export interface ShownPiece {
70
+ name: string;
71
+ piece_version: string;
72
+ kind: PieceStatement["kind"];
73
+ standard: string;
74
+ summary: string;
75
+ license: string;
76
+ source_kind: SourceKind;
77
+ import_path: string | null;
78
+ server_import_path: string | null;
79
+ needs: PieceNeed[];
80
+ settings: StatedSetting[];
81
+ hooks: StatedHook[];
82
+ is_edited: boolean;
83
+ }
84
+ export interface ShownLibrary {
85
+ name: string;
86
+ library_version: string;
87
+ summary: string;
88
+ license: string | null;
89
+ source_kind: SourceKind;
90
+ import_path: string;
91
+ is_edited: boolean;
92
+ }
93
+ export interface ImportMap {
94
+ imports: Record<string, string>;
95
+ }
96
+ export interface EngineNeed {
97
+ name: string;
98
+ version_range: string;
99
+ needed_by_name: string;
100
+ }
101
+ export interface PiecesList {
102
+ pieces: ShownPiece[];
103
+ libraries: ShownLibrary[];
104
+ standards: string[];
105
+ import_map: ImportMap;
106
+ }
107
+ export interface Brought {
108
+ is_dry_run: boolean;
109
+ added_pieces: ShownPiece[];
110
+ added_libraries: ShownLibrary[];
111
+ kept_names: string[];
112
+ engine_needs: EngineNeed[];
113
+ standards: string[];
114
+ new_standards: string[];
115
+ import_map: ImportMap;
116
+ }
117
+ export interface UpdateAnswer extends Brought {
118
+ name: string;
119
+ updated_piece: ShownPiece | null;
120
+ updated_library: ShownLibrary | null;
121
+ earlier_piece_version: string | null;
122
+ earlier_library_version: string | null;
123
+ }
124
+ export interface RemoveAnswer {
125
+ is_dry_run: boolean;
126
+ removed_name: string;
127
+ removed_folders: string[];
128
+ no_longer_needed_names: string[];
129
+ import_map: ImportMap;
130
+ }
131
+ export interface NewerAnswer {
132
+ newer_pieces: { name: string; piece_version: string; newest_piece_version: string; newest_accepted_piece_version: string | null; held_back_by_names: string[] }[];
133
+ newer_libraries: { name: string; library_version: string; newest_library_version: string; newest_accepted_library_version: string | null; held_back_by_names: string[] }[];
134
+ unchecked_names: string[];
135
+ }
136
+ export interface PieceCheckProblem {
137
+ code: string;
138
+ problem_kind: "refused" | "note";
139
+ message: string;
140
+ path: string | null;
141
+ fix: string;
142
+ }
143
+ export interface PieceCheckAnswer {
144
+ name: string | null;
145
+ piece_version: string | null;
146
+ is_ready: boolean;
147
+ problems: PieceCheckProblem[];
148
+ }
149
+
150
+ export declare const STATEMENT_VERSION_NUMBER: number;
151
+ export declare const RECORD_VERSION_NUMBER: number;
152
+ export declare const STATEMENT_FIELDS: string[];
153
+ export declare const NEED_FIELDS: string[];
154
+ export declare const SETTING_FIELDS: string[];
155
+ export declare const HOOK_FIELDS: string[];
156
+ export declare const PIECE_KINDS: PieceStatement["kind"][];
157
+ export declare const NEED_KINDS: PieceNeed["kind"][];
158
+ export declare const SETTING_VALUE_KINDS: StatedSetting["value_kind"][];
159
+ export declare const HOOK_KINDS: StatedHook["hook_kind"][];
160
+ export declare const SOURCE_KINDS: SourceKind[];
161
+ export declare const STATEMENT_PATH: string;
162
+ export declare const STATEMENT_MODULE_PATH: string;
163
+ export declare const RECORD_PATH: string;
164
+ export declare const PIECES_FOLDER: string;
165
+ export declare const SERVER_PIECES_FOLDER: string;
166
+ export declare const PIECE_LIMITS: Record<string, number>;
167
+ export declare const PIECE_CHECK_CODES: Record<string, { problemKind: "refused" | "note"; meaning: string }>;
168
+
169
+ /** A failure in the API's error shape. */
170
+ export declare class PiecesError extends Error {
171
+ error: { code: string; message: string; field: string | null; fix: string; retry_after_sec: null };
172
+ }
173
+
174
+ export declare function parseVersion(text: string): { majorNumber: number; minorNumber: number; patchNumber: number; prerelease: string | null } | null;
175
+ export declare function compareVersions(first: string, second: string): number;
176
+ export declare function parseRange(rangeText: string): { operator: string; version: string }[][] | null;
177
+ export declare function satisfies(version: string, rangeText: string): boolean;
178
+ export declare function newestSatisfying(versions: string[], ranges: string | string[]): string | null;
179
+ export declare function camelName(statedName: string): string;
180
+ export declare function readStatement(statementText: string, whereFrom?: string): PieceStatement;
181
+ export declare function statementModuleText(statementText: string): string;
182
+ export declare function planAdd(plan: {
183
+ piece: Unit;
184
+ had?: Record<string, Unit>;
185
+ gameLibraries?: Record<string, string>;
186
+ find: (name: string, needKind: "piece" | "library", ranges: string[]) => Promise<Unit | null> | Unit | null;
187
+ }): Promise<{ added: Unit[]; keptNames: string[]; engineNeeds: EngineNeed[] }>;
188
+ export declare function needersOf(name: string, had: Record<string, Unit>): { holder: Unit; need: PieceNeed }[];
189
+ export declare function checkUpdateFits(update: { name: string; nextVersion: string; had: Record<string, Unit> }): void;
190
+ export declare function filesHash(files: Record<string, Uint8Array>): string;
191
+ export declare function readTar(bytes: Uint8Array): Record<string, Buffer>;
192
+ export declare function readSource(source: string, where?: { baseFolder?: string }): Promise<Unit>;
193
+ export declare function readRecord(gameFolder: string): Promise<PiecesRecord>;
194
+ export declare function placesOf(unit: Unit): { path: string; filePath: string; hashKey: string }[];
195
+ export declare function importMapOf(record: PiecesRecord): ImportMap;
196
+ export declare function listPieces(gameFolder: string): Promise<PiecesList>;
197
+ export declare function addPiece(gameFolder: string, source: string, options?: { isDryRun?: boolean }): Promise<Brought>;
198
+ export declare function updatePiece(gameFolder: string, name: string, options?: { versionRange?: string; source?: string | null; isDiscardingEdits?: boolean; isDryRun?: boolean }): Promise<UpdateAnswer>;
199
+ export declare function removePiece(gameFolder: string, name: string, options?: { isDiscardingEdits?: boolean; isDryRun?: boolean }): Promise<RemoveAnswer>;
200
+ export declare function newerPieces(gameFolder: string): Promise<NewerAnswer>;
201
+ export declare function checkPiece(pieceFolder: string, options?: { isFixing?: boolean }): Promise<PieceCheckAnswer>;