@wix/editor-application 1.0.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/README.md +1 -0
- package/dist/cjs/index.js +182 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/index.js +177 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/statics/index.js +183 -0
- package/dist/statics/index.js.map +1 -0
- package/dist/types/index.d.ts +106 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +71 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
tbd
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var publicEditorPlatformEvents = require('@wix/public-editor-platform-events');
|
|
4
|
+
var publicEditorPlatformInterfaces = require('@wix/public-editor-platform-interfaces');
|
|
5
|
+
var publicEditorPlatformErrors = require('@wix/public-editor-platform-errors');
|
|
6
|
+
var editorPlatformContexts = require('@wix/editor-platform-contexts');
|
|
7
|
+
|
|
8
|
+
class ApplicationLifecycle {
|
|
9
|
+
constructor(events) {
|
|
10
|
+
this.events = events;
|
|
11
|
+
this.subscribe();
|
|
12
|
+
}
|
|
13
|
+
callbacks = {};
|
|
14
|
+
subscribe() {
|
|
15
|
+
this.events.subscribe((event) => {
|
|
16
|
+
const { type, payload } = event;
|
|
17
|
+
if (this.callbacks[type]) {
|
|
18
|
+
this.callbacks[type].forEach(({ fn }) => fn(payload));
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
addCallback(event, fn) {
|
|
23
|
+
if (!this.callbacks[event]) {
|
|
24
|
+
this.callbacks[event] = [];
|
|
25
|
+
}
|
|
26
|
+
const id = `${performance.now()}`;
|
|
27
|
+
this.callbacks[event].push({
|
|
28
|
+
id,
|
|
29
|
+
fn
|
|
30
|
+
});
|
|
31
|
+
return () => {
|
|
32
|
+
this.callbacks[event] = this.callbacks[event].filter(
|
|
33
|
+
(cb) => cb.id !== id
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* NOTE: currently, we return function to unsubscribe from the event,
|
|
39
|
+
* probably it is better to return `this` to allow chaining
|
|
40
|
+
* and provide another way to unsubscribe from events.
|
|
41
|
+
*/
|
|
42
|
+
onEditorReady(fn) {
|
|
43
|
+
return this.addCallback(publicEditorPlatformEvents.PlatformAppEvent.EditorReady, fn);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var EditorPlatformApplicationErrorCode = /* @__PURE__ */ ((EditorPlatformApplicationErrorCode2) => {
|
|
48
|
+
EditorPlatformApplicationErrorCode2["ApplicationRuntimeError"] = "ApplicationRuntimeError";
|
|
49
|
+
return EditorPlatformApplicationErrorCode2;
|
|
50
|
+
})(EditorPlatformApplicationErrorCode || {});
|
|
51
|
+
class EditorPlatformApplicationError extends publicEditorPlatformErrors.BaseError {
|
|
52
|
+
state = {};
|
|
53
|
+
constructor(message, code) {
|
|
54
|
+
super(message, code, "EP Application Error");
|
|
55
|
+
}
|
|
56
|
+
withUrl(url) {
|
|
57
|
+
this.state = { ...this.state, url };
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
withAppDefinitionId(appDefinitionId) {
|
|
61
|
+
this.state = { ...this.state, appDefinitionId };
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
withApiMethod(apiMethod) {
|
|
65
|
+
this.state = { ...this.state, apiMethod };
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
withApiType(apiType) {
|
|
69
|
+
this.state = { ...this.state, apiType };
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const createEditorPlatformApplicationError = publicEditorPlatformErrors.createErrorBuilder(EditorPlatformApplicationError);
|
|
74
|
+
|
|
75
|
+
class ChainAPIConfiguration {
|
|
76
|
+
constructor(api) {
|
|
77
|
+
this.api = api;
|
|
78
|
+
}
|
|
79
|
+
exposePublicAPI(api) {
|
|
80
|
+
this.api.public = api;
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
exposePrivateAPI(api) {
|
|
84
|
+
this.api.private = api;
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
class EditorPlatformApplication {
|
|
89
|
+
constructor(type, context) {
|
|
90
|
+
this.type = type;
|
|
91
|
+
this.#context = context;
|
|
92
|
+
const bindings = this.#context.getBindings();
|
|
93
|
+
this.appDefinitionId = bindings.appDefinitionId;
|
|
94
|
+
const events = this.#context.getEvents();
|
|
95
|
+
this.lifecycle = new ApplicationLifecycle(events);
|
|
96
|
+
events.addEventListener(publicEditorPlatformInterfaces.EventType.removeAppCompleted, (e) => {
|
|
97
|
+
if (e.appDefinitionId === this.appDefinitionId) {
|
|
98
|
+
this.state = "REMOVED";
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
const applicationRegister = __APPLICATION_REGISTRY_KEY;
|
|
102
|
+
applicationRegister(this);
|
|
103
|
+
events.notify({
|
|
104
|
+
type: publicEditorPlatformEvents.PlatformAppEvent.ApplicationInit,
|
|
105
|
+
payload: {}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
appDefinitionId;
|
|
109
|
+
state = "READY";
|
|
110
|
+
lifecycle;
|
|
111
|
+
#applicationAPI = {};
|
|
112
|
+
#chainAPIConfiguration = new ChainAPIConfiguration(
|
|
113
|
+
this.#applicationAPI
|
|
114
|
+
);
|
|
115
|
+
#manifest;
|
|
116
|
+
#context;
|
|
117
|
+
get context() {
|
|
118
|
+
return this.#context;
|
|
119
|
+
}
|
|
120
|
+
get events() {
|
|
121
|
+
return this.#context.getEvents();
|
|
122
|
+
}
|
|
123
|
+
setManifest(manifest) {
|
|
124
|
+
this.#manifest = manifest;
|
|
125
|
+
}
|
|
126
|
+
getManifest() {
|
|
127
|
+
return this.#manifest;
|
|
128
|
+
}
|
|
129
|
+
exposePublicAPI(api) {
|
|
130
|
+
return this.#chainAPIConfiguration.exposePublicAPI(api);
|
|
131
|
+
}
|
|
132
|
+
exposePrivateAPI(api) {
|
|
133
|
+
return this.#chainAPIConfiguration.exposePrivateAPI(api);
|
|
134
|
+
}
|
|
135
|
+
getPublicAPI() {
|
|
136
|
+
return this.#applicationAPI.public;
|
|
137
|
+
}
|
|
138
|
+
getPrivateAPI() {
|
|
139
|
+
return this.#applicationAPI.private;
|
|
140
|
+
}
|
|
141
|
+
ready() {
|
|
142
|
+
}
|
|
143
|
+
buildApplicationError(message) {
|
|
144
|
+
return createEditorPlatformApplicationError(
|
|
145
|
+
EditorPlatformApplicationErrorCode.ApplicationRuntimeError,
|
|
146
|
+
message
|
|
147
|
+
).withAppDefinitionId(this.appDefinitionId);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
var ApplicationType = /* @__PURE__ */ ((ApplicationType2) => {
|
|
152
|
+
ApplicationType2["EditorAddon"] = "EDITOR_ADDON";
|
|
153
|
+
ApplicationType2["Platform"] = "PLATFORM";
|
|
154
|
+
return ApplicationType2;
|
|
155
|
+
})(ApplicationType || {});
|
|
156
|
+
|
|
157
|
+
class WixEditorPlatformApplication extends EditorPlatformApplication {
|
|
158
|
+
static async create() {
|
|
159
|
+
return new WixEditorPlatformApplication(
|
|
160
|
+
await editorPlatformContexts.ApplicationContext.getInstance()
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
constructor(context) {
|
|
164
|
+
super(ApplicationType.Platform, context);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
class WixEditorPlatformAddon extends EditorPlatformApplication {
|
|
169
|
+
static async create() {
|
|
170
|
+
const context = await editorPlatformContexts.ApplicationContext.getInstance();
|
|
171
|
+
return new WixEditorPlatformAddon(context);
|
|
172
|
+
}
|
|
173
|
+
constructor(context) {
|
|
174
|
+
super(ApplicationType.EditorAddon, context);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
exports.ApplicationType = ApplicationType;
|
|
179
|
+
exports.EditorPlatformApplication = EditorPlatformApplication;
|
|
180
|
+
exports.WixEditorPlatformAddon = WixEditorPlatformAddon;
|
|
181
|
+
exports.WixEditorPlatformApplication = WixEditorPlatformApplication;
|
|
182
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/ApplicationLifecycle/ApplicationLifecycle.ts","../../src/errors.ts","../../src/EditorPlatformApplication/EditorPlatformApplication.ts","../../src/types.ts","../../src/EditorPlatformApplication/WixEditorPlatformApplication.ts","../../src/EditorPlatformApplication/WixEditorPlatformAddon.ts"],"sourcesContent":["import {\n PlatformAppEvent,\n IPlatformEditorReadyEvent,\n} from '@wix/public-editor-platform-events';\nimport type { ApplicationBoundEvents } from '@wix/editor-platform-contexts';\n\nexport class ApplicationLifecycle {\n private callbacks: Partial<\n Record<\n PlatformAppEvent,\n {\n id: string;\n fn: (payload: any) => void;\n }[]\n >\n > = {};\n\n constructor(private events: ApplicationBoundEvents) {\n this.subscribe();\n }\n\n private subscribe() {\n this.events.subscribe((event) => {\n const { type, payload } = event;\n if (this.callbacks[type]) {\n this.callbacks[type]!.forEach(({ fn }) => fn(payload));\n }\n });\n }\n\n private addCallback(event: PlatformAppEvent, fn: (payload: any) => void) {\n if (!this.callbacks[event]) {\n this.callbacks[event] = [];\n }\n\n const id = `${performance.now()}`;\n\n this.callbacks[event]!.push({\n id,\n fn,\n });\n\n return () => {\n this.callbacks[event] = this.callbacks[event]!.filter(\n (cb) => cb.id !== id,\n );\n };\n }\n\n /**\n * NOTE: currently, we return function to unsubscribe from the event,\n * probably it is better to return `this` to allow chaining\n * and provide another way to unsubscribe from events.\n */\n public onEditorReady(\n fn: (payload: IPlatformEditorReadyEvent['payload']) => void,\n ) {\n return this.addCallback(PlatformAppEvent.EditorReady, fn);\n }\n}\n","import {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\n\nexport enum EditorPlatformApplicationErrorCode {\n ApplicationRuntimeError = 'ApplicationRuntimeError',\n}\n\nclass EditorPlatformApplicationError extends BaseError<EditorPlatformApplicationErrorCode> {\n state: Partial<{\n url: string;\n appDefinitionId: string;\n apiMethod: string;\n apiType: string;\n }> = {};\n\n constructor(message: string, code: EditorPlatformApplicationErrorCode) {\n super(message, code, 'EP Application Error');\n }\n\n withUrl(url: string) {\n this.state = { ...this.state, url };\n return this;\n }\n\n withAppDefinitionId(appDefinitionId: string) {\n this.state = { ...this.state, appDefinitionId };\n return this;\n }\n\n withApiMethod(apiMethod: string) {\n this.state = { ...this.state, apiMethod };\n return this;\n }\n\n withApiType(apiType: string) {\n this.state = { ...this.state, apiType };\n return this;\n }\n}\n\nexport const createEditorPlatformApplicationError = createErrorBuilder<\n EditorPlatformApplicationErrorCode,\n EditorPlatformApplicationError\n>(EditorPlatformApplicationError);\n","import { PlatformAppEvent } from '@wix/public-editor-platform-events';\nimport {\n ApplicationContext,\n IApplicationContext,\n} from '@wix/editor-platform-contexts';\nimport { EventType } from '@wix/public-editor-platform-interfaces';\nimport { ApplicationLifecycle } from '../ApplicationLifecycle';\nimport {\n createEditorPlatformApplicationError,\n EditorPlatformApplicationErrorCode,\n} from '../errors';\nimport { ApplicationType } from '../types';\n\n/**\n * TODO: duplicated type to get rid of extra dependency\n */\nexport type IApplicationRegistry = (\n instance: EditorPlatformApplication,\n) => void;\n\ndeclare global {\n // eslint-disable-next-line no-var\n var __APPLICATION_REGISTRY_KEY: IApplicationRegistry;\n}\n\nexport interface IApplicationAPI<TPublicAPI, TPrivateAPI> {\n public?: TPublicAPI;\n private?: TPrivateAPI;\n}\n\nclass ChainAPIConfiguration<TPublicAPI, TPrivateAPI> {\n constructor(private api: IApplicationAPI<TPublicAPI, TPrivateAPI>) {}\n\n exposePublicAPI(api: TPublicAPI) {\n this.api.public = api;\n return this;\n }\n\n exposePrivateAPI(api: TPrivateAPI) {\n this.api.private = api;\n return this;\n }\n}\n\n/**\n * TODO: should accept generic type\n */\nexport abstract class EditorPlatformApplication<\n TContext extends IApplicationContext = IApplicationContext,\n TPublicAPI = unknown,\n TPrivateAPI = unknown,\n> {\n public appDefinitionId: string;\n public state: 'READY' | 'REMOVED' = 'READY';\n\n public lifecycle: ApplicationLifecycle;\n\n #applicationAPI: IApplicationAPI<TPublicAPI, TPrivateAPI> = {};\n #chainAPIConfiguration = new ChainAPIConfiguration<TPublicAPI, TPrivateAPI>(\n this.#applicationAPI,\n );\n\n #manifest: any;\n #context: ApplicationContext<TContext>;\n\n protected constructor(\n public readonly type: ApplicationType,\n context: ApplicationContext<TContext>,\n ) {\n this.#context = context;\n const bindings = this.#context.getBindings();\n\n this.appDefinitionId = bindings.appDefinitionId;\n\n const events = this.#context.getEvents();\n this.lifecycle = new ApplicationLifecycle(events);\n\n /**\n * TODO: application should not listen such event, we should manage its state outside\n */\n events.addEventListener(EventType.removeAppCompleted, (e) => {\n if (e.appDefinitionId === this.appDefinitionId) {\n this.state = 'REMOVED';\n }\n });\n\n // This line is used to get the application registry from the function scope\n // that is creating dynamically by using the `new Function` constructor\n // e.g. new Function('__APPLICATION_REGISTRY_KEY', '// our app code')\n const applicationRegister = __APPLICATION_REGISTRY_KEY;\n applicationRegister(this);\n\n events.notify({\n type: PlatformAppEvent.ApplicationInit,\n payload: {},\n });\n }\n\n protected get context() {\n return this.#context;\n }\n public get events() {\n return this.#context.getEvents();\n }\n\n public setManifest(manifest: any) {\n this.#manifest = manifest;\n }\n\n public getManifest() {\n return this.#manifest;\n }\n\n public exposePublicAPI(api: TPublicAPI) {\n return this.#chainAPIConfiguration.exposePublicAPI(api);\n }\n\n public exposePrivateAPI(api: TPrivateAPI) {\n return this.#chainAPIConfiguration.exposePrivateAPI(api);\n }\n\n public getPublicAPI() {\n return this.#applicationAPI.public;\n }\n\n public getPrivateAPI() {\n return this.#applicationAPI.private;\n }\n\n public ready() {}\n\n buildApplicationError(message: string) {\n return createEditorPlatformApplicationError(\n EditorPlatformApplicationErrorCode.ApplicationRuntimeError,\n message,\n ).withAppDefinitionId(this.appDefinitionId);\n }\n}\n","export enum ApplicationType {\n EditorAddon = 'EDITOR_ADDON',\n Platform = 'PLATFORM',\n}\n","import {\n ApplicationContext,\n IEditorApplicationContext,\n} from '@wix/editor-platform-contexts';\n\nimport { EditorPlatformApplication } from './EditorPlatformApplication';\nimport { ApplicationType } from '../types';\n\nexport class WixEditorPlatformApplication<\n TPublicAPI = unknown,\n TPrivateAPI = unknown,\n> extends EditorPlatformApplication<\n IEditorApplicationContext,\n TPublicAPI,\n TPrivateAPI\n> {\n static async create<TPublicAPI = unknown, TPrivateAPI = unknown>() {\n return new WixEditorPlatformApplication<TPublicAPI, TPrivateAPI>(\n await ApplicationContext.getInstance(),\n );\n }\n\n constructor(context: ApplicationContext<IEditorApplicationContext>) {\n super(ApplicationType.Platform, context);\n }\n}\n","import {\n ApplicationContext,\n IAddonContext,\n} from '@wix/editor-platform-contexts';\n\nimport { EditorPlatformApplication } from './EditorPlatformApplication';\nimport { ApplicationType } from '../types';\n\nexport class WixEditorPlatformAddon<\n TPublicAPI = unknown,\n TPrivateAPI = unknown,\n> extends EditorPlatformApplication<IAddonContext, TPublicAPI, TPrivateAPI> {\n static async create<TPublicAPI = unknown, TPrivateAPI = unknown>(): Promise<\n WixEditorPlatformAddon<TPublicAPI, TPrivateAPI>\n > {\n const context = await ApplicationContext.getInstance<IAddonContext>();\n\n return new WixEditorPlatformAddon<TPublicAPI, TPrivateAPI>(context);\n }\n\n constructor(context: ApplicationContext<IAddonContext>) {\n super(ApplicationType.EditorAddon, context);\n }\n}\n"],"names":["PlatformAppEvent","EditorPlatformApplicationErrorCode","BaseError","createErrorBuilder","EventType","ApplicationType","ApplicationContext"],"mappings":";;;;;;;AAMO,MAAM,oBAAqB,CAAA;AAAA,EAWhC,YAAoB,MAAgC,EAAA;AAAhC,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA,CAAA;AAClB,IAAA,IAA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AA,iBAAA,aAAc,CAAA,GAAA,cAAA,CAAA;AACd,EAAAA,iBAAA,UAAW,CAAA,GAAA,UAAA,CAAA;AAFD,EAAAA,OAAAA,gBAAAA,CAAAA;AAAA,CAAA,EAAA,eAAA,IAAA,EAAA;;ACQL,MAAM,qCAGH,yBAIR,CAAA;AAAA,EACA,aAAa,MAAsD,GAAA;AACjE,IAAA,OAAO,IAAI,4BAAA;AAAA,MACT,MAAMC,0CAAmB,WAAY,EAAA;AAAA,KACvC,CAAA;AAAA,GACF;AAAA,EAEA,YAAY,OAAwD,EAAA;AAClE,IAAM,KAAA,CAAA,eAAA,CAAgB,UAAU,OAAO,CAAA,CAAA;AAAA,GACzC;AACF;;ACjBO,MAAM,+BAGH,yBAAkE,CAAA;AAAA,EAC1E,aAAa,MAEX,GAAA;AACA,IAAM,MAAA,OAAA,GAAU,MAAMA,yCAAA,CAAmB,WAA2B,EAAA,CAAA;AAEpE,IAAO,OAAA,IAAI,uBAAgD,OAAO,CAAA,CAAA;AAAA,GACpE;AAAA,EAEA,YAAY,OAA4C,EAAA;AACtD,IAAM,KAAA,CAAA,eAAA,CAAgB,aAAa,OAAO,CAAA,CAAA;AAAA,GAC5C;AACF;;;;;;;"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { PlatformAppEvent } from '@wix/public-editor-platform-events';
|
|
2
|
+
import { EventType } from '@wix/public-editor-platform-interfaces';
|
|
3
|
+
import { createErrorBuilder, BaseError } from '@wix/public-editor-platform-errors';
|
|
4
|
+
import { ApplicationContext } from '@wix/editor-platform-contexts';
|
|
5
|
+
|
|
6
|
+
class ApplicationLifecycle {
|
|
7
|
+
constructor(events) {
|
|
8
|
+
this.events = events;
|
|
9
|
+
this.subscribe();
|
|
10
|
+
}
|
|
11
|
+
callbacks = {};
|
|
12
|
+
subscribe() {
|
|
13
|
+
this.events.subscribe((event) => {
|
|
14
|
+
const { type, payload } = event;
|
|
15
|
+
if (this.callbacks[type]) {
|
|
16
|
+
this.callbacks[type].forEach(({ fn }) => fn(payload));
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
addCallback(event, fn) {
|
|
21
|
+
if (!this.callbacks[event]) {
|
|
22
|
+
this.callbacks[event] = [];
|
|
23
|
+
}
|
|
24
|
+
const id = `${performance.now()}`;
|
|
25
|
+
this.callbacks[event].push({
|
|
26
|
+
id,
|
|
27
|
+
fn
|
|
28
|
+
});
|
|
29
|
+
return () => {
|
|
30
|
+
this.callbacks[event] = this.callbacks[event].filter(
|
|
31
|
+
(cb) => cb.id !== id
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* NOTE: currently, we return function to unsubscribe from the event,
|
|
37
|
+
* probably it is better to return `this` to allow chaining
|
|
38
|
+
* and provide another way to unsubscribe from events.
|
|
39
|
+
*/
|
|
40
|
+
onEditorReady(fn) {
|
|
41
|
+
return this.addCallback(PlatformAppEvent.EditorReady, fn);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var EditorPlatformApplicationErrorCode = /* @__PURE__ */ ((EditorPlatformApplicationErrorCode2) => {
|
|
46
|
+
EditorPlatformApplicationErrorCode2["ApplicationRuntimeError"] = "ApplicationRuntimeError";
|
|
47
|
+
return EditorPlatformApplicationErrorCode2;
|
|
48
|
+
})(EditorPlatformApplicationErrorCode || {});
|
|
49
|
+
class EditorPlatformApplicationError extends BaseError {
|
|
50
|
+
state = {};
|
|
51
|
+
constructor(message, code) {
|
|
52
|
+
super(message, code, "EP Application Error");
|
|
53
|
+
}
|
|
54
|
+
withUrl(url) {
|
|
55
|
+
this.state = { ...this.state, url };
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
withAppDefinitionId(appDefinitionId) {
|
|
59
|
+
this.state = { ...this.state, appDefinitionId };
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
withApiMethod(apiMethod) {
|
|
63
|
+
this.state = { ...this.state, apiMethod };
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
withApiType(apiType) {
|
|
67
|
+
this.state = { ...this.state, apiType };
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const createEditorPlatformApplicationError = createErrorBuilder(EditorPlatformApplicationError);
|
|
72
|
+
|
|
73
|
+
class ChainAPIConfiguration {
|
|
74
|
+
constructor(api) {
|
|
75
|
+
this.api = api;
|
|
76
|
+
}
|
|
77
|
+
exposePublicAPI(api) {
|
|
78
|
+
this.api.public = api;
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
exposePrivateAPI(api) {
|
|
82
|
+
this.api.private = api;
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
class EditorPlatformApplication {
|
|
87
|
+
constructor(type, context) {
|
|
88
|
+
this.type = type;
|
|
89
|
+
this.#context = context;
|
|
90
|
+
const bindings = this.#context.getBindings();
|
|
91
|
+
this.appDefinitionId = bindings.appDefinitionId;
|
|
92
|
+
const events = this.#context.getEvents();
|
|
93
|
+
this.lifecycle = new ApplicationLifecycle(events);
|
|
94
|
+
events.addEventListener(EventType.removeAppCompleted, (e) => {
|
|
95
|
+
if (e.appDefinitionId === this.appDefinitionId) {
|
|
96
|
+
this.state = "REMOVED";
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
const applicationRegister = __APPLICATION_REGISTRY_KEY;
|
|
100
|
+
applicationRegister(this);
|
|
101
|
+
events.notify({
|
|
102
|
+
type: PlatformAppEvent.ApplicationInit,
|
|
103
|
+
payload: {}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
appDefinitionId;
|
|
107
|
+
state = "READY";
|
|
108
|
+
lifecycle;
|
|
109
|
+
#applicationAPI = {};
|
|
110
|
+
#chainAPIConfiguration = new ChainAPIConfiguration(
|
|
111
|
+
this.#applicationAPI
|
|
112
|
+
);
|
|
113
|
+
#manifest;
|
|
114
|
+
#context;
|
|
115
|
+
get context() {
|
|
116
|
+
return this.#context;
|
|
117
|
+
}
|
|
118
|
+
get events() {
|
|
119
|
+
return this.#context.getEvents();
|
|
120
|
+
}
|
|
121
|
+
setManifest(manifest) {
|
|
122
|
+
this.#manifest = manifest;
|
|
123
|
+
}
|
|
124
|
+
getManifest() {
|
|
125
|
+
return this.#manifest;
|
|
126
|
+
}
|
|
127
|
+
exposePublicAPI(api) {
|
|
128
|
+
return this.#chainAPIConfiguration.exposePublicAPI(api);
|
|
129
|
+
}
|
|
130
|
+
exposePrivateAPI(api) {
|
|
131
|
+
return this.#chainAPIConfiguration.exposePrivateAPI(api);
|
|
132
|
+
}
|
|
133
|
+
getPublicAPI() {
|
|
134
|
+
return this.#applicationAPI.public;
|
|
135
|
+
}
|
|
136
|
+
getPrivateAPI() {
|
|
137
|
+
return this.#applicationAPI.private;
|
|
138
|
+
}
|
|
139
|
+
ready() {
|
|
140
|
+
}
|
|
141
|
+
buildApplicationError(message) {
|
|
142
|
+
return createEditorPlatformApplicationError(
|
|
143
|
+
EditorPlatformApplicationErrorCode.ApplicationRuntimeError,
|
|
144
|
+
message
|
|
145
|
+
).withAppDefinitionId(this.appDefinitionId);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
var ApplicationType = /* @__PURE__ */ ((ApplicationType2) => {
|
|
150
|
+
ApplicationType2["EditorAddon"] = "EDITOR_ADDON";
|
|
151
|
+
ApplicationType2["Platform"] = "PLATFORM";
|
|
152
|
+
return ApplicationType2;
|
|
153
|
+
})(ApplicationType || {});
|
|
154
|
+
|
|
155
|
+
class WixEditorPlatformApplication extends EditorPlatformApplication {
|
|
156
|
+
static async create() {
|
|
157
|
+
return new WixEditorPlatformApplication(
|
|
158
|
+
await ApplicationContext.getInstance()
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
constructor(context) {
|
|
162
|
+
super(ApplicationType.Platform, context);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
class WixEditorPlatformAddon extends EditorPlatformApplication {
|
|
167
|
+
static async create() {
|
|
168
|
+
const context = await ApplicationContext.getInstance();
|
|
169
|
+
return new WixEditorPlatformAddon(context);
|
|
170
|
+
}
|
|
171
|
+
constructor(context) {
|
|
172
|
+
super(ApplicationType.EditorAddon, context);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export { ApplicationType, EditorPlatformApplication, WixEditorPlatformAddon, WixEditorPlatformApplication };
|
|
177
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/ApplicationLifecycle/ApplicationLifecycle.ts","../../src/errors.ts","../../src/EditorPlatformApplication/EditorPlatformApplication.ts","../../src/types.ts","../../src/EditorPlatformApplication/WixEditorPlatformApplication.ts","../../src/EditorPlatformApplication/WixEditorPlatformAddon.ts"],"sourcesContent":["import {\n PlatformAppEvent,\n IPlatformEditorReadyEvent,\n} from '@wix/public-editor-platform-events';\nimport type { ApplicationBoundEvents } from '@wix/editor-platform-contexts';\n\nexport class ApplicationLifecycle {\n private callbacks: Partial<\n Record<\n PlatformAppEvent,\n {\n id: string;\n fn: (payload: any) => void;\n }[]\n >\n > = {};\n\n constructor(private events: ApplicationBoundEvents) {\n this.subscribe();\n }\n\n private subscribe() {\n this.events.subscribe((event) => {\n const { type, payload } = event;\n if (this.callbacks[type]) {\n this.callbacks[type]!.forEach(({ fn }) => fn(payload));\n }\n });\n }\n\n private addCallback(event: PlatformAppEvent, fn: (payload: any) => void) {\n if (!this.callbacks[event]) {\n this.callbacks[event] = [];\n }\n\n const id = `${performance.now()}`;\n\n this.callbacks[event]!.push({\n id,\n fn,\n });\n\n return () => {\n this.callbacks[event] = this.callbacks[event]!.filter(\n (cb) => cb.id !== id,\n );\n };\n }\n\n /**\n * NOTE: currently, we return function to unsubscribe from the event,\n * probably it is better to return `this` to allow chaining\n * and provide another way to unsubscribe from events.\n */\n public onEditorReady(\n fn: (payload: IPlatformEditorReadyEvent['payload']) => void,\n ) {\n return this.addCallback(PlatformAppEvent.EditorReady, fn);\n }\n}\n","import {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\n\nexport enum EditorPlatformApplicationErrorCode {\n ApplicationRuntimeError = 'ApplicationRuntimeError',\n}\n\nclass EditorPlatformApplicationError extends BaseError<EditorPlatformApplicationErrorCode> {\n state: Partial<{\n url: string;\n appDefinitionId: string;\n apiMethod: string;\n apiType: string;\n }> = {};\n\n constructor(message: string, code: EditorPlatformApplicationErrorCode) {\n super(message, code, 'EP Application Error');\n }\n\n withUrl(url: string) {\n this.state = { ...this.state, url };\n return this;\n }\n\n withAppDefinitionId(appDefinitionId: string) {\n this.state = { ...this.state, appDefinitionId };\n return this;\n }\n\n withApiMethod(apiMethod: string) {\n this.state = { ...this.state, apiMethod };\n return this;\n }\n\n withApiType(apiType: string) {\n this.state = { ...this.state, apiType };\n return this;\n }\n}\n\nexport const createEditorPlatformApplicationError = createErrorBuilder<\n EditorPlatformApplicationErrorCode,\n EditorPlatformApplicationError\n>(EditorPlatformApplicationError);\n","import { PlatformAppEvent } from '@wix/public-editor-platform-events';\nimport {\n ApplicationContext,\n IApplicationContext,\n} from '@wix/editor-platform-contexts';\nimport { EventType } from '@wix/public-editor-platform-interfaces';\nimport { ApplicationLifecycle } from '../ApplicationLifecycle';\nimport {\n createEditorPlatformApplicationError,\n EditorPlatformApplicationErrorCode,\n} from '../errors';\nimport { ApplicationType } from '../types';\n\n/**\n * TODO: duplicated type to get rid of extra dependency\n */\nexport type IApplicationRegistry = (\n instance: EditorPlatformApplication,\n) => void;\n\ndeclare global {\n // eslint-disable-next-line no-var\n var __APPLICATION_REGISTRY_KEY: IApplicationRegistry;\n}\n\nexport interface IApplicationAPI<TPublicAPI, TPrivateAPI> {\n public?: TPublicAPI;\n private?: TPrivateAPI;\n}\n\nclass ChainAPIConfiguration<TPublicAPI, TPrivateAPI> {\n constructor(private api: IApplicationAPI<TPublicAPI, TPrivateAPI>) {}\n\n exposePublicAPI(api: TPublicAPI) {\n this.api.public = api;\n return this;\n }\n\n exposePrivateAPI(api: TPrivateAPI) {\n this.api.private = api;\n return this;\n }\n}\n\n/**\n * TODO: should accept generic type\n */\nexport abstract class EditorPlatformApplication<\n TContext extends IApplicationContext = IApplicationContext,\n TPublicAPI = unknown,\n TPrivateAPI = unknown,\n> {\n public appDefinitionId: string;\n public state: 'READY' | 'REMOVED' = 'READY';\n\n public lifecycle: ApplicationLifecycle;\n\n #applicationAPI: IApplicationAPI<TPublicAPI, TPrivateAPI> = {};\n #chainAPIConfiguration = new ChainAPIConfiguration<TPublicAPI, TPrivateAPI>(\n this.#applicationAPI,\n );\n\n #manifest: any;\n #context: ApplicationContext<TContext>;\n\n protected constructor(\n public readonly type: ApplicationType,\n context: ApplicationContext<TContext>,\n ) {\n this.#context = context;\n const bindings = this.#context.getBindings();\n\n this.appDefinitionId = bindings.appDefinitionId;\n\n const events = this.#context.getEvents();\n this.lifecycle = new ApplicationLifecycle(events);\n\n /**\n * TODO: application should not listen such event, we should manage its state outside\n */\n events.addEventListener(EventType.removeAppCompleted, (e) => {\n if (e.appDefinitionId === this.appDefinitionId) {\n this.state = 'REMOVED';\n }\n });\n\n // This line is used to get the application registry from the function scope\n // that is creating dynamically by using the `new Function` constructor\n // e.g. new Function('__APPLICATION_REGISTRY_KEY', '// our app code')\n const applicationRegister = __APPLICATION_REGISTRY_KEY;\n applicationRegister(this);\n\n events.notify({\n type: PlatformAppEvent.ApplicationInit,\n payload: {},\n });\n }\n\n protected get context() {\n return this.#context;\n }\n public get events() {\n return this.#context.getEvents();\n }\n\n public setManifest(manifest: any) {\n this.#manifest = manifest;\n }\n\n public getManifest() {\n return this.#manifest;\n }\n\n public exposePublicAPI(api: TPublicAPI) {\n return this.#chainAPIConfiguration.exposePublicAPI(api);\n }\n\n public exposePrivateAPI(api: TPrivateAPI) {\n return this.#chainAPIConfiguration.exposePrivateAPI(api);\n }\n\n public getPublicAPI() {\n return this.#applicationAPI.public;\n }\n\n public getPrivateAPI() {\n return this.#applicationAPI.private;\n }\n\n public ready() {}\n\n buildApplicationError(message: string) {\n return createEditorPlatformApplicationError(\n EditorPlatformApplicationErrorCode.ApplicationRuntimeError,\n message,\n ).withAppDefinitionId(this.appDefinitionId);\n }\n}\n","export enum ApplicationType {\n EditorAddon = 'EDITOR_ADDON',\n Platform = 'PLATFORM',\n}\n","import {\n ApplicationContext,\n IEditorApplicationContext,\n} from '@wix/editor-platform-contexts';\n\nimport { EditorPlatformApplication } from './EditorPlatformApplication';\nimport { ApplicationType } from '../types';\n\nexport class WixEditorPlatformApplication<\n TPublicAPI = unknown,\n TPrivateAPI = unknown,\n> extends EditorPlatformApplication<\n IEditorApplicationContext,\n TPublicAPI,\n TPrivateAPI\n> {\n static async create<TPublicAPI = unknown, TPrivateAPI = unknown>() {\n return new WixEditorPlatformApplication<TPublicAPI, TPrivateAPI>(\n await ApplicationContext.getInstance(),\n );\n }\n\n constructor(context: ApplicationContext<IEditorApplicationContext>) {\n super(ApplicationType.Platform, context);\n }\n}\n","import {\n ApplicationContext,\n IAddonContext,\n} from '@wix/editor-platform-contexts';\n\nimport { EditorPlatformApplication } from './EditorPlatformApplication';\nimport { ApplicationType } from '../types';\n\nexport class WixEditorPlatformAddon<\n TPublicAPI = unknown,\n TPrivateAPI = unknown,\n> extends EditorPlatformApplication<IAddonContext, TPublicAPI, TPrivateAPI> {\n static async create<TPublicAPI = unknown, TPrivateAPI = unknown>(): Promise<\n WixEditorPlatformAddon<TPublicAPI, TPrivateAPI>\n > {\n const context = await ApplicationContext.getInstance<IAddonContext>();\n\n return new WixEditorPlatformAddon<TPublicAPI, TPrivateAPI>(context);\n }\n\n constructor(context: ApplicationContext<IAddonContext>) {\n super(ApplicationType.EditorAddon, context);\n }\n}\n"],"names":["EditorPlatformApplicationErrorCode","ApplicationType"],"mappings":";;;;;AAMO,MAAM,oBAAqB,CAAA;AAAA,EAWhC,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,CAAA;AAAA,GAC5C;AACF;;ACzIY,IAAA,eAAA,qBAAAC,gBAAL,KAAA;AACL,EAAAA,iBAAA,aAAc,CAAA,GAAA,cAAA,CAAA;AACd,EAAAA,iBAAA,UAAW,CAAA,GAAA,UAAA,CAAA;AAFD,EAAAA,OAAAA,gBAAAA,CAAAA;AAAA,CAAA,EAAA,eAAA,IAAA,EAAA;;ACQL,MAAM,qCAGH,yBAIR,CAAA;AAAA,EACA,aAAa,MAAsD,GAAA;AACjE,IAAA,OAAO,IAAI,4BAAA;AAAA,MACT,MAAM,mBAAmB,WAAY,EAAA;AAAA,KACvC,CAAA;AAAA,GACF;AAAA,EAEA,YAAY,OAAwD,EAAA;AAClE,IAAM,KAAA,CAAA,eAAA,CAAgB,UAAU,OAAO,CAAA,CAAA;AAAA,GACzC;AACF;;ACjBO,MAAM,+BAGH,yBAAkE,CAAA;AAAA,EAC1E,aAAa,MAEX,GAAA;AACA,IAAM,MAAA,OAAA,GAAU,MAAM,kBAAA,CAAmB,WAA2B,EAAA,CAAA;AAEpE,IAAO,OAAA,IAAI,uBAAgD,OAAO,CAAA,CAAA;AAAA,GACpE;AAAA,EAEA,YAAY,OAA4C,EAAA;AACtD,IAAM,KAAA,CAAA,eAAA,CAAgB,aAAa,OAAO,CAAA,CAAA;AAAA,GAC5C;AACF;;;;"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@wix/public-editor-platform-events'), require('@wix/public-editor-platform-interfaces'), require('@wix/public-editor-platform-errors'), require('@wix/editor-platform-contexts')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@wix/public-editor-platform-events', '@wix/public-editor-platform-interfaces', '@wix/public-editor-platform-errors', '@wix/editor-platform-contexts'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.EditorPlatformApplicationRuntime = {}, global.publicEditorPlatformEvents, global.publicEditorPlatformInterfaces, global.publicEditorPlatformErrors, global.editorPlatformContexts));
|
|
5
|
+
})(this, (function (exports, publicEditorPlatformEvents, publicEditorPlatformInterfaces, publicEditorPlatformErrors, editorPlatformContexts) { 'use strict';
|
|
6
|
+
|
|
7
|
+
class ApplicationLifecycle {
|
|
8
|
+
constructor(events) {
|
|
9
|
+
this.events = events;
|
|
10
|
+
this.subscribe();
|
|
11
|
+
}
|
|
12
|
+
callbacks = {};
|
|
13
|
+
subscribe() {
|
|
14
|
+
this.events.subscribe((event) => {
|
|
15
|
+
const { type, payload } = event;
|
|
16
|
+
if (this.callbacks[type]) {
|
|
17
|
+
this.callbacks[type].forEach(({ fn }) => fn(payload));
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
addCallback(event, fn) {
|
|
22
|
+
if (!this.callbacks[event]) {
|
|
23
|
+
this.callbacks[event] = [];
|
|
24
|
+
}
|
|
25
|
+
const id = `${performance.now()}`;
|
|
26
|
+
this.callbacks[event].push({
|
|
27
|
+
id,
|
|
28
|
+
fn
|
|
29
|
+
});
|
|
30
|
+
return () => {
|
|
31
|
+
this.callbacks[event] = this.callbacks[event].filter(
|
|
32
|
+
(cb) => cb.id !== id
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* NOTE: currently, we return function to unsubscribe from the event,
|
|
38
|
+
* probably it is better to return `this` to allow chaining
|
|
39
|
+
* and provide another way to unsubscribe from events.
|
|
40
|
+
*/
|
|
41
|
+
onEditorReady(fn) {
|
|
42
|
+
return this.addCallback(publicEditorPlatformEvents.PlatformAppEvent.EditorReady, fn);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
var EditorPlatformApplicationErrorCode = /* @__PURE__ */ ((EditorPlatformApplicationErrorCode2) => {
|
|
47
|
+
EditorPlatformApplicationErrorCode2["ApplicationRuntimeError"] = "ApplicationRuntimeError";
|
|
48
|
+
return EditorPlatformApplicationErrorCode2;
|
|
49
|
+
})(EditorPlatformApplicationErrorCode || {});
|
|
50
|
+
class EditorPlatformApplicationError extends publicEditorPlatformErrors.BaseError {
|
|
51
|
+
state = {};
|
|
52
|
+
constructor(message, code) {
|
|
53
|
+
super(message, code, "EP Application Error");
|
|
54
|
+
}
|
|
55
|
+
withUrl(url) {
|
|
56
|
+
this.state = { ...this.state, url };
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
withAppDefinitionId(appDefinitionId) {
|
|
60
|
+
this.state = { ...this.state, appDefinitionId };
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
withApiMethod(apiMethod) {
|
|
64
|
+
this.state = { ...this.state, apiMethod };
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
withApiType(apiType) {
|
|
68
|
+
this.state = { ...this.state, apiType };
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const createEditorPlatformApplicationError = publicEditorPlatformErrors.createErrorBuilder(EditorPlatformApplicationError);
|
|
73
|
+
|
|
74
|
+
class ChainAPIConfiguration {
|
|
75
|
+
constructor(api) {
|
|
76
|
+
this.api = api;
|
|
77
|
+
}
|
|
78
|
+
exposePublicAPI(api) {
|
|
79
|
+
this.api.public = api;
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
exposePrivateAPI(api) {
|
|
83
|
+
this.api.private = api;
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
class EditorPlatformApplication {
|
|
88
|
+
constructor(type, context) {
|
|
89
|
+
this.type = type;
|
|
90
|
+
this.#context = context;
|
|
91
|
+
const bindings = this.#context.getBindings();
|
|
92
|
+
this.appDefinitionId = bindings.appDefinitionId;
|
|
93
|
+
const events = this.#context.getEvents();
|
|
94
|
+
this.lifecycle = new ApplicationLifecycle(events);
|
|
95
|
+
events.addEventListener(publicEditorPlatformInterfaces.EventType.removeAppCompleted, (e) => {
|
|
96
|
+
if (e.appDefinitionId === this.appDefinitionId) {
|
|
97
|
+
this.state = "REMOVED";
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
const applicationRegister = __APPLICATION_REGISTRY_KEY;
|
|
101
|
+
applicationRegister(this);
|
|
102
|
+
events.notify({
|
|
103
|
+
type: publicEditorPlatformEvents.PlatformAppEvent.ApplicationInit,
|
|
104
|
+
payload: {}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
appDefinitionId;
|
|
108
|
+
state = "READY";
|
|
109
|
+
lifecycle;
|
|
110
|
+
#applicationAPI = {};
|
|
111
|
+
#chainAPIConfiguration = new ChainAPIConfiguration(
|
|
112
|
+
this.#applicationAPI
|
|
113
|
+
);
|
|
114
|
+
#manifest;
|
|
115
|
+
#context;
|
|
116
|
+
get context() {
|
|
117
|
+
return this.#context;
|
|
118
|
+
}
|
|
119
|
+
get events() {
|
|
120
|
+
return this.#context.getEvents();
|
|
121
|
+
}
|
|
122
|
+
setManifest(manifest) {
|
|
123
|
+
this.#manifest = manifest;
|
|
124
|
+
}
|
|
125
|
+
getManifest() {
|
|
126
|
+
return this.#manifest;
|
|
127
|
+
}
|
|
128
|
+
exposePublicAPI(api) {
|
|
129
|
+
return this.#chainAPIConfiguration.exposePublicAPI(api);
|
|
130
|
+
}
|
|
131
|
+
exposePrivateAPI(api) {
|
|
132
|
+
return this.#chainAPIConfiguration.exposePrivateAPI(api);
|
|
133
|
+
}
|
|
134
|
+
getPublicAPI() {
|
|
135
|
+
return this.#applicationAPI.public;
|
|
136
|
+
}
|
|
137
|
+
getPrivateAPI() {
|
|
138
|
+
return this.#applicationAPI.private;
|
|
139
|
+
}
|
|
140
|
+
ready() {
|
|
141
|
+
}
|
|
142
|
+
buildApplicationError(message) {
|
|
143
|
+
return createEditorPlatformApplicationError(
|
|
144
|
+
EditorPlatformApplicationErrorCode.ApplicationRuntimeError,
|
|
145
|
+
message
|
|
146
|
+
).withAppDefinitionId(this.appDefinitionId);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
var ApplicationType = /* @__PURE__ */ ((ApplicationType2) => {
|
|
151
|
+
ApplicationType2["EditorAddon"] = "EDITOR_ADDON";
|
|
152
|
+
ApplicationType2["Platform"] = "PLATFORM";
|
|
153
|
+
return ApplicationType2;
|
|
154
|
+
})(ApplicationType || {});
|
|
155
|
+
|
|
156
|
+
class WixEditorPlatformApplication extends EditorPlatformApplication {
|
|
157
|
+
static async create() {
|
|
158
|
+
return new WixEditorPlatformApplication(
|
|
159
|
+
await editorPlatformContexts.ApplicationContext.getInstance()
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
constructor(context) {
|
|
163
|
+
super(ApplicationType.Platform, context);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
class WixEditorPlatformAddon extends EditorPlatformApplication {
|
|
168
|
+
static async create() {
|
|
169
|
+
const context = await editorPlatformContexts.ApplicationContext.getInstance();
|
|
170
|
+
return new WixEditorPlatformAddon(context);
|
|
171
|
+
}
|
|
172
|
+
constructor(context) {
|
|
173
|
+
super(ApplicationType.EditorAddon, context);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
exports.ApplicationType = ApplicationType;
|
|
178
|
+
exports.EditorPlatformApplication = EditorPlatformApplication;
|
|
179
|
+
exports.WixEditorPlatformAddon = WixEditorPlatformAddon;
|
|
180
|
+
exports.WixEditorPlatformApplication = WixEditorPlatformApplication;
|
|
181
|
+
|
|
182
|
+
}));
|
|
183
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/ApplicationLifecycle/ApplicationLifecycle.ts","../../src/errors.ts","../../src/EditorPlatformApplication/EditorPlatformApplication.ts","../../src/types.ts","../../src/EditorPlatformApplication/WixEditorPlatformApplication.ts","../../src/EditorPlatformApplication/WixEditorPlatformAddon.ts"],"sourcesContent":["import {\n PlatformAppEvent,\n IPlatformEditorReadyEvent,\n} from '@wix/public-editor-platform-events';\nimport type { ApplicationBoundEvents } from '@wix/editor-platform-contexts';\n\nexport class ApplicationLifecycle {\n private callbacks: Partial<\n Record<\n PlatformAppEvent,\n {\n id: string;\n fn: (payload: any) => void;\n }[]\n >\n > = {};\n\n constructor(private events: ApplicationBoundEvents) {\n this.subscribe();\n }\n\n private subscribe() {\n this.events.subscribe((event) => {\n const { type, payload } = event;\n if (this.callbacks[type]) {\n this.callbacks[type]!.forEach(({ fn }) => fn(payload));\n }\n });\n }\n\n private addCallback(event: PlatformAppEvent, fn: (payload: any) => void) {\n if (!this.callbacks[event]) {\n this.callbacks[event] = [];\n }\n\n const id = `${performance.now()}`;\n\n this.callbacks[event]!.push({\n id,\n fn,\n });\n\n return () => {\n this.callbacks[event] = this.callbacks[event]!.filter(\n (cb) => cb.id !== id,\n );\n };\n }\n\n /**\n * NOTE: currently, we return function to unsubscribe from the event,\n * probably it is better to return `this` to allow chaining\n * and provide another way to unsubscribe from events.\n */\n public onEditorReady(\n fn: (payload: IPlatformEditorReadyEvent['payload']) => void,\n ) {\n return this.addCallback(PlatformAppEvent.EditorReady, fn);\n }\n}\n","import {\n BaseError,\n createErrorBuilder,\n} from '@wix/public-editor-platform-errors';\n\nexport enum EditorPlatformApplicationErrorCode {\n ApplicationRuntimeError = 'ApplicationRuntimeError',\n}\n\nclass EditorPlatformApplicationError extends BaseError<EditorPlatformApplicationErrorCode> {\n state: Partial<{\n url: string;\n appDefinitionId: string;\n apiMethod: string;\n apiType: string;\n }> = {};\n\n constructor(message: string, code: EditorPlatformApplicationErrorCode) {\n super(message, code, 'EP Application Error');\n }\n\n withUrl(url: string) {\n this.state = { ...this.state, url };\n return this;\n }\n\n withAppDefinitionId(appDefinitionId: string) {\n this.state = { ...this.state, appDefinitionId };\n return this;\n }\n\n withApiMethod(apiMethod: string) {\n this.state = { ...this.state, apiMethod };\n return this;\n }\n\n withApiType(apiType: string) {\n this.state = { ...this.state, apiType };\n return this;\n }\n}\n\nexport const createEditorPlatformApplicationError = createErrorBuilder<\n EditorPlatformApplicationErrorCode,\n EditorPlatformApplicationError\n>(EditorPlatformApplicationError);\n","import { PlatformAppEvent } from '@wix/public-editor-platform-events';\nimport {\n ApplicationContext,\n IApplicationContext,\n} from '@wix/editor-platform-contexts';\nimport { EventType } from '@wix/public-editor-platform-interfaces';\nimport { ApplicationLifecycle } from '../ApplicationLifecycle';\nimport {\n createEditorPlatformApplicationError,\n EditorPlatformApplicationErrorCode,\n} from '../errors';\nimport { ApplicationType } from '../types';\n\n/**\n * TODO: duplicated type to get rid of extra dependency\n */\nexport type IApplicationRegistry = (\n instance: EditorPlatformApplication,\n) => void;\n\ndeclare global {\n // eslint-disable-next-line no-var\n var __APPLICATION_REGISTRY_KEY: IApplicationRegistry;\n}\n\nexport interface IApplicationAPI<TPublicAPI, TPrivateAPI> {\n public?: TPublicAPI;\n private?: TPrivateAPI;\n}\n\nclass ChainAPIConfiguration<TPublicAPI, TPrivateAPI> {\n constructor(private api: IApplicationAPI<TPublicAPI, TPrivateAPI>) {}\n\n exposePublicAPI(api: TPublicAPI) {\n this.api.public = api;\n return this;\n }\n\n exposePrivateAPI(api: TPrivateAPI) {\n this.api.private = api;\n return this;\n }\n}\n\n/**\n * TODO: should accept generic type\n */\nexport abstract class EditorPlatformApplication<\n TContext extends IApplicationContext = IApplicationContext,\n TPublicAPI = unknown,\n TPrivateAPI = unknown,\n> {\n public appDefinitionId: string;\n public state: 'READY' | 'REMOVED' = 'READY';\n\n public lifecycle: ApplicationLifecycle;\n\n #applicationAPI: IApplicationAPI<TPublicAPI, TPrivateAPI> = {};\n #chainAPIConfiguration = new ChainAPIConfiguration<TPublicAPI, TPrivateAPI>(\n this.#applicationAPI,\n );\n\n #manifest: any;\n #context: ApplicationContext<TContext>;\n\n protected constructor(\n public readonly type: ApplicationType,\n context: ApplicationContext<TContext>,\n ) {\n this.#context = context;\n const bindings = this.#context.getBindings();\n\n this.appDefinitionId = bindings.appDefinitionId;\n\n const events = this.#context.getEvents();\n this.lifecycle = new ApplicationLifecycle(events);\n\n /**\n * TODO: application should not listen such event, we should manage its state outside\n */\n events.addEventListener(EventType.removeAppCompleted, (e) => {\n if (e.appDefinitionId === this.appDefinitionId) {\n this.state = 'REMOVED';\n }\n });\n\n // This line is used to get the application registry from the function scope\n // that is creating dynamically by using the `new Function` constructor\n // e.g. new Function('__APPLICATION_REGISTRY_KEY', '// our app code')\n const applicationRegister = __APPLICATION_REGISTRY_KEY;\n applicationRegister(this);\n\n events.notify({\n type: PlatformAppEvent.ApplicationInit,\n payload: {},\n });\n }\n\n protected get context() {\n return this.#context;\n }\n public get events() {\n return this.#context.getEvents();\n }\n\n public setManifest(manifest: any) {\n this.#manifest = manifest;\n }\n\n public getManifest() {\n return this.#manifest;\n }\n\n public exposePublicAPI(api: TPublicAPI) {\n return this.#chainAPIConfiguration.exposePublicAPI(api);\n }\n\n public exposePrivateAPI(api: TPrivateAPI) {\n return this.#chainAPIConfiguration.exposePrivateAPI(api);\n }\n\n public getPublicAPI() {\n return this.#applicationAPI.public;\n }\n\n public getPrivateAPI() {\n return this.#applicationAPI.private;\n }\n\n public ready() {}\n\n buildApplicationError(message: string) {\n return createEditorPlatformApplicationError(\n EditorPlatformApplicationErrorCode.ApplicationRuntimeError,\n message,\n ).withAppDefinitionId(this.appDefinitionId);\n }\n}\n","export enum ApplicationType {\n EditorAddon = 'EDITOR_ADDON',\n Platform = 'PLATFORM',\n}\n","import {\n ApplicationContext,\n IEditorApplicationContext,\n} from '@wix/editor-platform-contexts';\n\nimport { EditorPlatformApplication } from './EditorPlatformApplication';\nimport { ApplicationType } from '../types';\n\nexport class WixEditorPlatformApplication<\n TPublicAPI = unknown,\n TPrivateAPI = unknown,\n> extends EditorPlatformApplication<\n IEditorApplicationContext,\n TPublicAPI,\n TPrivateAPI\n> {\n static async create<TPublicAPI = unknown, TPrivateAPI = unknown>() {\n return new WixEditorPlatformApplication<TPublicAPI, TPrivateAPI>(\n await ApplicationContext.getInstance(),\n );\n }\n\n constructor(context: ApplicationContext<IEditorApplicationContext>) {\n super(ApplicationType.Platform, context);\n }\n}\n","import {\n ApplicationContext,\n IAddonContext,\n} from '@wix/editor-platform-contexts';\n\nimport { EditorPlatformApplication } from './EditorPlatformApplication';\nimport { ApplicationType } from '../types';\n\nexport class WixEditorPlatformAddon<\n TPublicAPI = unknown,\n TPrivateAPI = unknown,\n> extends EditorPlatformApplication<IAddonContext, TPublicAPI, TPrivateAPI> {\n static async create<TPublicAPI = unknown, TPrivateAPI = unknown>(): Promise<\n WixEditorPlatformAddon<TPublicAPI, TPrivateAPI>\n > {\n const context = await ApplicationContext.getInstance<IAddonContext>();\n\n return new WixEditorPlatformAddon<TPublicAPI, TPrivateAPI>(context);\n }\n\n constructor(context: ApplicationContext<IAddonContext>) {\n super(ApplicationType.EditorAddon, context);\n }\n}\n"],"names":["PlatformAppEvent","EditorPlatformApplicationErrorCode","BaseError","createErrorBuilder","EventType","ApplicationType","ApplicationContext"],"mappings":";;;;;;EAMO,MAAM,oBAAqB,CAAA;EAAA,EAWhC,YAAoB,MAAgC,EAAA;EAAhC,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA,CAAA;EAClB,IAAA,IAAA,CAAK,SAAU,EAAA,CAAA;EAAA,GACjB;EAAA,EAZQ,YAQJ,EAAC,CAAA;EAAA,EAMG,SAAY,GAAA;EAClB,IAAK,IAAA,CAAA,MAAA,CAAO,SAAU,CAAA,CAAC,KAAU,KAAA;EAC/B,MAAM,MAAA,EAAE,IAAM,EAAA,OAAA,EAAY,GAAA,KAAA,CAAA;EAC1B,MAAI,IAAA,IAAA,CAAK,SAAU,CAAA,IAAI,CAAG,EAAA;EACxB,QAAK,IAAA,CAAA,SAAA,CAAU,IAAI,CAAA,CAAG,OAAQ,CAAA,CAAC,EAAE,EAAG,EAAA,KAAM,EAAG,CAAA,OAAO,CAAC,CAAA,CAAA;EAAA,OACvD;EAAA,KACD,CAAA,CA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,yBAAkE,CAAA;EAAA,EAC1E,aAAa,MAEX,GAAA;EACA,IAAM,MAAA,OAAA,GAAU,MAAMA,yCAAA,CAAmB,WAA2B,EAAA,CAAA;EAEpE,IAAO,OAAA,IAAI,uBAAgD,OAAO,CAAA,CAAA;EAAA,GACpE;EAAA,EAEA,YAAY,OAA4C,EAAA;EACtD,IAAM,KAAA,CAAA,eAAA,CAAgB,aAAa,OAAO,CAAA,CAAA;EAAA,GAC5C;EACF;;;;;;;;;;;"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import * as _wix_public_editor_platform_errors from '@wix/public-editor-platform-errors';
|
|
2
|
+
import * as _wix_editor_platform_contexts from '@wix/editor-platform-contexts';
|
|
3
|
+
import { ApplicationBoundEvents, IApplicationContext, ApplicationContext, IEditorApplicationContext, IAddonContext } from '@wix/editor-platform-contexts';
|
|
4
|
+
import { IPlatformEditorReadyEvent } from '@wix/public-editor-platform-events';
|
|
5
|
+
|
|
6
|
+
declare class ApplicationLifecycle {
|
|
7
|
+
private events;
|
|
8
|
+
private callbacks;
|
|
9
|
+
constructor(events: ApplicationBoundEvents);
|
|
10
|
+
private subscribe;
|
|
11
|
+
private addCallback;
|
|
12
|
+
/**
|
|
13
|
+
* NOTE: currently, we return function to unsubscribe from the event,
|
|
14
|
+
* probably it is better to return `this` to allow chaining
|
|
15
|
+
* and provide another way to unsubscribe from events.
|
|
16
|
+
*/
|
|
17
|
+
onEditorReady(fn: (payload: IPlatformEditorReadyEvent['payload']) => void): () => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare enum EditorPlatformApplicationErrorCode {
|
|
21
|
+
ApplicationRuntimeError = "ApplicationRuntimeError"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare enum ApplicationType {
|
|
25
|
+
EditorAddon = "EDITOR_ADDON",
|
|
26
|
+
Platform = "PLATFORM"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* TODO: duplicated type to get rid of extra dependency
|
|
31
|
+
*/
|
|
32
|
+
type IApplicationRegistry = (instance: EditorPlatformApplication) => void;
|
|
33
|
+
declare global {
|
|
34
|
+
var __APPLICATION_REGISTRY_KEY: IApplicationRegistry;
|
|
35
|
+
}
|
|
36
|
+
interface IApplicationAPI<TPublicAPI, TPrivateAPI> {
|
|
37
|
+
public?: TPublicAPI;
|
|
38
|
+
private?: TPrivateAPI;
|
|
39
|
+
}
|
|
40
|
+
declare class ChainAPIConfiguration<TPublicAPI, TPrivateAPI> {
|
|
41
|
+
private api;
|
|
42
|
+
constructor(api: IApplicationAPI<TPublicAPI, TPrivateAPI>);
|
|
43
|
+
exposePublicAPI(api: TPublicAPI): this;
|
|
44
|
+
exposePrivateAPI(api: TPrivateAPI): this;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* TODO: should accept generic type
|
|
48
|
+
*/
|
|
49
|
+
declare abstract class EditorPlatformApplication<TContext extends IApplicationContext = IApplicationContext, TPublicAPI = unknown, TPrivateAPI = unknown> {
|
|
50
|
+
#private;
|
|
51
|
+
readonly type: ApplicationType;
|
|
52
|
+
appDefinitionId: string;
|
|
53
|
+
state: 'READY' | 'REMOVED';
|
|
54
|
+
lifecycle: ApplicationLifecycle;
|
|
55
|
+
protected constructor(type: ApplicationType, context: ApplicationContext<TContext>);
|
|
56
|
+
protected get context(): ApplicationContext<TContext>;
|
|
57
|
+
get events(): _wix_editor_platform_contexts.ApplicationBoundEvents;
|
|
58
|
+
setManifest(manifest: any): void;
|
|
59
|
+
getManifest(): any;
|
|
60
|
+
exposePublicAPI(api: TPublicAPI): ChainAPIConfiguration<TPublicAPI, TPrivateAPI>;
|
|
61
|
+
exposePrivateAPI(api: TPrivateAPI): ChainAPIConfiguration<TPublicAPI, TPrivateAPI>;
|
|
62
|
+
getPublicAPI(): TPublicAPI | undefined;
|
|
63
|
+
getPrivateAPI(): TPrivateAPI | undefined;
|
|
64
|
+
ready(): void;
|
|
65
|
+
buildApplicationError(message: string): {
|
|
66
|
+
state: Partial<{
|
|
67
|
+
url: string;
|
|
68
|
+
appDefinitionId: string;
|
|
69
|
+
apiMethod: string;
|
|
70
|
+
apiType: string;
|
|
71
|
+
}>;
|
|
72
|
+
withUrl(url: string): /*elided*/ any;
|
|
73
|
+
withAppDefinitionId(appDefinitionId: string): /*elided*/ any;
|
|
74
|
+
withApiMethod(apiMethod: string): /*elided*/ any;
|
|
75
|
+
withApiType(apiType: string): /*elided*/ any;
|
|
76
|
+
displayName: string;
|
|
77
|
+
prefix: string;
|
|
78
|
+
errorMessage: string;
|
|
79
|
+
parent: _wix_public_editor_platform_errors.BaseError<EditorPlatformApplicationErrorCode> | Error | undefined;
|
|
80
|
+
messages: string[][];
|
|
81
|
+
code: EditorPlatformApplicationErrorCode;
|
|
82
|
+
readonly parentError: _wix_public_editor_platform_errors.BaseError<any> | null;
|
|
83
|
+
getDisplayMessage(): string;
|
|
84
|
+
getMessage(): string;
|
|
85
|
+
getBreadcrumbs(): string[];
|
|
86
|
+
withParentError(e: Error | _wix_public_editor_platform_errors.BaseError<any>): /*elided*/ any;
|
|
87
|
+
withMessage(...messages: string[]): /*elided*/ any;
|
|
88
|
+
name: string;
|
|
89
|
+
message: string;
|
|
90
|
+
stack?: string;
|
|
91
|
+
cause?: unknown;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
declare class WixEditorPlatformApplication<TPublicAPI = unknown, TPrivateAPI = unknown> extends EditorPlatformApplication<IEditorApplicationContext, TPublicAPI, TPrivateAPI> {
|
|
96
|
+
static create<TPublicAPI = unknown, TPrivateAPI = unknown>(): Promise<WixEditorPlatformApplication<TPublicAPI, TPrivateAPI>>;
|
|
97
|
+
constructor(context: ApplicationContext<IEditorApplicationContext>);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
declare class WixEditorPlatformAddon<TPublicAPI = unknown, TPrivateAPI = unknown> extends EditorPlatformApplication<IAddonContext, TPublicAPI, TPrivateAPI> {
|
|
101
|
+
static create<TPublicAPI = unknown, TPrivateAPI = unknown>(): Promise<WixEditorPlatformAddon<TPublicAPI, TPrivateAPI>>;
|
|
102
|
+
constructor(context: ApplicationContext<IAddonContext>);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export { ApplicationType, EditorPlatformApplication, type IApplicationAPI, type IApplicationRegistry, WixEditorPlatformAddon, WixEditorPlatformApplication };
|
|
106
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wix/editor-application",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/cjs/index.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/types/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"start": "exit 0",
|
|
10
|
+
"build": "yarn typecheck && rollup -c",
|
|
11
|
+
"test": "exit 0",
|
|
12
|
+
"lint": "prettier --check ./src",
|
|
13
|
+
"lint:fix": "prettier --write ./src",
|
|
14
|
+
"typecheck": "tsc --noEmit"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./dist/esm/index.js",
|
|
19
|
+
"require": "./dist/cjs/index.js",
|
|
20
|
+
"types": "./dist/types/index.d.ts"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"keywords": [],
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"author": {
|
|
28
|
+
"name": "Editor Platform <editor-platform-dev@wix.com>",
|
|
29
|
+
"email": "editor-platform-dev@wix.com"
|
|
30
|
+
},
|
|
31
|
+
"license": "UNLICENSED",
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@rollup/plugin-node-resolve": "^15.3.1",
|
|
34
|
+
"esbuild": "^0.24.2",
|
|
35
|
+
"eslint": "^8.57.1",
|
|
36
|
+
"prettier": "^3.4.2",
|
|
37
|
+
"rollup": "^3.29.5",
|
|
38
|
+
"rollup-plugin-dts": "^6.1.1",
|
|
39
|
+
"rollup-plugin-esbuild": "^5.0.0",
|
|
40
|
+
"typescript": "^5.7.2"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@wix/editor-platform-contexts": "1.0.0",
|
|
44
|
+
"@wix/public-editor-platform-errors": "1.8.0",
|
|
45
|
+
"@wix/public-editor-platform-events": "1.304.0",
|
|
46
|
+
"@wix/public-editor-platform-interfaces": "1.15.0"
|
|
47
|
+
},
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"registry": "https://registry.npmjs.org/",
|
|
50
|
+
"access": "public"
|
|
51
|
+
},
|
|
52
|
+
"unpkg": true,
|
|
53
|
+
"lint-staged": {
|
|
54
|
+
"*.{js,ts}": "yarn run lint"
|
|
55
|
+
},
|
|
56
|
+
"wix": {
|
|
57
|
+
"artifact": {
|
|
58
|
+
"groupId": "com.wixpress",
|
|
59
|
+
"artifactId": "editor-platform-application",
|
|
60
|
+
"targets": {
|
|
61
|
+
"static": true
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"validations": {
|
|
65
|
+
"postDependenciesBuild": [
|
|
66
|
+
"lint"
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"falconPackageHash": "c01728cc015bd78d711153e67dc3f76460ff71f31bbcbe097decc79b"
|
|
71
|
+
}
|