@wix/editor 1.287.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,500 @@
1
+ import { createErrorBuilder, BaseError } from '@wix/public-editor-platform-errors';
2
+ import { PlatformAppEvent } from '@wix/public-editor-platform-events';
3
+ import { IFrameConsumerChannel, WorkerConsumerChannel } from '@wix/editor-platform-transport';
4
+ import { PlatformFrameAPI } from '@wix/editor-application/platform-frame-api';
5
+ import { PlatformWorkerAPI } from '@wix/editor-application/platform-worker-api';
6
+
7
+ var EditorPlatformApplicationContextErrorCode = /* @__PURE__ */ ((EditorPlatformApplicationContextErrorCode2) => {
8
+ EditorPlatformApplicationContextErrorCode2["IncorrectEnvironment"] = "IncorrectEnvironment";
9
+ return EditorPlatformApplicationContextErrorCode2;
10
+ })(EditorPlatformApplicationContextErrorCode || {});
11
+ class EditorPlatformApplicationContextError extends BaseError {
12
+ state = {};
13
+ constructor(message, code) {
14
+ super(message, code, "Editor Platform Application Context Error");
15
+ }
16
+ withUrl(url) {
17
+ this.state = { ...this.state, url };
18
+ return this;
19
+ }
20
+ withAppDefinitionId(appDefinitionId) {
21
+ this.state = { ...this.state, appDefinitionId };
22
+ return this;
23
+ }
24
+ }
25
+ const createEditorPlatformApplicationContextError = createErrorBuilder(EditorPlatformApplicationContextError);
26
+ async function transformEventPayload(eventPayload, privateAPI) {
27
+ if (!eventPayload?.type) {
28
+ return eventPayload;
29
+ }
30
+ switch (eventPayload.type) {
31
+ case "componentSelectionChanged":
32
+ const componentRefs = eventPayload.componentRefs || [];
33
+ const components = await Promise.all(
34
+ componentRefs.map((ref) => {
35
+ return privateAPI.components.getComponent(ref);
36
+ })
37
+ );
38
+ return {
39
+ type: eventPayload.type,
40
+ components
41
+ };
42
+ default:
43
+ return eventPayload;
44
+ }
45
+ }
46
+ class ApplicationBoundEvents {
47
+ constructor(appDefinitionId, events, privateAPI) {
48
+ this.appDefinitionId = appDefinitionId;
49
+ this.privateAPI = privateAPI;
50
+ this.events = events;
51
+ this.subscribe = events.subscribe.bind(events);
52
+ this.commit = events.commit.bind(events);
53
+ this.startTransaction = events.startTransaction.bind(events);
54
+ this.silent = events.silent.bind(events);
55
+ }
56
+ events;
57
+ subscribe;
58
+ commit;
59
+ startTransaction;
60
+ silent;
61
+ notify(event) {
62
+ this.events.notify({
63
+ type: event.type,
64
+ payload: event.payload,
65
+ meta: {
66
+ appDefinitionId: this.appDefinitionId
67
+ }
68
+ });
69
+ }
70
+ notifyCustomEvent(type, payload) {
71
+ this.notify({
72
+ type: PlatformAppEvent.CustomEvent,
73
+ payload: {
74
+ ...payload,
75
+ type
76
+ }
77
+ });
78
+ }
79
+ /**
80
+ * TODO: we should use same interface for all events
81
+ * (subscribe vs addEventListener)
82
+ */
83
+ addEventListener(eventType, fn) {
84
+ return this.events.subscribe(async (event) => {
85
+ const isAppMatch = event.meta?.appDefinitionId === this.appDefinitionId || event.meta?.appDefinitionId === null;
86
+ const transformPayload = () => transformEventPayload(event.payload, this.privateAPI);
87
+ if (eventType === "*") {
88
+ fn(await transformPayload());
89
+ } else if (event.type === PlatformAppEvent.CustomEvent) {
90
+ if (eventType === event.payload?.type && !isAppMatch) {
91
+ fn(await transformPayload());
92
+ }
93
+ } else if (event.type === PlatformAppEvent.HostEvent) {
94
+ if (eventType === event.payload?.type && isAppMatch) {
95
+ fn(await transformPayload());
96
+ }
97
+ }
98
+ });
99
+ }
100
+ }
101
+ const WAIT_INJECTED_TIMEOUT = 200;
102
+ const WAIT_INJECTED_RETRY_COUNT = 50;
103
+ class ContextInjectionStatus {
104
+ _resolveContextInjected = () => {
105
+ };
106
+ _isInjected = false;
107
+ key;
108
+ constructor(uuid) {
109
+ this.key = `__${uuid}_CONTEXT_INJECTION_STATUS_KEY`;
110
+ if (!globalThis[this.key]) {
111
+ globalThis[this.key] = new Promise((resolve) => {
112
+ this._resolveContextInjected = () => {
113
+ this._isInjected = true;
114
+ resolve();
115
+ };
116
+ });
117
+ }
118
+ }
119
+ isInjected() {
120
+ return !!this._isInjected;
121
+ }
122
+ resolveInjected() {
123
+ this._resolveContextInjected?.();
124
+ }
125
+ waitInjected() {
126
+ return new Promise((resolve, reject) => {
127
+ let injected = false;
128
+ let timeoutId;
129
+ let retryCount = 0;
130
+ const timeout = () => {
131
+ if (injected) {
132
+ return;
133
+ }
134
+ timeoutId = setTimeout(() => {
135
+ retryCount++;
136
+ if (retryCount < WAIT_INJECTED_RETRY_COUNT) {
137
+ if (retryCount % 10 === 0) {
138
+ console.log(
139
+ createEditorPlatformApplicationContextError(
140
+ EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,
141
+ "contexts are not resolved, still re-trying"
142
+ ).withMessage(`try number ${retryCount}`).message
143
+ );
144
+ }
145
+ timeout();
146
+ return;
147
+ }
148
+ if (!injected) {
149
+ const error = createEditorPlatformApplicationContextError(
150
+ EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,
151
+ "contexts are not resolved, threw by timeout"
152
+ );
153
+ reject(error);
154
+ }
155
+ }, WAIT_INJECTED_TIMEOUT);
156
+ };
157
+ timeout();
158
+ const _waitContextInjectedPromise = globalThis[this.key];
159
+ _waitContextInjectedPromise.then(() => {
160
+ injected = true;
161
+ clearTimeout(timeoutId);
162
+ resolve();
163
+ });
164
+ });
165
+ }
166
+ }
167
+ const ENVIRONMENT_CONTEXT_KEY = "__ENVIRONMENT_CONTEXT_KEY";
168
+ var PlatformEnvironment = /* @__PURE__ */ ((PlatformEnvironment2) => {
169
+ PlatformEnvironment2["Worker"] = "Worker";
170
+ PlatformEnvironment2["Frame"] = "Frame";
171
+ return PlatformEnvironment2;
172
+ })(PlatformEnvironment || {});
173
+ class EnvironmentContext {
174
+ constructor(environmentContext) {
175
+ this.environmentContext = environmentContext;
176
+ }
177
+ static status = new ContextInjectionStatus("environment");
178
+ static async inject(context) {
179
+ if (globalThis[ENVIRONMENT_CONTEXT_KEY]) {
180
+ throw createEditorPlatformApplicationContextError(
181
+ EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,
182
+ "Environment context already exists and should not be overridden"
183
+ );
184
+ }
185
+ globalThis[ENVIRONMENT_CONTEXT_KEY] = new EnvironmentContext(context);
186
+ this.status.resolveInjected();
187
+ }
188
+ static async getInstance() {
189
+ await this.status.waitInjected();
190
+ return globalThis[ENVIRONMENT_CONTEXT_KEY];
191
+ }
192
+ getPrivateAPI() {
193
+ return this.environmentContext.privateApi;
194
+ }
195
+ getEvents() {
196
+ return this.environmentContext.events;
197
+ }
198
+ getApplicationAPIs() {
199
+ return this.environmentContext.applicationAPIs ?? {};
200
+ }
201
+ getEnvironment() {
202
+ return this.environmentContext.environment;
203
+ }
204
+ }
205
+ const APPLICATION_CONTEXT_KEY = "__APPLICATION_CONTEXT_KEY";
206
+ class ApplicationContext {
207
+ constructor(applicationContext, environment) {
208
+ this.applicationContext = applicationContext;
209
+ this.environment = environment;
210
+ this.events = new ApplicationBoundEvents(
211
+ this.applicationContext.appDefinitionId,
212
+ this.environment.getEvents(),
213
+ this.environment.getPrivateAPI()
214
+ );
215
+ }
216
+ static status = new ContextInjectionStatus("application");
217
+ /**
218
+ * TODO: use generics for context type
219
+ * - application
220
+ * - editor
221
+ */
222
+ static async inject(context) {
223
+ const environment = await EnvironmentContext.getInstance();
224
+ if (environment.getEnvironment() !== PlatformEnvironment.Frame) {
225
+ throw createEditorPlatformApplicationContextError(
226
+ EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,
227
+ "Application context can be injected only in frame environment"
228
+ );
229
+ }
230
+ if (globalThis[APPLICATION_CONTEXT_KEY]) {
231
+ throw createEditorPlatformApplicationContextError(
232
+ EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,
233
+ "Application context already exists and should not be overridden"
234
+ );
235
+ }
236
+ globalThis[APPLICATION_CONTEXT_KEY] = new ApplicationContext(
237
+ context,
238
+ await EnvironmentContext.getInstance()
239
+ );
240
+ this.status.resolveInjected();
241
+ }
242
+ static async getInstance() {
243
+ const environment = await EnvironmentContext.getInstance();
244
+ if (environment.getEnvironment() === PlatformEnvironment.Frame) {
245
+ await this.status.waitInjected();
246
+ return globalThis[APPLICATION_CONTEXT_KEY];
247
+ } else {
248
+ return __APPLICATION_CONTEXT_KEY;
249
+ }
250
+ }
251
+ events;
252
+ getAppDefinitionId() {
253
+ return this.applicationContext.appDefinitionId;
254
+ }
255
+ getBindings() {
256
+ return this.applicationContext;
257
+ }
258
+ getEvents() {
259
+ return this.events;
260
+ }
261
+ getPrivateAPI() {
262
+ return this.environment.getPrivateAPI();
263
+ }
264
+ getPrivateApplicationAPI() {
265
+ const appDefinitionId = this.getAppDefinitionId();
266
+ if (!appDefinitionId) {
267
+ throw createEditorPlatformApplicationContextError(
268
+ EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,
269
+ "appDefinitionId is not available"
270
+ );
271
+ }
272
+ return this.environment.getApplicationAPIs()[appDefinitionId];
273
+ }
274
+ }
275
+
276
+ class EditorPlatformSDKAuthError extends BaseError {
277
+ state = {};
278
+ constructor(message, code) {
279
+ super(message, code, "Auth Strategy Error");
280
+ }
281
+ withAppDefinitionId(appDefinitionId) {
282
+ this.state = { ...this.state, appDefinitionId };
283
+ return this;
284
+ }
285
+ }
286
+ const createAuthStrategyShapeError = createErrorBuilder(EditorPlatformSDKAuthError);
287
+ const auth = () => {
288
+ return {
289
+ getAuthHeaders: async () => {
290
+ const context = await ApplicationContext.getInstance();
291
+ const privateAPI = context.getPrivateAPI();
292
+ const bindings = context.getBindings();
293
+ if (!bindings.appDefinitionId) {
294
+ throw createAuthStrategyShapeError(
295
+ "EmptyAppDefinitionId" /* EmptyAppDefinitionId */
296
+ );
297
+ }
298
+ const authInstance = await privateAPI.info.getAppInstance(
299
+ bindings.appDefinitionId
300
+ );
301
+ if (authInstance === void 0) {
302
+ throw createAuthStrategyShapeError(
303
+ "EmptyAppAuthInstance" /* EmptyAppAuthInstance */
304
+ ).withAppDefinitionId(bindings.appDefinitionId);
305
+ }
306
+ return {
307
+ headers: {
308
+ Authorization: authInstance
309
+ }
310
+ };
311
+ }
312
+ };
313
+ };
314
+
315
+ class PlatformSDKShape {
316
+ constructor(namespace, shape) {
317
+ this.namespace = namespace;
318
+ this.shape = shape;
319
+ }
320
+ static create(namespace, shape) {
321
+ return new PlatformSDKShape(namespace, shape);
322
+ }
323
+ build() {
324
+ return {
325
+ __type: "host",
326
+ create: () => {
327
+ return this.shape;
328
+ }
329
+ };
330
+ }
331
+ }
332
+
333
+ const application = {
334
+ getPrivateAPI: async () => {
335
+ const context = await ApplicationContext.getInstance();
336
+ return context.getPrivateApplicationAPI();
337
+ },
338
+ getPublicAPI: async (appDefinitionId) => {
339
+ const context = await ApplicationContext.getInstance();
340
+ const privateAPI = context.getPrivateAPI();
341
+ return privateAPI.applicationManager.getPublicApplicationAPI(
342
+ appDefinitionId
343
+ );
344
+ },
345
+ getAppInstance: async () => {
346
+ const context = await ApplicationContext.getInstance();
347
+ const privateAPI = context.getPrivateAPI();
348
+ const bindings = context.getBindings();
349
+ return privateAPI.info.getAppInstance(bindings.appDefinitionId);
350
+ }
351
+ };
352
+ var index$5 = PlatformSDKShape.create("application", application).build();
353
+
354
+ const components = {
355
+ async getSelectedComponents() {
356
+ const context = await ApplicationContext.getInstance();
357
+ const privateAPI = context.getPrivateAPI();
358
+ const refs = await privateAPI.components.getSelectedComponents();
359
+ return Promise.all(
360
+ refs.map((ref) => privateAPI.components.getComponent(ref))
361
+ );
362
+ }
363
+ };
364
+ var index$4 = PlatformSDKShape.create("components", components).build();
365
+
366
+ const events = {
367
+ addEventListener: async (name, cb) => {
368
+ const context = await ApplicationContext.getInstance();
369
+ return context.getEvents().addEventListener(name, cb);
370
+ }
371
+ };
372
+ var index$3 = PlatformSDKShape.create("events", events).build();
373
+
374
+ const info = {
375
+ async getViewMode() {
376
+ const context = await ApplicationContext.getInstance();
377
+ const privateAPI = context.getPrivateAPI();
378
+ return privateAPI.info.getViewMode();
379
+ },
380
+ async getLanguageCode() {
381
+ const context = await ApplicationContext.getInstance();
382
+ const privateAPI = context.getPrivateAPI();
383
+ return privateAPI.info.getLanguageCode();
384
+ }
385
+ };
386
+ var index$2 = PlatformSDKShape.create("info", info).build();
387
+
388
+ var WidgetShapeErrorCode = /* @__PURE__ */ ((WidgetShapeErrorCode2) => {
389
+ WidgetShapeErrorCode2["UndefinedCompRef"] = "UndefinedCompRef";
390
+ return WidgetShapeErrorCode2;
391
+ })(WidgetShapeErrorCode || {});
392
+ class WidgetShapeError extends BaseError {
393
+ constructor(message, code) {
394
+ super(message, code, "Widget Error");
395
+ }
396
+ }
397
+ const createWidgetShapeError = createErrorBuilder(WidgetShapeError);
398
+
399
+ const getSelectedComponentRef = async () => {
400
+ const selected = await components.getSelectedComponents();
401
+ const compRef = selected[0]?.compRef;
402
+ if (!compRef) {
403
+ throw createWidgetShapeError(WidgetShapeErrorCode.UndefinedCompRef);
404
+ }
405
+ return compRef;
406
+ };
407
+ const widget = {
408
+ // async getAttributes(): Promise<Record<string, string>> {
409
+ // const context = await ApplicationContext.getInstance();
410
+ // const privateAPI = context.getPrivateAPI();
411
+ // const compRef = await getSelectedComponentRef();
412
+ //
413
+ // return privateAPI.customElement.getAttributes(compRef);
414
+ // },
415
+ async getProp(propName) {
416
+ const context = await ApplicationContext.getInstance();
417
+ const privateAPI = context.getPrivateAPI();
418
+ const compRef = await getSelectedComponentRef();
419
+ return privateAPI.customElement.getAttribute(compRef, propName);
420
+ },
421
+ async setProp(propName, value) {
422
+ const context = await ApplicationContext.getInstance();
423
+ const privateAPI = context.getPrivateAPI();
424
+ const compRef = await getSelectedComponentRef();
425
+ await privateAPI.customElement.setAttribute(compRef, propName, value);
426
+ }
427
+ };
428
+ var index$1 = PlatformSDKShape.create("widget", widget).build();
429
+
430
+ const inputs = {
431
+ // TODO: duplicated types
432
+ async selectMedia(options) {
433
+ const context = await ApplicationContext.getInstance();
434
+ const privateAPI = context.getPrivateAPI();
435
+ return privateAPI.inputs.openMediaPanel(options);
436
+ },
437
+ // TODO: duplicated types
438
+ async selectLink(options) {
439
+ const context = await ApplicationContext.getInstance();
440
+ const privateAPI = context.getPrivateAPI();
441
+ return await privateAPI.inputs.openLinkPanel(
442
+ options
443
+ );
444
+ },
445
+ // TODO: duplicated types
446
+ async selectColor(options, onColorChange) {
447
+ const context = await ApplicationContext.getInstance();
448
+ const privateAPI = context.getPrivateAPI();
449
+ void privateAPI.inputs.openColorPicker(options, onColorChange);
450
+ },
451
+ // TODO: duplicated types
452
+ async selectFont(options, onFontChange) {
453
+ const context = await ApplicationContext.getInstance();
454
+ const privateAPI = context.getPrivateAPI();
455
+ void privateAPI.inputs.openFontPicker(options, onFontChange);
456
+ }
457
+ };
458
+ var index = PlatformSDKShape.create("inputs", inputs).build();
459
+
460
+ const editorPlatformFrameHost = () => {
461
+ const channel = new IFrameConsumerChannel();
462
+ channel.expose(new PlatformFrameAPI());
463
+ return {
464
+ environment: {},
465
+ channel: {
466
+ observeState: async () => {
467
+ return { disconnect() {
468
+ } };
469
+ }
470
+ }
471
+ };
472
+ };
473
+
474
+ const editorPlatformWorkerHost = () => {
475
+ const channel = new WorkerConsumerChannel();
476
+ channel.expose(new PlatformWorkerAPI());
477
+ return {
478
+ environment: {},
479
+ channel: {
480
+ observeState: async () => {
481
+ return { disconnect() {
482
+ } };
483
+ }
484
+ }
485
+ };
486
+ };
487
+
488
+ const editor = {
489
+ host: () => {
490
+ const isWorker = typeof importScripts === "function";
491
+ if (isWorker) {
492
+ return editorPlatformWorkerHost();
493
+ }
494
+ return editorPlatformFrameHost();
495
+ },
496
+ auth
497
+ };
498
+
499
+ export { index$5 as application, index$4 as components, editor, index$3 as events, index$2 as info, index as inputs, index$1 as widget };
500
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../editor-platform-application-context/dist/esm/index.js","../../src/auth.ts","../../src/PlatformSDKShape.ts","../../src/application/index.ts","../../src/components/index.ts","../../src/events/index.ts","../../src/info/index.ts","../../src/widget/errors.ts","../../src/widget/index.ts","../../src/inputs/index.ts","../../src/editorPlatformFrameHost.ts","../../src/editorPlatformWorkerHost.ts","../../src/index.ts"],"sourcesContent":["import { createErrorBuilder, BaseError } from '@wix/public-editor-platform-errors';\nimport { PlatformAppEvent } from '@wix/public-editor-platform-events';\n\nvar EditorPlatformApplicationContextErrorCode = /* @__PURE__ */ ((EditorPlatformApplicationContextErrorCode2) => {\n EditorPlatformApplicationContextErrorCode2[\"IncorrectEnvironment\"] = \"IncorrectEnvironment\";\n return EditorPlatformApplicationContextErrorCode2;\n})(EditorPlatformApplicationContextErrorCode || {});\nclass EditorPlatformApplicationContextError extends BaseError {\n state = {};\n constructor(message, code) {\n super(message, code, \"Editor Platform Application Context Error\");\n }\n withUrl(url) {\n this.state = { ...this.state, url };\n return this;\n }\n withAppDefinitionId(appDefinitionId) {\n this.state = { ...this.state, appDefinitionId };\n return this;\n }\n}\nconst createEditorPlatformApplicationContextError = createErrorBuilder(EditorPlatformApplicationContextError);\n\nasync function transformEventPayload(eventPayload, privateAPI) {\n if (!eventPayload?.type) {\n return eventPayload;\n }\n switch (eventPayload.type) {\n case \"componentSelectionChanged\":\n const componentRefs = eventPayload.componentRefs || [];\n const components = await Promise.all(\n componentRefs.map((ref) => {\n return privateAPI.components.getComponent(ref);\n })\n );\n return {\n type: eventPayload.type,\n components\n };\n default:\n return eventPayload;\n }\n}\n\nclass ApplicationBoundEvents {\n constructor(appDefinitionId, events, privateAPI) {\n this.appDefinitionId = appDefinitionId;\n this.privateAPI = privateAPI;\n this.events = events;\n this.subscribe = events.subscribe.bind(events);\n this.commit = events.commit.bind(events);\n this.startTransaction = events.startTransaction.bind(events);\n this.silent = events.silent.bind(events);\n }\n events;\n subscribe;\n commit;\n startTransaction;\n silent;\n notify(event) {\n this.events.notify({\n type: event.type,\n payload: event.payload,\n meta: {\n appDefinitionId: this.appDefinitionId\n }\n });\n }\n notifyCustomEvent(type, payload) {\n this.notify({\n type: PlatformAppEvent.CustomEvent,\n payload: {\n ...payload,\n type\n }\n });\n }\n /**\n * TODO: we should use same interface for all events\n * (subscribe vs addEventListener)\n */\n addEventListener(eventType, fn) {\n return this.events.subscribe(async (event) => {\n const isAppMatch = event.meta?.appDefinitionId === this.appDefinitionId || event.meta?.appDefinitionId === null;\n const transformPayload = () => transformEventPayload(event.payload, this.privateAPI);\n if (eventType === \"*\") {\n fn(await transformPayload());\n } else if (event.type === PlatformAppEvent.CustomEvent) {\n if (eventType === event.payload?.type && !isAppMatch) {\n fn(await transformPayload());\n }\n } else if (event.type === PlatformAppEvent.HostEvent) {\n if (eventType === event.payload?.type && isAppMatch) {\n fn(await transformPayload());\n }\n }\n });\n }\n}\n\nconst WAIT_INJECTED_TIMEOUT = 200;\nconst WAIT_INJECTED_RETRY_COUNT = 50;\nclass ContextInjectionStatus {\n _resolveContextInjected = () => {\n };\n _isInjected = false;\n key;\n constructor(uuid) {\n this.key = `__${uuid}_CONTEXT_INJECTION_STATUS_KEY`;\n if (!globalThis[this.key]) {\n globalThis[this.key] = new Promise((resolve) => {\n this._resolveContextInjected = () => {\n this._isInjected = true;\n resolve();\n };\n });\n }\n }\n isInjected() {\n return !!this._isInjected;\n }\n resolveInjected() {\n this._resolveContextInjected?.();\n }\n waitInjected() {\n return new Promise((resolve, reject) => {\n let injected = false;\n let timeoutId;\n let retryCount = 0;\n const timeout = () => {\n if (injected) {\n return;\n }\n timeoutId = setTimeout(() => {\n retryCount++;\n if (retryCount < WAIT_INJECTED_RETRY_COUNT) {\n if (retryCount % 10 === 0) {\n console.log(\n createEditorPlatformApplicationContextError(\n EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,\n \"contexts are not resolved, still re-trying\"\n ).withMessage(`try number ${retryCount}`).message\n );\n }\n timeout();\n return;\n }\n if (!injected) {\n const error = createEditorPlatformApplicationContextError(\n EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,\n \"contexts are not resolved, threw by timeout\"\n );\n reject(error);\n }\n }, WAIT_INJECTED_TIMEOUT);\n };\n timeout();\n const _waitContextInjectedPromise = globalThis[this.key];\n _waitContextInjectedPromise.then(() => {\n injected = true;\n clearTimeout(timeoutId);\n resolve();\n });\n });\n }\n}\n\nconst ENVIRONMENT_CONTEXT_KEY = \"__ENVIRONMENT_CONTEXT_KEY\";\nvar PlatformEnvironment = /* @__PURE__ */ ((PlatformEnvironment2) => {\n PlatformEnvironment2[\"Worker\"] = \"Worker\";\n PlatformEnvironment2[\"Frame\"] = \"Frame\";\n return PlatformEnvironment2;\n})(PlatformEnvironment || {});\nclass EnvironmentContext {\n constructor(environmentContext) {\n this.environmentContext = environmentContext;\n }\n static status = new ContextInjectionStatus(\"environment\");\n static async inject(context) {\n if (globalThis[ENVIRONMENT_CONTEXT_KEY]) {\n throw createEditorPlatformApplicationContextError(\n EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,\n \"Environment context already exists and should not be overridden\"\n );\n }\n globalThis[ENVIRONMENT_CONTEXT_KEY] = new EnvironmentContext(context);\n this.status.resolveInjected();\n }\n static async getInstance() {\n await this.status.waitInjected();\n return globalThis[ENVIRONMENT_CONTEXT_KEY];\n }\n getPrivateAPI() {\n return this.environmentContext.privateApi;\n }\n getEvents() {\n return this.environmentContext.events;\n }\n getApplicationAPIs() {\n return this.environmentContext.applicationAPIs ?? {};\n }\n getEnvironment() {\n return this.environmentContext.environment;\n }\n}\n\nconst APPLICATION_CONTEXT_KEY = \"__APPLICATION_CONTEXT_KEY\";\nclass ApplicationContext {\n constructor(applicationContext, environment) {\n this.applicationContext = applicationContext;\n this.environment = environment;\n this.events = new ApplicationBoundEvents(\n this.applicationContext.appDefinitionId,\n this.environment.getEvents(),\n this.environment.getPrivateAPI()\n );\n }\n static status = new ContextInjectionStatus(\"application\");\n /**\n * TODO: use generics for context type\n * - application\n * - editor\n */\n static async inject(context) {\n const environment = await EnvironmentContext.getInstance();\n if (environment.getEnvironment() !== PlatformEnvironment.Frame) {\n throw createEditorPlatformApplicationContextError(\n EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,\n \"Application context can be injected only in frame environment\"\n );\n }\n if (globalThis[APPLICATION_CONTEXT_KEY]) {\n throw createEditorPlatformApplicationContextError(\n EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,\n \"Application context already exists and should not be overridden\"\n );\n }\n globalThis[APPLICATION_CONTEXT_KEY] = new ApplicationContext(\n context,\n await EnvironmentContext.getInstance()\n );\n this.status.resolveInjected();\n }\n static async getInstance() {\n const environment = await EnvironmentContext.getInstance();\n if (environment.getEnvironment() === PlatformEnvironment.Frame) {\n await this.status.waitInjected();\n return globalThis[APPLICATION_CONTEXT_KEY];\n } else {\n return __APPLICATION_CONTEXT_KEY;\n }\n }\n events;\n getAppDefinitionId() {\n return this.applicationContext.appDefinitionId;\n }\n getBindings() {\n return this.applicationContext;\n }\n getEvents() {\n return this.events;\n }\n getPrivateAPI() {\n return this.environment.getPrivateAPI();\n }\n getPrivateApplicationAPI() {\n const appDefinitionId = this.getAppDefinitionId();\n if (!appDefinitionId) {\n throw createEditorPlatformApplicationContextError(\n EditorPlatformApplicationContextErrorCode.IncorrectEnvironment,\n \"appDefinitionId is not available\"\n );\n }\n return this.environment.getApplicationAPIs()[appDefinitionId];\n }\n}\n\nexport { APPLICATION_CONTEXT_KEY, ApplicationBoundEvents, ApplicationContext, ENVIRONMENT_CONTEXT_KEY, EnvironmentContext, PlatformEnvironment };\n//# sourceMappingURL=index.js.map\n","import { ApplicationContext } from '@wix/editor-application-context';\nimport {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\n\nexport enum EditorPlatformSDKAuthErrorCode {\n EmptyAppAuthInstance = 'EmptyAppAuthInstance',\n EmptyAppDefinitionId = 'EmptyAppDefinitionId',\n}\n\nclass EditorPlatformSDKAuthError extends BaseError<EditorPlatformSDKAuthErrorCode> {\n state: Partial<{\n appDefinitionId: string;\n }> = {};\n\n constructor(message: string, code: EditorPlatformSDKAuthErrorCode) {\n super(message, code, 'Auth Strategy Error');\n }\n\n withAppDefinitionId(appDefinitionId: string) {\n this.state = { ...this.state, appDefinitionId };\n return this;\n }\n}\n\nexport const createAuthStrategyShapeError = createErrorBuilder<\n EditorPlatformSDKAuthErrorCode,\n EditorPlatformSDKAuthError\n>(EditorPlatformSDKAuthError);\n\nexport const auth = () => {\n return {\n getAuthHeaders: async () => {\n const context = await ApplicationContext.getInstance();\n const privateAPI = context.getPrivateAPI();\n const bindings = context.getBindings();\n\n if (!bindings.appDefinitionId) {\n throw createAuthStrategyShapeError(\n EditorPlatformSDKAuthErrorCode.EmptyAppDefinitionId,\n );\n }\n\n const authInstance = await privateAPI.info.getAppInstance(\n bindings.appDefinitionId,\n );\n\n if (authInstance === undefined) {\n throw createAuthStrategyShapeError(\n EditorPlatformSDKAuthErrorCode.EmptyAppAuthInstance,\n ).withAppDefinitionId(bindings.appDefinitionId);\n }\n\n return {\n headers: {\n Authorization: authInstance,\n },\n };\n },\n };\n};\n","export class PlatformSDKShape<TShape extends Record<string, any>> {\n static create<TShape extends Record<string, any>>(\n namespace: string,\n shape: TShape,\n ) {\n return new PlatformSDKShape<TShape>(namespace, shape);\n }\n\n constructor(\n public namespace: string,\n private shape: TShape,\n ) {\n // Object.assign(this.shape, {\n // [Symbol(`platform-sdk-shape-namespace`)]: this.namespace,\n // });\n }\n\n build() {\n return {\n __type: 'host' as const,\n create: () => {\n return this.shape;\n },\n };\n }\n}\n","import { ApplicationContext } from '@wix/editor-application-context';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\n\nexport const application = {\n getPrivateAPI: async <TApplicationPrivateAPI = any>() => {\n const context = await ApplicationContext.getInstance();\n return context.getPrivateApplicationAPI() as TApplicationPrivateAPI;\n },\n getPublicAPI: async <TApplicationPrivateAPI = any>(\n appDefinitionId: string,\n ) => {\n const context = await ApplicationContext.getInstance();\n const privateAPI = context.getPrivateAPI();\n\n return privateAPI.applicationManager.getPublicApplicationAPI(\n appDefinitionId,\n ) as TApplicationPrivateAPI;\n },\n getAppInstance: async () => {\n const context = await ApplicationContext.getInstance();\n const privateAPI = context.getPrivateAPI();\n const bindings = context.getBindings();\n\n return privateAPI.info.getAppInstance(bindings.appDefinitionId);\n },\n};\n\nexport default PlatformSDKShape.create('application', application).build();\n","import {\n ApplicationContext,\n IComponent,\n} from '@wix/editor-application-context';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\n\nexport const components = {\n async getSelectedComponents(): Promise<IComponent[]> {\n const context = await ApplicationContext.getInstance();\n const privateAPI = context.getPrivateAPI();\n const refs = await privateAPI.components.getSelectedComponents();\n\n return Promise.all(\n refs.map((ref: any) => privateAPI.components.getComponent(ref)),\n );\n },\n};\n\nexport default PlatformSDKShape.create('components', components).build();\n","import {\n ApplicationContext,\n AppEventPayload,\n AllowedEvents,\n} from '@wix/editor-application-context';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\n\nexport const events = {\n addEventListener: async (\n name: any,\n // TODO: fix types\n cb: (payload: AppEventPayload<AllowedEvents>) => void,\n ) => {\n const context = await ApplicationContext.getInstance();\n return context.getEvents().addEventListener(name, cb);\n },\n};\n\nexport default PlatformSDKShape.create('events', events).build();\n","import { ApplicationContext } from '@wix/editor-application-context';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\n\nexport const info = {\n async getViewMode() {\n const context = await ApplicationContext.getInstance();\n const privateAPI = context.getPrivateAPI();\n return privateAPI.info.getViewMode();\n },\n\n async getLanguageCode() {\n const context = await ApplicationContext.getInstance();\n const privateAPI = context.getPrivateAPI();\n return privateAPI.info.getLanguageCode();\n },\n};\n\nexport default PlatformSDKShape.create('info', info).build();\n","import {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\n\nexport enum WidgetShapeErrorCode {\n UndefinedCompRef = 'UndefinedCompRef',\n}\n\nclass WidgetShapeError extends BaseError<WidgetShapeErrorCode> {\n constructor(message: string, code: WidgetShapeErrorCode) {\n super(message, code, 'Widget Error');\n }\n}\n\nexport const createWidgetShapeError = createErrorBuilder<\n WidgetShapeErrorCode,\n WidgetShapeError\n>(WidgetShapeError);\n","import { ApplicationContext } from '@wix/editor-application-context';\nimport { components } from '../components';\nimport { createWidgetShapeError, WidgetShapeErrorCode } from './errors';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\n\nconst getSelectedComponentRef = async () => {\n const selected = await components.getSelectedComponents();\n const compRef = selected[0]?.compRef;\n\n if (!compRef) {\n throw createWidgetShapeError(WidgetShapeErrorCode.UndefinedCompRef);\n }\n\n return compRef;\n};\n\nexport const widget = {\n // async getAttributes(): Promise<Record<string, string>> {\n // const context = await ApplicationContext.getInstance();\n // const privateAPI = context.getPrivateAPI();\n // const compRef = await getSelectedComponentRef();\n //\n // return privateAPI.customElement.getAttributes(compRef);\n // },\n async getProp(propName: string): Promise<string> {\n const context = await ApplicationContext.getInstance();\n const privateAPI = context.getPrivateAPI();\n const compRef = await getSelectedComponentRef();\n\n return privateAPI.customElement.getAttribute(compRef, propName);\n },\n async setProp(propName: string, value: string): Promise<void> {\n const context = await ApplicationContext.getInstance();\n const privateAPI = context.getPrivateAPI();\n const compRef = await getSelectedComponentRef();\n\n await privateAPI.customElement.setAttribute(compRef, propName, value);\n },\n};\n\nexport default PlatformSDKShape.create('widget', widget).build();\n","import { ApplicationContext } from '@wix/editor-application-context';\nimport { PlatformSDKShape } from '../PlatformSDKShape';\n\nexport const inputs = {\n // TODO: duplicated types\n async selectMedia(options: {\n mediaType: 'IMAGE' | 'VIDEO' | 'DOCUMENT';\n isMultiSelect?: boolean;\n }): Promise<any> {\n const context = await ApplicationContext.getInstance();\n const privateAPI = context.getPrivateAPI() as any;\n\n return privateAPI.inputs.openMediaPanel(options);\n },\n // TODO: duplicated types\n async selectLink<TResponse = object>(options: {\n value?: object;\n showLinkTargetSection?: boolean;\n }): Promise<TResponse> {\n const context = await ApplicationContext.getInstance();\n const privateAPI = context.getPrivateAPI() as any;\n\n return (await privateAPI.inputs.openLinkPanel(\n options,\n )) as Promise<TResponse>;\n },\n // TODO: duplicated types\n async selectColor(\n options: {\n color?: string;\n position?: {\n x: number;\n y: number;\n };\n },\n onColorChange: (value: {\n color: string;\n theme: string;\n isHover: boolean;\n }) => void,\n ) {\n const context = await ApplicationContext.getInstance();\n const privateAPI = context.getPrivateAPI() as any;\n\n void privateAPI.inputs.openColorPicker(options, onColorChange);\n },\n // TODO: duplicated types\n async selectFont(\n options: {\n position?: {\n x: number;\n y: number;\n };\n title?: string;\n panelSectionsDefinition?: Partial<{\n theme: 'hidden' | 'enabled';\n font: 'hidden' | 'enabled';\n size: 'hidden' | 'enabled';\n style: 'hidden' | 'enabled';\n htmlTag: 'hidden' | 'enabled';\n }>;\n fontMaxSize?: number;\n fontMinSize?: number;\n componentStyle?: {\n family: string;\n style: {\n bold: boolean;\n italic: boolean;\n underline: boolean;\n };\n size: number;\n preset: string;\n editorKey: string;\n\n htmlTag?: string;\n };\n },\n onFontChange: (\n value: [string, string | number | boolean, string] | [string, string],\n ) => void,\n ) {\n const context = await ApplicationContext.getInstance();\n const privateAPI = context.getPrivateAPI() as any;\n\n void privateAPI.inputs.openFontPicker(options, onFontChange);\n },\n};\n\nexport default PlatformSDKShape.create('inputs', inputs).build();\n","import { IFrameConsumerChannel } from '@wix/editor-platform-transport';\nimport { PlatformFrameAPI } from '@wix/editor-application/platform-frame-api';\nimport type { WixSDKTypes } from '@wix/public-editor-platform-interfaces';\n\n/**\n * TODO: expose channel from the host so all platform related modules\n * might get rid from the global Application and Environment contexts\n */\nexport const editorPlatformFrameHost = (): WixSDKTypes.Host => {\n const channel = new IFrameConsumerChannel();\n channel.expose(new PlatformFrameAPI());\n\n return {\n environment: {},\n channel: {\n observeState: async () => {\n return { disconnect() {} };\n },\n },\n };\n};\n","import { WorkerConsumerChannel } from '@wix/editor-platform-transport';\nimport { PlatformWorkerAPI } from '@wix/editor-application/platform-worker-api';\nimport type { WixSDKTypes } from '@wix/public-editor-platform-interfaces';\n\n/**\n * TODO: expose channel from the host so all platform related modules\n * might get rid from the global Application and Environment contexts\n */\nexport const editorPlatformWorkerHost = (): WixSDKTypes.Host => {\n const channel = new WorkerConsumerChannel();\n channel.expose(new PlatformWorkerAPI());\n\n return {\n environment: {},\n channel: {\n observeState: async () => {\n return { disconnect() {} };\n },\n },\n };\n};\n","import { auth } from './auth';\n\nexport { default as application } from './application';\nexport { default as components } from './components';\nexport { default as events } from './events';\nexport { default as info } from './info';\nexport { default as widget } from './widget';\nexport { default as inputs } from './inputs';\n\nimport { editorPlatformFrameHost } from './editorPlatformFrameHost';\nimport { editorPlatformWorkerHost } from './editorPlatformWorkerHost';\n\nexport const editor = {\n host: () => {\n const isWorker = typeof importScripts === 'function';\n\n if (isWorker) {\n return editorPlatformWorkerHost();\n }\n\n return editorPlatformFrameHost();\n },\n auth,\n};\n"],"names":["WidgetShapeErrorCode"],"mappings":";;;;;;AAGA,IAAI,yCAAA,qBAA8D,0CAA+C,KAAA;AAC/G,EAAA,0CAAA,CAA2C,sBAAsB,CAAI,GAAA,sBAAA,CAAA;AACrE,EAAO,OAAA,0CAAA,CAAA;AACT,CAAG,EAAA,yCAAA,IAA6C,EAAE,CAAA,CAAA;AAClD,MAAM,8CAA8C,SAAU,CAAA;AAAA,EAC5D,QAAQ,EAAC,CAAA;AAAA,EACT,WAAA,CAAY,SAAS,IAAM,EAAA;AACzB,IAAM,KAAA,CAAA,OAAA,EAAS,MAAM,2CAA2C,CAAA,CAAA;AAAA,GAClE;AAAA,EACA,QAAQ,GAAK,EAAA;AACX,IAAA,IAAA,CAAK,KAAQ,GAAA,EAAE,GAAG,IAAA,CAAK,OAAO,GAAI,EAAA,CAAA;AAClC,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AAAA,EACA,oBAAoB,eAAiB,EAAA;AACnC,IAAA,IAAA,CAAK,KAAQ,GAAA,EAAE,GAAG,IAAA,CAAK,OAAO,eAAgB,EAAA,CAAA;AAC9C,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AACF,CAAA;AACA,MAAM,2CAAA,GAA8C,mBAAmB,qCAAqC,CAAA,C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