@dxtmisha/figma-code 0.1.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.
@@ -0,0 +1,32 @@
1
+ import { UiFigmaFramesList } from '@dxtmisha/figma';
2
+ import { FigmaItem } from './FigmaItem';
3
+ import { UiFigmaNode } from '../library';
4
+ /**
5
+ * Class for managing and sending the list of top-level frames in the Figma plugin.
6
+ *
7
+ * Класс для управления и отправки списка фреймов верхнего уровня в плагине Figma.
8
+ */
9
+ export declare class FigmaTopLevelFrames {
10
+ /** Cached list of top-level frames / Кэшированный список фреймов верхнего уровня */
11
+ protected static frames: UiFigmaFramesList | undefined;
12
+ /**
13
+ * Retrieves and caches the formatted list of top-level frames.
14
+ *
15
+ * Получает и кэширует отформатированный список фреймов верхнего уровня.
16
+ * @returns A promise that resolves to the list of frames / Промис, который разрешается в список фреймов
17
+ */
18
+ static get(): Promise<UiFigmaFramesList>;
19
+ /**
20
+ * Sets up a listener for frame requests and sends the data back using the plugin messenger.
21
+ *
22
+ * Настраивает прослушиватель для запросов фреймов и отправляет данные обратно с помощью мессенджера плагина.
23
+ */
24
+ static send(): void;
25
+ /**
26
+ * Gets the list of main frames from the current Figma page.
27
+ *
28
+ * Получает список основных фреймов с текущей страницы Figma.
29
+ * @returns An array of Figma items / Массив элементов Figma
30
+ */
31
+ protected static getList(): FigmaItem<UiFigmaNode>[];
32
+ }
@@ -0,0 +1,3 @@
1
+ export declare const FIGMA_IMAGE_TYPE = "image/jpeg";
2
+ /** Figma message type for texts / Тип сообщения Figma для текстов */
3
+ export declare const FIGMA_MESSAGE_TEXTS = "texts";
@@ -0,0 +1,10 @@
1
+ import { FigmaFrame } from '../classes/FigmaFrame';
2
+ /**
3
+ * Returns a FigmaFrame object by its ID.
4
+ *
5
+ * Возвращает объект FigmaFrame по его идентификатору.
6
+ * @param id node ID / идентификатор узла
7
+ * @returns promise with FigmaFrame object or undefined /
8
+ * промис с объектом FigmaFrame или undefined
9
+ */
10
+ export declare function getFigmaFrameById(id: string): Promise<FigmaFrame | undefined>;
@@ -0,0 +1,9 @@
1
+ import { FigmaItem } from '../classes/FigmaItem';
2
+ import { UiFigmaNode } from '../types/figmaTypes';
3
+ /**
4
+ * Returns the Figma item by ID.
5
+ *
6
+ * Возвращает узел Figma по идентификатору.
7
+ * @param id node ID/ идентификатор узла
8
+ */
9
+ export declare function getFigmaItemById<T extends UiFigmaNode = UiFigmaNode>(id: string): Promise<FigmaItem<T> | undefined>;
@@ -0,0 +1,8 @@
1
+ import { UiFigmaNode } from '../types/figmaTypes';
2
+ /**
3
+ * Returns the Figma node used for storage by ID or figma.root.
4
+ *
5
+ * Возвращает узел Figma, используемый для хранения, по идентификатору или figma.root.
6
+ * @param id node ID/ идентификатор узла
7
+ */
8
+ export declare function getFigmaItemByIdOrRoot<T extends UiFigmaNode = UiFigmaNode>(id?: string): Promise<T>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Sets up a listener for selection changes in Figma and sends the selection data to the UI.
3
+ *
4
+ * Настраивает слушатель изменений выделения в Figma и отправляет данные о выделении в UI.
5
+ */
6
+ export declare const makeFigmaFrameSelection: () => void;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Sets up a listener for selection changes in Figma and sends text elements to the UI.
3
+ *
4
+ * Настраивает слушатель изменений выделения в Figma и отправляет текстовые элементы в UI.
5
+ */
6
+ export declare const makeFigmaTexts: () => void;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Sets up the client storage by message.
3
+ *
4
+ * Устанавливает клиентское хранилище по сообщению.
5
+ */
6
+ export declare function setupClientStorage(): void;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Sets up bidirectional frame selection management.
3
+ *
4
+ * 1. Activates automatic selection tracking (Backend -> UI).
5
+ * 2. Sets up a listener for programmatic selection requests (UI -> Backend).
6
+ *
7
+ * Настраивает двустороннее управление выделением фреймов.
8
+ *
9
+ * 1. Активирует автоматическое отслеживание выделения (Backend -> UI).
10
+ * 2. Устанавливает слушатель для запросов программного выделения (UI -> Backend).
11
+ */
12
+ export declare function setupFrameSelection(): void;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Sets up a listener for style update messages.
3
+ *
4
+ * Настраивает слушатель сообщений об обновлении стилей.
5
+ */
6
+ export declare function setupFrameStyles(): void;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Sets up the storage by message.
3
+ *
4
+ * Устанавливает хранилище по сообщению.
5
+ */
6
+ export declare function setupStorage(): void;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Moves the view to the specified item and selects it.
3
+ *
4
+ * Перемещает вид на указанный элемент и выбирает его.
5
+ */
6
+ export declare function toFrameSelection(id?: string): Promise<void>;
@@ -0,0 +1,19 @@
1
+ export * from './classes/FigmaClientStorage';
2
+ export * from './classes/FigmaFrame';
3
+ export * from './classes/FigmaFramesSelected';
4
+ export * from './classes/FigmaItem';
5
+ export * from './classes/FigmaPluginMessenger';
6
+ export * from './classes/FigmaStorage';
7
+ export * from './classes/FigmaStorageData';
8
+ export * from './classes/FigmaTopLevelFrames';
9
+ export * from './functions/getFigmaFrameById';
10
+ export * from './functions/getFigmaItemById';
11
+ export * from './functions/getFigmaItemByIdOrRoot';
12
+ export * from './functions/makeFigmaFrameSelection';
13
+ export * from './functions/makeFigmaTexts';
14
+ export * from './functions/setupClientStorage';
15
+ export * from './functions/setupFrameSelection';
16
+ export * from './functions/setupFrameStyles';
17
+ export * from './functions/setupStorage';
18
+ export * from './functions/toFrameSelection';
19
+ export * from './types/figmaTypes';
@@ -0,0 +1,546 @@
1
+ import { executeFunction as e, forEach as t, getCurrentTime as n, isNull as r, toArray as i } from "@dxtmisha/functional-basic";
2
+ import { FIGMA_FRAME_STYLES_MESSENGER_NAME as a, FigmaPostAbstract as o, FigmaPostCode as s, UI_FIGMA_CLIENT_STORAGE_GET as c, UI_FIGMA_CLIENT_STORAGE_SET as l, UI_FIGMA_FRAMES_POST_NAME as u, UI_FIGMA_FRAMES_SELECTED_ADD_NAME as d, UI_FIGMA_FRAMES_SELECTED_POST_NAME as f, UI_FIGMA_FRAME_GET_SELECTION as p, UI_FIGMA_FRAME_SET_SELECTION as m, UI_FIGMA_STORAGE_GET as h, UI_FIGMA_STORAGE_SET as g } from "@dxtmisha/figma";
3
+ //#region \0@oxc-project+runtime@0.128.0/helpers/typeof.js
4
+ function _(e) {
5
+ "@babel/helpers - typeof";
6
+ return _ = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
7
+ return typeof e;
8
+ } : function(e) {
9
+ return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
10
+ }, _(e);
11
+ }
12
+ //#endregion
13
+ //#region \0@oxc-project+runtime@0.128.0/helpers/toPrimitive.js
14
+ function v(e, t) {
15
+ if (_(e) != "object" || !e) return e;
16
+ var n = e[Symbol.toPrimitive];
17
+ if (n !== void 0) {
18
+ var r = n.call(e, t || "default");
19
+ if (_(r) != "object") return r;
20
+ throw TypeError("@@toPrimitive must return a primitive value.");
21
+ }
22
+ return (t === "string" ? String : Number)(e);
23
+ }
24
+ //#endregion
25
+ //#region \0@oxc-project+runtime@0.128.0/helpers/toPropertyKey.js
26
+ function y(e) {
27
+ var t = v(e, "string");
28
+ return _(t) == "symbol" ? t : t + "";
29
+ }
30
+ //#endregion
31
+ //#region \0@oxc-project+runtime@0.128.0/helpers/defineProperty.js
32
+ function b(e, t, n) {
33
+ return (t = y(t)) in e ? Object.defineProperty(e, t, {
34
+ value: n,
35
+ enumerable: !0,
36
+ configurable: !0,
37
+ writable: !0
38
+ }) : e[t] = n, e;
39
+ }
40
+ //#endregion
41
+ //#region src/classes/FigmaStorageData.ts
42
+ var x = class {
43
+ constructor(e, t) {
44
+ b(this, "value", void 0), b(this, "age", void 0), this.name = e, this.cache = t;
45
+ }
46
+ isNull() {
47
+ return r(this.value);
48
+ }
49
+ isCache() {
50
+ return !!(r(this.cache) || this.age && this.age + this.cache * 1e3 >= n());
51
+ }
52
+ isValue() {
53
+ return this.value !== void 0 && this.isCache();
54
+ }
55
+ get() {
56
+ return this.value;
57
+ }
58
+ getAge() {
59
+ return this.age;
60
+ }
61
+ getName() {
62
+ return `${s.get()}-${this.name}`;
63
+ }
64
+ getCache() {
65
+ return this.cache;
66
+ }
67
+ set(e, t) {
68
+ return this.setValue(e).setAge(t);
69
+ }
70
+ setByObject(e) {
71
+ return e ? this.set(e.value, e.age) : this;
72
+ }
73
+ setValue(e) {
74
+ return this.value = e, this;
75
+ }
76
+ setAge(e) {
77
+ return this.age = e, this;
78
+ }
79
+ update(e) {
80
+ return e === void 0 ? this.remove() : this.setValue(e).setAge(n());
81
+ }
82
+ remove() {
83
+ return this.set(void 0, void 0);
84
+ }
85
+ toValue() {
86
+ return {
87
+ value: this.value,
88
+ age: this.age
89
+ };
90
+ }
91
+ }, S = class t {
92
+ static getInstance(e) {
93
+ if (e in C) return C[e];
94
+ let n = new t(e);
95
+ return C[e] = n, n;
96
+ }
97
+ constructor(e, t) {
98
+ b(this, "data", void 0), this.name = e, this.cache = t, this.data = new x(e, t);
99
+ }
100
+ async get(e) {
101
+ if (await this.make(), this.data.isValue()) return this.data.get();
102
+ if (e !== void 0) return await this.set(e);
103
+ }
104
+ async set(t) {
105
+ return this.data.update(await e(t)), await figma.clientStorage.setAsync(this.data.getName(), this.data.toValue()), this.data.get();
106
+ }
107
+ async remove() {
108
+ return this.data.remove(), await figma.clientStorage.deleteAsync(this.data.getName()), this;
109
+ }
110
+ async getValue() {
111
+ return await figma.clientStorage.getAsync(this.data.getName());
112
+ }
113
+ async make() {
114
+ return this.data.isNull() && this.data.setByObject(await this.getValue()), this;
115
+ }
116
+ }, C = {}, w = class e {
117
+ constructor(e) {
118
+ this.item = e;
119
+ }
120
+ isDocument() {
121
+ return this.getType() === "DOCUMENT";
122
+ }
123
+ isFrame() {
124
+ return this.getType() === "FRAME";
125
+ }
126
+ isSection() {
127
+ return this.getType() === "SECTION";
128
+ }
129
+ isText() {
130
+ return this.getType() === "TEXT";
131
+ }
132
+ isTextNoValue() {
133
+ if (this.isText()) {
134
+ let e = this.getText();
135
+ return !(e === "" || e.match(/^[\d., ]+(|[^ ]{1,3})$/));
136
+ }
137
+ return !1;
138
+ }
139
+ inCurrentPage() {
140
+ var e;
141
+ return ((e = this.getParentPage()) == null ? void 0 : e.id) === figma.currentPage.id;
142
+ }
143
+ get() {
144
+ return this.item;
145
+ }
146
+ getType() {
147
+ if ("type" in this.item) return this.item.type;
148
+ }
149
+ getParent() {
150
+ if ("parent" in this.item) {
151
+ var e;
152
+ return (e = this.item.parent) == null ? void 0 : e;
153
+ }
154
+ }
155
+ getParentItem() {
156
+ let t = this.getParent();
157
+ if (t) return new e(t);
158
+ }
159
+ getParentPage() {
160
+ let e = this.getParent();
161
+ for (; e && e.type !== "PAGE";) if (e.parent) e = e.parent;
162
+ else return;
163
+ return e;
164
+ }
165
+ getParentPageItem() {
166
+ let t = this.getParentPage();
167
+ if (t) return new e(t);
168
+ }
169
+ getChildren() {
170
+ return "children" in this.item ? this.item.children : [];
171
+ }
172
+ getChildrenItems() {
173
+ let t = [];
174
+ for (let n of this.getChildren()) t.push(new e(n));
175
+ return t;
176
+ }
177
+ getId() {
178
+ return "id" in this.item ? this.item.id : "";
179
+ }
180
+ getName() {
181
+ return "name" in this.item ? this.item.name : this.getId();
182
+ }
183
+ getText() {
184
+ return this.isText() ? this.item.characters.trim() : "";
185
+ }
186
+ async getCss() {
187
+ return "getCSSAsync" in this.item ? await this.item.getCSSAsync() : {};
188
+ }
189
+ async getInfo() {
190
+ return {
191
+ name: this.getName(),
192
+ id: this.getId(),
193
+ image: await this.exportJpg()
194
+ };
195
+ }
196
+ async getStyles() {
197
+ return {
198
+ ...await this.getInfo(),
199
+ json: await this.exportJsonCompact(),
200
+ text: this.getText(),
201
+ styles: await this.getCss()
202
+ };
203
+ }
204
+ async exportJpg() {
205
+ return await this.exportItem("JPG");
206
+ }
207
+ async exportJson() {
208
+ return await this.exportItem("JSON_REST_V1");
209
+ }
210
+ async exportJsonCompact() {
211
+ let e = await this.exportJson();
212
+ if (e) return {
213
+ document: this.toJsonCompact(e.document),
214
+ styles: e.styles
215
+ };
216
+ }
217
+ toSelection() {
218
+ figma.currentPage.selection = [this.item], figma.viewport.scrollAndZoomIntoView([this.item]);
219
+ }
220
+ async toPageAndSelection() {
221
+ this.inCurrentPage() && this.toSelection();
222
+ let e = this.getParentPage();
223
+ e && (await figma.setCurrentPageAsync(e), this.toSelection());
224
+ }
225
+ getExportSettings(e) {
226
+ switch (e) {
227
+ case "JSON_REST_V1":
228
+ case "JPG":
229
+ case "PNG":
230
+ case "SVG":
231
+ case "PDF": return { format: e };
232
+ default: return e;
233
+ }
234
+ }
235
+ async exportItem(e) {
236
+ return "exportAsync" in this.item ? await this.item.exportAsync(this.getExportSettings(e)) : "";
237
+ }
238
+ toJsonCompact(e) {
239
+ let n = {
240
+ id: String(e.id),
241
+ name: String(e.name)
242
+ };
243
+ return "type" in e && (n.type = e.type), "characters" in e && (n.characters = e.characters), "style" in e && (n.style = e.style), "styles" in e && (n.styles = e.styles), "children" in e && e.children && e.children.length > 0 && (n.children = t(e.children, (e) => this.toJsonCompact(e))), n;
244
+ }
245
+ }, T = class e {
246
+ constructor(e, t = !1) {
247
+ b(this, "mainItem", []), b(this, "items", []), this.page = e, this.selection = t, this.mainItem = this.initMain(), this.items = this.initBySelection();
248
+ }
249
+ isSelection() {
250
+ return this.selection && "selection" in this.page;
251
+ }
252
+ getItemsFrame() {
253
+ return this.filter((e) => e.isFrame());
254
+ }
255
+ getItemsSection() {
256
+ return this.filter((e) => e.isSection());
257
+ }
258
+ getItemsText() {
259
+ return this.filter((e) => e.isText());
260
+ }
261
+ async getItemsInfo() {
262
+ return await this.getInfoByItems(this.items);
263
+ }
264
+ async getItemsCss() {
265
+ let e = {};
266
+ for (let t of this.items) e[t.getId()] = await t.getCss();
267
+ return e;
268
+ }
269
+ async getItemsStyles() {
270
+ return await this.getStylesByItems(this.items);
271
+ }
272
+ getMainFrames() {
273
+ let e = this.toMain();
274
+ return e ? e.getChildrenItems().filter((e) => e.isFrame() || e.isSection()) : [];
275
+ }
276
+ async getMainItemsInfo() {
277
+ return await this.getInfoByItems(this.mainItem);
278
+ }
279
+ async getMainItemsStyles() {
280
+ return await this.getStylesByItems(this.mainItem, !0);
281
+ }
282
+ getTexts() {
283
+ let e = [];
284
+ return this.filter((e) => e.isTextNoValue()).forEach((t) => {
285
+ let n = t.getText(), r = e.find((e) => e.text === n);
286
+ r ? r.id.push(t.getId()) : e.push({
287
+ id: [t.getId()],
288
+ text: n
289
+ });
290
+ }), e;
291
+ }
292
+ async screenshot() {
293
+ let e = [];
294
+ for (let t of this.mainItem) e.push(await t.exportJpg());
295
+ return e;
296
+ }
297
+ async getInfoByItems(e) {
298
+ let t = [];
299
+ for (let n of e) t.push(await n.getInfo());
300
+ return t;
301
+ }
302
+ async getStylesByItems(t, n = !1) {
303
+ let r = [];
304
+ for (let i of t) {
305
+ let t = await i.getStyles();
306
+ n && (t.childrenStyles = await new e(i.get()).getItemsCss()), r.push(t);
307
+ }
308
+ return r;
309
+ }
310
+ initMain() {
311
+ return this.isSelection() ? t([...this.page.selection], (e) => new w(e)) : [new w(this.page)];
312
+ }
313
+ initItems(e) {
314
+ let t = [];
315
+ if ("children" in e) for (let n of e.children) t.push(new w(n), ...this.initItems(n));
316
+ return t;
317
+ }
318
+ initBySelection() {
319
+ if (this.isSelection()) {
320
+ let e = [];
321
+ for (let t of this.page.selection) e.push(...this.initItems(t));
322
+ return e;
323
+ }
324
+ return this.initItems(this.page);
325
+ }
326
+ filter(e) {
327
+ return this.items.filter(e);
328
+ }
329
+ toMain(e = new w(this.page)) {
330
+ let t = e.getParentItem();
331
+ return t && !t.isDocument() ? this.toMain(t) : e;
332
+ }
333
+ }, E = class e extends o {
334
+ static getInstance() {
335
+ return D || (D = new e(), D.make(), D);
336
+ }
337
+ post(e, t) {
338
+ figma.ui.postMessage({
339
+ code: s.get(),
340
+ type: e,
341
+ message: t
342
+ });
343
+ }
344
+ prepare() {
345
+ figma.ui.onmessage = (e) => this.onMessage(e);
346
+ }
347
+ }, D;
348
+ //#endregion
349
+ //#region src/functions/getFigmaItemById.ts
350
+ async function O(e) {
351
+ let t = await figma.getNodeByIdAsync(e);
352
+ if (t) return new w(t);
353
+ }
354
+ //#endregion
355
+ //#region src/functions/getFigmaItemByIdOrRoot.ts
356
+ async function k(e) {
357
+ let t = e ? await O(e) : void 0;
358
+ return t ? t.get() : figma.root;
359
+ }
360
+ //#endregion
361
+ //#region src/classes/FigmaStorage.ts
362
+ var A = class t {
363
+ static getInstance(e, n = figma.root) {
364
+ let r = `${"id" in n ? n.id : "root"}:${e}`;
365
+ if (r in j) return j[r];
366
+ let i = new t(e, n);
367
+ return j[r] = i, i;
368
+ }
369
+ static async getInstanceById(e, n) {
370
+ let r = await k(n);
371
+ return t.getInstance(e, r);
372
+ }
373
+ constructor(e, t = figma.root, n) {
374
+ b(this, "data", void 0), this.name = e, this.item = t, this.cache = n, this.data = new x(e, n);
375
+ }
376
+ get(e) {
377
+ if (this.make(), this.data.isValue()) return this.data.get();
378
+ if (e !== void 0) return this.set(e);
379
+ }
380
+ set(t) {
381
+ return this.data.update(e(t)), this.item.setPluginData(this.data.getName(), JSON.stringify(this.data.toValue())), this.data.get();
382
+ }
383
+ remove() {
384
+ return this.data.remove(), this.item.setPluginData(this.data.getName(), ""), this;
385
+ }
386
+ getValue() {
387
+ let e = this.item.getPluginData(this.data.getName());
388
+ if (e) try {
389
+ return JSON.parse(e);
390
+ } catch (e) {
391
+ console.error("FigmaStorage", this.data.getName(), e);
392
+ }
393
+ }
394
+ make() {
395
+ return this.data.isNull() && this.data.setByObject(this.getValue()), this;
396
+ }
397
+ }, j = {}, M = class {
398
+ static has(e) {
399
+ return this.get().includes(e);
400
+ }
401
+ static get() {
402
+ return this.selected || (this.selected = this.getList()), this.selected;
403
+ }
404
+ static add(e) {
405
+ if (this.has(e)) return;
406
+ let t = this.get();
407
+ t.push(e), this.set(t);
408
+ }
409
+ static remove(e) {
410
+ if (this.has(e)) {
411
+ let t = this.get();
412
+ t.splice(t.indexOf(e), 1), this.set(t);
413
+ }
414
+ }
415
+ static toggle(e, t) {
416
+ t ? this.add(e) : this.remove(e);
417
+ }
418
+ static send() {
419
+ let e = E.getInstance();
420
+ e.add(f, () => this.post()), e.add(d, ({ id: e, selected: t }) => this.toggle(e, t));
421
+ }
422
+ static getList() {
423
+ var e;
424
+ return (e = this.storage.get()) == null ? [] : e;
425
+ }
426
+ static set(e) {
427
+ this.selected = e, this.storage.set(e);
428
+ }
429
+ static post() {
430
+ E.getInstance().post(f, this.get());
431
+ }
432
+ };
433
+ b(M, "storage", new A(f)), b(M, "selected", void 0);
434
+ //#endregion
435
+ //#region src/classes/FigmaTopLevelFrames.ts
436
+ var N = class {
437
+ static async get() {
438
+ if (!this.frames) {
439
+ this.frames = [];
440
+ for (let e of this.getList()) this.frames.push({
441
+ name: e.getName(),
442
+ id: e.getId(),
443
+ image: await e.exportJpg()
444
+ });
445
+ }
446
+ return this.frames;
447
+ }
448
+ static send() {
449
+ let e = E.getInstance();
450
+ e.add(u, () => {
451
+ this.get().then((t) => {
452
+ e.post(u, t);
453
+ });
454
+ });
455
+ }
456
+ static getList() {
457
+ return new T(figma.currentPage).getMainFrames();
458
+ }
459
+ };
460
+ b(N, "frames", void 0);
461
+ //#endregion
462
+ //#region src/functions/getFigmaFrameById.ts
463
+ async function P(e) {
464
+ let t = await figma.getNodeByIdAsync(e);
465
+ if (t) return new T(t);
466
+ }
467
+ //#endregion
468
+ //#region src/functions/makeFigmaFrameSelection.ts
469
+ var F = () => {
470
+ figma.on("selectionchange", async () => await I()), I().then();
471
+ }, I = async () => {
472
+ let e = new T(figma.currentPage, !0);
473
+ E.getInstance().post(p, await e.getMainItemsInfo());
474
+ }, L = "texts", R = () => {
475
+ figma.on("selectionchange", async () => {
476
+ let e = new T(figma.currentPage, !0);
477
+ E.getInstance().post(L, {
478
+ frame: e,
479
+ texts: e.getTexts(),
480
+ screenshot: await e.screenshot()
481
+ });
482
+ });
483
+ };
484
+ //#endregion
485
+ //#region src/functions/setupClientStorage.ts
486
+ function z() {
487
+ let e = E.getInstance(), t = (t, n) => e.post(c, {
488
+ name: t,
489
+ value: n
490
+ });
491
+ e.add(c, async ({ name: e, value: n }) => {
492
+ t(e, await S.getInstance(e).get(n));
493
+ }), e.add(l, async ({ name: e, value: n }) => {
494
+ t(e, await S.getInstance(e).set(n));
495
+ });
496
+ }
497
+ //#endregion
498
+ //#region src/functions/toFrameSelection.ts
499
+ async function B(e) {
500
+ if (e) {
501
+ let t = await O(e);
502
+ t && t.toPageAndSelection();
503
+ }
504
+ }
505
+ //#endregion
506
+ //#region src/functions/setupFrameSelection.ts
507
+ function V() {
508
+ let e = E.getInstance();
509
+ F(), e.add(m, ({ id: e }) => {
510
+ B(e).then();
511
+ });
512
+ }
513
+ //#endregion
514
+ //#region src/functions/setupFrameStyles.ts
515
+ function H() {
516
+ let e = E.getInstance(), t = async (e, t) => {
517
+ let n = await P(e);
518
+ return n ? t ? await n.getItemsStyles() : await n.getMainItemsStyles() : [];
519
+ };
520
+ e.add(a, async ({ ids: n, children: r }) => {
521
+ let o = i(n), s = [];
522
+ for (let e of o) s.push({
523
+ id: e,
524
+ data: await t(e, r == null ? !0 : r)
525
+ });
526
+ e.post(a, s);
527
+ });
528
+ }
529
+ //#endregion
530
+ //#region src/functions/setupStorage.ts
531
+ function U() {
532
+ let e = E.getInstance(), t = (t, n, r) => e.post(h, {
533
+ name: t,
534
+ value: n,
535
+ id: r
536
+ });
537
+ e.add(h, async (e) => {
538
+ let { name: n, value: r, id: i } = e == null ? {} : e;
539
+ t(n, (await A.getInstanceById(n, i)).get(r), i);
540
+ }), e.add(g, async (e) => {
541
+ let { name: n, value: r, id: i } = e == null ? {} : e;
542
+ t(n, (await A.getInstanceById(n, i)).set(r), i);
543
+ });
544
+ }
545
+ //#endregion
546
+ export { S as FigmaClientStorage, T as FigmaFrame, M as FigmaFramesSelected, w as FigmaItem, E as FigmaPluginMessenger, A as FigmaStorage, x as FigmaStorageData, N as FigmaTopLevelFrames, P as getFigmaFrameById, O as getFigmaItemById, k as getFigmaItemByIdOrRoot, F as makeFigmaFrameSelection, R as makeFigmaTexts, z as setupClientStorage, V as setupFrameSelection, H as setupFrameStyles, U as setupStorage, B as toFrameSelection };