deckjsx 0.7.0 → 0.8.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,28 @@
1
+ import { closeSync, mkdirSync, openSync, writeSync } from "node:fs";
2
+ import { mkdir, writeFile } from "node:fs/promises";
3
+ import { dirname } from "node:path";
4
+ //#region src/runtime/node-output.ts
5
+ function createNodeOutputByteSink(input) {
6
+ mkdirSync(dirname(input.output), { recursive: true });
7
+ const fd = openSync(input.output, "w");
8
+ let closed = false;
9
+ return {
10
+ name: "node-file-output",
11
+ write(chunk) {
12
+ if (closed) throw new Error("Cannot write output bytes after the file sink is closed.");
13
+ writeSync(fd, chunk, 0, chunk.byteLength);
14
+ },
15
+ close() {
16
+ if (closed) return;
17
+ closed = true;
18
+ closeSync(fd);
19
+ }
20
+ };
21
+ }
22
+ async function writeNodeOutput(input) {
23
+ await mkdir(dirname(input.output), { recursive: true });
24
+ await writeFile(input.output, input.artifact.bytes);
25
+ return { path: input.output };
26
+ }
27
+ //#endregion
28
+ export { createNodeOutputByteSink, writeNodeOutput };
@@ -0,0 +1,36 @@
1
+ import { $ as Diagnostics, M as GraphNodeId, an as StyleDeclarationValue, in as StyleDeclaration } from "./index-BlOsGMTm.mjs";
2
+
3
+ //#region src/style/resolve.d.ts
4
+ type ResolvedStyleDeclaration = StyleDeclaration;
5
+ type ResolvedStyleValue = StyleDeclarationValue;
6
+ type ResolvedStyleLayer = "default" | "theme" | "class" | "style";
7
+ type ResolvedStyleSource = {
8
+ readonly layer: "default";
9
+ } | {
10
+ readonly layer: "theme";
11
+ readonly defaultKey: string;
12
+ } | {
13
+ readonly layer: "class";
14
+ readonly className: string;
15
+ readonly stylesheetIndex: number;
16
+ readonly ruleIndex: number;
17
+ readonly selector: string;
18
+ } | {
19
+ readonly layer: "style";
20
+ };
21
+ type ResolvedStyleProperty = {
22
+ readonly value: ResolvedStyleValue | undefined;
23
+ readonly source: ResolvedStyleSource;
24
+ };
25
+ type ResolvedStyle = {
26
+ readonly style: Readonly<ResolvedStyleDeclaration>;
27
+ readonly properties: Readonly<Record<string, ResolvedStyleProperty>>;
28
+ readonly appliedClasses: readonly ResolvedStyleSource[];
29
+ };
30
+ type ResolvedStyleMap = ReadonlyMap<GraphNodeId, ResolvedStyle>;
31
+ type StyleResolutionResult = {
32
+ readonly resolvedStyles: ResolvedStyleMap;
33
+ readonly diagnostics: Diagnostics;
34
+ };
35
+ //#endregion
36
+ export { ResolvedStyleSource as a, ResolvedStyleProperty as i, ResolvedStyleLayer as n, StyleResolutionResult as o, ResolvedStyleMap as r, ResolvedStyle as t };
@@ -0,0 +1,156 @@
1
+ //#region src/authoring/tags.ts
2
+ const INTRINSIC_VIEW_TAGS = new Set([
3
+ "article",
4
+ "aside",
5
+ "div",
6
+ "figure",
7
+ "footer",
8
+ "header",
9
+ "main",
10
+ "nav",
11
+ "section"
12
+ ]);
13
+ const INTRINSIC_TEXT_TAGS = new Set([
14
+ "h1",
15
+ "h2",
16
+ "h3",
17
+ "h4",
18
+ "h5",
19
+ "h6",
20
+ "p"
21
+ ]);
22
+ function isIntrinsicViewTag(value) {
23
+ return INTRINSIC_VIEW_TAGS.has(value);
24
+ }
25
+ function isIntrinsicTextTag(value) {
26
+ return INTRINSIC_TEXT_TAGS.has(value);
27
+ }
28
+ function isAuthoredTag(value) {
29
+ return isIntrinsicViewTag(value) || isIntrinsicTextTag(value) || value === "img" || value === "shape" || value === "span";
30
+ }
31
+ //#endregion
32
+ //#region src/authoring/tree.ts
33
+ function isRecord(value) {
34
+ return typeof value === "object" && value !== null;
35
+ }
36
+ function isAuthorElementPropValue(value) {
37
+ if (value === null || value === void 0 || typeof value === "string" || typeof value === "number" || typeof value === "boolean") return true;
38
+ if (Array.isArray(value)) return value.every(isAuthorElementPropValue);
39
+ if (typeof value !== "object" || isAuthorTreeNode(value)) return false;
40
+ return Object.values(value).every(isAuthorElementPropValue);
41
+ }
42
+ function authorElementPropsFromEntries(entries) {
43
+ const props = {};
44
+ for (const [key, value] of entries) {
45
+ if (!isAuthorElementPropValue(value)) throw new Error(`JSX prop "${key}" must be serializable authoring data.`);
46
+ props[key] = value;
47
+ }
48
+ return props;
49
+ }
50
+ function createAuthorText(value, sourceSpan) {
51
+ return {
52
+ $$typeof: "deckjsx.author-tree",
53
+ kind: "text",
54
+ value,
55
+ ...sourceSpan ? { sourceSpan } : {}
56
+ };
57
+ }
58
+ function buildAuthorElement(input) {
59
+ return {
60
+ $$typeof: "deckjsx.author-tree",
61
+ kind: "element",
62
+ source: input.source,
63
+ ...input.key !== void 0 ? { key: input.key } : {},
64
+ props: input.props,
65
+ children: normalizeAuthorChildren(input.children ?? []),
66
+ ...input.sourceSpan ? { sourceSpan: input.sourceSpan } : {}
67
+ };
68
+ }
69
+ function isSlideElementInput(input) {
70
+ return input.source.kind === "slide";
71
+ }
72
+ function isViewElementInput(input) {
73
+ return input.source.kind === "tag" && isIntrinsicViewTag(input.source.tag);
74
+ }
75
+ function isTextElementInput(input) {
76
+ return input.source.kind === "tag" && isIntrinsicTextTag(input.source.tag);
77
+ }
78
+ function isSpanElementInput(input) {
79
+ return input.source.kind === "tag" && input.source.tag === "span";
80
+ }
81
+ function isImageElementInput(input) {
82
+ return input.source.kind === "tag" && input.source.tag === "img";
83
+ }
84
+ function isShapeElementInput(input) {
85
+ return input.source.kind === "tag" && input.source.tag === "shape";
86
+ }
87
+ function createAuthorElement(input) {
88
+ if (isSlideElementInput(input)) return buildAuthorElement({
89
+ ...input,
90
+ source: input.source,
91
+ props: input.props ?? {}
92
+ });
93
+ if (isViewElementInput(input)) return buildAuthorElement({
94
+ ...input,
95
+ source: input.source,
96
+ props: input.props ?? {}
97
+ });
98
+ if (isTextElementInput(input)) return buildAuthorElement({
99
+ ...input,
100
+ source: input.source,
101
+ props: input.props ?? {}
102
+ });
103
+ if (isSpanElementInput(input)) return buildAuthorElement({
104
+ ...input,
105
+ source: input.source,
106
+ props: input.props ?? {}
107
+ });
108
+ if (isImageElementInput(input)) return buildAuthorElement({
109
+ ...input,
110
+ source: input.source,
111
+ props: input.props
112
+ });
113
+ if (isShapeElementInput(input)) return buildAuthorElement({
114
+ ...input,
115
+ source: input.source,
116
+ props: input.props
117
+ });
118
+ throw new Error("Unsupported author element source.");
119
+ }
120
+ function createAuthorFragment(input) {
121
+ return {
122
+ $$typeof: "deckjsx.author-tree",
123
+ kind: "fragment",
124
+ ...input.key !== void 0 ? { key: input.key } : {},
125
+ children: normalizeAuthorChildren(input.children ?? []),
126
+ ...input.sourceSpan ? { sourceSpan: input.sourceSpan } : {}
127
+ };
128
+ }
129
+ function isAuthorTreeNode(value) {
130
+ return isRecord(value) && value.$$typeof === "deckjsx.author-tree";
131
+ }
132
+ function isAuthorTreeChild(value) {
133
+ return value === null || value === void 0 || typeof value === "boolean" || typeof value === "string" || typeof value === "number" || isAuthorTreeNode(value) || Array.isArray(value) && value.every(isAuthorTreeChild);
134
+ }
135
+ function authorTreeChildrenFromUnknown(children) {
136
+ return children.map((child) => {
137
+ if (!isAuthorTreeChild(child)) throw new Error("JSX children must be deckjsx author tree nodes or primitive text values.");
138
+ return child;
139
+ });
140
+ }
141
+ function normalizeAuthorChildren(children) {
142
+ return children.flatMap((child) => {
143
+ if (child === null || child === void 0 || typeof child === "boolean") return [];
144
+ if (typeof child === "string" || typeof child === "number") return [createAuthorText(child)];
145
+ if (Array.isArray(child)) return normalizeAuthorChildren(child);
146
+ if (isAuthorTreeNode(child)) return [child];
147
+ throw new Error("JSX children must be deckjsx author tree nodes or primitive text values.");
148
+ });
149
+ }
150
+ function collectChildren(propsObject, children) {
151
+ if (children.length === 0) return propsObject.children;
152
+ if (children.length === 1) return children[0];
153
+ return children;
154
+ }
155
+ //#endregion
156
+ export { createAuthorFragment as a, isAuthoredTag as c, createAuthorElement as i, isIntrinsicTextTag as l, authorTreeChildrenFromUnknown as n, isAuthorTreeChild as o, collectChildren as r, isAuthorTreeNode as s, authorElementPropsFromEntries as t, isIntrinsicViewTag as u };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "deckjsx",
3
- "version": "0.7.0",
3
+ "version": "0.8.1",
4
4
  "description": "Generate PowerPoint presentations from TSX/JSX through a compiler pipeline.",
5
5
  "license": "MIT",
6
6
  "author": "deckjsx contributors",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "https://github.com/chikina-dev/deckjsx"
9
+ "url": "git+https://github.com/chikina-dev/deckjsx.git"
10
10
  },
11
11
  "files": [
12
12
  "dist"
@@ -29,16 +29,16 @@
29
29
  "dev": "vp pack --watch",
30
30
  "test": "vp test",
31
31
  "check": "vp check",
32
- "verify:render": "bun run scripts/verify-render.ts",
32
+ "benchmark:pptx": "bun run scripts/benchmark-pptx-writer.tsx",
33
+ "verify:render": "bun run .github/render/verify-render.tsx",
33
34
  "prepublishOnly": "vp run build"
34
35
  },
35
- "dependencies": {
36
- "pptxgenjs": "^4.0.1"
37
- },
36
+ "dependencies": {},
38
37
  "devDependencies": {
39
38
  "@types/node": "^25.5.0",
40
39
  "@typescript/native-preview": "7.0.0-dev.20260328.1",
41
40
  "bumpp": "^11.0.1",
41
+ "fflate": "^0.8.3",
42
42
  "typescript": "^6.0.2",
43
43
  "vite-plus": "^0.1.14"
44
44
  },
@@ -46,22 +46,5 @@
46
46
  "vite": "npm:@voidzero-dev/vite-plus-core@latest",
47
47
  "vitest": "npm:@voidzero-dev/vite-plus-test@latest"
48
48
  },
49
- "packageManager": "bun@1.3.13",
50
- "inlinedDependencies": {
51
- "core-util-is": "1.0.3",
52
- "image-size": "1.2.1",
53
- "immediate": "3.0.6",
54
- "inherits": "2.0.4",
55
- "isarray": "1.0.0",
56
- "jszip": "3.10.1",
57
- "lie": "3.3.0",
58
- "pako": "1.0.11",
59
- "process-nextick-args": "2.0.1",
60
- "queue": "6.0.2",
61
- "readable-stream": "2.3.8",
62
- "safe-buffer": "5.1.2",
63
- "setimmediate": "1.0.5",
64
- "string_decoder": "1.1.1",
65
- "util-deprecate": "1.0.2"
66
- }
49
+ "packageManager": "bun@1.3.13"
67
50
  }
@@ -1,22 +0,0 @@
1
- import { rn as Diagnostics } from "./index-C-LDA3Lj.mjs";
2
- import { F as OutputFormat, L as ProjectionFormat, s as PptxPackageModel, z as RenderedArtifact } from "./pptx-DaSXvESd.mjs";
3
-
4
- //#region src/adapter.d.ts
5
- type RenderOptions = {
6
- readonly output?: string;
7
- };
8
- type WriterAdapterResult<TFormat extends OutputFormat = OutputFormat> = {
9
- readonly diagnostics: Diagnostics;
10
- readonly artifact?: RenderedArtifact<TFormat>;
11
- };
12
- type WriterAdapter<TProjection = unknown, TFormat extends OutputFormat = OutputFormat> = {
13
- readonly kind: "deckjsx.writerAdapter";
14
- readonly name: string;
15
- readonly projectionFormat: ProjectionFormat;
16
- readonly format: TFormat;
17
- readonly options: RenderOptions;
18
- render(projection: TProjection): Promise<WriterAdapterResult<TFormat>>;
19
- };
20
- declare function pptxgenjs(options?: RenderOptions): WriterAdapter<PptxPackageModel, "pptx">;
21
- //#endregion
22
- export { pptxgenjs as i, WriterAdapter as n, WriterAdapterResult as r, RenderOptions as t };