@pixelmatters/markup 1.6.1 → 1.6.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/README.md CHANGED
@@ -35,9 +35,9 @@ CDN drop-in (no build step) — paste this just before `</body>`:
35
35
  ```html
36
36
  <script type="module">
37
37
  // Pin the exact version — esm.sh resolves it from npm
38
- import { init } from 'https://esm.sh/@pixelmatters/markup@1.6.1'
38
+ import { init } from 'https://esm.sh/@pixelmatters/markup@1.6.2'
39
39
  // or
40
- // import { init } from 'https://esm.run/@pixelmatters/markup@1.6.1'
40
+ // import { init } from 'https://esm.run/@pixelmatters/markup@1.6.2'
41
41
 
42
42
  init({
43
43
  apiUrl: 'https://your-deployment.convex.site',
@@ -49,14 +49,14 @@ CDN drop-in (no build step) — paste this just before `</body>`:
49
49
  </script>
50
50
  ```
51
51
 
52
- > **Why pin the version?** CDN URLs without a version (`@pixelmatters/markup`) resolve to whatever's `latest` on npm — a future major release will break your page silently. Always pin (`@pixelmatters/markup@1.6.1`).
52
+ > **Why pin the version?** CDN URLs without a version (`@pixelmatters/markup`) resolve to whatever's `latest` on npm — a future major release will break your page silently. Always pin (`@pixelmatters/markup@1.6.2`).
53
53
 
54
54
  If your platform doesn't allow inline JS (some CMS / page-builder editors), use the auto-init form instead — point a `<script src=…>` at the bundle and pass config via `data-*` attributes:
55
55
 
56
56
  ```html
57
57
  <script
58
58
  type="module"
59
- src="https://esm.sh/@pixelmatters/markup@1.6.1"
59
+ src="https://esm.sh/@pixelmatters/markup@1.6.2"
60
60
  data-markup-widget="true"
61
61
  data-api-url="https://your-deployment.convex.site"
62
62
  data-api-key="markup_..."
@@ -278,7 +278,7 @@ For a `<script>` tag drop-in (no bundler), use the inline ESM form and **pin the
278
278
 
279
279
  ```html
280
280
  <script type="module">
281
- import { init } from 'https://esm.sh/@pixelmatters/markup@1.6.1'
281
+ import { init } from 'https://esm.sh/@pixelmatters/markup@1.6.2'
282
282
 
283
283
  init({
284
284
  apiUrl: '...',
@@ -295,7 +295,7 @@ If inline JS is disallowed (some CMS / page-builder editors), use the auto-init
295
295
  ```html
296
296
  <script
297
297
  type="module"
298
- src="https://esm.sh/@pixelmatters/markup@1.6.1"
298
+ src="https://esm.sh/@pixelmatters/markup@1.6.2"
299
299
  data-markup-widget="true"
300
300
  data-api-url="..."
301
301
  data-api-key="..."
package/dist/widget.js CHANGED
@@ -5309,20 +5309,28 @@ function po(e, t) {
5309
5309
  }
5310
5310
  //#endregion
5311
5311
  //#region src/widget.ts
5312
- var mo = null, ho = null;
5313
- function go(e) {
5312
+ var mo = null, ho = null, go = null;
5313
+ function _o(e) {
5314
5314
  if (!e.apiUrl || !e.apiKey) return console.warn("[markup] init() requires both apiUrl and apiKey — widget not mounted"), () => {};
5315
- _o();
5316
- let t = document.createElement("div");
5317
- return t.id = "markup-widget", document.body.appendChild(t), ho = t, mo = po(t, e), _o;
5315
+ vo();
5316
+ let t = () => {
5317
+ if (go = null, !document.body) return;
5318
+ let t = document.createElement("div");
5319
+ t.id = "markup-widget", document.body.appendChild(t), ho = t, mo = po(t, e);
5320
+ };
5321
+ if (document.readyState === "loading" || !document.body) {
5322
+ let e = () => t();
5323
+ go = () => document.removeEventListener("DOMContentLoaded", e), document.addEventListener("DOMContentLoaded", e, { once: !0 });
5324
+ } else t();
5325
+ return vo;
5318
5326
  }
5319
- function _o() {
5320
- mo &&= (mo(), null), ho?.parentNode && ho.parentNode.removeChild(ho), ho = null;
5327
+ function vo() {
5328
+ go &&= (go(), null), mo &&= (mo(), null), ho?.parentNode && ho.parentNode.removeChild(ho), ho = null;
5321
5329
  }
5322
5330
  if (typeof document < "u") {
5323
5331
  let e = document.currentScript ?? document.querySelector("script[data-markup-widget=\"true\"]"), t = e?.dataset.apiUrl, n = e?.dataset.apiKey;
5324
5332
  if (t && n) {
5325
- let r = e?.dataset.position, i = e?.dataset.theme, a = e?.dataset.fab, o = () => go({
5333
+ let r = e?.dataset.position, i = e?.dataset.theme, a = e?.dataset.fab, o = () => _o({
5326
5334
  apiUrl: t,
5327
5335
  apiKey: n,
5328
5336
  position: r,
@@ -5333,4 +5341,6 @@ if (typeof document < "u") {
5333
5341
  }
5334
5342
  }
5335
5343
  //#endregion
5336
- export { _o as destroy, go as init };
5344
+ export { vo as destroy, _o as init };
5345
+
5346
+ //# sourceMappingURL=widget.js.map