@levo-so/site-runtime 0.1.113 → 0.2.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.
Files changed (40) hide show
  1. package/CollectionInput-5QMoXahu.js +147 -0
  2. package/DateTimeWidget-CARoq7bQ.js +254 -0
  3. package/PhoneWidget-vtDO9CFq.js +99 -0
  4. package/Popover-B76-bN-a.js +57 -0
  5. package/RichTextWidget-CafZBEKI.js +912 -0
  6. package/ThemeProvider-Cm2jJC7a.js +381 -0
  7. package/Tooltip-Bx-BfR7T.js +78 -0
  8. package/VerifyButton-D1Mwk04d.js +299 -0
  9. package/index.d.ts +674 -0
  10. package/index.js +5752 -0
  11. package/package.json +63 -31
  12. package/styles.css +2 -0
  13. package/README.md +0 -93
  14. package/dist/LevoSiteProvider.d.ts +0 -25
  15. package/dist/LevoSiteProvider.js +0 -23
  16. package/dist/client.d.ts +0 -26
  17. package/dist/client.js +0 -14
  18. package/dist/data/index.d.ts +0 -101
  19. package/dist/data/index.js +0 -79
  20. package/dist/index.d.ts +0 -26
  21. package/dist/index.js +0 -6
  22. package/dist/inspector/dom.d.ts +0 -56
  23. package/dist/inspector/dom.js +0 -224
  24. package/dist/inspector/editorChannel.d.ts +0 -7
  25. package/dist/inspector/editorChannel.js +0 -19
  26. package/dist/inspector/historyWatcher.d.ts +0 -8
  27. package/dist/inspector/historyWatcher.js +0 -24
  28. package/dist/inspector/index.d.ts +0 -2
  29. package/dist/inspector/index.js +0 -191
  30. package/dist/inspector/messageRouter.d.ts +0 -38
  31. package/dist/inspector/messageRouter.js +0 -134
  32. package/dist/inspector/originalsStash.d.ts +0 -12
  33. package/dist/inspector/originalsStash.js +0 -24
  34. package/dist/inspector/protocol.d.ts +0 -180
  35. package/dist/inspector/stagedOverrides.d.ts +0 -28
  36. package/dist/inspector/stagedOverrides.js +0 -60
  37. package/dist/inspector/textEditController.d.ts +0 -24
  38. package/dist/inspector/textEditController.js +0 -62
  39. package/dist/pageHead.d.ts +0 -75
  40. package/dist/pageHead.js +0 -102
@@ -1,101 +0,0 @@
1
- import { LevoQuery } from '@levo-so/core';
2
- import { ILevoSiteConfig } from '../client';
3
- /**
4
- * The minimal QueryClient surface `prefetchLevoSources` needs. Structural on purpose — a
5
- * branded `QueryClient` type in the public API would clash whenever the consuming site
6
- * resolves a different `@tanstack/react-query` copy/version than the one this package was
7
- * built against (peer dep). Any real QueryClient satisfies this.
8
- */
9
- export interface IQueryClientLike {
10
- ensureQueryData: (options: {
11
- queryKey: readonly unknown[];
12
- queryFn: () => Promise<unknown>;
13
- }) => Promise<unknown>;
14
- }
15
- /** A list binding — collection records or blog posts matching `query`. */
16
- export interface ILevoSourceConfig {
17
- /** Only "collection" | "blog" today — the core client has no event/community module. */
18
- module: "collection" | "blog";
19
- /** Collection key / blog key. */
20
- identifier: string;
21
- /** where / sort / limit / page / search. `limit: -1` = all. */
22
- query?: LevoQuery.FindQuery;
23
- /** Reserved (blog sub-module identifiers etc.); round-tripped through the binding. */
24
- options?: Record<string, unknown>;
25
- }
26
- export interface ILevoSourceResult<T = Record<string, unknown>> {
27
- /** null until loaded, on error, and on an unwired site. */
28
- data: T[] | null;
29
- meta: {
30
- total: number;
31
- pages: number;
32
- } | null;
33
- isLoading: boolean;
34
- error: string | null;
35
- /** Spread onto the container that renders the list — stamps the editor binding. */
36
- bind: {
37
- "data-levo-source": string;
38
- };
39
- }
40
- /** A single-record binding — one collection record / blog post by `slug` (a detail page). */
41
- export interface ILevoRecordConfig {
42
- module: "collection" | "blog";
43
- identifier: string;
44
- /**
45
- * Reserved for field projection. The slug endpoints return the whole record today, so
46
- * this is round-tripped through the binding but not yet sent to the API.
47
- */
48
- query?: Pick<LevoQuery.FindQuery, "select" | "include">;
49
- }
50
- export interface ILevoRecordResult<T = Record<string, unknown>> {
51
- data: T | null;
52
- isLoading: boolean;
53
- error: string | null;
54
- bind: {
55
- "data-levo-source": string;
56
- };
57
- }
58
- /**
59
- * One entry in a page's `dataSources` export — a list or record binding, discriminated by
60
- * `mode`. The route loader reads these to prefetch; the page passes each to its hook. `mode`
61
- * is optional for lists (the default) and required for records (so the loader knows to use
62
- * the route slug).
63
- */
64
- export type ILevoSourceDef = (ILevoSourceConfig & {
65
- mode?: "list";
66
- }) | (ILevoRecordConfig & {
67
- mode: "record";
68
- });
69
- /** The shape a page exports so its route loader can prefetch every binding it renders. */
70
- export type ILevoDataSources = Record<string, ILevoSourceDef>;
71
- /**
72
- * Render a LIST of platform content. The config is a static literal (the editor rewrites
73
- * it). Reads the router QueryClient: if the route loader prefetched this binding, the first
74
- * render has data (SSR ships it); otherwise it fetches client-side. Always render a loading
75
- * and an empty state — `data` is null before the first load and on unwired sites.
76
- */
77
- export declare const useLevoSource: <T = Record<string, unknown>>(config: ILevoSourceConfig) => ILevoSourceResult<T>;
78
- /**
79
- * Render ONE record by slug — a detail page. `slug` is a RUNTIME arg (the page's route
80
- * param), kept OUT of the config literal so the binding stays static and editable. No slug
81
- * (or unwired site) → inert. `data` null after load = not found: render a friendly fallback.
82
- */
83
- export declare const useLevoRecord: <T = Record<string, unknown>>(config: ILevoRecordConfig, slug: string | undefined) => ILevoRecordResult<T>;
84
- /**
85
- * Prefetch every binding a page declares into the router's QueryClient — call it (awaited)
86
- * from the route `loader` so SSR renders fully-populated HTML. Builds its own client from
87
- * the site config (loaders run outside React, so `useLevoSite` isn't available). Record
88
- * bindings pull their slug from the route `params` (`$slug`). Resilient: a single failed
89
- * source resolves to a cached error so it doesn't blank the whole page — the hook surfaces
90
- * that binding's error while the rest render.
91
- */
92
- export declare const prefetchLevoSources: ({ queryClient, config, sources, params, }: {
93
- queryClient: IQueryClientLike;
94
- /** Site env config — same object the LevoSiteProvider receives. */
95
- config: ILevoSiteConfig | undefined;
96
- /** The page's `dataSources` export (undefined = page has none). */
97
- sources: ILevoDataSources | undefined;
98
- /** Route params; record bindings read `params.slug`. */
99
- params?: Record<string, string>;
100
- }) => Promise<void>;
101
- //# sourceMappingURL=index.d.ts.map
@@ -1,79 +0,0 @@
1
- import { createSiteClient as e } from "../client.js";
2
- import { useLevoSite as t } from "../LevoSiteProvider.js";
3
- import { getLevoError as n } from "@levo-so/core";
4
- import { useQuery as r } from "@tanstack/react-query";
5
- //#region src/data/index.ts
6
- var i = (e) => [
7
- "levo-source",
8
- "list",
9
- e.module,
10
- e.identifier,
11
- e.query ?? null,
12
- e.options ?? null
13
- ], a = (e, t) => [
14
- "levo-source",
15
- "record",
16
- e.module,
17
- e.identifier,
18
- t ?? null
19
- ], o = async (e, t) => {
20
- let n = t.module === "collection" ? await e.collection.getCollectionContentList({
21
- collection_key: t.identifier,
22
- ...t.query ?? {}
23
- }) : await e.blog.getAllBlogs(t.identifier, t.query ?? {});
24
- return {
25
- data: n.content.data ?? [],
26
- meta: n.content.meta ?? null
27
- };
28
- }, s = async (e, t, n) => (t.module === "collection" ? await e.collection.getCollectionContent({
29
- collection_key: t.identifier,
30
- slug: n
31
- }) : await e.blog.getSingleBlog(t.identifier, n)).content.data ?? null, c = (e) => {
32
- let a = t(), s = r({
33
- queryKey: i(e),
34
- queryFn: () => o(a, e),
35
- enabled: !!a
36
- });
37
- return {
38
- data: s.data?.data ?? null,
39
- meta: s.data?.meta ?? null,
40
- isLoading: s.isLoading,
41
- error: s.error ? n(s.error).message : null,
42
- bind: { "data-levo-source": JSON.stringify({
43
- mode: "list",
44
- ...e
45
- }) }
46
- };
47
- }, l = (e, i) => {
48
- let o = t(), c = r({
49
- queryKey: a(e, i),
50
- queryFn: () => s(o, e, i),
51
- enabled: !!o && !!i
52
- });
53
- return {
54
- data: c.data ?? null,
55
- isLoading: c.isLoading,
56
- error: c.error ? n(c.error).message : null,
57
- bind: { "data-levo-source": JSON.stringify({
58
- mode: "record",
59
- ...e
60
- }) }
61
- };
62
- }, u = async ({ queryClient: t, config: n, sources: r, params: c }) => {
63
- let l = e(n);
64
- !l || !r || await Promise.all(Object.values(r).map((e) => {
65
- if (e.mode === "record") {
66
- let n = c?.slug;
67
- return n ? t.ensureQueryData({
68
- queryKey: a(e, n),
69
- queryFn: () => s(l, e, n)
70
- }).catch(() => void 0) : Promise.resolve();
71
- }
72
- return t.ensureQueryData({
73
- queryKey: i(e),
74
- queryFn: () => o(l, e)
75
- }).catch(() => void 0);
76
- }));
77
- };
78
- //#endregion
79
- export { u as prefetchLevoSources, l as useLevoRecord, c as useLevoSource };
package/dist/index.d.ts DELETED
@@ -1,26 +0,0 @@
1
- /**
2
- * @levo-so/site-runtime — everything that runs INSIDE a Levo Studio v3 site:
3
- *
4
- * - `Inspector` — the editor-preview element inspector (select / text-edit / staged
5
- * overrides / layers snapshot), driven by the dashboard over postMessage. Mounted by
6
- * the scaffold's `__root`; inert outside the editor preview (it only reacts to the
7
- * editor's messages).
8
- * - `PageHead` / `pageHead` — per-page document metadata composed from SEO-editor
9
- * sidecars + site defaults.
10
- * - `LevoSiteProvider` / `useLevoSite` — the Levo client (core-only), mounted from
11
- * `__root` via the scaffold's env-reading shim.
12
- * - the editor ↔ preview message contract types (`IEditorToPreview` / `IPreviewToEditor`).
13
- *
14
- * Sites import the package directly; the scaffold's single `src/lib/levo/provider.tsx`
15
- * shim exists only to read Vite env (not injected into packaged deps) into the provider.
16
- */
17
- export { createSiteClient } from './client';
18
- export type { ILevoDataSources, ILevoRecordConfig, ILevoRecordResult, ILevoSourceConfig, ILevoSourceDef, ILevoSourceResult, IQueryClientLike, } from './data';
19
- export { prefetchLevoSources, useLevoRecord, useLevoSource } from './data';
20
- export { Inspector } from './inspector';
21
- export type { IEditorToPreview, IElementLocator, IHistoryFn, ILayersNode, IPageSource, IPatchedHistoryFn, IPreviewToEditor, ISelectedElement, IStagedEntry, IStagedStyleEntry, IStagedTextEntry, ITextChangedElement, } from './inspector/protocol';
22
- export type { ILevoSiteConfig } from './LevoSiteProvider';
23
- export { LevoSiteProvider, useLevoInsights, useLevoSite } from './LevoSiteProvider';
24
- export type { IComposedHead, IPageMeta, ISiteMeta } from './pageHead';
25
- export { PageHead, pageHead, parseRawHead } from './pageHead';
26
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js DELETED
@@ -1,6 +0,0 @@
1
- import { createSiteClient as e } from "./client.js";
2
- import { LevoSiteProvider as t, useLevoInsights as n, useLevoSite as r } from "./LevoSiteProvider.js";
3
- import { prefetchLevoSources as i, useLevoRecord as a, useLevoSource as o } from "./data/index.js";
4
- import { Inspector as s } from "./inspector/index.js";
5
- import { PageHead as c, pageHead as l, parseRawHead as u } from "./pageHead.js";
6
- export { s as Inspector, t as LevoSiteProvider, c as PageHead, e as createSiteClient, l as pageHead, u as parseRawHead, i as prefetchLevoSources, n as useLevoInsights, a as useLevoRecord, r as useLevoSite, o as useLevoSource };
@@ -1,56 +0,0 @@
1
- import { ILayersNode, IPageSource, ISelectedElement, IStagedStyleEntry } from './protocol';
2
- export declare const Z: {
3
- readonly ring: 99997;
4
- readonly overlay: 99998;
5
- readonly label: 99999;
6
- };
7
- export declare const COLOR: {
8
- readonly hover: "#3b82f6";
9
- readonly hoverBg: "rgba(59,130,246,0.12)";
10
- readonly hoverLabelBg: "#1d4ed8";
11
- readonly select: "#16a34a";
12
- readonly selectGlow: "rgba(22,163,74,0.18)";
13
- };
14
- export declare const sourceOf: (el: Element | null) => string | null;
15
- export declare const nodesForSource: (src: string) => Element[];
16
- export declare const sourceIndex: (el: Element, src: string) => number;
17
- export declare const nodeForSource: (src: string, idx?: number) => Element | null;
18
- export declare const addStagedKey: (el: Element, stageId: string) => void;
19
- export declare const removeStagedKey: (el: Element, stageId: string) => void;
20
- export declare const cssRuleFor: (stageId: string, entry: IStagedStyleEntry) => string;
21
- /** Create the four overlay artifacts (hover box + label, selection ring + label). */
22
- export declare const createOverlayNodes: () => {
23
- overlay: HTMLDivElement;
24
- label: HTMLDivElement;
25
- ring: HTMLDivElement;
26
- ringLabel: HTMLDivElement;
27
- };
28
- /** Glue a box + its label to an element's viewport rect (shared by the hover overlay and
29
- * the selection ring — the label clamp + above/below flip live in one place). */
30
- export declare const positionBox: (box: HTMLElement, boxLabel: HTMLElement, el: Element) => void;
31
- export declare const externalLinkHref: (target: EventTarget | null) => string | null;
32
- export declare const isTextLeaf: (el: Element) => boolean;
33
- /**
34
- * Everything a selection report carries about `el` — shared by click-picks and the inbound
35
- * `select-element` command so both emit the identical element-selected shape. `fullText` is
36
- * present ONLY for a source-stamped text-leaf (so the editor never offers a text edit that
37
- * would destroy nested markup). The 120-slice `text` feeds labels, not the editor.
38
- */
39
- export declare const selectedPayload: (el: Element) => ISelectedElement;
40
- /**
41
- * Every `data-levo-source` binding container on the page — the reply to `request-sources`,
42
- * feeding the editor's page-level Data manager (a list of bindings without needing a
43
- * selection). Unlike `sourceBindingOf` (nearest ancestor of a clicked node), this enumerates
44
- * the containers themselves. Binding containers are few (one per bound region), so the
45
- * per-container `sourceIndex` re-query is cheap — no layers-tree-style single-pass needed.
46
- */
47
- export declare const enumerateSources: () => IPageSource[];
48
- /**
49
- * Snapshot the live DOM for the editor's Layers panel. Pure pull — no observers, no pushes.
50
- * `ownNodes` are the runtime's overlay artifacts to skip.
51
- */
52
- export declare const buildLayersTree: (ownNodes: readonly Element[]) => {
53
- tree: ILayersNode;
54
- truncated: boolean;
55
- };
56
- //# sourceMappingURL=dom.d.ts.map
@@ -1,224 +0,0 @@
1
- //#region src/inspector/dom.ts
2
- var e = {
3
- ring: 99997,
4
- overlay: 99998,
5
- label: 99999
6
- }, t = {
7
- hover: "#3b82f6",
8
- hoverBg: "rgba(59,130,246,0.12)",
9
- hoverLabelBg: "#1d4ed8",
10
- select: "#16a34a",
11
- selectGlow: "rgba(22,163,74,0.18)"
12
- }, n = (e) => {
13
- let t = e?.getAttribute("data-tsd-source");
14
- return t ? t.replace(/^\//, "") : null;
15
- }, r = (e) => Array.from(document.querySelectorAll("[data-tsd-source]")).filter((t) => n(t) === e), i = (e, t) => {
16
- let n = r(t).indexOf(e);
17
- return n < 0 ? 0 : n;
18
- }, a = (e, t = 0) => {
19
- let n = r(e);
20
- return n[t] ?? n[0] ?? null;
21
- }, o = (e, t) => {
22
- let n = (e.getAttribute("data-staged-key") || "").split(/\s+/).filter(Boolean);
23
- n.includes(t) || e.setAttribute("data-staged-key", [...n, t].join(" "));
24
- }, s = (e, t) => {
25
- let n = (e.getAttribute("data-staged-key") || "").split(/\s+/).filter((e) => e && e !== t);
26
- n.length ? e.setAttribute("data-staged-key", n.join(" ")) : e.removeAttribute("data-staged-key");
27
- }, c = (e, t) => {
28
- let n = Object.entries(t.styles).filter(([e]) => /^-?[a-zA-Z][a-zA-Z0-9-]*$/.test(e)).map(([e, t]) => `${e}:${String(t).replace(/[;{}]/g, "")} !important;`).join("");
29
- if (!n) return "";
30
- let r = `[data-staged-key~="${CSS.escape(e)}"]{${n}}`, i = t.media?.replace(/[;{}]/g, "").trim();
31
- return i ? `@media ${i}{${r}}` : r;
32
- }, l = (e) => {
33
- let t = e.tagName.toLowerCase();
34
- return t === "input" ? {
35
- checkbox: "Checkbox",
36
- radio: "Radio button",
37
- submit: "Button",
38
- button: "Button",
39
- range: "Slider",
40
- file: "File upload"
41
- }[(e.getAttribute("type") || "text").toLowerCase()] || "Input" : {
42
- a: "Link",
43
- button: "Button",
44
- img: "Image",
45
- picture: "Image",
46
- svg: "Icon",
47
- h1: "Heading",
48
- h2: "Heading",
49
- h3: "Heading",
50
- h4: "Heading",
51
- h5: "Heading",
52
- h6: "Heading",
53
- p: "Text",
54
- span: "Text",
55
- strong: "Text",
56
- em: "Text",
57
- ul: "List",
58
- ol: "List",
59
- li: "List item",
60
- nav: "Navigation",
61
- header: "Header",
62
- footer: "Footer",
63
- form: "Form",
64
- label: "Label",
65
- select: "Dropdown",
66
- textarea: "Text field",
67
- video: "Video",
68
- section: "Section",
69
- article: "Article",
70
- main: "Section",
71
- aside: "Sidebar",
72
- div: "Container"
73
- }[t] || `${t.charAt(0).toUpperCase()}${t.slice(1)}`;
74
- }, u = 36, d = (e) => {
75
- let t = l(e), n = ((e) => e.replace(/\s+/g, " ").trim())(e.getAttribute("aria-label") || e.getAttribute("alt") || e.getAttribute("title") || e.getAttribute("name") || "");
76
- return n ? `${t} · ${n.length > u ? `${n.slice(0, u - 1).trimEnd()}…` : n}` : t;
77
- }, f = (e) => {
78
- let t = [], n = e;
79
- for (; n && n.nodeType === 1 && n !== document.body && t.length < 8;) t.unshift(n.tagName.toLowerCase()), n = n.parentElement;
80
- return t.join(" > ");
81
- }, p = () => {
82
- let n = document.createElement("div");
83
- n.style.cssText = `position:fixed;pointer-events:none;z-index:${e.overlay};background:${t.hoverBg};outline:2px solid ${t.hover};border-radius:2px;display:none`;
84
- let r = document.createElement("div");
85
- r.style.cssText = `position:fixed;pointer-events:none;z-index:${e.label};background:${t.hoverLabelBg};color:#fff;font:11px/1.6 ui-monospace,monospace;padding:1px 6px;border-radius:4px;display:none;max-width:70vw;white-space:nowrap;overflow:hidden;text-overflow:ellipsis`;
86
- let i = document.createElement("div");
87
- i.style.cssText = `position:fixed;pointer-events:none;z-index:${e.ring};outline:2px solid ${t.select};outline-offset:1px;border-radius:3px;box-shadow:0 0 0 4px ${t.selectGlow};display:none`;
88
- let a = document.createElement("div");
89
- return a.style.cssText = `position:fixed;pointer-events:none;z-index:${e.label};background:${t.select};color:#fff;font:11px/1.6 ui-monospace,monospace;padding:1px 6px;border-radius:4px;display:none;max-width:70vw;white-space:nowrap;overflow:hidden;text-overflow:ellipsis`, {
90
- overlay: n,
91
- label: r,
92
- ring: i,
93
- ringLabel: a
94
- };
95
- }, m = (e, t, n) => {
96
- let r = n.getBoundingClientRect();
97
- e.style.display = "block", e.style.left = `${r.left}px`, e.style.top = `${r.top}px`, e.style.width = `${r.width}px`, e.style.height = `${r.height}px`, t.style.display = "block", t.textContent = d(n), t.style.left = `${Math.max(4, r.left)}px`, t.style.top = `${r.top > 26 ? r.top - 22 : r.bottom + 4}px`;
98
- }, h = (e) => {
99
- let t = (e instanceof Element ? e : null)?.closest("a[href]");
100
- if (!t || t.target === "_blank") return null;
101
- let n;
102
- try {
103
- n = new URL(t.href, location.href);
104
- } catch {
105
- return null;
106
- }
107
- return n.protocol !== "http:" && n.protocol !== "https:" || n.origin === location.origin ? null : n.href;
108
- }, g = (e) => {
109
- if (!e.childNodes.length) return !1;
110
- let t = !1;
111
- for (let n of e.childNodes) {
112
- if (n.nodeType !== 3) return !1;
113
- (n.textContent ?? "").trim() && (t = !0);
114
- }
115
- return t;
116
- }, _ = 2e3, v = (e) => {
117
- let t = [], r = e;
118
- for (; r && r.nodeType === 1 && r !== document.body && t.length < 8;) {
119
- let e = n(r);
120
- e && t.unshift({
121
- tag: r.tagName.toLowerCase(),
122
- text: (r.textContent || "").trim().slice(0, 60),
123
- source: e
124
- }), r = r.parentElement;
125
- }
126
- return t;
127
- }, y = (e) => {
128
- let t = n(e), a = t ? r(t).length : 1, o = t ? i(e, t) : 0, s = t && g(e) ? (e.textContent ?? "").replace(/\s+/g, " ").trim().slice(0, _) : void 0, c = b(e);
129
- return {
130
- tag: e.tagName.toLowerCase(),
131
- classes: typeof e.className == "string" ? e.className.trim() : "",
132
- text: (e.innerText || "").trim().slice(0, 120),
133
- label: d(e),
134
- path: f(e),
135
- source: t,
136
- index: o,
137
- occurrences: a,
138
- ancestors: v(e),
139
- ...s === void 0 ? {} : { fullText: s },
140
- ...c ? { sourceBinding: c } : {}
141
- };
142
- }, b = (e) => {
143
- let t = e.closest("[data-levo-source]");
144
- if (!t) return;
145
- let r = t.getAttribute("data-levo-source") ?? "", a = n(t), o;
146
- try {
147
- o = JSON.parse(r);
148
- } catch {
149
- o = void 0;
150
- }
151
- return {
152
- raw: r,
153
- element: {
154
- source: a ?? "",
155
- index: a ? i(t, a) : 0
156
- },
157
- ...o === void 0 ? {} : { config: o }
158
- };
159
- }, x = () => Array.from(document.querySelectorAll("[data-levo-source]")).map((e) => {
160
- let t = e.getAttribute("data-levo-source") ?? "", r = n(e), a;
161
- try {
162
- a = JSON.parse(t);
163
- } catch {
164
- a = void 0;
165
- }
166
- return {
167
- raw: t,
168
- element: {
169
- source: r ?? "",
170
- index: r ? i(e, r) : 0
171
- },
172
- tag: e.tagName.toLowerCase(),
173
- label: d(e),
174
- ...a === void 0 ? {} : { config: a }
175
- };
176
- }), S = 14, C = 2e3, w = 100, T = 48, E = new Set([
177
- "script",
178
- "style",
179
- "template",
180
- "noscript"
181
- ]), D = (e, t) => t.includes(e) || e.id === "studio-staged" || E.has(e.tagName.toLowerCase()), O = (e) => {
182
- let t = !1, r = 0, i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
183
- for (let e of Array.from(document.querySelectorAll("[data-tsd-source]"))) {
184
- let t = n(e);
185
- if (!t) continue;
186
- let r = a.get(t) ?? 0;
187
- i.set(e, r), a.set(t, r + 1);
188
- }
189
- let o = (e) => {
190
- for (let t of e.childNodes) {
191
- if (t.nodeType !== 3) continue;
192
- let e = (t.textContent ?? "").replace(/\s+/g, " ").trim();
193
- if (e) return e.length > T ? `${e.slice(0, T).trimEnd()}…` : e;
194
- }
195
- }, s = (a, c) => {
196
- r++;
197
- let l = n(a), u = o(a), d = Array.from(a.children).filter((t) => !D(t, e)), f = {
198
- tag: a.tagName.toLowerCase(),
199
- ...l ? {
200
- source: l,
201
- index: i.get(a) ?? 0
202
- } : {},
203
- ...u === void 0 ? {} : { text: u },
204
- ...a.classList.contains("hidden") ? { hidden: !0 } : {},
205
- childCount: d.length,
206
- children: []
207
- };
208
- if (c >= S) return d.length && (t = !0), f;
209
- for (let e of d) {
210
- if (f.children.length >= w || r >= C) {
211
- t = !0;
212
- break;
213
- }
214
- f.children.push(s(e, c + 1));
215
- }
216
- return f;
217
- };
218
- return {
219
- tree: s(document.body, 0),
220
- truncated: t
221
- };
222
- };
223
- //#endregion
224
- export { t as COLOR, o as addStagedKey, O as buildLayersTree, p as createOverlayNodes, c as cssRuleFor, x as enumerateSources, h as externalLinkHref, g as isTextLeaf, a as nodeForSource, r as nodesForSource, m as positionBox, s as removeStagedKey, y as selectedPayload, i as sourceIndex, n as sourceOf };
@@ -1,7 +0,0 @@
1
- import { IPreviewToEditor } from './protocol';
2
- export type IEditorChannel = ReturnType<typeof createEditorChannel>;
3
- export declare const createEditorChannel: () => {
4
- send: (msg: IPreviewToEditor) => void;
5
- acceptOrigin: (e: MessageEvent) => boolean;
6
- };
7
- //# sourceMappingURL=editorChannel.d.ts.map
@@ -1,19 +0,0 @@
1
- //#region src/inspector/editorChannel.ts
2
- var e = () => {
3
- let e = null;
4
- return {
5
- send: (t) => {
6
- parent.postMessage({
7
- source: "web-chat-preview",
8
- ...t
9
- }, e ?? "*");
10
- },
11
- acceptOrigin: (t) => {
12
- if (e === null) e = t.origin;
13
- else if (t.origin !== e) return !1;
14
- return !0;
15
- }
16
- };
17
- };
18
- //#endregion
19
- export { e as createEditorChannel };
@@ -1,8 +0,0 @@
1
- export type IHistoryWatcher = ReturnType<typeof createHistoryWatcher>;
2
- export declare const createHistoryWatcher: (deps: {
3
- /** Fired AFTER `location.pathname` actually changed (dedup handled here). */
4
- onPathChange: () => void;
5
- }) => {
6
- teardown: () => void;
7
- };
8
- //# sourceMappingURL=historyWatcher.d.ts.map
@@ -1,24 +0,0 @@
1
- //#region src/inspector/historyWatcher.ts
2
- var e = (e) => {
3
- let t = location.pathname, n = () => {
4
- location.pathname !== t && (t = location.pathname, e.onPathChange());
5
- }, r = !1;
6
- if (!history.pushState.__inspectorPatched) {
7
- let e = history.pushState, t = history.replaceState, i = function(...t) {
8
- let r = e.apply(this, t);
9
- return n(), r;
10
- }, a = function(...e) {
11
- let r = t.apply(this, e);
12
- return n(), r;
13
- };
14
- i.__inspectorPatched = !0, i.__orig = e, a.__inspectorPatched = !0, a.__orig = t, history.pushState = i, history.replaceState = a, r = !0;
15
- }
16
- return window.addEventListener("popstate", n), { teardown: () => {
17
- if (window.removeEventListener("popstate", n), r) {
18
- let e = history.pushState, t = history.replaceState;
19
- e.__inspectorPatched && e.__orig && (history.pushState = e.__orig), t.__inspectorPatched && t.__orig && (history.replaceState = t.__orig);
20
- }
21
- } };
22
- };
23
- //#endregion
24
- export { e as createHistoryWatcher };
@@ -1,2 +0,0 @@
1
- export declare function Inspector(): null;
2
- //# sourceMappingURL=index.d.ts.map