@particle-academy/fancy-slides 0.1.5 → 0.1.7
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/dist/{chart-host-BHP6GUWO.js → chart-host-X55F6S44.js} +6 -4
- package/dist/chart-host-X55F6S44.js.map +1 -0
- package/dist/chunk-WIUXPQAK.js +47 -0
- package/dist/chunk-WIUXPQAK.js.map +1 -0
- package/dist/index.cjs +55 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +484 -0
- package/dist/index.d.ts +484 -0
- package/dist/index.js +15 -6
- package/dist/index.js.map +1 -1
- package/dist/registry.cjs +14 -2
- package/dist/registry.cjs.map +1 -1
- package/dist/registry.d.cts +11 -0
- package/dist/registry.d.ts +11 -0
- package/dist/registry.js +1 -1
- package/dist/styles.d.cts +2 -0
- package/dist/styles.d.ts +2 -0
- package/dist/types-Bc-psiRF.d.cts +290 -0
- package/dist/types-Bc-psiRF.d.ts +290 -0
- package/package.json +1 -1
- package/dist/chart-host-BHP6GUWO.js.map +0 -1
package/dist/registry.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var react = require('react');
|
|
3
4
|
var fancyEcharts = require('@particle-academy/fancy-echarts');
|
|
4
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
6
|
var fancyCode = require('@particle-academy/fancy-code');
|
|
6
7
|
var reactFancy = require('@particle-academy/react-fancy');
|
|
7
|
-
var react = require('react');
|
|
8
8
|
|
|
9
9
|
var __defProp = Object.defineProperty;
|
|
10
10
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -15,6 +15,15 @@ var __export = (target, all) => {
|
|
|
15
15
|
for (var name in all)
|
|
16
16
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
17
|
};
|
|
18
|
+
function useIsDarkSlide() {
|
|
19
|
+
return react.useContext(SlideContext)?.isDark ?? false;
|
|
20
|
+
}
|
|
21
|
+
var SlideContext;
|
|
22
|
+
var init_slide_context = __esm({
|
|
23
|
+
"src/components/Slide/slide-context.ts"() {
|
|
24
|
+
SlideContext = react.createContext(null);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
18
27
|
|
|
19
28
|
// src/registry/element-renderers/chart-host.tsx
|
|
20
29
|
var chart_host_exports = {};
|
|
@@ -22,10 +31,13 @@ __export(chart_host_exports, {
|
|
|
22
31
|
default: () => ChartHost
|
|
23
32
|
});
|
|
24
33
|
function ChartHost({ element }) {
|
|
25
|
-
|
|
34
|
+
const isDarkSlide = useIsDarkSlide();
|
|
35
|
+
const theme = element.chartTheme ?? (isDarkSlide ? "dark" : void 0);
|
|
36
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx(fancyEcharts.EChart, { option: element.option, theme }) });
|
|
26
37
|
}
|
|
27
38
|
var init_chart_host = __esm({
|
|
28
39
|
"src/registry/element-renderers/chart-host.tsx"() {
|
|
40
|
+
init_slide_context();
|
|
29
41
|
fancyEcharts.registerAll();
|
|
30
42
|
fancyEcharts.registerBuiltinThemes();
|
|
31
43
|
}
|
package/dist/registry.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/registry/element-renderers/chart-host.tsx","../src/registry/element-renderers/code-host.tsx","../src/registry/element-renderers/table-host.tsx","../src/registry/element-renderers/embed-host.tsx","../src/registry/index.tsx"],"names":["jsx","EChart","registerAll","registerBuiltinThemes","CodeEditor","jsxs","Table","ChartHost","lazy","CodeHost","TableHost","EmbedHost","Suspense"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAA,kBAAA,GAAA,EAAA;AAAA,QAAA,CAAA,kBAAA,EAAA;AAAA,EAAA,OAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAee,SAAR,SAAA,CAA2B,EAAE,OAAA,EAAQ,EAAoD;AAC5F,EAAA,sCACK,KAAA,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AACD,MAAA,uBACIV,cAAAA,CAACY,cAAA,EAAA,EAAS,QAAA,kBAAUZ,cAAAA,CAAC,OAAA,EAAA,EAAQ,KAAA,EAAM,eAAA,EAAgB,GAC/C,QAAA,kBAAAA,cAAAA,CAACW,UAAAA,EAAA,EAAU,SAAkC,CAAA,EACjD,CAAA;AAAA,IAER;AACI,MAAA,OAAO,MAAA;AAAA;AAEnB","file":"registry.cjs","sourcesContent":["import { EChart, registerAll, registerBuiltinThemes } from \"@particle-academy/fancy-echarts\";\nimport type { ChartElement } from \"../../types\";\n\n// fancy-echarts ships its chart types as opt-in tree-shake-friendly modules,\n// so the consumer normally calls `registerAll()` somewhere global. The\n// registry subpath here is the natural spot to wire it: this module only\n// loads when a deck actually contains a chart element (defaultElementRegistry\n// is React.lazy), so the registration cost is paid by chart-using hosts\n// only — non-chart consumers never even import this file.\n//\n// `registerAll()` is idempotent on echarts' side, so re-imports across\n// chunks are safe.\nregisterAll();\nregisterBuiltinThemes();\n\nexport default function ChartHost({ element }: { element: ChartElement; slideWidthPx: number }) {\n return (\n <div style={{ width: \"100%\", height: \"100%\" }}>\n <EChart option={element.option as Parameters<typeof EChart>[0][\"option\"]} theme={element.chartTheme} />\n </div>\n );\n}\n","import { CodeEditor } from \"@particle-academy/fancy-code\";\nimport type { CodeElement } from \"../../types\";\n\nexport default function CodeHost({ element }: { element: CodeElement }) {\n return (\n <div style={{ width: \"100%\", height: \"100%\", overflow: \"hidden\", borderRadius: 8 }}>\n <CodeEditor\n value={element.code}\n language={element.language ?? \"javascript\"}\n theme={element.codeTheme ?? \"dark\"}\n readOnly\n lineNumbers={element.lineNumbers ?? true}\n >\n <CodeEditor.Panel />\n </CodeEditor>\n </div>\n );\n}\n","import { Table } from \"@particle-academy/react-fancy\";\nimport type { TableElement } from \"../../types\";\n\nexport default function TableHost({ element }: { element: TableElement }) {\n return (\n <div style={{ width: \"100%\", height: \"100%\", overflow: \"auto\" }}>\n <Table className=\"w-full\">\n <Table.Head>\n <Table.Row>\n {element.columns.map((c) => (\n <Table.Cell key={c.key} header>\n {c.label}\n </Table.Cell>\n ))}\n </Table.Row>\n </Table.Head>\n <Table.Body>\n {element.rows.map((row, i) => (\n <Table.Row key={i}>\n {element.columns.map((c) => (\n <Table.Cell key={c.key}>{formatCell(row[c.key])}</Table.Cell>\n ))}\n </Table.Row>\n ))}\n </Table.Body>\n </Table>\n </div>\n );\n}\n\nfunction formatCell(v: unknown): string {\n if (v == null) return \"\";\n if (typeof v === \"object\") return JSON.stringify(v);\n return String(v);\n}\n","import type { EmbedElement } from \"../../types\";\n\nexport default function EmbedHost({ element }: { element: EmbedElement }) {\n return (\n <iframe\n src={element.src}\n title={element.title ?? \"Embedded content\"}\n sandbox={element.sandbox ?? \"allow-scripts\"}\n style={{ width: \"100%\", height: \"100%\", border: 0, display: \"block\" }}\n />\n );\n}\n","/**\n * Default element registry. Wires up the element types fancy-slides doesn't\n * render natively (chart / code / table / embed) by composing the other\n * fancy packages as optional peer deps.\n *\n * Hosts opt into this by importing from the `/registry` subpath:\n *\n * import { defaultElementRegistry } from \"@particle-academy/fancy-slides/registry\";\n * <DeckEditor renderElement={defaultElementRegistry} … />\n *\n * Keeping it behind a subpath means consumers who only render decks with\n * built-in element types (text / image / shape) never pull fancy-echarts,\n * fancy-code, or react-fancy Table into their bundle.\n */\n\nimport { lazy, Suspense } from \"react\";\nimport type { ChartElement, CodeElement, SlideElement, EmbedElement, TableElement } from \"../types\";\n\nconst ChartHost = lazy(() => import(\"./element-renderers/chart-host\"));\nconst CodeHost = lazy(() => import(\"./element-renderers/code-host\"));\nconst TableHost = lazy(() => import(\"./element-renderers/table-host\"));\nconst EmbedHost = lazy(() => import(\"./element-renderers/embed-host\"));\n\nconst Loading = ({ label }: { label: string }) => (\n <div\n style={{\n display: \"grid\",\n placeItems: \"center\",\n width: \"100%\",\n height: \"100%\",\n color: \"rgba(0,0,0,0.4)\",\n fontSize: 12,\n fontFamily: \"ui-sans-serif, system-ui, sans-serif\",\n }}\n >\n {label}…\n </div>\n);\n\n/**\n * Renderer signature compatible with `Slide`'s `renderElement` prop. Returns\n * `undefined` for element types fancy-slides handles itself, so the call\n * site falls back to the built-in renderer.\n */\nexport function defaultElementRegistry(element: SlideElement, slideWidthPx: number) {\n switch (element.type) {\n case \"chart\":\n return (\n <Suspense fallback={<Loading label=\"Loading chart\" />}>\n <ChartHost element={element as ChartElement} slideWidthPx={slideWidthPx} />\n </Suspense>\n );\n case \"code\":\n return (\n <Suspense fallback={<Loading label=\"Loading code\" />}>\n <CodeHost element={element as CodeElement} />\n </Suspense>\n );\n case \"table\":\n return (\n <Suspense fallback={<Loading label=\"Loading table\" />}>\n <TableHost element={element as TableElement} />\n </Suspense>\n );\n case \"embed\":\n return (\n <Suspense fallback={<Loading label=\"Loading embed\" />}>\n <EmbedHost element={element as EmbedElement} />\n </Suspense>\n );\n default:\n return undefined;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/Slide/slide-context.ts","../src/registry/element-renderers/chart-host.tsx","../src/registry/element-renderers/code-host.tsx","../src/registry/element-renderers/table-host.tsx","../src/registry/element-renderers/embed-host.tsx","../src/registry/index.tsx"],"names":["useContext","createContext","jsx","EChart","registerAll","registerBuiltinThemes","CodeEditor","jsxs","Table","ChartHost","lazy","CodeHost","TableHost","EmbedHost","Suspense"],"mappings":";;;;;;;;;;;;;;;;;AA6CO,SAAS,cAAA,GAA0B;AACtC,EAAA,OAAOA,gBAAA,CAAW,YAAY,CAAA,EAAG,MAAA,IAAU,KAAA;AAC/C;AA/CA,IAsBa,YAAA;AAtBb,IAAA,kBAAA,GAAA,KAAA,CAAA;AAAA,EAAA,uCAAA,GAAA;AAsBO,IAAM,YAAA,GAAeC,oBAAwC,IAAI,CAAA;AAAA,EAAA;AAAA,CAAA,CAAA;;;ACtBxE,IAAA,kBAAA,GAAA,EAAA;AAAA,QAAA,CAAA,kBAAA,EAAA;AAAA,EAAA,OAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AA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MAAA,uBACIT,cAAAA,CAACY,cAAA,EAAA,EAAS,QAAA,kBAAUZ,cAAAA,CAAC,OAAA,EAAA,EAAQ,KAAA,EAAM,eAAA,EAAgB,GAC/C,QAAA,kBAAAA,cAAAA,CAACU,UAAAA,EAAA,EAAU,SAAkC,CAAA,EACjD,CAAA;AAAA,IAER,KAAK,OAAA;AACD,MAAA,uBACIV,cAAAA,CAACY,cAAA,EAAA,EAAS,QAAA,kBAAUZ,cAAAA,CAAC,OAAA,EAAA,EAAQ,KAAA,EAAM,eAAA,EAAgB,GAC/C,QAAA,kBAAAA,cAAAA,CAACW,UAAAA,EAAA,EAAU,SAAkC,CAAA,EACjD,CAAA;AAAA,IAER;AACI,MAAA,OAAO,MAAA;AAAA;AAEnB","file":"registry.cjs","sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { Theme } from \"../../types\";\n\n/**\n * What the surrounding <Slide> knows about itself. Exposed to children\n * (including `renderElement` callbacks and registry hosts like chart-host)\n * via React context so they can react to the deck's theme without the\n * renderElement signature having to carry it around.\n */\nexport interface SlideContextValue {\n /** Fully-resolved theme (merged with defaults). */\n theme: Theme;\n /**\n * Heuristic: true when the resolved background is dark enough that\n * native-rendered widgets (charts, code blocks) should use a dark variant.\n * Computed once from `theme.colors.background` luminance.\n */\n isDark: boolean;\n /** Slide width in CSS pixels at the current render size. */\n slideWidthPx: number;\n}\n\nexport const SlideContext = createContext<SlideContextValue | null>(null);\n\n/**\n * Read the surrounding <Slide>'s context. Returns null when called outside\n * a Slide — chart-host / code-host can use that signal to fall back to\n * a sensible default (light theme, no resize anchor).\n */\nexport function useSlideContext(): SlideContextValue | null {\n return useContext(SlideContext);\n}\n\n/**\n * Convenience: returns the resolved theme, or undefined when the caller\n * isn't inside a Slide.\n */\nexport function useSlideTheme(): Theme | undefined {\n return useContext(SlideContext)?.theme;\n}\n\n/**\n * Convenience: returns true when the surrounding slide's background reads\n * as \"dark enough\" — useful for charts/code blocks that ship a dark variant.\n */\nexport function useIsDarkSlide(): boolean {\n return useContext(SlideContext)?.isDark ?? false;\n}\n\n/** Compute `isDark` from a hex/rgb colour. Used by Slide when building the context. */\nexport function isDarkColor(color: string): boolean {\n // Normalise #rgb / #rrggbb / rgb()/rgba() to a triple.\n const m = color.match(/^#([0-9a-f]{3,8})$/i);\n if (m) {\n let hex = m[1];\n if (hex.length === 3) {\n hex = hex.split(\"\").map((c) => c + c).join(\"\");\n }\n if (hex.length >= 6) {\n const r = parseInt(hex.slice(0, 2), 16);\n const g = parseInt(hex.slice(2, 4), 16);\n const b = parseInt(hex.slice(4, 6), 16);\n return relativeLuminance(r, g, b) < 0.5;\n }\n }\n const rgb = color.match(/rgba?\\(([^)]+)\\)/i);\n if (rgb) {\n const [r, g, b] = rgb[1].split(\",\").map((s) => parseInt(s.trim(), 10));\n if (!Number.isNaN(r) && !Number.isNaN(g) && !Number.isNaN(b)) {\n return relativeLuminance(r, g, b) < 0.5;\n }\n }\n return false;\n}\n\nfunction relativeLuminance(r: number, g: number, b: number): number {\n // Standard sRGB → relative luminance.\n const toLinear = (c: number) => {\n const v = c / 255;\n return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);\n };\n return 0.2126 * toLinear(r) + 0.7152 * toLinear(g) + 0.0722 * toLinear(b);\n}\n","import { EChart, registerAll, registerBuiltinThemes } from \"@particle-academy/fancy-echarts\";\nimport type { ChartElement } from \"../../types\";\nimport { useIsDarkSlide } from \"../../components/Slide/slide-context\";\n\n// fancy-echarts ships its chart types as opt-in tree-shake-friendly modules,\n// so the consumer normally calls `registerAll()` somewhere global. The\n// registry subpath here is the natural spot to wire it: this module only\n// loads when a deck actually contains a chart element (defaultElementRegistry\n// is React.lazy), so the registration cost is paid by chart-using hosts\n// only — non-chart consumers never even import this file.\n//\n// `registerAll()` is idempotent on echarts' side, so re-imports across\n// chunks are safe.\nregisterAll();\nregisterBuiltinThemes();\n\nexport default function ChartHost({ element }: { element: ChartElement; slideWidthPx: number }) {\n // If the slide background reads as dark and the chart doesn't already\n // pin a theme explicitly, fall back to echarts' built-in \"dark\" theme\n // so the chart legend/axis/tooltip text stay legible.\n const isDarkSlide = useIsDarkSlide();\n const theme = element.chartTheme ?? (isDarkSlide ? \"dark\" : undefined);\n return (\n <div style={{ width: \"100%\", height: \"100%\" }}>\n <EChart option={element.option as Parameters<typeof EChart>[0][\"option\"]} theme={theme} />\n </div>\n );\n}\n","import { CodeEditor } from \"@particle-academy/fancy-code\";\nimport type { CodeElement } from \"../../types\";\n\nexport default function CodeHost({ element }: { element: CodeElement }) {\n return (\n <div style={{ width: \"100%\", height: \"100%\", overflow: \"hidden\", borderRadius: 8 }}>\n <CodeEditor\n value={element.code}\n language={element.language ?? \"javascript\"}\n theme={element.codeTheme ?? \"dark\"}\n readOnly\n lineNumbers={element.lineNumbers ?? true}\n >\n <CodeEditor.Panel />\n </CodeEditor>\n </div>\n );\n}\n","import { Table } from \"@particle-academy/react-fancy\";\nimport type { TableElement } from \"../../types\";\n\nexport default function TableHost({ element }: { element: TableElement }) {\n return (\n <div style={{ width: \"100%\", height: \"100%\", overflow: \"auto\" }}>\n <Table className=\"w-full\">\n <Table.Head>\n <Table.Row>\n {element.columns.map((c) => (\n <Table.Cell key={c.key} header>\n {c.label}\n </Table.Cell>\n ))}\n </Table.Row>\n </Table.Head>\n <Table.Body>\n {element.rows.map((row, i) => (\n <Table.Row key={i}>\n {element.columns.map((c) => (\n <Table.Cell key={c.key}>{formatCell(row[c.key])}</Table.Cell>\n ))}\n </Table.Row>\n ))}\n </Table.Body>\n </Table>\n </div>\n );\n}\n\nfunction formatCell(v: unknown): string {\n if (v == null) return \"\";\n if (typeof v === \"object\") return JSON.stringify(v);\n return String(v);\n}\n","import type { EmbedElement } from \"../../types\";\n\nexport default function EmbedHost({ element }: { element: EmbedElement }) {\n return (\n <iframe\n src={element.src}\n title={element.title ?? \"Embedded content\"}\n sandbox={element.sandbox ?? \"allow-scripts\"}\n style={{ width: \"100%\", height: \"100%\", border: 0, display: \"block\" }}\n />\n );\n}\n","/**\n * Default element registry. Wires up the element types fancy-slides doesn't\n * render natively (chart / code / table / embed) by composing the other\n * fancy packages as optional peer deps.\n *\n * Hosts opt into this by importing from the `/registry` subpath:\n *\n * import { defaultElementRegistry } from \"@particle-academy/fancy-slides/registry\";\n * <DeckEditor renderElement={defaultElementRegistry} … />\n *\n * Keeping it behind a subpath means consumers who only render decks with\n * built-in element types (text / image / shape) never pull fancy-echarts,\n * fancy-code, or react-fancy Table into their bundle.\n */\n\nimport { lazy, Suspense } from \"react\";\nimport type { ChartElement, CodeElement, SlideElement, EmbedElement, TableElement } from \"../types\";\n\nconst ChartHost = lazy(() => import(\"./element-renderers/chart-host\"));\nconst CodeHost = lazy(() => import(\"./element-renderers/code-host\"));\nconst TableHost = lazy(() => import(\"./element-renderers/table-host\"));\nconst EmbedHost = lazy(() => import(\"./element-renderers/embed-host\"));\n\nconst Loading = ({ label }: { label: string }) => (\n <div\n style={{\n display: \"grid\",\n placeItems: \"center\",\n width: \"100%\",\n height: \"100%\",\n color: \"rgba(0,0,0,0.4)\",\n fontSize: 12,\n fontFamily: \"ui-sans-serif, system-ui, sans-serif\",\n }}\n >\n {label}…\n </div>\n);\n\n/**\n * Renderer signature compatible with `Slide`'s `renderElement` prop. Returns\n * `undefined` for element types fancy-slides handles itself, so the call\n * site falls back to the built-in renderer.\n */\nexport function defaultElementRegistry(element: SlideElement, slideWidthPx: number) {\n switch (element.type) {\n case \"chart\":\n return (\n <Suspense fallback={<Loading label=\"Loading chart\" />}>\n <ChartHost element={element as ChartElement} slideWidthPx={slideWidthPx} />\n </Suspense>\n );\n case \"code\":\n return (\n <Suspense fallback={<Loading label=\"Loading code\" />}>\n <CodeHost element={element as CodeElement} />\n </Suspense>\n );\n case \"table\":\n return (\n <Suspense fallback={<Loading label=\"Loading table\" />}>\n <TableHost element={element as TableElement} />\n </Suspense>\n );\n case \"embed\":\n return (\n <Suspense fallback={<Loading label=\"Loading embed\" />}>\n <EmbedHost element={element as EmbedElement} />\n </Suspense>\n );\n default:\n return undefined;\n }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { h as SlideElement } from './types-Bc-psiRF.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Renderer signature compatible with `Slide`'s `renderElement` prop. Returns
|
|
6
|
+
* `undefined` for element types fancy-slides handles itself, so the call
|
|
7
|
+
* site falls back to the built-in renderer.
|
|
8
|
+
*/
|
|
9
|
+
declare function defaultElementRegistry(element: SlideElement, slideWidthPx: number): react_jsx_runtime.JSX.Element | undefined;
|
|
10
|
+
|
|
11
|
+
export { defaultElementRegistry };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { h as SlideElement } from './types-Bc-psiRF.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Renderer signature compatible with `Slide`'s `renderElement` prop. Returns
|
|
6
|
+
* `undefined` for element types fancy-slides handles itself, so the call
|
|
7
|
+
* site falls back to the built-in renderer.
|
|
8
|
+
*/
|
|
9
|
+
declare function defaultElementRegistry(element: SlideElement, slideWidthPx: number): react_jsx_runtime.JSX.Element | undefined;
|
|
10
|
+
|
|
11
|
+
export { defaultElementRegistry };
|
package/dist/registry.js
CHANGED
|
@@ -2,7 +2,7 @@ import { lazy, Suspense } from 'react';
|
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
|
|
4
4
|
// src/registry/index.tsx
|
|
5
|
-
var ChartHost = lazy(() => import('./chart-host-
|
|
5
|
+
var ChartHost = lazy(() => import('./chart-host-X55F6S44.js'));
|
|
6
6
|
var CodeHost = lazy(() => import('./code-host-IYT6QDLA.js'));
|
|
7
7
|
var TableHost = lazy(() => import('./table-host-LWPOQHTL.js'));
|
|
8
8
|
var EmbedHost = lazy(() => import('./embed-host-ZECUEAOU.js'));
|
package/dist/styles.d.ts
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fancy-slides data model.
|
|
3
|
+
*
|
|
4
|
+
* Every shape here is JSON-friendly — pure objects, arrays, primitives, and
|
|
5
|
+
* tagged unions. No React children, no functions, no class instances. This
|
|
6
|
+
* is the contract the deck schema commits to: an LLM can emit a deck, a
|
|
7
|
+
* server can store one, a designer can hand-edit one, and the viewer +
|
|
8
|
+
* editor will render it identically.
|
|
9
|
+
*
|
|
10
|
+
* Coordinate system: elements position themselves in slide-relative units
|
|
11
|
+
* where the slide is a 1.0 × (1 / aspectRatio) rectangle. So `x: 0.5, y: 0.5`
|
|
12
|
+
* is the centre of the slide regardless of how big it's rendered. This
|
|
13
|
+
* keeps decks resolution-independent — a fullscreen 1920×1080 viewer and a
|
|
14
|
+
* thumbnail at 320×180 render the same layout.
|
|
15
|
+
*/
|
|
16
|
+
interface Deck {
|
|
17
|
+
/** Stable id. Required even when persistence is in-memory. */
|
|
18
|
+
id: string;
|
|
19
|
+
/** Human title — shown in the editor chrome + browser tab. */
|
|
20
|
+
title: string;
|
|
21
|
+
/** Ordered slide list. The viewer steps through in this order. */
|
|
22
|
+
slides: Slide[];
|
|
23
|
+
/** Visual theme for the whole deck. */
|
|
24
|
+
theme: Theme;
|
|
25
|
+
/** Free-form metadata — `{ author, createdAt, updatedAt, tags, … }`. */
|
|
26
|
+
metadata?: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
/** Layout presets that pre-populate / constrain element placement. */
|
|
29
|
+
type SlideLayout = "blank" | "title" | "title-content" | "two-column" | "section-divider" | "image-text" | "text-image" | "quote";
|
|
30
|
+
interface Slide {
|
|
31
|
+
/** Stable id. */
|
|
32
|
+
id: string;
|
|
33
|
+
/** Optional layout preset. Mostly used by agents — humans tend to free-place. */
|
|
34
|
+
layout?: SlideLayout;
|
|
35
|
+
/** Elements rendered on the slide in z-order (last on top). */
|
|
36
|
+
elements: SlideElement[];
|
|
37
|
+
/** Background fill — color, image, or gradient. Inherits from theme when absent. */
|
|
38
|
+
background?: SlideBackground;
|
|
39
|
+
/** Entrance transition for this slide. Inherits from theme.transition when absent. */
|
|
40
|
+
transition?: SlideTransition;
|
|
41
|
+
/** Speaker notes — markdown. */
|
|
42
|
+
notes?: string;
|
|
43
|
+
/** Free-form metadata — `{ title, tags, durationSec, … }`. */
|
|
44
|
+
metadata?: Record<string, unknown>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Every element is positioned in slide-relative coordinates (0..1). x/y are
|
|
48
|
+
* the top-left corner; w/h are width/height as a fraction of the slide.
|
|
49
|
+
*/
|
|
50
|
+
interface ElementBase {
|
|
51
|
+
/** Stable id. Agents reference elements by id. */
|
|
52
|
+
id: string;
|
|
53
|
+
/** Element kind — discriminator. */
|
|
54
|
+
type: SlideElement["type"];
|
|
55
|
+
/** Left edge, 0..1 (fraction of slide width). */
|
|
56
|
+
x: number;
|
|
57
|
+
/** Top edge, 0..1 (fraction of slide height). */
|
|
58
|
+
y: number;
|
|
59
|
+
/** Width, 0..1. */
|
|
60
|
+
w: number;
|
|
61
|
+
/** Height, 0..1. */
|
|
62
|
+
h: number;
|
|
63
|
+
/** Rotation in degrees, clockwise. */
|
|
64
|
+
rotation?: number;
|
|
65
|
+
/** Z-order — higher renders on top. Falls back to array order when undefined. */
|
|
66
|
+
z?: number;
|
|
67
|
+
/** Lock from editing. */
|
|
68
|
+
locked?: boolean;
|
|
69
|
+
/** Hide on this slide (still in the data — for animated reveals). */
|
|
70
|
+
hidden?: boolean;
|
|
71
|
+
}
|
|
72
|
+
interface TextElement extends ElementBase {
|
|
73
|
+
type: "text";
|
|
74
|
+
/** Content — markdown by default; can also be plain text or HTML. */
|
|
75
|
+
content: string;
|
|
76
|
+
/** Content format. Defaults to `"markdown"`. */
|
|
77
|
+
format?: "markdown" | "html" | "plain";
|
|
78
|
+
/** Typography. */
|
|
79
|
+
style?: TextStyle;
|
|
80
|
+
}
|
|
81
|
+
interface TextStyle {
|
|
82
|
+
/** Font family — falls back to theme.fonts.body. */
|
|
83
|
+
fontFamily?: string;
|
|
84
|
+
/** Font size in px at the slide's design width (theme.slideWidth). */
|
|
85
|
+
fontSize?: number;
|
|
86
|
+
/** Font weight (`100..900`, or `"normal" | "bold"`). */
|
|
87
|
+
weight?: "normal" | "medium" | "semibold" | "bold" | number;
|
|
88
|
+
/** Horizontal alignment. */
|
|
89
|
+
align?: "left" | "center" | "right" | "justify";
|
|
90
|
+
/** Vertical alignment within the box. */
|
|
91
|
+
verticalAlign?: "top" | "middle" | "bottom";
|
|
92
|
+
/** Color (any CSS color). Falls back to theme.colors.text. */
|
|
93
|
+
color?: string;
|
|
94
|
+
/** Line height (multiplier). */
|
|
95
|
+
lineHeight?: number;
|
|
96
|
+
/** Italic. */
|
|
97
|
+
italic?: boolean;
|
|
98
|
+
/** Underline. */
|
|
99
|
+
underline?: boolean;
|
|
100
|
+
}
|
|
101
|
+
interface ImageElement extends ElementBase {
|
|
102
|
+
type: "image";
|
|
103
|
+
/** Image URL or data URI. */
|
|
104
|
+
src: string;
|
|
105
|
+
/** Alt text for accessibility. */
|
|
106
|
+
alt?: string;
|
|
107
|
+
/** How the image is fit inside its box. */
|
|
108
|
+
fit?: "contain" | "cover" | "fill" | "scale-down";
|
|
109
|
+
/** Optional crop window (slide-relative). */
|
|
110
|
+
crop?: {
|
|
111
|
+
x: number;
|
|
112
|
+
y: number;
|
|
113
|
+
w: number;
|
|
114
|
+
h: number;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
interface ChartElement extends ElementBase {
|
|
118
|
+
type: "chart";
|
|
119
|
+
/** Apache ECharts option object. Passed straight to `<EChart>`. */
|
|
120
|
+
option: Record<string, unknown>;
|
|
121
|
+
/** Theme name passed to `<EChart>`. */
|
|
122
|
+
chartTheme?: string;
|
|
123
|
+
}
|
|
124
|
+
interface CodeElement extends ElementBase {
|
|
125
|
+
type: "code";
|
|
126
|
+
/** Source code. */
|
|
127
|
+
code: string;
|
|
128
|
+
/** Language alias for the highlighter. */
|
|
129
|
+
language?: string;
|
|
130
|
+
/** Show line numbers. Defaults to `true`. */
|
|
131
|
+
lineNumbers?: boolean;
|
|
132
|
+
/** Theme — `"light"`, `"dark"`, `"auto"`, or a custom registered name. */
|
|
133
|
+
codeTheme?: string;
|
|
134
|
+
}
|
|
135
|
+
interface TableElement extends ElementBase {
|
|
136
|
+
type: "table";
|
|
137
|
+
/** Column definitions — `{ key, label }`. */
|
|
138
|
+
columns: Array<{
|
|
139
|
+
key: string;
|
|
140
|
+
label: string;
|
|
141
|
+
}>;
|
|
142
|
+
/** Row data — array of objects keyed by column. */
|
|
143
|
+
rows: Array<Record<string, unknown>>;
|
|
144
|
+
}
|
|
145
|
+
type ShapeKind = "rect" | "rounded-rect" | "ellipse" | "line" | "arrow" | "triangle";
|
|
146
|
+
interface ShapeElement extends ElementBase {
|
|
147
|
+
type: "shape";
|
|
148
|
+
shape: ShapeKind;
|
|
149
|
+
/** Fill color (any CSS color, or `"none"`). */
|
|
150
|
+
fill?: string;
|
|
151
|
+
/** Stroke color. */
|
|
152
|
+
stroke?: string;
|
|
153
|
+
/** Stroke width in px at the slide's design width. */
|
|
154
|
+
strokeWidth?: number;
|
|
155
|
+
/** Dashed stroke. */
|
|
156
|
+
dashed?: boolean;
|
|
157
|
+
/** Corner radius (px) for `rect` / `rounded-rect`. */
|
|
158
|
+
radius?: number;
|
|
159
|
+
}
|
|
160
|
+
interface EmbedElement extends ElementBase {
|
|
161
|
+
type: "embed";
|
|
162
|
+
/** Embed URL — typically a video, dashboard, or fancy-screens Screen. */
|
|
163
|
+
src: string;
|
|
164
|
+
/** iframe `title` for accessibility. */
|
|
165
|
+
title?: string;
|
|
166
|
+
/** Sandbox attribute. Defaults to allow-scripts (no allow-same-origin). */
|
|
167
|
+
sandbox?: string;
|
|
168
|
+
}
|
|
169
|
+
type SlideElement = TextElement | ImageElement | ChartElement | CodeElement | TableElement | ShapeElement | EmbedElement;
|
|
170
|
+
interface SlideBackground {
|
|
171
|
+
/** Solid color, or `"transparent"` to inherit theme. */
|
|
172
|
+
color?: string;
|
|
173
|
+
/** Image background URL. Takes precedence over color when present. */
|
|
174
|
+
image?: string;
|
|
175
|
+
/** How the background image is fit. Defaults to `"cover"`. */
|
|
176
|
+
imageFit?: "contain" | "cover" | "fill";
|
|
177
|
+
/** Optional gradient — `"linear-gradient(...)"` or `"radial-gradient(...)"` string. */
|
|
178
|
+
gradient?: string;
|
|
179
|
+
}
|
|
180
|
+
type TransitionKind = "none" | "fade" | "slide" | "zoom";
|
|
181
|
+
interface SlideTransition {
|
|
182
|
+
kind: TransitionKind;
|
|
183
|
+
/** Duration in ms. */
|
|
184
|
+
duration?: number;
|
|
185
|
+
/** Direction for `slide` transitions. */
|
|
186
|
+
direction?: "left" | "right" | "up" | "down";
|
|
187
|
+
}
|
|
188
|
+
interface Theme {
|
|
189
|
+
/** Theme name — used for serialization + agent routing. */
|
|
190
|
+
name: string;
|
|
191
|
+
/** Aspect ratio — defaults to 16:9. Custom themes can pick anything. */
|
|
192
|
+
aspectRatio?: number;
|
|
193
|
+
/** Design width in px. Slides scale to fit; this just sets the unit base for fontSize/strokeWidth. */
|
|
194
|
+
slideWidth?: number;
|
|
195
|
+
colors?: ThemeColors;
|
|
196
|
+
fonts?: ThemeFonts;
|
|
197
|
+
/** Default transition for slides that don't specify their own. */
|
|
198
|
+
defaultTransition?: SlideTransition;
|
|
199
|
+
}
|
|
200
|
+
interface ThemeColors {
|
|
201
|
+
background?: string;
|
|
202
|
+
text?: string;
|
|
203
|
+
muted?: string;
|
|
204
|
+
accent?: string;
|
|
205
|
+
surface?: string;
|
|
206
|
+
}
|
|
207
|
+
interface ThemeFonts {
|
|
208
|
+
/** Used for `Heading`-like text elements (the default for large fontSize). */
|
|
209
|
+
heading?: string;
|
|
210
|
+
/** Used for body text. */
|
|
211
|
+
body?: string;
|
|
212
|
+
/** Used by CodeElement. */
|
|
213
|
+
mono?: string;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Agent activity broadcast whenever the deck mutates. Hosts subscribe to feed
|
|
217
|
+
* an AgentPanel, presence layer, or audit log.
|
|
218
|
+
*/
|
|
219
|
+
interface DeckActivity {
|
|
220
|
+
/** Stable activity id. */
|
|
221
|
+
id: string;
|
|
222
|
+
/** Wall-clock timestamp. */
|
|
223
|
+
at: number;
|
|
224
|
+
/** Who made the change. */
|
|
225
|
+
actor: {
|
|
226
|
+
kind: "human" | "agent";
|
|
227
|
+
id: string;
|
|
228
|
+
name?: string;
|
|
229
|
+
color?: string;
|
|
230
|
+
};
|
|
231
|
+
/** What changed. */
|
|
232
|
+
op: DeckOp;
|
|
233
|
+
}
|
|
234
|
+
type DeckOp = {
|
|
235
|
+
kind: "deck_set_title";
|
|
236
|
+
title: string;
|
|
237
|
+
} | {
|
|
238
|
+
kind: "deck_apply_theme";
|
|
239
|
+
theme: Theme;
|
|
240
|
+
} | {
|
|
241
|
+
kind: "slide_add";
|
|
242
|
+
index: number;
|
|
243
|
+
slide: Slide;
|
|
244
|
+
} | {
|
|
245
|
+
kind: "slide_remove";
|
|
246
|
+
id: string;
|
|
247
|
+
} | {
|
|
248
|
+
kind: "slide_reorder";
|
|
249
|
+
id: string;
|
|
250
|
+
toIndex: number;
|
|
251
|
+
} | {
|
|
252
|
+
kind: "slide_set_layout";
|
|
253
|
+
id: string;
|
|
254
|
+
layout: SlideLayout;
|
|
255
|
+
} | {
|
|
256
|
+
kind: "slide_set_notes";
|
|
257
|
+
id: string;
|
|
258
|
+
notes: string;
|
|
259
|
+
} | {
|
|
260
|
+
kind: "slide_set_background";
|
|
261
|
+
id: string;
|
|
262
|
+
background?: SlideBackground;
|
|
263
|
+
} | {
|
|
264
|
+
kind: "element_add";
|
|
265
|
+
slideId: string;
|
|
266
|
+
element: SlideElement;
|
|
267
|
+
} | {
|
|
268
|
+
kind: "element_remove";
|
|
269
|
+
slideId: string;
|
|
270
|
+
elementId: string;
|
|
271
|
+
} | {
|
|
272
|
+
kind: "element_update";
|
|
273
|
+
slideId: string;
|
|
274
|
+
elementId: string;
|
|
275
|
+
patch: Partial<SlideElement>;
|
|
276
|
+
} | {
|
|
277
|
+
kind: "element_move";
|
|
278
|
+
slideId: string;
|
|
279
|
+
elementId: string;
|
|
280
|
+
x: number;
|
|
281
|
+
y: number;
|
|
282
|
+
} | {
|
|
283
|
+
kind: "element_resize";
|
|
284
|
+
slideId: string;
|
|
285
|
+
elementId: string;
|
|
286
|
+
w: number;
|
|
287
|
+
h: number;
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
export type { ChartElement as C, Deck as D, ElementBase as E, ImageElement as I, ShapeElement as S, TableElement as T, CodeElement as a, DeckActivity as b, DeckOp as c, EmbedElement as d, ShapeKind as e, Slide as f, SlideBackground as g, SlideElement as h, SlideLayout as i, SlideTransition as j, TextElement as k, TextStyle as l, Theme as m, ThemeColors as n, ThemeFonts as o, TransitionKind as p };
|