@fruit-pie/quicksave 0.1.0 → 1.0.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 (2) hide show
  1. package/dist/index.js +145 -156
  2. package/package.json +4 -9
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  //#region node_modules/@fruit-pie/sdk/dist/index.js
2
2
  var e = function(e) {
3
- let { manifest: t, hostApi: n, prefix: r, objects: i, internalReceive: a, internalCreate: o, normalizeEventName: s, context: c, queue: l, scratch: u } = e, d = /* @__PURE__ */ new Map();
3
+ let { identity: t, hostApi: n, prefix: r, objects: i, internalReceive: a, internalCreate: o, normalizeEventName: s, context: c, queue: l, scratch: u } = e, d = /* @__PURE__ */ new Map();
4
4
  for (let e of i) for (let n of Object.keys(e.receive ?? {})) {
5
5
  let r = s(n), i = d.get(r);
6
6
  if (i) throw Error(`mod ${t.id}: both ${i} and ${e.name} receive ${JSON.stringify(r)}. They would race for each message; give it to one of them.`);
@@ -157,7 +157,7 @@ var l = function(e) {
157
157
  for (let t of e.scripts) {
158
158
  let n = {};
159
159
  (t.args ?? []).forEach((i, a) => {
160
- if (!r.test(i)) throw Error(`mod ${e.manifest.id}: script ${JSON.stringify(t.name)} has an argument called ${JSON.stringify(i)}, which is not a usable name`);
160
+ if (!r.test(i)) throw Error(`mod ${e.identity.id}: script ${JSON.stringify(t.name)} has an argument called ${JSON.stringify(i)}, which is not a usable name`);
161
161
  n[i] = `argument${a}`;
162
162
  }), e.hostApi.resource.create({
163
163
  kind: "script",
@@ -287,7 +287,7 @@ var l = function(e) {
287
287
  a(r);
288
288
  return;
289
289
  }
290
- console.warn(`[${e.manifest.id}] sprite ${JSON.stringify(n)} failed: ${r.message}`), a(r);
290
+ console.warn(`[${e.identity.id}] sprite ${JSON.stringify(n)} failed: ${r.message}`), a(r);
291
291
  } else i(o);
292
292
  }, h = () => {
293
293
  clearTimeout(d), d = setTimeout(() => p(/* @__PURE__ */ Error(`the game stopped answering after ${l} of ${u.length} chunks`)), f);
@@ -434,7 +434,7 @@ while (${i("b64i")} < 64) {
434
434
  }
435
435
  ${r(y.hello)}`;
436
436
  }, C = function(e) {
437
- let { manifest: t, sprites: n, shown: r, spriteLoader: i, handlers: a } = e;
437
+ let { identity: t, sprites: n, shown: r, spriteLoader: i, handlers: a } = e;
438
438
  if (n.length === 0) return;
439
439
  let o = 0;
440
440
  a.set(y.hello, [() => {
@@ -458,161 +458,154 @@ ${r(y.hello)}`;
458
458
  i.failed(t < 0 ? "the game refused the picture" : e.slice(t + 1));
459
459
  }]);
460
460
  }, w = function(e) {
461
- let t = (e.split(".").pop() ?? e).replaceAll(/[^A-Za-z0-9]/gu, "").slice(0, 12), n = 2166136261;
461
+ let t = (e.split(/[/.]/u).pop() ?? e).replaceAll(/[^A-Za-z0-9]/gu, "").slice(0, 12), n = 2166136261;
462
462
  for (let t = 0; t < e.length; t += 1) n = Math.imul(n ^ e.charCodeAt(t), 16777619);
463
463
  return `m${t}_${((n >>> 0) % 65536).toString(16).padStart(4, "0")}_`;
464
- }, T = function(t, a) {
465
- let s = {
466
- ...t,
467
- apiVersion: 2
468
- };
469
- return {
470
- manifest: s,
471
- activate(t) {
472
- let d = w(s.id), f = [], p = [], m = [], h = [], g = [], _ = /* @__PURE__ */ new Map(), v = !0, y = (e) => {
473
- if (!n.test(e)) throw Error(`mod ${s.id}: ${JSON.stringify(e)} is not a usable event name (letters, digits, - and _, starting with a letter)`);
474
- return e.replaceAll("-", "_");
475
- }, T = (e) => `${d}__${e}`, E = (e) => {
476
- let t = {};
477
- for (let n of e.vars ?? []) {
478
- if (!r.test(n)) throw Error(`mod ${s.id}: ${JSON.stringify(n)} is not a usable variable name (letters, digits and _, starting with a letter)`);
479
- t[n] = `${d}v_${n}`;
480
- }
481
- return t;
482
- }, D = (e) => `global.${d}q_${e}`, O = (e, n = "") => t.send(`${e} ${n}`), k = (e, n) => t.gml.send(n ? `"${e} " + (${n})` : `"${e} "`), A = (e, t) => k(y(e), t), j = (e, ...t) => {
483
- if (!p.some((t) => t.name === e)) throw Error(`mod ${s.id}: call(${JSON.stringify(e)}) names a script this mod never declared. It has: ${p.map((e) => e.name).join(", ") || "none"}`);
484
- return `${d}s_${e}(${t.join(", ")})`;
485
- }, M = (e) => ({
486
- engine: t.target.engine,
487
- v: E(e),
488
- send: A,
489
- call: j
490
- }), N = b({
491
- hostApi: t,
492
- manifest: s,
493
- sendInternal: O
494
- }), P = /* @__PURE__ */ new Map(), F = t.game;
495
- a({
496
- engine: t.target.engine,
497
- content: F,
498
- resource: {
499
- object: { create(e) {
500
- if (!v) throw Error(`mod ${s.id}: objects can only be declared while the mod is built`);
501
- f.push(e);
502
- } },
503
- script: {
504
- create(e) {
505
- if (!v) throw Error(`mod ${s.id}: scripts can only be declared while the mod is built`);
506
- if (!r.test(e.name)) throw Error(`mod ${s.id}: ${JSON.stringify(e.name)} is not a usable script name (letters, digits and _, starting with a letter)`);
507
- if (p.some((t) => t.name === e.name)) throw Error(`mod ${s.id}: two scripts are called ${JSON.stringify(e.name)}`);
508
- p.push(e);
509
- },
510
- hook(e, t) {
511
- if (!v) throw Error(`mod ${s.id}: hooks can only be declared while the mod is built`);
512
- h.push({
513
- script: e,
514
- wrap: t
515
- });
516
- },
517
- insert(e) {
518
- if (!v) throw Error(`mod ${s.id}: insertions can only be declared while the mod is built`);
519
- g.push({
520
- at: c(s.id, e),
521
- place: e.place,
522
- body: e.body
523
- });
524
- }
464
+ }, T = function(t) {
465
+ return { activate(a) {
466
+ let s = a.identity, d = w(s.id), f = [], p = [], m = [], h = [], g = [], _ = /* @__PURE__ */ new Map(), v = !0, y = (e) => {
467
+ if (!n.test(e)) throw Error(`mod ${s.id}: ${JSON.stringify(e)} is not a usable event name (letters, digits, - and _, starting with a letter)`);
468
+ return e.replaceAll("-", "_");
469
+ }, T = (e) => `${d}__${e}`, E = (e) => {
470
+ let t = {};
471
+ for (let n of e.vars ?? []) {
472
+ if (!r.test(n)) throw Error(`mod ${s.id}: ${JSON.stringify(n)} is not a usable variable name (letters, digits and _, starting with a letter)`);
473
+ t[n] = `${d}v_${n}`;
474
+ }
475
+ return t;
476
+ }, D = (e) => `global.${d}q_${e}`, O = (e, t = "") => a.send(`${e} ${t}`), k = (e, t) => a.gml.send(t ? `"${e} " + (${t})` : `"${e} "`), A = (e, t) => k(y(e), t), j = (e, ...t) => {
477
+ if (!p.some((t) => t.name === e)) throw Error(`mod ${s.id}: call(${JSON.stringify(e)}) names a script this mod never declared. It has: ${p.map((e) => e.name).join(", ") || "none"}`);
478
+ return `${d}s_${e}(${t.join(", ")})`;
479
+ }, M = (e) => ({
480
+ engine: a.target.engine,
481
+ v: E(e),
482
+ send: A,
483
+ call: j
484
+ }), N = b({
485
+ hostApi: a,
486
+ identity: s,
487
+ sendInternal: O
488
+ }), P = /* @__PURE__ */ new Map(), F = a.game;
489
+ t({
490
+ engine: a.target.engine,
491
+ content: F,
492
+ resource: {
493
+ object: { create(e) {
494
+ if (!v) throw Error(`mod ${s.id}: objects can only be declared while the mod is built`);
495
+ f.push(e);
496
+ } },
497
+ script: {
498
+ create(e) {
499
+ if (!v) throw Error(`mod ${s.id}: scripts can only be declared while the mod is built`);
500
+ if (!r.test(e.name)) throw Error(`mod ${s.id}: ${JSON.stringify(e.name)} is not a usable script name (letters, digits and _, starting with a letter)`);
501
+ if (p.some((t) => t.name === e.name)) throw Error(`mod ${s.id}: two scripts are called ${JSON.stringify(e.name)}`);
502
+ p.push(e);
525
503
  },
526
- sprite: { create(e, t = {}) {
527
- if (!v) throw Error(`mod ${s.id}: sprites can only be declared while the mod is built`);
528
- if (!r.test(e)) throw Error(`mod ${s.id}: ${JSON.stringify(e)} is not a usable sprite name (letters, digits and _, starting with a letter)`);
529
- if (m.some((t) => t.name === e)) throw Error(`mod ${s.id}: two sprites are called ${JSON.stringify(e)}`);
530
- return m.push({
531
- name: e,
532
- options: t
533
- }), {
534
- id: `global.${d}spr_${e}`,
535
- load: (n) => (P.set(e, n), N.loadSprite(e, t, n))
536
- };
537
- } }
538
- },
539
- on(e, t) {
540
- let n = y(e), r = _.get(n);
541
- r ? r.push(t) : _.set(n, [t]);
542
- },
543
- onStart(e) {
544
- t.on("start", e);
545
- },
546
- scratchPath(e) {
547
- if (!i.test(e)) throw Error(`mod ${s.id}: ${JSON.stringify(e)} is not a usable scratch file name (letters, digits, _ . and -)`);
548
- return t.target.engine === "gm8" ? `temp_directory + "\\${d}${e}"` : `"${d}${e}"`;
504
+ hook(e, t) {
505
+ if (!v) throw Error(`mod ${s.id}: hooks can only be declared while the mod is built`);
506
+ h.push({
507
+ script: e,
508
+ wrap: t
509
+ });
510
+ },
511
+ insert(e) {
512
+ if (!v) throw Error(`mod ${s.id}: insertions can only be declared while the mod is built`);
513
+ g.push({
514
+ at: c(s.id, e),
515
+ place: e.place,
516
+ body: e.body
517
+ });
518
+ }
549
519
  },
550
- send(e, n = "") {
551
- t.send(`${y(e)} ${n}`);
552
- }
553
- }), v = !1, l({
554
- manifest: s,
555
- inserts: g,
556
- prefix: d,
557
- hostApi: t,
558
- send: A,
559
- call: j
560
- }), u({
561
- manifest: s,
562
- scripts: p,
563
- hostApi: t,
564
- prefix: d,
565
- send: A,
566
- call: j
567
- }), o({
568
- manifest: s,
569
- hooks: h,
570
- content: F,
571
- hostApi: t,
520
+ sprite: { create(e, t = {}) {
521
+ if (!v) throw Error(`mod ${s.id}: sprites can only be declared while the mod is built`);
522
+ if (!r.test(e)) throw Error(`mod ${s.id}: ${JSON.stringify(e)} is not a usable sprite name (letters, digits and _, starting with a letter)`);
523
+ if (m.some((t) => t.name === e)) throw Error(`mod ${s.id}: two sprites are called ${JSON.stringify(e)}`);
524
+ return m.push({
525
+ name: e,
526
+ options: t
527
+ }), {
528
+ id: `global.${d}spr_${e}`,
529
+ load: (n) => (P.set(e, n), N.loadSprite(e, t, n))
530
+ };
531
+ } }
532
+ },
533
+ on(e, t) {
534
+ let n = y(e), r = _.get(n);
535
+ r ? r.push(t) : _.set(n, [t]);
536
+ },
537
+ onStart(e) {
538
+ a.on("start", e);
539
+ },
540
+ scratchPath(e) {
541
+ if (!i.test(e)) throw Error(`mod ${s.id}: ${JSON.stringify(e)} is not a usable scratch file name (letters, digits, _ . and -)`);
542
+ return a.target.engine === "gm8" ? `temp_directory + "\\${d}${e}"` : `"${d}${e}"`;
543
+ },
544
+ send(e, t = "") {
545
+ a.send(`${y(e)} ${t}`);
546
+ }
547
+ }), v = !1, l({
548
+ identity: s,
549
+ inserts: g,
550
+ prefix: d,
551
+ hostApi: a,
552
+ send: A,
553
+ call: j
554
+ }), u({
555
+ identity: s,
556
+ scripts: p,
557
+ hostApi: a,
558
+ prefix: d,
559
+ send: A,
560
+ call: j
561
+ }), o({
562
+ identity: s,
563
+ hooks: h,
564
+ content: F,
565
+ hostApi: a,
566
+ prefix: d,
567
+ send: A,
568
+ call: j
569
+ }), e({
570
+ identity: s,
571
+ hostApi: a,
572
+ prefix: d,
573
+ objects: f,
574
+ internalReceive: x({
575
+ hostApi: a,
572
576
  prefix: d,
573
- send: A,
574
- call: j
575
- }), e({
576
- manifest: s,
577
- hostApi: t,
577
+ sprites: m,
578
+ payload: T("pl"),
579
+ sendInternalGml: k
580
+ }),
581
+ internalCreate: S({
578
582
  prefix: d,
579
- objects: f,
580
- internalReceive: x({
581
- hostApi: t,
582
- prefix: d,
583
- sprites: m,
584
- payload: T("pl"),
585
- sendInternalGml: k
586
- }),
587
- internalCreate: S({
588
- prefix: d,
589
- sprites: m,
590
- sendInternalGml: k
591
- }),
592
- normalizeEventName: y,
593
- context: M,
594
- queue: D,
595
- scratch: T
596
- }), C({
597
- manifest: s,
598
583
  sprites: m,
599
- shown: P,
600
- spriteLoader: N,
601
- handlers: _
602
- }), t.on("message", (e) => {
603
- let t = e.indexOf(" "), n = t < 0 ? e : e.slice(0, t), r = t < 0 ? "" : e.slice(t + 1), i = _.get(n);
604
- if (!i) {
605
- console.warn(`[${s.id}] no handler for ${JSON.stringify(n)}`);
606
- return;
607
- }
608
- for (let e of i) new Promise((t) => {
609
- t(e(r));
610
- }).catch((e) => {
611
- console.error(`[${s.id}] handling ${n} failed:`, e);
612
- });
584
+ sendInternalGml: k
585
+ }),
586
+ normalizeEventName: y,
587
+ context: M,
588
+ queue: D,
589
+ scratch: T
590
+ }), C({
591
+ identity: s,
592
+ sprites: m,
593
+ shown: P,
594
+ spriteLoader: N,
595
+ handlers: _
596
+ }), a.on("message", (e) => {
597
+ let t = e.indexOf(" "), n = t < 0 ? e : e.slice(0, t), r = t < 0 ? "" : e.slice(t + 1), i = _.get(n);
598
+ if (!i) {
599
+ console.warn(`[${s.id}] no handler for ${JSON.stringify(n)}`);
600
+ return;
601
+ }
602
+ for (let e of i) new Promise((t) => {
603
+ t(e(r));
604
+ }).catch((e) => {
605
+ console.error(`[${s.id}] handling ${n} failed:`, e);
613
606
  });
614
- }
615
- };
607
+ });
608
+ } };
616
609
  }, E = /* @__PURE__ */ new Set([
617
610
  "file_bin_open",
618
611
  "file_text_open_read",
@@ -1172,11 +1165,7 @@ file_text_close(qs_file);`
1172
1165
  "dropped",
1173
1166
  "refused"
1174
1167
  ]) e.on(t, (e) => console.log(`[quicksave] ${t}${e ? `: ${e}` : ""}`));
1175
- }, q = T({
1176
- id: "fruit-pie.quicksave",
1177
- name: "Quicksave",
1178
- version: "1.0.0"
1179
- }, (e) => {
1168
+ }, q = T((e) => {
1180
1169
  let t = V(e.content);
1181
1170
  t.ok ? K(e, t.value) : console.warn(`[quicksave] this game is not supported: ${t.error}`);
1182
1171
  });
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@fruit-pie/quicksave",
3
- "version": "0.1.0",
3
+ "version": "1.0.1",
4
+ "displayName": "Quicksave",
4
5
  "description": "Save anywhere between two of the game's saves, without touching its save files.",
5
6
  "type": "module",
6
7
  "main": "dist/index.js",
@@ -16,12 +17,6 @@
16
17
  "publishConfig": {
17
18
  "access": "public"
18
19
  },
19
- "fruitPieMod": {
20
- "manifestId": "fruit-pie.quicksave",
21
- "name": "Quicksave",
22
- "entry": "dist/index.js",
23
- "apiVersion": 2
24
- },
25
20
  "devDependencies": {
26
21
  "@types/node": "^24.13.4",
27
22
  "concurrently": "^10.0.5",
@@ -29,7 +24,7 @@
29
24
  "vite": "^8.3.0"
30
25
  },
31
26
  "dependencies": {
32
- "@fruit-pie/detect": "^1.0.0",
33
- "@fruit-pie/sdk": "^1.1.0"
27
+ "@fruit-pie/detect": "^2.0.0",
28
+ "@fruit-pie/sdk": "^2.0.0"
34
29
  }
35
30
  }