dredless 0.2.0 → 0.2.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.
Files changed (77) hide show
  1. package/README.md +48 -48
  2. package/docs/API_REFERENCE.md +2481 -2481
  3. package/docs/BROWSER_API.md +98 -98
  4. package/docs/NODE_API.md +359 -359
  5. package/package.json +34 -34
  6. package/src/browser.d.ts +212 -212
  7. package/src/browser.js +133 -133
  8. package/src/client/core.js +1202 -1202
  9. package/src/client/domains/index.js +1818 -1818
  10. package/src/client/index.d.ts +2 -2
  11. package/src/client/index.js +1 -1
  12. package/src/compression/lz4.d.ts +1 -1
  13. package/src/compression/lz4.js +112 -112
  14. package/src/constants.js +74 -74
  15. package/src/crypto/chacha-native.d.ts +9 -9
  16. package/src/crypto/chacha-native.js +48 -48
  17. package/src/crypto/chacha.d.ts +25 -25
  18. package/src/crypto/chacha.js +274 -274
  19. package/src/events.js +39 -39
  20. package/src/index.d.ts +2277 -2277
  21. package/src/index.js +125 -125
  22. package/src/network/browser-session.js +291 -291
  23. package/src/network/connection.d.ts +1 -1
  24. package/src/network/connection.js +31 -31
  25. package/src/network/cookies.js +85 -85
  26. package/src/network/http.js +34 -34
  27. package/src/network/index.d.ts +4 -4
  28. package/src/network/index.js +4 -4
  29. package/src/network/servers.d.ts +7 -7
  30. package/src/network/servers.js +133 -133
  31. package/src/network/session.d.ts +7 -7
  32. package/src/network/session.js +320 -320
  33. package/src/network/ships.d.ts +12 -12
  34. package/src/network/ships.js +73 -73
  35. package/src/node.d.ts +2 -2
  36. package/src/node.js +8 -8
  37. package/src/protocol/codec/binary.d.ts +3 -3
  38. package/src/protocol/codec/binary.js +52 -52
  39. package/src/protocol/codec/msgpack.d.ts +3 -3
  40. package/src/protocol/codec/msgpack.js +555 -555
  41. package/src/protocol/inbound/frame.d.ts +1 -1
  42. package/src/protocol/inbound/frame.js +8 -8
  43. package/src/protocol/inbound/world-payload.d.ts +3 -3
  44. package/src/protocol/inbound/world-payload.js +21 -21
  45. package/src/protocol/index.d.ts +11 -11
  46. package/src/protocol/index.js +19 -19
  47. package/src/protocol/outbound/blueprint.d.ts +22 -22
  48. package/src/protocol/outbound/blueprint.js +36 -36
  49. package/src/protocol/outbound/commands.d.ts +3 -3
  50. package/src/protocol/outbound/commands.js +149 -149
  51. package/src/protocol/outbound/comms.d.ts +28 -28
  52. package/src/protocol/outbound/comms.js +40 -40
  53. package/src/protocol/outbound/inventory.d.ts +64 -64
  54. package/src/protocol/outbound/inventory.js +147 -147
  55. package/src/protocol/outbound/ship-management.d.ts +84 -84
  56. package/src/protocol/outbound/ship-management.js +221 -221
  57. package/src/protocol/outbound/sign.d.ts +18 -18
  58. package/src/protocol/outbound/sign.js +45 -45
  59. package/src/protocol/outbound/ui-config.d.ts +157 -157
  60. package/src/protocol/outbound/ui-config.js +578 -578
  61. package/src/runtime.js +36 -36
  62. package/src/state/generator-maze.d.ts +32 -32
  63. package/src/state/generator-maze.js +370 -370
  64. package/src/state/index.d.ts +3 -3
  65. package/src/state/index.js +3 -3
  66. package/src/state/items.js +20 -20
  67. package/src/state/model/decoder.js +1554 -1554
  68. package/src/state/model/index.d.ts +33 -33
  69. package/src/state/model/index.js +2 -2
  70. package/src/state/model/loader-config.js +1020 -1020
  71. package/src/state/model/reader.js +69 -69
  72. package/src/state/model/state.js +1257 -1257
  73. package/src/state/overworld.js +72 -72
  74. package/src/state/tilesets.js +53 -53
  75. package/src/state/world/index.d.ts +29 -29
  76. package/src/state/world/index.js +180 -180
  77. package/src/state/world/state.js +297 -297
@@ -1,72 +1,72 @@
1
- export const OVERWORLD_ZONES = Object.freeze([
2
- Object.freeze({baseId: 0, key: "freeport", name: "Freeport", tiered: false, navDestination: false}),
3
- Object.freeze({baseId: 10, key: "hummingbird", name: "Hummingbird", tiered: false, navDestination: true}),
4
- Object.freeze({baseId: 20, key: "finch", name: "Finch", tiered: true, navDestination: true}),
5
- Object.freeze({baseId: 30, key: "sparrow", name: "Sparrow", tiered: true, navDestination: true}),
6
- Object.freeze({baseId: 40, key: "raven", name: "Raven", tiered: false, navDestination: true}),
7
- Object.freeze({baseId: 50, key: "falcon", name: "Falcon", tiered: false, navDestination: true}),
8
- Object.freeze({baseId: 60, key: "combat-arena", name: "Combat Arena", tiered: false, navDestination: true}),
9
- Object.freeze({baseId: 66, key: "mosaic", name: "Mosaic", tiered: false, navDestination: false})
10
- ]);
11
-
12
- const OVERWORLD_ZONE_BY_BASE_ID = new Map(OVERWORLD_ZONES.map((zone) => [zone.baseId, zone]));
13
- const NAVIGATION_ZONE_BY_BASE_ID = new Map(OVERWORLD_ZONES
14
- .filter((zone) => zone.navDestination)
15
- .map((zone) => [zone.baseId, zone]));
16
-
17
- function romanNumeral(value) {
18
- const numerals = [
19
- [1000, "M"], [900, "CM"], [500, "D"], [400, "CD"],
20
- [100, "C"], [90, "XC"], [50, "L"], [40, "XL"],
21
- [10, "X"], [9, "IX"], [5, "V"], [4, "IV"], [1, "I"]
22
- ];
23
- let remaining = Math.max(1, Math.trunc(Number(value) || 1));
24
- let out = "";
25
- for (const [amount, label] of numerals) {
26
- while (remaining >= amount) {
27
- out += label;
28
- remaining -= amount;
29
- }
30
- }
31
- return out;
32
- }
33
-
34
- export function overworldZoneFromBaseId(baseId) {
35
- const id = Number(baseId);
36
- return Number.isInteger(id) ? OVERWORLD_ZONE_BY_BASE_ID.get(id) || null : null;
37
- }
38
-
39
- export function navigationZoneFromBaseId(baseId) {
40
- const id = Number(baseId);
41
- return Number.isInteger(id) ? NAVIGATION_ZONE_BY_BASE_ID.get(id) || null : null;
42
- }
43
-
44
- export function overworldZoneFromId(overworldId) {
45
- const id = Number(overworldId);
46
- if (!Number.isInteger(id) || id < 0) return null;
47
- const exactZone = overworldZoneFromBaseId(id);
48
- if (exactZone) return overworldZoneSummary(exactZone, id, 0);
49
- const baseId = Math.floor(id / 10) * 10;
50
- const zone = overworldZoneFromBaseId(baseId);
51
- if (!zone?.tiered) return null;
52
- const layer = id - baseId;
53
- return overworldZoneSummary(zone, id, layer);
54
- }
55
-
56
- function overworldZoneSummary(zone, id, layer) {
57
- return {
58
- id,
59
- baseId: zone.baseId,
60
- layer,
61
- key: zone.key,
62
- name: zone.name,
63
- tiered: zone.tiered,
64
- displayName: zone.tiered ? `${zone.name} ${romanNumeral(layer + 1)}` : zone.name
65
- };
66
- }
67
-
68
- export function navigationDestinationFromEncodedValue(value) {
69
- if (typeof value !== "number" || !Number.isInteger(value)) return null;
70
- const baseId = value + 1;
71
- return navigationZoneFromBaseId(baseId) ? baseId : null;
72
- }
1
+ export const OVERWORLD_ZONES = Object.freeze([
2
+ Object.freeze({baseId: 0, key: "freeport", name: "Freeport", tiered: false, navDestination: false}),
3
+ Object.freeze({baseId: 10, key: "hummingbird", name: "Hummingbird", tiered: false, navDestination: true}),
4
+ Object.freeze({baseId: 20, key: "finch", name: "Finch", tiered: true, navDestination: true}),
5
+ Object.freeze({baseId: 30, key: "sparrow", name: "Sparrow", tiered: true, navDestination: true}),
6
+ Object.freeze({baseId: 40, key: "raven", name: "Raven", tiered: false, navDestination: true}),
7
+ Object.freeze({baseId: 50, key: "falcon", name: "Falcon", tiered: false, navDestination: true}),
8
+ Object.freeze({baseId: 60, key: "combat-arena", name: "Combat Arena", tiered: false, navDestination: true}),
9
+ Object.freeze({baseId: 66, key: "mosaic", name: "Mosaic", tiered: false, navDestination: false})
10
+ ]);
11
+
12
+ const OVERWORLD_ZONE_BY_BASE_ID = new Map(OVERWORLD_ZONES.map((zone) => [zone.baseId, zone]));
13
+ const NAVIGATION_ZONE_BY_BASE_ID = new Map(OVERWORLD_ZONES
14
+ .filter((zone) => zone.navDestination)
15
+ .map((zone) => [zone.baseId, zone]));
16
+
17
+ function romanNumeral(value) {
18
+ const numerals = [
19
+ [1000, "M"], [900, "CM"], [500, "D"], [400, "CD"],
20
+ [100, "C"], [90, "XC"], [50, "L"], [40, "XL"],
21
+ [10, "X"], [9, "IX"], [5, "V"], [4, "IV"], [1, "I"]
22
+ ];
23
+ let remaining = Math.max(1, Math.trunc(Number(value) || 1));
24
+ let out = "";
25
+ for (const [amount, label] of numerals) {
26
+ while (remaining >= amount) {
27
+ out += label;
28
+ remaining -= amount;
29
+ }
30
+ }
31
+ return out;
32
+ }
33
+
34
+ export function overworldZoneFromBaseId(baseId) {
35
+ const id = Number(baseId);
36
+ return Number.isInteger(id) ? OVERWORLD_ZONE_BY_BASE_ID.get(id) || null : null;
37
+ }
38
+
39
+ export function navigationZoneFromBaseId(baseId) {
40
+ const id = Number(baseId);
41
+ return Number.isInteger(id) ? NAVIGATION_ZONE_BY_BASE_ID.get(id) || null : null;
42
+ }
43
+
44
+ export function overworldZoneFromId(overworldId) {
45
+ const id = Number(overworldId);
46
+ if (!Number.isInteger(id) || id < 0) return null;
47
+ const exactZone = overworldZoneFromBaseId(id);
48
+ if (exactZone) return overworldZoneSummary(exactZone, id, 0);
49
+ const baseId = Math.floor(id / 10) * 10;
50
+ const zone = overworldZoneFromBaseId(baseId);
51
+ if (!zone?.tiered) return null;
52
+ const layer = id - baseId;
53
+ return overworldZoneSummary(zone, id, layer);
54
+ }
55
+
56
+ function overworldZoneSummary(zone, id, layer) {
57
+ return {
58
+ id,
59
+ baseId: zone.baseId,
60
+ layer,
61
+ key: zone.key,
62
+ name: zone.name,
63
+ tiered: zone.tiered,
64
+ displayName: zone.tiered ? `${zone.name} ${romanNumeral(layer + 1)}` : zone.name
65
+ };
66
+ }
67
+
68
+ export function navigationDestinationFromEncodedValue(value) {
69
+ if (typeof value !== "number" || !Number.isInteger(value)) return null;
70
+ const baseId = value + 1;
71
+ return navigationZoneFromBaseId(baseId) ? baseId : null;
72
+ }
@@ -1,53 +1,53 @@
1
- import {
2
- OFFICIAL_CLIENT_OVERWORLD_MATERIAL_NAMES,
3
- OFFICIAL_CLIENT_SUBWORLD_MATERIAL_NAMES,
4
- OFFICIAL_CLIENT_TILESETS
5
- } from "../data/official-client-data.js";
6
-
7
- function cloneFilter(filter) {
8
- if (!filter) return null;
9
- return {
10
- categoryBits: filter.categoryBits ?? 1,
11
- maskBits: filter.maskBits ?? 65535,
12
- groupIndex: filter.groupIndex ?? 0
13
- };
14
- }
15
-
16
- function cloneTile(tile) {
17
- const copy = {solid: Boolean(tile.solid)};
18
- if (tile.name != null) copy.name = tile.name;
19
- if (tile.destruct_item != null) copy.destruct_item = tile.destruct_item;
20
- if (tile.blocks_bullets != null) copy.blocks_bullets = tile.blocks_bullets;
21
- if (tile.hp != null) copy.hp = tile.hp;
22
- if (tile.no_build_surface != null) copy.no_build_surface = tile.no_build_surface;
23
- if (tile.physics != null) {
24
- copy.physics = {};
25
- if (tile.physics.friction != null) copy.physics.friction = tile.physics.friction;
26
- if (tile.physics.restitution != null) copy.physics.restitution = tile.physics.restitution;
27
- if (tile.physics.transparent != null) copy.physics.transparent = tile.physics.transparent;
28
- if (tile.physics.walkway != null) copy.physics.walkway = tile.physics.walkway;
29
- if (tile.physics.filter != null) copy.physics.filter = cloneFilter(tile.physics.filter);
30
- }
31
- return copy;
32
- }
33
-
34
- export function cloneTileset(tileset) {
35
- const materialNames = tileset.atlas === "tiles_subworld"
36
- ? OFFICIAL_CLIENT_SUBWORLD_MATERIAL_NAMES
37
- : tileset.atlas === "tiles_overworld"
38
- ? OFFICIAL_CLIENT_OVERWORLD_MATERIAL_NAMES
39
- : null;
40
- return {
41
- scale: tileset.scale,
42
- atlas: tileset.atlas,
43
- tile_width: tileset.tile_width,
44
- tiles: tileset.tiles.map((tile, materialId) => cloneTile({
45
- ...tile,
46
- name: materialNames?.get(materialId)
47
- }))
48
- };
49
- }
50
-
51
- export function getTilesetForWorld(isOverworld) {
52
- return cloneTileset(isOverworld ? OFFICIAL_CLIENT_TILESETS.overworld : OFFICIAL_CLIENT_TILESETS.subworld);
53
- }
1
+ import {
2
+ OFFICIAL_CLIENT_OVERWORLD_MATERIAL_NAMES,
3
+ OFFICIAL_CLIENT_SUBWORLD_MATERIAL_NAMES,
4
+ OFFICIAL_CLIENT_TILESETS
5
+ } from "../data/official-client-data.js";
6
+
7
+ function cloneFilter(filter) {
8
+ if (!filter) return null;
9
+ return {
10
+ categoryBits: filter.categoryBits ?? 1,
11
+ maskBits: filter.maskBits ?? 65535,
12
+ groupIndex: filter.groupIndex ?? 0
13
+ };
14
+ }
15
+
16
+ function cloneTile(tile) {
17
+ const copy = {solid: Boolean(tile.solid)};
18
+ if (tile.name != null) copy.name = tile.name;
19
+ if (tile.destruct_item != null) copy.destruct_item = tile.destruct_item;
20
+ if (tile.blocks_bullets != null) copy.blocks_bullets = tile.blocks_bullets;
21
+ if (tile.hp != null) copy.hp = tile.hp;
22
+ if (tile.no_build_surface != null) copy.no_build_surface = tile.no_build_surface;
23
+ if (tile.physics != null) {
24
+ copy.physics = {};
25
+ if (tile.physics.friction != null) copy.physics.friction = tile.physics.friction;
26
+ if (tile.physics.restitution != null) copy.physics.restitution = tile.physics.restitution;
27
+ if (tile.physics.transparent != null) copy.physics.transparent = tile.physics.transparent;
28
+ if (tile.physics.walkway != null) copy.physics.walkway = tile.physics.walkway;
29
+ if (tile.physics.filter != null) copy.physics.filter = cloneFilter(tile.physics.filter);
30
+ }
31
+ return copy;
32
+ }
33
+
34
+ export function cloneTileset(tileset) {
35
+ const materialNames = tileset.atlas === "tiles_subworld"
36
+ ? OFFICIAL_CLIENT_SUBWORLD_MATERIAL_NAMES
37
+ : tileset.atlas === "tiles_overworld"
38
+ ? OFFICIAL_CLIENT_OVERWORLD_MATERIAL_NAMES
39
+ : null;
40
+ return {
41
+ scale: tileset.scale,
42
+ atlas: tileset.atlas,
43
+ tile_width: tileset.tile_width,
44
+ tiles: tileset.tiles.map((tile, materialId) => cloneTile({
45
+ ...tile,
46
+ name: materialNames?.get(materialId)
47
+ }))
48
+ };
49
+ }
50
+
51
+ export function getTilesetForWorld(isOverworld) {
52
+ return cloneTileset(isOverworld ? OFFICIAL_CLIENT_TILESETS.overworld : OFFICIAL_CLIENT_TILESETS.subworld);
53
+ }
@@ -1,29 +1,29 @@
1
- export {
2
- WorldStore,
3
- WorldState,
4
- ModelState,
5
- type Tile,
6
- type TileDefinition,
7
- type Tileset,
8
- type OverworldZoneSummary,
9
- type ShipWorldMetadataSummary,
10
- type WorldSnapshot,
11
- type WorldUpdate,
12
- type CommsBubbleSummary,
13
- type ModelRecord,
14
- type ModelSnapshot,
15
- type TransformSummary,
16
- type EntitySummary,
17
- type BotSummary,
18
- type BlockSummary,
19
- type BlueprintPreviewSummary,
20
- type ThrusterSummary,
21
- type PusherSummary,
22
- type LoaderSummary,
23
- type SignSummary,
24
- type SpawnPointSummary,
25
- type DoorSummary,
26
- type ShieldProjectorSummary,
27
- type ShieldGeneratorSummary,
28
- type MachineSummary
29
- } from "../../index.js";
1
+ export {
2
+ WorldStore,
3
+ WorldState,
4
+ ModelState,
5
+ type Tile,
6
+ type TileDefinition,
7
+ type Tileset,
8
+ type OverworldZoneSummary,
9
+ type ShipWorldMetadataSummary,
10
+ type WorldSnapshot,
11
+ type WorldUpdate,
12
+ type CommsBubbleSummary,
13
+ type ModelRecord,
14
+ type ModelSnapshot,
15
+ type TransformSummary,
16
+ type EntitySummary,
17
+ type BotSummary,
18
+ type BlockSummary,
19
+ type BlueprintPreviewSummary,
20
+ type ThrusterSummary,
21
+ type PusherSummary,
22
+ type LoaderSummary,
23
+ type SignSummary,
24
+ type SpawnPointSummary,
25
+ type DoorSummary,
26
+ type ShieldProjectorSummary,
27
+ type ShieldGeneratorSummary,
28
+ type MachineSummary
29
+ } from "../../index.js";