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.
@@ -0,0 +1,290 @@
1
+ //#region src/authoring/tree.ts
2
+ function isRecord$1(value) {
3
+ return typeof value === "object" && value !== null;
4
+ }
5
+ function createAuthorText(value, sourceSpan) {
6
+ return {
7
+ $$typeof: "deckjsx.author-tree",
8
+ kind: "text",
9
+ value,
10
+ ...sourceSpan ? { sourceSpan } : {}
11
+ };
12
+ }
13
+ function createAuthorElement(input) {
14
+ return {
15
+ $$typeof: "deckjsx.author-tree",
16
+ kind: "element",
17
+ source: input.source,
18
+ ...input.key !== void 0 ? { key: input.key } : {},
19
+ props: input.props ?? {},
20
+ children: normalizeAuthorChildren(input.children ?? []),
21
+ ...input.sourceSpan ? { sourceSpan: input.sourceSpan } : {}
22
+ };
23
+ }
24
+ function createAuthorFragment(input) {
25
+ return {
26
+ $$typeof: "deckjsx.author-tree",
27
+ kind: "fragment",
28
+ ...input.key !== void 0 ? { key: input.key } : {},
29
+ children: normalizeAuthorChildren(input.children ?? []),
30
+ ...input.sourceSpan ? { sourceSpan: input.sourceSpan } : {}
31
+ };
32
+ }
33
+ function isAuthorTreeNode(value) {
34
+ return isRecord$1(value) && value.$$typeof === "deckjsx.author-tree";
35
+ }
36
+ function normalizeAuthorChildren(children) {
37
+ return children.flatMap((child) => {
38
+ if (child === null || child === void 0 || typeof child === "boolean") return [];
39
+ if (typeof child === "string" || typeof child === "number") return [createAuthorText(child)];
40
+ if (Array.isArray(child)) return normalizeAuthorChildren(child);
41
+ if (isAuthorTreeNode(child)) return [child];
42
+ throw new Error("JSX children must be deckjsx author tree nodes or primitive text values.");
43
+ });
44
+ }
45
+ function collectChildren(propsObject, children) {
46
+ if (children.length === 0) return propsObject.children;
47
+ if (children.length === 1) return children[0];
48
+ return children;
49
+ }
50
+ //#endregion
51
+ //#region src/authoring/components.ts
52
+ function splitChildren(props) {
53
+ const { children, ...nodeProps } = props;
54
+ return {
55
+ props: nodeProps,
56
+ children: children === void 0 ? [] : [children]
57
+ };
58
+ }
59
+ function leafProps(props) {
60
+ const { children: _children, ...nodeProps } = props;
61
+ return nodeProps;
62
+ }
63
+ function Slide(props) {
64
+ const authored = splitChildren(props);
65
+ return createAuthorElement({
66
+ source: {
67
+ kind: "component",
68
+ component: "Slide"
69
+ },
70
+ props: authored.props,
71
+ children: authored.children
72
+ });
73
+ }
74
+ function View(props) {
75
+ const authored = splitChildren(props);
76
+ return createAuthorElement({
77
+ source: {
78
+ kind: "component",
79
+ component: "View"
80
+ },
81
+ props: authored.props,
82
+ children: authored.children
83
+ });
84
+ }
85
+ function Text(props) {
86
+ const authored = splitChildren(props);
87
+ return createAuthorElement({
88
+ source: {
89
+ kind: "component",
90
+ component: "Text"
91
+ },
92
+ props: authored.props,
93
+ children: authored.children
94
+ });
95
+ }
96
+ function Image(props) {
97
+ return createAuthorElement({
98
+ source: {
99
+ kind: "component",
100
+ component: "Image"
101
+ },
102
+ props: leafProps(props)
103
+ });
104
+ }
105
+ function Shape(props) {
106
+ return createAuthorElement({
107
+ source: {
108
+ kind: "component",
109
+ component: "Shape"
110
+ },
111
+ props: leafProps(props)
112
+ });
113
+ }
114
+ //#endregion
115
+ //#region src/authoring/tags.ts
116
+ const INTRINSIC_VIEW_TAGS = new Set([
117
+ "article",
118
+ "aside",
119
+ "div",
120
+ "figure",
121
+ "footer",
122
+ "header",
123
+ "main",
124
+ "nav",
125
+ "section"
126
+ ]);
127
+ const INTRINSIC_TEXT_TAGS = new Set([
128
+ "h1",
129
+ "h2",
130
+ "h3",
131
+ "h4",
132
+ "h5",
133
+ "h6",
134
+ "p"
135
+ ]);
136
+ function isIntrinsicViewTag(value) {
137
+ return INTRINSIC_VIEW_TAGS.has(value);
138
+ }
139
+ function isIntrinsicTextTag(value) {
140
+ return INTRINSIC_TEXT_TAGS.has(value);
141
+ }
142
+ function isAuthoredTag(value) {
143
+ return isIntrinsicViewTag(value) || isIntrinsicTextTag(value) || value === "img" || value === "span";
144
+ }
145
+ //#endregion
146
+ //#region src/authoring/legacy.ts
147
+ function textFromPrimitive(value) {
148
+ if (typeof value === "string" && value.trim().length === 0) return null;
149
+ const text = typeof value === "string" && /[\n\r\t]/.test(value) ? value.trim() : String(value);
150
+ if (text.length === 0) return null;
151
+ return legacyNode("text", {}, [text]);
152
+ }
153
+ function legacyNode(kind, props, children) {
154
+ return {
155
+ $$typeof: "deckjsx.author-node",
156
+ kind,
157
+ props,
158
+ children
159
+ };
160
+ }
161
+ function elementKind(node) {
162
+ if (node.source.kind === "component") switch (node.source.component) {
163
+ case "Slide": return "slide";
164
+ case "View": return "view";
165
+ case "Text": return "text";
166
+ case "Image": return "image";
167
+ case "Shape": return "shape";
168
+ }
169
+ if (isIntrinsicViewTag(node.source.tag)) return "view";
170
+ if (isIntrinsicTextTag(node.source.tag) || node.source.tag === "span") return "text";
171
+ return "image";
172
+ }
173
+ function convertChildrenFor(kind, children) {
174
+ const converted = [];
175
+ for (const child of children) {
176
+ if (child.kind === "fragment") {
177
+ converted.push(...convertChildrenFor(kind, child.children));
178
+ continue;
179
+ }
180
+ if (child.kind === "text") {
181
+ if (kind === "view" || kind === "slide") {
182
+ const textNode = textFromPrimitive(child.value);
183
+ if (textNode) converted.push(textNode);
184
+ continue;
185
+ }
186
+ converted.push(child.value);
187
+ continue;
188
+ }
189
+ converted.push(toLegacyAuthorNode(child));
190
+ }
191
+ return converted;
192
+ }
193
+ function toLegacyAuthorNode(node) {
194
+ const kind = elementKind(node);
195
+ const props = node.props;
196
+ switch (kind) {
197
+ case "slide": return legacyNode("slide", props, convertChildrenFor(kind, node.children));
198
+ case "view": return legacyNode("view", props, convertChildrenFor(kind, node.children));
199
+ case "text": return legacyNode("text", props, convertChildrenFor(kind, node.children));
200
+ case "image": return legacyNode("image", props, []);
201
+ case "shape": return legacyNode("shape", props, []);
202
+ }
203
+ }
204
+ function toLegacyJsxNode(value) {
205
+ if (isLegacyAuthorNode(value)) return value;
206
+ if (Array.isArray(value)) return value.map((item) => toLegacyJsxNode(item));
207
+ if (!isAuthorTreeNode(value)) return value;
208
+ if (value.kind === "fragment") return value.children.map((child) => toLegacyJsxNode(child));
209
+ if (value.kind === "text") return value.value;
210
+ return toLegacyAuthorNode(value);
211
+ }
212
+ function isLegacyAuthorNode(value) {
213
+ return typeof value === "object" && value !== null && "$$typeof" in value && value.$$typeof === "deckjsx.author-node";
214
+ }
215
+ //#endregion
216
+ //#region src/jsx.ts
217
+ function isRecord(value) {
218
+ return typeof value === "object" && value !== null;
219
+ }
220
+ function splitProps(props, children) {
221
+ const rawChildren = collectChildren(props, children);
222
+ const { children: _children, ...nodeProps } = props;
223
+ return {
224
+ props: nodeProps,
225
+ children: rawChildren === void 0 ? [] : [rawChildren]
226
+ };
227
+ }
228
+ function intrinsicElement(type, propsObject, children, key, sourceSpan) {
229
+ const authored = splitProps(propsObject, children);
230
+ return createAuthorElement({
231
+ source: {
232
+ kind: "tag",
233
+ tag: type
234
+ },
235
+ props: authored.props,
236
+ children: authored.children,
237
+ ...key !== void 0 ? { key } : {},
238
+ ...sourceSpan ? { sourceSpan } : {}
239
+ });
240
+ }
241
+ function createElement(type, props, ...children) {
242
+ return createElementWithMetadata(type, props, void 0, void 0, children);
243
+ }
244
+ function createElementWithMetadata(type, props, key, sourceSpan, children = []) {
245
+ if (typeof type === "string") {
246
+ if (isIntrinsicViewTag(type) || isIntrinsicTextTag(type) || type === "img" || type === "span") return intrinsicElement(type, isRecord(props) ? props : {}, children, key, sourceSpan);
247
+ if (!isAuthoredTag(type)) throw new Error(`Intrinsic element is not supported: <${type}>.`);
248
+ }
249
+ if (typeof type !== "function") throw new Error("JSX element type must be a function component.");
250
+ if (type === Fragment) {
251
+ const rawChildren = collectChildren(isRecord(props) ? props : {}, children);
252
+ return createAuthorFragment({
253
+ children: rawChildren === void 0 ? [] : [rawChildren],
254
+ ...key !== void 0 ? { key } : {},
255
+ ...sourceSpan ? { sourceSpan } : {}
256
+ });
257
+ }
258
+ const propsObject = isRecord(props) ? props : {};
259
+ const rawChildren = collectChildren(propsObject, children);
260
+ const result = type({
261
+ ...propsObject,
262
+ children: rawChildren
263
+ });
264
+ if (!isAuthorTreeNode(result)) throw new Error("Function components must return a deckjsx author tree node.");
265
+ if (key === void 0 && sourceSpan === void 0) return result;
266
+ if (result.kind === "element") return {
267
+ ...result,
268
+ ...key !== void 0 ? { key } : {},
269
+ ...sourceSpan ? { sourceSpan } : {}
270
+ };
271
+ return result;
272
+ }
273
+ function Fragment(props) {
274
+ return createAuthorFragment({ children: props.children === void 0 ? [] : [props.children] });
275
+ }
276
+ function isAuthorNodeKind(value) {
277
+ return value === "slide" || value === "view" || value === "text" || value === "image" || value === "shape";
278
+ }
279
+ function isAuthorNode(value) {
280
+ if (!isLegacyAuthorNode(value)) return false;
281
+ return isAuthorNodeKind(value.kind);
282
+ }
283
+ function isSlideNode(value) {
284
+ return isAuthorNode(value) && value.kind === "slide";
285
+ }
286
+ function isContentNode(value) {
287
+ return isAuthorNode(value) && value.kind !== "slide";
288
+ }
289
+ //#endregion
290
+ export { isContentNode as a, toLegacyJsxNode as c, Slide as d, Text as f, isAuthorNode as i, Image as l, isAuthorTreeNode as m, createElement as n, isSlideNode as o, View as p, createElementWithMetadata as r, isLegacyAuthorNode as s, Fragment as t, Shape as u };
@@ -1,2 +1,6 @@
1
- import { a as Fragment, i as jsxs, r as jsx, t as JSX } from "./jsx-runtime-BfZK5259.mjs";
2
- export { Fragment, type JSX, jsx, jsx as jsxDEV, jsxs };
1
+ import { Mt as JsxKey, i as Fragment, jt as AuthorTreeNode, n as jsx, r as jsxs, t as JSX } from "./jsx-runtime-ru5t8S3z.mjs";
2
+
3
+ //#region src/jsx-dev-runtime.d.ts
4
+ declare function jsxDEV(type: unknown, props: unknown, key?: JsxKey, _isStaticChildren?: boolean, source?: unknown): AuthorTreeNode;
5
+ //#endregion
6
+ export { Fragment, type JSX, jsx, jsxDEV, jsxs };
@@ -1,3 +1,18 @@
1
- import { t as Fragment } from "./jsx-Cj45FgcC.mjs";
1
+ import { r as createElementWithMetadata, t as Fragment } from "./jsx-Crlbye9V.mjs";
2
2
  import { jsx, jsxs } from "./jsx-runtime.mjs";
3
- export { Fragment, jsx, jsx as jsxDEV, jsxs };
3
+ //#region src/jsx-dev-runtime.ts
4
+ function sourceSpanFromDevSource(source) {
5
+ if (typeof source !== "object" || source === null) return;
6
+ const devSource = source;
7
+ if (devSource.fileName === void 0 && devSource.lineNumber === void 0 && devSource.columnNumber === void 0) return;
8
+ return {
9
+ file: devSource.fileName,
10
+ line: devSource.lineNumber,
11
+ column: devSource.columnNumber
12
+ };
13
+ }
14
+ function jsxDEV(type, props, key, _isStaticChildren, source) {
15
+ return createElementWithMetadata(type, props, key, sourceSpanFromDevSource(source));
16
+ }
17
+ //#endregion
18
+ export { Fragment, jsx, jsxDEV, jsxs };
@@ -1,3 +1,49 @@
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
1
47
  //#region src/authoring/index.d.ts
2
48
  type DeckLength = number | `${number}${"in" | "pt" | "px" | "%" | "em" | "rem" | "vh" | "vw" | "ch"}`;
3
49
  type DeckPointLength = number | `${number}${"pt" | "in" | "px" | "em" | "rem" | "vh" | "vw" | "ch"}`;
@@ -50,12 +96,14 @@ type ImageCropAuthoring = {
50
96
  left?: ImageCropValue;
51
97
  };
52
98
  interface TextJsxChildArray extends ReadonlyArray<TextJsxChild> {}
53
- type TextJsxChild = string | number | boolean | null | undefined | TextJsxChildArray;
99
+ type TextJsxChild = AuthorTreeNode | string | number | boolean | null | undefined | TextJsxChildArray;
54
100
  type ContentAuthorNode = AuthorNode<"view" | "text" | "image" | "shape">;
55
101
  interface ContentJsxChildArray extends ReadonlyArray<ContentJsxChild> {}
56
- type ContentJsxChild = AuthorNode | boolean | null | undefined | ContentJsxChildArray;
102
+ type ContentJsxChild = AuthorNode | AuthorTreeNode | boolean | null | undefined | ContentJsxChildArray;
103
+ interface ViewIntrinsicJsxChildArray extends ReadonlyArray<ViewIntrinsicJsxChild> {}
104
+ type ViewIntrinsicJsxChild = ContentJsxChild | string | number | ViewIntrinsicJsxChildArray;
57
105
  interface JsxNodeArray extends ReadonlyArray<JsxNode> {}
58
- type JsxNode = AuthorNode | string | number | boolean | null | undefined | JsxNodeArray;
106
+ type JsxNode = AuthorNode | AuthorTreeNode | string | number | boolean | null | undefined | JsxNodeArray;
59
107
  type BaseAuthorProps = {
60
108
  opacity?: number;
61
109
  rotation?: number;
@@ -274,6 +322,10 @@ type DeckOptions = {
274
322
  type SlideContext = {
275
323
  slideIndex: number;
276
324
  totalSlides: number;
325
+ context?: {
326
+ slideIndex: number;
327
+ totalSlides: number;
328
+ };
277
329
  };
278
330
  type SlideFactory = (context: SlideContext) => JsxNode;
279
331
  type OutputConfig = {
@@ -310,9 +362,13 @@ type TextProps = TextNodeProps & {
310
362
  };
311
363
  type ImageNodeProps = {
312
364
  style?: ImageStyle;
313
- src?: string;
365
+ } & ImageStyle & ({
366
+ src: string;
314
367
  data?: string;
315
- } & ImageStyle;
368
+ } | {
369
+ src?: string;
370
+ data: string;
371
+ });
316
372
  type ImageProps = ImageNodeProps & {
317
373
  children?: never;
318
374
  };
@@ -358,10 +414,30 @@ type AuthorNodeByKind = {
358
414
  shape: ShapeAuthorNode;
359
415
  };
360
416
  type AuthorNode<K extends AuthorNodeKind = AuthorNodeKind> = AuthorNodeByKind[K];
417
+ type IntrinsicDivProps = ViewNodeProps & {
418
+ children?: ViewIntrinsicJsxChild;
419
+ };
420
+ type IntrinsicPProps = TextNodeProps & {
421
+ children?: TextJsxChild;
422
+ };
423
+ type IntrinsicImgProps = ImageProps;
424
+ type IntrinsicViewTag = "article" | "aside" | "div" | "figure" | "footer" | "header" | "main" | "nav" | "section";
425
+ type IntrinsicTextTag = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p";
426
+ type DeckJsxIntrinsicElements = {
427
+ img: IntrinsicImgProps;
428
+ span: IntrinsicPProps;
429
+ } & { [Tag in IntrinsicViewTag]: IntrinsicDivProps } & { [Tag in IntrinsicTextTag]: IntrinsicPProps };
430
+ //#endregion
431
+ //#region src/authoring/components.d.ts
432
+ declare function Slide(props: SlideProps): AuthorElementNode;
433
+ declare function View(props: ViewProps): AuthorElementNode;
434
+ declare function Text(props: TextProps): AuthorElementNode;
435
+ declare function Image(props: ImageProps): AuthorElementNode;
436
+ declare function Shape(props: ShapeProps): AuthorElementNode;
361
437
  //#endregion
362
438
  //#region src/jsx.d.ts
363
439
  type ComponentProps = {
364
- children?: JsxNode;
440
+ children?: AuthorTreeChild;
365
441
  };
366
442
  type ElementChildren<P> = P extends {
367
443
  children?: infer Child;
@@ -371,38 +447,42 @@ type ElementChildArgs<P> = P extends {
371
447
  } ? [] : ElementChildren<P>[];
372
448
  declare function createElement<P extends {
373
449
  children?: unknown;
374
- }, R extends JsxNode>(type: (props: P) => R, props: (Omit<P, "children"> & Partial<Pick<P, "children">>) | null, ...children: ElementChildArgs<P>): R;
450
+ }, R extends AuthorTreeNode>(type: (props: P) => R, props: (Omit<P, "children"> & Partial<Pick<P, "children">>) | null, ...children: ElementChildArgs<P>): R;
451
+ declare function createElement(type: IntrinsicViewTag$1, props: (Omit<IntrinsicDivProps, "children"> & Partial<Pick<IntrinsicDivProps, "children">>) | null, ...children: ElementChildArgs<IntrinsicDivProps>): AuthorTreeNode;
452
+ declare function createElement(type: IntrinsicTextTag$1, props: (Omit<IntrinsicPProps, "children"> & Partial<Pick<IntrinsicPProps, "children">>) | null, ...children: ElementChildArgs<IntrinsicPProps>): AuthorTreeNode;
453
+ declare function createElement(type: "span", props: IntrinsicPProps | null): AuthorTreeNode;
454
+ declare function createElement(type: "img", props: IntrinsicImgProps): AuthorTreeNode;
375
455
  declare function createElement(type: string, props: ComponentProps | null): never;
376
456
  declare function Fragment(props: {
377
- children?: ContentJsxChild;
378
- }): ContentJsxChild;
379
- declare function Slide(props: SlideProps): AuthorNode<"slide">;
380
- declare function View(props: ViewProps): AuthorNode<"view">;
381
- declare function Text(props: TextProps): AuthorNode<"text">;
382
- declare function Image(props: ImageProps): AuthorNode<"image">;
383
- declare function Shape(props: ShapeProps): AuthorNode<"shape">;
457
+ children?: AuthorTreeChild;
458
+ }): AuthorTreeNode;
384
459
  declare function isAuthorNode(value: unknown): value is AuthorNode;
385
460
  declare function isSlideNode(value: unknown): value is AuthorNode<"slide">;
386
461
  declare function isContentNode(value: unknown): value is ContentAuthorNode;
387
462
  //#endregion
388
463
  //#region src/jsx-runtime.d.ts
389
- type JsxKey = string | number | bigint;
390
- type JsxComponent<P, R extends JsxNode> = (props: P) => R;
464
+ type JsxComponent<P, R extends AuthorTreeNode> = (props: P) => R;
391
465
  type JsxProps<P> = P extends {
392
466
  children?: unknown;
393
467
  } ? Omit<P, "children"> & Partial<Pick<P, "children">> : P;
394
- declare function jsx<P, R extends JsxNode>(type: JsxComponent<P, R>, props: JsxProps<P> | null, key?: JsxKey): R;
468
+ declare function jsx<P, R extends AuthorTreeNode>(type: JsxComponent<P, R>, props: JsxProps<P> | null, key?: JsxKey): R;
469
+ declare function jsx(type: IntrinsicViewTag, props: JsxProps<IntrinsicDivProps> | null, key?: JsxKey): AuthorTreeNode;
470
+ declare function jsx(type: IntrinsicTextTag, props: JsxProps<IntrinsicPProps> | null, key?: JsxKey): AuthorTreeNode;
471
+ declare function jsx(type: "span", props: JsxProps<IntrinsicPProps> | null, key?: JsxKey): AuthorTreeNode;
472
+ declare function jsx(type: "img", props: IntrinsicImgProps, key?: JsxKey): AuthorTreeNode;
395
473
  declare function jsx(type: string, props: Record<string, unknown> | null, key?: JsxKey): never;
396
474
  declare const jsxs: typeof jsx;
397
475
  declare namespace JSX {
398
- type Element = ContentJsxChild;
476
+ type Element = AuthorTreeNode;
399
477
  interface ElementChildrenAttribute {
400
478
  children: {};
401
479
  }
402
480
  interface IntrinsicAttributes {
403
481
  key?: JsxKey;
404
482
  }
405
- interface IntrinsicElements {}
483
+ interface IntrinsicElements extends DeckJsxIntrinsicElements {
484
+ span: IntrinsicPProps;
485
+ }
406
486
  }
407
487
  //#endregion
408
- export { ImageStyle as $, CssFlexBasis as A, CssGridTrack as B, ContentJsxChild as C, VerticalAlign as Ct, CssAspectRatio as D, CssAlignSelf as E, CssGridPlacement as F, CssPosition as G, CssJustifySelf as H, CssGridShorthand as I, DeckOptions as J, CssVisibility as K, CssGridTemplate as L, CssFlexWrap as M, CssGridAutoFlow as N, CssBoxSizing as O, CssGridLine as P, ImageProps as Q, CssGridTemplateAreas as R, ContentAuthorNode as S, TextTabStopLength as St, CssAlignItems as T, ViewStyle as Tt, CssObjectPosition as U, CssJustifyContent as V, CssOverflow as W, ImageCropAuthoring as X, DeckPointLength as Y, ImageCropValue as Z, AuthorNodeMap as _, TextJsxChild as _t, Fragment as a, ShapeStyle as at, BackendName as b, TextTabStopAlignment as bt, Slide as c, SlideProps as ct, createElement as d, StackAlignment as dt, ImplementedBackendName as et, isAuthorNode as f, StackAxis as ft, AuthorNodeKind as g, TextFit as gt, AuthorNode as h, StrokeLineJoin as ht, jsxs as i, ShapeProps as it, CssFlexDirection as j, CssDisplay as k, Text as l, SlideStyle as lt, isSlideNode as m, StrokeLineCap as mt, JsxKey as n, LayoutMode as nt, Image as o, SlideContext as ot, isContentNode as p, StrokeDashType as pt, DeckLength as q, jsx as r, OutputConfig as rt, Shape as s, SlideFactory as st, JSX as t, JsxNode as tt, View as u, Spacing as ut, AuthorNodeProps as v, TextProps as vt, CssAlignContent as w, ViewProps as wt, BorderStyle as x, TextTabStopAuthoring as xt, AuthorNodePropsMap as y, TextStyle as yt, CssGridTemplateShorthand as z };
488
+ export { ImageStyle as $, CssFlexDirection as A, ViewStyle as At, CssJustifyContent as B, CssAlignContent as C, TextProps as Ct, CssBoxSizing as D, TextTabStopLength as Dt, CssAspectRatio as E, TextTabStopAuthoring as Et, CssGridShorthand as F, AuthoredTag as Ft, CssVisibility as G, CssObjectPosition as H, CssGridTemplate as I, SectioningTag as It, DeckOptions as J, DeckJsxIntrinsicElements as K, CssGridTemplateAreas as L, CssGridAutoFlow as M, JsxKey as Mt, CssGridLine as N, SourceSpan as Nt, CssDisplay as O, VerticalAlign as Ot, CssGridPlacement as P, AuthoredComponent as Pt, ImageProps as Q, CssGridTemplateShorthand as R, ContentJsxChild as S, TextJsxChild as St, CssAlignSelf as T, TextTabStopAlignment as Tt, CssOverflow as U, CssJustifySelf as V, CssPosition as W, ImageCropAuthoring as X, DeckPointLength as Y, ImageCropValue as Z, AuthorNodeProps as _, StackAxis as _t, createElement as a, IntrinsicViewTag as at, BorderStyle as b, StrokeLineJoin as bt, isSlideNode as c, OutputConfig as ct, Slide as d, SlideContext as dt, ImplementedBackendName as et, Text as f, SlideFactory as ft, AuthorNodeMap as g, StackAlignment as gt, AuthorNodeKind as h, Spacing as ht, Fragment as i, IntrinsicTextTag as it, CssFlexWrap as j, AuthorTreeNode as jt, CssFlexBasis as k, ViewProps as kt, Image as l, ShapeProps as lt, AuthorNode as m, SlideStyle as mt, jsx as n, IntrinsicImgProps as nt, isAuthorNode as o, JsxNode as ot, View as p, SlideProps as pt, DeckLength as q, jsxs as r, IntrinsicPProps as rt, isContentNode as s, LayoutMode as st, JSX as t, IntrinsicDivProps as tt, Shape as u, ShapeStyle as ut, AuthorNodePropsMap as v, StrokeDashType as vt, CssAlignItems as w, TextStyle as wt, ContentAuthorNode as x, TextFit as xt, BackendName as y, StrokeLineCap as yt, CssGridTrack as z };
@@ -1,2 +1,2 @@
1
- import { a as Fragment, i as jsxs, n as JsxKey, r as jsx, t as JSX } from "./jsx-runtime-BfZK5259.mjs";
1
+ import { Mt as JsxKey, i as Fragment, n as jsx, r as jsxs, t as JSX } from "./jsx-runtime-ru5t8S3z.mjs";
2
2
  export { Fragment, JSX, JsxKey, jsx, jsxs };
@@ -1,7 +1,7 @@
1
- import { s as createElement, t as Fragment } from "./jsx-Cj45FgcC.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.1.2",
3
+ "version": "0.2.1",
4
4
  "description": "Generate PowerPoint presentations from TSX/JSX through a compiler pipeline.",
5
5
  "license": "MIT",
6
6
  "author": "deckjsx contributors",
@@ -1,103 +0,0 @@
1
- //#region src/jsx.ts
2
- function isRecord(value) {
3
- return typeof value === "object" && value !== null;
4
- }
5
- function isJsxNode(value) {
6
- 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));
7
- }
8
- function requireJsxNode(value) {
9
- if (isJsxNode(value)) return value;
10
- throw new Error("JSX children must be deckjsx nodes or primitive text values.");
11
- }
12
- function flattenChildren(input) {
13
- if (Array.isArray(input)) return input.flatMap((item) => flattenChildren(item));
14
- return [input];
15
- }
16
- function splitContentProps(props) {
17
- const { children: rawChildren, ...nodeProps } = props;
18
- return {
19
- props: nodeProps,
20
- children: rawChildren === void 0 ? [] : flattenChildren(rawChildren)
21
- };
22
- }
23
- function splitTextProps(props) {
24
- const { children: rawChildren, ...nodeProps } = props;
25
- return {
26
- props: nodeProps,
27
- children: rawChildren === void 0 ? [] : flattenChildren(rawChildren)
28
- };
29
- }
30
- function splitLeafProps(props) {
31
- const { children: _rawChildren, ...nodeProps } = props;
32
- return nodeProps;
33
- }
34
- function createElement(type, props, ...children) {
35
- if (typeof type === "string") throw new Error(`Intrinsic elements are not supported: <${type}>.`);
36
- if (typeof type !== "function") throw new Error("JSX element type must be a function component.");
37
- const propsObject = isRecord(props) ? props : {};
38
- return type({
39
- ...propsObject,
40
- children: children.length === 0 ? requireJsxNode(propsObject.children) : children.length === 1 ? requireJsxNode(children[0]) : children.map((child) => requireJsxNode(child))
41
- });
42
- }
43
- function Fragment(props) {
44
- return props.children ?? null;
45
- }
46
- function Slide(props) {
47
- const authored = splitContentProps(props);
48
- return {
49
- $$typeof: "deckjsx.author-node",
50
- kind: "slide",
51
- props: authored.props,
52
- children: authored.children
53
- };
54
- }
55
- function View(props) {
56
- const authored = splitContentProps(props);
57
- return {
58
- $$typeof: "deckjsx.author-node",
59
- kind: "view",
60
- props: authored.props,
61
- children: authored.children
62
- };
63
- }
64
- function Text(props) {
65
- const authored = splitTextProps(props);
66
- return {
67
- $$typeof: "deckjsx.author-node",
68
- kind: "text",
69
- props: authored.props,
70
- children: authored.children
71
- };
72
- }
73
- function Image(props) {
74
- return {
75
- $$typeof: "deckjsx.author-node",
76
- kind: "image",
77
- props: splitLeafProps(props),
78
- children: []
79
- };
80
- }
81
- function Shape(props) {
82
- return {
83
- $$typeof: "deckjsx.author-node",
84
- kind: "shape",
85
- props: splitLeafProps(props),
86
- children: []
87
- };
88
- }
89
- function isAuthorNodeKind(value) {
90
- return value === "slide" || value === "view" || value === "text" || value === "image" || value === "shape";
91
- }
92
- function isAuthorNode(value) {
93
- if (!isRecord(value)) return false;
94
- return value.$$typeof === "deckjsx.author-node" && isAuthorNodeKind(value.kind) && isRecord(value.props) && Array.isArray(value.children);
95
- }
96
- function isSlideNode(value) {
97
- return isAuthorNode(value) && value.kind === "slide";
98
- }
99
- function isContentNode(value) {
100
- return isAuthorNode(value) && value.kind !== "slide";
101
- }
102
- //#endregion
103
- 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 };