dredless 0.2.0 → 0.3.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.
Files changed (80) hide show
  1. package/README.md +65 -48
  2. package/dist/browser/dredless.global.js +12047 -0
  3. package/dist/browser/dredless.global.js.map +7 -0
  4. package/docs/API_REFERENCE.md +2481 -2481
  5. package/docs/BROWSER_API.md +98 -98
  6. package/docs/NODE_API.md +359 -359
  7. package/package.json +40 -35
  8. package/src/browser-global.js +3 -0
  9. package/src/browser.d.ts +212 -212
  10. package/src/browser.js +133 -133
  11. package/src/client/core.js +1202 -1202
  12. package/src/client/domains/index.js +1818 -1818
  13. package/src/client/index.d.ts +2 -2
  14. package/src/client/index.js +1 -1
  15. package/src/compression/lz4.d.ts +1 -1
  16. package/src/compression/lz4.js +112 -112
  17. package/src/constants.js +74 -74
  18. package/src/crypto/chacha-native.d.ts +9 -9
  19. package/src/crypto/chacha-native.js +48 -48
  20. package/src/crypto/chacha.d.ts +25 -25
  21. package/src/crypto/chacha.js +274 -274
  22. package/src/events.js +39 -39
  23. package/src/index.d.ts +2277 -2277
  24. package/src/index.js +125 -125
  25. package/src/network/browser-session.js +291 -291
  26. package/src/network/connection.d.ts +1 -1
  27. package/src/network/connection.js +31 -31
  28. package/src/network/cookies.js +85 -85
  29. package/src/network/http.js +34 -34
  30. package/src/network/index.d.ts +4 -4
  31. package/src/network/index.js +4 -4
  32. package/src/network/servers.d.ts +7 -7
  33. package/src/network/servers.js +133 -133
  34. package/src/network/session.d.ts +7 -7
  35. package/src/network/session.js +320 -320
  36. package/src/network/ships.d.ts +12 -12
  37. package/src/network/ships.js +73 -73
  38. package/src/node.d.ts +2 -2
  39. package/src/node.js +8 -8
  40. package/src/protocol/codec/binary.d.ts +3 -3
  41. package/src/protocol/codec/binary.js +52 -52
  42. package/src/protocol/codec/msgpack.d.ts +3 -3
  43. package/src/protocol/codec/msgpack.js +555 -555
  44. package/src/protocol/inbound/frame.d.ts +1 -1
  45. package/src/protocol/inbound/frame.js +8 -8
  46. package/src/protocol/inbound/world-payload.d.ts +3 -3
  47. package/src/protocol/inbound/world-payload.js +21 -21
  48. package/src/protocol/index.d.ts +11 -11
  49. package/src/protocol/index.js +19 -19
  50. package/src/protocol/outbound/blueprint.d.ts +22 -22
  51. package/src/protocol/outbound/blueprint.js +36 -36
  52. package/src/protocol/outbound/commands.d.ts +3 -3
  53. package/src/protocol/outbound/commands.js +149 -149
  54. package/src/protocol/outbound/comms.d.ts +28 -28
  55. package/src/protocol/outbound/comms.js +40 -40
  56. package/src/protocol/outbound/inventory.d.ts +64 -64
  57. package/src/protocol/outbound/inventory.js +147 -147
  58. package/src/protocol/outbound/ship-management.d.ts +84 -84
  59. package/src/protocol/outbound/ship-management.js +221 -221
  60. package/src/protocol/outbound/sign.d.ts +18 -18
  61. package/src/protocol/outbound/sign.js +45 -45
  62. package/src/protocol/outbound/ui-config.d.ts +157 -157
  63. package/src/protocol/outbound/ui-config.js +578 -578
  64. package/src/runtime.js +36 -36
  65. package/src/state/generator-maze.d.ts +32 -32
  66. package/src/state/generator-maze.js +370 -370
  67. package/src/state/index.d.ts +3 -3
  68. package/src/state/index.js +3 -3
  69. package/src/state/items.js +20 -20
  70. package/src/state/model/decoder.js +1554 -1554
  71. package/src/state/model/index.d.ts +33 -33
  72. package/src/state/model/index.js +2 -2
  73. package/src/state/model/loader-config.js +1020 -1020
  74. package/src/state/model/reader.js +69 -69
  75. package/src/state/model/state.js +1257 -1257
  76. package/src/state/overworld.js +72 -72
  77. package/src/state/tilesets.js +53 -53
  78. package/src/state/world/index.d.ts +29 -29
  79. package/src/state/world/index.js +180 -180
  80. package/src/state/world/state.js +297 -297
package/src/runtime.js CHANGED
@@ -1,36 +1,36 @@
1
- import {DEFAULT_BASE_URL} from "./constants.js";
2
-
3
- export const isNode = () => typeof process !== "undefined" && Boolean(process.versions?.node);
4
- export const isBrowser = () => typeof window !== "undefined" && typeof document !== "undefined";
5
- export const normalizeBaseUrl = (baseUrl = DEFAULT_BASE_URL) => new URL(baseUrl, DEFAULT_BASE_URL).origin;
6
- export const resolveUrl = (baseUrl, path = "") => new URL(String(path).replace(/^\//, ""), `${normalizeBaseUrl(baseUrl)}/`).href;
7
- export const hostName = (baseUrl) => new URL(normalizeBaseUrl(baseUrl)).hostname;
8
- export const asNumber = (value, fallback = 0) => {
9
- const number = Number(value);
10
- return Number.isFinite(number) ? number : fallback;
11
- };
12
-
13
- export function debug(...args) {
14
- if (isNode() && process.env.DREDLESS_LOG === "1") console.log("[dredless]", ...args);
15
- }
16
-
17
- export function getFetch() {
18
- if (typeof fetch !== "function") throw new Error("globalThis.fetch is not available");
19
- return fetch.bind(globalThis);
20
- }
21
-
22
- let wsModulePromise = null;
23
-
24
- export async function getWebSocket() {
25
- if (isBrowser()) {
26
- if (typeof WebSocket !== "function") throw new Error("globalThis.WebSocket is not available");
27
- return WebSocket;
28
- }
29
- if (typeof WebSocket === "function" && WebSocket.name !== "WebSocket") return WebSocket;
30
- if (isNode()) {
31
- wsModulePromise ??= import("ws").then((module) => module.default || module.WebSocket || module);
32
- return wsModulePromise;
33
- }
34
- if (typeof WebSocket === "function") return WebSocket;
35
- throw new Error("globalThis.WebSocket is not available");
36
- }
1
+ import {DEFAULT_BASE_URL} from "./constants.js";
2
+
3
+ export const isNode = () => typeof process !== "undefined" && Boolean(process.versions?.node);
4
+ export const isBrowser = () => typeof window !== "undefined" && typeof document !== "undefined";
5
+ export const normalizeBaseUrl = (baseUrl = DEFAULT_BASE_URL) => new URL(baseUrl, DEFAULT_BASE_URL).origin;
6
+ export const resolveUrl = (baseUrl, path = "") => new URL(String(path).replace(/^\//, ""), `${normalizeBaseUrl(baseUrl)}/`).href;
7
+ export const hostName = (baseUrl) => new URL(normalizeBaseUrl(baseUrl)).hostname;
8
+ export const asNumber = (value, fallback = 0) => {
9
+ const number = Number(value);
10
+ return Number.isFinite(number) ? number : fallback;
11
+ };
12
+
13
+ export function debug(...args) {
14
+ if (isNode() && process.env.DREDLESS_LOG === "1") console.log("[dredless]", ...args);
15
+ }
16
+
17
+ export function getFetch() {
18
+ if (typeof fetch !== "function") throw new Error("globalThis.fetch is not available");
19
+ return fetch.bind(globalThis);
20
+ }
21
+
22
+ let wsModulePromise = null;
23
+
24
+ export async function getWebSocket() {
25
+ if (isBrowser()) {
26
+ if (typeof WebSocket !== "function") throw new Error("globalThis.WebSocket is not available");
27
+ return WebSocket;
28
+ }
29
+ if (typeof WebSocket === "function" && WebSocket.name !== "WebSocket") return WebSocket;
30
+ if (isNode()) {
31
+ wsModulePromise ??= import("ws").then((module) => module.default || module.WebSocket || module);
32
+ return wsModulePromise;
33
+ }
34
+ if (typeof WebSocket === "function") return WebSocket;
35
+ throw new Error("globalThis.WebSocket is not available");
36
+ }
@@ -1,32 +1,32 @@
1
- export interface GeneratorMazeCellWalls {
2
- up: boolean;
3
- down: boolean;
4
- left: boolean;
5
- right: boolean;
6
- }
7
-
8
- export interface GeneratorMazeCell {
9
- x: number;
10
- y: number;
11
- value: number;
12
- hex: string;
13
- digit: number;
14
- walls: GeneratorMazeCellWalls;
15
- backtrackDirection: number;
16
- marker: number;
17
- }
18
-
19
- export interface GeneratorMaze {
20
- seed: number;
21
- width: number;
22
- height: number;
23
- cells: GeneratorMazeCell[];
24
- rows: GeneratorMazeCell[][];
25
- solution: string;
26
- }
27
-
28
- export function generateGeneratorMaze(seed: number): GeneratorMaze;
29
-
30
- export function solveGeneratorMazeSeed(seed: number): string;
31
-
32
- export function maybeSolveGeneratorMazeSeed(seed: number | null | undefined): string | null;
1
+ export interface GeneratorMazeCellWalls {
2
+ up: boolean;
3
+ down: boolean;
4
+ left: boolean;
5
+ right: boolean;
6
+ }
7
+
8
+ export interface GeneratorMazeCell {
9
+ x: number;
10
+ y: number;
11
+ value: number;
12
+ hex: string;
13
+ digit: number;
14
+ walls: GeneratorMazeCellWalls;
15
+ backtrackDirection: number;
16
+ marker: number;
17
+ }
18
+
19
+ export interface GeneratorMaze {
20
+ seed: number;
21
+ width: number;
22
+ height: number;
23
+ cells: GeneratorMazeCell[];
24
+ rows: GeneratorMazeCell[][];
25
+ solution: string;
26
+ }
27
+
28
+ export function generateGeneratorMaze(seed: number): GeneratorMaze;
29
+
30
+ export function solveGeneratorMazeSeed(seed: number): string;
31
+
32
+ export function maybeSolveGeneratorMazeSeed(seed: number | null | undefined): string | null;