@office-kit/pptx-dsl 0.2.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.
- package/LICENSE +21 -0
- package/README.md +131 -0
- package/dist/index.d.ts +135 -0
- package/dist/index.js +232 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx-runtime-BgfNl42k.js +70 -0
- package/dist/jsx-runtime-BgfNl42k.js.map +1 -0
- package/dist/jsx-runtime-C-Ggfem1.d.ts +50 -0
- package/dist/jsx-runtime.d.ts +2 -0
- package/dist/jsx-runtime.js +2 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yuichiro Yamashita
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# @office-kit/pptx-dsl
|
|
2
|
+
|
|
3
|
+
Start with [Create slides with AI and TSX](https://office-kit.github.io/pptx/docs/authoring)
|
|
4
|
+
for installation and preview, then see the
|
|
5
|
+
[TSX reference](https://office-kit.github.io/pptx/docs/tsx).
|
|
6
|
+
The DSL and CLI are not yet published to npm; the guide uses local packages.
|
|
7
|
+
|
|
8
|
+
Typed, declarative PowerPoint authoring in TSX. This package uses its own JSX
|
|
9
|
+
runtime; React and Vue are not dependencies. It creates native editable PPTX
|
|
10
|
+
objects through `@office-kit/pptx`. Rendering belongs to `@office-kit/pptx-preview`.
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import { Presentation, Slide, Text, Chart } from '@office-kit/pptx-dsl';
|
|
14
|
+
|
|
15
|
+
export default (
|
|
16
|
+
<Presentation>
|
|
17
|
+
<Slide background="#FFFFFF">
|
|
18
|
+
<Text x={0.9} y={0.5} width={11.5} height={0.8} size={30} bold>
|
|
19
|
+
Quarterly revenue
|
|
20
|
+
</Text>
|
|
21
|
+
<Chart
|
|
22
|
+
x={0.9}
|
|
23
|
+
y={1.7}
|
|
24
|
+
width={11.5}
|
|
25
|
+
height={5}
|
|
26
|
+
spec={{
|
|
27
|
+
kind: 'column',
|
|
28
|
+
categories: ['Q1', 'Q2'],
|
|
29
|
+
series: [{ name: 'Revenue', values: [120, 180] }],
|
|
30
|
+
}}
|
|
31
|
+
/>
|
|
32
|
+
</Slide>
|
|
33
|
+
</Presentation>
|
|
34
|
+
);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Configure TypeScript with `jsx: "react-jsx"`,
|
|
38
|
+
`jsxImportSource: "@office-kit/pptx-dsl"`, and `moduleResolution: "Bundler"`.
|
|
39
|
+
The `@office-kit/pptx-dev` CLI supplies project initialization, export and watch
|
|
40
|
+
preview. Alternatively, call `compile(root)` and `savePresentation(result)`.
|
|
41
|
+
The DSL itself is browser-safe and performs no filesystem access.
|
|
42
|
+
|
|
43
|
+
Coordinates and dimensions (`x`, `y`, `width`, `height`) are inches. Font size
|
|
44
|
+
and stroke width are points. Child order is drawing order. Functions, fragments,
|
|
45
|
+
arrays, conditions and `.map()` compose elements using ordinary TypeScript.
|
|
46
|
+
Layout is explicit: CSS and automatic UI layout are not implemented.
|
|
47
|
+
|
|
48
|
+
## Elements
|
|
49
|
+
|
|
50
|
+
| Element | Input |
|
|
51
|
+
| -------------- | ------------------------------------------------------------------------ |
|
|
52
|
+
| `Presentation` | Optional source PPTX bytes or `size`, theme, `mode` |
|
|
53
|
+
| `Slide` | Source `from` or edit `target`, layout, background, notes |
|
|
54
|
+
| `Text` | Literal children or core `ParagraphSpec[]` via `paragraphs`, text format |
|
|
55
|
+
| `Shape` | Core preset geometry, fill, stroke, effects, optional text |
|
|
56
|
+
| `Image` | Bytes in `data`, optional format and fit |
|
|
57
|
+
| `Chart` | Complete core `ChartSpec` via `spec` |
|
|
58
|
+
| `Table` | String rows, column widths, row heights, cell/header styles, stripe fill |
|
|
59
|
+
| `Fill` | Existing shape target, replacement text, optional format |
|
|
60
|
+
| `Remove` | Existing shape target |
|
|
61
|
+
| `Raw` | Deferred callback receiving the presentation and enclosing slide/shape |
|
|
62
|
+
|
|
63
|
+
Bounds are required for newly created visual objects. Shape styles support solid
|
|
64
|
+
and gradient fills, stroke, rotation, shadow, glow and click actions. `Text`
|
|
65
|
+
accepts the core `TextFormat` properties directly, plus alignment, anchor and
|
|
66
|
+
text auto-fit. Table cell formats are merged with header overrides.
|
|
67
|
+
|
|
68
|
+
## Existing presentations
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
import { readFile } from 'node:fs/promises';
|
|
72
|
+
import { Presentation, Slide, Fill } from '@office-kit/pptx-dsl';
|
|
73
|
+
|
|
74
|
+
const source = await readFile(new URL('./template.pptx', import.meta.url));
|
|
75
|
+
export default (
|
|
76
|
+
<Presentation source={source} mode="edit">
|
|
77
|
+
<Slide target={{ index: 0 }}>
|
|
78
|
+
<Fill target={{ name: 'Title 1' }}>Q3 business review</Fill>
|
|
79
|
+
</Slide>
|
|
80
|
+
</Presentation>
|
|
81
|
+
);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`mode="edit"` keeps the existing slide sequence and edits only explicit targets.
|
|
85
|
+
It is the default when a source is supplied. `mode="compose"` replaces the slide sequence with the declared
|
|
86
|
+
slides; use `<Slide from={{index: 0}}>` to duplicate an original slide. References
|
|
87
|
+
always refer to the source sequence, and each compilation loads the source fresh.
|
|
88
|
+
A source deck is not reconstructed from DSL-understood fields: the core package
|
|
89
|
+
retains existing parts. Editing text intentionally replaces that shape's text.
|
|
90
|
+
`size` applies only to new decks; source decks retain their original dimensions.
|
|
91
|
+
`theme` accepts the core theme overrides and follows its first-theme semantics.
|
|
92
|
+
|
|
93
|
+
Slide references accept a zero-based index, exact title, or part name. Layout
|
|
94
|
+
references accept exact name, type, or part name. Shape targets accept exact name,
|
|
95
|
+
id, or `{placeholder: {type, idx}}`. Missing and ambiguous matches are errors.
|
|
96
|
+
`office-pptx inspect template.pptx` lists usable references. Layouts and masters
|
|
97
|
+
from the template remain in the package; selecting a layout retains inheritance.
|
|
98
|
+
|
|
99
|
+
## Escape hatch
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
import { setShapeRotation } from '@office-kit/pptx';
|
|
103
|
+
import { Shape, Raw } from '@office-kit/pptx-dsl';
|
|
104
|
+
|
|
105
|
+
const element = (
|
|
106
|
+
<Shape preset="rect" x={1} y={1} width={2} height={1}>
|
|
107
|
+
<Raw
|
|
108
|
+
scope="shape"
|
|
109
|
+
apply={({ shape }) => {
|
|
110
|
+
setShapeRotation(shape, 15);
|
|
111
|
+
}}
|
|
112
|
+
/>
|
|
113
|
+
</Shape>
|
|
114
|
+
);
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Raw callbacks run in declaration order after normal construction and before the
|
|
118
|
+
compose mode removes original slides. They can be async. They use public core
|
|
119
|
+
APIs. Set `scope="shape"`, `scope="slide"` or `scope="presentation"` for required,
|
|
120
|
+
context-specific handles and a nesting check. Without scope, contextual handles
|
|
121
|
+
are optional. Text also
|
|
122
|
+
accepts Raw children. An enclosing shape does not accept new Slide-level objects.
|
|
123
|
+
|
|
124
|
+
## Current coverage
|
|
125
|
+
|
|
126
|
+
This is an initial DSL, not complete OOXML coverage. Typed master/layout creation,
|
|
127
|
+
animations, transitions, connectors, groups, media playback, and structured table
|
|
128
|
+
cells still require additional declarative elements or core work. Raw can invoke
|
|
129
|
+
available core capabilities but does not count as typed declarative support.
|
|
130
|
+
Cross-presentation imports are not exposed because the current core import API
|
|
131
|
+
can discard unsupported relationships. Do not use it as a lossless import path.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { c as Node, l as PresentationNode, o as Child, s as Children, t as Fragment, u as RawContext } from "./jsx-runtime-C-Ggfem1.js";
|
|
2
|
+
import * as api from "@office-kit/pptx";
|
|
3
|
+
|
|
4
|
+
//#region src/index.d.ts
|
|
5
|
+
type PresentationProps = Children & ({
|
|
6
|
+
source: api.PresentationInput;
|
|
7
|
+
size?: never;
|
|
8
|
+
} | {
|
|
9
|
+
source?: never;
|
|
10
|
+
size?: api.PresentationSize;
|
|
11
|
+
}) & {
|
|
12
|
+
theme?: Parameters<typeof api.setPresentationTheme>[1]; /** Compose replaces the slide sequence; edit retains the original sequence. */
|
|
13
|
+
mode?: 'compose' | 'edit';
|
|
14
|
+
};
|
|
15
|
+
declare function Presentation(props: PresentationProps): PresentationNode;
|
|
16
|
+
declare function compile(root: Node): Promise<api.PresentationData>;
|
|
17
|
+
type LayoutRef = {
|
|
18
|
+
name: string;
|
|
19
|
+
} | {
|
|
20
|
+
part: string;
|
|
21
|
+
} | {
|
|
22
|
+
type: string;
|
|
23
|
+
};
|
|
24
|
+
type SlideRef = {
|
|
25
|
+
index: number;
|
|
26
|
+
} | {
|
|
27
|
+
part: string;
|
|
28
|
+
} | {
|
|
29
|
+
title: string;
|
|
30
|
+
};
|
|
31
|
+
type Target = {
|
|
32
|
+
name: string;
|
|
33
|
+
} | {
|
|
34
|
+
id: number;
|
|
35
|
+
} | {
|
|
36
|
+
placeholder: {
|
|
37
|
+
type?: string;
|
|
38
|
+
idx?: number;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
type SlideProps = Children & ({
|
|
42
|
+
from?: SlideRef;
|
|
43
|
+
target?: never;
|
|
44
|
+
} | {
|
|
45
|
+
from?: never;
|
|
46
|
+
target: SlideRef;
|
|
47
|
+
}) & {
|
|
48
|
+
layout?: LayoutRef;
|
|
49
|
+
background?: string;
|
|
50
|
+
notes?: string;
|
|
51
|
+
};
|
|
52
|
+
declare function Slide(props: SlideProps): Node;
|
|
53
|
+
type RawProps = {
|
|
54
|
+
scope?: undefined;
|
|
55
|
+
apply: (context: RawContext) => void | Promise<void>;
|
|
56
|
+
} | {
|
|
57
|
+
scope: 'presentation';
|
|
58
|
+
apply: (context: Pick<RawContext, 'presentation'>) => void | Promise<void>;
|
|
59
|
+
} | {
|
|
60
|
+
scope: 'slide';
|
|
61
|
+
apply: (context: RawContext & {
|
|
62
|
+
slide: api.SlideData;
|
|
63
|
+
}) => void | Promise<void>;
|
|
64
|
+
} | {
|
|
65
|
+
scope: 'shape';
|
|
66
|
+
apply: (context: Required<RawContext>) => void | Promise<void>;
|
|
67
|
+
};
|
|
68
|
+
declare function Raw(props: RawProps): Node;
|
|
69
|
+
interface Bounds {
|
|
70
|
+
x: number;
|
|
71
|
+
y: number;
|
|
72
|
+
width: number;
|
|
73
|
+
height: number;
|
|
74
|
+
}
|
|
75
|
+
interface ShapeStyle {
|
|
76
|
+
name?: string;
|
|
77
|
+
fill?: string | api.GradientFillOptions;
|
|
78
|
+
stroke?: {
|
|
79
|
+
color: string;
|
|
80
|
+
width?: number;
|
|
81
|
+
} | false;
|
|
82
|
+
rotation?: number;
|
|
83
|
+
shadow?: api.ShadowOptions;
|
|
84
|
+
glow?: api.GlowOptions;
|
|
85
|
+
click?: api.ShapeClickAction;
|
|
86
|
+
}
|
|
87
|
+
interface TextProps extends Bounds, ShapeStyle, api.TextFormat, Children {
|
|
88
|
+
paragraphs?: readonly api.ParagraphSpec[];
|
|
89
|
+
align?: api.ParagraphAlignment;
|
|
90
|
+
anchor?: api.TextAnchor;
|
|
91
|
+
autoFit?: api.TextAutoFit;
|
|
92
|
+
}
|
|
93
|
+
declare function Text(props: TextProps): Node;
|
|
94
|
+
interface ShapeProps extends Bounds, ShapeStyle, Children {
|
|
95
|
+
preset: Parameters<typeof api.addSlideShape>[1]['preset'];
|
|
96
|
+
text?: string;
|
|
97
|
+
format?: api.TextFormat;
|
|
98
|
+
}
|
|
99
|
+
declare function Shape(props: ShapeProps): Node;
|
|
100
|
+
interface ImageProps extends Bounds, ShapeStyle, Children {
|
|
101
|
+
data: Uint8Array;
|
|
102
|
+
format?: api.ImageFormat;
|
|
103
|
+
fit?: api.ImageFit;
|
|
104
|
+
}
|
|
105
|
+
declare function Image(props: ImageProps): Node;
|
|
106
|
+
interface ChartProps extends Bounds, ShapeStyle, Children {
|
|
107
|
+
spec: api.ChartSpec;
|
|
108
|
+
}
|
|
109
|
+
declare function Chart(props: ChartProps): Node;
|
|
110
|
+
interface CellStyle {
|
|
111
|
+
fill?: string;
|
|
112
|
+
format?: api.TextFormat;
|
|
113
|
+
anchor?: api.TextAnchor;
|
|
114
|
+
}
|
|
115
|
+
interface TableProps extends Bounds, Children {
|
|
116
|
+
rows: readonly (readonly string[])[];
|
|
117
|
+
columnWidths?: readonly number[];
|
|
118
|
+
rowHeights?: readonly number[];
|
|
119
|
+
cellStyle?: CellStyle;
|
|
120
|
+
headerStyle?: CellStyle;
|
|
121
|
+
stripeFill?: string;
|
|
122
|
+
}
|
|
123
|
+
declare function Table(props: TableProps): Node;
|
|
124
|
+
interface FillProps extends Children {
|
|
125
|
+
target: Target;
|
|
126
|
+
text?: string;
|
|
127
|
+
format?: api.TextFormat;
|
|
128
|
+
}
|
|
129
|
+
declare function Fill(props: FillProps): Node;
|
|
130
|
+
declare function Remove(props: {
|
|
131
|
+
target: Target;
|
|
132
|
+
}): Node;
|
|
133
|
+
//#endregion
|
|
134
|
+
export { Bounds, CellStyle, Chart, ChartProps, type Child, type Children, Fill, FillProps, Fragment, Image, ImageProps, LayoutRef, type Node, Presentation, type PresentationNode, PresentationProps, Raw, type RawContext, RawProps, Remove, Shape, ShapeProps, ShapeStyle, Slide, SlideProps, SlideRef, Table, TableProps, Target, Text, TextProps, compile };
|
|
135
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { a as literal, c as textContent, l as visit, o as node, s as requireSlide, t as Fragment } from "./jsx-runtime-BgfNl42k.js";
|
|
2
|
+
import * as api from "@office-kit/pptx";
|
|
3
|
+
//#region src/index.ts
|
|
4
|
+
function Presentation(props) {
|
|
5
|
+
return {
|
|
6
|
+
kind: "Presentation",
|
|
7
|
+
evaluate: () => {
|
|
8
|
+
throw new Error("Presentation must be the root.");
|
|
9
|
+
},
|
|
10
|
+
async compile() {
|
|
11
|
+
if (props.source !== void 0 && props.size !== void 0) throw new Error("Presentation source retains its original size; do not specify size.");
|
|
12
|
+
const presentation = props.source === void 0 ? api.createPresentation(props.size === void 0 ? {} : { size: props.size }) : await api.loadPresentation(props.source);
|
|
13
|
+
if (props.theme) api.setPresentationTheme(presentation, props.theme);
|
|
14
|
+
const originals = [...api.getSlides(presentation)];
|
|
15
|
+
const context = {
|
|
16
|
+
presentation,
|
|
17
|
+
originals,
|
|
18
|
+
mode: props.mode ?? (props.source === void 0 ? "compose" : "edit"),
|
|
19
|
+
scope: "presentation",
|
|
20
|
+
deferred: []
|
|
21
|
+
};
|
|
22
|
+
await visit(props.children, context);
|
|
23
|
+
for (const apply of context.deferred) await apply();
|
|
24
|
+
if (context.mode === "compose") for (const slide of originals) api.removeSlide(presentation, slide);
|
|
25
|
+
return presentation;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
async function compile(root) {
|
|
30
|
+
if (!("compile" in root) || typeof root.compile !== "function") throw new Error("Export a Presentation as the root.");
|
|
31
|
+
return root.compile();
|
|
32
|
+
}
|
|
33
|
+
function selectSlide(context, ref) {
|
|
34
|
+
const matches = context.originals.filter((slide, index) => "index" in ref ? index === ref.index : "part" in ref ? api.getSlidePartName(slide) === ref.part : api.getSlideTitle(slide) === ref.title);
|
|
35
|
+
if (matches.length !== 1) throw new Error(`Slide reference matched ${matches.length} slides: ${JSON.stringify(ref)}`);
|
|
36
|
+
return matches[0];
|
|
37
|
+
}
|
|
38
|
+
function selectLayout(presentation, ref) {
|
|
39
|
+
const matches = api.getSlideLayouts(presentation).filter((layout) => "name" in ref ? api.getSlideLayoutName(layout) === ref.name : "part" in ref ? api.getSlideLayoutPartName(layout) === ref.part : api.getSlideLayoutType(layout) === ref.type);
|
|
40
|
+
if (matches.length !== 1) throw new Error(`Layout reference matched ${matches.length} layouts: ${JSON.stringify(ref)}`);
|
|
41
|
+
return matches[0];
|
|
42
|
+
}
|
|
43
|
+
function Slide(props) {
|
|
44
|
+
return node("Slide", async (context) => {
|
|
45
|
+
if (context.scope !== "presentation") throw new Error("Slide must be inside Presentation.");
|
|
46
|
+
if (props.target && context.mode !== "edit") throw new Error("Slide target requires Presentation mode=\"edit\".");
|
|
47
|
+
if (props.from && props.target) throw new Error("Slide cannot specify both from and target.");
|
|
48
|
+
const layout = props.layout ? selectLayout(context.presentation, props.layout) : void 0;
|
|
49
|
+
const slide = props.target ? selectSlide(context, props.target) : props.from ? api.duplicateSlide(context.presentation, selectSlide(context, props.from)) : layout ? api.addSlide(context.presentation, { layout }) : api.addBlankSlide(context.presentation);
|
|
50
|
+
if (layout && (props.from || props.target)) api.setSlideLayout(slide, layout);
|
|
51
|
+
if (props.background !== void 0) api.setSlideBackground(slide, props.background);
|
|
52
|
+
if (props.notes !== void 0) api.setSlideNotes(slide, props.notes);
|
|
53
|
+
await visit(props.children, {
|
|
54
|
+
...context,
|
|
55
|
+
slide,
|
|
56
|
+
scope: "slide"
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function Raw(props) {
|
|
61
|
+
return node("Raw", (context) => {
|
|
62
|
+
if (props.scope !== void 0 && props.scope !== context.scope) throw new Error(`Raw scope="${props.scope}" cannot run inside ${context.scope}.`);
|
|
63
|
+
context.deferred.push(() => {
|
|
64
|
+
if (props.scope === "shape") {
|
|
65
|
+
if (!context.shape || !context.slide) throw new Error("Raw requires a shape context.");
|
|
66
|
+
return props.apply({
|
|
67
|
+
presentation: context.presentation,
|
|
68
|
+
slide: context.slide,
|
|
69
|
+
shape: context.shape
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (props.scope === "slide") {
|
|
73
|
+
if (!context.slide) throw new Error("Raw requires a slide context.");
|
|
74
|
+
return props.apply({
|
|
75
|
+
...context,
|
|
76
|
+
slide: context.slide
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return props.apply(context);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function bounds(props) {
|
|
84
|
+
return {
|
|
85
|
+
x: api.inches(props.x),
|
|
86
|
+
y: api.inches(props.y),
|
|
87
|
+
w: api.inches(props.width),
|
|
88
|
+
h: api.inches(props.height)
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function style(shape, props) {
|
|
92
|
+
if (props.fill !== void 0) if (typeof props.fill === "string") api.setShapeFill(shape, props.fill);
|
|
93
|
+
else api.setShapeGradientFill(shape, props.fill);
|
|
94
|
+
if (props.stroke === false) api.setShapeNoStroke(shape);
|
|
95
|
+
else if (props.stroke) api.setShapeStroke(shape, {
|
|
96
|
+
color: props.stroke.color,
|
|
97
|
+
widthEmu: api.pt(props.stroke.width ?? 1)
|
|
98
|
+
});
|
|
99
|
+
if (props.rotation !== void 0) api.setShapeRotation(shape, props.rotation);
|
|
100
|
+
if (props.shadow) api.setShapeShadow(shape, props.shadow);
|
|
101
|
+
if (props.glow) api.setShapeGlow(shape, props.glow);
|
|
102
|
+
if (props.click) api.setShapeClickAction(shape, props.click);
|
|
103
|
+
}
|
|
104
|
+
function Text(props) {
|
|
105
|
+
return node("Text", async (context) => {
|
|
106
|
+
const slide = requireSlide(context);
|
|
107
|
+
const content = textContent(props.children);
|
|
108
|
+
if (props.paragraphs && content.text.trim()) throw new Error("Text accepts either text children or paragraphs.");
|
|
109
|
+
const shape = api.addSlideTextBox(slide, {
|
|
110
|
+
...bounds(props),
|
|
111
|
+
...props.name ? { name: props.name } : {},
|
|
112
|
+
text: content.text
|
|
113
|
+
});
|
|
114
|
+
if (props.paragraphs) api.setShapeParagraphs(shape, props.paragraphs);
|
|
115
|
+
api.setShapeTextFormat(shape, props);
|
|
116
|
+
if (props.align) api.setShapeAlignment(shape, props.align);
|
|
117
|
+
if (props.anchor) api.setShapeTextAnchor(shape, props.anchor);
|
|
118
|
+
if (props.autoFit) api.setShapeTextAutoFit(shape, props.autoFit);
|
|
119
|
+
style(shape, props);
|
|
120
|
+
await visit(content.elements, {
|
|
121
|
+
...context,
|
|
122
|
+
slide,
|
|
123
|
+
shape,
|
|
124
|
+
scope: "shape"
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function Shape(props) {
|
|
129
|
+
return node("Shape", async (context) => {
|
|
130
|
+
const shape = api.addSlideShape(requireSlide(context), {
|
|
131
|
+
...bounds(props),
|
|
132
|
+
preset: props.preset,
|
|
133
|
+
...props.name ? { name: props.name } : {},
|
|
134
|
+
...props.text !== void 0 ? { text: props.text } : {}
|
|
135
|
+
});
|
|
136
|
+
style(shape, props);
|
|
137
|
+
if (props.format) api.setShapeTextFormat(shape, props.format);
|
|
138
|
+
await visit(props.children, {
|
|
139
|
+
...context,
|
|
140
|
+
shape,
|
|
141
|
+
scope: "shape"
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
function Image(props) {
|
|
146
|
+
return node("Image", async (context) => {
|
|
147
|
+
const shape = api.addSlideImage(requireSlide(context), props.data, {
|
|
148
|
+
...bounds(props),
|
|
149
|
+
...props.format ? { format: props.format } : {},
|
|
150
|
+
...props.fit ? { fit: props.fit } : {},
|
|
151
|
+
...props.name ? { name: props.name } : {}
|
|
152
|
+
});
|
|
153
|
+
style(shape, props);
|
|
154
|
+
await visit(props.children, {
|
|
155
|
+
...context,
|
|
156
|
+
shape,
|
|
157
|
+
scope: "shape"
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
function Chart(props) {
|
|
162
|
+
return node("Chart", async (context) => {
|
|
163
|
+
const shape = api.addSlideChart(requireSlide(context), {
|
|
164
|
+
...bounds(props),
|
|
165
|
+
spec: props.spec,
|
|
166
|
+
...props.name ? { name: props.name } : {}
|
|
167
|
+
});
|
|
168
|
+
style(shape, props);
|
|
169
|
+
await visit(props.children, {
|
|
170
|
+
...context,
|
|
171
|
+
shape,
|
|
172
|
+
scope: "shape"
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
function Table(props) {
|
|
177
|
+
return node("Table", async (context) => {
|
|
178
|
+
const shape = api.addSlideTable(requireSlide(context), {
|
|
179
|
+
...bounds(props),
|
|
180
|
+
rows: props.rows,
|
|
181
|
+
...props.columnWidths ? { colWidths: props.columnWidths.map(api.inches) } : {},
|
|
182
|
+
...props.rowHeights ? { rowHeights: props.rowHeights.map(api.inches) } : {}
|
|
183
|
+
});
|
|
184
|
+
props.rows.forEach((row, r) => row.forEach((_, c) => {
|
|
185
|
+
const cell = api.getTableCell(shape, r, c);
|
|
186
|
+
const appearance = {
|
|
187
|
+
...props.cellStyle,
|
|
188
|
+
...r === 0 ? props.headerStyle : {},
|
|
189
|
+
format: {
|
|
190
|
+
...props.cellStyle?.format,
|
|
191
|
+
...r === 0 ? props.headerStyle?.format : {}
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
if (appearance.fill) api.setTableCellFill(cell, appearance.fill);
|
|
195
|
+
if (r > 0 && r % 2 === 0 && props.stripeFill) api.setTableCellFill(cell, props.stripeFill);
|
|
196
|
+
if (appearance.format) api.setTableCellTextFormat(cell, appearance.format);
|
|
197
|
+
if (appearance.anchor) api.setTableCellAnchor(cell, appearance.anchor);
|
|
198
|
+
}));
|
|
199
|
+
await visit(props.children, {
|
|
200
|
+
...context,
|
|
201
|
+
shape,
|
|
202
|
+
scope: "shape"
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
function selectShape(slide, target) {
|
|
207
|
+
const matches = api.getSlideShapes(slide).filter((shape) => {
|
|
208
|
+
if ("name" in target) return api.getShapeName(shape) === target.name;
|
|
209
|
+
if ("id" in target) return api.getShapeId(shape) === target.id;
|
|
210
|
+
const ph = target.placeholder;
|
|
211
|
+
return (ph.type !== void 0 || ph.idx !== void 0) && (ph.type === void 0 || api.getShapePlaceholderType(shape) === ph.type) && (ph.idx === void 0 || api.getShapePlaceholderIdx(shape) === ph.idx);
|
|
212
|
+
});
|
|
213
|
+
if (matches.length !== 1) throw new Error(`Shape reference matched ${matches.length} shapes: ${JSON.stringify(target)}`);
|
|
214
|
+
return matches[0];
|
|
215
|
+
}
|
|
216
|
+
function Fill(props) {
|
|
217
|
+
return node("Fill", (context) => {
|
|
218
|
+
const shape = selectShape(requireSlide(context), props.target);
|
|
219
|
+
api.setShapeText(shape, props.text ?? literal(props.children));
|
|
220
|
+
if (props.format) api.setShapeTextFormat(shape, props.format);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
function Remove(props) {
|
|
224
|
+
return node("Remove", (context) => {
|
|
225
|
+
const slide = requireSlide(context);
|
|
226
|
+
api.removeShape(selectShape(slide, props.target));
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
//#endregion
|
|
230
|
+
export { Chart, Fill, Fragment, Image, Presentation, Raw, Remove, Shape, Slide, Table, Text, compile };
|
|
231
|
+
|
|
232
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import * as api from '@office-kit/pptx';\nimport {\n textContent,\n literal,\n node,\n requireSlide,\n visit,\n type Children,\n type Context,\n type Node,\n type PresentationNode,\n type RawContext,\n} from './model.ts';\nexport type { Child, Children, Node, PresentationNode, RawContext } from './model.ts';\nexport { Fragment } from './jsx-runtime.ts';\n\nexport type PresentationProps = Children &\n (\n | { source: api.PresentationInput; size?: never }\n | { source?: never; size?: api.PresentationSize }\n ) & {\n theme?: Parameters<typeof api.setPresentationTheme>[1];\n /** Compose replaces the slide sequence; edit retains the original sequence. */\n mode?: 'compose' | 'edit';\n };\nexport function Presentation(props: PresentationProps): PresentationNode {\n return {\n kind: 'Presentation',\n evaluate: () => {\n throw new Error('Presentation must be the root.');\n },\n async compile() {\n if (props.source !== undefined && props.size !== undefined)\n throw new Error('Presentation source retains its original size; do not specify size.');\n const presentation =\n props.source === undefined\n ? api.createPresentation(props.size === undefined ? {} : { size: props.size })\n : await api.loadPresentation(props.source);\n if (props.theme) api.setPresentationTheme(presentation, props.theme);\n const originals = [...api.getSlides(presentation)];\n const context: Context = {\n presentation,\n originals,\n mode: props.mode ?? (props.source === undefined ? 'compose' : 'edit'),\n scope: 'presentation',\n deferred: [],\n };\n await visit(props.children, context);\n for (const apply of context.deferred) await apply();\n if (context.mode === 'compose') {\n for (const slide of originals) api.removeSlide(presentation, slide);\n }\n return presentation;\n },\n };\n}\nexport async function compile(root: Node): Promise<api.PresentationData> {\n if (!('compile' in root) || typeof root.compile !== 'function')\n throw new Error('Export a Presentation as the root.');\n return root.compile();\n}\n\nexport type LayoutRef = { name: string } | { part: string } | { type: string };\nexport type SlideRef = { index: number } | { part: string } | { title: string };\nexport type Target =\n | { name: string }\n | { id: number }\n | { placeholder: { type?: string; idx?: number } };\nexport type SlideProps = Children &\n ({ from?: SlideRef; target?: never } | { from?: never; target: SlideRef }) & {\n layout?: LayoutRef;\n background?: string;\n notes?: string;\n };\nfunction selectSlide(context: Context, ref: SlideRef): api.SlideData {\n const matches = context.originals.filter((slide, index) =>\n 'index' in ref\n ? index === ref.index\n : 'part' in ref\n ? api.getSlidePartName(slide) === ref.part\n : api.getSlideTitle(slide) === ref.title,\n );\n if (matches.length !== 1)\n throw new Error(`Slide reference matched ${matches.length} slides: ${JSON.stringify(ref)}`);\n return matches[0]!;\n}\nfunction selectLayout(presentation: api.PresentationData, ref: LayoutRef): api.SlideLayoutData {\n const matches = api\n .getSlideLayouts(presentation)\n .filter((layout) =>\n 'name' in ref\n ? api.getSlideLayoutName(layout) === ref.name\n : 'part' in ref\n ? api.getSlideLayoutPartName(layout) === ref.part\n : api.getSlideLayoutType(layout) === ref.type,\n );\n if (matches.length !== 1)\n throw new Error(`Layout reference matched ${matches.length} layouts: ${JSON.stringify(ref)}`);\n return matches[0]!;\n}\nexport function Slide(props: SlideProps): Node {\n return node('Slide', async (context) => {\n if (context.scope !== 'presentation') throw new Error('Slide must be inside Presentation.');\n if (props.target && context.mode !== 'edit')\n throw new Error('Slide target requires Presentation mode=\"edit\".');\n if (props.from && props.target) throw new Error('Slide cannot specify both from and target.');\n const layout = props.layout ? selectLayout(context.presentation, props.layout) : undefined;\n const slide = props.target\n ? selectSlide(context, props.target)\n : props.from\n ? api.duplicateSlide(context.presentation, selectSlide(context, props.from))\n : layout\n ? api.addSlide(context.presentation, { layout })\n : api.addBlankSlide(context.presentation);\n if (layout && (props.from || props.target)) api.setSlideLayout(slide, layout);\n if (props.background !== undefined) api.setSlideBackground(slide, props.background);\n if (props.notes !== undefined) api.setSlideNotes(slide, props.notes);\n await visit(props.children, { ...context, slide, scope: 'slide' });\n });\n}\nexport type RawProps =\n | { scope?: undefined; apply: (context: RawContext) => void | Promise<void> }\n | {\n scope: 'presentation';\n apply: (context: Pick<RawContext, 'presentation'>) => void | Promise<void>;\n }\n | {\n scope: 'slide';\n apply: (context: RawContext & { slide: api.SlideData }) => void | Promise<void>;\n }\n | { scope: 'shape'; apply: (context: Required<RawContext>) => void | Promise<void> };\n\nexport function Raw(props: RawProps): Node {\n return node('Raw', (context) => {\n if (props.scope !== undefined && props.scope !== context.scope) {\n throw new Error(`Raw scope=\"${props.scope}\" cannot run inside ${context.scope}.`);\n }\n context.deferred.push(() => {\n if (props.scope === 'shape') {\n if (!context.shape || !context.slide) throw new Error('Raw requires a shape context.');\n return props.apply({\n presentation: context.presentation,\n slide: context.slide,\n shape: context.shape,\n });\n }\n if (props.scope === 'slide') {\n if (!context.slide) throw new Error('Raw requires a slide context.');\n return props.apply({ ...context, slide: context.slide });\n }\n return props.apply(context);\n });\n });\n}\nexport interface Bounds {\n x: number;\n y: number;\n width: number;\n height: number;\n}\nexport interface ShapeStyle {\n name?: string;\n fill?: string | api.GradientFillOptions;\n stroke?: { color: string; width?: number } | false;\n rotation?: number;\n shadow?: api.ShadowOptions;\n glow?: api.GlowOptions;\n click?: api.ShapeClickAction;\n}\nfunction bounds(props: Bounds) {\n return {\n x: api.inches(props.x),\n y: api.inches(props.y),\n w: api.inches(props.width),\n h: api.inches(props.height),\n };\n}\nfunction style(shape: api.SlideShapeData, props: ShapeStyle) {\n if (props.fill !== undefined) {\n if (typeof props.fill === 'string') api.setShapeFill(shape, props.fill);\n else api.setShapeGradientFill(shape, props.fill);\n }\n if (props.stroke === false) api.setShapeNoStroke(shape);\n else if (props.stroke)\n api.setShapeStroke(shape, {\n color: props.stroke.color,\n widthEmu: api.pt(props.stroke.width ?? 1),\n });\n if (props.rotation !== undefined) api.setShapeRotation(shape, props.rotation);\n if (props.shadow) api.setShapeShadow(shape, props.shadow);\n if (props.glow) api.setShapeGlow(shape, props.glow);\n if (props.click) api.setShapeClickAction(shape, props.click);\n}\nexport interface TextProps extends Bounds, ShapeStyle, api.TextFormat, Children {\n paragraphs?: readonly api.ParagraphSpec[];\n align?: api.ParagraphAlignment;\n anchor?: api.TextAnchor;\n autoFit?: api.TextAutoFit;\n}\nexport function Text(props: TextProps): Node {\n return node('Text', async (context) => {\n const slide = requireSlide(context);\n const content = textContent(props.children);\n if (props.paragraphs && content.text.trim())\n throw new Error('Text accepts either text children or paragraphs.');\n const shape = api.addSlideTextBox(slide, {\n ...bounds(props),\n ...(props.name ? { name: props.name } : {}),\n text: content.text,\n });\n if (props.paragraphs) api.setShapeParagraphs(shape, props.paragraphs);\n api.setShapeTextFormat(shape, props);\n if (props.align) api.setShapeAlignment(shape, props.align);\n if (props.anchor) api.setShapeTextAnchor(shape, props.anchor);\n if (props.autoFit) api.setShapeTextAutoFit(shape, props.autoFit);\n style(shape, props);\n await visit(content.elements, { ...context, slide, shape, scope: 'shape' });\n });\n}\nexport interface ShapeProps extends Bounds, ShapeStyle, Children {\n preset: Parameters<typeof api.addSlideShape>[1]['preset'];\n text?: string;\n format?: api.TextFormat;\n}\nexport function Shape(props: ShapeProps): Node {\n return node('Shape', async (context) => {\n const shape = api.addSlideShape(requireSlide(context), {\n ...bounds(props),\n preset: props.preset,\n ...(props.name ? { name: props.name } : {}),\n ...(props.text !== undefined ? { text: props.text } : {}),\n });\n style(shape, props);\n if (props.format) api.setShapeTextFormat(shape, props.format);\n await visit(props.children, { ...context, shape, scope: 'shape' });\n });\n}\nexport interface ImageProps extends Bounds, ShapeStyle, Children {\n data: Uint8Array;\n format?: api.ImageFormat;\n fit?: api.ImageFit;\n}\nexport function Image(props: ImageProps): Node {\n return node('Image', async (context) => {\n const shape = api.addSlideImage(requireSlide(context), props.data, {\n ...bounds(props),\n ...(props.format ? { format: props.format } : {}),\n ...(props.fit ? { fit: props.fit } : {}),\n ...(props.name ? { name: props.name } : {}),\n });\n style(shape, props);\n await visit(props.children, { ...context, shape, scope: 'shape' });\n });\n}\nexport interface ChartProps extends Bounds, ShapeStyle, Children {\n spec: api.ChartSpec;\n}\nexport function Chart(props: ChartProps): Node {\n return node('Chart', async (context) => {\n const shape = api.addSlideChart(requireSlide(context), {\n ...bounds(props),\n spec: props.spec,\n ...(props.name ? { name: props.name } : {}),\n });\n style(shape, props);\n await visit(props.children, { ...context, shape, scope: 'shape' });\n });\n}\nexport interface CellStyle {\n fill?: string;\n format?: api.TextFormat;\n anchor?: api.TextAnchor;\n}\nexport interface TableProps extends Bounds, Children {\n rows: readonly (readonly string[])[];\n columnWidths?: readonly number[];\n rowHeights?: readonly number[];\n cellStyle?: CellStyle;\n headerStyle?: CellStyle;\n stripeFill?: string;\n}\nexport function Table(props: TableProps): Node {\n return node('Table', async (context) => {\n const shape = api.addSlideTable(requireSlide(context), {\n ...bounds(props),\n rows: props.rows,\n ...(props.columnWidths ? { colWidths: props.columnWidths.map(api.inches) } : {}),\n ...(props.rowHeights ? { rowHeights: props.rowHeights.map(api.inches) } : {}),\n });\n props.rows.forEach((row, r) =>\n row.forEach((_, c) => {\n const cell = api.getTableCell(shape, r, c);\n const appearance = {\n ...props.cellStyle,\n ...(r === 0 ? props.headerStyle : {}),\n format: { ...props.cellStyle?.format, ...(r === 0 ? props.headerStyle?.format : {}) },\n };\n if (appearance.fill) api.setTableCellFill(cell, appearance.fill);\n if (r > 0 && r % 2 === 0 && props.stripeFill) api.setTableCellFill(cell, props.stripeFill);\n if (appearance.format) api.setTableCellTextFormat(cell, appearance.format);\n if (appearance.anchor) api.setTableCellAnchor(cell, appearance.anchor);\n }),\n );\n await visit(props.children, { ...context, shape, scope: 'shape' });\n });\n}\nfunction selectShape(slide: api.SlideData, target: Target): api.SlideShapeData {\n const matches = api.getSlideShapes(slide).filter((shape) => {\n if ('name' in target) return api.getShapeName(shape) === target.name;\n if ('id' in target) return api.getShapeId(shape) === target.id;\n const ph = target.placeholder;\n return (\n (ph.type !== undefined || ph.idx !== undefined) &&\n (ph.type === undefined || api.getShapePlaceholderType(shape) === ph.type) &&\n (ph.idx === undefined || api.getShapePlaceholderIdx(shape) === ph.idx)\n );\n });\n if (matches.length !== 1)\n throw new Error(`Shape reference matched ${matches.length} shapes: ${JSON.stringify(target)}`);\n return matches[0]!;\n}\nexport interface FillProps extends Children {\n target: Target;\n text?: string;\n format?: api.TextFormat;\n}\nexport function Fill(props: FillProps): Node {\n return node('Fill', (context) => {\n const shape = selectShape(requireSlide(context), props.target);\n api.setShapeText(shape, props.text ?? literal(props.children));\n if (props.format) api.setShapeTextFormat(shape, props.format);\n });\n}\nexport function Remove(props: { target: Target }): Node {\n return node('Remove', (context) => {\n const slide = requireSlide(context);\n api.removeShape(selectShape(slide, props.target));\n });\n}\n"],"mappings":";;;AAyBA,SAAgB,aAAa,OAA4C;CACvE,OAAO;EACL,MAAM;EACN,gBAAgB;GACd,MAAM,IAAI,MAAM,gCAAgC;EAClD;EACA,MAAM,UAAU;GACd,IAAI,MAAM,WAAW,KAAA,KAAa,MAAM,SAAS,KAAA,GAC/C,MAAM,IAAI,MAAM,qEAAqE;GACvF,MAAM,eACJ,MAAM,WAAW,KAAA,IACb,IAAI,mBAAmB,MAAM,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,MAAM,KAAK,CAAC,IAC3E,MAAM,IAAI,iBAAiB,MAAM,MAAM;GAC7C,IAAI,MAAM,OAAO,IAAI,qBAAqB,cAAc,MAAM,KAAK;GACnE,MAAM,YAAY,CAAC,GAAG,IAAI,UAAU,YAAY,CAAC;GACjD,MAAM,UAAmB;IACvB;IACA;IACA,MAAM,MAAM,SAAS,MAAM,WAAW,KAAA,IAAY,YAAY;IAC9D,OAAO;IACP,UAAU,CAAC;GACb;GACA,MAAM,MAAM,MAAM,UAAU,OAAO;GACnC,KAAK,MAAM,SAAS,QAAQ,UAAU,MAAM,MAAM;GAClD,IAAI,QAAQ,SAAS,WACnB,KAAK,MAAM,SAAS,WAAW,IAAI,YAAY,cAAc,KAAK;GAEpE,OAAO;EACT;CACF;AACF;AACA,eAAsB,QAAQ,MAA2C;CACvE,IAAI,EAAE,aAAa,SAAS,OAA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a,KAAK,MAAM,OAAO;EAChE,IAAI,QAAQ,QAAQ,OAAO,IAAI,WAAW,KAAK,MAAM,OAAO;EAC5D,MAAM,KAAK,OAAO;EAClB,QACG,GAAG,SAAS,KAAA,KAAa,GAAG,QAAQ,KAAA,OACpC,GAAG,SAAS,KAAA,KAAa,IAAI,wBAAwB,KAAK,MAAM,GAAG,UACnE,GAAG,QAAQ,KAAA,KAAa,IAAI,uBAAuB,KAAK,MAAM,GAAG;CAEtE,CAAC;CACD,IAAI,QAAQ,WAAW,GACrB,MAAM,IAAI,MAAM,2BAA2B,QAAQ,OAAO,WAAW,KAAK,UAAU,MAAM,GAAG;CAC/F,OAAO,QAAQ;AACjB;AAMA,SAAgB,KAAK,OAAwB;CAC3C,OAAO,KAAK,SAAS,YAAY;EAC/B,MAAM,QAAQ,YAAY,aAAa,OAAO,GAAG,MAAM,MAAM;EAC7D,IAAI,aAAa,OAAO,MAAM,QAAQ,QAAQ,MAAM,QAAQ,CAAC;EAC7D,IAAI,MAAM,QAAQ,IAAI,mBAAmB,OAAO,MAAM,MAAM;CAC9D,CAAC;AACH;AACA,SAAgB,OAAO,OAAiC;CACtD,OAAO,KAAK,WAAW,YAAY;EACjC,MAAM,QAAQ,aAAa,OAAO;EAClC,IAAI,YAAY,YAAY,OAAO,MAAM,MAAM,CAAC;CAClD,CAAC;AACH"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
//#region src/model.ts
|
|
2
|
+
function node(kind, evaluate) {
|
|
3
|
+
return {
|
|
4
|
+
kind,
|
|
5
|
+
evaluate
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
async function visit(children, context) {
|
|
9
|
+
if (children == null || typeof children === "boolean") return;
|
|
10
|
+
if (typeof children === "string" || typeof children === "number") {
|
|
11
|
+
if (String(children).trim()) throw new Error("Text content must be inside Text or Fill.");
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if ("evaluate" in children) try {
|
|
15
|
+
await children.evaluate(context);
|
|
16
|
+
} catch (cause) {
|
|
17
|
+
if (!children.source) throw cause;
|
|
18
|
+
const { fileName, lineNumber, columnNumber } = children.source;
|
|
19
|
+
throw new Error(`${fileName}:${lineNumber}:${columnNumber} <${children.kind}>: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
|
|
20
|
+
}
|
|
21
|
+
else for (const child of children) await visit(child, context);
|
|
22
|
+
}
|
|
23
|
+
function requireSlide(context) {
|
|
24
|
+
if (!context.slide || context.scope !== "slide") throw new Error("This element must be a child of Slide.");
|
|
25
|
+
return context.slide;
|
|
26
|
+
}
|
|
27
|
+
function literal(children) {
|
|
28
|
+
if (children == null || typeof children === "boolean") return "";
|
|
29
|
+
if (typeof children === "string" || typeof children === "number") return String(children);
|
|
30
|
+
if ("evaluate" in children) throw new Error("Use paragraphs for rich text; element children are not text.");
|
|
31
|
+
return children.map(literal).join("");
|
|
32
|
+
}
|
|
33
|
+
/** Separate inline text from shape-scoped escape hatches without evaluating them. */
|
|
34
|
+
function textContent(children) {
|
|
35
|
+
const elements = [];
|
|
36
|
+
function collect(child) {
|
|
37
|
+
if (child == null || typeof child === "boolean") return "";
|
|
38
|
+
if (typeof child === "string" || typeof child === "number") return String(child);
|
|
39
|
+
if ("evaluate" in child) {
|
|
40
|
+
elements.push(child);
|
|
41
|
+
return "";
|
|
42
|
+
}
|
|
43
|
+
return child.map(collect).join("");
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
text: collect(children),
|
|
47
|
+
elements
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/jsx-runtime.ts
|
|
52
|
+
function jsx(component, props, _key) {
|
|
53
|
+
if (typeof component !== "function") throw new Error("Use imported PPTX components, not HTML tags.");
|
|
54
|
+
return component(props);
|
|
55
|
+
}
|
|
56
|
+
const jsxs = jsx;
|
|
57
|
+
function jsxDEV(component, props, key, _isStaticChildren, source) {
|
|
58
|
+
const result = jsx(component, props, key);
|
|
59
|
+
return source ? {
|
|
60
|
+
...result,
|
|
61
|
+
source
|
|
62
|
+
} : result;
|
|
63
|
+
}
|
|
64
|
+
function Fragment({ children }) {
|
|
65
|
+
return node("Fragment", (context) => visit(children, context));
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
export { literal as a, textContent as c, jsxs as i, visit as l, jsx as n, node as o, jsxDEV as r, requireSlide as s, Fragment as t };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=jsx-runtime-BgfNl42k.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-runtime-BgfNl42k.js","names":[],"sources":["../src/model.ts","../src/jsx-runtime.ts"],"sourcesContent":["import type * as api from '@office-kit/pptx';\n\nexport type Child = Node | string | number | boolean | null | undefined | readonly Child[];\nexport interface Children {\n children?: Child;\n}\nexport interface RawContext {\n presentation: api.PresentationData;\n slide?: api.SlideData;\n shape?: api.SlideShapeData;\n}\nexport interface Context extends RawContext {\n mode: 'compose' | 'edit';\n scope: 'presentation' | 'slide' | 'shape';\n originals: readonly api.SlideData[];\n deferred: Array<() => void | Promise<void>>;\n}\nexport interface Node {\n readonly kind: string;\n readonly source?: { fileName: string; lineNumber: number; columnNumber: number };\n readonly evaluate: (context: Context) => void | Promise<void>;\n}\nexport interface PresentationNode extends Node {\n readonly compile: () => Promise<api.PresentationData>;\n}\nexport function node(kind: string, evaluate: Node['evaluate']): Node {\n return { kind, evaluate };\n}\nexport async function visit(children: Child, context: Context): Promise<void> {\n if (children == null || typeof children === 'boolean') return;\n if (typeof children === 'string' || typeof children === 'number') {\n if (String(children).trim()) throw new Error('Text content must be inside Text or Fill.');\n return;\n }\n if ('evaluate' in children) {\n try {\n await children.evaluate(context);\n } catch (cause) {\n if (!children.source) throw cause;\n const { fileName, lineNumber, columnNumber } = children.source;\n throw new Error(\n `${fileName}:${lineNumber}:${columnNumber} <${children.kind}>: ${cause instanceof Error ? cause.message : String(cause)}`,\n { cause },\n );\n }\n } else {\n for (const child of children) await visit(child, context);\n }\n}\nexport function requireSlide(context: Context): api.SlideData {\n if (!context.slide || context.scope !== 'slide')\n throw new Error('This element must be a child of Slide.');\n return context.slide;\n}\nexport function literal(children: Child): string {\n if (children == null || typeof children === 'boolean') return '';\n if (typeof children === 'string' || typeof children === 'number') return String(children);\n if ('evaluate' in children)\n throw new Error('Use paragraphs for rich text; element children are not text.');\n return children.map(literal).join('');\n}\n\n/** Separate inline text from shape-scoped escape hatches without evaluating them. */\nexport function textContent(children: Child): { text: string; elements: Node[] } {\n const elements: Node[] = [];\n function collect(child: Child): string {\n if (child == null || typeof child === 'boolean') return '';\n if (typeof child === 'string' || typeof child === 'number') return String(child);\n if ('evaluate' in child) {\n elements.push(child);\n return '';\n }\n return child.map(collect).join('');\n }\n return { text: collect(children), elements };\n}\n","import { node, visit, type Child, type Children, type Node } from './model.ts';\n\nexport function jsx<P>(component: (props: P) => Node, props: P, _key?: string | number): Node {\n if (typeof component !== 'function')\n throw new Error('Use imported PPTX components, not HTML tags.');\n return component(props);\n}\nexport const jsxs = jsx;\nexport function jsxDEV<P>(\n component: (props: P) => Node,\n props: P,\n key?: string | number,\n _isStaticChildren?: boolean,\n source?: Node['source'],\n): Node {\n const result = jsx(component, props, key);\n return source ? { ...result, source } : result;\n}\nexport function Fragment({ children }: Children): Node {\n return node('Fragment', (context) => visit(children, context));\n}\nexport namespace JSX {\n export type Element = Node;\n export interface ElementChildrenAttribute {\n children: Child;\n }\n export interface IntrinsicAttributes {\n key?: string | number;\n }\n}\n"],"mappings":";AAyBA,SAAgB,KAAK,MAAc,UAAkC;CACnE,OAAO;EAAE;EAAM;CAAS;AAC1B;AACA,eAAsB,MAAM,UAAiB,SAAiC;CAC5E,IAAI,YAAY,QAAQ,OAAO,aAAa,WAAW;CACvD,IAAI,OAAO,aAAa,YAAY,OAAO,aAAa,UAAU;EAChE,IAAI,OAAO,QAAQ,CAAC,CAAC,KAAK,GAAG,MAAM,IAAI,MAAM,2CAA2C;EACxF;CACF;C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C;CAChE,OAAO,UAAU,KAAK;AACxB;AACA,MAAa,OAAO;AACpB,SAAgB,OACd,WACA,OACA,KACA,mBACA,QACM;CACN,MAAM,SAAS,IAAI,WAAW,OAAO,GAAG;CACxC,OAAO,SAAS;EAAE,GAAG;EAAQ;CAAO,IAAI;AAC1C;AACA,SAAgB,SAAS,EAAE,YAA4B;CACrD,OAAO,KAAK,aAAa,YAAY,MAAM,UAAU,OAAO,CAAC;AAC/D"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as api from "@office-kit/pptx";
|
|
2
|
+
|
|
3
|
+
//#region src/model.d.ts
|
|
4
|
+
type Child = Node | string | number | boolean | null | undefined | readonly Child[];
|
|
5
|
+
interface Children {
|
|
6
|
+
children?: Child;
|
|
7
|
+
}
|
|
8
|
+
interface RawContext {
|
|
9
|
+
presentation: api.PresentationData;
|
|
10
|
+
slide?: api.SlideData;
|
|
11
|
+
shape?: api.SlideShapeData;
|
|
12
|
+
}
|
|
13
|
+
interface Context extends RawContext {
|
|
14
|
+
mode: 'compose' | 'edit';
|
|
15
|
+
scope: 'presentation' | 'slide' | 'shape';
|
|
16
|
+
originals: readonly api.SlideData[];
|
|
17
|
+
deferred: Array<() => void | Promise<void>>;
|
|
18
|
+
}
|
|
19
|
+
interface Node {
|
|
20
|
+
readonly kind: string;
|
|
21
|
+
readonly source?: {
|
|
22
|
+
fileName: string;
|
|
23
|
+
lineNumber: number;
|
|
24
|
+
columnNumber: number;
|
|
25
|
+
};
|
|
26
|
+
readonly evaluate: (context: Context) => void | Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
interface PresentationNode extends Node {
|
|
29
|
+
readonly compile: () => Promise<api.PresentationData>;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/jsx-runtime.d.ts
|
|
33
|
+
declare function jsx<P>(component: (props: P) => Node, props: P, _key?: string | number): Node;
|
|
34
|
+
declare const jsxs: typeof jsx;
|
|
35
|
+
declare function jsxDEV<P>(component: (props: P) => Node, props: P, key?: string | number, _isStaticChildren?: boolean, source?: Node['source']): Node;
|
|
36
|
+
declare function Fragment({
|
|
37
|
+
children
|
|
38
|
+
}: Children): Node;
|
|
39
|
+
declare namespace JSX {
|
|
40
|
+
type Element = Node;
|
|
41
|
+
interface ElementChildrenAttribute {
|
|
42
|
+
children: Child;
|
|
43
|
+
}
|
|
44
|
+
interface IntrinsicAttributes {
|
|
45
|
+
key?: string | number;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { jsxs as a, Node as c, jsxDEV as i, PresentationNode as l, JSX as n, Child as o, jsx as r, Children as s, Fragment as t, RawContext as u };
|
|
50
|
+
//# sourceMappingURL=jsx-runtime-C-Ggfem1.d.ts.map
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@office-kit/pptx-dsl",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Typed TSX authoring for editable PowerPoint presentations",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/office-kit/pptx.git",
|
|
9
|
+
"directory": "packages/dsl"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"type": "module",
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./jsx-runtime": {
|
|
23
|
+
"types": "./dist/jsx-runtime.d.ts",
|
|
24
|
+
"import": "./dist/jsx-runtime.js"
|
|
25
|
+
},
|
|
26
|
+
"./jsx-dev-runtime": {
|
|
27
|
+
"types": "./dist/jsx-runtime.d.ts",
|
|
28
|
+
"import": "./dist/jsx-runtime.js"
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public",
|
|
34
|
+
"provenance": true
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"tsdown": "^0.22.2",
|
|
38
|
+
"typescript": "^6.0.3",
|
|
39
|
+
"@office-kit/pptx": "0.16.1"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@office-kit/pptx": ">=0.16.1"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=22.18.0"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsdown",
|
|
49
|
+
"typecheck": "tsc --noEmit"
|
|
50
|
+
}
|
|
51
|
+
}
|