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