@opencx/widget 4.0.61 → 5.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -1
- package/dist-embed/Chart.impl-BnzKZLOH-Cj2mYp2H.js +68 -0
- package/dist-embed/script.js +1 -381
- package/dist-embed/widget.js +833 -0
- package/package.json +10 -9
- package/dist-embed/script.js.map +0 -1
package/README.md
CHANGED
|
@@ -2,4 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
The default React widget. Embeddable in HTML.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
```html
|
|
6
|
+
<script src="https://unpkg.com/@opencx/widget@latest/dist-embed/script.js"></script>
|
|
7
|
+
<script>
|
|
8
|
+
window.addEventListener('DOMContentLoaded', () => {
|
|
9
|
+
initOpenScript({ token: 'YOUR_WIDGET_TOKEN' });
|
|
10
|
+
});
|
|
11
|
+
</script>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
For all the available options, check [the documentation](https://docs.open.cx/widget/getting-started).
|
|
15
|
+
|
|
16
|
+
## Self-hosting
|
|
17
|
+
|
|
18
|
+
Since v5 the embed is two files: `script.js` is a tiny classic loader that
|
|
19
|
+
injects `widget.js` as an ES module from the same directory, and `widget.js`
|
|
20
|
+
lazy-loads a few hashed chunks (the chart renderer, for one) from that
|
|
21
|
+
directory too. If you copy the build onto your own CDN:
|
|
22
|
+
|
|
23
|
+
- publish the WHOLE `dist-embed/` directory, not `script.js` alone;
|
|
24
|
+
- serve it with `Access-Control-Allow-Origin` (module scripts are fetched in
|
|
25
|
+
CORS mode);
|
|
26
|
+
- keep the previous chunks around when you redeploy, or give `widget.js` a
|
|
27
|
+
short cache TTL, so a cached `widget.js` never points at a chunk that no
|
|
28
|
+
longer exists;
|
|
29
|
+
- under a nonce-based CSP, the loader copies the nonce from its own `<script>`
|
|
30
|
+
tag onto the injected module tag.
|