@xtandard/webhooks 0.1.3 → 0.1.4

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 (46) hide show
  1. package/README.md +8 -6
  2. package/dist/cli.cjs +4 -4
  3. package/dist/cli.mjs +4 -4
  4. package/dist/{core-tmmtadF1.mjs → core-CSnkgzmP.mjs} +2 -2
  5. package/dist/{core-tmmtadF1.mjs.map → core-CSnkgzmP.mjs.map} +1 -1
  6. package/dist/{core-DkIXozBY.cjs → core-FOX5QhoI.cjs} +2 -2
  7. package/dist/{core-DkIXozBY.cjs.map → core-FOX5QhoI.cjs.map} +1 -1
  8. package/dist/core.cjs +1 -1
  9. package/dist/core.mjs +1 -1
  10. package/dist/{create-fetch-handler-B5WBbf8x.cjs → create-fetch-handler-B9gukX_e.cjs} +3 -3
  11. package/dist/{create-fetch-handler-B5WBbf8x.cjs.map → create-fetch-handler-B9gukX_e.cjs.map} +1 -1
  12. package/dist/{create-fetch-handler-DZohI08M.mjs → create-fetch-handler-KPASJUhE.mjs} +3 -3
  13. package/dist/{create-fetch-handler-DZohI08M.mjs.map → create-fetch-handler-KPASJUhE.mjs.map} +1 -1
  14. package/dist/{dispatcher-CQcoIsS9.mjs → dispatcher-DIcpJOU0.mjs} +3 -3
  15. package/dist/{dispatcher-CQcoIsS9.mjs.map → dispatcher-DIcpJOU0.mjs.map} +1 -1
  16. package/dist/{dispatcher-Bn4O874S.cjs → dispatcher-Dw8nhSxY.cjs} +3 -3
  17. package/dist/{dispatcher-Bn4O874S.cjs.map → dispatcher-Dw8nhSxY.cjs.map} +1 -1
  18. package/dist/{elysia-shared-Cop1-ie0.cjs → elysia-shared-Bhsy8h_n.cjs} +2 -2
  19. package/dist/{elysia-shared-Cop1-ie0.cjs.map → elysia-shared-Bhsy8h_n.cjs.map} +1 -1
  20. package/dist/{elysia-shared-CgTU3yPa.mjs → elysia-shared-BlmFhfOV.mjs} +2 -2
  21. package/dist/{elysia-shared-CgTU3yPa.mjs.map → elysia-shared-BlmFhfOV.mjs.map} +1 -1
  22. package/dist/entry-bun.cjs +1 -1
  23. package/dist/entry-bun.mjs +1 -1
  24. package/dist/entry-elysia.cjs +1 -1
  25. package/dist/entry-elysia.mjs +1 -1
  26. package/dist/entry-elysia2.cjs +1 -1
  27. package/dist/entry-elysia2.mjs +1 -1
  28. package/dist/entry-express.cjs +1 -1
  29. package/dist/entry-express.mjs +1 -1
  30. package/dist/entry-hono.cjs +1 -1
  31. package/dist/entry-hono.mjs +1 -1
  32. package/dist/index.cjs +3 -3
  33. package/dist/index.d.cts +1 -1
  34. package/dist/index.d.mts +1 -1
  35. package/dist/index.mjs +3 -3
  36. package/dist/react.css +1 -1
  37. package/dist/react.js +4928 -4944
  38. package/dist/testing.cjs +2 -2
  39. package/dist/testing.mjs +2 -2
  40. package/dist/types-elysia2/version.d.ts +1 -1
  41. package/dist/types-react/react.d.ts +16 -3
  42. package/dist/types-react/ui/App.d.ts +3 -1
  43. package/dist/types-react/ui/theme.d.ts +33 -5
  44. package/dist/ui/assets/{index-BgyX_njf.js → index-BJcdnARt.js} +48 -48
  45. package/dist/ui/index.html +1 -1
  46. package/package.json +2 -1
package/dist/testing.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_core = require("./core-DkIXozBY.cjs");
2
+ const require_core = require("./core-FOX5QhoI.cjs");
3
3
  const require_signing = require("./signing.cjs");
4
- const require_dispatcher = require("./dispatcher-Bn4O874S.cjs");
4
+ const require_dispatcher = require("./dispatcher-Dw8nhSxY.cjs");
5
5
  const require_memory = require("./memory-8Ef-PL5a.cjs");
6
6
  let node_http = require("node:http");
7
7
  //#region src/testing.ts
package/dist/testing.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { o as createWebhooksCore } from "./core-tmmtadF1.mjs";
1
+ import { o as createWebhooksCore } from "./core-CSnkgzmP.mjs";
2
2
  import { verify } from "./signing.mjs";
3
- import { n as createDispatcher } from "./dispatcher-CQcoIsS9.mjs";
3
+ import { n as createDispatcher } from "./dispatcher-DIcpJOU0.mjs";
4
4
  import { t as createMemoryStorage } from "./memory-BMsSSwqn.mjs";
5
5
  import { createServer } from "node:http";
6
6
  //#region src/testing.ts
@@ -5,4 +5,4 @@
5
5
  * @module
6
6
  */
7
7
  /** The published package version. */
8
- export declare const VERSION = "0.1.3";
8
+ export declare const VERSION = "0.1.4";
@@ -27,6 +27,8 @@ import type { BaseLocationHook } from "wouter";
27
27
  import { QueryClient } from "@tanstack/react-query";
28
28
  import { type FetchLike } from "./ui/api.ts";
29
29
  import "./ui/styles.css";
30
+ /** Theme modes for the embedded components (see {@link WebhooksDashboardProps.theme}). */
31
+ export type EmbedTheme = "auto" | "inherit" | "light" | "dark";
30
32
  /** Props for {@link WebhooksDashboard}. */
31
33
  export interface WebhooksDashboardProps {
32
34
  /**
@@ -48,8 +50,19 @@ export interface WebhooksDashboardProps {
48
50
  fetch?: FetchLike;
49
51
  /** Bring your own QueryClient; one is created if omitted. */
50
52
  queryClient?: QueryClient;
51
- /** Control theme handling. `"auto"` (default) initializes the system/light/dark switcher. */
52
- theme?: "auto" | "inherit";
53
+ /**
54
+ * Theme handling. The embed never writes to the host document — it resolves a
55
+ * theme and applies it to its own wrapper (`data-theme`), so surfaces, text,
56
+ * borders and code views always come from one theme.
57
+ * - `"auto"` (default) — the panel's own system/light/dark switcher (preference
58
+ * persisted in localStorage).
59
+ * - `"inherit"` — follow the host page, live: a `dark`/`light` class or
60
+ * `data-theme` attribute on `<html>` (then `<body>`), falling back to the OS
61
+ * `prefers-color-scheme`. The switcher is hidden; the host owns the theme.
62
+ * - `"light"` / `"dark"` — force one theme (switcher hidden). Useful when the
63
+ * host tracks its theme some other way: pass its resolved value.
64
+ */
65
+ theme?: EmbedTheme;
53
66
  /** Extra className on the dashboard root wrapper. */
54
67
  className?: string;
55
68
  /**
@@ -94,5 +107,5 @@ export declare function WebhooksDashboard({ apiBaseUrl, credentials, fetch: fetc
94
107
  */
95
108
  export declare function WebhooksPortal({ token, ...rest }: WebhooksPortalProps): React.ReactElement;
96
109
  export { setApiBase, setApiToken, type FetchLike } from "./ui/api.ts";
97
- export { setThemePref, getThemePref, type ThemePref } from "./ui/theme.ts";
110
+ export { setThemePref, getThemePref, detectHostTheme, type ThemePref, type ResolvedTheme, } from "./ui/theme.ts";
98
111
  export default WebhooksDashboard;
@@ -12,11 +12,13 @@ declare global {
12
12
  * the handler's SPA catch-all), while the embeddable defaults to hash routing so
13
13
  * it never touches the host app's router. Pass a custom hook (e.g. memory) to override.
14
14
  */
15
- export declare function App({ locationHook, base, logoUrl, initialApplicationKey, }: {
15
+ export declare function App({ locationHook, base, logoUrl, initialApplicationKey, showThemeToggle, }: {
16
16
  locationHook?: BaseLocationHook;
17
17
  base?: string;
18
18
  /** Override the navbar logo image (otherwise taken from server `/config`). */
19
19
  logoUrl?: string;
20
20
  /** Pre-select an application when the URL doesn't name one (embed hosts). */
21
21
  initialApplicationKey?: string;
22
+ /** Show the system/light/dark switcher. Off when an embedding host owns the theme. */
23
+ showThemeToggle?: boolean;
22
24
  }): React.ReactElement;
@@ -1,12 +1,40 @@
1
1
  /**
2
- * Theme preference: `system` (follows the OS), `light`, or `dark`. The resolved
3
- * value is written to `<html data-theme>`; the preference is persisted in
4
- * localStorage. `system` live-updates when the OS scheme changes.
2
+ * Theme preference: `system` (follows the OS), `light`, or `dark`. The
3
+ * preference is persisted in localStorage; `system` live-updates when the OS
4
+ * scheme changes.
5
+ *
6
+ * The standalone SPA writes the resolved theme to `<html data-theme>` (see
7
+ * {@link initTheme}). The React embed never touches the host document: it puts
8
+ * `data-theme` on its own wrapper, either from this preference (`theme="auto"`)
9
+ * or from the host page's theme ({@link detectHostTheme}, `theme="inherit"`).
5
10
  */
6
11
  export type ThemePref = "system" | "light" | "dark";
12
+ /** A concrete, resolved theme. */
13
+ export type ResolvedTheme = "light" | "dark";
7
14
  export declare function getThemePref(): ThemePref;
8
15
  /** The concrete theme a preference resolves to right now. */
9
- export declare function resolveTheme(pref: ThemePref): "light" | "dark";
16
+ export declare function resolveTheme(pref: ThemePref): ResolvedTheme;
17
+ /** Persist a preference and notify subscribers (the SPA root, embedded dashboards). */
10
18
  export declare function setThemePref(pref: ThemePref): void;
11
- /** Apply the stored preference and keep `system` in sync with the OS. Call once at boot. */
19
+ /** Subscribe to preference changes made via {@link setThemePref}. Returns an unsubscribe. */
20
+ export declare function subscribeThemePref(listener: (pref: ThemePref) => void): () => void;
21
+ /** Subscribe to OS color-scheme changes. Returns an unsubscribe. */
22
+ export declare function subscribeSystemTheme(listener: () => void): () => void;
23
+ /**
24
+ * Standalone SPA: apply the stored preference to `<html data-theme>`, follow
25
+ * later changes, and keep `system` in sync with the OS. Call once at boot.
26
+ */
12
27
  export declare function initTheme(): void;
28
+ /**
29
+ * The host page's theme, for `theme="inherit"`: a `dark`/`light` class or
30
+ * `data-theme` attribute on `<html>` (then `<body>`) — the conventions used by
31
+ * class- and attribute-based theme switchers — falling back to the OS
32
+ * `prefers-color-scheme` when the host sets neither.
33
+ */
34
+ export declare function detectHostTheme(): ResolvedTheme;
35
+ /**
36
+ * Call `listener` whenever the host page's theme may have changed: `class` /
37
+ * `data-theme` / `style` mutations on `<html>` or `<body>`, or an OS scheme
38
+ * change. Returns an unsubscribe.
39
+ */
40
+ export declare function watchHostTheme(listener: () => void): () => void;