@financial-times/custom-code-component 1.9.0 → 1.9.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/dist/custom-code-component.js +12 -21
- package/package.json +1 -1
- package/src/custom-code-component.ts +14 -25
|
@@ -12,9 +12,6 @@ class d extends HTMLElement {
|
|
|
12
12
|
]), this.unmount = (t) => {
|
|
13
13
|
}, this.channel = new MessageChannel();
|
|
14
14
|
}
|
|
15
|
-
static get observedAttributes() {
|
|
16
|
-
return ["path", "version", "env", "data-component-props"];
|
|
17
|
-
}
|
|
18
15
|
async mount() {
|
|
19
16
|
var c;
|
|
20
17
|
if (!this.app)
|
|
@@ -42,21 +39,18 @@ class d extends HTMLElement {
|
|
|
42
39
|
this.source = u ? `http://localhost:5173/src/${o}/index.jsx` : `https://www.ft.com/__component/${c}/${r}${e ? `@${e}` : "@latest"}/${o}/${o}.js`;
|
|
43
40
|
try {
|
|
44
41
|
this.app = await new Promise((n, m) => {
|
|
45
|
-
const p = setTimeout(
|
|
46
|
-
(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
Number(h)
|
|
59
|
-
);
|
|
42
|
+
const p = setTimeout(() => {
|
|
43
|
+
this.dispatchEvent(
|
|
44
|
+
new CustomEvent("ccc-timeout", {
|
|
45
|
+
bubbles: !0,
|
|
46
|
+
cancelable: !0,
|
|
47
|
+
detail: {
|
|
48
|
+
component: `${t}@${e}`,
|
|
49
|
+
source: this.source
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
), this.dataset.cccError = "import-timeout", delete this.dataset.cccReady;
|
|
53
|
+
}, Number(h));
|
|
60
54
|
import(
|
|
61
55
|
/* webpackIgnore: true */
|
|
62
56
|
this.source
|
|
@@ -94,9 +88,6 @@ class d extends HTMLElement {
|
|
|
94
88
|
}
|
|
95
89
|
}
|
|
96
90
|
}
|
|
97
|
-
attributeChangedCallback() {
|
|
98
|
-
this.mount();
|
|
99
|
-
}
|
|
100
91
|
disconnectedCallback() {
|
|
101
92
|
const t = this.getAttribute("path");
|
|
102
93
|
console.info(`<custom-code-component:${t}> disconnected`), typeof this.unmount == "function" && this.unmount();
|
package/package.json
CHANGED
|
@@ -21,10 +21,6 @@ class FTCustomCodeComponent extends HTMLElement {
|
|
|
21
21
|
"load-timeout",
|
|
22
22
|
]);
|
|
23
23
|
|
|
24
|
-
static get observedAttributes() {
|
|
25
|
-
return ["path", "version", "env", "data-component-props"];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
24
|
source: string;
|
|
29
25
|
|
|
30
26
|
async mount() {
|
|
@@ -87,23 +83,20 @@ class FTCustomCodeComponent extends HTMLElement {
|
|
|
87
83
|
|
|
88
84
|
try {
|
|
89
85
|
this.app = await new Promise((resolve, reject) => {
|
|
90
|
-
const to = setTimeout(
|
|
91
|
-
(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
},
|
|
105
|
-
Number(timeout)
|
|
106
|
-
);
|
|
86
|
+
const to = setTimeout(() => {
|
|
87
|
+
this.dispatchEvent(
|
|
88
|
+
new CustomEvent("ccc-timeout", {
|
|
89
|
+
bubbles: true,
|
|
90
|
+
cancelable: true,
|
|
91
|
+
detail: {
|
|
92
|
+
component: `${path}@${componentVersionRange}`,
|
|
93
|
+
source: this.source,
|
|
94
|
+
},
|
|
95
|
+
})
|
|
96
|
+
);
|
|
97
|
+
this.dataset.cccError = "import-timeout";
|
|
98
|
+
delete this.dataset.cccReady;
|
|
99
|
+
}, Number(timeout));
|
|
107
100
|
import(/* webpackIgnore: true */ this.source /* @vite-ignore */)
|
|
108
101
|
.then(({ default: componentRenderFunction }) => {
|
|
109
102
|
if (componentRenderFunction) {
|
|
@@ -162,10 +155,6 @@ class FTCustomCodeComponent extends HTMLElement {
|
|
|
162
155
|
}
|
|
163
156
|
}
|
|
164
157
|
|
|
165
|
-
attributeChangedCallback() {
|
|
166
|
-
this.mount();
|
|
167
|
-
}
|
|
168
|
-
|
|
169
158
|
disconnectedCallback() {
|
|
170
159
|
const path = this.getAttribute("path");
|
|
171
160
|
console.info(`<custom-code-component:${path}> disconnected`);
|