@algorisys/yappydraw 0.8.269 → 0.8.271

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/README.md CHANGED
@@ -20,7 +20,7 @@ Or with no install, from a CDN:
20
20
 
21
21
  ```html
22
22
  <script type="module">
23
- import { Yappy, mount } from 'https://cdn.jsdelivr.net/npm/@algorisys/yappydraw@0.8.269/yappy.js'
23
+ import { Yappy, mount } from 'https://cdn.jsdelivr.net/npm/@algorisys/yappydraw@0.8.271/yappy.js'
24
24
  </script>
25
25
  ```
26
26
 
@@ -42,4 +42,4 @@ Or with no install, from a CDN:
42
42
  - **Licence: AGPL-3.0-only**, as the rest of YappyDraw. Check that it suits your project before
43
43
  bundling it into software you distribute or run as a network service.
44
44
 
45
- Source: [algorisys-oss/yappydraw @ v0.8.269](https://github.com/algorisys-oss/yappydraw/tree/v0.8.269).
45
+ Source: [algorisys-oss/yappydraw @ v0.8.271](https://github.com/algorisys-oss/yappydraw/tree/v0.8.271).
@@ -1,5 +1,5 @@
1
1
  import { g as w, a as P, b as E, c as T } from "./ai-providers-CycU8sO1.js";
2
- import { s as u, b as r, p as y, u as b, _ as B, g as v, f as j } from "./index-N8KIsBvL.js";
2
+ import { s as u, b as r, p as y, u as b, $ as B, g as v, f as j } from "./index-Cbilitsx.js";
3
3
  const z = {
4
4
  rewrite: "Rewrite this text to be clearer and more engaging while keeping its meaning and rough length.",
5
5
  shorten: "Shorten this text to roughly half its length while keeping the key message.",
@@ -38,7 +38,7 @@ ${g.text}`,
38
38
  }
39
39
  return l > 0 ? r(`Magic Write updated ${l} text element${l === 1 ? "" : "s"}`, "success") : c || B(), l;
40
40
  }
41
- async function S(p, s, i) {
41
+ async function $(p, s, i) {
42
42
  const e = w("openai");
43
43
  if (!e) return { dataURL: null, error: "Add an OpenAI API key in AI Settings first" };
44
44
  try {
@@ -104,9 +104,9 @@ function D(p, s, i, e) {
104
104
  async function K(p, s = {}) {
105
105
  const i = s.size || "1024x1024", e = P("openai"), t = i === "1536x1024" ? "1792x1024" : i === "1024x1536" ? "1024x1792" : "1024x1024";
106
106
  r("Generating image…", "loading");
107
- let a = await S(p, e.startsWith("dall-e") ? t : i, e);
107
+ let a = await $(p, e.startsWith("dall-e") ? t : i, e);
108
108
  if (!a.dataURL && e !== "dall-e-3") {
109
- const l = await S(p, t, "dall-e-3");
109
+ const l = await $(p, t, "dall-e-3");
110
110
  l.dataURL && (a = l);
111
111
  }
112
112
  if (!a.dataURL)
@@ -215,14 +215,14 @@ async function Y(p, s = {}) {
215
215
  "prompt",
216
216
  (s.prompt?.trim() ? `${s.prompt.trim()}. ` : "") + "Extend the existing image seamlessly into the transparent areas, continuing its scene, lighting, style, and perspective. Keep the original (non-transparent) pixels unchanged."
217
217
  ), f.append("size", "auto");
218
- const { b64: L, error: $ } = await x(f, t);
218
+ const { b64: L, error: S } = await x(f, t);
219
219
  return L ? (y(), b(e.id, {
220
220
  dataURL: `data:image/png;base64,${L}`,
221
221
  x: e.x - e.width * a,
222
222
  y: e.y - e.height * o,
223
223
  width: e.width * (1 + a + n),
224
224
  height: e.height * (1 + o + l)
225
- }), r("Magic Expand applied", "success"), !0) : (r($ || "Magic Expand failed", "error"), !1);
225
+ }), r("Magic Expand applied", "success"), !0) : (r(S || "Magic Expand failed", "error"), !1);
226
226
  } catch (c) {
227
227
  return r(`Magic Expand failed: ${c?.message || c}`, "error"), !1;
228
228
  }
@@ -1,4 +1,4 @@
1
- import { h as r } from "./index-N8KIsBvL.js";
1
+ import { h as r } from "./index-Cbilitsx.js";
2
2
  const [s, t] = r(null);
3
3
  function a(e, n, i) {
4
4
  return s()?.resolve(null), new Promise((o) => t({ title: e, message: n, choices: i, resolve: o }));
@@ -1,7 +1,7 @@
1
1
  import { b as x, c as S } from "./ai-providers-CycU8sO1.js";
2
- import { b as u, $ as A, s as C, g as y, z as M, f as D } from "./index-N8KIsBvL.js";
3
- const $ = 'You are a senior graphic designer. Reply with ONLY a JSON object, no markdown fences, matching exactly: {"headline": string (max 6 words), "subhead": string (max 12 words), "bullets": string[] (0-4 short items), "cta": string (max 5 words, optional), "palette": {"background": hex, "primary": hex, "accent": hex, "text": hex}}. The palette must be harmonious with strong text/background contrast.';
4
- function P(r) {
2
+ import { b as u, a0 as A, s as C, g as y, z as M, f as D } from "./index-Cbilitsx.js";
3
+ const P = 'You are a senior graphic designer. Reply with ONLY a JSON object, no markdown fences, matching exactly: {"headline": string (max 6 words), "subhead": string (max 12 words), "bullets": string[] (0-4 short items), "cta": string (max 5 words, optional), "palette": {"background": hex, "primary": hex, "accent": hex, "text": hex}}. The palette must be harmonious with strong text/background contrast.';
4
+ function $(r) {
5
5
  try {
6
6
  const e = r.trim().replace(/^```(?:json)?\s*/i, "").replace(/\s*```$/, ""), n = JSON.parse(e);
7
7
  return !n?.headline || !n?.palette?.background ? null : n;
@@ -128,7 +128,7 @@ async function Y(r, e = { width: 1080, height: 1080 }) {
128
128
  provider: n,
129
129
  model: t,
130
130
  apiKey: o,
131
- systemPrompt: $,
131
+ systemPrompt: P,
132
132
  userPrompt: `Design brief: ${r.trim()}
133
133
  Format: ${e.width}×${e.height}px.`,
134
134
  temperature: 0.8,
@@ -136,7 +136,7 @@ Format: ${e.width}×${e.height}px.`,
136
136
  });
137
137
  if (!s.success)
138
138
  return u(s.error || "Design generation failed", "error"), !1;
139
- const i = P(s.content);
139
+ const i = $(s.content);
140
140
  if (!i)
141
141
  return u("The AI returned an unusable design — try again", "error"), !1;
142
142
  A("design", e);
@@ -1,6 +1,6 @@
1
1
  import { l as w, g as v, c as g } from "./ai-providers-CycU8sO1.js";
2
2
  import { a as x } from "./image-utils-CJQBaGoQ.js";
3
- import { a0 as A, a1 as N } from "./index-N8KIsBvL.js";
3
+ import { a1 as A, a2 as N } from "./index-Cbilitsx.js";
4
4
  function y() {
5
5
  return `You are a diagram generation assistant for YappyDraw. You output ONLY valid JSON DSL — no markdown fences, no explanation, no commentary. Just the raw JSON object.
6
6
 
@@ -1,18 +1,18 @@
1
- import { A as I, B as u, C as l, D as m, E as S, G as U, H as w, I as y, J as E, K as p, L as N, M as O, N as C } from "./index-N8KIsBvL.js";
1
+ import { A as I, B as u, C as l, D as m, E as S, G as U, H as w, I as E, b as N, J as y, K as O, L as p, M as T, N as C, O as G } from "./index-Cbilitsx.js";
2
2
  const f = "yappy:drawings:index", c = (t) => `yappy:drawing:${t}`;
3
- function G() {
3
+ function $() {
4
4
  return `d-${typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.floor(Math.random() * 1e9)}`}`;
5
5
  }
6
- function T(t) {
6
+ function J(t) {
7
7
  const n = t;
8
8
  return !!n.gameScript?.trim() || n.gameAuthoringMode === "code" || (n.sceneBehaviors?.length ?? 0) > 0 || n.blueprints && Object.keys(n.blueprints).length > 0 || Array.isArray(t.elements) && t.elements.some((a) => (a.behaviors?.length ?? 0) > 0);
9
9
  }
10
- class $ extends Error {
10
+ class M extends Error {
11
11
  constructor() {
12
12
  super("Local storage is unavailable — the drawing was not saved to disk."), this.name = "StorageUnavailableError";
13
13
  }
14
14
  }
15
- async function M() {
15
+ async function k() {
16
16
  return await m(f), S() === null;
17
17
  }
18
18
  async function o() {
@@ -22,34 +22,34 @@ async function g(t) {
22
22
  await y(f, t);
23
23
  }
24
24
  async function b(t, n = {}) {
25
- C();
26
- const a = JSON.stringify(t), i = (/* @__PURE__ */ new Date()).toISOString(), r = await o(), e = n.id ? r.find((d) => d.id === n.id) : void 0, s = e?.id ?? n.id ?? G(), A = (n.name ?? t.metadata?.name ?? e?.name ?? "Untitled").trim() || "Untitled", h = {
25
+ G();
26
+ const a = JSON.stringify(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = await o(), e = n.id ? i.find((d) => d.id === n.id) : void 0, s = e?.id ?? n.id ?? $(), A = (n.name ?? t.metadata?.name ?? e?.name ?? "Untitled").trim() || "Untitled", h = {
27
27
  id: s,
28
28
  name: A,
29
- createdAt: e?.createdAt ?? i,
30
- updatedAt: i,
29
+ createdAt: e?.createdAt ?? r,
30
+ updatedAt: r,
31
31
  docType: t.metadata?.docType ?? e?.docType,
32
32
  elementCount: Array.isArray(t.elements) ? t.elements.length : 0,
33
33
  pageCount: Array.isArray(t.slides) ? t.slides.length : 0,
34
34
  sizeBytes: a.length,
35
35
  thumb: n.thumb ?? e?.thumb,
36
- isGame: T(t)
37
- }, x = await y(c(s), a), v = [h, ...r.filter((d) => d.id !== s)];
38
- if (await g(v), !x) throw new $();
36
+ isGame: J(t)
37
+ }, x = await y(c(s), a), v = [h, ...i.filter((d) => d.id !== s)];
38
+ if (await g(v), !x) throw new M();
39
39
  return h;
40
40
  }
41
- async function j(t = {}) {
42
- const n = E(), a = t.name ?? p();
41
+ async function B(t = {}) {
42
+ const n = O(), a = t.name ?? p();
43
43
  a && a !== p() && w(a);
44
- let i;
44
+ let r;
45
45
  try {
46
- i = N();
46
+ r = T();
47
47
  } catch {
48
48
  }
49
- const r = t.forceNew ? void 0 : u() ?? void 0, e = await b(n, { id: r, name: a, thumb: i });
50
- return l(e.id), O(), e;
49
+ const i = t.forceNew ? void 0 : u() ?? void 0, e = await b(n, { id: i, name: a, thumb: r });
50
+ return l(e.id), C(), e;
51
51
  }
52
- async function k() {
52
+ async function K() {
53
53
  return o();
54
54
  }
55
55
  async function D(t) {
@@ -61,49 +61,49 @@ async function D(t) {
61
61
  return null;
62
62
  }
63
63
  }
64
- async function B(t) {
64
+ async function L(t) {
65
65
  const n = await D(t);
66
66
  if (!n) return !1;
67
67
  try {
68
68
  U(n);
69
- const i = (await o()).find((r) => r.id === t);
70
- return w(n.metadata?.name || i?.name || "Untitled"), l(t), !0;
69
+ const r = (await o()).find((i) => i.id === t);
70
+ return w(n.metadata?.name || r?.name || "Untitled"), l(t), !0;
71
71
  } catch (a) {
72
- return console.error("[drawings-store] open failed:", a), !1;
72
+ return a instanceof E && N(a.message, "error", 1e4), console.error("[drawings-store] open failed:", a), !1;
73
73
  }
74
74
  }
75
- async function K(t, n) {
76
- const a = n.trim() || "Untitled", i = await o(), r = i.find((s) => s.id === t);
77
- if (!r) return;
78
- r.name = a, r.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), await g(i);
75
+ async function R(t, n) {
76
+ const a = n.trim() || "Untitled", r = await o(), i = r.find((s) => s.id === t);
77
+ if (!i) return;
78
+ i.name = a, i.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), await g(r);
79
79
  const e = await D(t);
80
80
  e && (e.metadata = { ...e.metadata, name: a }, await y(c(t), JSON.stringify(e))), u() === t && w(a);
81
81
  }
82
- async function L(t) {
82
+ async function Y(t) {
83
83
  const n = await D(t);
84
84
  if (!n) return null;
85
- const i = (await o()).find((s) => s.id === t), r = `${i?.name ?? n.metadata?.name ?? "Untitled"} copy`, e = { ...n, metadata: { ...n.metadata, name: r } };
86
- return b(e, { name: r, thumb: i?.thumb });
85
+ const r = (await o()).find((s) => s.id === t), i = `${r?.name ?? n.metadata?.name ?? "Untitled"} copy`, e = { ...n, metadata: { ...n.metadata, name: i } };
86
+ return b(e, { name: i, thumb: r?.thumb });
87
87
  }
88
- async function R(t) {
88
+ async function _(t) {
89
89
  const n = await o();
90
90
  await g(n.filter((a) => a.id !== t)), await I(c(t)), u() === t && l(null);
91
91
  }
92
- async function Y() {
92
+ async function q() {
93
93
  return (await o()).length;
94
94
  }
95
95
  export {
96
- $ as StorageUnavailableError,
96
+ M as StorageUnavailableError,
97
97
  u as activeDrawingId,
98
- Y as countDrawings,
99
- R as deleteDrawing,
100
- L as duplicateDrawing,
101
- M as galleryReadable,
98
+ q as countDrawings,
99
+ _ as deleteDrawing,
100
+ Y as duplicateDrawing,
101
+ k as galleryReadable,
102
102
  D as getDrawingDoc,
103
- k as listDrawings,
104
- B as openDrawing,
105
- K as renameDrawing,
106
- j as saveCurrentToGallery,
103
+ K as listDrawings,
104
+ L as openDrawing,
105
+ R as renameDrawing,
106
+ B as saveCurrentToGallery,
107
107
  b as saveDrawingDoc,
108
108
  l as setActiveDrawingId
109
109
  };
@@ -1,4 +1,4 @@
1
- import { s as p, u as d, a as g } from "./index-N8KIsBvL.js";
1
+ import { s as p, u as d, a as g } from "./index-Cbilitsx.js";
2
2
  function x(n) {
3
3
  return n ? n.split(",").map((r) => r.trim()).filter((r) => r.length > 0) : [];
4
4
  }