@reticular/speakable 1.5.0 → 1.7.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.
@@ -0,0 +1,86 @@
1
+ // ../src/browser/upgrade.ts
2
+ var DEFAULT_UPGRADE_TIMEOUT_MS = 2e3;
3
+ function withTimeout(promise, timeoutMs) {
4
+ return new Promise((resolve) => {
5
+ let settled = false;
6
+ const timer = setTimeout(() => {
7
+ if (!settled) {
8
+ settled = true;
9
+ resolve(false);
10
+ }
11
+ }, timeoutMs);
12
+ promise.then(
13
+ () => {
14
+ if (!settled) {
15
+ settled = true;
16
+ clearTimeout(timer);
17
+ resolve(true);
18
+ }
19
+ },
20
+ () => {
21
+ if (!settled) {
22
+ settled = true;
23
+ clearTimeout(timer);
24
+ resolve(true);
25
+ }
26
+ }
27
+ );
28
+ });
29
+ }
30
+ function collectCustomElementTags(root) {
31
+ const tags = /* @__PURE__ */ new Set();
32
+ const rootEl = "documentElement" in root ? root.documentElement : root;
33
+ if (!rootEl) return [];
34
+ const consider = (el) => {
35
+ if (el.localName && el.localName.includes("-")) {
36
+ tags.add(el.localName);
37
+ }
38
+ };
39
+ consider(rootEl);
40
+ const all = rootEl.querySelectorAll("*");
41
+ all.forEach(consider);
42
+ return Array.from(tags);
43
+ }
44
+ function collectUpdateCompletables(root) {
45
+ const rootEl = "documentElement" in root ? root.documentElement : root;
46
+ if (!rootEl) return [];
47
+ const promises = [];
48
+ const consider = (el) => {
49
+ const uc = el.updateComplete;
50
+ if (uc && typeof uc.then === "function") {
51
+ promises.push(uc);
52
+ }
53
+ };
54
+ consider(rootEl);
55
+ rootEl.querySelectorAll("*").forEach(consider);
56
+ return promises;
57
+ }
58
+ async function awaitCustomElementsReady(root, timeoutMs = DEFAULT_UPGRADE_TIMEOUT_MS) {
59
+ const warnings = [];
60
+ const hasCustomElements = typeof customElements !== "undefined" && customElements !== null;
61
+ if (!hasCustomElements) {
62
+ return warnings;
63
+ }
64
+ const tags = collectCustomElementTags(root);
65
+ await Promise.all(
66
+ tags.map(async (tag) => {
67
+ if (customElements.get(tag)) return;
68
+ const defined = await withTimeout(customElements.whenDefined(tag), timeoutMs);
69
+ if (!defined) {
70
+ warnings.push({
71
+ tag,
72
+ message: `Custom element "${tag}" did not upgrade within ${timeoutMs}ms; analysis may reflect a pre-hydration state.`
73
+ });
74
+ }
75
+ })
76
+ );
77
+ const updateCompletables = collectUpdateCompletables(root);
78
+ if (updateCompletables.length > 0) {
79
+ await withTimeout(Promise.all(updateCompletables), timeoutMs);
80
+ }
81
+ return warnings;
82
+ }
83
+
84
+ export {
85
+ awaitCustomElementsReady
86
+ };
@@ -0,0 +1,30 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
27
+ export {
28
+ __commonJS,
29
+ __toESM
30
+ };
@@ -0,0 +1,16 @@
1
+ // src/index.ts
2
+ var ADDON_ID = "speakable";
3
+ var PANEL_ID = `${ADDON_ID}/panel`;
4
+ var EVENT_RENDER = `${ADDON_ID}/render`;
5
+ var EVENT_RESULT = `${ADDON_ID}/result`;
6
+ var EVENT_TIMELINE = `${ADDON_ID}/timeline`;
7
+ var EVENT_DIFF = `${ADDON_ID}/diff`;
8
+
9
+ export {
10
+ ADDON_ID,
11
+ PANEL_ID,
12
+ EVENT_RENDER,
13
+ EVENT_RESULT,
14
+ EVENT_TIMELINE,
15
+ EVENT_DIFF
16
+ };
@@ -0,0 +1,17 @@
1
+ import {
2
+ ADDON_ID,
3
+ EVENT_DIFF,
4
+ EVENT_RENDER,
5
+ EVENT_RESULT,
6
+ EVENT_TIMELINE,
7
+ PANEL_ID
8
+ } from "./chunk-QVJRQZT5.js";
9
+ import "./chunk-JSBRDJBE.js";
10
+ export {
11
+ ADDON_ID,
12
+ EVENT_DIFF,
13
+ EVENT_RENDER,
14
+ EVENT_RESULT,
15
+ EVENT_TIMELINE,
16
+ PANEL_ID
17
+ };