@particle-academy/fancy-slides 0.8.0 → 0.10.0
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/index.cjs +116 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -3
- package/dist/index.d.ts +44 -3
- package/dist/index.js +112 -5
- package/dist/index.js.map +1 -1
- package/dist/registry.d.cts +1 -1
- package/dist/registry.d.ts +1 -1
- package/dist/{types-9BbelJX1.d.cts → types-C3w37g3A.d.cts} +25 -1
- package/dist/{types-9BbelJX1.d.ts → types-C3w37g3A.d.ts} +25 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode, CSSProperties } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export { A as AnimationEffect, a as AnimationTrigger, C as ChartElement, b as CodeElement, c as DeckActivity, e as ElementBase, f as EmbedElement, T as TableElement,
|
|
3
|
+
import { i as Slide$1, p as Theme, k as SlideElement, D as Deck, d as DeckOp, h as ShapeKind, m as SlideTransition, j as SlideBackground, l as SlideLayout, E as ElementAnimation, n as TextElement, I as ImageElement, g as ShapeElement } from './types-C3w37g3A.cjs';
|
|
4
|
+
export { A as AnimationEffect, a as AnimationTrigger, C as ChartElement, b as CodeElement, c as DeckActivity, e as ElementBase, f as EmbedElement, S as SCHEMA_VERSION, T as TableElement, o as TextStyle, q as ThemeColors, r as ThemeFonts, s as TransitionKind } from './types-C3w37g3A.cjs';
|
|
5
5
|
import { EditorAction } from '@particle-academy/react-fancy';
|
|
6
6
|
|
|
7
7
|
interface SlideProps {
|
|
@@ -594,6 +594,8 @@ interface DeckStateApi {
|
|
|
594
594
|
/** Deck-level helpers. */
|
|
595
595
|
setTitle: (title: string) => void;
|
|
596
596
|
applyTheme: (theme: Theme) => void;
|
|
597
|
+
/** Replace the entire deck — stream a full presentation in atomically. */
|
|
598
|
+
setDeck: (deck: Deck) => void;
|
|
597
599
|
/** Slide-level helpers. */
|
|
598
600
|
addSlide: (index?: number, partial?: Partial<Slide$1>) => string;
|
|
599
601
|
duplicateSlide: (id: string) => string;
|
|
@@ -673,4 +675,43 @@ type ChartKind = "bar" | "line" | "pie" | "area" | "scatter";
|
|
|
673
675
|
type Option = Record<string, unknown>;
|
|
674
676
|
declare function chartStarterOption(kind: ChartKind): Option;
|
|
675
677
|
|
|
676
|
-
|
|
678
|
+
/**
|
|
679
|
+
* Stream a full presentation in and out. The `Deck` is already plain JSON
|
|
680
|
+
* (no functions, no React children), so "serialize" is mostly `JSON.stringify`
|
|
681
|
+
* — these helpers add the schema-version stamp, a forgiving structural
|
|
682
|
+
* validation, and a forward-migration shim so a host can persist a deck, hand
|
|
683
|
+
* it to an agent, and load it back safely.
|
|
684
|
+
*
|
|
685
|
+
* Streaming OUT: read `value` / `onChange` from the controlled editor, or call
|
|
686
|
+
* `serializeDeck(deck)`.
|
|
687
|
+
* Streaming IN: `parseDeck(json)` → feed to `DeckEditor`'s `value`, or apply a
|
|
688
|
+
* `{ kind: "deck_set", deck }` op (also exposed as the bridge's `deck_set` tool).
|
|
689
|
+
*/
|
|
690
|
+
|
|
691
|
+
interface DeckValidation {
|
|
692
|
+
ok: boolean;
|
|
693
|
+
errors: string[];
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Structurally validate a deck. Forgiving by design — it checks the shape an
|
|
697
|
+
* editor / writer relies on (ids, slides array, element types + 0..1 geometry),
|
|
698
|
+
* not every optional field. Returns all problems found rather than throwing.
|
|
699
|
+
*/
|
|
700
|
+
declare function validateDeck(deck: unknown): DeckValidation;
|
|
701
|
+
/**
|
|
702
|
+
* Migrate a deck authored against an older schema version forward to the
|
|
703
|
+
* current one. Today it only stamps the version (no breaking changes yet); the
|
|
704
|
+
* `switch` is where future migrations slot in, each bumping `version` by one.
|
|
705
|
+
*/
|
|
706
|
+
declare function migrateDeck(deck: Deck): Deck;
|
|
707
|
+
/** Serialize a deck to a JSON string, stamping the current schema version. */
|
|
708
|
+
declare function serializeDeck(deck: Deck, pretty?: boolean): string;
|
|
709
|
+
/**
|
|
710
|
+
* Parse a deck from a JSON string (or an already-parsed object), migrating it
|
|
711
|
+
* forward and validating its structure. Throws a descriptive error when the
|
|
712
|
+
* JSON is malformed or the structure is invalid — callers streaming untrusted
|
|
713
|
+
* input should try/catch.
|
|
714
|
+
*/
|
|
715
|
+
declare function parseDeck(input: string | unknown): Deck;
|
|
716
|
+
|
|
717
|
+
export { type Build, type BuildStep, type ChartKind$1 as ChartKind, Deck, DeckEditor, type DeckEditorProps, DeckOp, type DeckStateApi, type DeckValidation, EditorToolbar, type EditorToolbarProps, ElementAnimation, ElementInspector, type ElementInspectorProps, ImageElement, ImageElementRenderer, type ImageElementRendererProps, PRESENTATION_EDITOR_ACTIONS, type ParaReveal, PresenterView, type PresenterViewProps, ShapeElement, ShapeElementRenderer, type ShapeElementRendererProps, ShapeKind, Slide, SlideBackground, type SlideContextValue, Slide$1 as SlideData, SlideElement, type SlideKeyboardOptions, SlideLayout, type SlideProps, SlideRail, type SlideRailProps, SlideThumbnail, type SlideThumbnailProps, SlideTransition, SlideViewer, type SlideViewerProps, SpeakerNotes, type SpeakerNotesProps, TextElement, TextElementRenderer, type TextElementRendererProps, Theme, type UseDeckStateOptions, buildSteps, buildsForStep, builtinThemes, chartStarterOption, collectBuilds, darkTheme, deckId, defaultTheme, defineTheme, elementId, isByParagraph, migrateDeck, nextId, normalizeSlideMarkdown, paragraphReveals, parseDeck, reduce as reduceDeck, resolveTheme, serializeDeck, slideId, splitParagraphs, stepDelays, totalBuildSteps, useDeckState, useIsDarkSlide, useSlideContext, useSlideKeyboard, useSlideTheme, validateDeck, visibleElementIds, vividTheme };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode, CSSProperties } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export { A as AnimationEffect, a as AnimationTrigger, C as ChartElement, b as CodeElement, c as DeckActivity, e as ElementBase, f as EmbedElement, T as TableElement,
|
|
3
|
+
import { i as Slide$1, p as Theme, k as SlideElement, D as Deck, d as DeckOp, h as ShapeKind, m as SlideTransition, j as SlideBackground, l as SlideLayout, E as ElementAnimation, n as TextElement, I as ImageElement, g as ShapeElement } from './types-C3w37g3A.js';
|
|
4
|
+
export { A as AnimationEffect, a as AnimationTrigger, C as ChartElement, b as CodeElement, c as DeckActivity, e as ElementBase, f as EmbedElement, S as SCHEMA_VERSION, T as TableElement, o as TextStyle, q as ThemeColors, r as ThemeFonts, s as TransitionKind } from './types-C3w37g3A.js';
|
|
5
5
|
import { EditorAction } from '@particle-academy/react-fancy';
|
|
6
6
|
|
|
7
7
|
interface SlideProps {
|
|
@@ -594,6 +594,8 @@ interface DeckStateApi {
|
|
|
594
594
|
/** Deck-level helpers. */
|
|
595
595
|
setTitle: (title: string) => void;
|
|
596
596
|
applyTheme: (theme: Theme) => void;
|
|
597
|
+
/** Replace the entire deck — stream a full presentation in atomically. */
|
|
598
|
+
setDeck: (deck: Deck) => void;
|
|
597
599
|
/** Slide-level helpers. */
|
|
598
600
|
addSlide: (index?: number, partial?: Partial<Slide$1>) => string;
|
|
599
601
|
duplicateSlide: (id: string) => string;
|
|
@@ -673,4 +675,43 @@ type ChartKind = "bar" | "line" | "pie" | "area" | "scatter";
|
|
|
673
675
|
type Option = Record<string, unknown>;
|
|
674
676
|
declare function chartStarterOption(kind: ChartKind): Option;
|
|
675
677
|
|
|
676
|
-
|
|
678
|
+
/**
|
|
679
|
+
* Stream a full presentation in and out. The `Deck` is already plain JSON
|
|
680
|
+
* (no functions, no React children), so "serialize" is mostly `JSON.stringify`
|
|
681
|
+
* — these helpers add the schema-version stamp, a forgiving structural
|
|
682
|
+
* validation, and a forward-migration shim so a host can persist a deck, hand
|
|
683
|
+
* it to an agent, and load it back safely.
|
|
684
|
+
*
|
|
685
|
+
* Streaming OUT: read `value` / `onChange` from the controlled editor, or call
|
|
686
|
+
* `serializeDeck(deck)`.
|
|
687
|
+
* Streaming IN: `parseDeck(json)` → feed to `DeckEditor`'s `value`, or apply a
|
|
688
|
+
* `{ kind: "deck_set", deck }` op (also exposed as the bridge's `deck_set` tool).
|
|
689
|
+
*/
|
|
690
|
+
|
|
691
|
+
interface DeckValidation {
|
|
692
|
+
ok: boolean;
|
|
693
|
+
errors: string[];
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Structurally validate a deck. Forgiving by design — it checks the shape an
|
|
697
|
+
* editor / writer relies on (ids, slides array, element types + 0..1 geometry),
|
|
698
|
+
* not every optional field. Returns all problems found rather than throwing.
|
|
699
|
+
*/
|
|
700
|
+
declare function validateDeck(deck: unknown): DeckValidation;
|
|
701
|
+
/**
|
|
702
|
+
* Migrate a deck authored against an older schema version forward to the
|
|
703
|
+
* current one. Today it only stamps the version (no breaking changes yet); the
|
|
704
|
+
* `switch` is where future migrations slot in, each bumping `version` by one.
|
|
705
|
+
*/
|
|
706
|
+
declare function migrateDeck(deck: Deck): Deck;
|
|
707
|
+
/** Serialize a deck to a JSON string, stamping the current schema version. */
|
|
708
|
+
declare function serializeDeck(deck: Deck, pretty?: boolean): string;
|
|
709
|
+
/**
|
|
710
|
+
* Parse a deck from a JSON string (or an already-parsed object), migrating it
|
|
711
|
+
* forward and validating its structure. Throws a descriptive error when the
|
|
712
|
+
* JSON is malformed or the structure is invalid — callers streaming untrusted
|
|
713
|
+
* input should try/catch.
|
|
714
|
+
*/
|
|
715
|
+
declare function parseDeck(input: string | unknown): Deck;
|
|
716
|
+
|
|
717
|
+
export { type Build, type BuildStep, type ChartKind$1 as ChartKind, Deck, DeckEditor, type DeckEditorProps, DeckOp, type DeckStateApi, type DeckValidation, EditorToolbar, type EditorToolbarProps, ElementAnimation, ElementInspector, type ElementInspectorProps, ImageElement, ImageElementRenderer, type ImageElementRendererProps, PRESENTATION_EDITOR_ACTIONS, type ParaReveal, PresenterView, type PresenterViewProps, ShapeElement, ShapeElementRenderer, type ShapeElementRendererProps, ShapeKind, Slide, SlideBackground, type SlideContextValue, Slide$1 as SlideData, SlideElement, type SlideKeyboardOptions, SlideLayout, type SlideProps, SlideRail, type SlideRailProps, SlideThumbnail, type SlideThumbnailProps, SlideTransition, SlideViewer, type SlideViewerProps, SpeakerNotes, type SpeakerNotesProps, TextElement, TextElementRenderer, type TextElementRendererProps, Theme, type UseDeckStateOptions, buildSteps, buildsForStep, builtinThemes, chartStarterOption, collectBuilds, darkTheme, deckId, defaultTheme, defineTheme, elementId, isByParagraph, migrateDeck, nextId, normalizeSlideMarkdown, paragraphReveals, parseDeck, reduce as reduceDeck, resolveTheme, serializeDeck, slideId, splitParagraphs, stepDelays, totalBuildSteps, useDeckState, useIsDarkSlide, useSlideContext, useSlideKeyboard, useSlideTheme, validateDeck, visibleElementIds, vividTheme };
|
package/dist/index.js
CHANGED
|
@@ -728,7 +728,18 @@ function SlideElementHost({
|
|
|
728
728
|
touchAction: canMove ? "none" : void 0,
|
|
729
729
|
...buildAnimation ? buildEnterStyle(buildAnimation, buildDelay) : null
|
|
730
730
|
};
|
|
731
|
-
const
|
|
731
|
+
const rendered = renderInner({ element, theme, slideWidthPx, editing, selected, onContentChange, paraReveal }) ?? renderElement?.(element, slideWidthPx) ?? elementPlaceholder(element);
|
|
732
|
+
const inner = element.href && !editing ? /* @__PURE__ */ jsx(
|
|
733
|
+
"a",
|
|
734
|
+
{
|
|
735
|
+
href: element.href,
|
|
736
|
+
target: "_blank",
|
|
737
|
+
rel: "noreferrer",
|
|
738
|
+
style: { display: "block", width: "100%", height: "100%", color: "inherit", textDecoration: "inherit" },
|
|
739
|
+
"data-fancy-slides-href": "",
|
|
740
|
+
children: rendered
|
|
741
|
+
}
|
|
742
|
+
) : rendered;
|
|
732
743
|
return /* @__PURE__ */ jsxs(
|
|
733
744
|
"div",
|
|
734
745
|
{
|
|
@@ -1531,6 +1542,7 @@ function useDeckState({ value, onChange, onOp }) {
|
|
|
1531
1542
|
apply,
|
|
1532
1543
|
setTitle: (title) => apply({ kind: "deck_set_title", title }),
|
|
1533
1544
|
applyTheme: (theme) => apply({ kind: "deck_apply_theme", theme }),
|
|
1545
|
+
setDeck: (deck) => apply({ kind: "deck_set", deck }),
|
|
1534
1546
|
addSlide: (index, partial) => {
|
|
1535
1547
|
const id = partial?.id ?? slideId();
|
|
1536
1548
|
const slide = {
|
|
@@ -1585,6 +1597,8 @@ function reduce(deck, op) {
|
|
|
1585
1597
|
return { ...deck, title: op.title };
|
|
1586
1598
|
case "deck_apply_theme":
|
|
1587
1599
|
return { ...deck, theme: op.theme };
|
|
1600
|
+
case "deck_set":
|
|
1601
|
+
return op.deck;
|
|
1588
1602
|
case "slide_add": {
|
|
1589
1603
|
const slides = [...deck.slides];
|
|
1590
1604
|
slides.splice(Math.max(0, Math.min(slides.length, op.index)), 0, op.slide);
|
|
@@ -2033,7 +2047,7 @@ function ElementInspector({ element, onPatch, onDelete, onLockToggle, slide, onS
|
|
|
2033
2047
|
/* @__PURE__ */ jsxs(Tabs.Panels, { children: [
|
|
2034
2048
|
/* @__PURE__ */ jsx(Tabs.Panel, { value: "style", children: /* @__PURE__ */ jsx(Card, { padding: "md", className: "!bg-white dark:!bg-zinc-950", children: /* @__PURE__ */ jsx(StyleSection, { element, onPatch }) }) }),
|
|
2035
2049
|
/* @__PURE__ */ jsx(Tabs.Panel, { value: "build", children: /* @__PURE__ */ jsx(Card, { padding: "md", className: "!bg-white dark:!bg-zinc-950", children: /* @__PURE__ */ jsx(AnimateSection, { animation: element.animation, onSetAnimation, isText: element.type === "text" }) }) }),
|
|
2036
|
-
/* @__PURE__ */ jsx(Tabs.Panel, { value: "layout", children: /* @__PURE__ */ jsx(Card, { padding: "md", className: "!bg-white dark:!bg-zinc-950", children: /* @__PURE__ */ jsx(LayoutSection, { element, onPatch }) }) }),
|
|
2050
|
+
/* @__PURE__ */ jsx(Tabs.Panel, { value: "layout", children: /* @__PURE__ */ jsx(Card, { padding: "md", className: "!bg-white dark:!bg-zinc-950", children: /* @__PURE__ */ jsx(LayoutSection, { element, onPatch, siblings: slide?.elements ?? [] }) }) }),
|
|
2037
2051
|
/* @__PURE__ */ jsx(Tabs.Panel, { value: "advanced", children: /* @__PURE__ */ jsx(Card, { padding: "md", className: "!bg-white dark:!bg-zinc-950", children: /* @__PURE__ */ jsx(AdvancedSection, { element, onPatch }) }) })
|
|
2038
2052
|
] })
|
|
2039
2053
|
] }) })
|
|
@@ -2238,7 +2252,10 @@ function buildLabel(element) {
|
|
|
2238
2252
|
}
|
|
2239
2253
|
return `${element.type} #${element.id.slice(-6)}`;
|
|
2240
2254
|
}
|
|
2241
|
-
function LayoutSection({ element, onPatch }) {
|
|
2255
|
+
function LayoutSection({ element, onPatch, siblings }) {
|
|
2256
|
+
const zs = siblings.map((e) => e.z ?? 0);
|
|
2257
|
+
const bringToFront = () => onPatch({ z: (zs.length ? Math.max(...zs) : 0) + 1 });
|
|
2258
|
+
const sendToBack = () => onPatch({ z: (zs.length ? Math.min(...zs) : 0) - 1 });
|
|
2242
2259
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2243
2260
|
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
|
|
2244
2261
|
/* @__PURE__ */ jsx(Input, { label: "X", type: "number", value: String(roundFrac(element.x)), onChange: (e) => onPatch({ x: clamp2(parseFloat(e.target.value), 0, 1) }) }),
|
|
@@ -2248,7 +2265,26 @@ function LayoutSection({ element, onPatch }) {
|
|
|
2248
2265
|
] }),
|
|
2249
2266
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
2250
2267
|
/* @__PURE__ */ jsx(Slider, { label: "Rotation", value: element.rotation ?? 0, onValueChange: (v) => onPatch({ rotation: Number(v) }), min: -180, max: 180 }),
|
|
2251
|
-
/* @__PURE__ */
|
|
2268
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2", children: [
|
|
2269
|
+
/* @__PURE__ */ jsx(Input, { label: "Z-index", type: "number", value: String(element.z ?? 0), onChange: (e) => onPatch({ z: parseInt(e.target.value, 10) || 0 }), className: "flex-1" }),
|
|
2270
|
+
/* @__PURE__ */ jsx(Action, { size: "sm", variant: "ghost", onClick: bringToFront, "aria-label": "Bring to front", children: "Front" }),
|
|
2271
|
+
/* @__PURE__ */ jsx(Action, { size: "sm", variant: "ghost", onClick: sendToBack, "aria-label": "Send to back", children: "Back" })
|
|
2272
|
+
] }),
|
|
2273
|
+
/* @__PURE__ */ jsx(Separator, {}),
|
|
2274
|
+
/* @__PURE__ */ jsx(
|
|
2275
|
+
Input,
|
|
2276
|
+
{
|
|
2277
|
+
label: "Link (href)",
|
|
2278
|
+
value: element.href ?? "",
|
|
2279
|
+
placeholder: "https://\u2026",
|
|
2280
|
+
onChange: (e) => onPatch({ href: e.target.value || void 0 })
|
|
2281
|
+
}
|
|
2282
|
+
),
|
|
2283
|
+
/* @__PURE__ */ jsxs(Text, { size: "xs", className: "!text-zinc-500", children: [
|
|
2284
|
+
"Makes the whole element a click target in the viewer (opens a new tab) and exports as a pptx hyperlink. For links inside text, use markdown ",
|
|
2285
|
+
/* @__PURE__ */ jsx("code", { children: "[label](url)" }),
|
|
2286
|
+
"."
|
|
2287
|
+
] })
|
|
2252
2288
|
] });
|
|
2253
2289
|
}
|
|
2254
2290
|
function AdvancedSection({ element, onPatch }) {
|
|
@@ -3070,6 +3106,77 @@ function DeckEditor({
|
|
|
3070
3106
|
);
|
|
3071
3107
|
}
|
|
3072
3108
|
|
|
3073
|
-
|
|
3109
|
+
// src/types.ts
|
|
3110
|
+
var SCHEMA_VERSION = 1;
|
|
3111
|
+
|
|
3112
|
+
// src/utils/serialize.ts
|
|
3113
|
+
var ELEMENT_TYPES = ["text", "image", "chart", "code", "table", "shape", "embed"];
|
|
3114
|
+
function validateDeck(deck) {
|
|
3115
|
+
const errors = [];
|
|
3116
|
+
const d = deck;
|
|
3117
|
+
if (!d || typeof d !== "object") {
|
|
3118
|
+
return { ok: false, errors: ["deck is not an object"] };
|
|
3119
|
+
}
|
|
3120
|
+
if (typeof d.id !== "string" || !d.id) errors.push("deck.id must be a non-empty string");
|
|
3121
|
+
if (typeof d.title !== "string") errors.push("deck.title must be a string");
|
|
3122
|
+
if (!d.theme || typeof d.theme !== "object") errors.push("deck.theme must be an object");
|
|
3123
|
+
if (!Array.isArray(d.slides)) {
|
|
3124
|
+
errors.push("deck.slides must be an array");
|
|
3125
|
+
return { ok: errors.length === 0, errors };
|
|
3126
|
+
}
|
|
3127
|
+
d.slides.forEach((slide, si) => {
|
|
3128
|
+
if (!slide || typeof slide !== "object") {
|
|
3129
|
+
errors.push(`slides[${si}] is not an object`);
|
|
3130
|
+
return;
|
|
3131
|
+
}
|
|
3132
|
+
if (typeof slide.id !== "string" || !slide.id) errors.push(`slides[${si}].id must be a non-empty string`);
|
|
3133
|
+
if (!Array.isArray(slide.elements)) {
|
|
3134
|
+
errors.push(`slides[${si}].elements must be an array`);
|
|
3135
|
+
return;
|
|
3136
|
+
}
|
|
3137
|
+
slide.elements.forEach((el, ei) => {
|
|
3138
|
+
const where = `slides[${si}].elements[${ei}]`;
|
|
3139
|
+
if (!el || typeof el !== "object") {
|
|
3140
|
+
errors.push(`${where} is not an object`);
|
|
3141
|
+
return;
|
|
3142
|
+
}
|
|
3143
|
+
if (typeof el.id !== "string" || !el.id) errors.push(`${where}.id must be a non-empty string`);
|
|
3144
|
+
if (!ELEMENT_TYPES.includes(el.type)) errors.push(`${where}.type "${el.type}" is not a known element type`);
|
|
3145
|
+
for (const k of ["x", "y", "w", "h"]) {
|
|
3146
|
+
const v = el[k];
|
|
3147
|
+
if (typeof v !== "number" || v < 0 || v > 1) errors.push(`${where}.${k} must be a number in 0..1`);
|
|
3148
|
+
}
|
|
3149
|
+
});
|
|
3150
|
+
});
|
|
3151
|
+
return { ok: errors.length === 0, errors };
|
|
3152
|
+
}
|
|
3153
|
+
function migrateDeck(deck) {
|
|
3154
|
+
let d = deck;
|
|
3155
|
+
d.version ?? 1;
|
|
3156
|
+
return d.version === SCHEMA_VERSION ? d : { ...d, version: SCHEMA_VERSION };
|
|
3157
|
+
}
|
|
3158
|
+
function serializeDeck(deck, pretty = false) {
|
|
3159
|
+
const stamped = deck.version === SCHEMA_VERSION ? deck : { ...deck, version: SCHEMA_VERSION };
|
|
3160
|
+
return JSON.stringify(stamped, null, pretty ? 2 : void 0);
|
|
3161
|
+
}
|
|
3162
|
+
function parseDeck(input) {
|
|
3163
|
+
let raw;
|
|
3164
|
+
if (typeof input === "string") {
|
|
3165
|
+
try {
|
|
3166
|
+
raw = JSON.parse(input);
|
|
3167
|
+
} catch (e) {
|
|
3168
|
+
throw new Error(`parseDeck: invalid JSON \u2014 ${e.message}`);
|
|
3169
|
+
}
|
|
3170
|
+
} else {
|
|
3171
|
+
raw = input;
|
|
3172
|
+
}
|
|
3173
|
+
const result = validateDeck(raw);
|
|
3174
|
+
if (!result.ok) {
|
|
3175
|
+
throw new Error(`parseDeck: invalid deck \u2014 ${result.errors.join("; ")}`);
|
|
3176
|
+
}
|
|
3177
|
+
return migrateDeck(raw);
|
|
3178
|
+
}
|
|
3179
|
+
|
|
3180
|
+
export { DeckEditor, EditorToolbar, ElementInspector, ImageElementRenderer, PRESENTATION_EDITOR_ACTIONS, PresenterView, SCHEMA_VERSION, ShapeElementRenderer, Slide, SlideRail, SlideThumbnail, SlideViewer, SpeakerNotes, TextElementRenderer, buildSteps, buildsForStep, builtinThemes, chartStarterOption, collectBuilds, darkTheme, deckId, defaultTheme, defineTheme, elementId, isByParagraph, migrateDeck, nextId, normalizeSlideMarkdown, paragraphReveals, parseDeck, reduce as reduceDeck, resolveTheme, serializeDeck, slideId, splitParagraphs, stepDelays, totalBuildSteps, useDeckState, useSlideKeyboard, validateDeck, visibleElementIds, vividTheme };
|
|
3074
3181
|
//# sourceMappingURL=index.js.map
|
|
3075
3182
|
//# sourceMappingURL=index.js.map
|