@levo-so/site-runtime 0.2.2 → 0.2.3
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/CollectionField-CzS-34zx.js +270 -0
- package/DateTimeWidget-C1jHOtz7.js +255 -0
- package/Dialog-CzVhHLEY.js +145 -0
- package/KBChatWidget-h3xW6Q4I.js +1067 -0
- package/{PhoneWidget-vtDO9CFq.js → PhoneWidget-_nw97rkI.js} +5 -5
- package/{Popover-B76-bN-a.js → Popover-q5dL7y0W.js} +1 -1
- package/PopupRenderer-Bncp54gB-DuCULkBK.js +3514 -0
- package/RichTextWidget-D-mGlES0.js +758 -0
- package/ThemeProvider-BQmIB5tr.js +116 -0
- package/Tooltip-BIgrpetu.js +67 -0
- package/VerifyButton-BkP98H17.js +191 -0
- package/dist-CJknSbJK.js +80 -0
- package/dist-DBbiX2ST.js +3556 -0
- package/index.d.ts +146 -13
- package/index.js +717 -4219
- package/inlineBaseTheme-DS-AfUHi.js +9 -0
- package/inlineCollectionTheme-D2w17LHX.js +86 -0
- package/kbChat-DHujgETt.js +163 -0
- package/nodeAlignment-Cn6xNtOP.js +166 -0
- package/package.json +15 -3
- package/pillChrome-DWHpfbDk.js +16 -0
- package/popups.d.ts +47 -0
- package/popups.js +5 -0
- package/rolldown-runtime-CAFD8bLK.js +11 -0
- package/styles.css +1 -1
- package/theme.cssm-2YTdd8Yh.js +15 -0
- package/DateTimeWidget-CARoq7bQ.js +0 -254
- package/RichTextWidget-CafZBEKI.js +0 -912
- package/ThemeProvider-Cm2jJC7a.js +0 -381
- package/Tooltip-Bx-BfR7T.js +0 -78
- package/VerifyButton-D1Mwk04d.js +0 -299
- /package/{CollectionInput-5QMoXahu.js → CollectionInput-B1qV4QEH.js} +0 -0
package/index.d.ts
CHANGED
|
@@ -4,6 +4,27 @@ import { ILevoInsights } from '@levo-so/insights';
|
|
|
4
4
|
import { JSX } from 'react/jsx-runtime';
|
|
5
5
|
import { LevoQuery } from '@levo-so/core';
|
|
6
6
|
|
|
7
|
+
/** Color-mode preference. `system` follows the OS `prefers-color-scheme`. */
|
|
8
|
+
export declare type ColorMode = "dark" | "light" | "system";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Site-wide light/dark color mode for a generated Studio site. This does NOT define the
|
|
12
|
+
* theme (colors/tokens live in `theme.css`) — it only toggles a `light`/`dark` class on
|
|
13
|
+
* `<html>`; `theme.css` keys its dark token overrides off `.dark` (via `@custom-variant
|
|
14
|
+
* dark`), so every semantic utility (`bg-page`, `text-ink`, …) flips with zero page changes.
|
|
15
|
+
*
|
|
16
|
+
* Mounted once from the scaffold's `__root` (wrapping the page) — deliberately NOT from
|
|
17
|
+
* `LevoSiteProvider`: that one returns bare children on an unwired site (no `api_url`), and
|
|
18
|
+
* light/dark can't depend on whether a backend is stamped. `defaultMode` is also a per-site
|
|
19
|
+
* design decision the generated site owns, not something the runtime should pick.
|
|
20
|
+
*
|
|
21
|
+
* SSR-safe: the initial
|
|
22
|
+
* render uses `defaultMode` and emits only the `ScriptOnce` guard; the stored preference is
|
|
23
|
+
* read and applied post-mount. Put `suppressHydrationWarning` on `<html>` since the guard
|
|
24
|
+
* mutates it before hydration.
|
|
25
|
+
*/
|
|
26
|
+
export declare const ColorModeProvider: React.FC<IColorModeProviderProps>;
|
|
27
|
+
|
|
7
28
|
/**
|
|
8
29
|
* Build the site's `levoHead` from its `site.json`. Each route passes its OWN imported
|
|
9
30
|
* meta file (`head: levoHead(meta)`) — no path matching anywhere; the import IS the
|
|
@@ -24,8 +45,11 @@ export declare const createLevoHead: (site: ISiteJson) => (meta?: IPlatformMetaF
|
|
|
24
45
|
* `levoHead`'s dynamic config reads for per-record heads. An empty `dataSources` ({})
|
|
25
46
|
* resolves to an empty map. Context is typed structurally (just `queryClient`) so the
|
|
26
47
|
* scaffold's router types never enter the package.
|
|
48
|
+
*
|
|
49
|
+
* Takes the raw `site.json` — same single input as `createLevoHead` and
|
|
50
|
+
* `LevoSiteProvider` — and derives the client config itself.
|
|
27
51
|
*/
|
|
28
|
-
export declare const createLevoLoader: (
|
|
52
|
+
export declare const createLevoLoader: (site: ISiteJson) => (sources: ILevoDataSources) => ({ context, params, }: {
|
|
29
53
|
context: {
|
|
30
54
|
queryClient: IQueryClientLike;
|
|
31
55
|
};
|
|
@@ -41,6 +65,27 @@ export declare const createLevoLoader: (config: ILevoSiteConfig) => (sources: IL
|
|
|
41
65
|
*/
|
|
42
66
|
export declare const createSiteClient: (config?: ILevoSiteConfig) => ILevoClient | null;
|
|
43
67
|
|
|
68
|
+
export declare interface IColorModeProviderProps {
|
|
69
|
+
children: React.ReactNode;
|
|
70
|
+
/** Fallback when nothing is stored yet. */
|
|
71
|
+
defaultMode?: ColorMode;
|
|
72
|
+
/** localStorage key the preference is persisted under. */
|
|
73
|
+
storageKey?: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export declare interface IColorModeState {
|
|
77
|
+
/** The stored preference (`system` before it resolves to light/dark). */
|
|
78
|
+
mode: ColorMode;
|
|
79
|
+
/**
|
|
80
|
+
* The mode actually in effect — `system` already resolved against the OS. Use this to
|
|
81
|
+
* render a two-state toggle so no site has to re-implement the media query. Before mount
|
|
82
|
+
* it reflects `defaultMode` (with `system` read as light), matching what the server sent.
|
|
83
|
+
*/
|
|
84
|
+
resolvedMode: ResolvedColorMode;
|
|
85
|
+
/** Persist a new preference and re-apply it immediately. */
|
|
86
|
+
setMode: (mode: ColorMode) => void;
|
|
87
|
+
}
|
|
88
|
+
|
|
44
89
|
export declare interface IComposedHead {
|
|
45
90
|
meta: IHeadEntry[];
|
|
46
91
|
links: IHeadEntry[];
|
|
@@ -136,6 +181,11 @@ export declare interface ILayersNode {
|
|
|
136
181
|
children: ILayersNode[];
|
|
137
182
|
}
|
|
138
183
|
|
|
184
|
+
export declare interface ILevoChatProps {
|
|
185
|
+
/** The site's root `site.json` — all chat props are derived from it. */
|
|
186
|
+
site: ISiteJson;
|
|
187
|
+
}
|
|
188
|
+
|
|
139
189
|
/** The shape a page exports so its route loader can prefetch every binding it renders. */
|
|
140
190
|
export declare type ILevoDataSources = Record<string, ILevoSourceDef>;
|
|
141
191
|
|
|
@@ -231,6 +281,14 @@ declare interface ILevoFormTheme {
|
|
|
231
281
|
gap?: string;
|
|
232
282
|
}
|
|
233
283
|
|
|
284
|
+
export declare interface ILevoPopupsProps {
|
|
285
|
+
/**
|
|
286
|
+
* The site's id (`site.json` `id`) — scopes the active-popups fetch. Absent → the
|
|
287
|
+
* workspace-wide active popups are returned.
|
|
288
|
+
*/
|
|
289
|
+
siteId?: string;
|
|
290
|
+
}
|
|
291
|
+
|
|
234
292
|
/** A single-record binding — one collection record / blog post / event by `slug` (a detail page). */
|
|
235
293
|
export declare interface ILevoRecordConfig {
|
|
236
294
|
module: "collection" | "blog" | "event";
|
|
@@ -485,17 +543,47 @@ export declare interface ISelectedElement {
|
|
|
485
543
|
};
|
|
486
544
|
}
|
|
487
545
|
|
|
488
|
-
/**
|
|
546
|
+
/**
|
|
547
|
+
* The project's root `site.json` — the ONE input to the whole runtime. The platform stamps
|
|
548
|
+
* it at provision and re-syncs it on settings saves; the scaffold shim imports it and hands
|
|
549
|
+
* the same object to every factory (`createLevoHead`, `createLevoLoader`,
|
|
550
|
+
* `<LevoSiteProvider site>`).
|
|
551
|
+
*
|
|
552
|
+
* It lives in its own leaf module because four modules read it (client, scaffold, provider,
|
|
553
|
+
* chat) and every one of them sits at a different depth of the import graph — hanging the
|
|
554
|
+
* type off any of them makes the graph cyclic.
|
|
555
|
+
*
|
|
556
|
+
* Every field is optional on purpose: a site provisioned before a given block shipped is
|
|
557
|
+
* missing it entirely, and the runtime must degrade (inert client, hidden widget) rather
|
|
558
|
+
* than crash.
|
|
559
|
+
*/
|
|
489
560
|
export declare interface ISiteJson {
|
|
490
561
|
id?: string;
|
|
491
562
|
workspace_id?: string;
|
|
563
|
+
/** Site slug — tags the visitor-chat "Powered by" link's utm_source. */
|
|
564
|
+
slug?: string;
|
|
492
565
|
name?: string;
|
|
493
566
|
description?: string;
|
|
494
567
|
/** The site's live URL host (with or without protocol) — feeds auto-canonicals. */
|
|
495
568
|
domain?: string;
|
|
569
|
+
/**
|
|
570
|
+
* Favicon media object. Its `.location` becomes the site's `<link rel="icon">` and the
|
|
571
|
+
* visitor-chat header icon. Absent → the site keeps the starter's default `favicon.ico`.
|
|
572
|
+
*/
|
|
573
|
+
icon?: {
|
|
574
|
+
location?: string;
|
|
575
|
+
} | null;
|
|
496
576
|
settings?: {
|
|
497
577
|
head_code?: string;
|
|
498
578
|
};
|
|
579
|
+
/**
|
|
580
|
+
* Workspace feature flags stamped into the site. `branding` gates the visitor-chat
|
|
581
|
+
* "Powered by levo.so" attribution — same flag as the "Made with Levo" page badge.
|
|
582
|
+
* Absent (not yet stamped) → coerced false → attribution hidden (white-label-safe).
|
|
583
|
+
*/
|
|
584
|
+
feature_flag?: {
|
|
585
|
+
branding?: boolean;
|
|
586
|
+
};
|
|
499
587
|
levo?: {
|
|
500
588
|
api_url?: string;
|
|
501
589
|
insights_url?: string | null;
|
|
@@ -507,6 +595,11 @@ export declare interface ISiteJson {
|
|
|
507
595
|
export declare interface ISiteMeta extends IPageMeta {
|
|
508
596
|
/** "%s · Acme" — %s is the page title. Applied only when the page provides a title. */
|
|
509
597
|
titleTemplate?: string;
|
|
598
|
+
/**
|
|
599
|
+
* Favicon URL → `<link rel="icon">`. Site-level only (a per-page favicon isn't a thing),
|
|
600
|
+
* which is why it lives here rather than on `IPageMeta`.
|
|
601
|
+
*/
|
|
602
|
+
icon?: string;
|
|
510
603
|
}
|
|
511
604
|
|
|
512
605
|
export declare type IStagedEntry = IStagedStyleEntry | IStagedTextEntry | IStagedImageEntry;
|
|
@@ -544,13 +637,22 @@ export declare interface ITextChangedElement {
|
|
|
544
637
|
occurrences: number;
|
|
545
638
|
}
|
|
546
639
|
|
|
640
|
+
/**
|
|
641
|
+
* Drops the site's AI chat widget onto every page, wired from `site.json`. Mounted once
|
|
642
|
+
* from the scaffold's `__root` (via the `SiteChat` shim) alongside `<Inspector />`. Self-
|
|
643
|
+
* gates: renders nothing until the workspace resolves a servable active agent, so an
|
|
644
|
+
* unwired or agent-less site paints no launcher. `apiBaseUrl` is intentionally left at the
|
|
645
|
+
* KBChat default (the same-origin `/.levo` proxy) — the serving layer owns that route.
|
|
646
|
+
*/
|
|
647
|
+
export declare const LevoChat: React.FC<ILevoChatProps>;
|
|
648
|
+
|
|
547
649
|
/**
|
|
548
650
|
* Self-contained event registration widget for generated Studio v3 sites — ticket
|
|
549
651
|
* selection, coupons, attendee details, payment (Razorpay by default; Stripe Embedded
|
|
550
652
|
* Checkout when the booking API returns `provider: "stripe"`), and a booking confirmation.
|
|
551
653
|
*
|
|
552
654
|
* The AI drops this onto an event page and NEVER rebuilds the flow: it owns the entire
|
|
553
|
-
* booking + payment path against the Levo event API. The site client (`
|
|
655
|
+
* booking + payment path against the Levo event API. The site client (`useLevoClient`)
|
|
554
656
|
* auto-stamps the workspace on every request, so no auth/workspace wiring is needed.
|
|
555
657
|
* `external` turns it into a plain link out to a third-party ticketing URL.
|
|
556
658
|
*/
|
|
@@ -578,13 +680,32 @@ export declare const LevoEventRegister: ({ eventID, title, external, buttonText,
|
|
|
578
680
|
export declare const LevoForm: React.FC<ILevoFormProps>;
|
|
579
681
|
|
|
580
682
|
/**
|
|
581
|
-
* Mounts the
|
|
582
|
-
*
|
|
583
|
-
*
|
|
584
|
-
*
|
|
683
|
+
* Mounts the site's popups, wired from `site.json`. Rendered once from the scaffold's
|
|
684
|
+
* `__root` (via the `SitePopups` shim), inside `<LevoSiteProvider>` — `PopupLoader` reads
|
|
685
|
+
* the Levo client through `useLevo()`, which that provider mounts. The library handles
|
|
686
|
+
* everything else: it fetches active popups, evaluates page/referrer targeting against the
|
|
687
|
+
* current URL, lazy-loads the renderer only when popups exist, and self-hides otherwise.
|
|
688
|
+
*
|
|
689
|
+
* No `pageId` is threaded: that is a studio DB page id with no equivalent in a code-routed
|
|
690
|
+
* site, so page-bound rules don't apply here — site-wide and URL-path targeting (the
|
|
691
|
+
* `is_all_pages` / `contains` / `begins_with` matchers) do.
|
|
692
|
+
*/
|
|
693
|
+
export declare const LevoPopups: React.FC<ILevoPopupsProps>;
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* Mounts the Levo client + insights for a generated site, and the site-wide overlays that
|
|
697
|
+
* ride on top of it (AI chat + popups). Rendered once from the scaffold's `__root` (via the
|
|
698
|
+
* env-reading shim); SSR-safe — construction guards its window/document reads, and
|
|
699
|
+
* `insights.init()` (client-side only by contract) runs in an effect after mount.
|
|
700
|
+
*
|
|
701
|
+
* Takes the raw `site.json` and derives everything from it: the data client's config, and
|
|
702
|
+
* the site-wide overlays' metadata (workspace/name/slug/icon/branding for chat, id for
|
|
703
|
+
* popups). The overlays render only on a wired site, so they always have a client in scope;
|
|
704
|
+
* each is client-only, lazy, and self-hiding, so they add nothing to the initial page. Omit
|
|
705
|
+
* `site` to mount a bare (null) client context.
|
|
585
706
|
*/
|
|
586
707
|
export declare const LevoSiteProvider: React.FC<{
|
|
587
|
-
|
|
708
|
+
site?: ISiteJson;
|
|
588
709
|
children: React.ReactNode;
|
|
589
710
|
}>;
|
|
590
711
|
|
|
@@ -623,7 +744,7 @@ export declare const parseRawHead: (raw: string) => IComposedHead;
|
|
|
623
744
|
/**
|
|
624
745
|
* Prefetch every binding a page declares into the router's QueryClient — call it (awaited)
|
|
625
746
|
* from the route `loader` so SSR renders fully-populated HTML. Builds its own client from
|
|
626
|
-
* the site config (loaders run outside React, so
|
|
747
|
+
* the site config (loaders run outside React, so the client context isn't available). Record
|
|
627
748
|
* bindings pull their slug from the route `params` (`$slug`). Resilient: a single failed
|
|
628
749
|
* source resolves to null so it doesn't blank the whole page — the hook surfaces that
|
|
629
750
|
* binding's error while the rest render.
|
|
@@ -642,13 +763,21 @@ export declare const prefetchLevoSources: ({ queryClient, config, sources, param
|
|
|
642
763
|
params?: Record<string, string>;
|
|
643
764
|
}) => Promise<Record<string, unknown>>;
|
|
644
765
|
|
|
766
|
+
/** What `system` resolves to — the class actually on `<html>`. */
|
|
767
|
+
export declare type ResolvedColorMode = "dark" | "light";
|
|
768
|
+
|
|
645
769
|
/**
|
|
646
|
-
* The site's Levo client config from its `site.json
|
|
647
|
-
*
|
|
648
|
-
*
|
|
770
|
+
* The site's Levo client config from its `site.json` — the only place that mapping lives, so
|
|
771
|
+
* the provider and the SSR route loader can't drift apart.
|
|
772
|
+
*
|
|
773
|
+
* The `?.` on `levo` is load-bearing: a site provisioned before the block shipped degrades to
|
|
774
|
+
* an inert client, never a crash.
|
|
649
775
|
*/
|
|
650
776
|
export declare const siteConfigFromJson: (site: ISiteJson) => ILevoSiteConfig;
|
|
651
777
|
|
|
778
|
+
/** Read/set the current color mode. Throws outside a `<ColorModeProvider>`. */
|
|
779
|
+
export declare function useColorMode(): IColorModeState;
|
|
780
|
+
|
|
652
781
|
/**
|
|
653
782
|
* Load a collection's SCHEMA so `LevoForm` can render its fields. Like the other hooks the
|
|
654
783
|
* config is a static literal (the editor binding); it reads the warm cache the route loader
|
|
@@ -669,7 +798,11 @@ export declare const useLevoRecord: <T = Record<string, unknown>>(config: ILevoR
|
|
|
669
798
|
|
|
670
799
|
/**
|
|
671
800
|
* The site's Levo client, or `null` when the site isn't wired to a Levo backend yet
|
|
672
|
-
* (no `
|
|
801
|
+
* (no `api_url` in `site.json` — e.g. not stamped at provision). Consumers no-op on null.
|
|
802
|
+
*
|
|
803
|
+
* Site-facing alias only. This package's own components call `@levo-so/react`'s
|
|
804
|
+
* `useLevoClient()` directly so that nothing internal imports THIS module — which keeps the
|
|
805
|
+
* provider, and the chat/popup widgets it mounts, off the SSR route-loader's import path.
|
|
673
806
|
*
|
|
674
807
|
* Explicit return type on purpose: inference would inline core-internal names
|
|
675
808
|
* (`IPageContext`) that the rolled-up d.ts doesn't export → TS4023 on declaration emit.
|