@takazudo/zdtp 0.4.9 → 0.4.10

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.
@@ -1,6 +1,6 @@
1
1
  import { jsx as y, jsxs as K, Fragment as kt } from "preact/jsx-runtime";
2
2
  import { useEffect as P, useState as Y, useRef as O, useMemo as J, useCallback as X } from "preact/hooks";
3
- import { b as ft, p as wt, u as ht, a as Ne, A as bt, Z as gt } from "./index-t74PT2zd.js";
3
+ import { b as ft, p as wt, u as ht, a as Ne, A as bt, Z as gt } from "./index-C5_Z29Nr.js";
4
4
  import { g as vt, m as j } from "./panel-config-BNLlUc_r.js";
5
5
  const xt = (e, o) => {
6
6
  const t = new Array(e.length + o.length);
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import "preact/jsx-runtime";
2
2
  import "preact";
3
- import { S as i, c as t, d as n, _ as l, e as d, f as _, g, h as p, i as P, j as m, k as A, l as C, m as u, n as c, o as f, q as K, r as M, s as T, t as v, v as S, w as E, x as h } from "./index-t74PT2zd.js";
3
+ import { S as i, c as t, d as n, _ as l, e as d, f as _, g, h as p, i as P, j as m, k as A, l as C, m as u, n as c, o as f, q as K, r as M, s as T, t as v, v as S, w as E, x as h } from "./index-C5_Z29Nr.js";
4
4
  import { Z as D, U as k, v as y, u as F, X as H } from "./tweak-state-Dti6XMoQ.js";
5
5
  import { c as b, s as w } from "./panel-config-BNLlUc_r.js";
6
- import "./autoload-state-CFmRjtD-.js";
6
+ import "./autoload-state-CEkOpbGS.js";
7
7
  export {
8
8
  i as SCHEMA_V1,
9
9
  t as SCHEMA_V2,
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Liveness probes for the global `document`.
3
+ *
4
+ * Why these exist (zudolab/zudo-doc#3344): the panel's deferred surfaces —
5
+ * dynamic-import continuations in the Astro host adapter, host code calling
6
+ * the public API right after `await import('@takazudo/zdtp')` resolves, and
7
+ * Preact's rAF/setTimeout effect flush — can resume AFTER the environment
8
+ * that scheduled them is gone. Under vitest, the jsdom environment is torn
9
+ * down (or swapped for the next test file) while such a continuation is
10
+ * still in flight; the global `document` then either disappears or is
11
+ * replaced by a non-Document stub, and a late `document.getElementById(...)`
12
+ * throws `TypeError: document.getElementById is not a function` — surfacing
13
+ * as an unhandled rejection in the downstream test run.
14
+ *
15
+ * In a real browser the page's document outlives every continuation
16
+ * scheduled from it, so both probes are inert there (always true): the
17
+ * guards only change behavior in torn-down / swapped-environment states
18
+ * where the alternative is a crash.
19
+ */
20
+ /**
21
+ * True when the global `document` exists and behaves like a live Document.
22
+ * `getElementById` doubles as the canary: it is the first DOM call the
23
+ * panel's mount/lookup paths make, and the exact method the downstream
24
+ * teardown crash reported missing.
25
+ *
26
+ * The explicit `document !== null` operand is load-bearing: `typeof null` is
27
+ * `'object'`, so a teardown that nulls the global (`globalThis.document =
28
+ * null`) sails past the `typeof` check and the `getElementById` probe then
29
+ * dereferences null — throwing the exact TypeError this helper prevents.
30
+ */
31
+ export declare function isDocumentUsable(): boolean;
32
+ /**
33
+ * Null-safe snapshot of the global `document` for later identity comparison.
34
+ * A bare `const doc = document` would throw a ReferenceError when the global
35
+ * has already been deleted (teardown completed before the async surface was
36
+ * even entered) — and inside an async function that ReferenceError becomes
37
+ * the very unhandled rejection these helpers exist to prevent.
38
+ *
39
+ * A nulled global (`globalThis.document = null`) is captured as `null` too,
40
+ * not as a "captured document" — `isSameUsableDocument(null)` is false, so a
41
+ * continuation entered during that teardown shape cancels rather than
42
+ * matching a null global against a null capture.
43
+ */
44
+ export declare function captureDocument(): Document | null;
45
+ /**
46
+ * True when the global `document` is still the SAME live document captured
47
+ * when an async surface was entered. Checked after `await` boundaries: a
48
+ * mismatch means the environment was torn down or swapped mid-flight, and
49
+ * the continuation must cancel itself instead of driving a document it does
50
+ * not own — even a fully-functional replacement document belongs to someone
51
+ * else (the next test file's environment, a new page).
52
+ */
53
+ export declare function isSameUsableDocument(owningDoc: Document | null): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takazudo/zdtp",
3
- "version": "0.4.9",
3
+ "version": "0.4.10",
4
4
  "description": "Dynamic design-token tweak panel — host-config-driven, framework-agnostic Preact UI.",
5
5
  "private": false,
6
6
  "license": "MIT",
@@ -1,64 +0,0 @@
1
- import { g as t, l as o } from "./panel-config-BNLlUc_r.js";
2
- function n(e = t()) {
3
- return `${e.storagePrefix}-elpath-enabled`;
4
- }
5
- function c(e = t()) {
6
- try {
7
- return localStorage.getItem(n(e)) === "1";
8
- } catch {
9
- return !1;
10
- }
11
- }
12
- function d(e, a = t()) {
13
- try {
14
- localStorage.setItem(n(a), e ? "1" : "0");
15
- } catch {
16
- }
17
- }
18
- function r(e = t()) {
19
- return `${e.storagePrefix}-domtweaker-enabled`;
20
- }
21
- function u(e = t()) {
22
- try {
23
- return localStorage.getItem(r(e)) === "1";
24
- } catch {
25
- return !1;
26
- }
27
- }
28
- function f(e, a = t()) {
29
- try {
30
- localStorage.setItem(r(a), e ? "1" : "0");
31
- } catch {
32
- }
33
- }
34
- function s(e) {
35
- if (typeof window > "u") return !1;
36
- try {
37
- return window.localStorage.getItem(o(e)) === "1";
38
- } catch {
39
- return !1;
40
- }
41
- }
42
- function i(e, a) {
43
- if (!(typeof window > "u"))
44
- try {
45
- window.localStorage.setItem(o(e), a ? "1" : "0");
46
- } catch {
47
- }
48
- }
49
- function g(e) {
50
- if (!(typeof window > "u"))
51
- try {
52
- window.localStorage.removeItem(o(e));
53
- } catch {
54
- }
55
- }
56
- export {
57
- u as a,
58
- i as b,
59
- g as c,
60
- d,
61
- f as e,
62
- c as l,
63
- s
64
- };