deckjsx 0.1.1 → 0.1.2

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
@@ -80,6 +80,29 @@ await deck.output({ backend: "pptxgenjs", output: "quarterly-review.pptx" });
80
80
  Use `deck.render()` for tests, snapshots, and backend-independent inspection. Use
81
81
  `deck.output({ backend: "pptxgenjs", output })` when writing a PowerPoint file.
82
82
 
83
+ ## View Layout Semantics
84
+
85
+ `View` is a containing block for its children. Child `x`, `y`, `left`, `top`, `right`,
86
+ `bottom`, `width`, and `height` values are resolved relative to the parent `View`, not
87
+ the slide, so authors can build panels with local coordinates. Percentage lengths use
88
+ the parent frame as their reference.
89
+
90
+ ```tsx
91
+ <View style={{ x: 1, y: 1, width: 6, height: 3 }}>
92
+ <Text style={{ x: "10%", y: "20%", width: "50%", height: "25%" }}>local percent frame</Text>
93
+ <Text style={{ left: "55%", top: "10%", right: "10%", bottom: "60%" }}>inset frame</Text>
94
+ </View>
95
+ ```
96
+
97
+ For `display: "flex"` and `display: "grid"`, normal-flow children are laid out inside
98
+ the content frame after padding. `gap`, `flexGrow`, percentage widths, `fr` grid tracks,
99
+ and simple `gridColumn` / `gridRow` spans resolve to concrete slide coordinates during
100
+ rendering. Absolutely positioned children inside flex or grid containers also use the
101
+ container content frame, including padding, as their containing block.
102
+
103
+ Use direct slide children when you want slide-global absolute placement. Use children
104
+ inside a `View` when you want a local, web-like layout region.
105
+
83
106
  ## Development
84
107
 
85
108
  ```bash
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as OutputConfig, A as CssGridLine, B as CssOverflow, C as CssAspectRatio, D as CssFlexDirection, E as CssFlexBasis, F as CssGridTemplateShorthand, G as DeckPointLength, H as CssVisibility, I as CssGridTrack, J as ImageProps, K as ImageCropAuthoring, L as CssJustifyContent, M as CssGridShorthand, N as CssGridTemplate, O as CssFlexWrap, P as CssGridTemplateAreas, Q as LayoutMode, R as CssJustifySelf, S as CssAlignSelf, T as CssDisplay, U as DeckLength, V as CssPosition, W as DeckOptions, X as ImplementedBackendName, Y as ImageStyle, Z as JsxNode, _ as BorderStyle, _t as TextTabStopAuthoring, a as Text, at as SlideStyle, b as CssAlignContent, bt as ViewProps, c as isAuthorNode, ct as StackAxis, d as AuthorNode, dt as StrokeLineJoin, et as ShapeProps, f as AuthorNodeKind, ft as TextFit, g as BackendName, gt as TextTabStopAlignment, h as AuthorNodePropsMap, ht as TextStyle, i as Slide, it as SlideProps, j as CssGridPlacement, k as CssGridAutoFlow, l as isContentNode, lt as StrokeDashType, m as AuthorNodeProps, mt as TextProps, n as Image, nt as SlideContext, o as View, ot as Spacing, p as AuthorNodeMap, pt as TextJsxChild, q as ImageCropValue, r as Shape, rt as SlideFactory, s as createElement, st as StackAlignment, t as Fragment, tt as ShapeStyle, u as isSlideNode, ut as StrokeLineCap, v as ContentAuthorNode, vt as TextTabStopLength, w as CssBoxSizing, x as CssAlignItems, xt as ViewStyle, y as ContentJsxChild, yt as VerticalAlign, z as CssObjectPosition } from "./jsx-CrQPDEqU.mjs";
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";
2
2
 
3
3
  //#region src/ir/index.d.ts
4
4
  type PresentationIR = {
@@ -260,8 +260,11 @@ declare global {
260
260
  interface ElementChildrenAttribute {
261
261
  children: {};
262
262
  }
263
+ interface IntrinsicAttributes {
264
+ key?: JsxKey;
265
+ }
263
266
  interface IntrinsicElements {}
264
267
  }
265
268
  }
266
269
  //#endregion
267
- 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 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 };
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 };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as Text, c as isAuthorNode, i as Slide, l as isContentNode, n as Image, o as View, r as Shape, s as createElement, t as Fragment, u as isSlideNode } from "./jsx-5H4Zgl79.mjs";
1
+ import { a as Text, c as isAuthorNode, i as Slide, l as isContentNode, n as Image, o as View, r as Shape, s as createElement, t as Fragment, u as isSlideNode } from "./jsx-Cj45FgcC.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import { mkdir, writeFile } from "node:fs/promises";
4
4
  import { dirname } from "node:path";
@@ -13,15 +13,24 @@ function flattenChildren(input) {
13
13
  if (Array.isArray(input)) return input.flatMap((item) => flattenChildren(item));
14
14
  return [input];
15
15
  }
16
- function authorNode(kind, props) {
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) {
17
24
  const { children: rawChildren, ...nodeProps } = props;
18
25
  return {
19
- $$typeof: "deckjsx.author-node",
20
- kind,
21
26
  props: nodeProps,
22
27
  children: rawChildren === void 0 ? [] : flattenChildren(rawChildren)
23
28
  };
24
29
  }
30
+ function splitLeafProps(props) {
31
+ const { children: _rawChildren, ...nodeProps } = props;
32
+ return nodeProps;
33
+ }
25
34
  function createElement(type, props, ...children) {
26
35
  if (typeof type === "string") throw new Error(`Intrinsic elements are not supported: <${type}>.`);
27
36
  if (typeof type !== "function") throw new Error("JSX element type must be a function component.");
@@ -35,19 +44,47 @@ function Fragment(props) {
35
44
  return props.children ?? null;
36
45
  }
37
46
  function Slide(props) {
38
- return authorNode("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
+ };
39
54
  }
40
55
  function View(props) {
41
- return authorNode("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
+ };
42
63
  }
43
64
  function Text(props) {
44
- return authorNode("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
+ };
45
72
  }
46
73
  function Image(props) {
47
- return authorNode("image", props);
74
+ return {
75
+ $$typeof: "deckjsx.author-node",
76
+ kind: "image",
77
+ props: splitLeafProps(props),
78
+ children: []
79
+ };
48
80
  }
49
81
  function Shape(props) {
50
- return authorNode("shape", props);
82
+ return {
83
+ $$typeof: "deckjsx.author-node",
84
+ kind: "shape",
85
+ props: splitLeafProps(props),
86
+ children: []
87
+ };
51
88
  }
52
89
  function isAuthorNodeKind(value) {
53
90
  return value === "slide" || value === "view" || value === "text" || value === "image" || value === "shape";
@@ -1,3 +1,2 @@
1
- import { t as Fragment } from "./jsx-CrQPDEqU.mjs";
2
- import { JSX, jsx, jsxs } from "./jsx-runtime.mjs";
1
+ import { a as Fragment, i as jsxs, r as jsx, t as JSX } from "./jsx-runtime-BfZK5259.mjs";
3
2
  export { Fragment, type JSX, jsx, jsx as jsxDEV, jsxs };
@@ -1,3 +1,3 @@
1
- import { t as Fragment } from "./jsx-5H4Zgl79.mjs";
1
+ import { t as Fragment } from "./jsx-Cj45FgcC.mjs";
2
2
  import { jsx, jsxs } from "./jsx-runtime.mjs";
3
3
  export { Fragment, jsx, jsx as jsxDEV, jsxs };
@@ -339,12 +339,25 @@ type AuthorNodePropsMap = {
339
339
  shape: ShapeNodeProps;
340
340
  };
341
341
  type AuthorNodeProps<K extends AuthorNodeKind> = AuthorNodePropsMap[K];
342
- type AuthorNode<K extends AuthorNodeKind = AuthorNodeKind> = { [NodeKind in K]: {
342
+ type BaseAuthorNode<K extends AuthorNodeKind, P, C> = {
343
343
  readonly $$typeof: "deckjsx.author-node";
344
- readonly kind: NodeKind;
345
- readonly props: AuthorNodeProps<NodeKind>;
346
- readonly children: ReadonlyArray<JsxNode>;
347
- } }[K];
344
+ readonly kind: K;
345
+ readonly props: P;
346
+ readonly children: ReadonlyArray<C>;
347
+ };
348
+ interface SlideAuthorNode extends BaseAuthorNode<"slide", SlideNodeProps, ContentJsxChild> {}
349
+ interface ViewAuthorNode extends BaseAuthorNode<"view", ViewNodeProps, ContentJsxChild> {}
350
+ interface TextAuthorNode extends BaseAuthorNode<"text", TextNodeProps, TextJsxChild> {}
351
+ interface ImageAuthorNode extends BaseAuthorNode<"image", ImageNodeProps, never> {}
352
+ interface ShapeAuthorNode extends BaseAuthorNode<"shape", ShapeNodeProps, never> {}
353
+ type AuthorNodeByKind = {
354
+ slide: SlideAuthorNode;
355
+ view: ViewAuthorNode;
356
+ text: TextAuthorNode;
357
+ image: ImageAuthorNode;
358
+ shape: ShapeAuthorNode;
359
+ };
360
+ type AuthorNode<K extends AuthorNodeKind = AuthorNodeKind> = AuthorNodeByKind[K];
348
361
  //#endregion
349
362
  //#region src/jsx.d.ts
350
363
  type ComponentProps = {
@@ -372,4 +385,24 @@ declare function isAuthorNode(value: unknown): value is AuthorNode;
372
385
  declare function isSlideNode(value: unknown): value is AuthorNode<"slide">;
373
386
  declare function isContentNode(value: unknown): value is ContentAuthorNode;
374
387
  //#endregion
375
- export { OutputConfig as $, CssGridLine as A, CssOverflow as B, CssAspectRatio as C, CssFlexDirection as D, CssFlexBasis as E, CssGridTemplateShorthand as F, DeckPointLength as G, CssVisibility as H, CssGridTrack as I, ImageProps as J, ImageCropAuthoring as K, CssJustifyContent as L, CssGridShorthand as M, CssGridTemplate as N, CssFlexWrap as O, CssGridTemplateAreas as P, LayoutMode as Q, CssJustifySelf as R, CssAlignSelf as S, CssDisplay as T, DeckLength as U, CssPosition as V, DeckOptions as W, ImplementedBackendName as X, ImageStyle as Y, JsxNode as Z, BorderStyle as _, TextTabStopAuthoring as _t, Text as a, SlideStyle as at, CssAlignContent as b, ViewProps as bt, isAuthorNode as c, StackAxis as ct, AuthorNode as d, StrokeLineJoin as dt, ShapeProps as et, AuthorNodeKind as f, TextFit as ft, BackendName as g, TextTabStopAlignment as gt, AuthorNodePropsMap as h, TextStyle as ht, Slide as i, SlideProps as it, CssGridPlacement as j, CssGridAutoFlow as k, isContentNode as l, StrokeDashType as lt, AuthorNodeProps as m, TextProps as mt, Image as n, SlideContext as nt, View as o, Spacing as ot, AuthorNodeMap as p, TextJsxChild as pt, ImageCropValue as q, Shape as r, SlideFactory as rt, createElement as s, StackAlignment as st, Fragment as t, ShapeStyle as tt, isSlideNode as u, StrokeLineCap as ut, ContentAuthorNode as v, TextTabStopLength as vt, CssBoxSizing as w, CssAlignItems as x, ViewStyle as xt, ContentJsxChild as y, VerticalAlign as yt, CssObjectPosition as z };
388
+ //#region src/jsx-runtime.d.ts
389
+ type JsxKey = string | number | bigint;
390
+ type JsxComponent<P, R extends JsxNode> = (props: P) => R;
391
+ type JsxProps<P> = P extends {
392
+ children?: unknown;
393
+ } ? 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;
395
+ declare function jsx(type: string, props: Record<string, unknown> | null, key?: JsxKey): never;
396
+ declare const jsxs: typeof jsx;
397
+ declare namespace JSX {
398
+ type Element = ContentJsxChild;
399
+ interface ElementChildrenAttribute {
400
+ children: {};
401
+ }
402
+ interface IntrinsicAttributes {
403
+ key?: JsxKey;
404
+ }
405
+ interface IntrinsicElements {}
406
+ }
407
+ //#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 };
@@ -1,19 +1,2 @@
1
- import { Z as JsxNode, t as Fragment, y as ContentJsxChild } from "./jsx-CrQPDEqU.mjs";
2
-
3
- //#region src/jsx-runtime.d.ts
4
- type JsxComponent<P, R extends JsxNode> = (props: P) => R;
5
- type JsxProps<P> = P extends {
6
- children?: unknown;
7
- } ? Omit<P, "children"> & Partial<Pick<P, "children">> : P;
8
- declare function jsx<P, R extends JsxNode>(type: JsxComponent<P, R>, props: JsxProps<P> | null, key?: string): R;
9
- declare function jsx(type: string, props: Record<string, unknown> | null, key?: string): never;
10
- declare const jsxs: typeof jsx;
11
- declare namespace JSX {
12
- type Element = ContentJsxChild;
13
- interface ElementChildrenAttribute {
14
- children: {};
15
- }
16
- interface IntrinsicElements {}
17
- }
18
- //#endregion
19
- export { Fragment, JSX, jsx, jsxs };
1
+ import { a as Fragment, i as jsxs, n as JsxKey, r as jsx, t as JSX } from "./jsx-runtime-BfZK5259.mjs";
2
+ export { Fragment, JSX, JsxKey, jsx, jsxs };
@@ -1,4 +1,4 @@
1
- import { s as createElement, t as Fragment } from "./jsx-5H4Zgl79.mjs";
1
+ import { s as createElement, t as Fragment } from "./jsx-Cj45FgcC.mjs";
2
2
  //#region src/jsx-runtime.ts
3
3
  function jsx(type, props, _key) {
4
4
  return createElement(type, props);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deckjsx",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Generate PowerPoint presentations from TSX/JSX through a compiler pipeline.",
5
5
  "license": "MIT",
6
6
  "author": "deckjsx contributors",
@@ -27,6 +27,7 @@
27
27
  "dev": "vp pack --watch",
28
28
  "test": "vp test",
29
29
  "check": "vp check",
30
+ "verify:render": "bun run scripts/verify-render.ts",
30
31
  "prepublishOnly": "vp run build"
31
32
  },
32
33
  "dependencies": {