@pixerate/editor 0.250.0 → 0.251.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.
Files changed (123) hide show
  1. package/dist/agent/index.cjs +40 -41
  2. package/dist/agent/index.js +9 -10
  3. package/dist/animation/index.cjs +6 -7
  4. package/dist/animation/index.js +5 -6
  5. package/dist/animation-editor/index.cjs +70 -70
  6. package/dist/animation-editor/index.js +12 -12
  7. package/dist/brushes/index.cjs +1406 -0
  8. package/dist/brushes/index.d.cts +12 -0
  9. package/dist/brushes/index.d.ts +12 -0
  10. package/dist/brushes/index.js +1406 -0
  11. package/dist/brushes/migrate.d.cts +17 -0
  12. package/dist/brushes/migrate.d.ts +17 -0
  13. package/dist/brushes/normalize.d.cts +15 -0
  14. package/dist/brushes/normalize.d.ts +15 -0
  15. package/dist/brushes/presets.d.cts +12 -0
  16. package/dist/brushes/presets.d.ts +12 -0
  17. package/dist/brushes/resolve.d.cts +56 -0
  18. package/dist/brushes/resolve.d.ts +56 -0
  19. package/dist/brushes/schema.d.cts +29 -0
  20. package/dist/brushes/schema.d.ts +29 -0
  21. package/dist/brushes/types.d.cts +323 -0
  22. package/dist/brushes/types.d.ts +323 -0
  23. package/dist/{brushstrokeRender-2FHFLSEG.js → brushstrokeRender-5PYSKZIJ.js} +8 -8
  24. package/dist/{brushstrokeRender-QGRXOKDA.cjs → brushstrokeRender-7FLLSQEC.cjs} +14 -14
  25. package/dist/canvas/index.cjs +57 -58
  26. package/dist/canvas/index.js +31 -32
  27. package/dist/chart/index.cjs +159 -160
  28. package/dist/chart/index.js +9 -10
  29. package/dist/{chunk-NOHJP5TK.js → chunk-2ZJ4DT3M.js} +1 -1
  30. package/dist/{chunk-XZNU4DUX.cjs → chunk-3NS5C7FB.cjs} +76 -76
  31. package/dist/{chunk-UTI5IITZ.cjs → chunk-4ZC5QJE2.cjs} +3 -3
  32. package/dist/{chunk-SMSGP2HQ.js → chunk-5JNA6LLY.js} +1 -1
  33. package/dist/{chunk-RD7RX52G.cjs → chunk-5UEFBM2M.cjs} +207 -18
  34. package/dist/{chunk-WA44NKPF.js → chunk-62Z5WLRA.js} +1 -1
  35. package/dist/{chunk-BVRRIW7F.js → chunk-6GRUVGKU.js} +3 -3
  36. package/dist/{chunk-QARCM66V.js → chunk-6ZZKRH7R.js} +3 -3
  37. package/dist/{chunk-BP6KSGVD.js → chunk-7272D3K2.js} +4 -6
  38. package/dist/{chunk-NTRAVM2I.js → chunk-7P6VF3FG.js} +2 -2
  39. package/dist/chunk-APX63ILU.js +173 -0
  40. package/dist/{chunk-W7L4HUT2.cjs → chunk-CJ6TBL2N.cjs} +16 -16
  41. package/dist/{chunk-7PT4RJL5.cjs → chunk-EUIDTZNQ.cjs} +111 -113
  42. package/dist/{chunk-CXXXAZ7H.js → chunk-F6R67I3A.js} +1 -1
  43. package/dist/{chunk-I7NJPHWV.cjs → chunk-FQPUF2W2.cjs} +35 -606
  44. package/dist/{chunk-D5KGAO4Z.js → chunk-GCVFEPJG.js} +2 -573
  45. package/dist/{chunk-LEQKZGQI.js → chunk-GOBOCZZI.js} +1 -1
  46. package/dist/{chunk-KDLBJ6QR.js → chunk-GYMMNCFT.js} +3 -3
  47. package/dist/{chunk-NUTMINJZ.cjs → chunk-H7ET2ISK.cjs} +52 -52
  48. package/dist/chunk-HS6QDWDF.cjs +1029 -0
  49. package/dist/{chunk-T7KQEMAE.cjs → chunk-HUAISCUX.cjs} +18 -18
  50. package/dist/{chunk-YGQVCQTG.js → chunk-ILP77UD6.js} +1 -1
  51. package/dist/{chunk-S6OT6CTS.cjs → chunk-IWEVV63O.cjs} +31 -33
  52. package/dist/{chunk-M2VKFE5L.cjs → chunk-JFHBXNR2.cjs} +88 -88
  53. package/dist/{chunk-WPUXGDH4.cjs → chunk-JPEHXIB5.cjs} +10 -10
  54. package/dist/chunk-JSDND7DF.cjs +173 -0
  55. package/dist/{chunk-36ZTV7WO.js → chunk-L6Y7TSQ4.js} +1 -1
  56. package/dist/{chunk-YW43M56C.cjs → chunk-LFMKWGFL.cjs} +1 -1
  57. package/dist/{chunk-V6DT2CDH.js → chunk-M2TPMYJE.js} +1 -1
  58. package/dist/{chunk-LJZRHVZV.cjs → chunk-M5GLQQWG.cjs} +2 -2
  59. package/dist/{chunk-JEGJP4OW.js → chunk-MHLU6GRJ.js} +196 -7
  60. package/dist/{chunk-KMPM5JM5.js → chunk-MONXNVZK.js} +4 -6
  61. package/dist/chunk-MTKY6K3Q.js +1029 -0
  62. package/dist/{chunk-MOW3JMNG.cjs → chunk-N76AMOKE.cjs} +42 -42
  63. package/dist/{chunk-75K3W4D6.cjs → chunk-NKGB64CW.cjs} +16 -16
  64. package/dist/{chunk-SGPIVHJB.js → chunk-P3K2JCJA.js} +3 -3
  65. package/dist/chunk-PXDIAYB6.cjs +594 -0
  66. package/dist/{chunk-3TWOCSCY.js → chunk-QC3OXRE4.js} +9 -9
  67. package/dist/{chunk-YM6ZBTXG.cjs → chunk-QLSGTCYT.cjs} +23 -23
  68. package/dist/{chunk-7YW7T5TJ.js → chunk-RHPSE2YR.js} +2 -2
  69. package/dist/{chunk-44BMJJVA.cjs → chunk-RUONPPMC.cjs} +8 -8
  70. package/dist/{chunk-ATK6ABN3.cjs → chunk-SABJMH6M.cjs} +145 -12
  71. package/dist/{chunk-XWOLPNBW.cjs → chunk-SOSBOS5T.cjs} +22 -22
  72. package/dist/{chunk-PPFJHTW5.cjs → chunk-TFF2GTGN.cjs} +22 -24
  73. package/dist/{chunk-X7WRL5ZZ.cjs → chunk-TLOGFIIV.cjs} +37 -37
  74. package/dist/chunk-TXFWZ5ZJ.js +594 -0
  75. package/dist/{chunk-GXAK6Q5J.js → chunk-UFEDHACQ.js} +2 -2
  76. package/dist/{chunk-GA4EU4P3.cjs → chunk-UXETV2NC.cjs} +4 -4
  77. package/dist/{chunk-N4DFDI73.js → chunk-WKMUBATU.js} +1 -1
  78. package/dist/{chunk-3R5P3DVY.cjs → chunk-WRZ6C4TU.cjs} +6 -6
  79. package/dist/{chunk-U4NUOKBT.js → chunk-WZOGDKCQ.js} +134 -1
  80. package/dist/{chunk-6ADHGQ73.js → chunk-YBAPT7NL.js} +2 -4
  81. package/dist/color/index.cjs +4 -6
  82. package/dist/color/index.js +7 -9
  83. package/dist/export/index.cjs +7 -8
  84. package/dist/export/index.js +6 -7
  85. package/dist/extensions/index.cjs +10 -11
  86. package/dist/extensions/index.js +9 -10
  87. package/dist/gradient/index.cjs +33 -34
  88. package/dist/gradient/index.js +4 -5
  89. package/dist/image-editor/index.cjs +845 -844
  90. package/dist/image-editor/index.js +39 -38
  91. package/dist/index.cjs +16 -17
  92. package/dist/index.js +10 -11
  93. package/dist/paint/index.cjs +6 -4
  94. package/dist/paint/index.js +21 -19
  95. package/dist/paint-editor/brushes.d.cts +1 -2
  96. package/dist/paint-editor/brushes.d.ts +1 -2
  97. package/dist/paint-editor/index.cjs +2193 -694
  98. package/dist/paint-editor/index.js +1575 -76
  99. package/dist/paint-editor/mark-settings.d.cts +104 -0
  100. package/dist/paint-editor/mark-settings.d.ts +104 -0
  101. package/dist/paint-editor/procedural.d.cts +2 -75
  102. package/dist/paint-editor/procedural.d.ts +2 -75
  103. package/dist/paint-editor/stickers.d.cts +1 -22
  104. package/dist/paint-editor/stickers.d.ts +1 -22
  105. package/dist/raster/index.cjs +2 -2
  106. package/dist/raster/index.js +9 -9
  107. package/dist/stickers/index.cjs +10 -10
  108. package/dist/stickers/index.js +9 -9
  109. package/dist/tokens/index.cjs +3 -4
  110. package/dist/tokens/index.js +2 -3
  111. package/dist/typography/index.cjs +7 -8
  112. package/dist/typography/index.js +2 -3
  113. package/dist/vector/index.cjs +974 -974
  114. package/dist/vector/index.js +12 -12
  115. package/dist/video-editor/index.cjs +6 -7
  116. package/dist/video-editor/index.js +5 -6
  117. package/package.json +11 -1
  118. package/dist/chunk-4JNWA3VT.cjs +0 -302
  119. package/dist/chunk-7AHBW2CQ.cjs +0 -200
  120. package/dist/chunk-F67XMVDI.js +0 -200
  121. package/dist/chunk-GT77U7QG.cjs +0 -2637
  122. package/dist/chunk-OTEPAQJX.js +0 -2637
  123. package/dist/chunk-WKH5ZAUA.js +0 -302
@@ -26,7 +26,7 @@ import {
26
26
  traceField,
27
27
  traceVectorImage,
28
28
  vectorTraceContours
29
- } from "../chunk-NOHJP5TK.js";
29
+ } from "../chunk-2ZJ4DT3M.js";
30
30
  import {
31
31
  applyHomography,
32
32
  homographyFromPoints,
@@ -53,7 +53,7 @@ import {
53
53
  reverseMorphContour,
54
54
  subpathToMorphContour,
55
55
  turnMorphContour
56
- } from "../chunk-NTRAVM2I.js";
56
+ } from "../chunk-7P6VF3FG.js";
57
57
  import {
58
58
  DEFAULT_VECTOR_FONT,
59
59
  IDENTITY_MATRIX,
@@ -526,9 +526,9 @@ import {
526
526
  withVectorStrokes,
527
527
  withVectorTargetPaint,
528
528
  zigzagPaths
529
- } from "../chunk-KDLBJ6QR.js";
530
- import "../chunk-OTEPAQJX.js";
531
- import "../chunk-WKH5ZAUA.js";
529
+ } from "../chunk-GYMMNCFT.js";
530
+ import "../chunk-MTKY6K3Q.js";
531
+ import "../chunk-APX63ILU.js";
532
532
  import {
533
533
  createProvenance
534
534
  } from "../chunk-M6DNZNVY.js";
@@ -566,16 +566,17 @@ import {
566
566
  import "../chunk-V2ZCJRDM.js";
567
567
  import {
568
568
  GRAIN_PATTERNS
569
- } from "../chunk-D5KGAO4Z.js";
569
+ } from "../chunk-TXFWZ5ZJ.js";
570
+ import "../chunk-GCVFEPJG.js";
570
571
  import "../chunk-4D6KP5BV.js";
571
572
  import "../chunk-ODBT55Q7.js";
572
- import "../chunk-IRSTHLQQ.js";
573
573
  import {
574
574
  bytesToBase64,
575
575
  decodePng,
576
576
  isPng,
577
577
  parseDataUrl
578
578
  } from "../chunk-OTTT5N3K.js";
579
+ import "../chunk-IRSTHLQQ.js";
579
580
  import "../chunk-HVVR5PZW.js";
580
581
  import {
581
582
  deflate
@@ -590,14 +591,13 @@ import {
590
591
  HistoryManager
591
592
  } from "../chunk-NS62CQ2B.js";
592
593
  import "../chunk-5UJHB3BW.js";
593
- import "../chunk-V6DT2CDH.js";
594
+ import "../chunk-M2TPMYJE.js";
594
595
  import {
595
596
  hexToRgba
596
597
  } from "../chunk-2WPNAGHI.js";
597
- import "../chunk-BP6KSGVD.js";
598
- import "../chunk-6ADHGQ73.js";
599
- import "../chunk-JEGJP4OW.js";
600
- import "../chunk-F67XMVDI.js";
598
+ import "../chunk-7272D3K2.js";
599
+ import "../chunk-YBAPT7NL.js";
600
+ import "../chunk-MHLU6GRJ.js";
601
601
  import "../chunk-6ONMQ6WF.js";
602
602
 
603
603
  // src/vector/stylize.ts
@@ -182,17 +182,16 @@ require('../chunk-2BSBFBOA.cjs');
182
182
  var _chunkWKPXOGZZcjs = require('../chunk-WKPXOGZZ.cjs');
183
183
 
184
184
 
185
- var _chunkLJZRHVZVcjs = require('../chunk-LJZRHVZV.cjs');
185
+ var _chunkM5GLQQWGcjs = require('../chunk-M5GLQQWG.cjs');
186
186
 
187
187
 
188
188
 
189
189
  var _chunkDWJJI6RTcjs = require('../chunk-DWJJI6RT.cjs');
190
- require('../chunk-UTI5IITZ.cjs');
190
+ require('../chunk-4ZC5QJE2.cjs');
191
191
  require('../chunk-A6QWKBJP.cjs');
192
- require('../chunk-7PT4RJL5.cjs');
193
- require('../chunk-PPFJHTW5.cjs');
194
- require('../chunk-RD7RX52G.cjs');
195
- require('../chunk-7AHBW2CQ.cjs');
192
+ require('../chunk-EUIDTZNQ.cjs');
193
+ require('../chunk-TFF2GTGN.cjs');
194
+ require('../chunk-5UEFBM2M.cjs');
196
195
  require('../chunk-IPJ3TEYR.cjs');
197
196
 
198
197
  // src/video-editor/parse.ts
@@ -3675,7 +3674,7 @@ var VideoEditorController = (_class8 = class _VideoEditorController {
3675
3674
  this.readOnly = _nullishCoalesce(options.readOnly, () => ( false));
3676
3675
  this.previewScale = checkPreviewScale(_nullishCoalesce(options.previewScale, () => ( "auto")));
3677
3676
  this.onChange = options.onChange;
3678
- this.player = new (0, _chunkLJZRHVZVcjs.AnimationPlayer)({ clock: options.clock, duration: () => _chunkZBCT5MEAcjs.videoProjectDuration.call(void 0, this.project), loop: "none" });
3677
+ this.player = new (0, _chunkM5GLQQWGcjs.AnimationPlayer)({ clock: options.clock, duration: () => _chunkZBCT5MEAcjs.videoProjectDuration.call(void 0, this.project), loop: "none" });
3679
3678
  this.state = this.computeState();
3680
3679
  this.connect();
3681
3680
  }
@@ -182,17 +182,16 @@ import {
182
182
  } from "../chunk-NS62CQ2B.js";
183
183
  import {
184
184
  AnimationPlayer
185
- } from "../chunk-CXXXAZ7H.js";
185
+ } from "../chunk-F6R67I3A.js";
186
186
  import {
187
187
  CUBIC_BEZIER_PRESETS,
188
188
  evaluateEasing
189
189
  } from "../chunk-5UJHB3BW.js";
190
- import "../chunk-V6DT2CDH.js";
190
+ import "../chunk-M2TPMYJE.js";
191
191
  import "../chunk-2WPNAGHI.js";
192
- import "../chunk-BP6KSGVD.js";
193
- import "../chunk-6ADHGQ73.js";
194
- import "../chunk-JEGJP4OW.js";
195
- import "../chunk-F67XMVDI.js";
192
+ import "../chunk-7272D3K2.js";
193
+ import "../chunk-YBAPT7NL.js";
194
+ import "../chunk-MHLU6GRJ.js";
196
195
  import "../chunk-6ONMQ6WF.js";
197
196
 
198
197
  // src/video-editor/parse.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor",
3
- "version": "0.250.0",
3
+ "version": "0.251.0",
4
4
  "description": "UI-agnostic rich text and media editing core library",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -194,6 +194,16 @@
194
194
  "default": "./dist/paint-editor/index.cjs"
195
195
  }
196
196
  },
197
+ "./brushes": {
198
+ "import": {
199
+ "types": "./dist/brushes/index.d.ts",
200
+ "default": "./dist/brushes/index.js"
201
+ },
202
+ "require": {
203
+ "types": "./dist/brushes/index.d.cts",
204
+ "default": "./dist/brushes/index.cjs"
205
+ }
206
+ },
197
207
  "./commands": {
198
208
  "import": {
199
209
  "types": "./dist/commands/index.d.ts",
@@ -1,302 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
2
-
3
- var _chunkU67EN7GGcjs = require('./chunk-U67EN7GG.cjs');
4
-
5
-
6
- var _chunk3K6HWEXZcjs = require('./chunk-3K6HWEXZ.cjs');
7
-
8
- // src/stickers/stamps.ts
9
- var STAMP_KINDS = ["dot", "star", "heart", "leaf", "flower", "confetti", "splat", "sparkle", "ring"];
10
- function stampCoverage(kind, u, v, t) {
11
- const r = Math.hypot(u, v);
12
- const a = Math.atan2(v, u);
13
- const edge = (d) => Math.min(1, Math.max(0, d * 24 + 0.5));
14
- switch (kind) {
15
- case "dot":
16
- return edge(0.95 - r);
17
- case "ring":
18
- return edge(Math.min(0.95 - r, r - 0.6));
19
- case "star": {
20
- const f = (a + Math.PI / 2) * 5 / (2 * Math.PI) % 1;
21
- const notch = Math.min(f < 0 ? f + 1 : f, 1 - (f < 0 ? f + 1 : f)) * 2;
22
- return edge(0.95 - 0.55 * notch - r);
23
- }
24
- case "sparkle": {
25
- const q = Math.pow(Math.abs(u) / 0.95, 0.6) + Math.pow(Math.abs(v) / 0.95, 0.6);
26
- return edge((1 - q) * 0.4);
27
- }
28
- case "heart": {
29
- const x = u * 1.1;
30
- const y = -v * 1.1 + 0.15;
31
- const q = x * x + y * y - 0.55;
32
- return edge(-(q * q * q - x * x * y * y * y) * 3);
33
- }
34
- case "leaf": {
35
- const w = 0.42 * Math.sqrt(Math.max(0, 1 - u * u));
36
- const inside = edge(w - Math.abs(v + 0.15 * u * u));
37
- const rib = Math.abs(v + 0.15 * u * u) < 0.03 && Math.abs(u) < 0.85 ? 0.65 : 1;
38
- return inside * rib;
39
- }
40
- case "flower": {
41
- const petals = 0.6 + 0.35 * Math.abs(Math.cos(2.5 * a));
42
- const body = edge(petals - r);
43
- return r < 0.22 ? Math.max(body, 1) * 0.85 : body;
44
- }
45
- case "confetti": {
46
- return edge(Math.min(0.9 - Math.abs(u), 0.35 - Math.abs(v)));
47
- }
48
- case "splat": {
49
- let rr = 0.55;
50
- for (let k = 1; k <= 3; k++) rr += 0.08 * Math.sin(a * (k + 2) + _chunk3K6HWEXZcjs.hash2.call(void 0, k, 1, t) * 6.28) / k;
51
- let c = edge(rr - r);
52
- for (let k = 0; k < 4; k++) {
53
- const ang = _chunk3K6HWEXZcjs.hash2.call(void 0, k, 7, t) * Math.PI * 2;
54
- const dist = 0.72 + 0.2 * _chunk3K6HWEXZcjs.hash2.call(void 0, k, 9, t);
55
- const dx = u - Math.cos(ang) * dist;
56
- const dy = v - Math.sin(ang) * dist;
57
- c = Math.max(c, edge(0.08 + 0.06 * _chunk3K6HWEXZcjs.hash2.call(void 0, k, 11, t) - Math.hypot(dx, dy)));
58
- }
59
- return c;
60
- }
61
- }
62
- }
63
-
64
- // src/stickers/helpers.ts
65
- var DEFAULT_STICKER_PAGE = 24;
66
- var MAX_STICKER_PAGE = 100;
67
- var EDITOR_STICKERS_ID = "editor";
68
- function checkStickerSearchOptions(options = {}) {
69
- if (options.limit !== void 0 && !(Number.isInteger(options.limit) && options.limit >= 1 && options.limit <= MAX_STICKER_PAGE)) {
70
- throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", `limit must be a whole number from 1 to ${MAX_STICKER_PAGE}, got ${options.limit}.`);
71
- }
72
- if (options.after !== void 0 && !/^\d+$/.test(options.after)) throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", `after "${options.after}" is not a cursor from this provider; pass the next value of the previous page.`);
73
- }
74
- var words = (s) => s.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean);
75
- function stickerPage(items, options = {}, query = "") {
76
- checkStickerSearchOptions(options);
77
- const q = words(query);
78
- const tags = (_nullishCoalesce(options.tags, () => ( []))).map((t) => t.toLowerCase());
79
- const matches = items.filter((s) => {
80
- if (options.category && s.category !== options.category) return false;
81
- if (tags.length && !tags.every((t) => (_nullishCoalesce(s.tags, () => ( []))).some((x) => x.toLowerCase() === t))) return false;
82
- if (_optionalChain([options, 'access', _2 => _2.licence, 'optionalAccess', _3 => _3.commercial]) === true && !s.licence.commercial) return false;
83
- if (!q.length) return true;
84
- const text = new Set(words([s.name, s.category, _nullishCoalesce(s.description, () => ( "")), ..._nullishCoalesce(s.tags, () => ( []))].join(" ")));
85
- return q.every((w) => [...text].some((t) => t.startsWith(w)));
86
- });
87
- const start = options.after ? Number(options.after) : 0;
88
- const limit = _nullishCoalesce(options.limit, () => ( DEFAULT_STICKER_PAGE));
89
- const page = matches.slice(start, start + limit);
90
- return { items: page, total: matches.length, ...start + limit < matches.length ? { next: String(start + limit) } : {} };
91
- }
92
- function parseStickerRef(ref) {
93
- if (typeof ref !== "string" || !ref) throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", 'A sticker ref is a "provider:id" string, e.g. "editor:star" (find_stickers lists them).');
94
- const i = ref.indexOf(":");
95
- if (i === -1) {
96
- if (STAMP_KINDS.includes(ref)) return { provider: EDITOR_STICKERS_ID, id: ref };
97
- throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", `"${ref}" is not a sticker ref; refs are "provider:id" (e.g. "editor:${STAMP_KINDS[1]}"); find_stickers lists them.`);
98
- }
99
- if (i === 0 || i === ref.length - 1) throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", `"${ref}" is not a sticker ref; refs are "provider:id".`);
100
- return { provider: ref.slice(0, i), id: ref.slice(i + 1) };
101
- }
102
- function normalizeStickerRef(ref) {
103
- const { provider, id } = parseStickerRef(ref);
104
- return `${provider}:${id}`;
105
- }
106
- function editorStampOf(ref) {
107
- const { provider, id } = parseStickerRef(ref);
108
- return provider === EDITOR_STICKERS_ID && STAMP_KINDS.includes(id) ? id : null;
109
- }
110
- function stickerRefOf(provider, id) {
111
- return provider.namespaced ? id : `${provider.id}:${id}`;
112
- }
113
- function stickerIdFor(provider, ref) {
114
- const { provider: owner, id } = parseStickerRef(ref);
115
- if (provider.namespaced) return `${owner}:${id}`;
116
- return owner === provider.id ? id : null;
117
- }
118
- function closestStickerRefs(wanted, candidates, n = 3) {
119
- const w = wanted.toLowerCase();
120
- const dist = (a, b) => {
121
- const d = Array.from({ length: b.length + 1 }, (_, j) => j);
122
- for (let i = 1; i <= a.length; i++) {
123
- let prev = d[0];
124
- d[0] = i;
125
- for (let j = 1; j <= b.length; j++) {
126
- const tmp = d[j];
127
- d[j] = Math.min(d[j] + 1, d[j - 1] + 1, prev + (a[i - 1] === b[j - 1] ? 0 : 1));
128
- prev = tmp;
129
- }
130
- }
131
- return d[b.length];
132
- };
133
- return [...candidates].sort((a, b) => dist(w, a.toLowerCase()) - dist(w, b.toLowerCase()) || a.localeCompare(b)).slice(0, n);
134
- }
135
- var StickersSlot = (_class = class {
136
- constructor(fallback) {;_class.prototype.__init.call(this);
137
- this.fallback = fallback;
138
- this.current = fallback;
139
- }
140
-
141
-
142
- __init() {this.listeners = /* @__PURE__ */ new Set()}
143
- get provider() {
144
- return this.current;
145
- }
146
- set(provider) {
147
- const next = _nullishCoalesce(provider, () => ( this.fallback));
148
- if (next === this.current) return;
149
- this.current = next;
150
- for (const l of [...this.listeners]) l(next);
151
- }
152
- subscribe(listener) {
153
- this.listeners.add(listener);
154
- return () => this.listeners.delete(listener);
155
- }
156
- }, _class);
157
-
158
- // src/stickers/tools.ts
159
- var READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
160
- var WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
161
- function stickerForAgent(provider, s) {
162
- const { id, thumbnail: _thumbnail, ...rest } = s;
163
- return { ref: stickerRefOf(provider, id), ...rest };
164
- }
165
- async function knownRefs(provider, cap = 500) {
166
- const refs = [];
167
- let after;
168
- while (refs.length < cap) {
169
- const page = await provider.list({ limit: MAX_STICKER_PAGE, ...after ? { after } : {} });
170
- refs.push(...page.items.map((s) => stickerRefOf(provider, s.id)));
171
- if (!page.next || !page.items.length) break;
172
- after = page.next;
173
- }
174
- return refs;
175
- }
176
- async function describeStickerRef(provider, ref) {
177
- parseStickerRef(ref);
178
- const id = stickerIdFor(provider, ref);
179
- const found = id === null ? void 0 : await provider.describe(id);
180
- if (found) return found;
181
- const near = closestStickerRefs(ref, await knownRefs(provider));
182
- const owner = parseStickerRef(ref).provider;
183
- const where = id === null && !provider.namespaced ? ` The sticker library is "${provider.id}", not "${owner}".` : "";
184
- throw new (0, _chunkU67EN7GGcjs.StickerError)("unknown_sticker", `No sticker "${ref}".${where} Closest: ${near.join(", ") || "none"}; find_stickers lists them.`);
185
- }
186
- function createStickerTools(options) {
187
- const find = {
188
- name: "find_stickers",
189
- title: "Find stickers",
190
- description: "Searches the sticker library (the editor's own stamps unless the host plugged in its own): words in the name, tags, category or description, filtered by category, tags and commercial licence, a small page at a time. Returns each sticker's ref (provider:id, for the tools that spray or place stickers), name, category, tags, natural width and height, formats, whether it is tintable (recoloured to the paint colour) and its licence, plus total and next (pass as after for the next page) and the categories. Changes nothing.",
191
- inputSchema: {
192
- type: "object",
193
- properties: {
194
- query: { type: "string", maxLength: 200, description: "Words to match (default: list everything)." },
195
- category: { type: "string", description: "Only this category (the result lists them)." },
196
- tags: { type: "array", maxItems: 10, items: { type: "string", description: "A tag." }, description: "Only stickers with every one of these tags." },
197
- commercial: { type: "boolean", description: "true: only stickers whose licence allows commercial use." },
198
- limit: { type: "integer", minimum: 1, maximum: MAX_STICKER_PAGE, description: "Page size (default 24)." },
199
- after: { type: "string", description: "next from the previous page." }
200
- },
201
- additionalProperties: false
202
- },
203
- annotations: { title: "Find stickers", ...READ },
204
- handler: async ({ query, category, tags, commercial, limit, after }) => {
205
- const p = options.provider();
206
- const categories = await _asyncNullishCoalesce(await _optionalChain([p, 'access', _4 => _4.categories, 'optionalCall', _5 => _5()]), async () => ( null));
207
- if (category !== void 0 && categories && !categories.some((c) => c.id === category)) {
208
- throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", `No category "${category}" in "${p.name}"; categories: ${categories.map((c) => c.id).join(", ")}.`);
209
- }
210
- const o = { ...category !== void 0 ? { category } : {}, ...tags ? { tags } : {}, ...commercial ? { licence: { commercial: true } } : {}, ...limit !== void 0 ? { limit } : {}, ...after !== void 0 ? { after } : {} };
211
- const q = typeof query === "string" ? query.trim() : "";
212
- if (q && !p.capabilities.supportsSearch) throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", `"${p.name}" can't search; leave query out and filter by category instead.`);
213
- const page = q ? await p.search(q, o) : await p.list(o);
214
- return { provider: p.id, items: page.items.map((s) => stickerForAgent(p, s)), total: page.total, ...page.next ? { next: page.next } : {}, ...categories ? { categories } : {} };
215
- }
216
- };
217
- const describe = {
218
- name: "describe_sticker",
219
- title: "Describe a sticker",
220
- description: "Everything about one sticker by ref (from find_stickers): name, category, tags, natural size, formats, tintable, licence (with any attribution it asks for), dominant colours, variants and its outline as SVG path data (silhouette). An unknown ref is refused with the closest refs. Changes nothing.",
221
- inputSchema: { type: "object", properties: { ref: { type: "string", description: "Sticker ref provider:id from find_stickers (e.g. editor:star)." } }, required: ["ref"], additionalProperties: false },
222
- annotations: { title: "Describe a sticker", ...READ },
223
- handler: async ({ ref }) => {
224
- const p = options.provider();
225
- const d = await describeStickerRef(p, ref);
226
- const { thumbnail: _thumbnail, id, ...rest } = d;
227
- return { ref: stickerRefOf(p, id), ...rest };
228
- }
229
- };
230
- return options.insert ? [find, describe, createInsertStickerTool(options.provider, options.insert)] : [find, describe];
231
- }
232
- async function loadForHost(provider, ref, d, host, colour, size) {
233
- const id = stickerIdFor(provider, ref);
234
- const format = d.formats.includes(host.format) ? host.format : _nullishCoalesce(d.formats[0], () => ( host.format));
235
- return provider.load(id, { format, ...format === "png" ? { size: Math.max(8, Math.min(_nullishCoalesce(provider.capabilities.maxSize, () => ( 1024)), Math.round(size))) } : {}, ...colour && d.tintable ? { colour } : {} });
236
- }
237
- async function insertSticker(provider, host, options) {
238
- const d = await describeStickerRef(provider, options.ref);
239
- if (options.color !== void 0 && !d.tintable) throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", `"${options.ref}" is not tintable (its art has its own colours); leave color out, or pick a tintable sticker (find_stickers lists tintable).`);
240
- if (options.width !== void 0 && !(options.width > 0)) throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", `width must be a positive size, got ${options.width}.`);
241
- const w = _nullishCoalesce(options.width, () => ( d.width));
242
- const h = w * d.height / d.width;
243
- const centre = host.defaultCentre();
244
- const asset = await loadForHost(provider, options.ref, d, host, options.color, Math.max(w, h));
245
- const ref = stickerRefOf(provider, d.id);
246
- const made = await host.insert({ ref, description: d, asset, x: _nullishCoalesce(options.x, () => ( centre.x)), y: _nullishCoalesce(options.y, () => ( centre.y)), width: w, height: h, ...options.color ? { colour: options.color.toLowerCase() } : {} });
247
- return { ...made, ref, width: w, height: h, licence: d.licence };
248
- }
249
- function createInsertStickerTool(provider, host) {
250
- return {
251
- name: "insert_sticker",
252
- title: "Insert a sticker",
253
- description: `Puts one sticker from the sticker library (ref from find_stickers) into the document as a new ${host.noun}, centred at x, y and width wide (its natural aspect kept; default its natural size), tinted to color when the sticker is tintable. Its art is loaded first; an unknown ref is refused with the closest ones. One undo step. Returns the new ${host.noun}'s id (for the editor's own tools, such as effects on it), the ref and its licence (credit any attribution it asks for).`,
254
- inputSchema: {
255
- type: "object",
256
- properties: {
257
- ref: { type: "string", minLength: 1, description: "Sticker ref provider:id from find_stickers (e.g. editor:star)." },
258
- x: { type: "number", description: "Centre x in document units (default the middle of the view or document)." },
259
- y: { type: "number", description: "Centre y in document units (default the middle of the view or document)." },
260
- width: { type: "number", exclusiveMinimum: 0, maximum: 1e4, description: "Width in document units (default the natural width); the height follows the aspect." },
261
- color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$", description: "Tint #rrggbb for tintable stickers (default the sticker's own colour); refused for stickers that are not tintable." }
262
- },
263
- required: ["ref"],
264
- additionalProperties: false
265
- },
266
- annotations: { title: "Insert a sticker", ...WRITE },
267
- handler: ({ ref, x, y, width, color }) => insertSticker(provider(), host, { ref, x, y, width, color })
268
- };
269
- }
270
- function createStickerToolProvider(options) {
271
- return {
272
- id: _nullishCoalesce(options.id, () => ( "stickers")),
273
- namespace: options.namespace,
274
- title: "Stickers",
275
- description: "Find and describe stickers from the sticker library, by ref (provider:id), for the editors that spray or place them.",
276
- skill: "pixerate-stickers",
277
- tools: createStickerTools(options)
278
- };
279
- }
280
-
281
-
282
-
283
-
284
-
285
-
286
-
287
-
288
-
289
-
290
-
291
-
292
-
293
-
294
-
295
-
296
-
297
-
298
-
299
-
300
-
301
-
302
- exports.STAMP_KINDS = STAMP_KINDS; exports.stampCoverage = stampCoverage; exports.DEFAULT_STICKER_PAGE = DEFAULT_STICKER_PAGE; exports.MAX_STICKER_PAGE = MAX_STICKER_PAGE; exports.EDITOR_STICKERS_ID = EDITOR_STICKERS_ID; exports.checkStickerSearchOptions = checkStickerSearchOptions; exports.stickerPage = stickerPage; exports.parseStickerRef = parseStickerRef; exports.normalizeStickerRef = normalizeStickerRef; exports.editorStampOf = editorStampOf; exports.stickerRefOf = stickerRefOf; exports.stickerIdFor = stickerIdFor; exports.closestStickerRefs = closestStickerRefs; exports.StickersSlot = StickersSlot; exports.stickerForAgent = stickerForAgent; exports.describeStickerRef = describeStickerRef; exports.createStickerTools = createStickerTools; exports.insertSticker = insertSticker; exports.createInsertStickerTool = createInsertStickerTool; exports.createStickerToolProvider = createStickerToolProvider;
@@ -1,200 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
-
5
-
6
-
7
-
8
- var _chunkIPJ3TEYRcjs = require('./chunk-IPJ3TEYR.cjs');
9
-
10
- // src/color/convert.ts
11
- function srgbToLinear(v) {
12
- const sign = Math.sign(v);
13
- const abs = Math.abs(v);
14
- return sign * (abs <= 0.04045 ? abs / 12.92 : ((abs + 0.055) / 1.055) ** 2.4);
15
- }
16
- function linearToSrgb(v) {
17
- const sign = Math.sign(v);
18
- const abs = Math.abs(v);
19
- return sign * (abs <= 31308e-7 ? 12.92 * abs : 1.055 * abs ** (1 / 2.4) - 0.055);
20
- }
21
- function rgbToHsl(rgba) {
22
- const { r, g, b, a } = rgba;
23
- const max = Math.max(r, g, b);
24
- const min = Math.min(r, g, b);
25
- const d = max - min;
26
- const l = (max + min) / 2;
27
- let h = 0;
28
- if (d > 0) {
29
- if (max === r) h = 60 * ((g - b) / d % 6);
30
- else if (max === g) h = 60 * ((b - r) / d + 2);
31
- else h = 60 * ((r - g) / d + 4);
32
- }
33
- if (h < 0) h += 360;
34
- const s = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1));
35
- return { h, s, l, alpha: a };
36
- }
37
- function hslToRgb(hsla) {
38
- const { h, s, l, alpha } = hsla;
39
- const hh = (h % 360 + 360) % 360 / 60;
40
- const c = (1 - Math.abs(2 * l - 1)) * s;
41
- const x = c * (1 - Math.abs(hh % 2 - 1));
42
- const m = l - c / 2;
43
- let r = 0;
44
- let g = 0;
45
- let b = 0;
46
- if (hh < 1) {
47
- r = c;
48
- g = x;
49
- b = 0;
50
- } else if (hh < 2) {
51
- r = x;
52
- g = c;
53
- b = 0;
54
- } else if (hh < 3) {
55
- r = 0;
56
- g = c;
57
- b = x;
58
- } else if (hh < 4) {
59
- r = 0;
60
- g = x;
61
- b = c;
62
- } else if (hh < 5) {
63
- r = x;
64
- g = 0;
65
- b = c;
66
- } else {
67
- r = c;
68
- g = 0;
69
- b = x;
70
- }
71
- return { r: r + m, g: g + m, b: b + m, a: alpha };
72
- }
73
- function rgbToHsv(rgba) {
74
- const { r, g, b, a } = rgba;
75
- const max = Math.max(r, g, b);
76
- const min = Math.min(r, g, b);
77
- const d = max - min;
78
- let h = 0;
79
- if (d > 0) {
80
- if (max === r) h = 60 * ((g - b) / d % 6);
81
- else if (max === g) h = 60 * ((b - r) / d + 2);
82
- else h = 60 * ((r - g) / d + 4);
83
- }
84
- if (h < 0) h += 360;
85
- const s = max === 0 ? 0 : d / max;
86
- return { h, s, v: max, alpha: a };
87
- }
88
- function hsvToRgb(hsva) {
89
- const { h, s, v, alpha } = hsva;
90
- const hh = (h % 360 + 360) % 360 / 60;
91
- const c = v * s;
92
- const x = c * (1 - Math.abs(hh % 2 - 1));
93
- const m = v - c;
94
- let r = 0;
95
- let g = 0;
96
- let b = 0;
97
- if (hh < 1) {
98
- r = c;
99
- g = x;
100
- b = 0;
101
- } else if (hh < 2) {
102
- r = x;
103
- g = c;
104
- b = 0;
105
- } else if (hh < 3) {
106
- r = 0;
107
- g = c;
108
- b = x;
109
- } else if (hh < 4) {
110
- r = 0;
111
- g = x;
112
- b = c;
113
- } else if (hh < 5) {
114
- r = x;
115
- g = 0;
116
- b = c;
117
- } else {
118
- r = c;
119
- g = 0;
120
- b = x;
121
- }
122
- return { r: r + m, g: g + m, b: b + m, a: alpha };
123
- }
124
- function rgbToOklab(rgba) {
125
- const lr = srgbToLinear(rgba.r);
126
- const lg = srgbToLinear(rgba.g);
127
- const lb = srgbToLinear(rgba.b);
128
- const l = Math.cbrt(0.4122214708 * lr + 0.5363325363 * lg + 0.0514459929 * lb);
129
- const m = Math.cbrt(0.2119034982 * lr + 0.6806995451 * lg + 0.1073969566 * lb);
130
- const s = Math.cbrt(0.0883024619 * lr + 0.2817188376 * lg + 0.6299787005 * lb);
131
- return {
132
- l: 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
133
- a: 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
134
- b: 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,
135
- alpha: rgba.a
136
- };
137
- }
138
- function oklabToRgb(lab) {
139
- const l_ = lab.l + 0.3963377774 * lab.a + 0.2158037573 * lab.b;
140
- const m_ = lab.l - 0.1055613458 * lab.a - 0.0638541728 * lab.b;
141
- const s_ = lab.l - 0.0894841775 * lab.a - 1.291485548 * lab.b;
142
- const l = l_ ** 3;
143
- const m = m_ ** 3;
144
- const s = s_ ** 3;
145
- return {
146
- r: linearToSrgb(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s),
147
- g: linearToSrgb(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s),
148
- b: linearToSrgb(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s),
149
- a: lab.alpha
150
- };
151
- }
152
- function oklabToOklch(lab) {
153
- const c = Math.hypot(lab.a, lab.b);
154
- let h = 0;
155
- if (c >= 1e-6) {
156
- h = Math.atan2(lab.b, lab.a) * 180 / Math.PI;
157
- if (h < 0) h += 360;
158
- if (h >= 360) h -= 360;
159
- }
160
- return { l: lab.l, c, h, alpha: lab.alpha };
161
- }
162
- function oklchToOklab(lch) {
163
- const rad = lch.h * Math.PI / 180;
164
- return {
165
- l: lch.l,
166
- a: lch.c * Math.cos(rad),
167
- b: lch.c * Math.sin(rad),
168
- alpha: lch.alpha
169
- };
170
- }
171
- var D65_XYZ = _chunkIPJ3TEYRcjs.xyToXyz.call(void 0, _chunkIPJ3TEYRcjs.D65_XY);
172
- var SRGB_TO_XYZ = _chunkIPJ3TEYRcjs.rgbToXyzMatrix.call(void 0, [0.64, 0.33], [0.3, 0.6], [0.15, 0.06], D65_XYZ);
173
- var P3_TO_XYZ = _chunkIPJ3TEYRcjs.rgbToXyzMatrix.call(void 0, [0.68, 0.32], [0.265, 0.69], [0.15, 0.06], D65_XYZ);
174
- var XYZ_TO_SRGB = _chunkIPJ3TEYRcjs.invert.call(void 0, SRGB_TO_XYZ);
175
- var XYZ_TO_P3 = _chunkIPJ3TEYRcjs.invert.call(void 0, P3_TO_XYZ);
176
- var P3_TO_SRGB_MAT = _chunkIPJ3TEYRcjs.mul.call(void 0, XYZ_TO_SRGB, P3_TO_XYZ);
177
- var SRGB_TO_P3_MAT = _chunkIPJ3TEYRcjs.mul.call(void 0, XYZ_TO_P3, SRGB_TO_XYZ);
178
- function linearSrgbToDisplayP3(rgb) {
179
- const out = _chunkIPJ3TEYRcjs.apply.call(void 0, SRGB_TO_P3_MAT, [rgb.r, rgb.g, rgb.b]);
180
- return { r: out[0], g: out[1], b: out[2], a: rgb.a };
181
- }
182
- function displayP3ToLinearSrgb(rgb) {
183
- const out = _chunkIPJ3TEYRcjs.apply.call(void 0, P3_TO_SRGB_MAT, [rgb.r, rgb.g, rgb.b]);
184
- return { r: out[0], g: out[1], b: out[2], a: rgb.a };
185
- }
186
-
187
-
188
-
189
-
190
-
191
-
192
-
193
-
194
-
195
-
196
-
197
-
198
-
199
-
200
- exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.rgbToHsv = rgbToHsv; exports.hsvToRgb = hsvToRgb; exports.rgbToOklab = rgbToOklab; exports.oklabToRgb = oklabToRgb; exports.oklabToOklch = oklabToOklch; exports.oklchToOklab = oklchToOklab; exports.linearSrgbToDisplayP3 = linearSrgbToDisplayP3; exports.displayP3ToLinearSrgb = displayP3ToLinearSrgb;