@wix/public-editor-platform-events 1.284.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/cjs/index.js +321 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/index.mjs +313 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/types/index.d.ts +208 -0
- package/package.json +58 -0
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var editorPlatformSdkTypes = require('@wix/editor-platform-sdk-types');
|
|
4
|
+
|
|
5
|
+
class EventEmitter {
|
|
6
|
+
static biEvents = {
|
|
7
|
+
PLATFORM_WORKER_SPAWN: 123,
|
|
8
|
+
PLATFORM_APP_RUNNER_INIT_APP_API: 124,
|
|
9
|
+
PLATFORM_APP_RUNNER_RUN_APP: 125,
|
|
10
|
+
PLATFORM_APP_RUNNER_REMOVE_APP: 126,
|
|
11
|
+
PLATFORM_WORKER_APP_BUNDLE_LOAD: 127,
|
|
12
|
+
PLATFORM_WORKER_APP_BUNDLE_EXECUTE: 128,
|
|
13
|
+
PLATFORM_IFRAME_INIT: 129,
|
|
14
|
+
PLATFORM_APP_API_INIT: 130,
|
|
15
|
+
PLATFORM_APP_API_GET: 131
|
|
16
|
+
};
|
|
17
|
+
static EventSteps = {
|
|
18
|
+
Start: "start",
|
|
19
|
+
End: "end",
|
|
20
|
+
Error: "error"
|
|
21
|
+
};
|
|
22
|
+
uid = 0;
|
|
23
|
+
callbacks = /* @__PURE__ */ new Map();
|
|
24
|
+
inTransaction = false;
|
|
25
|
+
isSilent = false;
|
|
26
|
+
queue = [];
|
|
27
|
+
silent(isSilent = true) {
|
|
28
|
+
this.isSilent = isSilent;
|
|
29
|
+
}
|
|
30
|
+
startTransaction() {
|
|
31
|
+
this.inTransaction = true;
|
|
32
|
+
}
|
|
33
|
+
commit() {
|
|
34
|
+
this.inTransaction = false;
|
|
35
|
+
const queue = this.queue;
|
|
36
|
+
this.queue = [];
|
|
37
|
+
if (!this.isSilent) {
|
|
38
|
+
queue.forEach((event) => {
|
|
39
|
+
this.notify(event);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
notify(event) {
|
|
44
|
+
if (this.isSilent) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (this.inTransaction) {
|
|
48
|
+
this.queue.push(event);
|
|
49
|
+
} else {
|
|
50
|
+
this.callbacks.forEach((callback) => {
|
|
51
|
+
callback(event);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
subscribe(callback) {
|
|
56
|
+
const uid = this.uid++;
|
|
57
|
+
this.callbacks.set(uid, callback);
|
|
58
|
+
return () => {
|
|
59
|
+
this.callbacks.delete(uid);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
notifyWithStep(event, step) {
|
|
63
|
+
this.notify({
|
|
64
|
+
...event,
|
|
65
|
+
meta: {
|
|
66
|
+
...event.meta,
|
|
67
|
+
step
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
async withEvent(event, cb) {
|
|
72
|
+
let result = cb();
|
|
73
|
+
if (result && result.hasOwnProperty("then")) {
|
|
74
|
+
try {
|
|
75
|
+
this.notifyWithStep(event, EventEmitter.EventSteps.Start);
|
|
76
|
+
result = await result;
|
|
77
|
+
this.notifyWithStep(event, EventEmitter.EventSteps.End);
|
|
78
|
+
return result;
|
|
79
|
+
} catch (e) {
|
|
80
|
+
this.notifyWithStep(
|
|
81
|
+
{
|
|
82
|
+
...event,
|
|
83
|
+
meta: {
|
|
84
|
+
...event.meta,
|
|
85
|
+
error: e
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
EventEmitter.EventSteps.Error
|
|
89
|
+
);
|
|
90
|
+
throw e;
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
this.notify(event);
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
var PlatformPrivateEvent = /* @__PURE__ */ ((PlatformPrivateEvent2) => {
|
|
100
|
+
PlatformPrivateEvent2["WorkerSpawn"] = "WorkerSpawn";
|
|
101
|
+
PlatformPrivateEvent2["HostEvent"] = "HostEvent";
|
|
102
|
+
PlatformPrivateEvent2["ApplicationsSpecsReceived"] = "ApplicationsSpecsReceived";
|
|
103
|
+
PlatformPrivateEvent2["InitApplicationApi"] = "InitApplicationApi";
|
|
104
|
+
PlatformPrivateEvent2["RunApplication"] = "RunApplication";
|
|
105
|
+
PlatformPrivateEvent2["getApplicationApi"] = "getApplicationApi";
|
|
106
|
+
PlatformPrivateEvent2["IframeInit"] = "IframeInit";
|
|
107
|
+
return PlatformPrivateEvent2;
|
|
108
|
+
})(PlatformPrivateEvent || {});
|
|
109
|
+
var PlatformLifecycleEvent = /* @__PURE__ */ ((PlatformLifecycleEvent2) => {
|
|
110
|
+
PlatformLifecycleEvent2["EditorReady"] = "EditorReady";
|
|
111
|
+
return PlatformLifecycleEvent2;
|
|
112
|
+
})(PlatformLifecycleEvent || {});
|
|
113
|
+
class PlatformPrivateEventFactories {
|
|
114
|
+
createWorkerSpawnEvent({
|
|
115
|
+
url,
|
|
116
|
+
workerId,
|
|
117
|
+
strategy
|
|
118
|
+
}) {
|
|
119
|
+
return {
|
|
120
|
+
type: "WorkerSpawn" /* WorkerSpawn */,
|
|
121
|
+
payload: {
|
|
122
|
+
url
|
|
123
|
+
},
|
|
124
|
+
meta: {
|
|
125
|
+
bi: {
|
|
126
|
+
evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_WORKER_SPAWN,
|
|
127
|
+
workerId,
|
|
128
|
+
strategy
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
createRunApplicationEvent(app) {
|
|
134
|
+
return {
|
|
135
|
+
type: "RunApplication" /* RunApplication */,
|
|
136
|
+
payload: {
|
|
137
|
+
appDefinitionId: app.appDefinitionId
|
|
138
|
+
},
|
|
139
|
+
meta: {
|
|
140
|
+
bi: {
|
|
141
|
+
appType: app.type,
|
|
142
|
+
appDefId: app.appDefinitionId,
|
|
143
|
+
evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_APP_RUNNER_RUN_APP
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
createGetApplicationApiEvent(targetAppDefId, scope) {
|
|
149
|
+
return {
|
|
150
|
+
type: "getApplicationApi" /* getApplicationApi */,
|
|
151
|
+
payload: {},
|
|
152
|
+
meta: {
|
|
153
|
+
bi: {
|
|
154
|
+
targetAppDefId,
|
|
155
|
+
scope,
|
|
156
|
+
evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_APP_API_GET
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
createInitApplicationApiEvent(appDefinitionId) {
|
|
162
|
+
return {
|
|
163
|
+
type: "InitApplicationApi" /* InitApplicationApi */,
|
|
164
|
+
payload: {
|
|
165
|
+
appDefinitionId
|
|
166
|
+
},
|
|
167
|
+
meta: {
|
|
168
|
+
bi: {
|
|
169
|
+
appDefId: appDefinitionId,
|
|
170
|
+
evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_APP_API_INIT
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
createIframeInitEvent(frameUrl, iframeId) {
|
|
176
|
+
return {
|
|
177
|
+
type: "IframeInit" /* IframeInit */,
|
|
178
|
+
payload: {},
|
|
179
|
+
meta: {
|
|
180
|
+
bi: {
|
|
181
|
+
frameUrl,
|
|
182
|
+
iframeId,
|
|
183
|
+
evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_IFRAME_INIT
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
class PlatformPrivateEventEmitter extends EventEmitter {
|
|
190
|
+
factories = new PlatformPrivateEventFactories();
|
|
191
|
+
notify(event) {
|
|
192
|
+
super.notify(event);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
var PlatformAppEvent = /* @__PURE__ */ ((PlatformAppEvent2) => {
|
|
197
|
+
PlatformAppEvent2["ApplicationInit"] = "ApplicationInit";
|
|
198
|
+
PlatformAppEvent2["ApplicationExecute"] = "ApplicationExecute";
|
|
199
|
+
PlatformAppEvent2["ApplicationRemoved"] = "ApplicationRemoved";
|
|
200
|
+
PlatformAppEvent2["ApplicationLoad"] = "ApplicationLoad";
|
|
201
|
+
PlatformAppEvent2["ApplicationApiInit"] = "ApplicationApiInit";
|
|
202
|
+
PlatformAppEvent2["CustomEvent"] = "CustomEvent";
|
|
203
|
+
PlatformAppEvent2["HostEvent"] = "HostEvent";
|
|
204
|
+
PlatformAppEvent2["EditorReady"] = "EditorReady";
|
|
205
|
+
return PlatformAppEvent2;
|
|
206
|
+
})(PlatformAppEvent || {});
|
|
207
|
+
class PlatformAppEventsFactories {
|
|
208
|
+
createApplicationRemovedEvent(appDefinitionId) {
|
|
209
|
+
return {
|
|
210
|
+
type: "ApplicationRemoved" /* ApplicationRemoved */,
|
|
211
|
+
payload: {
|
|
212
|
+
appDefinitionId
|
|
213
|
+
},
|
|
214
|
+
meta: {
|
|
215
|
+
bi: {
|
|
216
|
+
evid: PlatformAppEventEmitter.biEvents.PLATFORM_WORKER_SPAWN,
|
|
217
|
+
appDefId: appDefinitionId
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
createApplicationLoadEvent(app, url) {
|
|
223
|
+
return {
|
|
224
|
+
type: "ApplicationLoad" /* ApplicationLoad */,
|
|
225
|
+
payload: {
|
|
226
|
+
appDefinitionId: app.appDefinitionId,
|
|
227
|
+
url
|
|
228
|
+
},
|
|
229
|
+
meta: {
|
|
230
|
+
bi: {
|
|
231
|
+
evid: PlatformAppEventEmitter.biEvents.PLATFORM_WORKER_APP_BUNDLE_LOAD,
|
|
232
|
+
appDefId: app.appDefinitionId,
|
|
233
|
+
appType: app.appType,
|
|
234
|
+
bundleUrl: url
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
createApplicationExecuteEvent(app, url) {
|
|
240
|
+
return {
|
|
241
|
+
type: "ApplicationExecute" /* ApplicationExecute */,
|
|
242
|
+
payload: {
|
|
243
|
+
appDefinitionId: app.appDefinitionId,
|
|
244
|
+
url
|
|
245
|
+
},
|
|
246
|
+
meta: {
|
|
247
|
+
bi: {
|
|
248
|
+
evid: PlatformAppEventEmitter.biEvents.PLATFORM_WORKER_APP_BUNDLE_EXECUTE,
|
|
249
|
+
appDefId: app.appDefinitionId,
|
|
250
|
+
appType: app.appType,
|
|
251
|
+
bundleUrl: url
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
createApplicationApiInitEvent(appDefinitionId, scope) {
|
|
257
|
+
return {
|
|
258
|
+
type: "ApplicationApiInit" /* ApplicationApiInit */,
|
|
259
|
+
payload: { appDefinitionId },
|
|
260
|
+
meta: {
|
|
261
|
+
bi: {
|
|
262
|
+
evid: PlatformAppEventEmitter.biEvents.PLATFORM_APP_API_INIT,
|
|
263
|
+
appDefId: appDefinitionId,
|
|
264
|
+
scope
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
class PlatformAppEventEmitter extends EventEmitter {
|
|
271
|
+
factories = new PlatformAppEventsFactories();
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
class DMEventsBridge {
|
|
275
|
+
constructor(events) {
|
|
276
|
+
this.events = events;
|
|
277
|
+
}
|
|
278
|
+
static allowedEvents = [
|
|
279
|
+
editorPlatformSdkTypes.EventType.componentSelectionChanged,
|
|
280
|
+
editorPlatformSdkTypes.EventType.appInstalled,
|
|
281
|
+
editorPlatformSdkTypes.EventType.appUpdateCompleted,
|
|
282
|
+
editorPlatformSdkTypes.EventType.removeAppCompleted
|
|
283
|
+
];
|
|
284
|
+
mapToPlatformHostEvent(event) {
|
|
285
|
+
if (typeof event === "string") {
|
|
286
|
+
try {
|
|
287
|
+
event = JSON.parse(event);
|
|
288
|
+
} catch (e) {
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return {
|
|
292
|
+
type: PlatformPrivateEvent.HostEvent,
|
|
293
|
+
payload: {
|
|
294
|
+
type: event.args.eventType,
|
|
295
|
+
...event.args.eventPayload
|
|
296
|
+
},
|
|
297
|
+
meta: {
|
|
298
|
+
appDefinitionId: event.appDefinitionId ?? null,
|
|
299
|
+
intent: event.intent
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Notify by event from Worker Manager (platform infrastructure)
|
|
305
|
+
*/
|
|
306
|
+
notify(_event) {
|
|
307
|
+
const event = this.mapToPlatformHostEvent(_event);
|
|
308
|
+
if (DMEventsBridge.allowedEvents.includes(event.payload.type)) {
|
|
309
|
+
this.events.notify(event);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
exports.DMEventsBridge = DMEventsBridge;
|
|
315
|
+
exports.EventEmitter = EventEmitter;
|
|
316
|
+
exports.PlatformAppEvent = PlatformAppEvent;
|
|
317
|
+
exports.PlatformAppEventEmitter = PlatformAppEventEmitter;
|
|
318
|
+
exports.PlatformLifecycleEvent = PlatformLifecycleEvent;
|
|
319
|
+
exports.PlatformPrivateEvent = PlatformPrivateEvent;
|
|
320
|
+
exports.PlatformPrivateEventEmitter = PlatformPrivateEventEmitter;
|
|
321
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/EventEmitter.ts","../../src/PlatformPrivateEventEmitter.ts","../../src/PlatformAppEventEmitter.ts","../../src/DMEventsBridge.ts"],"sourcesContent":["export class EventEmitter<TEvent = any> {\n static biEvents = {\n PLATFORM_WORKER_SPAWN: 123,\n PLATFORM_APP_RUNNER_INIT_APP_API: 124,\n PLATFORM_APP_RUNNER_RUN_APP: 125,\n PLATFORM_APP_RUNNER_REMOVE_APP: 126,\n PLATFORM_WORKER_APP_BUNDLE_LOAD: 127,\n PLATFORM_WORKER_APP_BUNDLE_EXECUTE: 128,\n PLATFORM_IFRAME_INIT: 129,\n PLATFORM_APP_API_INIT: 130,\n PLATFORM_APP_API_GET: 131,\n };\n\n static EventSteps = {\n Start: 'start',\n End: 'end',\n Error: 'error',\n };\n\n private uid = 0;\n private callbacks: Map<any, (event: TEvent) => void> = new Map();\n private inTransaction = false;\n private isSilent = false;\n private queue: TEvent[] = [];\n\n silent(isSilent = true) {\n this.isSilent = isSilent;\n }\n\n startTransaction() {\n this.inTransaction = true;\n }\n\n commit() {\n this.inTransaction = false;\n\n const queue = this.queue;\n this.queue = [];\n\n if (!this.isSilent) {\n queue.forEach((event) => {\n this.notify(event);\n });\n }\n }\n\n notify(event: TEvent) {\n if (this.isSilent) {\n return;\n }\n\n if (this.inTransaction) {\n this.queue.push(event);\n } else {\n this.callbacks.forEach((callback) => {\n callback(event);\n });\n }\n }\n\n subscribe(callback: (event: TEvent) => void) {\n const uid = this.uid++;\n\n this.callbacks.set(uid, callback);\n\n return () => {\n this.callbacks.delete(uid);\n };\n }\n\n notifyWithStep(event: TEvent, step: string) {\n this.notify({\n ...event,\n meta: {\n ...(event as any).meta,\n step,\n },\n });\n }\n\n async withEvent<TResult = any>(\n event: TEvent,\n cb: () => TResult | Promise<TResult>,\n ): Promise<TResult> {\n let result = cb();\n\n if (result && result.hasOwnProperty('then')) {\n try {\n this.notifyWithStep(event, EventEmitter.EventSteps.Start);\n\n result = await result;\n\n this.notifyWithStep(event, EventEmitter.EventSteps.End);\n\n return result;\n } catch (e) {\n this.notifyWithStep(\n {\n ...event,\n meta: {\n ...(event as any).meta,\n error: e,\n },\n },\n EventEmitter.EventSteps.Error,\n );\n\n throw e;\n }\n } else {\n this.notify(event);\n\n return result;\n }\n }\n}\n","import { EventEmitter } from './EventEmitter';\nimport { IPlatformPrivateEventBase } from './events';\n\nexport enum PlatformPrivateEvent {\n WorkerSpawn = 'WorkerSpawn',\n HostEvent = 'HostEvent',\n ApplicationsSpecsReceived = 'ApplicationsSpecsReceived',\n InitApplicationApi = 'InitApplicationApi',\n RunApplication = 'RunApplication',\n getApplicationApi = 'getApplicationApi',\n IframeInit = 'IframeInit',\n}\n\nexport enum PlatformLifecycleEvent {\n EditorReady = 'EditorReady',\n}\n\nexport type IPlatformWorkerSpawnEvent = IPlatformPrivateEventBase<\n PlatformPrivateEvent.WorkerSpawn,\n { url: string },\n {\n bi: {\n workerId: string;\n strategy: string;\n };\n }\n>;\n\nexport type IPlatformEditorReadyLifecycleEvent = IPlatformPrivateEventBase<\n PlatformLifecycleEvent.EditorReady,\n {},\n {}\n>;\n\nexport type IPlatformHostEvent = IPlatformPrivateEventBase<\n PlatformPrivateEvent.HostEvent,\n {\n type: string;\n },\n { appDefinitionId: string; intent: string }\n>;\n\nexport type IPlatformApplicationsSpecsReceived = IPlatformPrivateEventBase<\n PlatformPrivateEvent.ApplicationsSpecsReceived,\n {\n appDefinitionIds: string[];\n },\n {}\n>;\n\nexport type IPlatformRunApplication = IPlatformPrivateEventBase<\n PlatformPrivateEvent.RunApplication,\n {\n appDefinitionId: string;\n },\n {\n bi: {\n appType?: string;\n appDefId?: string;\n };\n }\n>;\n\nexport type IPlatformGetApplicationApi = IPlatformPrivateEventBase<\n PlatformPrivateEvent.getApplicationApi,\n {},\n {\n bi: {\n targetAppDefId: string;\n scope: 'private' | 'public';\n };\n }\n>;\n\nexport type IPlatformInitApplicationApi = IPlatformPrivateEventBase<\n PlatformPrivateEvent.InitApplicationApi,\n {\n appDefinitionId: string;\n },\n {\n bi: {\n appDefId: string;\n };\n }\n>;\n\nexport type IPlatformIframeInit = IPlatformPrivateEventBase<\n PlatformPrivateEvent.IframeInit,\n {},\n {\n bi: {\n frameUrl: string;\n iframeId: string;\n };\n }\n>;\n\nexport type IPlatformPrivateEvent =\n | IPlatformWorkerSpawnEvent\n | IPlatformEditorReadyLifecycleEvent\n | IPlatformHostEvent\n | IPlatformApplicationsSpecsReceived\n | IPlatformRunApplication\n | IPlatformGetApplicationApi\n | IPlatformInitApplicationApi\n | IPlatformIframeInit;\n\nclass PlatformPrivateEventFactories {\n public createWorkerSpawnEvent({\n url,\n workerId,\n strategy,\n }: {\n url: string;\n workerId: string;\n strategy: string;\n }): IPlatformWorkerSpawnEvent {\n return {\n type: PlatformPrivateEvent.WorkerSpawn,\n payload: {\n url,\n },\n meta: {\n bi: {\n evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_WORKER_SPAWN,\n workerId,\n strategy,\n },\n },\n };\n }\n\n public createRunApplicationEvent(app: {\n appDefinitionId: string;\n type: string;\n }): IPlatformRunApplication {\n return {\n type: PlatformPrivateEvent.RunApplication,\n payload: {\n appDefinitionId: app.appDefinitionId,\n },\n meta: {\n bi: {\n appType: app.type,\n appDefId: app.appDefinitionId,\n evid: PlatformPrivateEventEmitter.biEvents\n .PLATFORM_APP_RUNNER_RUN_APP,\n },\n },\n };\n }\n\n public createGetApplicationApiEvent(\n targetAppDefId: string,\n scope: 'private' | 'public',\n ): IPlatformGetApplicationApi {\n return {\n type: PlatformPrivateEvent.getApplicationApi,\n payload: {},\n meta: {\n bi: {\n targetAppDefId,\n scope,\n evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_APP_API_GET,\n },\n },\n };\n }\n\n public createInitApplicationApiEvent(\n appDefinitionId: string,\n ): IPlatformInitApplicationApi {\n return {\n type: PlatformPrivateEvent.InitApplicationApi,\n payload: {\n appDefinitionId,\n },\n meta: {\n bi: {\n appDefId: appDefinitionId,\n evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_APP_API_INIT,\n },\n },\n };\n }\n\n public createIframeInitEvent(\n frameUrl: string,\n iframeId: string,\n ): IPlatformIframeInit {\n return {\n type: PlatformPrivateEvent.IframeInit,\n payload: {},\n meta: {\n bi: {\n frameUrl,\n iframeId,\n evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_IFRAME_INIT,\n },\n },\n };\n }\n}\n\nexport class PlatformPrivateEventEmitter extends EventEmitter<IPlatformPrivateEvent> {\n public factories = new PlatformPrivateEventFactories();\n\n notify(event: IPlatformPrivateEvent) {\n super.notify(event);\n }\n}\n","import { EventEmitter } from './EventEmitter';\n\nimport { IPlatformAppEventBase, IPlatformEventBase } from './events';\n\nexport enum PlatformAppEvent {\n ApplicationInit = 'ApplicationInit',\n ApplicationExecute = 'ApplicationExecute',\n ApplicationRemoved = 'ApplicationRemoved',\n ApplicationLoad = 'ApplicationLoad',\n ApplicationApiInit = 'ApplicationApiInit',\n CustomEvent = 'CustomEvent',\n HostEvent = 'HostEvent',\n\n EditorReady = 'EditorReady',\n}\n\nexport type IPlatformAppInitEvent = IPlatformAppEventBase<\n PlatformAppEvent.ApplicationInit,\n {},\n {}\n>;\n\nexport type IPlatformAppCustomEvent = IPlatformAppEventBase<\n PlatformAppEvent.CustomEvent,\n {\n type: string;\n } & Record<string, string>,\n {}\n>;\n\nexport type IPlatformAppHostEvent = IPlatformAppEventBase<\n PlatformAppEvent.HostEvent,\n {\n type: string;\n } & Record<string, string>,\n {}\n>;\n\nexport type IPlatformAppExecuteEvent = IPlatformAppEventBase<\n PlatformAppEvent.ApplicationExecute,\n {\n url: string;\n appDefinitionId: string;\n },\n {\n bi: {\n appDefId: string;\n appType: string;\n bundleUrl: string;\n };\n }\n>;\n\nexport type IPlatformEditorReadyEvent = IPlatformEventBase<\n PlatformAppEvent.EditorReady,\n {},\n {}\n>;\n\nexport type IPlatformApplicationRemovedEvent = IPlatformAppEventBase<\n PlatformAppEvent.ApplicationRemoved,\n {},\n {\n bi: {\n appDefId: string;\n };\n }\n>;\n\nexport type IPlatformAppLoadEvent = IPlatformAppEventBase<\n PlatformAppEvent.ApplicationLoad,\n {\n url: string;\n appDefinitionId: string;\n },\n {\n bi: {\n appDefId: string;\n appType: string;\n bundleUrl: string;\n };\n }\n>;\n\nexport type IPlatformApplicationApiInitEvent = IPlatformAppEventBase<\n PlatformAppEvent.ApplicationApiInit,\n {},\n {\n bi: {\n appDefId: string;\n scope: 'private' | 'public';\n };\n }\n>;\n\nexport type IPlatformAppEvent =\n | IPlatformAppInitEvent\n | IPlatformAppCustomEvent\n | IPlatformAppHostEvent\n | IPlatformAppExecuteEvent\n | IPlatformAppLoadEvent\n | IPlatformApplicationRemovedEvent\n | IPlatformApplicationApiInitEvent;\n\nclass PlatformAppEventsFactories {\n public createApplicationRemovedEvent(\n appDefinitionId: string,\n ): IPlatformApplicationRemovedEvent {\n return {\n type: PlatformAppEvent.ApplicationRemoved,\n payload: {\n appDefinitionId,\n },\n meta: {\n bi: {\n evid: PlatformAppEventEmitter.biEvents.PLATFORM_WORKER_SPAWN,\n appDefId: appDefinitionId,\n },\n },\n };\n }\n\n public createApplicationLoadEvent(\n app: {\n appDefinitionId: string;\n appType: string;\n },\n url: string,\n ): IPlatformAppLoadEvent {\n return {\n type: PlatformAppEvent.ApplicationLoad,\n payload: {\n appDefinitionId: app.appDefinitionId,\n url,\n },\n meta: {\n bi: {\n evid: PlatformAppEventEmitter.biEvents\n .PLATFORM_WORKER_APP_BUNDLE_LOAD,\n appDefId: app.appDefinitionId,\n appType: app.appType,\n bundleUrl: url,\n },\n },\n };\n }\n\n public createApplicationExecuteEvent(\n app: {\n appDefinitionId: string;\n appType: string;\n },\n url: string,\n ): IPlatformAppExecuteEvent {\n return {\n type: PlatformAppEvent.ApplicationExecute,\n payload: {\n appDefinitionId: app.appDefinitionId,\n url,\n },\n meta: {\n bi: {\n evid: PlatformAppEventEmitter.biEvents\n .PLATFORM_WORKER_APP_BUNDLE_EXECUTE,\n appDefId: app.appDefinitionId,\n appType: app.appType,\n bundleUrl: url,\n },\n },\n };\n }\n\n public createApplicationApiInitEvent(\n appDefinitionId: string,\n scope: 'private' | 'public',\n ): IPlatformApplicationApiInitEvent {\n return {\n type: PlatformAppEvent.ApplicationApiInit,\n payload: { appDefinitionId },\n meta: {\n bi: {\n evid: PlatformAppEventEmitter.biEvents.PLATFORM_APP_API_INIT,\n appDefId: appDefinitionId,\n scope,\n },\n },\n };\n }\n}\n\nexport class PlatformAppEventEmitter extends EventEmitter<IPlatformAppEvent> {\n public factories = new PlatformAppEventsFactories();\n}\n","import { EventType } from '@wix/editor-platform-sdk-types';\nimport {\n IPlatformHostEvent,\n PlatformPrivateEvent,\n PlatformPrivateEventEmitter,\n} from './PlatformPrivateEventEmitter';\n\n/**\n * The events bridge between DM and private events\n */\nexport class DMEventsBridge {\n static allowedEvents = [\n EventType.componentSelectionChanged,\n EventType.appInstalled,\n EventType.appUpdateCompleted,\n EventType.removeAppCompleted,\n ];\n\n private mapToPlatformHostEvent(event: any): IPlatformHostEvent {\n if (typeof event === 'string') {\n try {\n event = JSON.parse(event);\n } catch (e) {\n // TODO: log error\n }\n }\n\n return {\n type: PlatformPrivateEvent.HostEvent,\n payload: {\n type: event.args.eventType,\n ...event.args.eventPayload,\n },\n meta: {\n appDefinitionId: event.appDefinitionId ?? null,\n intent: event.intent,\n },\n };\n }\n\n constructor(private events: PlatformPrivateEventEmitter) {}\n\n /**\n * Notify by event from Worker Manager (platform infrastructure)\n */\n public notify(_event: any) {\n const event = this.mapToPlatformHostEvent(_event);\n if (\n DMEventsBridge.allowedEvents.includes(event.payload.type as EventType)\n ) {\n this.events.notify(event);\n }\n }\n}\n"],"names":["PlatformPrivateEvent","PlatformLifecycleEvent","PlatformAppEvent","EventType"],"mappings":";;;;AAAO,MAAM,YAA2B,CAAA;AAAA,EACtC,OAAO,QAAW,GAAA;AAAA,IAChB,qBAAuB,EAAA,GAAA;AAAA,IACvB,gCAAkC,EAAA,GAAA;AAAA,IAClC,2BAA6B,EAAA,GAAA;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C1B;AAAA,GACF;AACF;;;;;;;;;;"}
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { EventType } from '@wix/editor-platform-sdk-types';
|
|
2
|
+
|
|
3
|
+
class EventEmitter {
|
|
4
|
+
static biEvents = {
|
|
5
|
+
PLATFORM_WORKER_SPAWN: 123,
|
|
6
|
+
PLATFORM_APP_RUNNER_INIT_APP_API: 124,
|
|
7
|
+
PLATFORM_APP_RUNNER_RUN_APP: 125,
|
|
8
|
+
PLATFORM_APP_RUNNER_REMOVE_APP: 126,
|
|
9
|
+
PLATFORM_WORKER_APP_BUNDLE_LOAD: 127,
|
|
10
|
+
PLATFORM_WORKER_APP_BUNDLE_EXECUTE: 128,
|
|
11
|
+
PLATFORM_IFRAME_INIT: 129,
|
|
12
|
+
PLATFORM_APP_API_INIT: 130,
|
|
13
|
+
PLATFORM_APP_API_GET: 131
|
|
14
|
+
};
|
|
15
|
+
static EventSteps = {
|
|
16
|
+
Start: "start",
|
|
17
|
+
End: "end",
|
|
18
|
+
Error: "error"
|
|
19
|
+
};
|
|
20
|
+
uid = 0;
|
|
21
|
+
callbacks = /* @__PURE__ */ new Map();
|
|
22
|
+
inTransaction = false;
|
|
23
|
+
isSilent = false;
|
|
24
|
+
queue = [];
|
|
25
|
+
silent(isSilent = true) {
|
|
26
|
+
this.isSilent = isSilent;
|
|
27
|
+
}
|
|
28
|
+
startTransaction() {
|
|
29
|
+
this.inTransaction = true;
|
|
30
|
+
}
|
|
31
|
+
commit() {
|
|
32
|
+
this.inTransaction = false;
|
|
33
|
+
const queue = this.queue;
|
|
34
|
+
this.queue = [];
|
|
35
|
+
if (!this.isSilent) {
|
|
36
|
+
queue.forEach((event) => {
|
|
37
|
+
this.notify(event);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
notify(event) {
|
|
42
|
+
if (this.isSilent) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (this.inTransaction) {
|
|
46
|
+
this.queue.push(event);
|
|
47
|
+
} else {
|
|
48
|
+
this.callbacks.forEach((callback) => {
|
|
49
|
+
callback(event);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
subscribe(callback) {
|
|
54
|
+
const uid = this.uid++;
|
|
55
|
+
this.callbacks.set(uid, callback);
|
|
56
|
+
return () => {
|
|
57
|
+
this.callbacks.delete(uid);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
notifyWithStep(event, step) {
|
|
61
|
+
this.notify({
|
|
62
|
+
...event,
|
|
63
|
+
meta: {
|
|
64
|
+
...event.meta,
|
|
65
|
+
step
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
async withEvent(event, cb) {
|
|
70
|
+
let result = cb();
|
|
71
|
+
if (result && result.hasOwnProperty("then")) {
|
|
72
|
+
try {
|
|
73
|
+
this.notifyWithStep(event, EventEmitter.EventSteps.Start);
|
|
74
|
+
result = await result;
|
|
75
|
+
this.notifyWithStep(event, EventEmitter.EventSteps.End);
|
|
76
|
+
return result;
|
|
77
|
+
} catch (e) {
|
|
78
|
+
this.notifyWithStep(
|
|
79
|
+
{
|
|
80
|
+
...event,
|
|
81
|
+
meta: {
|
|
82
|
+
...event.meta,
|
|
83
|
+
error: e
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
EventEmitter.EventSteps.Error
|
|
87
|
+
);
|
|
88
|
+
throw e;
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
this.notify(event);
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
var PlatformPrivateEvent = /* @__PURE__ */ ((PlatformPrivateEvent2) => {
|
|
98
|
+
PlatformPrivateEvent2["WorkerSpawn"] = "WorkerSpawn";
|
|
99
|
+
PlatformPrivateEvent2["HostEvent"] = "HostEvent";
|
|
100
|
+
PlatformPrivateEvent2["ApplicationsSpecsReceived"] = "ApplicationsSpecsReceived";
|
|
101
|
+
PlatformPrivateEvent2["InitApplicationApi"] = "InitApplicationApi";
|
|
102
|
+
PlatformPrivateEvent2["RunApplication"] = "RunApplication";
|
|
103
|
+
PlatformPrivateEvent2["getApplicationApi"] = "getApplicationApi";
|
|
104
|
+
PlatformPrivateEvent2["IframeInit"] = "IframeInit";
|
|
105
|
+
return PlatformPrivateEvent2;
|
|
106
|
+
})(PlatformPrivateEvent || {});
|
|
107
|
+
var PlatformLifecycleEvent = /* @__PURE__ */ ((PlatformLifecycleEvent2) => {
|
|
108
|
+
PlatformLifecycleEvent2["EditorReady"] = "EditorReady";
|
|
109
|
+
return PlatformLifecycleEvent2;
|
|
110
|
+
})(PlatformLifecycleEvent || {});
|
|
111
|
+
class PlatformPrivateEventFactories {
|
|
112
|
+
createWorkerSpawnEvent({
|
|
113
|
+
url,
|
|
114
|
+
workerId,
|
|
115
|
+
strategy
|
|
116
|
+
}) {
|
|
117
|
+
return {
|
|
118
|
+
type: "WorkerSpawn" /* WorkerSpawn */,
|
|
119
|
+
payload: {
|
|
120
|
+
url
|
|
121
|
+
},
|
|
122
|
+
meta: {
|
|
123
|
+
bi: {
|
|
124
|
+
evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_WORKER_SPAWN,
|
|
125
|
+
workerId,
|
|
126
|
+
strategy
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
createRunApplicationEvent(app) {
|
|
132
|
+
return {
|
|
133
|
+
type: "RunApplication" /* RunApplication */,
|
|
134
|
+
payload: {
|
|
135
|
+
appDefinitionId: app.appDefinitionId
|
|
136
|
+
},
|
|
137
|
+
meta: {
|
|
138
|
+
bi: {
|
|
139
|
+
appType: app.type,
|
|
140
|
+
appDefId: app.appDefinitionId,
|
|
141
|
+
evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_APP_RUNNER_RUN_APP
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
createGetApplicationApiEvent(targetAppDefId, scope) {
|
|
147
|
+
return {
|
|
148
|
+
type: "getApplicationApi" /* getApplicationApi */,
|
|
149
|
+
payload: {},
|
|
150
|
+
meta: {
|
|
151
|
+
bi: {
|
|
152
|
+
targetAppDefId,
|
|
153
|
+
scope,
|
|
154
|
+
evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_APP_API_GET
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
createInitApplicationApiEvent(appDefinitionId) {
|
|
160
|
+
return {
|
|
161
|
+
type: "InitApplicationApi" /* InitApplicationApi */,
|
|
162
|
+
payload: {
|
|
163
|
+
appDefinitionId
|
|
164
|
+
},
|
|
165
|
+
meta: {
|
|
166
|
+
bi: {
|
|
167
|
+
appDefId: appDefinitionId,
|
|
168
|
+
evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_APP_API_INIT
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
createIframeInitEvent(frameUrl, iframeId) {
|
|
174
|
+
return {
|
|
175
|
+
type: "IframeInit" /* IframeInit */,
|
|
176
|
+
payload: {},
|
|
177
|
+
meta: {
|
|
178
|
+
bi: {
|
|
179
|
+
frameUrl,
|
|
180
|
+
iframeId,
|
|
181
|
+
evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_IFRAME_INIT
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
class PlatformPrivateEventEmitter extends EventEmitter {
|
|
188
|
+
factories = new PlatformPrivateEventFactories();
|
|
189
|
+
notify(event) {
|
|
190
|
+
super.notify(event);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
var PlatformAppEvent = /* @__PURE__ */ ((PlatformAppEvent2) => {
|
|
195
|
+
PlatformAppEvent2["ApplicationInit"] = "ApplicationInit";
|
|
196
|
+
PlatformAppEvent2["ApplicationExecute"] = "ApplicationExecute";
|
|
197
|
+
PlatformAppEvent2["ApplicationRemoved"] = "ApplicationRemoved";
|
|
198
|
+
PlatformAppEvent2["ApplicationLoad"] = "ApplicationLoad";
|
|
199
|
+
PlatformAppEvent2["ApplicationApiInit"] = "ApplicationApiInit";
|
|
200
|
+
PlatformAppEvent2["CustomEvent"] = "CustomEvent";
|
|
201
|
+
PlatformAppEvent2["HostEvent"] = "HostEvent";
|
|
202
|
+
PlatformAppEvent2["EditorReady"] = "EditorReady";
|
|
203
|
+
return PlatformAppEvent2;
|
|
204
|
+
})(PlatformAppEvent || {});
|
|
205
|
+
class PlatformAppEventsFactories {
|
|
206
|
+
createApplicationRemovedEvent(appDefinitionId) {
|
|
207
|
+
return {
|
|
208
|
+
type: "ApplicationRemoved" /* ApplicationRemoved */,
|
|
209
|
+
payload: {
|
|
210
|
+
appDefinitionId
|
|
211
|
+
},
|
|
212
|
+
meta: {
|
|
213
|
+
bi: {
|
|
214
|
+
evid: PlatformAppEventEmitter.biEvents.PLATFORM_WORKER_SPAWN,
|
|
215
|
+
appDefId: appDefinitionId
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
createApplicationLoadEvent(app, url) {
|
|
221
|
+
return {
|
|
222
|
+
type: "ApplicationLoad" /* ApplicationLoad */,
|
|
223
|
+
payload: {
|
|
224
|
+
appDefinitionId: app.appDefinitionId,
|
|
225
|
+
url
|
|
226
|
+
},
|
|
227
|
+
meta: {
|
|
228
|
+
bi: {
|
|
229
|
+
evid: PlatformAppEventEmitter.biEvents.PLATFORM_WORKER_APP_BUNDLE_LOAD,
|
|
230
|
+
appDefId: app.appDefinitionId,
|
|
231
|
+
appType: app.appType,
|
|
232
|
+
bundleUrl: url
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
createApplicationExecuteEvent(app, url) {
|
|
238
|
+
return {
|
|
239
|
+
type: "ApplicationExecute" /* ApplicationExecute */,
|
|
240
|
+
payload: {
|
|
241
|
+
appDefinitionId: app.appDefinitionId,
|
|
242
|
+
url
|
|
243
|
+
},
|
|
244
|
+
meta: {
|
|
245
|
+
bi: {
|
|
246
|
+
evid: PlatformAppEventEmitter.biEvents.PLATFORM_WORKER_APP_BUNDLE_EXECUTE,
|
|
247
|
+
appDefId: app.appDefinitionId,
|
|
248
|
+
appType: app.appType,
|
|
249
|
+
bundleUrl: url
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
createApplicationApiInitEvent(appDefinitionId, scope) {
|
|
255
|
+
return {
|
|
256
|
+
type: "ApplicationApiInit" /* ApplicationApiInit */,
|
|
257
|
+
payload: { appDefinitionId },
|
|
258
|
+
meta: {
|
|
259
|
+
bi: {
|
|
260
|
+
evid: PlatformAppEventEmitter.biEvents.PLATFORM_APP_API_INIT,
|
|
261
|
+
appDefId: appDefinitionId,
|
|
262
|
+
scope
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
class PlatformAppEventEmitter extends EventEmitter {
|
|
269
|
+
factories = new PlatformAppEventsFactories();
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
class DMEventsBridge {
|
|
273
|
+
constructor(events) {
|
|
274
|
+
this.events = events;
|
|
275
|
+
}
|
|
276
|
+
static allowedEvents = [
|
|
277
|
+
EventType.componentSelectionChanged,
|
|
278
|
+
EventType.appInstalled,
|
|
279
|
+
EventType.appUpdateCompleted,
|
|
280
|
+
EventType.removeAppCompleted
|
|
281
|
+
];
|
|
282
|
+
mapToPlatformHostEvent(event) {
|
|
283
|
+
if (typeof event === "string") {
|
|
284
|
+
try {
|
|
285
|
+
event = JSON.parse(event);
|
|
286
|
+
} catch (e) {
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return {
|
|
290
|
+
type: PlatformPrivateEvent.HostEvent,
|
|
291
|
+
payload: {
|
|
292
|
+
type: event.args.eventType,
|
|
293
|
+
...event.args.eventPayload
|
|
294
|
+
},
|
|
295
|
+
meta: {
|
|
296
|
+
appDefinitionId: event.appDefinitionId ?? null,
|
|
297
|
+
intent: event.intent
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Notify by event from Worker Manager (platform infrastructure)
|
|
303
|
+
*/
|
|
304
|
+
notify(_event) {
|
|
305
|
+
const event = this.mapToPlatformHostEvent(_event);
|
|
306
|
+
if (DMEventsBridge.allowedEvents.includes(event.payload.type)) {
|
|
307
|
+
this.events.notify(event);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export { DMEventsBridge, EventEmitter, PlatformAppEvent, PlatformAppEventEmitter, PlatformLifecycleEvent, PlatformPrivateEvent, PlatformPrivateEventEmitter };
|
|
313
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/EventEmitter.ts","../../src/PlatformPrivateEventEmitter.ts","../../src/PlatformAppEventEmitter.ts","../../src/DMEventsBridge.ts"],"sourcesContent":["export class EventEmitter<TEvent = any> {\n static biEvents = {\n PLATFORM_WORKER_SPAWN: 123,\n PLATFORM_APP_RUNNER_INIT_APP_API: 124,\n PLATFORM_APP_RUNNER_RUN_APP: 125,\n PLATFORM_APP_RUNNER_REMOVE_APP: 126,\n PLATFORM_WORKER_APP_BUNDLE_LOAD: 127,\n PLATFORM_WORKER_APP_BUNDLE_EXECUTE: 128,\n PLATFORM_IFRAME_INIT: 129,\n PLATFORM_APP_API_INIT: 130,\n PLATFORM_APP_API_GET: 131,\n };\n\n static EventSteps = {\n Start: 'start',\n End: 'end',\n Error: 'error',\n };\n\n private uid = 0;\n private callbacks: Map<any, (event: TEvent) => void> = new Map();\n private inTransaction = false;\n private isSilent = false;\n private queue: TEvent[] = [];\n\n silent(isSilent = true) {\n this.isSilent = isSilent;\n }\n\n startTransaction() {\n this.inTransaction = true;\n }\n\n commit() {\n this.inTransaction = false;\n\n const queue = this.queue;\n this.queue = [];\n\n if (!this.isSilent) {\n queue.forEach((event) => {\n this.notify(event);\n });\n }\n }\n\n notify(event: TEvent) {\n if (this.isSilent) {\n return;\n }\n\n if (this.inTransaction) {\n this.queue.push(event);\n } else {\n this.callbacks.forEach((callback) => {\n callback(event);\n });\n }\n }\n\n subscribe(callback: (event: TEvent) => void) {\n const uid = this.uid++;\n\n this.callbacks.set(uid, callback);\n\n return () => {\n this.callbacks.delete(uid);\n };\n }\n\n notifyWithStep(event: TEvent, step: string) {\n this.notify({\n ...event,\n meta: {\n ...(event as any).meta,\n step,\n },\n });\n }\n\n async withEvent<TResult = any>(\n event: TEvent,\n cb: () => TResult | Promise<TResult>,\n ): Promise<TResult> {\n let result = cb();\n\n if (result && result.hasOwnProperty('then')) {\n try {\n this.notifyWithStep(event, EventEmitter.EventSteps.Start);\n\n result = await result;\n\n this.notifyWithStep(event, EventEmitter.EventSteps.End);\n\n return result;\n } catch (e) {\n this.notifyWithStep(\n {\n ...event,\n meta: {\n ...(event as any).meta,\n error: e,\n },\n },\n EventEmitter.EventSteps.Error,\n );\n\n throw e;\n }\n } else {\n this.notify(event);\n\n return result;\n }\n }\n}\n","import { EventEmitter } from './EventEmitter';\nimport { IPlatformPrivateEventBase } from './events';\n\nexport enum PlatformPrivateEvent {\n WorkerSpawn = 'WorkerSpawn',\n HostEvent = 'HostEvent',\n ApplicationsSpecsReceived = 'ApplicationsSpecsReceived',\n InitApplicationApi = 'InitApplicationApi',\n RunApplication = 'RunApplication',\n getApplicationApi = 'getApplicationApi',\n IframeInit = 'IframeInit',\n}\n\nexport enum PlatformLifecycleEvent {\n EditorReady = 'EditorReady',\n}\n\nexport type IPlatformWorkerSpawnEvent = IPlatformPrivateEventBase<\n PlatformPrivateEvent.WorkerSpawn,\n { url: string },\n {\n bi: {\n workerId: string;\n strategy: string;\n };\n }\n>;\n\nexport type IPlatformEditorReadyLifecycleEvent = IPlatformPrivateEventBase<\n PlatformLifecycleEvent.EditorReady,\n {},\n {}\n>;\n\nexport type IPlatformHostEvent = IPlatformPrivateEventBase<\n PlatformPrivateEvent.HostEvent,\n {\n type: string;\n },\n { appDefinitionId: string; intent: string }\n>;\n\nexport type IPlatformApplicationsSpecsReceived = IPlatformPrivateEventBase<\n PlatformPrivateEvent.ApplicationsSpecsReceived,\n {\n appDefinitionIds: string[];\n },\n {}\n>;\n\nexport type IPlatformRunApplication = IPlatformPrivateEventBase<\n PlatformPrivateEvent.RunApplication,\n {\n appDefinitionId: string;\n },\n {\n bi: {\n appType?: string;\n appDefId?: string;\n };\n }\n>;\n\nexport type IPlatformGetApplicationApi = IPlatformPrivateEventBase<\n PlatformPrivateEvent.getApplicationApi,\n {},\n {\n bi: {\n targetAppDefId: string;\n scope: 'private' | 'public';\n };\n }\n>;\n\nexport type IPlatformInitApplicationApi = IPlatformPrivateEventBase<\n PlatformPrivateEvent.InitApplicationApi,\n {\n appDefinitionId: string;\n },\n {\n bi: {\n appDefId: string;\n };\n }\n>;\n\nexport type IPlatformIframeInit = IPlatformPrivateEventBase<\n PlatformPrivateEvent.IframeInit,\n {},\n {\n bi: {\n frameUrl: string;\n iframeId: string;\n };\n }\n>;\n\nexport type IPlatformPrivateEvent =\n | IPlatformWorkerSpawnEvent\n | IPlatformEditorReadyLifecycleEvent\n | IPlatformHostEvent\n | IPlatformApplicationsSpecsReceived\n | IPlatformRunApplication\n | IPlatformGetApplicationApi\n | IPlatformInitApplicationApi\n | IPlatformIframeInit;\n\nclass PlatformPrivateEventFactories {\n public createWorkerSpawnEvent({\n url,\n workerId,\n strategy,\n }: {\n url: string;\n workerId: string;\n strategy: string;\n }): IPlatformWorkerSpawnEvent {\n return {\n type: PlatformPrivateEvent.WorkerSpawn,\n payload: {\n url,\n },\n meta: {\n bi: {\n evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_WORKER_SPAWN,\n workerId,\n strategy,\n },\n },\n };\n }\n\n public createRunApplicationEvent(app: {\n appDefinitionId: string;\n type: string;\n }): IPlatformRunApplication {\n return {\n type: PlatformPrivateEvent.RunApplication,\n payload: {\n appDefinitionId: app.appDefinitionId,\n },\n meta: {\n bi: {\n appType: app.type,\n appDefId: app.appDefinitionId,\n evid: PlatformPrivateEventEmitter.biEvents\n .PLATFORM_APP_RUNNER_RUN_APP,\n },\n },\n };\n }\n\n public createGetApplicationApiEvent(\n targetAppDefId: string,\n scope: 'private' | 'public',\n ): IPlatformGetApplicationApi {\n return {\n type: PlatformPrivateEvent.getApplicationApi,\n payload: {},\n meta: {\n bi: {\n targetAppDefId,\n scope,\n evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_APP_API_GET,\n },\n },\n };\n }\n\n public createInitApplicationApiEvent(\n appDefinitionId: string,\n ): IPlatformInitApplicationApi {\n return {\n type: PlatformPrivateEvent.InitApplicationApi,\n payload: {\n appDefinitionId,\n },\n meta: {\n bi: {\n appDefId: appDefinitionId,\n evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_APP_API_INIT,\n },\n },\n };\n }\n\n public createIframeInitEvent(\n frameUrl: string,\n iframeId: string,\n ): IPlatformIframeInit {\n return {\n type: PlatformPrivateEvent.IframeInit,\n payload: {},\n meta: {\n bi: {\n frameUrl,\n iframeId,\n evid: PlatformPrivateEventEmitter.biEvents.PLATFORM_IFRAME_INIT,\n },\n },\n };\n }\n}\n\nexport class PlatformPrivateEventEmitter extends EventEmitter<IPlatformPrivateEvent> {\n public factories = new PlatformPrivateEventFactories();\n\n notify(event: IPlatformPrivateEvent) {\n super.notify(event);\n }\n}\n","import { EventEmitter } from './EventEmitter';\n\nimport { IPlatformAppEventBase, IPlatformEventBase } from './events';\n\nexport enum PlatformAppEvent {\n ApplicationInit = 'ApplicationInit',\n ApplicationExecute = 'ApplicationExecute',\n ApplicationRemoved = 'ApplicationRemoved',\n ApplicationLoad = 'ApplicationLoad',\n ApplicationApiInit = 'ApplicationApiInit',\n CustomEvent = 'CustomEvent',\n HostEvent = 'HostEvent',\n\n EditorReady = 'EditorReady',\n}\n\nexport type IPlatformAppInitEvent = IPlatformAppEventBase<\n PlatformAppEvent.ApplicationInit,\n {},\n {}\n>;\n\nexport type IPlatformAppCustomEvent = IPlatformAppEventBase<\n PlatformAppEvent.CustomEvent,\n {\n type: string;\n } & Record<string, string>,\n {}\n>;\n\nexport type IPlatformAppHostEvent = IPlatformAppEventBase<\n PlatformAppEvent.HostEvent,\n {\n type: string;\n } & Record<string, string>,\n {}\n>;\n\nexport type IPlatformAppExecuteEvent = IPlatformAppEventBase<\n PlatformAppEvent.ApplicationExecute,\n {\n url: string;\n appDefinitionId: string;\n },\n {\n bi: {\n appDefId: string;\n appType: string;\n bundleUrl: string;\n };\n }\n>;\n\nexport type IPlatformEditorReadyEvent = IPlatformEventBase<\n PlatformAppEvent.EditorReady,\n {},\n {}\n>;\n\nexport type IPlatformApplicationRemovedEvent = IPlatformAppEventBase<\n PlatformAppEvent.ApplicationRemoved,\n {},\n {\n bi: {\n appDefId: string;\n };\n }\n>;\n\nexport type IPlatformAppLoadEvent = IPlatformAppEventBase<\n PlatformAppEvent.ApplicationLoad,\n {\n url: string;\n appDefinitionId: string;\n },\n {\n bi: {\n appDefId: string;\n appType: string;\n bundleUrl: string;\n };\n }\n>;\n\nexport type IPlatformApplicationApiInitEvent = IPlatformAppEventBase<\n PlatformAppEvent.ApplicationApiInit,\n {},\n {\n bi: {\n appDefId: string;\n scope: 'private' | 'public';\n };\n }\n>;\n\nexport type IPlatformAppEvent =\n | IPlatformAppInitEvent\n | IPlatformAppCustomEvent\n | IPlatformAppHostEvent\n | IPlatformAppExecuteEvent\n | IPlatformAppLoadEvent\n | IPlatformApplicationRemovedEvent\n | IPlatformApplicationApiInitEvent;\n\nclass PlatformAppEventsFactories {\n public createApplicationRemovedEvent(\n appDefinitionId: string,\n ): IPlatformApplicationRemovedEvent {\n return {\n type: PlatformAppEvent.ApplicationRemoved,\n payload: {\n appDefinitionId,\n },\n meta: {\n bi: {\n evid: PlatformAppEventEmitter.biEvents.PLATFORM_WORKER_SPAWN,\n appDefId: appDefinitionId,\n },\n },\n };\n }\n\n public createApplicationLoadEvent(\n app: {\n appDefinitionId: string;\n appType: string;\n },\n url: string,\n ): IPlatformAppLoadEvent {\n return {\n type: PlatformAppEvent.ApplicationLoad,\n payload: {\n appDefinitionId: app.appDefinitionId,\n url,\n },\n meta: {\n bi: {\n evid: PlatformAppEventEmitter.biEvents\n .PLATFORM_WORKER_APP_BUNDLE_LOAD,\n appDefId: app.appDefinitionId,\n appType: app.appType,\n bundleUrl: url,\n },\n },\n };\n }\n\n public createApplicationExecuteEvent(\n app: {\n appDefinitionId: string;\n appType: string;\n },\n url: string,\n ): IPlatformAppExecuteEvent {\n return {\n type: PlatformAppEvent.ApplicationExecute,\n payload: {\n appDefinitionId: app.appDefinitionId,\n url,\n },\n meta: {\n bi: {\n evid: PlatformAppEventEmitter.biEvents\n .PLATFORM_WORKER_APP_BUNDLE_EXECUTE,\n appDefId: app.appDefinitionId,\n appType: app.appType,\n bundleUrl: url,\n },\n },\n };\n }\n\n public createApplicationApiInitEvent(\n appDefinitionId: string,\n scope: 'private' | 'public',\n ): IPlatformApplicationApiInitEvent {\n return {\n type: PlatformAppEvent.ApplicationApiInit,\n payload: { appDefinitionId },\n meta: {\n bi: {\n evid: PlatformAppEventEmitter.biEvents.PLATFORM_APP_API_INIT,\n appDefId: appDefinitionId,\n scope,\n },\n },\n };\n }\n}\n\nexport class PlatformAppEventEmitter extends EventEmitter<IPlatformAppEvent> {\n public factories = new PlatformAppEventsFactories();\n}\n","import { EventType } from '@wix/editor-platform-sdk-types';\nimport {\n IPlatformHostEvent,\n PlatformPrivateEvent,\n PlatformPrivateEventEmitter,\n} from './PlatformPrivateEventEmitter';\n\n/**\n * The events bridge between DM and private events\n */\nexport class DMEventsBridge {\n static allowedEvents = [\n EventType.componentSelectionChanged,\n EventType.appInstalled,\n EventType.appUpdateCompleted,\n EventType.removeAppCompleted,\n ];\n\n private mapToPlatformHostEvent(event: any): IPlatformHostEvent {\n if (typeof event === 'string') {\n try {\n event = JSON.parse(event);\n } catch (e) {\n // TODO: log error\n }\n }\n\n return {\n type: PlatformPrivateEvent.HostEvent,\n payload: {\n type: event.args.eventType,\n ...event.args.eventPayload,\n },\n meta: {\n appDefinitionId: event.appDefinitionId ?? null,\n intent: event.intent,\n },\n };\n }\n\n constructor(private events: PlatformPrivateEventEmitter) {}\n\n /**\n * Notify by event from Worker Manager (platform infrastructure)\n */\n public notify(_event: any) {\n const event = this.mapToPlatformHostEvent(_event);\n if (\n DMEventsBridge.allowedEvents.includes(event.payload.type as EventType)\n ) {\n this.events.notify(event);\n }\n }\n}\n"],"names":["PlatformPrivateEvent","PlatformLifecycleEvent","PlatformAppEvent"],"mappings":";;AAAO,MAAM,YAA2B,CAAA;AAAA,EACtC,OAAO,QAAW,GAAA;AAAA,IAChB,qBAAuB,EAAA,GAAA;AAAA,IACvB,gCAAkC,EAAA,GAAA;AAAA,IAClC,2BAA6B,EAAA,GAAA;AAAA,IAC7B,8BAAgC,EAAA,GAAA;AAAA,IAChC,+BAAiC,EAAA,GAAA;AAAA,IACjC,kCAAoC,EAAA,GAAA;AAAA,IACpC,oBAAsB,EAAA,GAAA;AAAA,IACtB,qBAAuB,EAAA,GAAA;AAAA,IACvB,oBAAsB,EAAA,GAAA;AAAA,GACxB,CAAA;AAAA,EAEA,OAAO,UAAa,GAAA;AAAA,IAClB,KAAO,EAAA,OAAA;AAAA,IACP,GAAK,EAAA,KAAA;AAAA,IACL,KAAO,EAAA,OAAA;AAAA,GACT,CAAA;AAAA,EAEQ,GAAM,GAAA,CAAA,CAAA;AAAA,EACN,SAAA,uBAAmD,GAAI,EAAA,CAAA;AAAA,EACvD,aAAgB,GAAA,KAAA,CAAA;AAAA,EAChB,QAAW,GAAA,KAAA,CAAA;AAAA,E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KAAA,GAAA,IAAA,CAAK,MAAM,KAAK,CAAA,CAAA;AAAA,eACjB,CAAG,EAAA;AAAA,OAEZ;AAAA,KACF;AAEA,IAAO,OAAA;AAAA,MACL,MAAM,oBAAqB,CAAA,SAAA;AAAA,MAC3B,OAAS,EAAA;AAAA,QACP,IAAA,EAAM,MAAM,IAAK,CAAA,SAAA;AAAA,QACjB,GAAG,MAAM,IAAK,CAAA,YAAA;AAAA,OAChB;AAAA,MACA,IAAM,EAAA;AAAA,QACJ,eAAA,EAAiB,MAAM,eAAmB,IAAA,IAAA;AAAA,QAC1C,QAAQ,KAAM,CAAA,MAAA;AAAA,OAChB;AAAA,KACF,CAAA;AAAA,GACF;AAAA;AAAA;AAAA;AAAA,EAOO,OAAO,MAAa,EAAA;AACzB,IAAM,MAAA,KAAA,GAAQ,IAAK,CAAA,sBAAA,CAAuB,MAAM,CAAA,CAAA;AAChD,IAAA,IACE,eAAe,aAAc,CAAA,QAAA,CAAS,KAAM,CAAA,OAAA,CAAQ,IAAiB,CACrE,EAAA;AACA,MAAK,IAAA,CAAA,MAAA,CAAO,OAAO,KAAK,CAAA,CAAA;AAAA,KAC1B;AAAA,GACF;AACF;;;;"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { EventType } from '@wix/editor-platform-sdk-types';
|
|
2
|
+
|
|
3
|
+
declare class EventEmitter<TEvent = any> {
|
|
4
|
+
static biEvents: {
|
|
5
|
+
PLATFORM_WORKER_SPAWN: number;
|
|
6
|
+
PLATFORM_APP_RUNNER_INIT_APP_API: number;
|
|
7
|
+
PLATFORM_APP_RUNNER_RUN_APP: number;
|
|
8
|
+
PLATFORM_APP_RUNNER_REMOVE_APP: number;
|
|
9
|
+
PLATFORM_WORKER_APP_BUNDLE_LOAD: number;
|
|
10
|
+
PLATFORM_WORKER_APP_BUNDLE_EXECUTE: number;
|
|
11
|
+
PLATFORM_IFRAME_INIT: number;
|
|
12
|
+
PLATFORM_APP_API_INIT: number;
|
|
13
|
+
PLATFORM_APP_API_GET: number;
|
|
14
|
+
};
|
|
15
|
+
static EventSteps: {
|
|
16
|
+
Start: string;
|
|
17
|
+
End: string;
|
|
18
|
+
Error: string;
|
|
19
|
+
};
|
|
20
|
+
private uid;
|
|
21
|
+
private callbacks;
|
|
22
|
+
private inTransaction;
|
|
23
|
+
private isSilent;
|
|
24
|
+
private queue;
|
|
25
|
+
silent(isSilent?: boolean): void;
|
|
26
|
+
startTransaction(): void;
|
|
27
|
+
commit(): void;
|
|
28
|
+
notify(event: TEvent): void;
|
|
29
|
+
subscribe(callback: (event: TEvent) => void): () => void;
|
|
30
|
+
notifyWithStep(event: TEvent, step: string): void;
|
|
31
|
+
withEvent<TResult = any>(event: TEvent, cb: () => TResult | Promise<TResult>): Promise<TResult>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface IMetaBase {
|
|
35
|
+
bi?: {
|
|
36
|
+
evid: number;
|
|
37
|
+
};
|
|
38
|
+
error?: any;
|
|
39
|
+
step?: string;
|
|
40
|
+
}
|
|
41
|
+
interface IPlatformEventBase<TType, TPayload, TMeta> {
|
|
42
|
+
type: TType;
|
|
43
|
+
payload: TPayload;
|
|
44
|
+
meta: TMeta & IMetaBase;
|
|
45
|
+
}
|
|
46
|
+
type IPlatformPrivateEventBase<TType, TPayload, TMeta> = IPlatformEventBase<TType, TPayload, TMeta>;
|
|
47
|
+
type IPlatformAppEventBase<TType, TPayload, TMeta> = IPlatformEventBase<TType, TPayload, TMeta & {
|
|
48
|
+
appDefinitionId?: string;
|
|
49
|
+
}>;
|
|
50
|
+
|
|
51
|
+
declare enum PlatformPrivateEvent {
|
|
52
|
+
WorkerSpawn = "WorkerSpawn",
|
|
53
|
+
HostEvent = "HostEvent",
|
|
54
|
+
ApplicationsSpecsReceived = "ApplicationsSpecsReceived",
|
|
55
|
+
InitApplicationApi = "InitApplicationApi",
|
|
56
|
+
RunApplication = "RunApplication",
|
|
57
|
+
getApplicationApi = "getApplicationApi",
|
|
58
|
+
IframeInit = "IframeInit"
|
|
59
|
+
}
|
|
60
|
+
declare enum PlatformLifecycleEvent {
|
|
61
|
+
EditorReady = "EditorReady"
|
|
62
|
+
}
|
|
63
|
+
type IPlatformWorkerSpawnEvent = IPlatformPrivateEventBase<PlatformPrivateEvent.WorkerSpawn, {
|
|
64
|
+
url: string;
|
|
65
|
+
}, {
|
|
66
|
+
bi: {
|
|
67
|
+
workerId: string;
|
|
68
|
+
strategy: string;
|
|
69
|
+
};
|
|
70
|
+
}>;
|
|
71
|
+
type IPlatformEditorReadyLifecycleEvent = IPlatformPrivateEventBase<PlatformLifecycleEvent.EditorReady, {}, {}>;
|
|
72
|
+
type IPlatformHostEvent = IPlatformPrivateEventBase<PlatformPrivateEvent.HostEvent, {
|
|
73
|
+
type: string;
|
|
74
|
+
}, {
|
|
75
|
+
appDefinitionId: string;
|
|
76
|
+
intent: string;
|
|
77
|
+
}>;
|
|
78
|
+
type IPlatformApplicationsSpecsReceived = IPlatformPrivateEventBase<PlatformPrivateEvent.ApplicationsSpecsReceived, {
|
|
79
|
+
appDefinitionIds: string[];
|
|
80
|
+
}, {}>;
|
|
81
|
+
type IPlatformRunApplication = IPlatformPrivateEventBase<PlatformPrivateEvent.RunApplication, {
|
|
82
|
+
appDefinitionId: string;
|
|
83
|
+
}, {
|
|
84
|
+
bi: {
|
|
85
|
+
appType?: string;
|
|
86
|
+
appDefId?: string;
|
|
87
|
+
};
|
|
88
|
+
}>;
|
|
89
|
+
type IPlatformGetApplicationApi = IPlatformPrivateEventBase<PlatformPrivateEvent.getApplicationApi, {}, {
|
|
90
|
+
bi: {
|
|
91
|
+
targetAppDefId: string;
|
|
92
|
+
scope: 'private' | 'public';
|
|
93
|
+
};
|
|
94
|
+
}>;
|
|
95
|
+
type IPlatformInitApplicationApi = IPlatformPrivateEventBase<PlatformPrivateEvent.InitApplicationApi, {
|
|
96
|
+
appDefinitionId: string;
|
|
97
|
+
}, {
|
|
98
|
+
bi: {
|
|
99
|
+
appDefId: string;
|
|
100
|
+
};
|
|
101
|
+
}>;
|
|
102
|
+
type IPlatformIframeInit = IPlatformPrivateEventBase<PlatformPrivateEvent.IframeInit, {}, {
|
|
103
|
+
bi: {
|
|
104
|
+
frameUrl: string;
|
|
105
|
+
iframeId: string;
|
|
106
|
+
};
|
|
107
|
+
}>;
|
|
108
|
+
type IPlatformPrivateEvent = IPlatformWorkerSpawnEvent | IPlatformEditorReadyLifecycleEvent | IPlatformHostEvent | IPlatformApplicationsSpecsReceived | IPlatformRunApplication | IPlatformGetApplicationApi | IPlatformInitApplicationApi | IPlatformIframeInit;
|
|
109
|
+
declare class PlatformPrivateEventFactories {
|
|
110
|
+
createWorkerSpawnEvent({ url, workerId, strategy, }: {
|
|
111
|
+
url: string;
|
|
112
|
+
workerId: string;
|
|
113
|
+
strategy: string;
|
|
114
|
+
}): IPlatformWorkerSpawnEvent;
|
|
115
|
+
createRunApplicationEvent(app: {
|
|
116
|
+
appDefinitionId: string;
|
|
117
|
+
type: string;
|
|
118
|
+
}): IPlatformRunApplication;
|
|
119
|
+
createGetApplicationApiEvent(targetAppDefId: string, scope: 'private' | 'public'): IPlatformGetApplicationApi;
|
|
120
|
+
createInitApplicationApiEvent(appDefinitionId: string): IPlatformInitApplicationApi;
|
|
121
|
+
createIframeInitEvent(frameUrl: string, iframeId: string): IPlatformIframeInit;
|
|
122
|
+
}
|
|
123
|
+
declare class PlatformPrivateEventEmitter extends EventEmitter<IPlatformPrivateEvent> {
|
|
124
|
+
factories: PlatformPrivateEventFactories;
|
|
125
|
+
notify(event: IPlatformPrivateEvent): void;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
declare enum PlatformAppEvent {
|
|
129
|
+
ApplicationInit = "ApplicationInit",
|
|
130
|
+
ApplicationExecute = "ApplicationExecute",
|
|
131
|
+
ApplicationRemoved = "ApplicationRemoved",
|
|
132
|
+
ApplicationLoad = "ApplicationLoad",
|
|
133
|
+
ApplicationApiInit = "ApplicationApiInit",
|
|
134
|
+
CustomEvent = "CustomEvent",
|
|
135
|
+
HostEvent = "HostEvent",
|
|
136
|
+
EditorReady = "EditorReady"
|
|
137
|
+
}
|
|
138
|
+
type IPlatformAppInitEvent = IPlatformAppEventBase<PlatformAppEvent.ApplicationInit, {}, {}>;
|
|
139
|
+
type IPlatformAppCustomEvent = IPlatformAppEventBase<PlatformAppEvent.CustomEvent, {
|
|
140
|
+
type: string;
|
|
141
|
+
} & Record<string, string>, {}>;
|
|
142
|
+
type IPlatformAppHostEvent = IPlatformAppEventBase<PlatformAppEvent.HostEvent, {
|
|
143
|
+
type: string;
|
|
144
|
+
} & Record<string, string>, {}>;
|
|
145
|
+
type IPlatformAppExecuteEvent = IPlatformAppEventBase<PlatformAppEvent.ApplicationExecute, {
|
|
146
|
+
url: string;
|
|
147
|
+
appDefinitionId: string;
|
|
148
|
+
}, {
|
|
149
|
+
bi: {
|
|
150
|
+
appDefId: string;
|
|
151
|
+
appType: string;
|
|
152
|
+
bundleUrl: string;
|
|
153
|
+
};
|
|
154
|
+
}>;
|
|
155
|
+
type IPlatformEditorReadyEvent = IPlatformEventBase<PlatformAppEvent.EditorReady, {}, {}>;
|
|
156
|
+
type IPlatformApplicationRemovedEvent = IPlatformAppEventBase<PlatformAppEvent.ApplicationRemoved, {}, {
|
|
157
|
+
bi: {
|
|
158
|
+
appDefId: string;
|
|
159
|
+
};
|
|
160
|
+
}>;
|
|
161
|
+
type IPlatformAppLoadEvent = IPlatformAppEventBase<PlatformAppEvent.ApplicationLoad, {
|
|
162
|
+
url: string;
|
|
163
|
+
appDefinitionId: string;
|
|
164
|
+
}, {
|
|
165
|
+
bi: {
|
|
166
|
+
appDefId: string;
|
|
167
|
+
appType: string;
|
|
168
|
+
bundleUrl: string;
|
|
169
|
+
};
|
|
170
|
+
}>;
|
|
171
|
+
type IPlatformApplicationApiInitEvent = IPlatformAppEventBase<PlatformAppEvent.ApplicationApiInit, {}, {
|
|
172
|
+
bi: {
|
|
173
|
+
appDefId: string;
|
|
174
|
+
scope: 'private' | 'public';
|
|
175
|
+
};
|
|
176
|
+
}>;
|
|
177
|
+
type IPlatformAppEvent = IPlatformAppInitEvent | IPlatformAppCustomEvent | IPlatformAppHostEvent | IPlatformAppExecuteEvent | IPlatformAppLoadEvent | IPlatformApplicationRemovedEvent | IPlatformApplicationApiInitEvent;
|
|
178
|
+
declare class PlatformAppEventsFactories {
|
|
179
|
+
createApplicationRemovedEvent(appDefinitionId: string): IPlatformApplicationRemovedEvent;
|
|
180
|
+
createApplicationLoadEvent(app: {
|
|
181
|
+
appDefinitionId: string;
|
|
182
|
+
appType: string;
|
|
183
|
+
}, url: string): IPlatformAppLoadEvent;
|
|
184
|
+
createApplicationExecuteEvent(app: {
|
|
185
|
+
appDefinitionId: string;
|
|
186
|
+
appType: string;
|
|
187
|
+
}, url: string): IPlatformAppExecuteEvent;
|
|
188
|
+
createApplicationApiInitEvent(appDefinitionId: string, scope: 'private' | 'public'): IPlatformApplicationApiInitEvent;
|
|
189
|
+
}
|
|
190
|
+
declare class PlatformAppEventEmitter extends EventEmitter<IPlatformAppEvent> {
|
|
191
|
+
factories: PlatformAppEventsFactories;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* The events bridge between DM and private events
|
|
196
|
+
*/
|
|
197
|
+
declare class DMEventsBridge {
|
|
198
|
+
private events;
|
|
199
|
+
static allowedEvents: EventType[];
|
|
200
|
+
private mapToPlatformHostEvent;
|
|
201
|
+
constructor(events: PlatformPrivateEventEmitter);
|
|
202
|
+
/**
|
|
203
|
+
* Notify by event from Worker Manager (platform infrastructure)
|
|
204
|
+
*/
|
|
205
|
+
notify(_event: any): void;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export { DMEventsBridge, EventEmitter, type IPlatformAppCustomEvent, type IPlatformAppEvent, type IPlatformAppExecuteEvent, type IPlatformAppHostEvent, type IPlatformAppInitEvent, type IPlatformAppLoadEvent, type IPlatformApplicationApiInitEvent, type IPlatformApplicationRemovedEvent, type IPlatformApplicationsSpecsReceived, type IPlatformEditorReadyEvent, type IPlatformEditorReadyLifecycleEvent, type IPlatformGetApplicationApi, type IPlatformHostEvent, type IPlatformIframeInit, type IPlatformInitApplicationApi, type IPlatformPrivateEvent, type IPlatformRunApplication, type IPlatformWorkerSpawnEvent, PlatformAppEvent, PlatformAppEventEmitter, PlatformLifecycleEvent, PlatformPrivateEvent, PlatformPrivateEventEmitter };
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wix/public-editor-platform-events",
|
|
3
|
+
"version": "1.284.0",
|
|
4
|
+
"license": "UNLICENSED",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Editor Platform <editor-platform-dev@wix.com>",
|
|
7
|
+
"email": "editor-platform-dev@wix.com"
|
|
8
|
+
},
|
|
9
|
+
"main": "dist/cjs/index.js",
|
|
10
|
+
"module": "dist/esm/index.mjs",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"types": "dist/types/index.d.ts",
|
|
13
|
+
"files": [
|
|
14
|
+
"dist/cjs",
|
|
15
|
+
"dist/esm",
|
|
16
|
+
"dist/types"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"registry": "https://registry.npmjs.org/",
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"unpkg": true,
|
|
23
|
+
"publishScoped": true,
|
|
24
|
+
"scripts": {
|
|
25
|
+
"start": "exit 0",
|
|
26
|
+
"build": "yarn typecheck && rollup -c",
|
|
27
|
+
"test": "exit 0",
|
|
28
|
+
"lint": "prettier --check ./src",
|
|
29
|
+
"lint:fix": "prettier --write ./src",
|
|
30
|
+
"typecheck": "tsc --noEmit"
|
|
31
|
+
},
|
|
32
|
+
"lint-staged": {
|
|
33
|
+
"*.{js,ts}": "yarn lint"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@wix/editor-platform-sdk-types": "1.1448.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"esbuild": "^0.19.5",
|
|
40
|
+
"prettier": "^3.1.0",
|
|
41
|
+
"rollup": "^3.29.4",
|
|
42
|
+
"rollup-plugin-dts": "^6.1.0",
|
|
43
|
+
"rollup-plugin-esbuild": "^5.0.0",
|
|
44
|
+
"typescript": "~5.2.2"
|
|
45
|
+
},
|
|
46
|
+
"wix": {
|
|
47
|
+
"artifact": {
|
|
48
|
+
"groupId": "com.wixpress",
|
|
49
|
+
"artifactId": "public-editor-platform-events"
|
|
50
|
+
},
|
|
51
|
+
"validations": {
|
|
52
|
+
"postDependenciesBuild": [
|
|
53
|
+
"lint"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"falconPackageHash": "cef22456c0ef307d71eb6cf5a02da1757f518ed25840a56676c25672"
|
|
58
|
+
}
|