@pixerate/editor 0.262.1 → 0.264.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/animation-editor/index.cjs +60 -60
- package/dist/animation-editor/index.js +4 -4
- package/dist/brushes/index.cjs +158 -71
- package/dist/brushes/index.d.cts +3 -3
- package/dist/brushes/index.d.ts +3 -3
- package/dist/brushes/index.js +113 -26
- package/dist/brushes/library.d.cts +2 -0
- package/dist/brushes/library.d.ts +2 -0
- package/dist/brushes/profiles.d.cts +21 -2
- package/dist/brushes/profiles.d.ts +21 -2
- package/dist/brushes/ui.d.cts +57 -4
- package/dist/brushes/ui.d.ts +57 -4
- package/dist/{brushstrokeRender-25Q5BEY6.js → brushstrokeRender-3MOI7PH4.js} +3 -3
- package/dist/{brushstrokeRender-N6UPZSQS.cjs → brushstrokeRender-SMMPIJF2.cjs} +13 -13
- package/dist/canvas/index.cjs +15 -14
- package/dist/canvas/index.js +3 -2
- package/dist/canvas/stickers.d.cts +5 -1
- package/dist/canvas/stickers.d.ts +5 -1
- package/dist/{chunk-X2EXYY4J.js → chunk-4OJC4MCD.js} +9 -8
- package/dist/{chunk-J5UQHWVL.js → chunk-6JL2D5SG.js} +27 -15
- package/dist/{chunk-APX63ILU.js → chunk-ACFSFUQH.js} +31 -0
- package/dist/{chunk-TZOX7KWV.cjs → chunk-BY5EBP26.cjs} +35 -14
- package/dist/{chunk-CQVTGBQI.js → chunk-CECCP2V7.js} +1 -1
- package/dist/{chunk-F7CPSRLN.js → chunk-DOZ6F2K2.js} +12 -4
- package/dist/{chunk-5IW65VQ6.js → chunk-EE7SAYBF.js} +24 -3
- package/dist/{chunk-PYTJBVW5.cjs → chunk-F3KKR6DD.cjs} +37 -36
- package/dist/{chunk-YLUIFXSL.cjs → chunk-FQC5TDB6.cjs} +35 -35
- package/dist/{chunk-UVZ7RQOE.cjs → chunk-G5ADO47G.cjs} +1 -1
- package/dist/{chunk-D4TE5JNW.js → chunk-HAUDEVMC.js} +1 -1
- package/dist/{chunk-EHALWBBD.js → chunk-JEML4FSA.js} +1 -1
- package/dist/{chunk-43NT242D.cjs → chunk-KXNZNOEF.cjs} +86 -86
- package/dist/{chunk-JSDND7DF.cjs → chunk-OTN6VB5S.cjs} +32 -1
- package/dist/{chunk-AVTPZO4Z.cjs → chunk-PE6YJMQT.cjs} +37 -25
- package/dist/{chunk-QAR2N7HZ.js → chunk-ROBSFJ6F.js} +1 -1
- package/dist/{chunk-7AUQ2UJ3.cjs → chunk-USJX5SW4.cjs} +10 -10
- package/dist/{chunk-3TQW5MPW.cjs → chunk-V7MJ4HIN.cjs} +23 -23
- package/dist/{chunk-6NZL24W4.js → chunk-WWI6FLH2.js} +1 -1
- package/dist/{chunk-RVGP2XLF.cjs → chunk-XORJ7UZO.cjs} +21 -13
- package/dist/image-editor/controller.d.cts +3 -0
- package/dist/image-editor/controller.d.ts +3 -0
- package/dist/image-editor/index.cjs +792 -788
- package/dist/image-editor/index.js +10 -6
- package/dist/image-editor/stickers.d.cts +7 -2
- package/dist/image-editor/stickers.d.ts +7 -2
- package/dist/image-editor/types.d.cts +7 -0
- package/dist/image-editor/types.d.ts +7 -0
- package/dist/paint-editor/brush-library-tools.d.cts +8 -1
- package/dist/paint-editor/brush-library-tools.d.ts +8 -1
- package/dist/paint-editor/controller.d.cts +7 -2
- package/dist/paint-editor/controller.d.ts +7 -2
- package/dist/paint-editor/index.cjs +581 -524
- package/dist/paint-editor/index.d.cts +1 -1
- package/dist/paint-editor/index.d.ts +1 -1
- package/dist/paint-editor/index.js +105 -48
- package/dist/paint-editor/sticker-art.d.cts +20 -10
- package/dist/paint-editor/sticker-art.d.ts +20 -10
- package/dist/paint-editor/stickers.d.cts +8 -1
- package/dist/paint-editor/stickers.d.ts +8 -1
- package/dist/paint-editor/stroke.d.cts +2 -0
- package/dist/paint-editor/stroke.d.ts +2 -0
- package/dist/stickers/browser.d.cts +10 -3
- package/dist/stickers/browser.d.ts +10 -3
- package/dist/stickers/combine.d.cts +2 -0
- package/dist/stickers/combine.d.ts +2 -0
- package/dist/stickers/conformance.d.cts +1 -1
- package/dist/stickers/conformance.d.ts +1 -1
- package/dist/stickers/errors.d.cts +1 -1
- package/dist/stickers/errors.d.ts +1 -1
- package/dist/stickers/fake.d.cts +4 -2
- package/dist/stickers/fake.d.ts +4 -2
- package/dist/stickers/helpers.d.cts +16 -2
- package/dist/stickers/helpers.d.ts +16 -2
- package/dist/stickers/index.cjs +116 -29
- package/dist/stickers/index.js +106 -19
- package/dist/stickers/tools.d.cts +9 -2
- package/dist/stickers/tools.d.ts +9 -2
- package/dist/stickers/types.d.cts +32 -5
- package/dist/stickers/types.d.ts +32 -5
- package/dist/vector/controller.d.cts +13 -0
- package/dist/vector/controller.d.ts +13 -0
- package/dist/vector/index.cjs +1218 -1207
- package/dist/vector/index.js +19 -8
- package/dist/vector/stickers.d.cts +7 -2
- package/dist/vector/stickers.d.ts +7 -2
- package/package.json +1 -1
- package/skills/pixerate-brushes/SKILL.md +11 -3
- package/skills/pixerate-brushes-design/SKILL.md +1 -0
- package/skills/pixerate-stickers/SKILL.md +20 -9
- package/skills/pixerate-vector/SKILL.md +1 -1
|
@@ -61,6 +61,9 @@ function stampCoverage(kind, u, v, t) {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
// src/stickers/types.ts
|
|
65
|
+
var STICKER_VARIANTS = ["light", "dark"];
|
|
66
|
+
|
|
64
67
|
// src/stickers/helpers.ts
|
|
65
68
|
var DEFAULT_STICKER_PAGE = 24;
|
|
66
69
|
var MAX_STICKER_PAGE = 100;
|
|
@@ -78,6 +81,7 @@ function stickerPage(items, options = {}, query = "") {
|
|
|
78
81
|
const tags = (_nullishCoalesce(options.tags, () => ( []))).map((t) => t.toLowerCase());
|
|
79
82
|
const matches = items.filter((s) => {
|
|
80
83
|
if (options.category && s.category !== options.category) return false;
|
|
84
|
+
if (options.collection && s.collection !== options.collection) return false;
|
|
81
85
|
if (tags.length && !tags.every((t) => (_nullishCoalesce(s.tags, () => ( []))).some((x) => x.toLowerCase() === t))) return false;
|
|
82
86
|
if (_optionalChain([options, 'access', _2 => _2.licence, 'optionalAccess', _3 => _3.commercial]) === true && !s.licence.commercial) return false;
|
|
83
87
|
if (!q.length) return true;
|
|
@@ -89,6 +93,28 @@ function stickerPage(items, options = {}, query = "") {
|
|
|
89
93
|
const page = matches.slice(start, start + limit);
|
|
90
94
|
return { items: page, total: matches.length, ...start + limit < matches.length ? { next: String(start + limit) } : {} };
|
|
91
95
|
}
|
|
96
|
+
function stickerVariantsOf(s) {
|
|
97
|
+
return STICKER_VARIANTS.filter((v) => v === "light" || _optionalChain([s, 'access', _4 => _4.variants, 'optionalAccess', _5 => _5.includes, 'call', _6 => _6(v)]));
|
|
98
|
+
}
|
|
99
|
+
function checkStickerVariant(s, variant) {
|
|
100
|
+
const v = _nullishCoalesce(variant, () => ( "light"));
|
|
101
|
+
const has = stickerVariantsOf(s);
|
|
102
|
+
if (!has.includes(v)) throw new (0, _chunkU67EN7GGcjs.StickerError)("unsupported_variant", `Sticker "${s.id}" has no ${JSON.stringify(v)} variant; it has ${has.join(", ")}.`);
|
|
103
|
+
return v;
|
|
104
|
+
}
|
|
105
|
+
function stickerVariantFor(s, dark) {
|
|
106
|
+
return dark && _optionalChain([s, 'access', _7 => _7.variants, 'optionalAccess', _8 => _8.includes, 'call', _9 => _9("dark")]) ? "dark" : "light";
|
|
107
|
+
}
|
|
108
|
+
function stickerCollections(items, names = {}) {
|
|
109
|
+
const out = /* @__PURE__ */ new Map();
|
|
110
|
+
for (const s of items) {
|
|
111
|
+
if (!s.collection) continue;
|
|
112
|
+
const c = _nullishCoalesce(out.get(s.collection), () => ( { id: s.collection, ..._nullishCoalesce(names[s.collection], () => ( { name: s.collection })), count: 0 }));
|
|
113
|
+
c.count++;
|
|
114
|
+
out.set(s.collection, c);
|
|
115
|
+
}
|
|
116
|
+
return [...out.values()];
|
|
117
|
+
}
|
|
92
118
|
function parseStickerRef(ref) {
|
|
93
119
|
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
120
|
const i = ref.indexOf(":");
|
|
@@ -170,4 +196,9 @@ var StickersSlot = (_class = class {
|
|
|
170
196
|
|
|
171
197
|
|
|
172
198
|
|
|
173
|
-
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
exports.STAMP_KINDS = STAMP_KINDS; exports.stampCoverage = stampCoverage; exports.STICKER_VARIANTS = STICKER_VARIANTS; 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.stickerVariantsOf = stickerVariantsOf; exports.checkStickerVariant = checkStickerVariant; exports.stickerVariantFor = stickerVariantFor; exports.stickerCollections = stickerCollections; exports.parseStickerRef = parseStickerRef; exports.normalizeStickerRef = normalizeStickerRef; exports.editorStampOf = editorStampOf; exports.stickerRefOf = stickerRefOf; exports.stickerIdFor = stickerIdFor; exports.closestStickerRefs = closestStickerRefs; exports.StickersSlot = StickersSlot;
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunkOTN6VB5Scjs = require('./chunk-OTN6VB5S.cjs');
|
|
8
11
|
|
|
9
12
|
|
|
10
13
|
var _chunkU67EN7GGcjs = require('./chunk-U67EN7GG.cjs');
|
|
@@ -14,26 +17,26 @@ var READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, o
|
|
|
14
17
|
var WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
|
|
15
18
|
function stickerForAgent(provider, s) {
|
|
16
19
|
const { id, thumbnail: _thumbnail, ...rest } = s;
|
|
17
|
-
return { ref:
|
|
20
|
+
return { ref: _chunkOTN6VB5Scjs.stickerRefOf.call(void 0, provider, id), ...rest };
|
|
18
21
|
}
|
|
19
22
|
async function knownRefs(provider, cap = 500) {
|
|
20
23
|
const refs = [];
|
|
21
24
|
let after;
|
|
22
25
|
while (refs.length < cap) {
|
|
23
|
-
const page = await provider.list({ limit:
|
|
24
|
-
refs.push(...page.items.map((s) =>
|
|
26
|
+
const page = await provider.list({ limit: _chunkOTN6VB5Scjs.MAX_STICKER_PAGE, ...after ? { after } : {} });
|
|
27
|
+
refs.push(...page.items.map((s) => _chunkOTN6VB5Scjs.stickerRefOf.call(void 0, provider, s.id)));
|
|
25
28
|
if (!page.next || !page.items.length) break;
|
|
26
29
|
after = page.next;
|
|
27
30
|
}
|
|
28
31
|
return refs;
|
|
29
32
|
}
|
|
30
33
|
async function describeStickerRef(provider, ref) {
|
|
31
|
-
|
|
32
|
-
const id =
|
|
34
|
+
_chunkOTN6VB5Scjs.parseStickerRef.call(void 0, ref);
|
|
35
|
+
const id = _chunkOTN6VB5Scjs.stickerIdFor.call(void 0, provider, ref);
|
|
33
36
|
const found = id === null ? void 0 : await provider.describe(id);
|
|
34
37
|
if (found) return found;
|
|
35
|
-
const near =
|
|
36
|
-
const owner =
|
|
38
|
+
const near = _chunkOTN6VB5Scjs.closestStickerRefs.call(void 0, ref, await knownRefs(provider));
|
|
39
|
+
const owner = _chunkOTN6VB5Scjs.parseStickerRef.call(void 0, ref).provider;
|
|
37
40
|
const where = id === null && !provider.namespaced ? ` The sticker library is "${provider.id}", not "${owner}".` : "";
|
|
38
41
|
throw new (0, _chunkU67EN7GGcjs.StickerError)("unknown_sticker", `No sticker "${ref}".${where} Closest: ${near.join(", ") || "none"}; find_stickers lists them.`);
|
|
39
42
|
}
|
|
@@ -41,70 +44,78 @@ function createStickerTools(options) {
|
|
|
41
44
|
const find = {
|
|
42
45
|
name: "find_stickers",
|
|
43
46
|
title: "Find stickers",
|
|
44
|
-
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
|
|
47
|
+
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, collection, 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), its licence, aiGenerated when the provider says whether AI made the art, variants (light, and dark when it has art for dark backgrounds) and its collection, plus total and next (pass as after for the next page), the categories and the collections. Changes nothing.",
|
|
45
48
|
inputSchema: {
|
|
46
49
|
type: "object",
|
|
47
50
|
properties: {
|
|
48
51
|
query: { type: "string", maxLength: 200, description: "Words to match (default: list everything)." },
|
|
49
52
|
category: { type: "string", description: "Only this category (the result lists them)." },
|
|
53
|
+
collection: { type: "string", minLength: 1, description: "Only this collection id (the result lists them; default every collection)." },
|
|
50
54
|
tags: { type: "array", maxItems: 10, items: { type: "string", description: "A tag." }, description: "Only stickers with every one of these tags." },
|
|
51
55
|
commercial: { type: "boolean", description: "true: only stickers whose licence allows commercial use." },
|
|
52
|
-
limit: { type: "integer", minimum: 1, maximum:
|
|
56
|
+
limit: { type: "integer", minimum: 1, maximum: _chunkOTN6VB5Scjs.MAX_STICKER_PAGE, description: "Page size (default 24)." },
|
|
53
57
|
after: { type: "string", description: "next from the previous page." }
|
|
54
58
|
},
|
|
55
59
|
additionalProperties: false
|
|
56
60
|
},
|
|
57
61
|
annotations: { title: "Find stickers", ...READ },
|
|
58
|
-
handler: async ({ query, category, tags, commercial, limit, after }) => {
|
|
62
|
+
handler: async ({ query, category, collection, tags, commercial, limit, after }) => {
|
|
59
63
|
const p = options.provider();
|
|
60
64
|
const categories = await _asyncNullishCoalesce(await _optionalChain([p, 'access', _ => _.categories, 'optionalCall', _2 => _2()]), async () => ( null));
|
|
61
65
|
if (category !== void 0 && categories && !categories.some((c) => c.id === category)) {
|
|
62
66
|
throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", `No category "${category}" in "${p.name}"; categories: ${categories.map((c) => c.id).join(", ")}.`);
|
|
63
67
|
}
|
|
64
|
-
const
|
|
68
|
+
const collections = await _asyncNullishCoalesce(await _optionalChain([p, 'access', _3 => _3.listCollections, 'optionalCall', _4 => _4()]), async () => ( null));
|
|
69
|
+
if (collection !== void 0 && !_optionalChain([collections, 'optionalAccess', _5 => _5.some, 'call', _6 => _6((c) => c.id === collection)])) {
|
|
70
|
+
throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", _optionalChain([collections, 'optionalAccess', _7 => _7.length]) ? `No collection "${collection}" in "${p.name}"; collections: ${collections.map((c) => c.id).join(", ")}.` : `"${p.name}" has no collections; leave collection out.`);
|
|
71
|
+
}
|
|
72
|
+
const o = { ...category !== void 0 ? { category } : {}, ...collection !== void 0 ? { collection } : {}, ...tags ? { tags } : {}, ...commercial ? { licence: { commercial: true } } : {}, ...limit !== void 0 ? { limit } : {}, ...after !== void 0 ? { after } : {} };
|
|
65
73
|
const q = typeof query === "string" ? query.trim() : "";
|
|
66
74
|
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.`);
|
|
67
75
|
const page = q ? await p.search(q, o) : await p.list(o);
|
|
68
|
-
return { provider: p.id, items: page.items.map((s) => stickerForAgent(p, s)), total: page.total, ...page.next ? { next: page.next } : {}, ...categories ? { categories } : {} };
|
|
76
|
+
return { provider: p.id, items: page.items.map((s) => stickerForAgent(p, s)), total: page.total, ...page.next ? { next: page.next } : {}, ...categories ? { categories } : {}, ..._optionalChain([collections, 'optionalAccess', _8 => _8.length]) ? { collections } : {} };
|
|
69
77
|
}
|
|
70
78
|
};
|
|
71
79
|
const describe = {
|
|
72
80
|
name: "describe_sticker",
|
|
73
81
|
title: "Describe a sticker",
|
|
74
|
-
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
|
|
82
|
+
description: "Everything about one sticker by ref (from find_stickers): name, category, collection, tags, natural size, formats, tintable, licence (with any attribution it asks for), aiGenerated, variants (light / dark), dominant colours and its outline as SVG path data (silhouette). An unknown ref is refused with the closest refs. Changes nothing.",
|
|
75
83
|
inputSchema: { type: "object", properties: { ref: { type: "string", description: "Sticker ref provider:id from find_stickers (e.g. editor:star)." } }, required: ["ref"], additionalProperties: false },
|
|
76
84
|
annotations: { title: "Describe a sticker", ...READ },
|
|
77
85
|
handler: async ({ ref }) => {
|
|
78
86
|
const p = options.provider();
|
|
79
87
|
const d = await describeStickerRef(p, ref);
|
|
80
88
|
const { thumbnail: _thumbnail, id, ...rest } = d;
|
|
81
|
-
return { ref:
|
|
89
|
+
return { ref: _chunkOTN6VB5Scjs.stickerRefOf.call(void 0, p, id), ...rest };
|
|
82
90
|
}
|
|
83
91
|
};
|
|
84
92
|
return options.insert ? [find, describe, createInsertStickerTool(options.provider, options.insert)] : [find, describe];
|
|
85
93
|
}
|
|
86
|
-
async function loadForHost(provider, ref, d, host, colour, size) {
|
|
87
|
-
const id =
|
|
94
|
+
async function loadForHost(provider, ref, d, host, colour, size, variant) {
|
|
95
|
+
const id = _chunkOTN6VB5Scjs.stickerIdFor.call(void 0, provider, ref);
|
|
88
96
|
const format = d.formats.includes(host.format) ? host.format : _nullishCoalesce(d.formats[0], () => ( host.format));
|
|
89
|
-
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 } : {} });
|
|
97
|
+
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 } : {}, ...variant !== "light" ? { variant } : {} });
|
|
90
98
|
}
|
|
91
99
|
async function insertSticker(provider, host, options) {
|
|
92
100
|
const d = await describeStickerRef(provider, options.ref);
|
|
101
|
+
const has = _chunkOTN6VB5Scjs.stickerVariantsOf.call(void 0, d);
|
|
102
|
+
if (options.variant !== void 0 && !has.includes(options.variant)) throw new (0, _chunkU67EN7GGcjs.StickerError)("unsupported_variant", `"${options.ref}" has no ${JSON.stringify(options.variant)} variant; it has ${has.join(", ")}. Leave variant out to pick for the background.`);
|
|
103
|
+
const variant = _nullishCoalesce(options.variant, () => ( _chunkOTN6VB5Scjs.stickerVariantFor.call(void 0, d, _nullishCoalesce(_optionalChain([host, 'access', _9 => _9.dark, 'optionalCall', _10 => _10()]), () => ( false)))));
|
|
93
104
|
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).`);
|
|
94
105
|
if (options.width !== void 0 && !(options.width > 0)) throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", `width must be a positive size, got ${options.width}.`);
|
|
95
106
|
const w = _nullishCoalesce(options.width, () => ( d.width));
|
|
96
107
|
const h = w * d.height / d.width;
|
|
97
108
|
const centre = host.defaultCentre();
|
|
98
|
-
const asset = await loadForHost(provider, options.ref, d, host, options.color, Math.max(w, h));
|
|
99
|
-
const ref =
|
|
100
|
-
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() } : {} });
|
|
101
|
-
return { ...made, ref, width: w, height: h, licence: d.licence };
|
|
109
|
+
const asset = await loadForHost(provider, options.ref, d, host, options.color, Math.max(w, h), variant);
|
|
110
|
+
const ref = _chunkOTN6VB5Scjs.stickerRefOf.call(void 0, provider, d.id);
|
|
111
|
+
const made = await host.insert({ ref, description: d, asset, variant, x: _nullishCoalesce(options.x, () => ( centre.x)), y: _nullishCoalesce(options.y, () => ( centre.y)), width: w, height: h, ...options.color ? { colour: options.color.toLowerCase() } : {} });
|
|
112
|
+
return { ...made, ref, width: w, height: h, variant, licence: d.licence };
|
|
102
113
|
}
|
|
103
114
|
function createInsertStickerTool(provider, host) {
|
|
104
115
|
return {
|
|
105
116
|
name: "insert_sticker",
|
|
106
117
|
title: "Insert a sticker",
|
|
107
|
-
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).`,
|
|
118
|
+
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, in its dark variant when the background is dark and it has one (or the variant asked for). 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, the variant used and its licence (credit any attribution it asks for).`,
|
|
108
119
|
inputSchema: {
|
|
109
120
|
type: "object",
|
|
110
121
|
properties: {
|
|
@@ -112,13 +123,14 @@ function createInsertStickerTool(provider, host) {
|
|
|
112
123
|
x: { type: "number", description: "Centre x in document units (default the middle of the view or document)." },
|
|
113
124
|
y: { type: "number", description: "Centre y in document units (default the middle of the view or document)." },
|
|
114
125
|
width: { type: "number", exclusiveMinimum: 0, maximum: 1e4, description: "Width in document units (default the natural width); the height follows the aspect." },
|
|
115
|
-
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." }
|
|
126
|
+
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." },
|
|
127
|
+
variant: { type: "string", enum: [..._chunkOTN6VB5Scjs.STICKER_VARIANTS], description: "light or dark art (default: dark on a dark background when the sticker has it, else light); one the sticker does not list (find_stickers variants) is refused." }
|
|
116
128
|
},
|
|
117
129
|
required: ["ref"],
|
|
118
130
|
additionalProperties: false
|
|
119
131
|
},
|
|
120
132
|
annotations: { title: "Insert a sticker", ...WRITE },
|
|
121
|
-
handler: ({ ref, x, y, width, color }) => insertSticker(provider(), host, { ref, x, y, width, color })
|
|
133
|
+
handler: ({ ref, x, y, width, color, variant }) => insertSticker(provider(), host, { ref, x, y, width, color, variant })
|
|
122
134
|
};
|
|
123
135
|
}
|
|
124
136
|
function createStickerToolProvider(options) {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkBY5EBP26cjs = require('./chunk-BY5EBP26.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
var _chunkCVFAAZXEcjs = require('./chunk-CVFAAZXE.cjs');
|
|
@@ -2536,11 +2536,11 @@ function vectorExtrudeFaces(path, params) {
|
|
|
2536
2536
|
|
|
2537
2537
|
// src/vector/brushstroke.ts
|
|
2538
2538
|
var VECTOR_BRUSHSTROKE_SCALE = 2;
|
|
2539
|
-
var PRESETS =
|
|
2539
|
+
var PRESETS = _chunkBY5EBP26cjs.listPresets.call(void 0, _chunkBY5EBP26cjs.VECTOR_PROFILE).map((spec) => _chunkBY5EBP26cjs.BUILTIN_BRUSHES.find((b) => b.id === spec.id));
|
|
2540
2540
|
function admitted(spec) {
|
|
2541
2541
|
try {
|
|
2542
|
-
const brush =
|
|
2543
|
-
return
|
|
2542
|
+
const brush = _chunkBY5EBP26cjs.normalizeBrushSpec.call(void 0, spec);
|
|
2543
|
+
return _chunkBY5EBP26cjs.checkBrush.call(void 0, brush, _chunkBY5EBP26cjs.VECTOR_PROFILE).ok && _chunkPXDIAYB6cjs.isBrushstrokeBrush.call(void 0, _chunkBY5EBP26cjs.resolveBrush.call(void 0, brush)) ? brush : null;
|
|
2544
2544
|
} catch (e4) {
|
|
2545
2545
|
return null;
|
|
2546
2546
|
}
|
|
@@ -2549,7 +2549,7 @@ function vectorBrushstrokeBrushes(user = []) {
|
|
|
2549
2549
|
const out = [...PRESETS];
|
|
2550
2550
|
for (const raw of user) {
|
|
2551
2551
|
const brush = admitted(raw);
|
|
2552
|
-
if (brush && !out.some((b) => b.id === brush.id)) out.push(
|
|
2552
|
+
if (brush && !out.some((b) => b.id === brush.id)) out.push(_chunkBY5EBP26cjs.resolveBrush.call(void 0, brush));
|
|
2553
2553
|
}
|
|
2554
2554
|
return out;
|
|
2555
2555
|
}
|
|
@@ -2559,7 +2559,7 @@ function vectorBrushstrokeBrush(id) {
|
|
|
2559
2559
|
function vectorBrushstrokeBrushOf(brush) {
|
|
2560
2560
|
if (brush.spec) {
|
|
2561
2561
|
const saved = admitted(brush.spec);
|
|
2562
|
-
return saved && saved.id === brush.brushId ?
|
|
2562
|
+
return saved && saved.id === brush.brushId ? _chunkBY5EBP26cjs.resolveBrush.call(void 0, saved) : null;
|
|
2563
2563
|
}
|
|
2564
2564
|
return vectorBrushstrokeBrush(brush.brushId);
|
|
2565
2565
|
}
|
|
@@ -2567,14 +2567,14 @@ function vectorBrushstrokeBrushError(id, user = []) {
|
|
|
2567
2567
|
if (vectorBrushstrokeBrush(id)) return null;
|
|
2568
2568
|
const saved = user.find((b) => b.id === id);
|
|
2569
2569
|
const ids = vectorBrushstrokeBrushes(user).map((b) => b.id);
|
|
2570
|
-
const reasons = (b) =>
|
|
2570
|
+
const reasons = (b) => _chunkBY5EBP26cjs.checkBrush.call(void 0, b, _chunkBY5EBP26cjs.VECTOR_PROFILE).issues.filter((i) => i.severity === "error").map((i) => `${i.reason} ${i.fix}`).join(" ") || "it is not a dry dab brush.";
|
|
2571
2571
|
if (saved) return admitted(saved) ? null : `Brush "${id}" (${saved.name}) can't paint a brushstroke: ${reasons(saved)} Use one of: ${ids.join(", ")}.`;
|
|
2572
|
-
const preset =
|
|
2572
|
+
const preset = _chunkBY5EBP26cjs.BRUSH_PRESETS.find((b) => b.id === id);
|
|
2573
2573
|
if (preset) return `Brush "${id}" (${preset.name}) can't paint a brushstroke: ${reasons(preset)} Use one of: ${ids.join(", ")}.`;
|
|
2574
|
-
return `Unknown brush "${id}". ${
|
|
2574
|
+
return `Unknown brush "${id}". ${_chunkBY5EBP26cjs.closest.call(void 0, id, ids)}Use one of: ${ids.join(", ")} (vector.listBrushes lists them).`;
|
|
2575
2575
|
}
|
|
2576
2576
|
function vectorBrushstrokeDefaultColour(id, user = [], scheme = "light") {
|
|
2577
|
-
const brush = _nullishCoalesce(
|
|
2577
|
+
const brush = _nullishCoalesce(_chunkBY5EBP26cjs.BRUSH_PRESETS.find((b) => b.id === id), () => ( user.find((b) => b.id === id)));
|
|
2578
2578
|
return brush ? _chunkLRTR4ASZcjs.brushColourHex.call(void 0, _optionalChain([brush, 'access', _55 => _55.colour, 'optionalAccess', _56 => _56.default]), scheme) : null;
|
|
2579
2579
|
}
|
|
2580
2580
|
function sanitizeVectorBrushstroke(value, user = []) {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkUSJX5SW4cjs = require('./chunk-USJX5SW4.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
var _chunkGF2RBSDMcjs = require('./chunk-GF2RBSDM.cjs');
|
|
@@ -1361,12 +1361,12 @@ var unit = (x, y) => {
|
|
|
1361
1361
|
return l > 1e-12 && Number.isFinite(l) ? [x / l, y / l] : null;
|
|
1362
1362
|
};
|
|
1363
1363
|
function cubicOf(sp, i) {
|
|
1364
|
-
const s =
|
|
1364
|
+
const s = _chunkUSJX5SW4cjs.subpathSegment.call(void 0, sp, i);
|
|
1365
1365
|
if (s.length === 4) return s;
|
|
1366
1366
|
const [a, b] = s;
|
|
1367
1367
|
return [a, [a[0] + (b[0] - a[0]) / 3, a[1] + (b[1] - a[1]) / 3], [a[0] + 2 * (b[0] - a[0]) / 3, a[1] + 2 * (b[1] - a[1]) / 3], b];
|
|
1368
1368
|
}
|
|
1369
|
-
var isLine = (sp, i) =>
|
|
1369
|
+
var isLine = (sp, i) => _chunkUSJX5SW4cjs.subpathSegment.call(void 0, sp, i).length === 2;
|
|
1370
1370
|
function startTangent(c) {
|
|
1371
1371
|
for (let k = 1; k < 4; k++) {
|
|
1372
1372
|
const u = unit(c[k][0] - c[0][0], c[k][1] - c[0][1]);
|
|
@@ -1386,10 +1386,10 @@ function sample(c, n, out, withStart) {
|
|
|
1386
1386
|
}
|
|
1387
1387
|
var onAnchor = (a, h) => !h || Math.abs(h.x - a.x) < EPS && Math.abs(h.y - a.y) < EPS;
|
|
1388
1388
|
function tidy(a, keepType = true) {
|
|
1389
|
-
const next =
|
|
1389
|
+
const next = _chunkUSJX5SW4cjs.cloneAnchor.call(void 0, a);
|
|
1390
1390
|
if (onAnchor(next, next.in)) delete next.in;
|
|
1391
1391
|
if (onAnchor(next, next.out)) delete next.out;
|
|
1392
|
-
const shown =
|
|
1392
|
+
const shown = _chunkUSJX5SW4cjs.inferAnchorType.call(void 0, next);
|
|
1393
1393
|
const type = keepType && a.type ? a.type === "symmetric" && shown !== "symmetric" ? shown === "corner" ? "corner" : "smooth" : a.type === "smooth" && shown === "corner" ? "corner" : a.type : shown;
|
|
1394
1394
|
if (type === "corner") delete next.type;
|
|
1395
1395
|
else next.type = type;
|
|
@@ -1433,7 +1433,7 @@ function fitAcross(pts, N, t0, t1) {
|
|
|
1433
1433
|
return goldenMin(fit, 0, 1);
|
|
1434
1434
|
}
|
|
1435
1435
|
function removeAnchorKeepingShape(sp, index) {
|
|
1436
|
-
const anchors = sp.anchors.map(
|
|
1436
|
+
const anchors = sp.anchors.map(_chunkUSJX5SW4cjs.cloneAnchor);
|
|
1437
1437
|
const n = anchors.length;
|
|
1438
1438
|
if (index < 0 || index >= n) return { anchors, closed: sp.closed };
|
|
1439
1439
|
if ((sp.closed || index > 0 && index < n - 1) && n >= 3) {
|
|
@@ -1467,12 +1467,12 @@ function removeAnchorKeepingShape(sp, index) {
|
|
|
1467
1467
|
}
|
|
1468
1468
|
function removeAnchorsKeepingShape(sp, indices) {
|
|
1469
1469
|
const order = [...new Set(indices)].filter((i) => i >= 0 && i < sp.anchors.length).sort((a, b) => b - a);
|
|
1470
|
-
return order.reduce((acc, i) => removeAnchorKeepingShape(acc, i), { anchors: sp.anchors.map(
|
|
1470
|
+
return order.reduce((acc, i) => removeAnchorKeepingShape(acc, i), { anchors: sp.anchors.map(_chunkUSJX5SW4cjs.cloneAnchor), closed: sp.closed });
|
|
1471
1471
|
}
|
|
1472
1472
|
function bendSegment(sp, segment, t, p) {
|
|
1473
|
-
const anchors = sp.anchors.map(
|
|
1473
|
+
const anchors = sp.anchors.map(_chunkUSJX5SW4cjs.cloneAnchor);
|
|
1474
1474
|
const n = anchors.length;
|
|
1475
|
-
if (segment < 0 || segment >=
|
|
1475
|
+
if (segment < 0 || segment >= _chunkUSJX5SW4cjs.subpathSegmentCount.call(void 0, sp) || !Number.isFinite(t) || !Number.isFinite(p.x) || !Number.isFinite(p.y)) return { anchors, closed: sp.closed };
|
|
1476
1476
|
const tc = Math.min(0.95, Math.max(0.05, t));
|
|
1477
1477
|
const ia = segment;
|
|
1478
1478
|
const ib = (segment + 1) % n;
|
|
@@ -1483,16 +1483,16 @@ function bendSegment(sp, segment, t, p) {
|
|
|
1483
1483
|
const oy = (p.y - (a.y + (b.y - a.y) * tc)) / k;
|
|
1484
1484
|
const c1 = { x: a.x + (b.x - a.x) / 3 + ox, y: a.y + (b.y - a.y) / 3 + oy };
|
|
1485
1485
|
const c2 = { x: b.x + (a.x - b.x) / 3 + ox, y: b.y + (a.y - b.y) / 3 + oy };
|
|
1486
|
-
anchors[ia] =
|
|
1487
|
-
anchors[ib] =
|
|
1486
|
+
anchors[ia] = _chunkUSJX5SW4cjs.moveAnchorHandle.call(void 0, a, "out", c1);
|
|
1487
|
+
anchors[ib] = _chunkUSJX5SW4cjs.moveAnchorHandle.call(void 0, b, "in", c2);
|
|
1488
1488
|
return { anchors, closed: sp.closed };
|
|
1489
1489
|
}
|
|
1490
1490
|
function subpathPointAt(sp, segment, t) {
|
|
1491
|
-
const [x, y] = _chunkGF2RBSDMcjs.segmentPoint.call(void 0,
|
|
1491
|
+
const [x, y] = _chunkGF2RBSDMcjs.segmentPoint.call(void 0, _chunkUSJX5SW4cjs.subpathSegment.call(void 0, sp, segment), t);
|
|
1492
1492
|
return { x, y };
|
|
1493
1493
|
}
|
|
1494
1494
|
function curvatureMoveAnchor(sp, index, q) {
|
|
1495
|
-
const anchors = sp.anchors.map(
|
|
1495
|
+
const anchors = sp.anchors.map(_chunkUSJX5SW4cjs.cloneAnchor);
|
|
1496
1496
|
const a = sp.anchors[index];
|
|
1497
1497
|
if (!a) return { anchors, closed: sp.closed };
|
|
1498
1498
|
const own = [
|
|
@@ -1538,7 +1538,7 @@ function curvatureMoveAnchor(sp, index, q) {
|
|
|
1538
1538
|
function cutSubpathAt(sp, at) {
|
|
1539
1539
|
const n = sp.anchors.length;
|
|
1540
1540
|
const cuts = [...new Set(at)].filter((i) => Number.isInteger(i) && i >= 0 && i < n && (sp.closed || i > 0 && i < n - 1)).sort((a, b) => a - b);
|
|
1541
|
-
if (!cuts.length || n < 2) return [{ anchors: sp.anchors.map(
|
|
1541
|
+
if (!cuts.length || n < 2) return [{ anchors: sp.anchors.map(_chunkUSJX5SW4cjs.cloneAnchor), closed: sp.closed }];
|
|
1542
1542
|
const first = cuts[0];
|
|
1543
1543
|
const run = sp.closed ? Array.from({ length: n + 1 }, (_, i) => sp.anchors[(first + i) % n]) : sp.anchors;
|
|
1544
1544
|
const cutSet = new Set(sp.closed ? [...cuts.map((c) => (c - first + n) % n), n] : cuts);
|
|
@@ -1546,7 +1546,7 @@ function cutSubpathAt(sp, at) {
|
|
|
1546
1546
|
let cur = [];
|
|
1547
1547
|
run.forEach((a, i) => {
|
|
1548
1548
|
if (!cutSet.has(i)) {
|
|
1549
|
-
cur.push(
|
|
1549
|
+
cur.push(_chunkUSJX5SW4cjs.cloneAnchor.call(void 0, a));
|
|
1550
1550
|
return;
|
|
1551
1551
|
}
|
|
1552
1552
|
if (cur.length) {
|
|
@@ -1561,10 +1561,10 @@ function cutSubpathAt(sp, at) {
|
|
|
1561
1561
|
}
|
|
1562
1562
|
function splitSubpathAt(sp, segment, t, endTolerance = 1e-6) {
|
|
1563
1563
|
const n = sp.anchors.length;
|
|
1564
|
-
if (segment < 0 || segment >=
|
|
1564
|
+
if (segment < 0 || segment >= _chunkUSJX5SW4cjs.subpathSegmentCount.call(void 0, sp)) return [{ anchors: sp.anchors.map(_chunkUSJX5SW4cjs.cloneAnchor), closed: sp.closed }];
|
|
1565
1565
|
if (t <= endTolerance) return cutSubpathAt(sp, [segment]);
|
|
1566
1566
|
if (t >= 1 - endTolerance) return cutSubpathAt(sp, [(segment + 1) % n]);
|
|
1567
|
-
const { subpath, index } =
|
|
1567
|
+
const { subpath, index } = _chunkUSJX5SW4cjs.insertAnchor.call(void 0, sp, segment, t);
|
|
1568
1568
|
return cutSubpathAt(subpath, [index]);
|
|
1569
1569
|
}
|
|
1570
1570
|
var endOf = (sp, last) => sp.anchors[last ? sp.anchors.length - 1 : 0];
|
|
@@ -1587,7 +1587,7 @@ function joinSubpaths(subpaths, tolerance) {
|
|
|
1587
1587
|
const closed = [];
|
|
1588
1588
|
let open = [];
|
|
1589
1589
|
for (const sp of subpaths) {
|
|
1590
|
-
const copy = { anchors: sp.anchors.map(
|
|
1590
|
+
const copy = { anchors: sp.anchors.map(_chunkUSJX5SW4cjs.cloneAnchor), closed: sp.closed };
|
|
1591
1591
|
if (sp.closed || sp.anchors.length < 2) {
|
|
1592
1592
|
if (sp.anchors.length) closed.push(copy);
|
|
1593
1593
|
} else open.push(copy);
|
|
@@ -1642,7 +1642,7 @@ function smoothSubpath(sp, amount = 1, only) {
|
|
|
1642
1642
|
const t = Math.min(1, Math.max(0, amount));
|
|
1643
1643
|
const orig = sp.anchors;
|
|
1644
1644
|
const n = orig.length;
|
|
1645
|
-
const anchors = orig.map(
|
|
1645
|
+
const anchors = orig.map(_chunkUSJX5SW4cjs.cloneAnchor);
|
|
1646
1646
|
if (n < 3 || t === 0) return { anchors, closed: sp.closed };
|
|
1647
1647
|
for (let i = 0; i < n; i++) {
|
|
1648
1648
|
if (!sp.closed && (i === 0 || i === n - 1)) continue;
|
|
@@ -1671,8 +1671,8 @@ function smoothSubpath(sp, amount = 1, only) {
|
|
|
1671
1671
|
}
|
|
1672
1672
|
function segsOf(sp) {
|
|
1673
1673
|
const out = [];
|
|
1674
|
-
for (let i = 0; i <
|
|
1675
|
-
const s =
|
|
1674
|
+
for (let i = 0; i < _chunkUSJX5SW4cjs.subpathSegmentCount.call(void 0, sp); i++) {
|
|
1675
|
+
const s = _chunkUSJX5SW4cjs.subpathSegment.call(void 0, sp, i);
|
|
1676
1676
|
out.push(s.length === 2 ? { c: s, line: true } : { c: s, line: false });
|
|
1677
1677
|
}
|
|
1678
1678
|
return out;
|
|
@@ -1729,7 +1729,7 @@ function removeRedundantPoints(sp, tolerance) {
|
|
|
1729
1729
|
const tol = Math.max(tolerance, 1e-9);
|
|
1730
1730
|
const types = new Map(sp.anchors.filter((a) => a.type).map((a) => [`${a.x},${a.y}`, a.type]));
|
|
1731
1731
|
const segs = segsOf(sp).filter((s) => !isZeroSeg(s));
|
|
1732
|
-
if (!segs.length) return { anchors: sp.anchors.map(
|
|
1732
|
+
if (!segs.length) return { anchors: sp.anchors.map(_chunkUSJX5SW4cjs.cloneAnchor), closed: sp.closed };
|
|
1733
1733
|
const minSegs = sp.closed ? 2 : 1;
|
|
1734
1734
|
let changed = true;
|
|
1735
1735
|
while (changed && segs.length > minSegs) {
|
|
@@ -1747,7 +1747,7 @@ function removeRedundantPoints(sp, tolerance) {
|
|
|
1747
1747
|
break;
|
|
1748
1748
|
}
|
|
1749
1749
|
}
|
|
1750
|
-
return _nullishCoalesce(segsToSubpath(segs, sp.closed, types), () => ( { anchors: sp.anchors.map(
|
|
1750
|
+
return _nullishCoalesce(segsToSubpath(segs, sp.closed, types), () => ( { anchors: sp.anchors.map(_chunkUSJX5SW4cjs.cloneAnchor), closed: sp.closed }));
|
|
1751
1751
|
}
|
|
1752
1752
|
|
|
1753
1753
|
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
var _chunkOTN6VB5Scjs = require('./chunk-OTN6VB5S.cjs');
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
var _chunkU67EN7GGcjs = require('./chunk-U67EN7GG.cjs');
|
|
@@ -32,7 +33,7 @@ var HEX = /^#[0-9a-fA-F]{6}$/;
|
|
|
32
33
|
function stampOutline(kind) {
|
|
33
34
|
const n = GRID;
|
|
34
35
|
const f = new Float32Array((n + 1) * (n + 1));
|
|
35
|
-
for (let j = 0; j <= n; j++) for (let i = 0; i <= n; i++) f[j * (n + 1) + i] =
|
|
36
|
+
for (let j = 0; j <= n; j++) for (let i = 0; i <= n; i++) f[j * (n + 1) + i] = _chunkOTN6VB5Scjs.stampCoverage.call(void 0, kind, i / n * 2 - 1, j / n * 2 - 1, SHAPE_SEED) - 0.5;
|
|
36
37
|
const at = (i, j) => f[j * (n + 1) + i];
|
|
37
38
|
const points = /* @__PURE__ */ new Map();
|
|
38
39
|
const point = (key, i0, j0, i1, j1) => {
|
|
@@ -169,7 +170,7 @@ function stampPixels(kind, size, colour) {
|
|
|
169
170
|
for (let y = 0; y < size; y++) {
|
|
170
171
|
for (let x = 0; x < size; x++) {
|
|
171
172
|
let c = 0;
|
|
172
|
-
for (let sy = 0; sy < ss; sy++) for (let sx = 0; sx < ss; sx++) c +=
|
|
173
|
+
for (let sy = 0; sy < ss; sy++) for (let sx = 0; sx < ss; sx++) c += _chunkOTN6VB5Scjs.stampCoverage.call(void 0, kind, (x + (sx + 0.5) / ss) / size * 2 - 1, (y + (sy + 0.5) / ss) / size * 2 - 1, SHAPE_SEED);
|
|
173
174
|
const a = Math.round(c / (ss * ss) * 255);
|
|
174
175
|
if (!a) continue;
|
|
175
176
|
const i = (y * size + x) * 4;
|
|
@@ -191,24 +192,25 @@ function editorStickers() {
|
|
|
191
192
|
return { id: k, name: m.name, category: m.category, tags: m.tags, description: m.description, width: BOX, height: BOX, thumbnail: thumbs.get(k), formats: ["svg", "png"], licence: { ...LICENCE }, tintable: true };
|
|
192
193
|
};
|
|
193
194
|
const kind = (id) => {
|
|
194
|
-
if (!
|
|
195
|
+
if (!_chunkOTN6VB5Scjs.STAMP_KINDS.includes(id)) throw new (0, _chunkU67EN7GGcjs.StickerError)("unknown_sticker", `The editor has no sticker "${id}"; its stickers are ${_chunkOTN6VB5Scjs.STAMP_KINDS.join(", ")}.`);
|
|
195
196
|
return id;
|
|
196
197
|
};
|
|
197
198
|
return {
|
|
198
|
-
id:
|
|
199
|
+
id: _chunkOTN6VB5Scjs.EDITOR_STICKERS_ID,
|
|
199
200
|
name: "Editor stickers",
|
|
200
201
|
version: "1",
|
|
201
202
|
capabilities: { supportsSearch: true, supportsSvg: true, supportsRaster: true, maxSize: 1024 },
|
|
202
|
-
list: (options) =>
|
|
203
|
-
search: (query, options) =>
|
|
203
|
+
list: (options) => _chunkOTN6VB5Scjs.stickerPage.call(void 0, _chunkOTN6VB5Scjs.STAMP_KINDS.map(summary), options),
|
|
204
|
+
search: (query, options) => _chunkOTN6VB5Scjs.stickerPage.call(void 0, _chunkOTN6VB5Scjs.STAMP_KINDS.map(summary), options, query),
|
|
204
205
|
describe(id) {
|
|
205
|
-
if (!
|
|
206
|
+
if (!_chunkOTN6VB5Scjs.STAMP_KINDS.includes(id)) return void 0;
|
|
206
207
|
const k = id;
|
|
207
208
|
return { ...summary(k), silhouette: outline(k), colours: [META[k].colour] };
|
|
208
209
|
},
|
|
209
|
-
categories: () => [...new Set(
|
|
210
|
+
categories: () => [...new Set(_chunkOTN6VB5Scjs.STAMP_KINDS.map((k) => META[k].category))].map((c) => ({ id: c, name: c[0].toUpperCase() + c.slice(1), count: _chunkOTN6VB5Scjs.STAMP_KINDS.filter((k) => META[k].category === c).length })),
|
|
210
211
|
load(id, options = {}) {
|
|
211
212
|
const k = kind(id);
|
|
213
|
+
_chunkOTN6VB5Scjs.checkStickerVariant.call(void 0, { id: k }, options.variant);
|
|
212
214
|
const colour = _nullishCoalesce(options.colour, () => ( META[k].colour));
|
|
213
215
|
if (!HEX.test(colour)) throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", `colour ${JSON.stringify(colour)} must be #rrggbb.`);
|
|
214
216
|
if (options.format === "png") {
|
|
@@ -229,7 +231,7 @@ var StickerBrowser = (_class = class {
|
|
|
229
231
|
constructor(provider, pageSize = 24) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
|
|
230
232
|
this.provider = provider;
|
|
231
233
|
this.pageSize = pageSize;
|
|
232
|
-
this.s = { query: "", category: "", items: [], total: 0, hasMore: false, loading: false, error: null, categories: [], provider: provider().name };
|
|
234
|
+
this.s = { query: "", category: "", collection: "", items: [], total: 0, hasMore: false, loading: false, error: null, categories: [], collections: [], provider: provider().name };
|
|
233
235
|
}
|
|
234
236
|
|
|
235
237
|
|
|
@@ -256,8 +258,9 @@ var StickerBrowser = (_class = class {
|
|
|
256
258
|
this.set({ loading: true, error: null, items: [], total: 0, hasMore: false, provider: p.name });
|
|
257
259
|
try {
|
|
258
260
|
const categories = await _asyncNullishCoalesce(await _optionalChain([p, 'access', _2 => _2.categories, 'optionalCall', _3 => _3()]), async () => ( []));
|
|
261
|
+
const collections = await _asyncNullishCoalesce(await _optionalChain([p, 'access', _4 => _4.listCollections, 'optionalCall', _5 => _5()]), async () => ( []));
|
|
259
262
|
if (run !== this.run) return;
|
|
260
|
-
this.set({ categories });
|
|
263
|
+
this.set({ categories, collections, ...this.s.collection && !collections.some((c) => c.id === this.s.collection) ? { collection: "" } : {} });
|
|
261
264
|
await this.page(run, p, true);
|
|
262
265
|
} catch (e) {
|
|
263
266
|
if (run === this.run) this.set({ loading: false, error: e instanceof Error ? e.message : String(e) });
|
|
@@ -273,6 +276,11 @@ var StickerBrowser = (_class = class {
|
|
|
273
276
|
this.s = { ...this.s, category };
|
|
274
277
|
return this.refresh();
|
|
275
278
|
}
|
|
279
|
+
/** Shows one collection (`''` for all) from the first page. */
|
|
280
|
+
setCollection(collection) {
|
|
281
|
+
this.s = { ...this.s, collection };
|
|
282
|
+
return this.refresh();
|
|
283
|
+
}
|
|
276
284
|
/** Loads the next page onto the list. */
|
|
277
285
|
async more() {
|
|
278
286
|
if (!this.next || this.s.loading) return;
|
|
@@ -285,12 +293,12 @@ var StickerBrowser = (_class = class {
|
|
|
285
293
|
}
|
|
286
294
|
}
|
|
287
295
|
async page(run, p, first) {
|
|
288
|
-
const options = { limit: this.pageSize, ...this.s.category ? { category: this.s.category } : {}, ...!first && this.next ? { after: this.next } : {} };
|
|
296
|
+
const options = { limit: this.pageSize, ...this.s.category ? { category: this.s.category } : {}, ...this.s.collection ? { collection: this.s.collection } : {}, ...!first && this.next ? { after: this.next } : {} };
|
|
289
297
|
const q = this.s.query.trim();
|
|
290
298
|
const res = q && p.capabilities.supportsSearch ? await p.search(q, options) : await p.list(options);
|
|
291
299
|
if (run !== this.run) return;
|
|
292
300
|
this.next = res.next;
|
|
293
|
-
const items = res.items.map((s) => ({ ...s, ref:
|
|
301
|
+
const items = res.items.map((s) => ({ ...s, ref: _chunkOTN6VB5Scjs.stickerRefOf.call(void 0, p, s.id) }));
|
|
294
302
|
this.set({ items: first ? items : [...this.s.items, ...items], total: res.total, hasMore: Boolean(res.next), loading: false });
|
|
295
303
|
}
|
|
296
304
|
}, _class);
|
|
@@ -46,6 +46,7 @@ import { type ProofSetup } from './color-management.cjs';
|
|
|
46
46
|
import type { EffectPattern } from '../raster/effects/patterns.cjs';
|
|
47
47
|
import { type GlobalLight, type LayerEffect, type LayerEffectKind, type LayerEffects } from '../raster/effects/model.cjs';
|
|
48
48
|
import { type BrushLibrary, type BrushLibraryEntry } from '../brushes/library.cjs';
|
|
49
|
+
import type { BrushPreviewRenderer } from '../brushes/tools.cjs';
|
|
49
50
|
import { type ImageBrushPreset } from './brush-presets.cjs';
|
|
50
51
|
/** What `getSmartObject` reports. */
|
|
51
52
|
export interface SmartObjectInfo {
|
|
@@ -1575,6 +1576,8 @@ export declare class ImageEditorController {
|
|
|
1575
1576
|
}): string | null;
|
|
1576
1577
|
/** The brush library the brush presets come from (shared with other editors when the host passes one). */
|
|
1577
1578
|
readonly brushLibrary: BrushLibrary;
|
|
1579
|
+
/** The `brushPreview` option: draws the brush editor's preview stroke, or `null`. */
|
|
1580
|
+
readonly brushPreview: BrushPreviewRenderer | null;
|
|
1578
1581
|
/** The brushes this editor can paint with (`IMAGE_PROFILE`): built-in presets, then saved brushes. */
|
|
1579
1582
|
listBrushPresets(): Promise<BrushLibraryEntry[]>;
|
|
1580
1583
|
/**
|
|
@@ -46,6 +46,7 @@ import { type ProofSetup } from './color-management.js';
|
|
|
46
46
|
import type { EffectPattern } from '../raster/effects/patterns.js';
|
|
47
47
|
import { type GlobalLight, type LayerEffect, type LayerEffectKind, type LayerEffects } from '../raster/effects/model.js';
|
|
48
48
|
import { type BrushLibrary, type BrushLibraryEntry } from '../brushes/library.js';
|
|
49
|
+
import type { BrushPreviewRenderer } from '../brushes/tools.js';
|
|
49
50
|
import { type ImageBrushPreset } from './brush-presets.js';
|
|
50
51
|
/** What `getSmartObject` reports. */
|
|
51
52
|
export interface SmartObjectInfo {
|
|
@@ -1575,6 +1576,8 @@ export declare class ImageEditorController {
|
|
|
1575
1576
|
}): string | null;
|
|
1576
1577
|
/** The brush library the brush presets come from (shared with other editors when the host passes one). */
|
|
1577
1578
|
readonly brushLibrary: BrushLibrary;
|
|
1579
|
+
/** The `brushPreview` option: draws the brush editor's preview stroke, or `null`. */
|
|
1580
|
+
readonly brushPreview: BrushPreviewRenderer | null;
|
|
1578
1581
|
/** The brushes this editor can paint with (`IMAGE_PROFILE`): built-in presets, then saved brushes. */
|
|
1579
1582
|
listBrushPresets(): Promise<BrushLibraryEntry[]>;
|
|
1580
1583
|
/**
|