@emailmaker/extensions-app 1.0.111-dev.5 → 1.0.111-dev.7
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 +33 -2
- package/externals.json +4 -20
- package/index.js +408 -55
- package/package.json +2 -2
- package/types.d.ts +103 -6
package/README.md
CHANGED
|
@@ -192,8 +192,8 @@ module.exports = {
|
|
|
192
192
|
|
|
193
193
|
Нужна только для продвинутой интеграции или собственного бандлерного пайплайна. Основной сценарий для внешнего плагина — отдельный пакет с `PluginDev`.
|
|
194
194
|
|
|
195
|
-
- `resolve.alias`: `react` → `@emailmaker/emailmaker/runtime/react` (и т.д.) для `esm` / dev; локальные shared internals идут через compat facades runtime
|
|
196
|
-
- `externals`: `@emailmaker/emailmaker/runtime/core`, runtime npm
|
|
195
|
+
- `resolve.alias`: `react` → `@emailmaker/emailmaker/runtime/react` (и т.д.) для `esm` / dev; локальные shared internals идут через compat facades runtime; UI-kit (`@emailmaker/ui-kit`) → **`@emailmaker/emailmaker/ui-kit`** (singleton bytes на main, не `runtime/@scope/ui-kit`)
|
|
196
|
+
- `externals`: `@emailmaker/emailmaker/runtime/core`, runtime npm-модули; ui-kit external → **`@emailmaker/emailmaker/ui-kit`** (глобальный ключ `UiKit` в `runtimeExports`, см. манифест)
|
|
197
197
|
- Список модулей: `@emailmaker/emailmaker/runtime/plugin-dev-manifest.json` → `runtimeModules`
|
|
198
198
|
|
|
199
199
|
Если release bundle неожиданно стал толстым или target `встраиваемый bundle` не загружается, начните с раздела `Troubleshooting`.
|
|
@@ -504,6 +504,21 @@ panel.showSettingsPanel({
|
|
|
504
504
|
});
|
|
505
505
|
```
|
|
506
506
|
|
|
507
|
+
#### `instanceKey` (идентификатор экземпляра панели)
|
|
508
|
+
|
|
509
|
+
По умолчанию **каждый** вызов `showSettingsPanel` получает новый `instanceKey`, и хост **перемонтирует** React-компонент панели. Это нужно при переключении между несколькими экземплярами одного блока в письме (две карточки товара с одним `ComponentId`).
|
|
510
|
+
|
|
511
|
+
Передайте стабильный `instanceKey` только если нужно **обновлять props без remount** и сохранять внутреннее состояние панели (скролл, фокус, черновик формы):
|
|
512
|
+
|
|
513
|
+
```ts
|
|
514
|
+
panel.showSettingsPanel({
|
|
515
|
+
instanceKey: blockUuid,
|
|
516
|
+
content: { type: 'SettingsPanelId', props: { blockUuid, settings } },
|
|
517
|
+
});
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
Не вызывайте `closeSettingsPanel` перед `showSettingsPanel` при переключении между экземплярами — достаточно одного `showSettingsPanel` с новыми `props`.
|
|
521
|
+
|
|
507
522
|
Примерная последовательность процесса взаимодействия sandbox и app:
|
|
508
523
|
1. Обработчик клика в sandbox
|
|
509
524
|
2. Отправка события в app через MessageService
|
|
@@ -725,6 +740,10 @@ settingsPanel.showSettingsPanel({
|
|
|
725
740
|
|
|
726
741
|
## 🎨 UI Kit
|
|
727
742
|
|
|
743
|
+
### ColorPicker — минимальный пример
|
|
744
|
+
|
|
745
|
+
Растягивается на ширину родителя (Form.Item, колонку и т.д.) — дополнительный inline-style для ширины не нужен.
|
|
746
|
+
|
|
728
747
|
```tsx
|
|
729
748
|
import { EmIcons, ColorPicker } from "@emailmaker/ui-kit";
|
|
730
749
|
|
|
@@ -734,6 +753,18 @@ import { EmIcons, ColorPicker } from "@emailmaker/ui-kit";
|
|
|
734
753
|
/>
|
|
735
754
|
```
|
|
736
755
|
|
|
756
|
+
### FormColorField — рекомендуется для settings panel
|
|
757
|
+
|
|
758
|
+
Микролейбл + `Form.Item` + color picker — тот же паттерн, что в панелях редактора. Используйте внутри `Form` с полем `name`.
|
|
759
|
+
|
|
760
|
+
```tsx
|
|
761
|
+
import { Form, FormColorField } from "@emailmaker/ui-kit";
|
|
762
|
+
|
|
763
|
+
<Form layout="vertical">
|
|
764
|
+
<FormColorField name="bgColor" label="Цвет фона" />
|
|
765
|
+
</Form>
|
|
766
|
+
```
|
|
767
|
+
|
|
737
768
|
|
|
738
769
|
---
|
|
739
770
|
|
package/externals.json
CHANGED
|
@@ -39,10 +39,6 @@
|
|
|
39
39
|
"promise __emailmaker__.modules",
|
|
40
40
|
"AntDesignCssinjs"
|
|
41
41
|
],
|
|
42
|
-
"@ant-design/pro-layout": [
|
|
43
|
-
"promise __emailmaker__.modules",
|
|
44
|
-
"AntDesignProLayout"
|
|
45
|
-
],
|
|
46
42
|
"classnames": [
|
|
47
43
|
"promise __emailmaker__.modules",
|
|
48
44
|
"Classnames"
|
|
@@ -55,6 +51,10 @@
|
|
|
55
51
|
"promise __emailmaker__.modules",
|
|
56
52
|
"Uuid"
|
|
57
53
|
],
|
|
54
|
+
"@emailmaker/ui-kit": [
|
|
55
|
+
"promise __emailmaker__.modules",
|
|
56
|
+
"UiKit"
|
|
57
|
+
],
|
|
58
58
|
"@emailmaker/emailmaker/runtime/core": [
|
|
59
59
|
"promise __emailmaker__.modules",
|
|
60
60
|
"Core"
|
|
@@ -78,21 +78,5 @@
|
|
|
78
78
|
"@emailmaker/emailmaker/runtime-core": [
|
|
79
79
|
"promise __emailmaker__.modules",
|
|
80
80
|
"Core"
|
|
81
|
-
],
|
|
82
|
-
"di": [
|
|
83
|
-
"promise __emailmaker__.modules",
|
|
84
|
-
"Core"
|
|
85
|
-
],
|
|
86
|
-
"disposable": [
|
|
87
|
-
"promise __emailmaker__.modules",
|
|
88
|
-
"Core"
|
|
89
|
-
],
|
|
90
|
-
"guid": [
|
|
91
|
-
"promise __emailmaker__.modules",
|
|
92
|
-
"Core"
|
|
93
|
-
],
|
|
94
|
-
"errors-runtime": [
|
|
95
|
-
"promise __emailmaker__.modules",
|
|
96
|
-
"Core"
|
|
97
81
|
]
|
|
98
82
|
}
|
package/index.js
CHANGED
|
@@ -1,23 +1,381 @@
|
|
|
1
|
-
//#region
|
|
2
|
-
var e =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
//#region packages/runtime-core/disposable/index.ts
|
|
2
|
+
var e = class e {
|
|
3
|
+
_isDisposed = !1;
|
|
4
|
+
constructor(e = []) {
|
|
5
|
+
this._inner = e;
|
|
6
|
+
}
|
|
7
|
+
addDisposable(t) {
|
|
8
|
+
return this._inner.push(t), t instanceof e && t.addDispose(() => {
|
|
9
|
+
this.removeDisposable(t);
|
|
10
|
+
}), t;
|
|
11
|
+
}
|
|
12
|
+
addDispose(e) {
|
|
13
|
+
this.addDisposable({ dispose: e });
|
|
14
|
+
}
|
|
15
|
+
removeDisposable(e) {
|
|
16
|
+
let t = this._inner.indexOf(e);
|
|
17
|
+
t >= 0 && this._inner.splice(t, 1);
|
|
18
|
+
}
|
|
19
|
+
isDisposed() {
|
|
20
|
+
return this._isDisposed;
|
|
21
|
+
}
|
|
22
|
+
dispose() {
|
|
23
|
+
if (!this._isDisposed) {
|
|
24
|
+
this._isDisposed = !0;
|
|
25
|
+
for (let e of [...this._inner]) e.dispose();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region packages/runtime-core/di/container.ts
|
|
31
|
+
function t(e) {
|
|
32
|
+
return `service_container_${e}`;
|
|
33
|
+
}
|
|
34
|
+
var n = class n extends e {
|
|
35
|
+
_injectCallbacks = [];
|
|
36
|
+
_injections = Object.create(null);
|
|
37
|
+
_runCallbacks(e) {
|
|
38
|
+
this._injectCallbacks.forEach((t) => t(e));
|
|
39
|
+
}
|
|
40
|
+
constructor(e = null) {
|
|
41
|
+
super(), this._parent = e, e && this.addDisposable(e.onInject((e) => this._runCallbacks(e)));
|
|
42
|
+
}
|
|
43
|
+
onInject = (e) => (this._injectCallbacks.push(e), { dispose: () => {
|
|
44
|
+
let t = this._injectCallbacks.indexOf(e);
|
|
45
|
+
t >= 0 && this._injectCallbacks.splice(t, 1);
|
|
46
|
+
} });
|
|
47
|
+
inject(e, t) {
|
|
48
|
+
this._injections[e] = () => t, this._runCallbacks(e);
|
|
49
|
+
}
|
|
50
|
+
injectFactory(e, t, n) {
|
|
51
|
+
let r = this._injections[e], i = typeof r == "function" ? r() : r, a = this._injections[e] = () => (i = t(this, i), i);
|
|
52
|
+
n && a(), this._runCallbacks(e);
|
|
53
|
+
}
|
|
54
|
+
_find(e, t = !0) {
|
|
55
|
+
return this._injections[e] || t && this._parent?._find(e);
|
|
56
|
+
}
|
|
57
|
+
_onInject(t, n, r = new e()) {
|
|
58
|
+
return r.addDisposable(this.onInject((e) => {
|
|
59
|
+
t === e && (r.dispose(), n(this.getInstance(e)));
|
|
60
|
+
})), this._parent && r.addDisposable(this._parent._onInject(t, n, r)), this.addDisposable(r), r;
|
|
61
|
+
}
|
|
62
|
+
getInstance(e, t = !0) {
|
|
63
|
+
let n = this._find(e, t);
|
|
64
|
+
if (typeof n == "function") return n();
|
|
65
|
+
}
|
|
66
|
+
getOrCreateInstance(e, t) {
|
|
67
|
+
let n = this._find(e);
|
|
68
|
+
if (typeof n == "function") return n();
|
|
69
|
+
let r = t(this);
|
|
70
|
+
return this.inject(e, r), r;
|
|
71
|
+
}
|
|
72
|
+
getInstanceAsync(e) {
|
|
73
|
+
let t = this._find(e);
|
|
74
|
+
return typeof t == "function" ? Promise.resolve(t()) : new Promise((t) => this._onInject(e, () => t(this.getInstance(e))));
|
|
75
|
+
}
|
|
76
|
+
addService(n, r) {
|
|
77
|
+
let i = t(n);
|
|
78
|
+
this.injectFactory(i, (e, t = []) => t.indexOf(r) < 0 ? [...t, r] : t);
|
|
79
|
+
let a = new e();
|
|
80
|
+
return a.addDispose(() => {
|
|
81
|
+
this.injectFactory(i, (e, t = []) => t.filter((e) => e !== r));
|
|
82
|
+
}), a;
|
|
83
|
+
}
|
|
84
|
+
addServiceFactory(n, r, i) {
|
|
85
|
+
let a = t(n), o;
|
|
86
|
+
this.injectFactory(a, (e, t = []) => (o = r(e, o), o === void 0 ? t : t.indexOf(o) < 0 ? [...t, o] : t), i);
|
|
87
|
+
let s = new e();
|
|
88
|
+
return s.addDispose(() => {
|
|
89
|
+
this.injectFactory(a, (e, t = []) => o === void 0 ? t : t.filter((e) => e !== o));
|
|
90
|
+
}), s;
|
|
91
|
+
}
|
|
92
|
+
getServices(e) {
|
|
93
|
+
let n = t(e);
|
|
94
|
+
return [...this.getInstance(n, !1) || [], ...this._parent?.getServices(e) || []];
|
|
95
|
+
}
|
|
96
|
+
createChild() {
|
|
97
|
+
return new n(this);
|
|
98
|
+
}
|
|
99
|
+
getOrCreateIsolatedContainer(e) {
|
|
100
|
+
return this.getOrCreateInstance(e, () => {
|
|
101
|
+
let t = this._parent?.getOrCreateIsolatedContainer(e);
|
|
102
|
+
return new n(t);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
dispose() {
|
|
106
|
+
this._injections = Object.create(null);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region packages/runtime-core/di/namespace.ts
|
|
111
|
+
function r(e) {
|
|
112
|
+
return e.startsWith("__") ? e : `__${e}__`;
|
|
113
|
+
}
|
|
114
|
+
function i(e) {
|
|
115
|
+
if (typeof globalThis > "u") throw Error("[di] globalThis is required for namespace container access.");
|
|
116
|
+
let t = r(e), n = globalThis;
|
|
117
|
+
return n[t] ??= {};
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region packages/runtime-core/di/ensureContainer.ts
|
|
121
|
+
function a(e) {
|
|
122
|
+
return typeof e == "object" && !!e && typeof e.inject == "function" && typeof e.getInstance == "function";
|
|
123
|
+
}
|
|
124
|
+
function o(e) {
|
|
125
|
+
return r(e || "emailmaker");
|
|
126
|
+
}
|
|
127
|
+
function s(e) {
|
|
128
|
+
let t = i(o(e));
|
|
129
|
+
if (a(t.container)) return t.container;
|
|
130
|
+
let r = new n(null);
|
|
131
|
+
return t.container = r, r;
|
|
132
|
+
}
|
|
133
|
+
function c(e) {
|
|
134
|
+
return s(e);
|
|
135
|
+
}
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region packages/runtime-core/guid/index.ts
|
|
138
|
+
function l() {
|
|
139
|
+
let e = (/* @__PURE__ */ new Date()).getTime(), t = typeof performance < "u" && performance.now && performance.now() * 1e3 || 0;
|
|
140
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(n) {
|
|
141
|
+
let r = Math.random() * 16;
|
|
142
|
+
return e > 0 ? (r = (e + r) % 16 | 0, e = Math.floor(e / 16)) : (r = (t + r) % 16 | 0, t = Math.floor(t / 16)), (n === "x" ? r : r & 3 | 8).toString(16);
|
|
13
143
|
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region packages/runtime-core/di/identifier.ts
|
|
147
|
+
function u(e = l()) {
|
|
148
|
+
return e;
|
|
149
|
+
}
|
|
18
150
|
//#endregion
|
|
19
|
-
//#region packages/
|
|
20
|
-
|
|
151
|
+
//#region packages/runtime-core/di/index.ts
|
|
152
|
+
function d() {
|
|
153
|
+
return "app";
|
|
154
|
+
}
|
|
155
|
+
function f(e) {
|
|
156
|
+
if (typeof globalThis > "u") return;
|
|
157
|
+
let t = d(), n = globalThis[e] ?? {};
|
|
158
|
+
globalThis[e] = n;
|
|
159
|
+
let r = n.__diagnostics ??= {}, i = r.diModuleEval ??= {
|
|
160
|
+
evalCount: 0,
|
|
161
|
+
records: [],
|
|
162
|
+
duplicateWarned: !1
|
|
163
|
+
};
|
|
164
|
+
if (i.records.push({
|
|
165
|
+
buildSource: t,
|
|
166
|
+
timestamp: Date.now(),
|
|
167
|
+
stack: (/* @__PURE__ */ Error()).stack
|
|
168
|
+
}), i.evalCount += 1, i.evalCount <= 1 || i.duplicateWarned) return;
|
|
169
|
+
i.duplicateWarned = !0;
|
|
170
|
+
let a = {
|
|
171
|
+
message: "[di] runtime-core/di evaluated more than once (duplicate bundle / duplicate graph)",
|
|
172
|
+
evalCount: i.evalCount,
|
|
173
|
+
buildSource: t,
|
|
174
|
+
records: i.records
|
|
175
|
+
};
|
|
176
|
+
typeof console < "u" && typeof console.warn == "function" && console.warn(a.message, a);
|
|
177
|
+
}
|
|
178
|
+
function p() {
|
|
179
|
+
return "__emailmaker__";
|
|
180
|
+
}
|
|
181
|
+
function m(e, t) {
|
|
182
|
+
if (f(t), typeof globalThis > "u") return e;
|
|
183
|
+
let n = d(), r = globalThis, i = r[t] = r[t] || {}, a = i.__diagnostics = i.__diagnostics || {}, o = a.dependencyResolver = a.dependencyResolver || {
|
|
184
|
+
entries: [],
|
|
185
|
+
warnings: []
|
|
186
|
+
}, s = {
|
|
187
|
+
container: e,
|
|
188
|
+
source: "packages/runtime-core/di/index.ts",
|
|
189
|
+
buildSource: n,
|
|
190
|
+
timestamp: Date.now(),
|
|
191
|
+
stack: (/* @__PURE__ */ Error()).stack
|
|
192
|
+
};
|
|
193
|
+
if (o.entries.push(s), o.entries.length > 1) {
|
|
194
|
+
let e = o.entries[0];
|
|
195
|
+
if (o.entries.some((t) => t.container !== e.container) && !o.duplicateWarningShown) {
|
|
196
|
+
o.duplicateWarningShown = !0;
|
|
197
|
+
let e = {
|
|
198
|
+
message: "[di] Multiple DependencyResolver instances detected on namespace",
|
|
199
|
+
namespaceKey: t,
|
|
200
|
+
buildSource: n,
|
|
201
|
+
entries: o.entries
|
|
202
|
+
};
|
|
203
|
+
o.warnings.push(e), typeof console < "u" && typeof console.warn == "function" && console.warn(e.message, e);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return e;
|
|
207
|
+
}
|
|
208
|
+
var h;
|
|
209
|
+
function g() {
|
|
210
|
+
if (h) return h;
|
|
211
|
+
let e = p();
|
|
212
|
+
return h = m(s(e), e), h;
|
|
213
|
+
}
|
|
214
|
+
var _ = new Proxy({}, { get(e, t, n) {
|
|
215
|
+
let r = g(), i = Reflect.get(r, t, n);
|
|
216
|
+
return typeof i == "function" ? i.bind(r) : i;
|
|
217
|
+
} }), v = class {
|
|
218
|
+
_plugins = /* @__PURE__ */ new Map();
|
|
219
|
+
_listeners = /* @__PURE__ */ new Map();
|
|
220
|
+
_getOrCreateEntry(e) {
|
|
221
|
+
let t = this._plugins.get(e);
|
|
222
|
+
return t || (t = { overrides: [] }, this._plugins.set(e, t)), t;
|
|
223
|
+
}
|
|
224
|
+
_applyOverrides(e, t) {
|
|
225
|
+
let n = this._plugins.get(e);
|
|
226
|
+
if (n?.overrides) for (let e of n.overrides) t = e(t) || t;
|
|
227
|
+
return t;
|
|
228
|
+
}
|
|
229
|
+
_notifyListeners(e, t) {
|
|
230
|
+
let n = this._listeners.get(e);
|
|
231
|
+
if (!n || n.length === 0) return;
|
|
232
|
+
for (let r of n) try {
|
|
233
|
+
r.callback(t);
|
|
234
|
+
} catch (t) {
|
|
235
|
+
console.warn(`Plugin registration listener threw an error for "${String(e)}":`, t);
|
|
236
|
+
}
|
|
237
|
+
let r = n.filter((e) => !e.once);
|
|
238
|
+
r.length > 0 ? this._listeners.set(e, r) : this._listeners.delete(e);
|
|
239
|
+
}
|
|
240
|
+
get(e) {
|
|
241
|
+
let t = this._plugins.get(e);
|
|
242
|
+
if (t?.ctor) return this._applyOverrides(e, t.ctor);
|
|
243
|
+
}
|
|
244
|
+
async getAsync(e) {
|
|
245
|
+
let t = this._plugins.get(e);
|
|
246
|
+
if (t?.ctor) return this._applyOverrides(e, t.ctor);
|
|
247
|
+
if (t?.loading) {
|
|
248
|
+
let n = await t.loading;
|
|
249
|
+
return this._applyOverrides(e, n);
|
|
250
|
+
}
|
|
251
|
+
if (t?.factory) {
|
|
252
|
+
let n = Promise.resolve(t.factory()).then((n) => (t.ctor = n, t.loading = void 0, this._notifyListeners(e, n), n));
|
|
253
|
+
t.loading = n;
|
|
254
|
+
let r = await n;
|
|
255
|
+
return this._applyOverrides(e, r);
|
|
256
|
+
}
|
|
257
|
+
return new Promise((t) => {
|
|
258
|
+
this.on(e, (n) => t(this._applyOverrides(e, n)));
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
add(e, t) {
|
|
262
|
+
let n = this._getOrCreateEntry(e);
|
|
263
|
+
n.ctor = t, this._notifyListeners(e, t);
|
|
264
|
+
}
|
|
265
|
+
addAll(e) {
|
|
266
|
+
for (let t of Object.keys(e)) {
|
|
267
|
+
let n = e[t];
|
|
268
|
+
n !== void 0 && this.add(t, n);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
addAsync(e, t) {
|
|
272
|
+
let n = this._getOrCreateEntry(e);
|
|
273
|
+
return n.factory = t, { dispose: () => {
|
|
274
|
+
n.ctor || (n.factory = void 0);
|
|
275
|
+
} };
|
|
276
|
+
}
|
|
277
|
+
has(e) {
|
|
278
|
+
let t = this._plugins.get(e);
|
|
279
|
+
return !!(t?.ctor || t?.factory);
|
|
280
|
+
}
|
|
281
|
+
isLoaded(e) {
|
|
282
|
+
return !!this._plugins.get(e)?.ctor;
|
|
283
|
+
}
|
|
284
|
+
override(e, t) {
|
|
285
|
+
let n = this._getOrCreateEntry(e);
|
|
286
|
+
return n.overrides.push(t), { dispose: () => {
|
|
287
|
+
let e = n.overrides.indexOf(t);
|
|
288
|
+
e >= 0 && n.overrides.splice(e, 1);
|
|
289
|
+
} };
|
|
290
|
+
}
|
|
291
|
+
on(e, t) {
|
|
292
|
+
let n = this.get(e);
|
|
293
|
+
n && t(n);
|
|
294
|
+
let r = this._listeners.get(e);
|
|
295
|
+
r || (r = [], this._listeners.set(e, r));
|
|
296
|
+
let i = {
|
|
297
|
+
callback: t,
|
|
298
|
+
once: !1
|
|
299
|
+
};
|
|
300
|
+
return r.push(i), { dispose: () => this._removeListener(e, t) };
|
|
301
|
+
}
|
|
302
|
+
once(e, t) {
|
|
303
|
+
let n = this.get(e);
|
|
304
|
+
if (n) return t(n), { dispose: () => {} };
|
|
305
|
+
let r = this._listeners.get(e);
|
|
306
|
+
r || (r = [], this._listeners.set(e, r));
|
|
307
|
+
let i = {
|
|
308
|
+
callback: t,
|
|
309
|
+
once: !0
|
|
310
|
+
};
|
|
311
|
+
return r.push(i), { dispose: () => this._removeListener(e, t) };
|
|
312
|
+
}
|
|
313
|
+
off(e, t) {
|
|
314
|
+
this._removeListener(e, t);
|
|
315
|
+
}
|
|
316
|
+
_removeListener(e, t) {
|
|
317
|
+
let n = this._listeners.get(e);
|
|
318
|
+
if (n) {
|
|
319
|
+
let r = n.findIndex((e) => e.callback === t);
|
|
320
|
+
r >= 0 && n.splice(r, 1), n.length === 0 && this._listeners.delete(e);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
keys() {
|
|
324
|
+
return Array.from(this._plugins.keys());
|
|
325
|
+
}
|
|
326
|
+
forContext() {
|
|
327
|
+
let e = this;
|
|
328
|
+
return { add(t, n) {
|
|
329
|
+
e.add(t, n);
|
|
330
|
+
} };
|
|
331
|
+
}
|
|
332
|
+
}, y = class {
|
|
333
|
+
constructor(e) {
|
|
334
|
+
this.resolveRegistry = e;
|
|
335
|
+
}
|
|
336
|
+
target() {
|
|
337
|
+
return this.resolveRegistry();
|
|
338
|
+
}
|
|
339
|
+
get(e) {
|
|
340
|
+
return this.target().get(e);
|
|
341
|
+
}
|
|
342
|
+
getAsync(e) {
|
|
343
|
+
return this.target().getAsync(e);
|
|
344
|
+
}
|
|
345
|
+
add(e, t) {
|
|
346
|
+
return this.target().add(e, t);
|
|
347
|
+
}
|
|
348
|
+
addAll(e) {
|
|
349
|
+
return this.target().addAll(e);
|
|
350
|
+
}
|
|
351
|
+
addAsync(e, t) {
|
|
352
|
+
return this.target().addAsync(e, t);
|
|
353
|
+
}
|
|
354
|
+
has(e) {
|
|
355
|
+
return this.target().has(e);
|
|
356
|
+
}
|
|
357
|
+
isLoaded(e) {
|
|
358
|
+
return this.target().isLoaded(e);
|
|
359
|
+
}
|
|
360
|
+
override(e, t) {
|
|
361
|
+
return this.target().override(e, t);
|
|
362
|
+
}
|
|
363
|
+
on(e, t) {
|
|
364
|
+
return this.target().on(e, t);
|
|
365
|
+
}
|
|
366
|
+
once(e, t) {
|
|
367
|
+
return this.target().once(e, t);
|
|
368
|
+
}
|
|
369
|
+
off(e, t) {
|
|
370
|
+
return this.target().off(e, t);
|
|
371
|
+
}
|
|
372
|
+
keys() {
|
|
373
|
+
return this.target().keys();
|
|
374
|
+
}
|
|
375
|
+
forContext() {
|
|
376
|
+
return this.target().forContext();
|
|
377
|
+
}
|
|
378
|
+
}, b = class {
|
|
21
379
|
_factories = /* @__PURE__ */ new Map();
|
|
22
380
|
add(e, t) {
|
|
23
381
|
let n = e;
|
|
@@ -28,28 +386,19 @@ var l = class {
|
|
|
28
386
|
get(e) {
|
|
29
387
|
return this._factories.get(e);
|
|
30
388
|
}
|
|
31
|
-
},
|
|
32
|
-
function
|
|
33
|
-
return
|
|
389
|
+
}, x = u("DomComponentRegistry");
|
|
390
|
+
function S(e, t = x) {
|
|
391
|
+
return _.getOrCreateInstance(t, () => new b());
|
|
34
392
|
}
|
|
35
393
|
//#endregion
|
|
36
|
-
//#region
|
|
37
|
-
var
|
|
38
|
-
import * as p from "@emailmaker/emailmaker/runtime/app-core/index.js";
|
|
39
|
-
o(f, p);
|
|
40
|
-
//#endregion
|
|
41
|
-
//#region packages/extensions-core/identifiers/index.ts
|
|
42
|
-
function m(e) {
|
|
43
|
-
return (0, s.createIdentifier)(e);
|
|
44
|
-
}
|
|
45
|
-
(0, s.createIdentifier)(), m("HANDLE_ATOM_INSERT"), (0, s.createIdentifier)(), (0, s.createIdentifier)("MESSAGE_SERVICE"), m("SETTINGS_PANEL_EVENT"), m("MODAL_SHOW_EVENT"), m("MODAL_CLOSE_EVENT"), m("MODAL_UPDATE_EVENT"), (0, s.createIdentifier)("client"), (0, s.createIdentifier)("ai_client"), (0, s.createIdentifier)(), (0, s.createIdentifier)(), (0, s.createIdentifier)("autosave-recovery");
|
|
46
|
-
var h = (0, s.createIdentifier)("PluginRegistry");
|
|
394
|
+
//#region src/plugin/registryId.ts
|
|
395
|
+
var C = "PluginRegistry";
|
|
47
396
|
//#endregion
|
|
48
397
|
//#region src/plugin/pluginRegistry.ts
|
|
49
|
-
function
|
|
50
|
-
return e.getOrCreateInstance(
|
|
398
|
+
function w(e = c()) {
|
|
399
|
+
return e.getOrCreateInstance(C, () => new v());
|
|
51
400
|
}
|
|
52
|
-
var
|
|
401
|
+
var T = new y(() => w());
|
|
53
402
|
//#endregion
|
|
54
403
|
//#region src/extensions/api/src/index.ts
|
|
55
404
|
(function(e) {
|
|
@@ -107,12 +456,12 @@ var _ = g();
|
|
|
107
456
|
n.packages[e.id] = e, n.validateAll();
|
|
108
457
|
}, t.__compat.registerPackage({
|
|
109
458
|
id: "extensions-api",
|
|
110
|
-
version: "1.0.111-dev.
|
|
459
|
+
version: "1.0.111-dev.7",
|
|
111
460
|
requires: { host: "^1.0.105" }
|
|
112
461
|
});
|
|
113
462
|
}
|
|
114
463
|
})(typeof window < "u" ? window : typeof globalThis < "u" ? globalThis : void 0);
|
|
115
|
-
function
|
|
464
|
+
function E(e, t, n, r) {
|
|
116
465
|
if (typeof r.value == "function") {
|
|
117
466
|
Object.defineProperty(e, n, {
|
|
118
467
|
value: r.value.bind(t),
|
|
@@ -140,46 +489,50 @@ function v(e, t, n, r) {
|
|
|
140
489
|
enumerable: !1
|
|
141
490
|
});
|
|
142
491
|
}
|
|
143
|
-
function
|
|
492
|
+
function D(e, t, n) {
|
|
144
493
|
let r = t.use(n), i = /* @__PURE__ */ new Set(), a = [r];
|
|
145
494
|
for (let e = Object.getPrototypeOf(r); e && e !== Object.prototype; e = Object.getPrototypeOf(e)) a.push(e);
|
|
146
495
|
for (let t of a) for (let n of Reflect.ownKeys(t)) {
|
|
147
496
|
if (n === "constructor" || i.has(n)) continue;
|
|
148
497
|
let a = Object.getOwnPropertyDescriptor(t, n);
|
|
149
|
-
a && (i.add(n),
|
|
498
|
+
a && (i.add(n), E(e, r, n, a));
|
|
150
499
|
}
|
|
151
500
|
}
|
|
152
|
-
function
|
|
501
|
+
function O() {
|
|
153
502
|
return typeof globalThis.crypto?.randomUUID == "function" ? globalThis.crypto.randomUUID() : `component-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
154
503
|
}
|
|
155
|
-
var
|
|
504
|
+
var k = class {
|
|
505
|
+
constructor(e) {
|
|
506
|
+
D(this, e, "SandboxScriptApi");
|
|
507
|
+
}
|
|
508
|
+
}, A = class {
|
|
156
509
|
constructor(e) {
|
|
157
|
-
|
|
510
|
+
D(this, e, "ElementsApi");
|
|
158
511
|
}
|
|
159
|
-
},
|
|
512
|
+
}, j = class {
|
|
160
513
|
constructor(e) {
|
|
161
|
-
|
|
514
|
+
D(this, e, "BlocksApi");
|
|
162
515
|
}
|
|
163
|
-
},
|
|
516
|
+
}, M = class {
|
|
164
517
|
constructor(e) {
|
|
165
|
-
|
|
518
|
+
D(this, e, "MessageService");
|
|
166
519
|
}
|
|
167
|
-
},
|
|
520
|
+
}, N = class {
|
|
168
521
|
constructor(e) {
|
|
169
|
-
|
|
522
|
+
D(this, e, "SettingsPanelApi");
|
|
170
523
|
}
|
|
171
|
-
},
|
|
524
|
+
}, P = class {
|
|
172
525
|
constructor(e) {
|
|
173
|
-
|
|
526
|
+
D(this, e, "ModalApi");
|
|
174
527
|
}
|
|
175
|
-
},
|
|
528
|
+
}, F = class {
|
|
176
529
|
constructor(e) {
|
|
177
|
-
|
|
530
|
+
D(this, e, "EmailSettingsApi");
|
|
178
531
|
}
|
|
179
532
|
};
|
|
180
|
-
function
|
|
533
|
+
function I(e = O()) {
|
|
181
534
|
return e;
|
|
182
535
|
}
|
|
183
|
-
var
|
|
536
|
+
var L = S(_), R = "1.0.111-dev.7";
|
|
184
537
|
//#endregion
|
|
185
|
-
export {
|
|
538
|
+
export { j as BlocksApi, L as DomComponentRegistry, A as ElementsApi, F as EmailSettingsApi, M as MessageService, P as ModalApi, k as SandboxScriptApi, N as SettingsPanelApi, I as createComponentIdentifier, T as pluginRegistry, R as version };
|
package/package.json
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "types.d.ts",
|
|
7
7
|
"name": "@emailmaker/extensions-app",
|
|
8
|
-
"version": "1.0.111-dev.
|
|
8
|
+
"version": "1.0.111-dev.7",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@emailmaker/emailmaker": "1.0.111-dev.
|
|
10
|
+
"@emailmaker/emailmaker": "1.0.111-dev.7"
|
|
11
11
|
}
|
|
12
12
|
}
|
package/types.d.ts
CHANGED
|
@@ -49,6 +49,81 @@ type MayBePromise$1<Value> = Promise<Value> | Value;
|
|
|
49
49
|
interface IDisposable$1 {
|
|
50
50
|
dispose(): void;
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Payload for `BlocksApi.handleInject` when a block/structure was inserted in the sandbox
|
|
54
|
+
* (mirrors `application_block_inserted` message data).
|
|
55
|
+
*/
|
|
56
|
+
interface BlockInjectInfo {
|
|
57
|
+
type?: string;
|
|
58
|
+
name?: string;
|
|
59
|
+
blockId?: string;
|
|
60
|
+
project?: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Context passed to ElementsApi.handleBeforeInject before element (atom) HTML is sent to the iframe.
|
|
64
|
+
* Listeners may mutate fields in place and/or return a partial object to merge (SaveEmitter-style).
|
|
65
|
+
*/
|
|
66
|
+
interface ElementInsertContext extends Record<string, unknown> {
|
|
67
|
+
name: string;
|
|
68
|
+
className: string;
|
|
69
|
+
html: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Context passed to BlocksApi.handleBeforeInject before block HTML is sent to the iframe.
|
|
73
|
+
* `insertFrom` is the editor catalog route (e.g. project / template / common), not REST Block.type taxonomy.
|
|
74
|
+
*/
|
|
75
|
+
interface BlockInsertContext extends Record<string, unknown> {
|
|
76
|
+
html: string;
|
|
77
|
+
insertFrom?: string;
|
|
78
|
+
fragmentRole?: 'block' | 'structure';
|
|
79
|
+
/** REST / catalog taxonomy (e.g. block type from API), not the same as `insertFrom`. */
|
|
80
|
+
type?: string;
|
|
81
|
+
name?: string;
|
|
82
|
+
/** Current app project id (route / Redux), not necessarily `Block.project` from REST. */
|
|
83
|
+
project?: string | number;
|
|
84
|
+
id?: string;
|
|
85
|
+
title?: string | null;
|
|
86
|
+
tags?: string[];
|
|
87
|
+
slug?: string;
|
|
88
|
+
description?: string;
|
|
89
|
+
subject?: string;
|
|
90
|
+
blocktags?: number[];
|
|
91
|
+
modified?: string | null;
|
|
92
|
+
author?: string;
|
|
93
|
+
lock?: boolean;
|
|
94
|
+
excerpt?: string | null;
|
|
95
|
+
status?: string;
|
|
96
|
+
is_template?: boolean;
|
|
97
|
+
link?: string;
|
|
98
|
+
renderGuid?: string;
|
|
99
|
+
date?: string | null;
|
|
100
|
+
date_gmt?: string | null;
|
|
101
|
+
modified_gmt?: string | null;
|
|
102
|
+
comment_status?: string;
|
|
103
|
+
ping_status?: string;
|
|
104
|
+
template?: string;
|
|
105
|
+
related_email?: string;
|
|
106
|
+
project_title?: string;
|
|
107
|
+
project_author?: string;
|
|
108
|
+
isAmp?: boolean;
|
|
109
|
+
/** Remaining catalog/API fields not mapped above (shallow copy). */
|
|
110
|
+
catalogExtra?: Record<string, unknown>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* API for block insert lifecycle in the editor (before HTML is sent to the iframe, and after sandbox insert).
|
|
114
|
+
*/
|
|
115
|
+
interface IBlocksApi {
|
|
116
|
+
/**
|
|
117
|
+
* Runs before block HTML is posted to the iframe. Listeners receive a mutable context; they may
|
|
118
|
+
* mutate `html` and related fields or return a partial object to merge (SaveEmitter-style).
|
|
119
|
+
*/
|
|
120
|
+
handleBeforeInject(listener: (ctx: BlockInsertContext) => MayBePromise$1<Partial<BlockInsertContext> | void>, priority?: number, thisArg?: unknown): IDisposable$1;
|
|
121
|
+
/**
|
|
122
|
+
* Fires after a block or structure was inserted in the sandbox (same channel as `application_block_inserted`).
|
|
123
|
+
* Does not allow changing markup; use {@link handleBeforeInject} to transform HTML before postMessage.
|
|
124
|
+
*/
|
|
125
|
+
handleInject(listener: (info: BlockInjectInfo) => void, priority?: number, thisArg?: unknown): IDisposable$1;
|
|
126
|
+
}
|
|
52
127
|
/**
|
|
53
128
|
* Information about an element.
|
|
54
129
|
*/
|
|
@@ -88,13 +163,19 @@ interface IElementsApi {
|
|
|
88
163
|
*/
|
|
89
164
|
insert(element: Element, position?: number): IDisposable$1;
|
|
90
165
|
/**
|
|
91
|
-
*
|
|
166
|
+
* Runs before atom HTML is posted to the iframe. Listeners receive a mutable context; they may
|
|
167
|
+
* mutate `html` / `name` / `className` or return a partial object to merge (SaveEmitter-style).
|
|
168
|
+
*/
|
|
169
|
+
handleBeforeInject(listener: (ctx: ElementInsertContext) => MayBePromise$1<Partial<ElementInsertContext> | void>, priority?: number, thisArg?: unknown): IDisposable$1;
|
|
170
|
+
/**
|
|
171
|
+
* Fires after an atom is injected into the email HTML in the sandbox. Does not allow changing inserted markup.
|
|
172
|
+
* For transforming HTML before postMessage, use {@link handleBeforeInject}.
|
|
92
173
|
*/
|
|
93
174
|
handleInject(listener: (elementInfo: {
|
|
94
175
|
name: string;
|
|
95
176
|
className: string;
|
|
96
177
|
html: string;
|
|
97
|
-
}) => void, priority?: number, thisArg?:
|
|
178
|
+
}) => void, priority?: number, thisArg?: unknown): IDisposable$1;
|
|
98
179
|
}
|
|
99
180
|
/**
|
|
100
181
|
* API for interacting with the MessageService.
|
|
@@ -263,6 +344,12 @@ interface SettingsPanelOptions<Props = unknown> {
|
|
|
263
344
|
deletable?: boolean;
|
|
264
345
|
parent?: boolean;
|
|
265
346
|
advancedTabs?: ExtraTabOptions[];
|
|
347
|
+
/**
|
|
348
|
+
* Stable logical instance (block uuid, atom id, etc.).
|
|
349
|
+
* When omitted, each {@link ISettingsPanelApi.showSettingsPanel} call gets a fresh key and the host remounts the panel.
|
|
350
|
+
* Pass a stable value only to update props in-place and preserve internal UI state (scroll, focus, drafts).
|
|
351
|
+
*/
|
|
352
|
+
instanceKey?: string;
|
|
266
353
|
}
|
|
267
354
|
/**
|
|
268
355
|
* API for managing the settings panel.
|
|
@@ -350,14 +437,15 @@ declare const DomComponentRegistry: IDomComponentRegistry;
|
|
|
350
437
|
// ============================================
|
|
351
438
|
// EmailSettingsApi
|
|
352
439
|
// ============================================
|
|
353
|
-
/**
|
|
354
|
-
* API for working with email settings.
|
|
355
|
-
*/
|
|
356
440
|
interface EmailSettingsApi {
|
|
357
441
|
getEmailLayoutSettings(): Promise<EmailLayoutSettings>;
|
|
358
442
|
setEmailLayoutSettings(settings: Partial<EmailLayoutSettings>): Promise<void>;
|
|
359
443
|
getEmailContentStyles(): Promise<EmailContentStyles>;
|
|
360
444
|
setEmailContentStyles(contentStyles: Partial<EmailContentStyles>): Promise<void>;
|
|
445
|
+
/** Fired after email layout settings change. */
|
|
446
|
+
onChangeEmailLayoutSettings(listener: (settings: EmailLayoutSettings) => void): IDisposable;
|
|
447
|
+
/** Fired after email content styles change. */
|
|
448
|
+
onChangeEmailContentStyles(listener: (contentStyles: EmailContentStyles) => void): IDisposable;
|
|
361
449
|
}
|
|
362
450
|
/**
|
|
363
451
|
* Email layout settings.
|
|
@@ -514,6 +602,14 @@ declare class ElementsApi {
|
|
|
514
602
|
constructor(editor: Instance);
|
|
515
603
|
}
|
|
516
604
|
interface ElementsApi extends IElementsApi {}
|
|
605
|
+
/**
|
|
606
|
+
* @deprecated Use `editor.use('BlocksApi')` to access built-in platform APIs.
|
|
607
|
+
* This compatibility facade will be removed in a future plugin-system package release.
|
|
608
|
+
*/
|
|
609
|
+
declare class BlocksApi {
|
|
610
|
+
constructor(editor: Instance);
|
|
611
|
+
}
|
|
612
|
+
interface BlocksApi extends IBlocksApi {}
|
|
517
613
|
/**
|
|
518
614
|
* @deprecated Use `editor.use('MessageService')` to access built-in platform APIs.
|
|
519
615
|
* This compatibility facade will be removed in a future plugin-system package release.
|
|
@@ -549,6 +645,7 @@ declare module '@emailmaker/emailmaker' {
|
|
|
549
645
|
interface PluginTypeMap {
|
|
550
646
|
SandboxScriptApi: IPluginConstructor<ISandboxScriptApi>;
|
|
551
647
|
ElementsApi: IPluginConstructor<IElementsApi>;
|
|
648
|
+
BlocksApi: IPluginConstructor<IBlocksApi>;
|
|
552
649
|
MessageService: IPluginConstructor<IMessageServiceApi>;
|
|
553
650
|
SettingsPanelApi: IPluginConstructor<ISettingsPanelApi>;
|
|
554
651
|
ModalApi: IPluginConstructor<IModalApi>;
|
|
@@ -557,4 +654,4 @@ declare module '@emailmaker/emailmaker' {
|
|
|
557
654
|
}
|
|
558
655
|
declare const pluginRegistry: PluginRegistry;
|
|
559
656
|
declare const version: string;
|
|
560
|
-
export { ComponentId, ComponentInput, ComponentInputRegistry, ComponentType, DomComponentRegistry, ElementsApi, EmailContentStyles, EmailLayoutSettings, EmailSettingsApi, type IDisposable, IDomComponent, IDomComponentFactory, IDomComponentRegistry, type ISandboxScriptHandle, Identifier, MayBePromise, MessageService, ModalApi, SandboxScriptApi, SettingsPanelApi, createComponentIdentifier, pluginRegistry, version };
|
|
657
|
+
export { BlocksApi, ComponentId, ComponentInput, ComponentInputRegistry, ComponentType, DomComponentRegistry, ElementsApi, EmailContentStyles, EmailLayoutSettings, EmailSettingsApi, type IDisposable, IDomComponent, IDomComponentFactory, IDomComponentRegistry, type ISandboxScriptHandle, Identifier, MayBePromise, MessageService, ModalApi, SandboxScriptApi, SettingsPanelApi, createComponentIdentifier, pluginRegistry, version };
|