deckjsx 0.1.2 → 0.2.1

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/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # deckjsx
2
2
 
3
- `deckjsx` is a TypeScript library for generating presentation files from JSX through a compiler pipeline.
3
+ `deckjsx` is a TypeScript library for generating presentation files from JSX through a compiler
4
+ pipeline.
4
5
 
5
6
  The intended architecture is:
6
7
 
@@ -13,7 +14,8 @@ JSX
13
14
  ```
14
15
 
15
16
  This project is being designed as a compiler, not as a thin `PptxGenJS` wrapper.
16
- The current API direction is a class-based compiler with callback-based `.add()`, `.render()`, and `.output()`, and JSX authoring centered on a `style` object prop.
17
+ The API uses a class-based compiler with callback-based `.add()`, `.render()`, and `.output()`.
18
+ Authoring uses typed JSX elements with a `style` object prop.
17
19
 
18
20
  The implementation preserves the compiler model with explicit module boundaries for authoring,
19
21
  style normalization, layout, IR, backend emission, and Node runtime output.
@@ -29,7 +31,7 @@ The package currently targets Node.js output and ships a `pptxgenjs` backend.
29
31
  ## Usage
30
32
 
31
33
  ```tsx
32
- import { Deck, Slide, Text, View } from "deckjsx";
34
+ import { Deck, Slide } from "deckjsx";
33
35
 
34
36
  const deck = new Deck({
35
37
  layout: { width: 13.333, height: 7.5, unit: "in" },
@@ -38,38 +40,41 @@ const deck = new Deck({
38
40
 
39
41
  deck.add(({ slideIndex, totalSlides }) => (
40
42
  <Slide name={`Slide ${slideIndex + 1}`} style={{ backgroundColor: "#F8FAFC" }}>
41
- <Text
43
+ <main
42
44
  style={{
43
45
  x: 0.7,
44
46
  y: 0.5,
45
- width: 8.5,
46
- height: 0.6,
47
- fontSize: 28,
48
- fontWeight: 700,
49
- color: "#0F172A",
50
- }}
51
- >
52
- Quarterly Review
53
- </Text>
54
- <View
55
- style={{
56
- x: 0.7,
57
- y: 1.4,
58
47
  width: 11.9,
59
- height: 4.8,
48
+ height: 6.3,
60
49
  display: "grid",
61
- gridTemplateColumns: "1fr 1fr",
62
- columnGap: 0.35,
50
+ gridTemplateRows: ["0.9in", "1fr", "0.4in"],
51
+ rowGap: 0.25,
63
52
  }}
64
53
  >
65
- <Text style={{ fontSize: 18, color: "#334155", fit: "shrink" }}>
66
- Author slides with TSX primitives, inspect the generated IR, and emit PPTX files through the
67
- backend boundary.
68
- </Text>
69
- <Text style={{ fontSize: 18, color: "#334155", fit: "shrink" }}>
70
- {slideIndex + 1} / {totalSlides}
71
- </Text>
72
- </View>
54
+ <header>
55
+ <h1 style={{ width: "100%", height: 0.6, fontSize: 28, fontWeight: 700, color: "#0F172A" }}>
56
+ Quarterly Review
57
+ </h1>
58
+ </header>
59
+
60
+ <section style={{ display: "grid", gridTemplateColumns: "1fr 1fr", columnGap: 0.35 }}>
61
+ <p style={{ fontSize: 18, color: "#334155", fit: "shrink" }}>
62
+ Author slides with typed JSX, inspect the generated IR, and emit PPTX files through the
63
+ backend boundary.
64
+ </p>
65
+ <figure style={{ backgroundColor: "#E0F2FE", borderRadius: 0.15, padding: 0.25 }}>
66
+ <img src="chart.png" style={{ width: "100%", height: "100%", fit: "contain" }} />
67
+ </figure>
68
+ </section>
69
+
70
+ <footer>
71
+ <p
72
+ style={{ width: "100%", height: 0.3, fontSize: 11, color: "#64748B", textAlign: "right" }}
73
+ >
74
+ {slideIndex + 1} / {totalSlides}
75
+ </p>
76
+ </footer>
77
+ </main>
73
78
  </Slide>
74
79
  ));
75
80
 
@@ -80,6 +85,41 @@ await deck.output({ backend: "pptxgenjs", output: "quarterly-review.pptx" });
80
85
  Use `deck.render()` for tests, snapshots, and backend-independent inspection. Use
81
86
  `deck.output({ backend: "pptxgenjs", output })` when writing a PowerPoint file.
82
87
 
88
+ ## JSX elements
89
+
90
+ `deckjsx` supports both the original capitalized components and a typed HTML-like JSX surface.
91
+
92
+ View-like elements compile to grouped layout containers:
93
+
94
+ ```tsx
95
+ <main>
96
+ <header />
97
+ <section />
98
+ <article />
99
+ <aside />
100
+ <nav />
101
+ <footer />
102
+ <figure />
103
+ </main>
104
+ ```
105
+
106
+ Text-like elements compile to text boxes:
107
+
108
+ ```tsx
109
+ <h1>Title</h1>
110
+ <h2>Section</h2>
111
+ <p>Body copy</p>
112
+ ```
113
+
114
+ Image elements compile to images and require either `src` or `data`:
115
+
116
+ ```tsx
117
+ <img src="diagram.png" style={{ width: 4, height: 2.5, fit: "contain" }} />
118
+ ```
119
+
120
+ Primitive string and number children inside view-like elements are normalized to implicit text
121
+ nodes. Inline rich text with `span` is intentionally reserved for a later release.
122
+
83
123
  ## View Layout Semantics
84
124
 
85
125
  `View` is a containing block for its children. Child `x`, `y`, `left`, `top`, `right`,
package/dist/index.d.mts CHANGED
@@ -1,5 +1,151 @@
1
- import { $ as ImageStyle, A as CssFlexBasis, B as CssGridTrack, C as ContentJsxChild, Ct as VerticalAlign, D as CssAspectRatio, E as CssAlignSelf, F as CssGridPlacement, G as CssPosition, H as CssJustifySelf, I as CssGridShorthand, J as DeckOptions, K as CssVisibility, L as CssGridTemplate, M as CssFlexWrap, N as CssGridAutoFlow, O as CssBoxSizing, P as CssGridLine, Q as ImageProps, R as CssGridTemplateAreas, S as ContentAuthorNode, St as TextTabStopLength, T as CssAlignItems, Tt as ViewStyle, U as CssObjectPosition, V as CssJustifyContent, W as CssOverflow, X as ImageCropAuthoring, Y as DeckPointLength, Z as ImageCropValue, _ as AuthorNodeMap, _t as TextJsxChild, a as Fragment, at as ShapeStyle, b as BackendName, bt as TextTabStopAlignment, c as Slide, ct as SlideProps, d as createElement, dt as StackAlignment, et as ImplementedBackendName, f as isAuthorNode, ft as StackAxis, g as AuthorNodeKind, gt as TextFit, h as AuthorNode, ht as StrokeLineJoin, it as ShapeProps, j as CssFlexDirection, k as CssDisplay, l as Text, lt as SlideStyle, m as isSlideNode, mt as StrokeLineCap, n as JsxKey, nt as LayoutMode, o as Image, ot as SlideContext, p as isContentNode, pt as StrokeDashType, q as DeckLength, rt as OutputConfig, s as Shape, st as SlideFactory, tt as JsxNode, u as View, ut as Spacing, v as AuthorNodeProps, vt as TextProps, w as CssAlignContent, wt as ViewProps, x as BorderStyle, xt as TextTabStopAuthoring, y as AuthorNodePropsMap, yt as TextStyle, z as CssGridTemplateShorthand } from "./jsx-runtime-BfZK5259.mjs";
1
+ import { $ as ImageStyle, A as CssFlexDirection, At as ViewStyle, B as CssJustifyContent, C as CssAlignContent, Ct as TextProps, D as CssBoxSizing, Dt as TextTabStopLength, E as CssAspectRatio, Et as TextTabStopAuthoring, F as CssGridShorthand, Ft as AuthoredTag, G as CssVisibility, H as CssObjectPosition, I as CssGridTemplate, It as SectioningTag, J as DeckOptions, K as DeckJsxIntrinsicElements, L as CssGridTemplateAreas, M as CssGridAutoFlow, Mt as JsxKey, N as CssGridLine, Nt as SourceSpan, O as CssDisplay, Ot as VerticalAlign, P as CssGridPlacement, Pt as AuthoredComponent, Q as ImageProps, R as CssGridTemplateShorthand, S as ContentJsxChild, St as TextJsxChild, T as CssAlignSelf, Tt as TextTabStopAlignment, U as CssOverflow, V as CssJustifySelf, W as CssPosition, X as ImageCropAuthoring, Y as DeckPointLength, Z as ImageCropValue, _ as AuthorNodeProps, _t as StackAxis, a as createElement, at as IntrinsicViewTag, b as BorderStyle, bt as StrokeLineJoin, c as isSlideNode, ct as OutputConfig, d as Slide, dt as SlideContext, et as ImplementedBackendName, f as Text, ft as SlideFactory, g as AuthorNodeMap, gt as StackAlignment, h as AuthorNodeKind, ht as Spacing, i as Fragment, it as IntrinsicTextTag, j as CssFlexWrap, k as CssFlexBasis, kt as ViewProps, l as Image, lt as ShapeProps, m as AuthorNode, mt as SlideStyle, nt as IntrinsicImgProps, o as isAuthorNode, ot as JsxNode, p as View, pt as SlideProps, q as DeckLength, rt as IntrinsicPProps, s as isContentNode, st as LayoutMode, tt as IntrinsicDivProps, u as Shape, ut as ShapeStyle, v as AuthorNodePropsMap, vt as StrokeDashType, w as CssAlignItems, wt as TextStyle, x as ContentAuthorNode, xt as TextFit, y as BackendName, yt as StrokeLineCap, z as CssGridTrack } from "./jsx-runtime-ru5t8S3z.mjs";
2
2
 
3
+ //#region src/diagnostics/errors.d.ts
4
+ declare class DeckDiagnosticError extends Error {
5
+ readonly diagnostics: Diagnostics;
6
+ constructor(message: string, diagnostics: Diagnostics);
7
+ }
8
+ declare class SemanticGraphDiagnosticError extends DeckDiagnosticError {
9
+ constructor(diagnostics: Diagnostics);
10
+ }
11
+ //#endregion
12
+ //#region src/diagnostics/format.d.ts
13
+ declare function formatDiagnostic(diagnostic: Diagnostic): string;
14
+ declare function formatDiagnostics(diagnostics: Diagnostics): string;
15
+ //#endregion
16
+ //#region src/diagnostics/index.d.ts
17
+ type DiagnosticSeverity = "error" | "warning";
18
+ type DiagnosticLabel = {
19
+ readonly message: string;
20
+ readonly path: string;
21
+ readonly sourceSpan?: SourceSpan;
22
+ readonly severity?: "primary" | "secondary";
23
+ };
24
+ type Diagnostic = {
25
+ readonly severity: DiagnosticSeverity;
26
+ readonly code: string;
27
+ readonly title: string;
28
+ readonly message?: string;
29
+ readonly labels: readonly DiagnosticLabel[];
30
+ readonly notes?: readonly string[];
31
+ readonly help?: readonly string[];
32
+ };
33
+ type Diagnostics = {
34
+ readonly items: readonly Diagnostic[];
35
+ readonly hasErrors: boolean;
36
+ readonly hasWarnings: boolean;
37
+ };
38
+ //#endregion
39
+ //#region src/graph/types.d.ts
40
+ type Brand<T, B extends string> = T & {
41
+ readonly __brand: B;
42
+ };
43
+ type GraphNodeId = Brand<string, "GraphNodeId">;
44
+ type StyleEntityId = Brand<string, "StyleEntityId">;
45
+ type AssetEntityId = Brand<string, "AssetEntityId">;
46
+ type SemanticNodeKind = "container" | "document" | "image" | "shape" | "slide" | "text" | "textRun";
47
+ type SemanticRole = {
48
+ readonly kind: "document";
49
+ } | {
50
+ readonly kind: "slide";
51
+ } | {
52
+ readonly kind: "genericContainer";
53
+ } | {
54
+ readonly kind: "sectioning";
55
+ readonly tag: SectioningTag;
56
+ } | {
57
+ readonly kind: "figure";
58
+ } | {
59
+ readonly kind: "paragraph";
60
+ } | {
61
+ readonly kind: "heading";
62
+ readonly level: 1 | 2 | 3 | 4 | 5 | 6;
63
+ } | {
64
+ readonly kind: "image";
65
+ } | {
66
+ readonly kind: "shape";
67
+ };
68
+ type SemanticOrigin = {
69
+ readonly kind: "authored" | "implicit";
70
+ readonly path: string;
71
+ readonly sourceSpan?: SourceSpan;
72
+ readonly reason?: "primitive-text-in-container";
73
+ };
74
+ type BaseSemanticNode = {
75
+ readonly id: GraphNodeId;
76
+ readonly kind: SemanticNodeKind;
77
+ readonly origin: SemanticOrigin;
78
+ readonly authoredTag?: AuthoredTag;
79
+ readonly authoredComponent?: AuthoredComponent;
80
+ readonly role?: SemanticRole;
81
+ readonly key?: JsxKey;
82
+ readonly styleRef?: StyleEntityId;
83
+ };
84
+ type SemanticDocumentNode = BaseSemanticNode & {
85
+ readonly kind: "document";
86
+ readonly children: readonly GraphNodeId[];
87
+ };
88
+ type SemanticSlideNode = BaseSemanticNode & {
89
+ readonly kind: "slide";
90
+ readonly name?: string;
91
+ readonly children: readonly GraphNodeId[];
92
+ };
93
+ type SemanticContainerNode = BaseSemanticNode & {
94
+ readonly kind: "container";
95
+ readonly children: readonly GraphNodeId[];
96
+ };
97
+ type SemanticTextNode = BaseSemanticNode & {
98
+ readonly kind: "text";
99
+ readonly inlineChildren: readonly GraphNodeId[];
100
+ readonly implicit?: boolean;
101
+ };
102
+ type SemanticTextRunNode = BaseSemanticNode & {
103
+ readonly kind: "textRun";
104
+ readonly text: string;
105
+ };
106
+ type SemanticImageNode = BaseSemanticNode & {
107
+ readonly kind: "image";
108
+ readonly assetRef?: AssetEntityId;
109
+ };
110
+ type SemanticShapeNode = BaseSemanticNode & {
111
+ readonly kind: "shape";
112
+ };
113
+ type SemanticNode = SemanticContainerNode | SemanticDocumentNode | SemanticImageNode | SemanticShapeNode | SemanticSlideNode | SemanticTextNode | SemanticTextRunNode;
114
+ type StyleEntity = {
115
+ readonly id: StyleEntityId;
116
+ readonly target: SemanticNodeKind;
117
+ readonly authored: {
118
+ readonly style?: unknown;
119
+ readonly direct?: unknown;
120
+ };
121
+ readonly resolved?: unknown;
122
+ };
123
+ type AssetEntity = {
124
+ readonly id: AssetEntityId;
125
+ readonly kind: "image";
126
+ readonly source: {
127
+ readonly kind: "path";
128
+ readonly path: string;
129
+ } | {
130
+ readonly kind: "data";
131
+ readonly data: string;
132
+ };
133
+ readonly metadata: {
134
+ readonly mediaType?: string;
135
+ readonly byteLength?: number;
136
+ readonly widthPx?: number;
137
+ readonly heightPx?: number;
138
+ readonly contentHash?: string;
139
+ };
140
+ readonly resolution: "failed" | "resolved" | "unresolved";
141
+ };
142
+ type SemanticAuthorGraph = {
143
+ readonly documentId: GraphNodeId;
144
+ readonly nodes: ReadonlyMap<GraphNodeId, SemanticNode>;
145
+ readonly styles: ReadonlyMap<StyleEntityId, StyleEntity>;
146
+ readonly assets: ReadonlyMap<AssetEntityId, AssetEntity>;
147
+ };
148
+ //#endregion
3
149
  //#region src/ir/index.d.ts
4
150
  type PresentationIR = {
5
151
  version: "0.1";
@@ -171,6 +317,11 @@ type EdgeStrokeIR = {
171
317
  };
172
318
  type TextContentIR = {
173
319
  text: string;
320
+ runs?: ReadonlyArray<TextRunIR>;
321
+ };
322
+ type TextRunIR = {
323
+ text: string;
324
+ style?: TextStyleIR;
174
325
  };
175
326
  type TextTabStopIR = {
176
327
  positionIn: number;
@@ -238,11 +389,23 @@ type CompileBackend = {
238
389
  };
239
390
  //#endregion
240
391
  //#region src/deck.d.ts
392
+ type CompileMode = "inspect" | "strict";
393
+ type CompileInspectResult = {
394
+ readonly graph?: SemanticAuthorGraph;
395
+ readonly diagnostics: Diagnostics;
396
+ };
241
397
  declare class Deck {
242
398
  #private;
243
399
  constructor(options: DeckOptions);
244
400
  add(slide: SlideFactory): this;
245
401
  render(): PresentationIR;
402
+ compile(): SemanticAuthorGraph;
403
+ compile(config: {
404
+ mode?: "strict";
405
+ }): SemanticAuthorGraph;
406
+ compile(config: {
407
+ mode: "inspect";
408
+ }): CompileInspectResult;
246
409
  output(config: OutputConfig): Promise<void>;
247
410
  }
248
411
  //#endregion
@@ -263,8 +426,8 @@ declare global {
263
426
  interface IntrinsicAttributes {
264
427
  key?: JsxKey;
265
428
  }
266
- interface IntrinsicElements {}
429
+ interface IntrinsicElements extends DeckJsxIntrinsicElements {}
267
430
  }
268
431
  }
269
432
  //#endregion
270
- export { type AuthorNode, type AuthorNodeKind, type AuthorNodeMap, type AuthorNodeProps, type AuthorNodePropsMap, type BackendArtifact, type BackendName, type BackgroundImageLayerIR, type BackgroundLayerIR, type BaseNodeIR, type BorderStyle, type CompileBackend, type ContentAuthorNode, type ContentJsxChild, type CssAlignContent, type CssAlignItems, type CssAlignSelf, type CssAspectRatio, type CssBoxSizing, type CssDisplay, type CssFlexBasis, type CssFlexDirection, type CssFlexWrap, type CssGridAutoFlow, type CssGridLine, type CssGridPlacement, type CssGridShorthand, type CssGridTemplate, type CssGridTemplateAreas, type CssGridTemplateShorthand, type CssGridTrack, type CssJustifyContent, type CssJustifySelf, type CssObjectPosition, type CssOverflow, type CssPosition, type CssVisibility, Deck, type DeckLength, type DeckOptions, type DeckPointLength, EMU_PER_INCH, type EdgeStrokeIR, type FillIR, Fragment, type FrameIR, type GroupIR, type HyperlinkIR, Image, type ImageCropAuthoring, type ImageCropIR, type ImageCropValue, type ImageIR, type ImageProps, type ImageSourceIR, type ImageStyle, type ImplementedBackendName, type JsxKey, type JsxNode, type LayoutMode, type LinearGradientFillIR, type LinearGradientStopIR, type NodeIR, type ObjectPositionIR, type OutputConfig, POINTS_PER_INCH, type PresentationIR, type RadialGradientFillIR, type ShadowIR, Shape, type ShapeIR, type ShapeProps, type ShapeStyle, type SizeIR, Slide, type SlideContext, type SlideFactory, type SlideIR, type SlideProps, type SlideStyle, type SolidFillIR, type Spacing, type StackAlignment, type StackAxis, type StrokeDashType, type StrokeIR, type StrokeLineCap, type StrokeLineJoin, Text, type TextBulletListIR, type TextContentIR, type TextFit, type TextIR, type TextJsxChild, type TextListIR, type TextNoListIR, type TextNumberListIR, type TextProps, type TextStyle, type TextStyleIR, type TextTabStopAlignment, type TextTabStopAuthoring, type TextTabStopIR, type TextTabStopLength, type VerticalAlign, View, type ViewProps, type ViewStyle, createElement, isAuthorNode, isContentNode, isSlideNode, pptxgenjsBackend };
433
+ export { type AssetEntity, type AssetEntityId, type AuthorNode, type AuthorNodeKind, type AuthorNodeMap, type AuthorNodeProps, type AuthorNodePropsMap, type BackendArtifact, type BackendName, type BackgroundImageLayerIR, type BackgroundLayerIR, type BaseNodeIR, type BaseSemanticNode, type BorderStyle, type CompileBackend, type CompileInspectResult, type CompileMode, type ContentAuthorNode, type ContentJsxChild, type CssAlignContent, type CssAlignItems, type CssAlignSelf, type CssAspectRatio, type CssBoxSizing, type CssDisplay, type CssFlexBasis, type CssFlexDirection, type CssFlexWrap, type CssGridAutoFlow, type CssGridLine, type CssGridPlacement, type CssGridShorthand, type CssGridTemplate, type CssGridTemplateAreas, type CssGridTemplateShorthand, type CssGridTrack, type CssJustifyContent, type CssJustifySelf, type CssObjectPosition, type CssOverflow, type CssPosition, type CssVisibility, Deck, DeckDiagnosticError, type DeckJsxIntrinsicElements, type DeckLength, type DeckOptions, type DeckPointLength, type Diagnostic, type DiagnosticLabel, type DiagnosticSeverity, type Diagnostics, EMU_PER_INCH, type EdgeStrokeIR, type FillIR, Fragment, type FrameIR, type GraphNodeId, type GroupIR, type HyperlinkIR, Image, type ImageCropAuthoring, type ImageCropIR, type ImageCropValue, type ImageIR, type ImageProps, type ImageSourceIR, type ImageStyle, type ImplementedBackendName, type IntrinsicDivProps, type IntrinsicImgProps, type IntrinsicPProps, type IntrinsicTextTag, type IntrinsicViewTag, type JsxKey, type JsxNode, type LayoutMode, type LinearGradientFillIR, type LinearGradientStopIR, type NodeIR, type ObjectPositionIR, type OutputConfig, POINTS_PER_INCH, type PresentationIR, type RadialGradientFillIR, type SemanticAuthorGraph, type SemanticContainerNode, type SemanticDocumentNode, SemanticGraphDiagnosticError, type SemanticImageNode, type SemanticNode, type SemanticNodeKind, type SemanticOrigin, type SemanticRole, type SemanticShapeNode, type SemanticSlideNode, type SemanticTextNode, type SemanticTextRunNode, type ShadowIR, Shape, type ShapeIR, type ShapeProps, type ShapeStyle, type SizeIR, Slide, type SlideContext, type SlideFactory, type SlideIR, type SlideProps, type SlideStyle, type SolidFillIR, type SourceSpan, type Spacing, type StackAlignment, type StackAxis, type StrokeDashType, type StrokeIR, type StrokeLineCap, type StrokeLineJoin, type StyleEntity, type StyleEntityId, Text, type TextBulletListIR, type TextContentIR, type TextFit, type TextIR, type TextJsxChild, type TextListIR, type TextNoListIR, type TextNumberListIR, type TextProps, type TextRunIR, type TextStyle, type TextStyleIR, type TextTabStopAlignment, type TextTabStopAuthoring, type TextTabStopIR, type TextTabStopLength, type VerticalAlign, View, type ViewProps, type ViewStyle, createElement, formatDiagnostic, formatDiagnostics, isAuthorNode, isContentNode, isSlideNode, pptxgenjsBackend };