deckjsx 0.2.0 → 0.3.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.
@@ -1,3 +1,250 @@
1
+ //#region src/authoring/tags.d.ts
2
+ type AuthoredTag = "article" | "aside" | "div" | "figure" | "footer" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "header" | "img" | "main" | "nav" | "p" | "section" | "span";
3
+ type SectioningTag = "article" | "aside" | "footer" | "header" | "main" | "nav" | "section";
4
+ type AuthoredComponent = "Image" | "Shape" | "Slide" | "Text" | "View";
5
+ type IntrinsicViewTag$1 = "article" | "aside" | "div" | "figure" | "footer" | "header" | "main" | "nav" | "section";
6
+ type IntrinsicTextTag$1 = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p";
7
+ //#endregion
8
+ //#region src/authoring/tree.d.ts
9
+ type JsxKey = string | number | bigint;
10
+ type SourceSpan = {
11
+ readonly file?: string;
12
+ readonly line?: number;
13
+ readonly column?: number;
14
+ };
15
+ type AuthorElementSource = {
16
+ readonly kind: "tag";
17
+ readonly tag: AuthoredTag;
18
+ } | {
19
+ readonly kind: "component";
20
+ readonly component: AuthoredComponent;
21
+ };
22
+ type AuthorElementNode = {
23
+ readonly $$typeof: "deckjsx.author-tree";
24
+ readonly kind: "element";
25
+ readonly source: AuthorElementSource;
26
+ readonly key?: JsxKey;
27
+ readonly props: Record<string, unknown>;
28
+ readonly children: readonly AuthorTreeNode[];
29
+ readonly sourceSpan?: SourceSpan;
30
+ };
31
+ type AuthorFragmentNode = {
32
+ readonly $$typeof: "deckjsx.author-tree";
33
+ readonly kind: "fragment";
34
+ readonly key?: JsxKey;
35
+ readonly children: readonly AuthorTreeNode[];
36
+ readonly sourceSpan?: SourceSpan;
37
+ };
38
+ type AuthorTextLeaf = {
39
+ readonly $$typeof: "deckjsx.author-tree";
40
+ readonly kind: "text";
41
+ readonly value: string | number;
42
+ readonly sourceSpan?: SourceSpan;
43
+ };
44
+ type AuthorTreeNode = AuthorElementNode | AuthorFragmentNode | AuthorTextLeaf;
45
+ type AuthorTreeChild = AuthorTreeNode | string | number | boolean | null | undefined | readonly AuthorTreeChild[];
46
+ //#endregion
47
+ //#region src/diagnostics/errors.d.ts
48
+ declare class DeckDiagnosticError extends Error {
49
+ readonly diagnostics: Diagnostics;
50
+ constructor(message: string, diagnostics: Diagnostics);
51
+ }
52
+ declare class SemanticGraphDiagnosticError extends DeckDiagnosticError {
53
+ constructor(diagnostics: Diagnostics);
54
+ }
55
+ declare class CompositionDiagnosticError extends DeckDiagnosticError {
56
+ constructor(diagnostics: Diagnostics);
57
+ }
58
+ //#endregion
59
+ //#region src/diagnostics/format.d.ts
60
+ declare function formatDiagnostic(diagnostic: Diagnostic): string;
61
+ declare function formatDiagnostics(diagnostics: Diagnostics): string;
62
+ //#endregion
63
+ //#region src/diagnostics/index.d.ts
64
+ type DiagnosticSeverity = "error" | "warning";
65
+ type DiagnosticLabel = {
66
+ readonly message: string;
67
+ readonly path: string;
68
+ readonly sourceSpan?: SourceSpan;
69
+ readonly severity?: "primary" | "secondary";
70
+ };
71
+ type Diagnostic = {
72
+ readonly severity: DiagnosticSeverity;
73
+ readonly code: string;
74
+ readonly title: string;
75
+ readonly message?: string;
76
+ readonly labels: readonly DiagnosticLabel[];
77
+ readonly notes?: readonly string[];
78
+ readonly help?: readonly string[];
79
+ };
80
+ type Diagnostics = {
81
+ readonly items: readonly Diagnostic[];
82
+ readonly hasErrors: boolean;
83
+ readonly hasWarnings: boolean;
84
+ };
85
+ //#endregion
86
+ //#region src/graph/types.d.ts
87
+ type Brand<T, B extends string> = T & {
88
+ readonly __brand: B;
89
+ };
90
+ type GraphNodeId = Brand<string, "GraphNodeId">;
91
+ type StyleEntityId = Brand<string, "StyleEntityId">;
92
+ type AssetEntityId = Brand<string, "AssetEntityId">;
93
+ type SourceIdentity = Brand<string, "SourceIdentity">;
94
+ type SemanticNodeKind = "container" | "document" | "image" | "shape" | "slide" | "text" | "textRun";
95
+ type SemanticRole = {
96
+ readonly kind: "document";
97
+ } | {
98
+ readonly kind: "slide";
99
+ } | {
100
+ readonly kind: "genericContainer";
101
+ } | {
102
+ readonly kind: "sectioning";
103
+ readonly tag: SectioningTag;
104
+ } | {
105
+ readonly kind: "figure";
106
+ } | {
107
+ readonly kind: "paragraph";
108
+ } | {
109
+ readonly kind: "heading";
110
+ readonly level: 1 | 2 | 3 | 4 | 5 | 6;
111
+ } | {
112
+ readonly kind: "image";
113
+ } | {
114
+ readonly kind: "shape";
115
+ };
116
+ type SourceOrigin = {
117
+ readonly kind: "root";
118
+ } | {
119
+ readonly kind: "mounted";
120
+ readonly sourceKey: string;
121
+ readonly sourceIdentity: SourceIdentity;
122
+ };
123
+ type SemanticOrigin = {
124
+ readonly kind: "authored" | "implicit";
125
+ readonly path: string;
126
+ readonly source?: SourceOrigin;
127
+ readonly sourceSpan?: SourceSpan;
128
+ readonly reason?: "primitive-text-in-container";
129
+ };
130
+ type BaseSemanticNode = {
131
+ readonly id: GraphNodeId;
132
+ readonly kind: SemanticNodeKind;
133
+ readonly origin: SemanticOrigin;
134
+ readonly authoredTag?: AuthoredTag;
135
+ readonly authoredComponent?: AuthoredComponent;
136
+ readonly role?: SemanticRole;
137
+ readonly key?: JsxKey;
138
+ readonly styleRef?: StyleEntityId;
139
+ };
140
+ type SemanticDocumentNode = BaseSemanticNode & {
141
+ readonly kind: "document";
142
+ readonly children: readonly GraphNodeId[];
143
+ };
144
+ type SemanticSlideNode = BaseSemanticNode & {
145
+ readonly kind: "slide";
146
+ readonly name?: string;
147
+ readonly children: readonly GraphNodeId[];
148
+ };
149
+ type SemanticContainerNode = BaseSemanticNode & {
150
+ readonly kind: "container";
151
+ readonly children: readonly GraphNodeId[];
152
+ };
153
+ type SemanticTextNode = BaseSemanticNode & {
154
+ readonly kind: "text";
155
+ readonly inlineChildren: readonly GraphNodeId[];
156
+ readonly implicit?: boolean;
157
+ };
158
+ type SemanticTextRunNode = BaseSemanticNode & {
159
+ readonly kind: "textRun";
160
+ readonly text: string;
161
+ };
162
+ type SemanticImageNode = BaseSemanticNode & {
163
+ readonly kind: "image";
164
+ readonly assetRef?: AssetEntityId;
165
+ };
166
+ type SemanticShapeNode = BaseSemanticNode & {
167
+ readonly kind: "shape";
168
+ };
169
+ type SemanticNode = SemanticContainerNode | SemanticDocumentNode | SemanticImageNode | SemanticShapeNode | SemanticSlideNode | SemanticTextNode | SemanticTextRunNode;
170
+ type StyleEntity = {
171
+ readonly id: StyleEntityId;
172
+ readonly target: SemanticNodeKind;
173
+ readonly authored: {
174
+ readonly style?: unknown;
175
+ readonly direct?: unknown;
176
+ };
177
+ readonly resolved?: unknown;
178
+ };
179
+ type AssetEntity = {
180
+ readonly id: AssetEntityId;
181
+ readonly kind: "image";
182
+ readonly source: {
183
+ readonly kind: "path";
184
+ readonly path: string;
185
+ } | {
186
+ readonly kind: "data";
187
+ readonly data: string;
188
+ };
189
+ readonly metadata: {
190
+ readonly mediaType?: string;
191
+ readonly byteLength?: number;
192
+ readonly widthPx?: number;
193
+ readonly heightPx?: number;
194
+ readonly contentHash?: string;
195
+ };
196
+ readonly resolution: "failed" | "resolved" | "unresolved";
197
+ };
198
+ type SemanticAuthorGraph = {
199
+ readonly documentId: GraphNodeId;
200
+ readonly nodes: ReadonlyMap<GraphNodeId, SemanticNode>;
201
+ readonly styles: ReadonlyMap<StyleEntityId, StyleEntity>;
202
+ readonly assets: ReadonlyMap<AssetEntityId, AssetEntity>;
203
+ };
204
+ //#endregion
205
+ //#region src/composition/types.d.ts
206
+ declare const COMPOSITION_SOURCE: unique symbol;
207
+ type CompositionContext = {
208
+ readonly sourceKey?: string;
209
+ readonly slideIndex: number;
210
+ readonly totalSlides: number;
211
+ readonly deckSlideIndex: number;
212
+ readonly deckTotalSlides: number;
213
+ };
214
+ type SlideFactoryInput<TSourceContext = void> = [TSourceContext] extends [void] ? {
215
+ readonly composition: CompositionContext;
216
+ } : {
217
+ readonly context: TSourceContext;
218
+ readonly composition: CompositionContext;
219
+ };
220
+ type SlideFactory<TSourceContext = void> = (input: SlideFactoryInput<TSourceContext>) => JsxNode;
221
+ type SourceContextMapper<TParentContext, TChildContext> = [TParentContext] extends [void] ? () => TChildContext : (context: TParentContext) => TChildContext;
222
+ type SourceContextInput<TParentContext, TChildContext> = TChildContext | SourceContextMapper<TParentContext, TChildContext>;
223
+ type SourceContextBinding<TSourceContext = unknown> = {
224
+ readonly present: false;
225
+ } | {
226
+ readonly present: true;
227
+ readonly value: TSourceContext;
228
+ };
229
+ type CompositionEntry<TSourceContext = unknown> = {
230
+ readonly kind: "slide";
231
+ readonly factory: SlideFactory<TSourceContext>;
232
+ } | {
233
+ readonly kind: "mount";
234
+ readonly sourceKey: string;
235
+ readonly source: CompositionSource<unknown>;
236
+ readonly contextProvider?: SourceContextInput<TSourceContext, unknown>;
237
+ readonly invalidExtraContext?: boolean;
238
+ };
239
+ type CompositionSourceInternals<TSourceContext = unknown> = {
240
+ readonly entries: readonly CompositionEntry<TSourceContext>[];
241
+ readonly cycleId: object;
242
+ readonly boundContext: SourceContextBinding<TSourceContext>;
243
+ };
244
+ type CompositionSource<TSourceContext = unknown> = {
245
+ readonly [COMPOSITION_SOURCE]: () => CompositionSourceInternals<TSourceContext>;
246
+ };
247
+ //#endregion
1
248
  //#region src/authoring/index.d.ts
2
249
  type DeckLength = number | `${number}${"in" | "pt" | "px" | "%" | "em" | "rem" | "vh" | "vw" | "ch"}`;
3
250
  type DeckPointLength = number | `${number}${"pt" | "in" | "px" | "em" | "rem" | "vh" | "vw" | "ch"}`;
@@ -50,14 +297,14 @@ type ImageCropAuthoring = {
50
297
  left?: ImageCropValue;
51
298
  };
52
299
  interface TextJsxChildArray extends ReadonlyArray<TextJsxChild> {}
53
- type TextJsxChild = string | number | boolean | null | undefined | TextJsxChildArray;
300
+ type TextJsxChild = AuthorTreeNode | string | number | boolean | null | undefined | TextJsxChildArray;
54
301
  type ContentAuthorNode = AuthorNode<"view" | "text" | "image" | "shape">;
55
302
  interface ContentJsxChildArray extends ReadonlyArray<ContentJsxChild> {}
56
- type ContentJsxChild = AuthorNode | boolean | null | undefined | ContentJsxChildArray;
303
+ type ContentJsxChild = AuthorNode | AuthorTreeNode | boolean | null | undefined | ContentJsxChildArray;
57
304
  interface ViewIntrinsicJsxChildArray extends ReadonlyArray<ViewIntrinsicJsxChild> {}
58
305
  type ViewIntrinsicJsxChild = ContentJsxChild | string | number | ViewIntrinsicJsxChildArray;
59
306
  interface JsxNodeArray extends ReadonlyArray<JsxNode> {}
60
- type JsxNode = AuthorNode | string | number | boolean | null | undefined | JsxNodeArray;
307
+ type JsxNode = AuthorNode | AuthorTreeNode | string | number | boolean | null | undefined | JsxNodeArray;
61
308
  type BaseAuthorProps = {
62
309
  opacity?: number;
63
310
  rotation?: number;
@@ -273,11 +520,6 @@ type DeckOptions = {
273
520
  subject?: string;
274
521
  };
275
522
  };
276
- type SlideContext = {
277
- slideIndex: number;
278
- totalSlides: number;
279
- };
280
- type SlideFactory = (context: SlideContext) => JsxNode;
281
523
  type OutputConfig = {
282
524
  backend: ImplementedBackendName;
283
525
  output: string;
@@ -375,11 +617,19 @@ type IntrinsicViewTag = "article" | "aside" | "div" | "figure" | "footer" | "hea
375
617
  type IntrinsicTextTag = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p";
376
618
  type DeckJsxIntrinsicElements = {
377
619
  img: IntrinsicImgProps;
620
+ span: IntrinsicPProps;
378
621
  } & { [Tag in IntrinsicViewTag]: IntrinsicDivProps } & { [Tag in IntrinsicTextTag]: IntrinsicPProps };
379
622
  //#endregion
623
+ //#region src/authoring/components.d.ts
624
+ declare function Slide(props: SlideProps): AuthorElementNode;
625
+ declare function View(props: ViewProps): AuthorElementNode;
626
+ declare function Text(props: TextProps): AuthorElementNode;
627
+ declare function Image(props: ImageProps): AuthorElementNode;
628
+ declare function Shape(props: ShapeProps): AuthorElementNode;
629
+ //#endregion
380
630
  //#region src/jsx.d.ts
381
631
  type ComponentProps = {
382
- children?: JsxNode;
632
+ children?: AuthorTreeChild;
383
633
  };
384
634
  type ElementChildren<P> = P extends {
385
635
  children?: infer Child;
@@ -389,44 +639,42 @@ type ElementChildArgs<P> = P extends {
389
639
  } ? [] : ElementChildren<P>[];
390
640
  declare function createElement<P extends {
391
641
  children?: unknown;
392
- }, R extends JsxNode>(type: (props: P) => R, props: (Omit<P, "children"> & Partial<Pick<P, "children">>) | null, ...children: ElementChildArgs<P>): R;
393
- declare function createElement(type: IntrinsicViewTag, props: (Omit<IntrinsicDivProps, "children"> & Partial<Pick<IntrinsicDivProps, "children">>) | null, ...children: ElementChildArgs<IntrinsicDivProps>): AuthorNode<"view">;
394
- declare function createElement(type: IntrinsicTextTag, props: (Omit<IntrinsicPProps, "children"> & Partial<Pick<IntrinsicPProps, "children">>) | null, ...children: ElementChildArgs<IntrinsicPProps>): AuthorNode<"text">;
395
- declare function createElement(type: "img", props: IntrinsicImgProps): AuthorNode<"image">;
642
+ }, R extends AuthorTreeNode>(type: (props: P) => R, props: (Omit<P, "children"> & Partial<Pick<P, "children">>) | null, ...children: ElementChildArgs<P>): R;
643
+ declare function createElement(type: IntrinsicViewTag$1, props: (Omit<IntrinsicDivProps, "children"> & Partial<Pick<IntrinsicDivProps, "children">>) | null, ...children: ElementChildArgs<IntrinsicDivProps>): AuthorTreeNode;
644
+ declare function createElement(type: IntrinsicTextTag$1, props: (Omit<IntrinsicPProps, "children"> & Partial<Pick<IntrinsicPProps, "children">>) | null, ...children: ElementChildArgs<IntrinsicPProps>): AuthorTreeNode;
645
+ declare function createElement(type: "span", props: IntrinsicPProps | null): AuthorTreeNode;
646
+ declare function createElement(type: "img", props: IntrinsicImgProps): AuthorTreeNode;
396
647
  declare function createElement(type: string, props: ComponentProps | null): never;
397
648
  declare function Fragment(props: {
398
- children?: ContentJsxChild;
399
- }): ContentJsxChild;
400
- declare function Slide(props: SlideProps): AuthorNode<"slide">;
401
- declare function View(props: ViewProps): AuthorNode<"view">;
402
- declare function Text(props: TextProps): AuthorNode<"text">;
403
- declare function Image(props: ImageProps): AuthorNode<"image">;
404
- declare function Shape(props: ShapeProps): AuthorNode<"shape">;
649
+ children?: AuthorTreeChild;
650
+ }): AuthorTreeNode;
405
651
  declare function isAuthorNode(value: unknown): value is AuthorNode;
406
652
  declare function isSlideNode(value: unknown): value is AuthorNode<"slide">;
407
653
  declare function isContentNode(value: unknown): value is ContentAuthorNode;
408
654
  //#endregion
409
655
  //#region src/jsx-runtime.d.ts
410
- type JsxKey = string | number | bigint;
411
- type JsxComponent<P, R extends JsxNode> = (props: P) => R;
656
+ type JsxComponent<P, R extends AuthorTreeNode> = (props: P) => R;
412
657
  type JsxProps<P> = P extends {
413
658
  children?: unknown;
414
659
  } ? Omit<P, "children"> & Partial<Pick<P, "children">> : P;
415
- declare function jsx<P, R extends JsxNode>(type: JsxComponent<P, R>, props: JsxProps<P> | null, key?: JsxKey): R;
416
- declare function jsx(type: IntrinsicViewTag, props: JsxProps<IntrinsicDivProps> | null, key?: JsxKey): JsxNode;
417
- declare function jsx(type: IntrinsicTextTag, props: JsxProps<IntrinsicPProps> | null, key?: JsxKey): JsxNode;
418
- declare function jsx(type: "img", props: IntrinsicImgProps, key?: JsxKey): JsxNode;
660
+ declare function jsx<P, R extends AuthorTreeNode>(type: JsxComponent<P, R>, props: JsxProps<P> | null, key?: JsxKey): R;
661
+ declare function jsx(type: IntrinsicViewTag, props: JsxProps<IntrinsicDivProps> | null, key?: JsxKey): AuthorTreeNode;
662
+ declare function jsx(type: IntrinsicTextTag, props: JsxProps<IntrinsicPProps> | null, key?: JsxKey): AuthorTreeNode;
663
+ declare function jsx(type: "span", props: JsxProps<IntrinsicPProps> | null, key?: JsxKey): AuthorTreeNode;
664
+ declare function jsx(type: "img", props: IntrinsicImgProps, key?: JsxKey): AuthorTreeNode;
419
665
  declare function jsx(type: string, props: Record<string, unknown> | null, key?: JsxKey): never;
420
666
  declare const jsxs: typeof jsx;
421
667
  declare namespace JSX {
422
- type Element = ContentJsxChild;
668
+ type Element = AuthorTreeNode;
423
669
  interface ElementChildrenAttribute {
424
670
  children: {};
425
671
  }
426
672
  interface IntrinsicAttributes {
427
673
  key?: JsxKey;
428
674
  }
429
- interface IntrinsicElements extends DeckJsxIntrinsicElements {}
675
+ interface IntrinsicElements extends DeckJsxIntrinsicElements {
676
+ span: IntrinsicPProps;
677
+ }
430
678
  }
431
679
  //#endregion
432
- export { ImageProps as $, CssFlexBasis as A, ViewProps as At, CssGridTrack as B, ContentJsxChild as C, TextJsxChild as Ct, CssAspectRatio as D, TextTabStopAuthoring as Dt, CssAlignSelf as E, TextTabStopAlignment as Et, CssGridPlacement as F, CssPosition as G, CssJustifySelf as H, CssGridShorthand as I, DeckLength as J, CssVisibility as K, CssGridTemplate as L, CssFlexWrap as M, CssGridAutoFlow as N, CssBoxSizing as O, TextTabStopLength as Ot, CssGridLine as P, ImageCropValue as Q, CssGridTemplateAreas as R, ContentAuthorNode as S, TextFit as St, CssAlignItems as T, TextStyle as Tt, CssObjectPosition as U, CssJustifyContent as V, CssOverflow as W, DeckPointLength as X, DeckOptions as Y, ImageCropAuthoring as Z, AuthorNodeMap as _, StackAlignment as _t, Fragment as a, IntrinsicTextTag as at, BackendName as b, StrokeLineCap as bt, Slide as c, LayoutMode as ct, createElement as d, ShapeStyle as dt, ImageStyle as et, isAuthorNode as f, SlideContext as ft, AuthorNodeKind as g, Spacing as gt, AuthorNode as h, SlideStyle as ht, jsxs as i, IntrinsicPProps as it, CssFlexDirection as j, ViewStyle as jt, CssDisplay as k, VerticalAlign as kt, Text as l, OutputConfig as lt, isSlideNode as m, SlideProps as mt, JsxKey as n, IntrinsicDivProps as nt, Image as o, IntrinsicViewTag as ot, isContentNode as p, SlideFactory as pt, DeckJsxIntrinsicElements as q, jsx as r, IntrinsicImgProps as rt, Shape as s, JsxNode as st, JSX as t, ImplementedBackendName as tt, View as u, ShapeProps as ut, AuthorNodeProps as v, StackAxis as vt, CssAlignContent as w, TextProps as wt, BorderStyle as x, StrokeLineJoin as xt, AuthorNodePropsMap as y, StrokeDashType as yt, CssGridTemplateShorthand as z };
680
+ export { ImageStyle as $, SourceIdentity as $t, CssFlexDirection as A, CompositionContext as At, CssJustifyContent as B, GraphNodeId as Bt, CssAlignContent as C, TextTabStopAlignment as Ct, CssBoxSizing as D, ViewProps as Dt, CssAspectRatio as E, VerticalAlign as Et, CssGridShorthand as F, SourceContextInput as Ft, CssVisibility as G, SemanticNode as Gt, CssObjectPosition as H, SemanticContainerNode as Ht, CssGridTemplate as I, SourceContextMapper as It, DeckOptions as J, SemanticRole as Jt, DeckJsxIntrinsicElements as K, SemanticNodeKind as Kt, CssGridTemplateAreas as L, AssetEntity as Lt, CssGridAutoFlow as M, CompositionSourceInternals as Mt, CssGridLine as N, SlideFactory as Nt, CssDisplay as O, ViewStyle as Ot, CssGridPlacement as P, SlideFactoryInput as Pt, ImageProps as Q, SemanticTextRunNode as Qt, CssGridTemplateShorthand as R, AssetEntityId as Rt, ContentJsxChild as S, TextStyle as St, CssAlignSelf as T, TextTabStopLength as Tt, CssOverflow as U, SemanticDocumentNode as Ut, CssJustifySelf as V, SemanticAuthorGraph as Vt, CssPosition as W, SemanticImageNode as Wt, ImageCropAuthoring as X, SemanticSlideNode as Xt, DeckPointLength as Y, SemanticShapeNode as Yt, ImageCropValue as Z, SemanticTextNode as Zt, AuthorNodeProps as _, StrokeLineCap as _t, createElement as a, DiagnosticSeverity as an, IntrinsicViewTag as at, BorderStyle as b, TextJsxChild as bt, isSlideNode as c, formatDiagnostics as cn, OutputConfig as ct, Slide as d, SemanticGraphDiagnosticError as dn, SlideProps as dt, SourceOrigin as en, ImplementedBackendName as et, Text as f, AuthorTreeNode as fn, SlideStyle as ft, AuthorNodeMap as g, StrokeDashType as gt, AuthorNodeKind as h, StackAxis as ht, Fragment as i, DiagnosticLabel as in, IntrinsicTextTag as it, CssFlexWrap as j, CompositionSource as jt, CssFlexBasis as k, COMPOSITION_SOURCE as kt, Image as l, CompositionDiagnosticError as ln, ShapeProps as lt, AuthorNode as m, SourceSpan as mn, StackAlignment as mt, jsx as n, StyleEntityId as nn, IntrinsicImgProps as nt, isAuthorNode as o, Diagnostics as on, JsxNode as ot, View as p, JsxKey as pn, Spacing as pt, DeckLength as q, SemanticOrigin as qt, jsxs as r, Diagnostic as rn, IntrinsicPProps as rt, isContentNode as s, formatDiagnostic as sn, LayoutMode as st, JSX as t, StyleEntity as tn, IntrinsicDivProps as tt, Shape as u, DeckDiagnosticError as un, ShapeStyle as ut, AuthorNodePropsMap as v, StrokeLineJoin as vt, CssAlignItems as w, TextTabStopAuthoring as wt, ContentAuthorNode as x, TextProps as xt, BackendName as y, TextFit as yt, CssGridTrack as z, BaseSemanticNode as zt };
@@ -1,2 +1,2 @@
1
- import { a as Fragment, i as jsxs, n as JsxKey, r as jsx, t as JSX } from "./jsx-runtime-BWV9tOov.mjs";
1
+ import { i as Fragment, n as jsx, pn as JsxKey, r as jsxs, t as JSX } from "./jsx-runtime-DauuRkY2.mjs";
2
2
  export { Fragment, JSX, JsxKey, jsx, jsxs };
@@ -1,7 +1,7 @@
1
- import { s as createElement, t as Fragment } from "./jsx-lqMAdW2X.mjs";
1
+ import { r as createElementWithMetadata, t as Fragment } from "./jsx-Crlbye9V.mjs";
2
2
  //#region src/jsx-runtime.ts
3
- function jsx(type, props, _key) {
4
- return createElement(type, props);
3
+ function jsx(type, props, key) {
4
+ return createElementWithMetadata(type, props, key);
5
5
  }
6
6
  const jsxs = jsx;
7
7
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deckjsx",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Generate PowerPoint presentations from TSX/JSX through a compiler pipeline.",
5
5
  "license": "MIT",
6
6
  "author": "deckjsx contributors",
@@ -1,175 +0,0 @@
1
- //#region src/jsx.ts
2
- const VIEW_INTRINSIC_TAGS = new Set([
3
- "article",
4
- "aside",
5
- "div",
6
- "figure",
7
- "footer",
8
- "header",
9
- "main",
10
- "nav",
11
- "section"
12
- ]);
13
- const TEXT_INTRINSIC_TAGS = new Set([
14
- "h1",
15
- "h2",
16
- "h3",
17
- "h4",
18
- "h5",
19
- "h6",
20
- "p"
21
- ]);
22
- function isRecord(value) {
23
- return typeof value === "object" && value !== null;
24
- }
25
- function isViewIntrinsicTag(value) {
26
- return VIEW_INTRINSIC_TAGS.has(value);
27
- }
28
- function isTextIntrinsicTag(value) {
29
- return TEXT_INTRINSIC_TAGS.has(value);
30
- }
31
- function isJsxNode(value) {
32
- return value === null || value === void 0 || typeof value === "string" || typeof value === "number" || typeof value === "boolean" || isAuthorNode(value) || Array.isArray(value) && value.every((item) => isJsxNode(item));
33
- }
34
- function isTextJsxNode(value) {
35
- return value === null || value === void 0 || typeof value === "string" || typeof value === "number" || typeof value === "boolean" || Array.isArray(value) && value.every((item) => isTextJsxNode(item));
36
- }
37
- function requireJsxNode(value) {
38
- if (isJsxNode(value)) return value;
39
- throw new Error("JSX children must be deckjsx nodes or primitive text values.");
40
- }
41
- function requireTextJsxNode(value) {
42
- if (isTextJsxNode(value)) return value;
43
- throw new Error("Text-like intrinsic children must be primitive text values.");
44
- }
45
- function flattenChildren(input) {
46
- if (Array.isArray(input)) return input.flatMap((item) => flattenChildren(item));
47
- return [input];
48
- }
49
- function splitContentProps(props) {
50
- const { children: rawChildren, ...nodeProps } = props;
51
- return {
52
- props: nodeProps,
53
- children: rawChildren === void 0 ? [] : flattenChildren(rawChildren)
54
- };
55
- }
56
- function splitTextProps(props) {
57
- const { children: rawChildren, ...nodeProps } = props;
58
- return {
59
- props: nodeProps,
60
- children: rawChildren === void 0 ? [] : flattenChildren(rawChildren)
61
- };
62
- }
63
- function splitLeafProps(props) {
64
- const { children: _rawChildren, ...nodeProps } = props;
65
- return nodeProps;
66
- }
67
- function collectRawChildren(propsObject, children) {
68
- if (children.length === 0) return propsObject.children;
69
- if (children.length === 1) return children[0];
70
- return children;
71
- }
72
- function implicitTextNode(value) {
73
- if (typeof value === "string" && value.trim().length === 0) return null;
74
- const text = typeof value === "string" && /[\n\r\t]/.test(value) ? value.trim() : String(value);
75
- if (text.length === 0) return null;
76
- return Text({ children: text });
77
- }
78
- function normalizeViewIntrinsicChildren(value) {
79
- if (value === void 0) return;
80
- return flattenChildren(value).map((child) => {
81
- if (typeof child === "string" || typeof child === "number") return implicitTextNode(child);
82
- return child;
83
- });
84
- }
85
- function intrinsicElement(type, propsObject, children) {
86
- const rawChildren = collectRawChildren(propsObject, children);
87
- const { children: _children, ...nodeProps } = propsObject;
88
- if (isViewIntrinsicTag(type)) {
89
- const viewChildren = requireJsxNode(rawChildren);
90
- return View({
91
- ...nodeProps,
92
- children: normalizeViewIntrinsicChildren(viewChildren)
93
- });
94
- }
95
- if (isTextIntrinsicTag(type)) return Text({
96
- ...nodeProps,
97
- children: requireTextJsxNode(rawChildren)
98
- });
99
- if (rawChildren !== void 0) throw new Error("<img> is a leaf element and does not accept children.");
100
- if (typeof propsObject.src !== "string" && typeof propsObject.data !== "string") throw new Error("<img> requires either src or data.");
101
- return Image(nodeProps);
102
- }
103
- function createElement(type, props, ...children) {
104
- if (typeof type === "string") {
105
- if (isViewIntrinsicTag(type) || isTextIntrinsicTag(type) || type === "img") return intrinsicElement(type, isRecord(props) ? props : {}, children);
106
- throw new Error(`Intrinsic element is not supported: <${type}>.`);
107
- }
108
- if (typeof type !== "function") throw new Error("JSX element type must be a function component.");
109
- const propsObject = isRecord(props) ? props : {};
110
- return type({
111
- ...propsObject,
112
- children: children.length === 0 ? requireJsxNode(propsObject.children) : children.length === 1 ? requireJsxNode(children[0]) : children.map((child) => requireJsxNode(child))
113
- });
114
- }
115
- function Fragment(props) {
116
- return props.children ?? null;
117
- }
118
- function Slide(props) {
119
- const authored = splitContentProps(props);
120
- return {
121
- $$typeof: "deckjsx.author-node",
122
- kind: "slide",
123
- props: authored.props,
124
- children: authored.children
125
- };
126
- }
127
- function View(props) {
128
- const authored = splitContentProps(props);
129
- return {
130
- $$typeof: "deckjsx.author-node",
131
- kind: "view",
132
- props: authored.props,
133
- children: authored.children
134
- };
135
- }
136
- function Text(props) {
137
- const authored = splitTextProps(props);
138
- return {
139
- $$typeof: "deckjsx.author-node",
140
- kind: "text",
141
- props: authored.props,
142
- children: authored.children
143
- };
144
- }
145
- function Image(props) {
146
- return {
147
- $$typeof: "deckjsx.author-node",
148
- kind: "image",
149
- props: splitLeafProps(props),
150
- children: []
151
- };
152
- }
153
- function Shape(props) {
154
- return {
155
- $$typeof: "deckjsx.author-node",
156
- kind: "shape",
157
- props: splitLeafProps(props),
158
- children: []
159
- };
160
- }
161
- function isAuthorNodeKind(value) {
162
- return value === "slide" || value === "view" || value === "text" || value === "image" || value === "shape";
163
- }
164
- function isAuthorNode(value) {
165
- if (!isRecord(value)) return false;
166
- return value.$$typeof === "deckjsx.author-node" && isAuthorNodeKind(value.kind) && isRecord(value.props) && Array.isArray(value.children);
167
- }
168
- function isSlideNode(value) {
169
- return isAuthorNode(value) && value.kind === "slide";
170
- }
171
- function isContentNode(value) {
172
- return isAuthorNode(value) && value.kind !== "slide";
173
- }
174
- //#endregion
175
- export { Text as a, isAuthorNode as c, Slide as i, isContentNode as l, Image as n, View as o, Shape as r, createElement as s, Fragment as t, isSlideNode as u };