@algorisys/yappydraw 0.8.269 → 0.8.278

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.
@@ -1,4 +1,4 @@
1
- import { s as o, b as m, d as b, z as W, w as z, g as a, x as U, y as B } from "./index-N8KIsBvL.js";
1
+ import { s as o, b as m, d as b, z as W, w as z, g as a, x as U, y as B } from "./index-vjDu6_KH.js";
2
2
  const h = /* @__PURE__ */ new Set(), x = [], G = {
3
3
  ArrowLeft: "left",
4
4
  a: "left",
@@ -19,27 +19,27 @@ const h = /* @__PURE__ */ new Set(), x = [], G = {
19
19
  x: "b",
20
20
  X: "b",
21
21
  Shift: "b"
22
- }, j = (e) => {
22
+ }, q = (e) => {
23
23
  h.has(e) || (h.add(e), I(e));
24
24
  }, Q = (e) => {
25
25
  h.delete(e);
26
26
  }, I = (e) => {
27
- for (const i of x) i.button === e && L(i.fn);
28
- }, u = { x: 0, y: 0, down: !1 }, v = [], ee = (e, i) => {
29
- u.x = e, u.y = i;
30
- }, te = (e, i) => {
31
- u.x = e, u.y = i, u.down = !0;
32
- for (const s of v) L(() => s(e, i));
27
+ for (const r of x) r.button === e && L(r.fn);
28
+ }, u = { x: 0, y: 0, down: !1 }, v = [], ee = (e, r) => {
29
+ u.x = e, u.y = r;
30
+ }, te = (e, r) => {
31
+ u.x = e, u.y = r, u.down = !0;
32
+ for (const s of v) L(() => s(e, r));
33
33
  }, ne = () => {
34
34
  u.down = !1;
35
35
  };
36
36
  class A {
37
37
  id;
38
- constructor(i) {
39
- this.id = i;
38
+ constructor(r) {
39
+ this.id = r;
40
40
  }
41
41
  el() {
42
- return o.elements.find((i) => i.id === this.id);
42
+ return o.elements.find((r) => r.id === this.id);
43
43
  }
44
44
  get alive() {
45
45
  return !!this.el();
@@ -64,33 +64,33 @@ class A {
64
64
  }
65
65
  /** Center coordinates. */
66
66
  get cx() {
67
- const i = this.el();
68
- return i ? i.x + i.width / 2 : 0;
67
+ const r = this.el();
68
+ return r ? r.x + r.width / 2 : 0;
69
69
  }
70
70
  get cy() {
71
- const i = this.el();
72
- return i ? i.y + i.height / 2 : 0;
71
+ const r = this.el();
72
+ return r ? r.y + r.height / 2 : 0;
73
73
  }
74
- set(i) {
75
- return C(this.id, i), this;
74
+ set(r) {
75
+ return C(this.id, r), this;
76
76
  }
77
- moveTo(i, s) {
78
- return this.set({ x: i, y: s });
77
+ moveTo(r, s) {
78
+ return this.set({ x: r, y: s });
79
79
  }
80
- moveBy(i, s) {
81
- return this.set({ x: this.x + i, y: this.y + s });
80
+ moveBy(r, s) {
81
+ return this.set({ x: this.x + r, y: this.y + s });
82
82
  }
83
- centerAt(i, s) {
84
- return this.set({ x: i - this.width / 2, y: s - this.height / 2 });
83
+ centerAt(r, s) {
84
+ return this.set({ x: r - this.width / 2, y: s - this.height / 2 });
85
85
  }
86
- rotateBy(i) {
87
- return this.set({ angle: this.angle + i * Math.PI / 180 });
86
+ rotateBy(r) {
87
+ return this.set({ angle: this.angle + r * Math.PI / 180 });
88
88
  }
89
- color(i) {
90
- return this.set({ backgroundColor: i, fillStyle: "solid" });
89
+ color(r) {
90
+ return this.set({ backgroundColor: r, fillStyle: "solid" });
91
91
  }
92
- setText(i) {
93
- return this.set({ text: i });
92
+ setText(r) {
93
+ return this.set({ text: r });
94
94
  }
95
95
  hide() {
96
96
  return this.set({ opacity: 0 });
@@ -102,45 +102,45 @@ class A {
102
102
  H(this.id);
103
103
  }
104
104
  }
105
- const C = (e, i) => {
106
- a("elements", (s) => s.id === e, i);
105
+ const C = (e, r) => {
106
+ a("elements", (s) => s.id === e, r);
107
107
  }, H = (e) => {
108
- a("elements", (i) => i.filter((s) => s.id !== e));
108
+ a("elements", (r) => r.filter((s) => s.id !== e));
109
109
  };
110
110
  let g = null, y = null, w = [], k = 0, M = 0, c = null, T = !1, F = "", f = 0;
111
111
  const N = "SCORE ";
112
112
  let $ = null, V = !1, E = () => {
113
113
  };
114
- const ie = (e) => {
114
+ const re = (e) => {
115
115
  E = e;
116
- }, q = (e) => {
116
+ }, J = (e) => {
117
117
  $ = e, E();
118
118
  }, P = (e) => {
119
119
  T = e, V = e, E();
120
120
  }, L = (e) => {
121
121
  try {
122
122
  e();
123
- } catch (i) {
124
- console.error("[arcade] script error:", i), m(`Game error: ${i?.message || i}`, "error"), p();
123
+ } catch (r) {
124
+ console.error("[arcade] script error:", r), m(`Game error: ${r?.message || r}`, "error"), p();
125
125
  }
126
126
  }, K = (e) => {
127
127
  if (e.key === "Escape") {
128
128
  p();
129
129
  return;
130
130
  }
131
- const i = G[e.key];
132
- i && (e.preventDefault(), h.has(i) || (h.add(i), I(i)));
131
+ const r = G[e.key];
132
+ r && (e.preventDefault(), h.has(r) || (h.add(r), I(r)));
133
133
  }, O = (e) => {
134
- const i = G[e.key];
135
- i && h.delete(i);
134
+ const r = G[e.key];
135
+ r && h.delete(r);
136
136
  };
137
- let J = 0;
138
- function X() {
137
+ let X = 0;
138
+ function Y() {
139
139
  const e = o.slides[o.activeSlideIndex] || o.slides[0];
140
140
  return e ? { x: e.spatialPosition.x, y: e.spatialPosition.y, width: e.dimensions.width, height: e.dimensions.height } : { x: 0, y: 0, width: 800, height: 600 };
141
141
  }
142
- function Y() {
143
- const e = X(), i = {
142
+ function Z() {
143
+ const e = Y(), r = {
144
144
  strokeColor: "transparent",
145
145
  strokeWidth: 0,
146
146
  strokeStyle: "solid",
@@ -152,17 +152,17 @@ function Y() {
152
152
  locked: !1,
153
153
  layerId: o.activeLayerId || "default-layer",
154
154
  roundness: null
155
- }, s = (n, t, r, d, l, S) => {
155
+ }, s = (n, t, i, d, l, S) => {
156
156
  const D = {
157
- id: `game-${Date.now()}-${++J}`,
157
+ id: `game-${Date.now()}-${++X}`,
158
158
  type: n,
159
159
  x: t,
160
- y: r,
160
+ y: i,
161
161
  width: d,
162
162
  height: l,
163
163
  backgroundColor: "#3b82f6",
164
164
  seed: 1,
165
- ...i,
165
+ ...r,
166
166
  ...S
167
167
  };
168
168
  return a("elements", (R) => [...R, D]), new A(D.id);
@@ -184,12 +184,12 @@ function Y() {
184
184
  v.push(n);
185
185
  },
186
186
  find: (n) => {
187
- const t = o.elements.find((r) => r.id === n || r.tag === n || r.text === n);
187
+ const t = o.elements.find((i) => i.id === n || i.tag === n || i.text === n);
188
188
  return t ? new A(t.id) : null;
189
189
  },
190
190
  findAll: (n) => o.elements.filter((t) => t.id === n || t.tag === n || t.text === n).map((t) => new A(t.id)),
191
- spawn: (n, t, r, d, l, S) => s(n, t, r, d, l, S),
192
- spawnText: (n, t, r, d = 32, l) => s("text", t, r, Math.max(60, n.length * d * 0.6), d * 1.4, {
191
+ spawn: (n, t, i, d, l, S) => s(n, t, i, d, l, S),
192
+ spawnText: (n, t, i, d = 32, l) => s("text", t, i, Math.max(60, n.length * d * 0.6), d * 1.4, {
193
193
  text: n,
194
194
  fontSize: d,
195
195
  textColor: "#111827",
@@ -218,13 +218,13 @@ function Y() {
218
218
  score: (n) => {
219
219
  f += n;
220
220
  const t = N + f;
221
- if (c && o.elements.some((r) => r.id === c))
221
+ if (c && o.elements.some((i) => i.id === c))
222
222
  C(c, { text: t });
223
223
  else {
224
- const r = Math.round(e.width / 18);
225
- c = s("text", e.x + e.width * 0.1, e.y + 16, e.width * 0.8, r * 1.5, {
224
+ const i = Math.round(e.width / 18);
225
+ c = s("text", e.x + e.width * 0.1, e.y + 16, e.width * 0.8, i * 1.5, {
226
226
  text: t,
227
- fontSize: r,
227
+ fontSize: i,
228
228
  textColor: "#111827",
229
229
  textAlign: "center",
230
230
  backgroundColor: "transparent",
@@ -236,21 +236,21 @@ function Y() {
236
236
  },
237
237
  getScore: () => f,
238
238
  goToState: (n) => {
239
- const t = o.states.find((r) => r.name === n || r.id === n);
239
+ const t = o.states.find((i) => i.name === n || i.id === n);
240
240
  t && B(t.id);
241
241
  },
242
242
  playAnim: (n, t) => {
243
- n?.alive && import("./index-N8KIsBvL.js").then((r) => r.ap).then((r) => r.sequenceAnimator.playAnimation(n.id, { id: `bhv-${Date.now()}`, type: "preset", name: t, trigger: "programmatic" }, () => {
243
+ n?.alive && import("./index-vjDu6_KH.js").then((i) => i.aq).then((i) => i.sequenceAnimator.playAnimation(n.id, { id: `bhv-${Date.now()}`, type: "preset", name: t, trigger: "programmatic" }, () => {
244
244
  }));
245
245
  },
246
246
  goToPage: (n) => {
247
247
  n >= 0 && n < o.slides.length && U(n);
248
248
  },
249
249
  sound: (n) => {
250
- import("./index-N8KIsBvL.js").then((t) => t.aq).then((t) => t.playSfx(n));
250
+ import("./index-vjDu6_KH.js").then((t) => t.ar).then((t) => t.playSfx(n));
251
251
  },
252
252
  music: (n) => {
253
- import("./index-N8KIsBvL.js").then((t) => t.aq).then((t) => n ? t.startMusic() : t.stopMusic());
253
+ import("./index-vjDu6_KH.js").then((t) => t.ar).then((t) => n ? t.startMusic() : t.stopMusic());
254
254
  },
255
255
  end: (n) => {
256
256
  if (P(!0), n) {
@@ -266,16 +266,16 @@ function Y() {
266
266
  });
267
267
  }
268
268
  },
269
- pad: (n) => q(n),
269
+ pad: (n) => J(n),
270
270
  random: (n, t) => n + Math.random() * (t - n),
271
- clamp: (n, t, r) => Math.max(t, Math.min(r, n))
271
+ clamp: (n, t, i) => Math.max(t, Math.min(i, n))
272
272
  };
273
273
  }
274
- const re = () => o.gameActive;
275
- function Z(e) {
274
+ const ie = () => o.gameActive;
275
+ function _(e) {
276
276
  o.gameActive && p();
277
- const i = e ?? o.gameScript;
278
- if (!i?.trim())
277
+ const r = e ?? o.gameScript;
278
+ if (!r?.trim())
279
279
  return m("No game script yet — open Menu → Game Script…", "info"), !1;
280
280
  g = {
281
281
  elements: JSON.stringify(o.elements),
@@ -283,11 +283,11 @@ function Z(e) {
283
283
  activeSlideIndex: o.activeSlideIndex,
284
284
  appMode: o.appMode,
285
285
  viewState: { ...o.viewState }
286
- }, F = i, w = [], x.length = 0, v.length = 0, h.clear(), c = null, f = 0, P(!1), $ = null;
286
+ }, F = r, w = [], x.length = 0, v.length = 0, h.clear(), c = null, f = 0, P(!1), $ = null;
287
287
  let s;
288
288
  try {
289
289
  s = new Function("game", `'use strict';
290
- ${i}`);
290
+ ${r}`);
291
291
  } catch (t) {
292
292
  return m(`Game script error: ${t?.message || t}`, "error"), g = null, !1;
293
293
  }
@@ -295,19 +295,19 @@ ${i}`);
295
295
  a("selection", []), a("gameActive", !0), a("appMode", "presentation");
296
296
  }), W();
297
297
  try {
298
- s(Y());
298
+ s(Z());
299
299
  } catch (t) {
300
300
  return m(`Game error: ${t?.message || t}`, "error"), p(), !1;
301
301
  }
302
302
  window.addEventListener("keydown", K, !0), window.addEventListener("keyup", O, !0), k = performance.now(), M = k;
303
303
  const n = (t) => {
304
304
  y = requestAnimationFrame(n);
305
- const r = Math.min(0.05, (t - M) / 1e3);
305
+ const i = Math.min(0.05, (t - M) / 1e3);
306
306
  if (M = t, T) return;
307
307
  const d = (t - k) / 1e3;
308
308
  try {
309
309
  b(() => {
310
- for (const l of w) l(r, d);
310
+ for (const l of w) l(i, d);
311
311
  });
312
312
  } catch (l) {
313
313
  console.error("[arcade] tick error:", l), m(`Game error: ${l?.message || l}`, "error"), p();
@@ -316,7 +316,7 @@ ${i}`);
316
316
  return y = requestAnimationFrame(n), !0;
317
317
  }
318
318
  function p() {
319
- if (y !== null && (cancelAnimationFrame(y), y = null), window.removeEventListener("keydown", K, !0), window.removeEventListener("keyup", O, !0), import("./index-N8KIsBvL.js").then((e) => e.aq).then((e) => e.stopMusic()), h.clear(), w = [], x.length = 0, v.length = 0, g) {
319
+ if (y !== null && (cancelAnimationFrame(y), y = null), window.removeEventListener("keydown", K, !0), window.removeEventListener("keyup", O, !0), import("./index-vjDu6_KH.js").then((e) => e.ar).then((e) => e.stopMusic()), h.clear(), w = [], x.length = 0, v.length = 0, g) {
320
320
  const e = g;
321
321
  g = null, b(() => {
322
322
  a("elements", JSON.parse(e.elements)), a("selection", e.selection), a("activeSlideIndex", e.activeSlideIndex), a("appMode", e.appMode), a("gameActive", !1);
@@ -327,7 +327,7 @@ function p() {
327
327
  }
328
328
  function se() {
329
329
  const e = F;
330
- p(), e && Z(e);
330
+ p(), e && _(e);
331
331
  }
332
332
  export {
333
333
  A as Sprite,
@@ -335,12 +335,12 @@ export {
335
335
  te as gamePointerDown,
336
336
  ee as gamePointerMove,
337
337
  ne as gamePointerUp,
338
- re as isGameRunning,
339
- ie as onGameUiSignal,
340
- j as padPress,
338
+ ie as isGameRunning,
339
+ re as onGameUiSignal,
340
+ q as padPress,
341
341
  Q as padRelease,
342
342
  $ as padVisibleOverride,
343
343
  se as restartGame,
344
- Z as startGame,
344
+ _ as startGame,
345
345
  p as stopGame
346
346
  };