@lewismoten/gamemaker-sandbox-archives 0.0.0-stage → 3.2.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/dist/zip.js ADDED
@@ -0,0 +1,115 @@
1
+ const L = (() => {
2
+ const t = new Uint32Array(256);
3
+ for (let n = 0; n < 256; n++) {
4
+ let e = n;
5
+ for (let s = 0; s < 8; s++) e = e & 1 ? 3988292384 ^ e >>> 1 : e >>> 1;
6
+ t[n] = e >>> 0;
7
+ }
8
+ return t;
9
+ })();
10
+ function P(t) {
11
+ let n = 4294967295;
12
+ for (let e = 0; e < t.length; e++) n = L[(n ^ t[e]) & 255] ^ n >>> 8;
13
+ return (n ^ 4294967295) >>> 0;
14
+ }
15
+ async function Z(t, n) {
16
+ const e = new Response(new Blob([t]).stream().pipeThrough(n));
17
+ return new Uint8Array(await e.arrayBuffer());
18
+ }
19
+ const S = () => typeof CompressionStream < "u";
20
+ function k(t) {
21
+ const n = t.getHours() << 11 | t.getMinutes() << 5 | t.getSeconds() >> 1, e = Math.max(1980, t.getFullYear()) - 1980 << 9 | t.getMonth() + 1 << 5 | t.getDate();
22
+ return [n, e];
23
+ }
24
+ async function M(t, n = /* @__PURE__ */ new Date()) {
25
+ const e = new TextEncoder(), [s, i] = k(n), d = [], l = [];
26
+ let u = 0;
27
+ for (const r of t) {
28
+ const f = e.encode(r.name), U = P(r.data);
29
+ let m = 0, w = r.data;
30
+ if (S() && !r.store && r.data.length > 64) {
31
+ const p = await Z(r.data, new CompressionStream("deflate-raw"));
32
+ p.length < r.data.length && (m = 8, w = p);
33
+ }
34
+ const c = new DataView(new ArrayBuffer(30));
35
+ c.setUint32(0, 67324752, !0), c.setUint16(4, 20, !0), c.setUint16(6, 2048, !0), c.setUint16(8, m, !0), c.setUint16(10, s, !0), c.setUint16(12, i, !0), c.setUint32(14, U, !0), c.setUint32(18, w.length, !0), c.setUint32(22, r.data.length, !0), c.setUint16(26, f.length, !0), d.push(new Uint8Array(c.buffer), f, w);
36
+ const o = new DataView(new ArrayBuffer(46));
37
+ o.setUint32(0, 33639248, !0), o.setUint16(4, 20, !0), o.setUint16(6, 20, !0), o.setUint16(8, 2048, !0), o.setUint16(10, m, !0), o.setUint16(12, s, !0), o.setUint16(14, i, !0), o.setUint32(16, U, !0), o.setUint32(20, w.length, !0), o.setUint32(24, r.data.length, !0), o.setUint16(28, f.length, !0), r.mode !== void 0 && (o.setUint16(4, 788, !0), o.setUint32(38, r.mode << 16 >>> 0, !0)), o.setUint32(42, u, !0), l.push(new Uint8Array(o.buffer), f), u += 30 + f.length + w.length;
38
+ }
39
+ const g = l.reduce((r, f) => r + f.length, 0), a = new DataView(new ArrayBuffer(22));
40
+ a.setUint32(0, 101010256, !0), a.setUint16(8, t.length, !0), a.setUint16(10, t.length, !0), a.setUint32(12, g, !0), a.setUint32(16, u, !0);
41
+ const A = [...d, ...l, new Uint8Array(a.buffer)], y = new Uint8Array(A.reduce((r, f) => r + f.length, 0));
42
+ let h = 0;
43
+ for (const r of A)
44
+ y.set(r, h), h += r.length;
45
+ return y;
46
+ }
47
+ async function C(t, n) {
48
+ const e = new Blob([t]).stream().pipeThrough(new DecompressionStream("deflate-raw")).getReader(), s = [];
49
+ let i = 0;
50
+ for (; ; ) {
51
+ const { done: u, value: g } = await e.read();
52
+ if (u) break;
53
+ if (i += g.length, i > n)
54
+ throw await e.cancel(), new Error("A file in the ZIP is bigger than its directory says");
55
+ s.push(g);
56
+ }
57
+ const d = new Uint8Array(i);
58
+ let l = 0;
59
+ for (const u of s)
60
+ d.set(u, l), l += u.length;
61
+ return d;
62
+ }
63
+ function b(t, n) {
64
+ const e = new DataView(t.buffer, t.byteOffset, t.byteLength);
65
+ let s = -1;
66
+ for (let h = t.length - 22; h >= Math.max(0, t.length - 65557); h--)
67
+ if (e.getUint32(h, !0) === 101010256) {
68
+ s = h;
69
+ break;
70
+ }
71
+ if (s < 0) throw new Error("Not a ZIP file");
72
+ const i = e.getUint16(s + 10, !0);
73
+ if (n && i > n.maxEntries) throw new Error(`The ZIP holds ${i} entries, more than ${n.maxEntries}`);
74
+ let d = 0;
75
+ const l = e.getUint32(s + 12, !0), u = e.getUint32(s + 16, !0), g = Math.max(0, s - l - u);
76
+ let a = u + g;
77
+ const A = new TextDecoder(), y = [];
78
+ for (let h = 0; h < i; h++) {
79
+ if (a + 46 > t.length || e.getUint32(a, !0) !== 33639248) throw new Error("Damaged ZIP directory");
80
+ const r = e.getUint16(a + 10, !0), f = e.getUint32(a + 20, !0), U = e.getUint32(a + 24, !0), m = e.getUint16(a + 28, !0), w = e.getUint16(a + 30, !0), c = e.getUint16(a + 32, !0), o = e.getUint32(a + 42, !0) + g, p = A.decode(t.subarray(a + 46, a + 46 + m));
81
+ if (a += 46 + m + w + c, p.endsWith("/")) continue;
82
+ if (n && (d += U) > n.maxBytes) throw new Error(`The ZIP unpacks to more than ${n.maxBytes} bytes`);
83
+ const T = async () => {
84
+ if (o + 30 > t.length) throw new Error("Damaged ZIP entry");
85
+ const B = e.getUint16(o + 26, !0), I = e.getUint16(o + 28, !0), D = o + 30 + B + I, E = t.subarray(D, D + f);
86
+ if (r === 0) return E.slice();
87
+ if (r === 8)
88
+ try {
89
+ return await (n ? C(E, U) : Z(E, new DecompressionStream("deflate-raw")));
90
+ } catch (x) {
91
+ throw x instanceof TypeError ? new Error(`The ZIP entry ${p} is damaged (its compressed data does not unpack)`, { cause: x }) : x;
92
+ }
93
+ };
94
+ y.push({ name: p, size: U, read: T });
95
+ }
96
+ return y;
97
+ }
98
+ async function v(t, n) {
99
+ const e = [];
100
+ for (const s of b(t, n)) {
101
+ const i = await s.read();
102
+ i && e.push({ name: s.name, data: i });
103
+ }
104
+ return e;
105
+ }
106
+ function z(t) {
107
+ return t[0] === 80 && t[1] === 75 && t[2] === 3 && t[3] === 4;
108
+ }
109
+ export {
110
+ P as crc32,
111
+ M as createZip,
112
+ z as isZip,
113
+ b as listZip,
114
+ v as readZip
115
+ };
package/package.json CHANGED
@@ -1,6 +1,101 @@
1
1
  {
2
2
  "name": "@lewismoten/gamemaker-sandbox-archives",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "3.2.0",
4
+ "description": "Portable game discovery, ZIP/SFX extraction, and ZIP creation for Game-Maker files",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/lewismoten/GameMaker-SandboxEdition.git",
10
+ "directory": "web/packages/archives"
11
+ },
12
+ "engines": {
13
+ "node": ">=22.12.0"
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "CHANGELOG.md",
19
+ "LICENSE",
20
+ "NOTICE.md"
21
+ ],
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/types/index.d.ts",
25
+ "gamemaker-source": "./src/index.ts",
26
+ "import": "./dist/index.js"
27
+ },
28
+ "./zip": {
29
+ "types": "./dist/types/project/zip.d.ts",
30
+ "gamemaker-source": "./src/project/zip.ts",
31
+ "import": "./dist/zip.js"
32
+ },
33
+ "./pack": {
34
+ "types": "./dist/types/project/gamePack.d.ts",
35
+ "gamemaker-source": "./src/project/gamePack.ts",
36
+ "import": "./dist/pack.js"
37
+ },
38
+ "./scan": {
39
+ "types": "./dist/types/project/importScan.d.ts",
40
+ "gamemaker-source": "./src/project/importScan.ts",
41
+ "import": "./dist/scan.js"
42
+ },
43
+ "./player/applyPatches": {
44
+ "types": "./dist/types/player/applyPatches.d.ts",
45
+ "gamemaker-source": "./src/player/applyPatches.ts",
46
+ "import": "./dist/player/applyPatches.js"
47
+ },
48
+ "./player/md5": {
49
+ "types": "./dist/types/player/md5.d.ts",
50
+ "gamemaker-source": "./src/player/md5.ts",
51
+ "import": "./dist/player/md5.js"
52
+ },
53
+ "./project/extensionNames": {
54
+ "types": "./dist/types/project/extensionNames.d.ts",
55
+ "gamemaker-source": "./src/project/extensionNames.ts",
56
+ "import": "./dist/project/extensionNames.js"
57
+ },
58
+ "./project/gamePack": {
59
+ "types": "./dist/types/project/gamePack.d.ts",
60
+ "gamemaker-source": "./src/project/gamePack.ts",
61
+ "import": "./dist/pack.js"
62
+ },
63
+ "./project/importLeftovers": {
64
+ "types": "./dist/types/project/importLeftovers.d.ts",
65
+ "gamemaker-source": "./src/project/importLeftovers.ts",
66
+ "import": "./dist/project/importLeftovers.js"
67
+ },
68
+ "./project/importPlayer": {
69
+ "types": "./dist/types/project/importPlayer.d.ts",
70
+ "gamemaker-source": "./src/project/importPlayer.ts",
71
+ "import": "./dist/project/importPlayer.js"
72
+ },
73
+ "./project/importScan": {
74
+ "types": "./dist/types/project/importScan.d.ts",
75
+ "gamemaker-source": "./src/project/importScan.ts",
76
+ "import": "./dist/scan.js"
77
+ },
78
+ "./project/zip": {
79
+ "types": "./dist/types/project/zip.d.ts",
80
+ "gamemaker-source": "./src/project/zip.ts",
81
+ "import": "./dist/zip.js"
82
+ }
83
+ },
84
+ "scripts": {
85
+ "build": "node build.js",
86
+ "prepack": "npm run build",
87
+ "verify": "npm run build && node verify.js"
88
+ },
89
+ "devDependencies": {
90
+ "typescript": "~5.9.0",
91
+ "vite": "^7.1.0",
92
+ "@types/node": "^22.20.5"
93
+ },
94
+ "publishConfig": {
95
+ "registry": "https://npm.pkg.github.com/"
96
+ },
97
+ "dependencies": {
98
+ "@lewismoten/gamemaker-sandbox-engine": "^3.2.0"
99
+ },
100
+ "author": "Lewis Moten"
101
+ }