@starrykit/slides-core 0.1.26

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.
@@ -0,0 +1,36 @@
1
+ export interface RectLike {
2
+ left: number;
3
+ top: number;
4
+ width: number;
5
+ height: number;
6
+ }
7
+ export interface StageRect {
8
+ x: number;
9
+ y: number;
10
+ width: number;
11
+ height: number;
12
+ }
13
+ export interface StageGeometry {
14
+ scale: number;
15
+ offsetX: number;
16
+ offsetY: number;
17
+ slideWidth: number;
18
+ slideHeight: number;
19
+ }
20
+ export declare const ELEMENT_LAYOUT_STYLE_KEYS: readonly ["position", "left", "top", "width", "maxWidth", "height", "transform", "transformOrigin", "margin", "zIndex"];
21
+ export type ElementLayoutStyleKey = (typeof ELEMENT_LAYOUT_STYLE_KEYS)[number];
22
+ export type ElementLayoutStyleSnapshot = Record<ElementLayoutStyleKey, string | null>;
23
+ export declare function createEmptyElementLayoutStyleSnapshot(): ElementLayoutStyleSnapshot;
24
+ export declare function captureElementLayoutStyleSnapshot(node: HTMLElement): ElementLayoutStyleSnapshot;
25
+ export declare function normalizeElementLayoutStyleSnapshot(snapshot: Partial<ElementLayoutStyleSnapshot>): ElementLayoutStyleSnapshot;
26
+ export declare function parseTransformParts(transformValue: string | null | undefined): {
27
+ translateX: number;
28
+ translateY: number;
29
+ rotate: number;
30
+ };
31
+ export declare function composeTransform(translateX: number, translateY: number, rotate: number): string | null;
32
+ export declare function elementRectToStageRect(elementRect: RectLike, rootRect: RectLike, geometry: StageGeometry): StageRect;
33
+ export declare function stageDeltaToSlideDelta(deltaX: number, deltaY: number, geometry: StageGeometry): {
34
+ x: number;
35
+ y: number;
36
+ };
@@ -0,0 +1,20 @@
1
+ import type { SlideDeckManifestEntry } from "./slide-contract.js";
2
+ export type PdfExportSelection = {
3
+ mode?: "all";
4
+ } | {
5
+ mode: "slide";
6
+ slideFile?: string;
7
+ } | {
8
+ mode: "slides";
9
+ slideFiles?: string[];
10
+ };
11
+ export type ResolvedPdfExportMode = "all" | "single" | "slides";
12
+ export interface ResolvedPdfExportSelection {
13
+ mode: ResolvedPdfExportMode;
14
+ slides: SlideDeckManifestEntry[];
15
+ }
16
+ export declare function planPdfExport({ slides, selection, }: {
17
+ slides: SlideDeckManifestEntry[];
18
+ selection?: PdfExportSelection;
19
+ }): ResolvedPdfExportSelection;
20
+ export declare function planPdfExportSlides(slides: SlideDeckManifestEntry[], selection?: PdfExportSelection): SlideDeckManifestEntry[];
@@ -0,0 +1,7 @@
1
+ export type PresentationTool = "none" | "laser" | "pen";
2
+ export declare const PRESENTATION_PEN_COLORS: string[];
3
+ export interface PresentableSlide {
4
+ hidden?: boolean;
5
+ }
6
+ export declare function planPresentationSlides<TSlide extends PresentableSlide>(slides: TSlide[]): TSlide[];
7
+ export declare function clampPresentationIndex(index: number, slideCount: number): number;
@@ -0,0 +1,56 @@
1
+ export type EditableType = "text" | "image" | "block" | "group";
2
+ export interface EditableElement {
3
+ id: string;
4
+ selector: string;
5
+ type: EditableType;
6
+ content: string;
7
+ tagName: string;
8
+ }
9
+ export interface SlideModel {
10
+ id: string;
11
+ title: string;
12
+ htmlSource: string;
13
+ rootSelector: string;
14
+ width: number;
15
+ height: number;
16
+ elements: EditableElement[];
17
+ sourceFile?: string;
18
+ hidden?: boolean;
19
+ }
20
+ export interface SlideDeckManifestEntry {
21
+ file: string;
22
+ title?: string;
23
+ hidden?: boolean;
24
+ archetype?: string;
25
+ notes?: string;
26
+ }
27
+ export interface SlideDeckManifest {
28
+ deckTitle?: string;
29
+ description?: string;
30
+ generatedAt?: string;
31
+ slides?: SlideDeckManifestEntry[];
32
+ }
33
+ export interface ImportedSlideDeck {
34
+ manifest: SlideDeckManifest;
35
+ slides: SlideModel[];
36
+ }
37
+ export declare const SELECTOR_ATTR = "data-editable-id";
38
+ export declare const SLIDE_ROOT_ID = "slide-root";
39
+ export declare const SLIDE_ROOT_SELECTOR = "body";
40
+ export declare const DEFAULT_SLIDE_WIDTH = 1920;
41
+ export declare const DEFAULT_SLIDE_HEIGHT = 1080;
42
+ export declare function getSlideElementSelector(elementId: string): string;
43
+ export declare function getSlideRootSelector(rootId: string): string;
44
+ export declare function getElementId(node: Element | null): string | null;
45
+ export declare function isPersistedGroupElementId(elementId: string | null | undefined): boolean;
46
+ export declare function isPersistedGroupNode(node: Element | null): boolean;
47
+ export declare function setElementId(node: Element, id: string): void;
48
+ export declare function createElementId(index: number, type: EditableType): string;
49
+ export declare function parseDimension(value: string | null, fallback: number): number;
50
+ export declare function parseFixedPixelDimension(value: string | null | undefined): number | null;
51
+ export declare function readBodyStyleValueFromHtmlSource(html: string, propertyName: string): string | null;
52
+ export declare function readBodyDimensionsFromHtmlSource(html: string): {
53
+ width: number;
54
+ height: number;
55
+ };
56
+ export declare function normalizeSlideId(slideId: string): string;
@@ -0,0 +1,7 @@
1
+ import { type SlideModel } from "./slide-contract.js";
2
+ export declare function ensureEditableSelectors(html: string): string;
3
+ export declare function parseSlide(html: string, slideId?: string): SlideModel;
4
+ export declare function querySlideElement<T extends Element = HTMLElement>(doc: ParentNode, elementId: string): T | null;
5
+ export declare function querySlideRoot<T extends HTMLElement = HTMLBodyElement>(doc: ParentNode): T | null;
6
+ export declare function querySlideNode<T extends HTMLElement = HTMLElement>(doc: ParentNode, elementId: string): T | null;
7
+ export declare function getSlideInlineStyleValue(slide: SlideModel, elementId: string, propertyName: string): string;
@@ -0,0 +1,2 @@
1
+ export declare function getDeckSlideBaseUrl(sourceFile?: string): string;
2
+ export declare function injectBaseTag(htmlSource: string, sourceFile?: string): string;
@@ -0,0 +1,3 @@
1
+ export declare function parseHtmlDocument(html: string): Document | null;
2
+ export declare function serializeHtmlDocument(doc: Document): string;
3
+ export declare function updateHtmlSource(html: string, updater: (doc: Document) => void): string;
@@ -0,0 +1,4 @@
1
+ import type { SlideModel } from "./slide-contract.js";
2
+ import type { SlideOperation } from "./slide-operation-types.js";
3
+ export declare function applySlideOperation(slide: SlideModel, operation: SlideOperation): SlideModel;
4
+ export declare function invertSlideOperation(operation: SlideOperation): SlideOperation;
@@ -0,0 +1,123 @@
1
+ import type { ElementLayoutStyleSnapshot } from "./layout.js";
2
+ import type { SlideModel } from "./slide-contract.js";
3
+ export interface TextUpdateOperation {
4
+ type: "text.update";
5
+ slideId: string;
6
+ elementId: string;
7
+ previousText: string;
8
+ nextText: string;
9
+ timestamp: number;
10
+ }
11
+ export interface StyleUpdateOperation {
12
+ type: "style.update";
13
+ slideId: string;
14
+ elementId: string;
15
+ propertyName: string;
16
+ previousValue: string;
17
+ nextValue: string;
18
+ timestamp: number;
19
+ }
20
+ export interface AttributeUpdateOperation {
21
+ type: "attribute.update";
22
+ slideId: string;
23
+ elementId: string;
24
+ attributeName: string;
25
+ previousValue: string;
26
+ nextValue: string;
27
+ timestamp: number;
28
+ }
29
+ export interface ElementLayoutUpdateOperation {
30
+ type: "element.layout.update";
31
+ slideId: string;
32
+ elementId: string;
33
+ previousStyle: ElementLayoutStyleSnapshot;
34
+ nextStyle: ElementLayoutStyleSnapshot;
35
+ timestamp: number;
36
+ }
37
+ export interface ElementInsertOperation {
38
+ type: "element.insert";
39
+ slideId: string;
40
+ elementId: string;
41
+ parentElementId: string | null;
42
+ previousSiblingElementId: string | null;
43
+ nextSiblingElementId: string | null;
44
+ html: string;
45
+ timestamp: number;
46
+ }
47
+ export interface ElementRemoveOperation {
48
+ type: "element.remove";
49
+ slideId: string;
50
+ elementId: string;
51
+ parentElementId: string | null;
52
+ previousSiblingElementId: string | null;
53
+ nextSiblingElementId: string | null;
54
+ html: string;
55
+ timestamp: number;
56
+ }
57
+ export interface GroupCreateOperation {
58
+ type: "group.create";
59
+ slideId: string;
60
+ groupElementId: string;
61
+ elementIds: string[];
62
+ previousHtmlSource: string;
63
+ nextHtmlSource: string;
64
+ timestamp: number;
65
+ }
66
+ export interface GroupUngroupOperation {
67
+ type: "group.ungroup";
68
+ slideId: string;
69
+ groupElementId: string;
70
+ childElementIds: string[];
71
+ previousHtmlSource: string;
72
+ nextHtmlSource: string;
73
+ timestamp: number;
74
+ }
75
+ export type AtomicSlideOperation = TextUpdateOperation | StyleUpdateOperation | AttributeUpdateOperation | ElementLayoutUpdateOperation | ElementInsertOperation | ElementRemoveOperation | GroupCreateOperation | GroupUngroupOperation;
76
+ export interface SlideBatchOperation {
77
+ type: "operation.batch";
78
+ slideId: string;
79
+ operations: AtomicSlideOperation[];
80
+ timestamp: number;
81
+ }
82
+ export interface SlideCreateOperation {
83
+ type: "slide.create";
84
+ slide: SlideModel;
85
+ index: number;
86
+ timestamp: number;
87
+ }
88
+ export interface SlideDeleteOperation {
89
+ type: "slide.delete";
90
+ slide: SlideModel;
91
+ index: number;
92
+ timestamp: number;
93
+ }
94
+ export interface SlideDuplicateOperation {
95
+ type: "slide.duplicate";
96
+ sourceSlideId: string;
97
+ slide: SlideModel;
98
+ index: number;
99
+ timestamp: number;
100
+ }
101
+ export interface SlideReorderOperation {
102
+ type: "slide.reorder";
103
+ slideId: string;
104
+ fromIndex: number;
105
+ toIndex: number;
106
+ timestamp: number;
107
+ }
108
+ export interface SlideVisibilityUpdateOperation {
109
+ type: "slide.visibility.update";
110
+ slideId: string;
111
+ previousHidden: boolean;
112
+ nextHidden: boolean;
113
+ timestamp: number;
114
+ }
115
+ export interface SlideTitleUpdateOperation {
116
+ type: "slide.title.update";
117
+ slideId: string;
118
+ previousTitle: string;
119
+ nextTitle: string;
120
+ timestamp: number;
121
+ }
122
+ export type DeckSlideOperation = SlideCreateOperation | SlideDeleteOperation | SlideDuplicateOperation | SlideReorderOperation | SlideVisibilityUpdateOperation | SlideTitleUpdateOperation;
123
+ export type SlideOperation = AtomicSlideOperation | SlideBatchOperation | DeckSlideOperation;
@@ -0,0 +1,14 @@
1
+ import { type ElementLayoutStyleSnapshot } from "./layout.js";
2
+ import type { ElementInsertOperation } from "./slide-operation-types.js";
3
+ export declare function updateSlideText(html: string, elementId: string, value: string): string;
4
+ export declare function updateSlideStyle(html: string, elementId: string, propertyName: string, value: string): string;
5
+ export declare function updateSlideAttribute(html: string, elementId: string, attributeName: string, value: string): string;
6
+ export declare function duplicateSlideElement(html: string, sourceElementId: string, nextElementId: string): string;
7
+ export declare function updateSlideElementLayout(html: string, elementId: string, snapshot: ElementLayoutStyleSnapshot): string;
8
+ export declare function createElementPlacement(html: string, elementId: string): Pick<ElementInsertOperation, "parentElementId" | "previousSiblingElementId" | "nextSiblingElementId"> | null;
9
+ export declare function getSlideElementHtml(html: string, elementId: string): string | null;
10
+ export declare function updateSlideElementHtmlIds(elementHtml: string, idMap: Record<string, string>): string;
11
+ export declare function createUniqueElementId(html: string, preferredId: string): string;
12
+ export declare function insertSlideElement(html: string, operation: Pick<ElementInsertOperation, "elementId" | "parentElementId" | "previousSiblingElementId" | "nextSiblingElementId" | "html">): string;
13
+ export declare function removeSlideElement(html: string, elementId: string): string;
14
+ export declare function updateSlideElementTransform(html: string, elementId: string, deltaX: number, deltaY: number): string;
@@ -0,0 +1,5 @@
1
+ export type { AtomicSlideOperation, AttributeUpdateOperation, ElementInsertOperation, ElementLayoutUpdateOperation, ElementRemoveOperation, GroupCreateOperation, GroupUngroupOperation, SlideBatchOperation, SlideTitleUpdateOperation, SlideOperation, StyleUpdateOperation, TextUpdateOperation, } from "./slide-operation-types.js";
2
+ export type { GroupElementRectMap, ElementPresentationStyleMap } from "./group-operations.js";
3
+ export { createGroupCreateOperation, createGroupUngroupOperation, } from "./group-operations.js";
4
+ export { createElementPlacement, createUniqueElementId, duplicateSlideElement, getSlideElementHtml, insertSlideElement, removeSlideElement, updateSlideAttribute, updateSlideElementHtmlIds, updateSlideElementLayout, updateSlideElementTransform, updateSlideStyle, updateSlideText, } from "./slide-operations-helpers.js";
5
+ export { applySlideOperation, invertSlideOperation } from "./slide-operation-reducer.js";
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@starrykit/slides-core",
3
+ "version": "0.1.26",
4
+ "description": "Slide contract, document model, validation, history, operations, and export-planning logic for Starry Slides.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc -p tsconfig.json && tsup src/index.ts --format esm"
21
+ }
22
+ }