@merkur/integration-custom-element 0.35.13 → 0.36.1
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/lib/index.cjs +103 -24
- package/lib/index.es9.cjs +89 -30
- package/lib/index.es9.mjs +90 -31
- package/lib/index.js +103 -24
- package/lib/index.mjs +104 -25
- package/lib/index.umd.js +1 -1
- package/package.json +4 -4
package/lib/index.cjs
CHANGED
|
@@ -3,16 +3,19 @@
|
|
|
3
3
|
var core = require('@merkur/core');
|
|
4
4
|
var integration = require('@merkur/integration');
|
|
5
5
|
|
|
6
|
-
async function createSPAWidget(widgetDefinition) {
|
|
6
|
+
async function createSPAWidget(widgetDefinition, root) {
|
|
7
7
|
const definition = {
|
|
8
8
|
...widgetDefinition,
|
|
9
|
-
createWidget: widgetDefinition.createWidget
|
|
9
|
+
createWidget: widgetDefinition.createWidget,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
core.getMerkur()
|
|
12
|
+
const merkur = core.getMerkur();
|
|
13
|
+
if (!merkur.isRegistered(definition.name + definition.version)) {
|
|
14
|
+
core.getMerkur().register(definition);
|
|
15
|
+
}
|
|
13
16
|
|
|
14
17
|
await afterDOMLoad();
|
|
15
|
-
await integration.loadAssets(definition.assets,
|
|
18
|
+
await integration.loadAssets(definition.assets, root);
|
|
16
19
|
|
|
17
20
|
return await core.getMerkur().create(definition);
|
|
18
21
|
}
|
|
@@ -39,35 +42,72 @@ function registerCustomElement(options) {
|
|
|
39
42
|
constructor() {
|
|
40
43
|
super();
|
|
41
44
|
|
|
42
|
-
|
|
43
|
-
const shadow = this.attachShadow({ mode: 'open' });
|
|
45
|
+
const customWidgetDefinition = deepMerge({}, widgetDefinition);
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
(async () => {
|
|
48
|
+
this._shadow = this.attachShadow({ mode: 'open' });
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
try {
|
|
51
|
+
const widget = await callbacks?.getInstance?.();
|
|
52
|
+
|
|
53
|
+
if (widget && widget.name && widget.version) {
|
|
54
|
+
this._widget = widget;
|
|
55
|
+
|
|
56
|
+
await afterDOMLoad();
|
|
57
|
+
await integration.loadAssets(widget.assets, this._shadow);
|
|
58
|
+
|
|
59
|
+
await callbacks?.reconstructor?.(this._widget, {
|
|
60
|
+
shadow: this._shadow,
|
|
61
|
+
customElement: this,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (typeof callbacks?.remount === 'function') {
|
|
65
|
+
await callbacks?.remount?.(this._widget, {
|
|
66
|
+
shadow: this._shadow,
|
|
67
|
+
customElement: this,
|
|
68
|
+
});
|
|
69
|
+
} else {
|
|
70
|
+
widget.root = this._shadow;
|
|
71
|
+
widget.customElement = this;
|
|
72
|
+
this._shadow.appendChild(widget.container);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.error(error);
|
|
50
79
|
|
|
51
80
|
return;
|
|
52
81
|
}
|
|
53
82
|
|
|
54
83
|
try {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
84
|
+
customWidgetDefinition.root = this._shadow;
|
|
85
|
+
customWidgetDefinition.customElement = this;
|
|
86
|
+
|
|
87
|
+
if (!customWidgetDefinition.container) {
|
|
88
|
+
customWidgetDefinition.container = document.createElement('div');
|
|
89
|
+
customWidgetDefinition.container.setAttribute(
|
|
90
|
+
'id',
|
|
91
|
+
'merkur-container',
|
|
92
|
+
);
|
|
62
93
|
}
|
|
63
94
|
|
|
64
|
-
|
|
95
|
+
this._shadow.appendChild(customWidgetDefinition.container);
|
|
65
96
|
|
|
66
|
-
this._widget = await createSPAWidget(
|
|
97
|
+
this._widget = await createSPAWidget(
|
|
98
|
+
customWidgetDefinition,
|
|
99
|
+
this._shadow,
|
|
100
|
+
);
|
|
67
101
|
|
|
68
|
-
callbacks?.constructor?.(this._widget
|
|
102
|
+
await callbacks?.constructor?.(this._widget, {
|
|
103
|
+
shadow: this._shadow,
|
|
104
|
+
customElement: this,
|
|
105
|
+
});
|
|
69
106
|
|
|
70
|
-
await this._widget
|
|
107
|
+
(await callbacks?.mount?.(this._widget, {
|
|
108
|
+
shadow: this._shadow,
|
|
109
|
+
customElement: this,
|
|
110
|
+
})) ?? (await this._widget.mount());
|
|
71
111
|
} catch (error) {
|
|
72
112
|
console.error(error);
|
|
73
113
|
}
|
|
@@ -75,23 +115,62 @@ function registerCustomElement(options) {
|
|
|
75
115
|
}
|
|
76
116
|
|
|
77
117
|
connectedCallback() {
|
|
78
|
-
|
|
118
|
+
this._widget?.connectedCallback?.({
|
|
119
|
+
shadow: this._shadow,
|
|
120
|
+
customElement: this,
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
callbacks?.connectedCallback?.(this._widget, {
|
|
124
|
+
shadow: this._shadow,
|
|
125
|
+
customElement: this,
|
|
126
|
+
});
|
|
79
127
|
}
|
|
80
128
|
|
|
81
129
|
disconnectedCallback() {
|
|
82
|
-
|
|
130
|
+
this._widget?.disconnectedCallback?.({
|
|
131
|
+
shadow: this._shadow,
|
|
132
|
+
customElement: this,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
callbacks?.disconnectedCallback?.(this._widget, {
|
|
136
|
+
shadow: this._shadow,
|
|
137
|
+
customElement: this,
|
|
138
|
+
});
|
|
83
139
|
}
|
|
84
140
|
|
|
85
141
|
adoptedCallback() {
|
|
86
|
-
|
|
142
|
+
this._widget?.adoptedCallback?.({
|
|
143
|
+
shadow: this._shadow,
|
|
144
|
+
customElement: this,
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
callbacks?.adoptedCallback?.(this._widget, {
|
|
148
|
+
shadow: this._shadow,
|
|
149
|
+
customElement: this,
|
|
150
|
+
});
|
|
87
151
|
}
|
|
88
152
|
|
|
89
153
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
154
|
+
this._widget?.attributeChangedCallback?.(
|
|
155
|
+
this._widget,
|
|
156
|
+
name,
|
|
157
|
+
oldValue,
|
|
158
|
+
newValue,
|
|
159
|
+
{
|
|
160
|
+
shadow: this._shadow,
|
|
161
|
+
customElement: this,
|
|
162
|
+
},
|
|
163
|
+
);
|
|
164
|
+
|
|
90
165
|
callbacks?.attributeChangedCallback?.(
|
|
91
166
|
this._widget,
|
|
92
167
|
name,
|
|
93
168
|
oldValue,
|
|
94
169
|
newValue,
|
|
170
|
+
{
|
|
171
|
+
shadow: this._shadow,
|
|
172
|
+
customElement: this,
|
|
173
|
+
},
|
|
95
174
|
);
|
|
96
175
|
}
|
|
97
176
|
}
|
package/lib/index.es9.cjs
CHANGED
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
var core = require('@merkur/core');
|
|
4
4
|
var integration = require('@merkur/integration');
|
|
5
|
-
async function createSPAWidget(widgetDefinition) {
|
|
5
|
+
async function createSPAWidget(widgetDefinition, root) {
|
|
6
6
|
const definition = {
|
|
7
7
|
...widgetDefinition,
|
|
8
|
-
createWidget: widgetDefinition.createWidget
|
|
8
|
+
createWidget: widgetDefinition.createWidget
|
|
9
9
|
};
|
|
10
|
-
core.getMerkur()
|
|
10
|
+
const merkur = core.getMerkur();
|
|
11
|
+
if (!merkur.isRegistered(definition.name + definition.version)) {
|
|
12
|
+
core.getMerkur().register(definition);
|
|
13
|
+
}
|
|
11
14
|
await afterDOMLoad();
|
|
12
|
-
await integration.loadAssets(definition.assets,
|
|
15
|
+
await integration.loadAssets(definition.assets, root);
|
|
13
16
|
return await core.getMerkur().create(definition);
|
|
14
17
|
}
|
|
15
18
|
function afterDOMLoad() {
|
|
@@ -35,50 +38,106 @@ function registerCustomElement(options) {
|
|
|
35
38
|
class WidgetElement extends HTMLElement {
|
|
36
39
|
constructor() {
|
|
37
40
|
super();
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
const customWidgetDefinition = deepMerge({}, widgetDefinition);
|
|
42
|
+
(async () => {
|
|
43
|
+
this._shadow = this.attachShadow({
|
|
40
44
|
mode: 'open'
|
|
41
45
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
try {
|
|
47
|
+
var _callbacks$getInstanc;
|
|
48
|
+
const widget = await (callbacks === null || callbacks === void 0 || (_callbacks$getInstanc = callbacks.getInstance) === null || _callbacks$getInstanc === void 0 ? void 0 : _callbacks$getInstanc.call(callbacks));
|
|
49
|
+
if (widget && widget.name && widget.version) {
|
|
50
|
+
var _callbacks$reconstruc;
|
|
51
|
+
this._widget = widget;
|
|
52
|
+
await afterDOMLoad();
|
|
53
|
+
await integration.loadAssets(widget.assets, this._shadow);
|
|
54
|
+
await (callbacks === null || callbacks === void 0 || (_callbacks$reconstruc = callbacks.reconstructor) === null || _callbacks$reconstruc === void 0 ? void 0 : _callbacks$reconstruc.call(callbacks, this._widget, {
|
|
55
|
+
shadow: this._shadow,
|
|
56
|
+
customElement: this
|
|
57
|
+
}));
|
|
58
|
+
if (typeof (callbacks === null || callbacks === void 0 ? void 0 : callbacks.remount) === 'function') {
|
|
59
|
+
var _callbacks$remount;
|
|
60
|
+
await (callbacks === null || callbacks === void 0 || (_callbacks$remount = callbacks.remount) === null || _callbacks$remount === void 0 ? void 0 : _callbacks$remount.call(callbacks, this._widget, {
|
|
61
|
+
shadow: this._shadow,
|
|
62
|
+
customElement: this
|
|
63
|
+
}));
|
|
64
|
+
} else {
|
|
65
|
+
widget.root = this._shadow;
|
|
66
|
+
widget.customElement = this;
|
|
67
|
+
this._shadow.appendChild(widget.container);
|
|
68
|
+
}
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.error(error);
|
|
47
73
|
return;
|
|
48
74
|
}
|
|
49
75
|
try {
|
|
50
|
-
var _callbacks$constructo;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
widgetDefinition.container.setAttribute('id', 'merkur-container');
|
|
76
|
+
var _callbacks$constructo, _await$callbacks$moun, _callbacks$mount;
|
|
77
|
+
customWidgetDefinition.root = this._shadow;
|
|
78
|
+
customWidgetDefinition.customElement = this;
|
|
79
|
+
if (!customWidgetDefinition.container) {
|
|
80
|
+
customWidgetDefinition.container = document.createElement('div');
|
|
81
|
+
customWidgetDefinition.container.setAttribute('id', 'merkur-container');
|
|
57
82
|
}
|
|
58
|
-
|
|
59
|
-
this._widget = await createSPAWidget(
|
|
60
|
-
callbacks === null || callbacks === void 0 || (_callbacks$constructo = callbacks.constructor) === null || _callbacks$constructo === void 0
|
|
61
|
-
|
|
83
|
+
this._shadow.appendChild(customWidgetDefinition.container);
|
|
84
|
+
this._widget = await createSPAWidget(customWidgetDefinition, this._shadow);
|
|
85
|
+
await (callbacks === null || callbacks === void 0 || (_callbacks$constructo = callbacks.constructor) === null || _callbacks$constructo === void 0 ? void 0 : _callbacks$constructo.call(callbacks, this._widget, {
|
|
86
|
+
shadow: this._shadow,
|
|
87
|
+
customElement: this
|
|
88
|
+
}));
|
|
89
|
+
(_await$callbacks$moun = await (callbacks === null || callbacks === void 0 || (_callbacks$mount = callbacks.mount) === null || _callbacks$mount === void 0 ? void 0 : _callbacks$mount.call(callbacks, this._widget, {
|
|
90
|
+
shadow: this._shadow,
|
|
91
|
+
customElement: this
|
|
92
|
+
}))) !== null && _await$callbacks$moun !== void 0 ? _await$callbacks$moun : await this._widget.mount();
|
|
62
93
|
} catch (error) {
|
|
63
94
|
console.error(error);
|
|
64
95
|
}
|
|
65
96
|
})();
|
|
66
97
|
}
|
|
67
98
|
connectedCallback() {
|
|
68
|
-
var _callbacks$connectedC;
|
|
69
|
-
|
|
99
|
+
var _this$_widget, _this$_widget$connect, _callbacks$connectedC;
|
|
100
|
+
(_this$_widget = this._widget) === null || _this$_widget === void 0 || (_this$_widget$connect = _this$_widget.connectedCallback) === null || _this$_widget$connect === void 0 || _this$_widget$connect.call(_this$_widget, {
|
|
101
|
+
shadow: this._shadow,
|
|
102
|
+
customElement: this
|
|
103
|
+
});
|
|
104
|
+
callbacks === null || callbacks === void 0 || (_callbacks$connectedC = callbacks.connectedCallback) === null || _callbacks$connectedC === void 0 || _callbacks$connectedC.call(callbacks, this._widget, {
|
|
105
|
+
shadow: this._shadow,
|
|
106
|
+
customElement: this
|
|
107
|
+
});
|
|
70
108
|
}
|
|
71
109
|
disconnectedCallback() {
|
|
72
|
-
var _callbacks$disconnect;
|
|
73
|
-
|
|
110
|
+
var _this$_widget2, _this$_widget2$discon, _callbacks$disconnect;
|
|
111
|
+
(_this$_widget2 = this._widget) === null || _this$_widget2 === void 0 || (_this$_widget2$discon = _this$_widget2.disconnectedCallback) === null || _this$_widget2$discon === void 0 || _this$_widget2$discon.call(_this$_widget2, {
|
|
112
|
+
shadow: this._shadow,
|
|
113
|
+
customElement: this
|
|
114
|
+
});
|
|
115
|
+
callbacks === null || callbacks === void 0 || (_callbacks$disconnect = callbacks.disconnectedCallback) === null || _callbacks$disconnect === void 0 || _callbacks$disconnect.call(callbacks, this._widget, {
|
|
116
|
+
shadow: this._shadow,
|
|
117
|
+
customElement: this
|
|
118
|
+
});
|
|
74
119
|
}
|
|
75
120
|
adoptedCallback() {
|
|
76
|
-
var _callbacks$adoptedCal;
|
|
77
|
-
|
|
121
|
+
var _this$_widget3, _this$_widget3$adopte, _callbacks$adoptedCal;
|
|
122
|
+
(_this$_widget3 = this._widget) === null || _this$_widget3 === void 0 || (_this$_widget3$adopte = _this$_widget3.adoptedCallback) === null || _this$_widget3$adopte === void 0 || _this$_widget3$adopte.call(_this$_widget3, {
|
|
123
|
+
shadow: this._shadow,
|
|
124
|
+
customElement: this
|
|
125
|
+
});
|
|
126
|
+
callbacks === null || callbacks === void 0 || (_callbacks$adoptedCal = callbacks.adoptedCallback) === null || _callbacks$adoptedCal === void 0 || _callbacks$adoptedCal.call(callbacks, this._widget, {
|
|
127
|
+
shadow: this._shadow,
|
|
128
|
+
customElement: this
|
|
129
|
+
});
|
|
78
130
|
}
|
|
79
131
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
80
|
-
var _callbacks$attributeC;
|
|
81
|
-
|
|
132
|
+
var _this$_widget4, _this$_widget4$attrib, _callbacks$attributeC;
|
|
133
|
+
(_this$_widget4 = this._widget) === null || _this$_widget4 === void 0 || (_this$_widget4$attrib = _this$_widget4.attributeChangedCallback) === null || _this$_widget4$attrib === void 0 || _this$_widget4$attrib.call(_this$_widget4, this._widget, name, oldValue, newValue, {
|
|
134
|
+
shadow: this._shadow,
|
|
135
|
+
customElement: this
|
|
136
|
+
});
|
|
137
|
+
callbacks === null || callbacks === void 0 || (_callbacks$attributeC = callbacks.attributeChangedCallback) === null || _callbacks$attributeC === void 0 || _callbacks$attributeC.call(callbacks, this._widget, name, oldValue, newValue, {
|
|
138
|
+
shadow: this._shadow,
|
|
139
|
+
customElement: this
|
|
140
|
+
});
|
|
82
141
|
}
|
|
83
142
|
}
|
|
84
143
|
if (customElements.get(widgetDefinition.name) === undefined) {
|
package/lib/index.es9.mjs
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getMerkur } from '@merkur/core';
|
|
2
2
|
import { loadAssets } from '@merkur/integration';
|
|
3
|
-
async function createSPAWidget(widgetDefinition) {
|
|
3
|
+
async function createSPAWidget(widgetDefinition, root) {
|
|
4
4
|
const definition = {
|
|
5
5
|
...widgetDefinition,
|
|
6
|
-
createWidget: widgetDefinition.createWidget
|
|
6
|
+
createWidget: widgetDefinition.createWidget
|
|
7
7
|
};
|
|
8
|
-
getMerkur()
|
|
8
|
+
const merkur = getMerkur();
|
|
9
|
+
if (!merkur.isRegistered(definition.name + definition.version)) {
|
|
10
|
+
getMerkur().register(definition);
|
|
11
|
+
}
|
|
9
12
|
await afterDOMLoad();
|
|
10
|
-
await loadAssets(definition.assets,
|
|
13
|
+
await loadAssets(definition.assets, root);
|
|
11
14
|
return await getMerkur().create(definition);
|
|
12
15
|
}
|
|
13
16
|
function afterDOMLoad() {
|
|
@@ -33,50 +36,106 @@ function registerCustomElement(options) {
|
|
|
33
36
|
class WidgetElement extends HTMLElement {
|
|
34
37
|
constructor() {
|
|
35
38
|
super();
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
const customWidgetDefinition = deepMerge({}, widgetDefinition);
|
|
40
|
+
(async () => {
|
|
41
|
+
this._shadow = this.attachShadow({
|
|
38
42
|
mode: 'open'
|
|
39
43
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
try {
|
|
45
|
+
var _callbacks$getInstanc;
|
|
46
|
+
const widget = await (callbacks === null || callbacks === void 0 || (_callbacks$getInstanc = callbacks.getInstance) === null || _callbacks$getInstanc === void 0 ? void 0 : _callbacks$getInstanc.call(callbacks));
|
|
47
|
+
if (widget && widget.name && widget.version) {
|
|
48
|
+
var _callbacks$reconstruc;
|
|
49
|
+
this._widget = widget;
|
|
50
|
+
await afterDOMLoad();
|
|
51
|
+
await loadAssets(widget.assets, this._shadow);
|
|
52
|
+
await (callbacks === null || callbacks === void 0 || (_callbacks$reconstruc = callbacks.reconstructor) === null || _callbacks$reconstruc === void 0 ? void 0 : _callbacks$reconstruc.call(callbacks, this._widget, {
|
|
53
|
+
shadow: this._shadow,
|
|
54
|
+
customElement: this
|
|
55
|
+
}));
|
|
56
|
+
if (typeof (callbacks === null || callbacks === void 0 ? void 0 : callbacks.remount) === 'function') {
|
|
57
|
+
var _callbacks$remount;
|
|
58
|
+
await (callbacks === null || callbacks === void 0 || (_callbacks$remount = callbacks.remount) === null || _callbacks$remount === void 0 ? void 0 : _callbacks$remount.call(callbacks, this._widget, {
|
|
59
|
+
shadow: this._shadow,
|
|
60
|
+
customElement: this
|
|
61
|
+
}));
|
|
62
|
+
} else {
|
|
63
|
+
widget.root = this._shadow;
|
|
64
|
+
widget.customElement = this;
|
|
65
|
+
this._shadow.appendChild(widget.container);
|
|
66
|
+
}
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error(error);
|
|
45
71
|
return;
|
|
46
72
|
}
|
|
47
73
|
try {
|
|
48
|
-
var _callbacks$constructo;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
widgetDefinition.container.setAttribute('id', 'merkur-container');
|
|
74
|
+
var _callbacks$constructo, _await$callbacks$moun, _callbacks$mount;
|
|
75
|
+
customWidgetDefinition.root = this._shadow;
|
|
76
|
+
customWidgetDefinition.customElement = this;
|
|
77
|
+
if (!customWidgetDefinition.container) {
|
|
78
|
+
customWidgetDefinition.container = document.createElement('div');
|
|
79
|
+
customWidgetDefinition.container.setAttribute('id', 'merkur-container');
|
|
55
80
|
}
|
|
56
|
-
|
|
57
|
-
this._widget = await createSPAWidget(
|
|
58
|
-
callbacks === null || callbacks === void 0 || (_callbacks$constructo = callbacks.constructor) === null || _callbacks$constructo === void 0
|
|
59
|
-
|
|
81
|
+
this._shadow.appendChild(customWidgetDefinition.container);
|
|
82
|
+
this._widget = await createSPAWidget(customWidgetDefinition, this._shadow);
|
|
83
|
+
await (callbacks === null || callbacks === void 0 || (_callbacks$constructo = callbacks.constructor) === null || _callbacks$constructo === void 0 ? void 0 : _callbacks$constructo.call(callbacks, this._widget, {
|
|
84
|
+
shadow: this._shadow,
|
|
85
|
+
customElement: this
|
|
86
|
+
}));
|
|
87
|
+
(_await$callbacks$moun = await (callbacks === null || callbacks === void 0 || (_callbacks$mount = callbacks.mount) === null || _callbacks$mount === void 0 ? void 0 : _callbacks$mount.call(callbacks, this._widget, {
|
|
88
|
+
shadow: this._shadow,
|
|
89
|
+
customElement: this
|
|
90
|
+
}))) !== null && _await$callbacks$moun !== void 0 ? _await$callbacks$moun : await this._widget.mount();
|
|
60
91
|
} catch (error) {
|
|
61
92
|
console.error(error);
|
|
62
93
|
}
|
|
63
94
|
})();
|
|
64
95
|
}
|
|
65
96
|
connectedCallback() {
|
|
66
|
-
var _callbacks$connectedC;
|
|
67
|
-
|
|
97
|
+
var _this$_widget, _this$_widget$connect, _callbacks$connectedC;
|
|
98
|
+
(_this$_widget = this._widget) === null || _this$_widget === void 0 || (_this$_widget$connect = _this$_widget.connectedCallback) === null || _this$_widget$connect === void 0 || _this$_widget$connect.call(_this$_widget, {
|
|
99
|
+
shadow: this._shadow,
|
|
100
|
+
customElement: this
|
|
101
|
+
});
|
|
102
|
+
callbacks === null || callbacks === void 0 || (_callbacks$connectedC = callbacks.connectedCallback) === null || _callbacks$connectedC === void 0 || _callbacks$connectedC.call(callbacks, this._widget, {
|
|
103
|
+
shadow: this._shadow,
|
|
104
|
+
customElement: this
|
|
105
|
+
});
|
|
68
106
|
}
|
|
69
107
|
disconnectedCallback() {
|
|
70
|
-
var _callbacks$disconnect;
|
|
71
|
-
|
|
108
|
+
var _this$_widget2, _this$_widget2$discon, _callbacks$disconnect;
|
|
109
|
+
(_this$_widget2 = this._widget) === null || _this$_widget2 === void 0 || (_this$_widget2$discon = _this$_widget2.disconnectedCallback) === null || _this$_widget2$discon === void 0 || _this$_widget2$discon.call(_this$_widget2, {
|
|
110
|
+
shadow: this._shadow,
|
|
111
|
+
customElement: this
|
|
112
|
+
});
|
|
113
|
+
callbacks === null || callbacks === void 0 || (_callbacks$disconnect = callbacks.disconnectedCallback) === null || _callbacks$disconnect === void 0 || _callbacks$disconnect.call(callbacks, this._widget, {
|
|
114
|
+
shadow: this._shadow,
|
|
115
|
+
customElement: this
|
|
116
|
+
});
|
|
72
117
|
}
|
|
73
118
|
adoptedCallback() {
|
|
74
|
-
var _callbacks$adoptedCal;
|
|
75
|
-
|
|
119
|
+
var _this$_widget3, _this$_widget3$adopte, _callbacks$adoptedCal;
|
|
120
|
+
(_this$_widget3 = this._widget) === null || _this$_widget3 === void 0 || (_this$_widget3$adopte = _this$_widget3.adoptedCallback) === null || _this$_widget3$adopte === void 0 || _this$_widget3$adopte.call(_this$_widget3, {
|
|
121
|
+
shadow: this._shadow,
|
|
122
|
+
customElement: this
|
|
123
|
+
});
|
|
124
|
+
callbacks === null || callbacks === void 0 || (_callbacks$adoptedCal = callbacks.adoptedCallback) === null || _callbacks$adoptedCal === void 0 || _callbacks$adoptedCal.call(callbacks, this._widget, {
|
|
125
|
+
shadow: this._shadow,
|
|
126
|
+
customElement: this
|
|
127
|
+
});
|
|
76
128
|
}
|
|
77
129
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
78
|
-
var _callbacks$attributeC;
|
|
79
|
-
|
|
130
|
+
var _this$_widget4, _this$_widget4$attrib, _callbacks$attributeC;
|
|
131
|
+
(_this$_widget4 = this._widget) === null || _this$_widget4 === void 0 || (_this$_widget4$attrib = _this$_widget4.attributeChangedCallback) === null || _this$_widget4$attrib === void 0 || _this$_widget4$attrib.call(_this$_widget4, this._widget, name, oldValue, newValue, {
|
|
132
|
+
shadow: this._shadow,
|
|
133
|
+
customElement: this
|
|
134
|
+
});
|
|
135
|
+
callbacks === null || callbacks === void 0 || (_callbacks$attributeC = callbacks.attributeChangedCallback) === null || _callbacks$attributeC === void 0 || _callbacks$attributeC.call(callbacks, this._widget, name, oldValue, newValue, {
|
|
136
|
+
shadow: this._shadow,
|
|
137
|
+
customElement: this
|
|
138
|
+
});
|
|
80
139
|
}
|
|
81
140
|
}
|
|
82
141
|
if (customElements.get(widgetDefinition.name) === undefined) {
|
package/lib/index.js
CHANGED
|
@@ -3,16 +3,19 @@
|
|
|
3
3
|
var core = require('@merkur/core');
|
|
4
4
|
var integration = require('@merkur/integration');
|
|
5
5
|
|
|
6
|
-
async function createSPAWidget(widgetDefinition) {
|
|
6
|
+
async function createSPAWidget(widgetDefinition, root) {
|
|
7
7
|
const definition = {
|
|
8
8
|
...widgetDefinition,
|
|
9
|
-
createWidget: widgetDefinition.createWidget
|
|
9
|
+
createWidget: widgetDefinition.createWidget,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
core.getMerkur()
|
|
12
|
+
const merkur = core.getMerkur();
|
|
13
|
+
if (!merkur.isRegistered(definition.name + definition.version)) {
|
|
14
|
+
core.getMerkur().register(definition);
|
|
15
|
+
}
|
|
13
16
|
|
|
14
17
|
await afterDOMLoad();
|
|
15
|
-
await integration.loadAssets(definition.assets,
|
|
18
|
+
await integration.loadAssets(definition.assets, root);
|
|
16
19
|
|
|
17
20
|
return await core.getMerkur().create(definition);
|
|
18
21
|
}
|
|
@@ -39,35 +42,72 @@ function registerCustomElement(options) {
|
|
|
39
42
|
constructor() {
|
|
40
43
|
super();
|
|
41
44
|
|
|
42
|
-
|
|
43
|
-
const shadow = this.attachShadow({ mode: 'open' });
|
|
45
|
+
const customWidgetDefinition = deepMerge({}, widgetDefinition);
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
(async () => {
|
|
48
|
+
this._shadow = this.attachShadow({ mode: 'open' });
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
try {
|
|
51
|
+
const widget = await callbacks?.getInstance?.();
|
|
52
|
+
|
|
53
|
+
if (widget && widget.name && widget.version) {
|
|
54
|
+
this._widget = widget;
|
|
55
|
+
|
|
56
|
+
await afterDOMLoad();
|
|
57
|
+
await integration.loadAssets(widget.assets, this._shadow);
|
|
58
|
+
|
|
59
|
+
await callbacks?.reconstructor?.(this._widget, {
|
|
60
|
+
shadow: this._shadow,
|
|
61
|
+
customElement: this,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (typeof callbacks?.remount === 'function') {
|
|
65
|
+
await callbacks?.remount?.(this._widget, {
|
|
66
|
+
shadow: this._shadow,
|
|
67
|
+
customElement: this,
|
|
68
|
+
});
|
|
69
|
+
} else {
|
|
70
|
+
widget.root = this._shadow;
|
|
71
|
+
widget.customElement = this;
|
|
72
|
+
this._shadow.appendChild(widget.container);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.error(error);
|
|
50
79
|
|
|
51
80
|
return;
|
|
52
81
|
}
|
|
53
82
|
|
|
54
83
|
try {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
84
|
+
customWidgetDefinition.root = this._shadow;
|
|
85
|
+
customWidgetDefinition.customElement = this;
|
|
86
|
+
|
|
87
|
+
if (!customWidgetDefinition.container) {
|
|
88
|
+
customWidgetDefinition.container = document.createElement('div');
|
|
89
|
+
customWidgetDefinition.container.setAttribute(
|
|
90
|
+
'id',
|
|
91
|
+
'merkur-container',
|
|
92
|
+
);
|
|
62
93
|
}
|
|
63
94
|
|
|
64
|
-
|
|
95
|
+
this._shadow.appendChild(customWidgetDefinition.container);
|
|
65
96
|
|
|
66
|
-
this._widget = await createSPAWidget(
|
|
97
|
+
this._widget = await createSPAWidget(
|
|
98
|
+
customWidgetDefinition,
|
|
99
|
+
this._shadow,
|
|
100
|
+
);
|
|
67
101
|
|
|
68
|
-
callbacks?.constructor?.(this._widget
|
|
102
|
+
await callbacks?.constructor?.(this._widget, {
|
|
103
|
+
shadow: this._shadow,
|
|
104
|
+
customElement: this,
|
|
105
|
+
});
|
|
69
106
|
|
|
70
|
-
await this._widget
|
|
107
|
+
(await callbacks?.mount?.(this._widget, {
|
|
108
|
+
shadow: this._shadow,
|
|
109
|
+
customElement: this,
|
|
110
|
+
})) ?? (await this._widget.mount());
|
|
71
111
|
} catch (error) {
|
|
72
112
|
console.error(error);
|
|
73
113
|
}
|
|
@@ -75,23 +115,62 @@ function registerCustomElement(options) {
|
|
|
75
115
|
}
|
|
76
116
|
|
|
77
117
|
connectedCallback() {
|
|
78
|
-
|
|
118
|
+
this._widget?.connectedCallback?.({
|
|
119
|
+
shadow: this._shadow,
|
|
120
|
+
customElement: this,
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
callbacks?.connectedCallback?.(this._widget, {
|
|
124
|
+
shadow: this._shadow,
|
|
125
|
+
customElement: this,
|
|
126
|
+
});
|
|
79
127
|
}
|
|
80
128
|
|
|
81
129
|
disconnectedCallback() {
|
|
82
|
-
|
|
130
|
+
this._widget?.disconnectedCallback?.({
|
|
131
|
+
shadow: this._shadow,
|
|
132
|
+
customElement: this,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
callbacks?.disconnectedCallback?.(this._widget, {
|
|
136
|
+
shadow: this._shadow,
|
|
137
|
+
customElement: this,
|
|
138
|
+
});
|
|
83
139
|
}
|
|
84
140
|
|
|
85
141
|
adoptedCallback() {
|
|
86
|
-
|
|
142
|
+
this._widget?.adoptedCallback?.({
|
|
143
|
+
shadow: this._shadow,
|
|
144
|
+
customElement: this,
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
callbacks?.adoptedCallback?.(this._widget, {
|
|
148
|
+
shadow: this._shadow,
|
|
149
|
+
customElement: this,
|
|
150
|
+
});
|
|
87
151
|
}
|
|
88
152
|
|
|
89
153
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
154
|
+
this._widget?.attributeChangedCallback?.(
|
|
155
|
+
this._widget,
|
|
156
|
+
name,
|
|
157
|
+
oldValue,
|
|
158
|
+
newValue,
|
|
159
|
+
{
|
|
160
|
+
shadow: this._shadow,
|
|
161
|
+
customElement: this,
|
|
162
|
+
},
|
|
163
|
+
);
|
|
164
|
+
|
|
90
165
|
callbacks?.attributeChangedCallback?.(
|
|
91
166
|
this._widget,
|
|
92
167
|
name,
|
|
93
168
|
oldValue,
|
|
94
169
|
newValue,
|
|
170
|
+
{
|
|
171
|
+
shadow: this._shadow,
|
|
172
|
+
customElement: this,
|
|
173
|
+
},
|
|
95
174
|
);
|
|
96
175
|
}
|
|
97
176
|
}
|
package/lib/index.mjs
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getMerkur } from '@merkur/core';
|
|
2
2
|
import { loadAssets } from '@merkur/integration';
|
|
3
3
|
|
|
4
|
-
async function createSPAWidget(widgetDefinition) {
|
|
4
|
+
async function createSPAWidget(widgetDefinition, root) {
|
|
5
5
|
const definition = {
|
|
6
6
|
...widgetDefinition,
|
|
7
|
-
createWidget: widgetDefinition.createWidget
|
|
7
|
+
createWidget: widgetDefinition.createWidget,
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
getMerkur()
|
|
10
|
+
const merkur = getMerkur();
|
|
11
|
+
if (!merkur.isRegistered(definition.name + definition.version)) {
|
|
12
|
+
getMerkur().register(definition);
|
|
13
|
+
}
|
|
11
14
|
|
|
12
15
|
await afterDOMLoad();
|
|
13
|
-
await loadAssets(definition.assets,
|
|
16
|
+
await loadAssets(definition.assets, root);
|
|
14
17
|
|
|
15
18
|
return await getMerkur().create(definition);
|
|
16
19
|
}
|
|
@@ -37,35 +40,72 @@ function registerCustomElement(options) {
|
|
|
37
40
|
constructor() {
|
|
38
41
|
super();
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
const shadow = this.attachShadow({ mode: 'open' });
|
|
43
|
+
const customWidgetDefinition = deepMerge({}, widgetDefinition);
|
|
42
44
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
(async () => {
|
|
46
|
+
this._shadow = this.attachShadow({ mode: 'open' });
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
try {
|
|
49
|
+
const widget = await callbacks?.getInstance?.();
|
|
50
|
+
|
|
51
|
+
if (widget && widget.name && widget.version) {
|
|
52
|
+
this._widget = widget;
|
|
53
|
+
|
|
54
|
+
await afterDOMLoad();
|
|
55
|
+
await loadAssets(widget.assets, this._shadow);
|
|
56
|
+
|
|
57
|
+
await callbacks?.reconstructor?.(this._widget, {
|
|
58
|
+
shadow: this._shadow,
|
|
59
|
+
customElement: this,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
if (typeof callbacks?.remount === 'function') {
|
|
63
|
+
await callbacks?.remount?.(this._widget, {
|
|
64
|
+
shadow: this._shadow,
|
|
65
|
+
customElement: this,
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
widget.root = this._shadow;
|
|
69
|
+
widget.customElement = this;
|
|
70
|
+
this._shadow.appendChild(widget.container);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.error(error);
|
|
48
77
|
|
|
49
78
|
return;
|
|
50
79
|
}
|
|
51
80
|
|
|
52
81
|
try {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
82
|
+
customWidgetDefinition.root = this._shadow;
|
|
83
|
+
customWidgetDefinition.customElement = this;
|
|
84
|
+
|
|
85
|
+
if (!customWidgetDefinition.container) {
|
|
86
|
+
customWidgetDefinition.container = document.createElement('div');
|
|
87
|
+
customWidgetDefinition.container.setAttribute(
|
|
88
|
+
'id',
|
|
89
|
+
'merkur-container',
|
|
90
|
+
);
|
|
60
91
|
}
|
|
61
92
|
|
|
62
|
-
|
|
93
|
+
this._shadow.appendChild(customWidgetDefinition.container);
|
|
63
94
|
|
|
64
|
-
this._widget = await createSPAWidget(
|
|
95
|
+
this._widget = await createSPAWidget(
|
|
96
|
+
customWidgetDefinition,
|
|
97
|
+
this._shadow,
|
|
98
|
+
);
|
|
65
99
|
|
|
66
|
-
callbacks?.constructor?.(this._widget
|
|
100
|
+
await callbacks?.constructor?.(this._widget, {
|
|
101
|
+
shadow: this._shadow,
|
|
102
|
+
customElement: this,
|
|
103
|
+
});
|
|
67
104
|
|
|
68
|
-
await this._widget
|
|
105
|
+
(await callbacks?.mount?.(this._widget, {
|
|
106
|
+
shadow: this._shadow,
|
|
107
|
+
customElement: this,
|
|
108
|
+
})) ?? (await this._widget.mount());
|
|
69
109
|
} catch (error) {
|
|
70
110
|
console.error(error);
|
|
71
111
|
}
|
|
@@ -73,23 +113,62 @@ function registerCustomElement(options) {
|
|
|
73
113
|
}
|
|
74
114
|
|
|
75
115
|
connectedCallback() {
|
|
76
|
-
|
|
116
|
+
this._widget?.connectedCallback?.({
|
|
117
|
+
shadow: this._shadow,
|
|
118
|
+
customElement: this,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
callbacks?.connectedCallback?.(this._widget, {
|
|
122
|
+
shadow: this._shadow,
|
|
123
|
+
customElement: this,
|
|
124
|
+
});
|
|
77
125
|
}
|
|
78
126
|
|
|
79
127
|
disconnectedCallback() {
|
|
80
|
-
|
|
128
|
+
this._widget?.disconnectedCallback?.({
|
|
129
|
+
shadow: this._shadow,
|
|
130
|
+
customElement: this,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
callbacks?.disconnectedCallback?.(this._widget, {
|
|
134
|
+
shadow: this._shadow,
|
|
135
|
+
customElement: this,
|
|
136
|
+
});
|
|
81
137
|
}
|
|
82
138
|
|
|
83
139
|
adoptedCallback() {
|
|
84
|
-
|
|
140
|
+
this._widget?.adoptedCallback?.({
|
|
141
|
+
shadow: this._shadow,
|
|
142
|
+
customElement: this,
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
callbacks?.adoptedCallback?.(this._widget, {
|
|
146
|
+
shadow: this._shadow,
|
|
147
|
+
customElement: this,
|
|
148
|
+
});
|
|
85
149
|
}
|
|
86
150
|
|
|
87
151
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
152
|
+
this._widget?.attributeChangedCallback?.(
|
|
153
|
+
this._widget,
|
|
154
|
+
name,
|
|
155
|
+
oldValue,
|
|
156
|
+
newValue,
|
|
157
|
+
{
|
|
158
|
+
shadow: this._shadow,
|
|
159
|
+
customElement: this,
|
|
160
|
+
},
|
|
161
|
+
);
|
|
162
|
+
|
|
88
163
|
callbacks?.attributeChangedCallback?.(
|
|
89
164
|
this._widget,
|
|
90
165
|
name,
|
|
91
166
|
oldValue,
|
|
92
167
|
newValue,
|
|
168
|
+
{
|
|
169
|
+
shadow: this._shadow,
|
|
170
|
+
customElement: this,
|
|
171
|
+
},
|
|
93
172
|
);
|
|
94
173
|
}
|
|
95
174
|
}
|
package/lib/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}!function(e,t){if("function"==typeof define&&define.amd)define("@merkur/integration-custom-element",["exports","@merkur/core","@merkur/integration"],t);else if("undefined"!=typeof exports)t(exports,require("@merkur/core"),require("@merkur/integration"));else{var n={exports:{}};t(n.exports,e.Merkur.Core,e.Merkur.Integration),e.merkurIntegrationCustomElement=n.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(t,n,
|
|
1
|
+
function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}!function(e,t){if("function"==typeof define&&define.amd)define("@merkur/integration-custom-element",["exports","@merkur/core","@merkur/integration"],t);else if("undefined"!=typeof exports)t(exports,require("@merkur/core"),require("@merkur/integration"));else{var n={exports:{}};t(n.exports,e.Merkur.Core,e.Merkur.Integration),e.merkurIntegrationCustomElement=n.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(t,n,o){function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){l(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e,t,n){return(t=c(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,c(o.key),o)}}function c(t){var n=function(t,n){if("object"!=e(t)||!t)return t;var o=t[Symbol.toPrimitive];if(void 0!==o){var r=o.call(t,n||"default");if("object"!=e(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"==e(n)?n:n+""}function a(e){var t="function"==typeof Map?new Map:void 0;return a=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(s())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,t);var r=new(e.bind.apply(e,o));return n&&d(r,n.prototype),r}(e,arguments,f(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),d(n,e)},a(e)}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(s=function(){return!!e})()}function d(e,t){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},d(e,t)}function f(e){return f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},f(e)}function p(e,t,n,o,r,i,l){try{var u=e[i](l),c=u.value}catch(e){return void n(e)}u.done?t(c):Promise.resolve(c).then(o,r)}function y(e){return function(){var t=this,n=arguments;return new Promise((function(o,r){var i=e.apply(t,n);function l(e){p(i,o,r,l,u,"next",e)}function u(e){p(i,o,r,l,u,"throw",e)}l(void 0)}))}}function h(){return(h=y((function*(e,t){var r=i(i({},e),{},{createWidget:e.createWidget});return(0,n.getMerkur)().isRegistered(r.name+r.version)||(0,n.getMerkur)().register(r),yield m(),yield(0,o.loadAssets)(r.assets,t),yield(0,n.getMerkur)().create(r)}))).apply(this,arguments)}function m(){return new Promise((function(e){"undefined"!=typeof document?"loading"!==document.readyState?e():window.addEventListener("DOMContentLoaded",(function(){e()})):e()}))}Object.defineProperty(t,"__esModule",{value:!0}),t.deepMerge=b,t.registerCustomElement=function(t){var n=b({},t),r=n.widgetDefinition,i=n.callbacks,l=function(t){function n(){var t,l,u,c;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),l=this,u=f(u=n),t=function(t,n){if(n&&("object"===e(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}(l,s()?Reflect.construct(u,c||[],f(l).constructor):u.apply(l,c));var a=b({},r);return y((function*(){t._shadow=t.attachShadow({mode:"open"});try{var e,n=yield null==i||null===(e=i.getInstance)||void 0===e?void 0:e.call(i);if(n&&n.name&&n.version){var r,l;if(t._widget=n,yield m(),yield(0,o.loadAssets)(n.assets,t._shadow),yield null==i||null===(r=i.reconstructor)||void 0===r?void 0:r.call(i,t._widget,{shadow:t._shadow,customElement:t}),"function"==typeof(null==i?void 0:i.remount))yield null==i||null===(l=i.remount)||void 0===l?void 0:l.call(i,t._widget,{shadow:t._shadow,customElement:t});else n.root=t._shadow,n.customElement=t,t._shadow.appendChild(n.container);return}}catch(e){return void console.error(e)}try{var u,c,s;a.root=t._shadow,a.customElement=t,a.container||(a.container=document.createElement("div"),a.container.setAttribute("id","merkur-container")),t._shadow.appendChild(a.container),t._widget=yield function(e,t){return h.apply(this,arguments)}(a,t._shadow),yield null==i||null===(u=i.constructor)||void 0===u?void 0:u.call(i,t._widget,{shadow:t._shadow,customElement:t}),null!==(c=yield null==i||null===(s=i.mount)||void 0===s?void 0:s.call(i,t._widget,{shadow:t._shadow,customElement:t}))&&void 0!==c||(yield t._widget.mount())}catch(e){console.error(e)}}))(),t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&d(e,t)}(n,t),function(e,t,n){t&&u(e.prototype,t);n&&u(e,n);return Object.defineProperty(e,"prototype",{writable:!1}),e}(n,[{key:"connectedCallback",value:function(){var e,t,n;null===(e=this._widget)||void 0===e||null===(t=e.connectedCallback)||void 0===t||t.call(e,{shadow:this._shadow,customElement:this}),null==i||null===(n=i.connectedCallback)||void 0===n||n.call(i,this._widget,{shadow:this._shadow,customElement:this})}},{key:"disconnectedCallback",value:function(){var e,t,n;null===(e=this._widget)||void 0===e||null===(t=e.disconnectedCallback)||void 0===t||t.call(e,{shadow:this._shadow,customElement:this}),null==i||null===(n=i.disconnectedCallback)||void 0===n||n.call(i,this._widget,{shadow:this._shadow,customElement:this})}},{key:"adoptedCallback",value:function(){var e,t,n;null===(e=this._widget)||void 0===e||null===(t=e.adoptedCallback)||void 0===t||t.call(e,{shadow:this._shadow,customElement:this}),null==i||null===(n=i.adoptedCallback)||void 0===n||n.call(i,this._widget,{shadow:this._shadow,customElement:this})}},{key:"attributeChangedCallback",value:function(e,t,n){var o,r,l;null===(o=this._widget)||void 0===o||null===(r=o.attributeChangedCallback)||void 0===r||r.call(o,this._widget,e,t,n,{shadow:this._shadow,customElement:this}),null==i||null===(l=i.attributeChangedCallback)||void 0===l||l.call(i,this._widget,e,t,n,{shadow:this._shadow,customElement:this})}}])}(a(HTMLElement));void 0===customElements.get(r.name)&&customElements.define(r.name,l)};var v=["__proto__","prototype","constructor"];function b(e,t){var n=function(e){return!!e&&e.constructor===Object};return n(e)&&n(t)?(Object.keys(t).forEach((function(o){if(!v.includes(o)){var r=e[o],i=t[o];Array.isArray(r)&&Array.isArray(i)?e[o]=r.concat(i):n(r)&&n(i)?e[o]=b(Object.assign({},r),i):e[o]=i}})),e):t}}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@merkur/integration-custom-element",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.1",
|
|
4
4
|
"description": "Merkur module for easy integration with other apps with custom element.",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"module": "lib/index",
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
},
|
|
51
51
|
"homepage": "https://merkur.js.org/",
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@merkur/core": "^0.
|
|
54
|
-
"@merkur/integration": "^0.
|
|
53
|
+
"@merkur/core": "^0.36.0",
|
|
54
|
+
"@merkur/integration": "^0.36.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@merkur/core": "*",
|
|
58
58
|
"@merkur/integration": "*"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "aa04d6baa119e2d57a231b69e641aaaa918cf942"
|
|
61
61
|
}
|