@officedk/pptxdk 0.0.0-stage → 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/dist/build-zrZuX4fK.d.ts +3 -0
- package/dist/build.d.ts +35 -0
- package/dist/build.js +128 -0
- package/dist/capabilities/dist/all.js +34 -0
- package/dist/capabilities/dist/box/box-codegen.js +84 -0
- package/dist/capabilities/dist/box/box-declaration.js +32 -0
- package/dist/capabilities/dist/box/box-elements.js +17 -0
- package/dist/capabilities/dist/box/box.js +142 -0
- package/dist/capabilities/dist/chart/chart-codegen.js +79 -0
- package/dist/capabilities/dist/chart/chart-declaration.js +7 -0
- package/dist/capabilities/dist/chart/chart-elements.js +12 -0
- package/dist/capabilities/dist/chart/chart-import.js +2403 -0
- package/dist/capabilities/dist/chart/chart-labels.js +86 -0
- package/dist/capabilities/dist/chart/chart-model.js +9 -0
- package/dist/capabilities/dist/chart/chart-schemas.js +1088 -0
- package/dist/capabilities/dist/chart/chart-xml.js +788 -0
- package/dist/capabilities/dist/chart/chart.js +1119 -0
- package/dist/capabilities/dist/chart/preview/axes-and-grid.js +311 -0
- package/dist/capabilities/dist/chart/preview/bar-column.js +143 -0
- package/dist/capabilities/dist/chart/preview/data-labels.js +334 -0
- package/dist/capabilities/dist/chart/preview/error-bars.js +213 -0
- package/dist/capabilities/dist/chart/preview/index.js +192 -0
- package/dist/capabilities/dist/chart/preview/layout.js +592 -0
- package/dist/capabilities/dist/chart/preview/legend.js +273 -0
- package/dist/capabilities/dist/chart/preview/line-area.js +404 -0
- package/dist/capabilities/dist/chart/preview/markers.js +100 -0
- package/dist/capabilities/dist/chart/preview/number-format.js +247 -0
- package/dist/capabilities/dist/chart/preview/pie-doughnut.js +159 -0
- package/dist/capabilities/dist/chart/preview/scales.js +365 -0
- package/dist/capabilities/dist/chart/preview/scatter.js +131 -0
- package/dist/capabilities/dist/chart/preview/style.js +60 -0
- package/dist/capabilities/dist/chart/preview/text-render.js +116 -0
- package/dist/capabilities/dist/chart/preview/trendlines.js +537 -0
- package/dist/capabilities/dist/chart/preview/types.js +5 -0
- package/dist/capabilities/dist/document.js +168 -0
- package/dist/capabilities/dist/font/font-embedding.js +119 -0
- package/dist/capabilities/dist/font/font-engine.js +834 -0
- package/dist/capabilities/dist/font/font-import.js +766 -0
- package/dist/capabilities/dist/font/font-subset.js +55 -0
- package/dist/capabilities/dist/font/font.js +72 -0
- package/dist/capabilities/dist/group/group-codegen.js +74 -0
- package/dist/capabilities/dist/group/group-declaration.js +41 -0
- package/dist/capabilities/dist/group/group-elements.js +12 -0
- package/dist/capabilities/dist/group/group-import.js +649 -0
- package/dist/capabilities/dist/group/group-xml.js +8 -0
- package/dist/capabilities/dist/group/group.js +260 -0
- package/dist/capabilities/dist/image/gif-decoder.js +244 -0
- package/dist/capabilities/dist/image/image-codegen.js +164 -0
- package/dist/capabilities/dist/image/image-declaration.js +8 -0
- package/dist/capabilities/dist/image/image-decode.js +244 -0
- package/dist/capabilities/dist/image/image-elements.js +12 -0
- package/dist/capabilities/dist/image/image-import.js +984 -0
- package/dist/capabilities/dist/image/image-schemas.js +147 -0
- package/dist/capabilities/dist/image/image-xml.js +12 -0
- package/dist/capabilities/dist/image/image.js +552 -0
- package/dist/capabilities/dist/line/line-codegen.js +89 -0
- package/dist/capabilities/dist/line/line-declaration.js +72 -0
- package/dist/capabilities/dist/line/line-elements.js +12 -0
- package/dist/capabilities/dist/line/line-import.js +504 -0
- package/dist/capabilities/dist/line/line-xml.js +9 -0
- package/dist/capabilities/dist/line/line.js +331 -0
- package/dist/capabilities/dist/masters/footer-placeholder.js +683 -0
- package/dist/capabilities/dist/masters/masters-codegen.js +69 -0
- package/dist/capabilities/dist/masters/masters.js +250 -0
- package/dist/capabilities/dist/motion/motion-api.js +757 -0
- package/dist/capabilities/dist/motion/motion-codegen.js +406 -0
- package/dist/capabilities/dist/motion/motion-elements.js +43 -0
- package/dist/capabilities/dist/motion/motion-import.js +1568 -0
- package/dist/capabilities/dist/motion/motion-plan.js +2340 -0
- package/dist/capabilities/dist/motion/motion-query.js +423 -0
- package/dist/capabilities/dist/motion/motion-schemas.js +339 -0
- package/dist/capabilities/dist/motion/motion.js +1617 -0
- package/dist/capabilities/dist/notes/notes-codegen.js +19 -0
- package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
- package/dist/capabilities/dist/notes/notes-elements.js +12 -0
- package/dist/capabilities/dist/notes/notes-import.js +292 -0
- package/dist/capabilities/dist/notes/notes-schemas.js +38 -0
- package/dist/capabilities/dist/notes/notes-xml.js +38 -0
- package/dist/capabilities/dist/notes/notes.js +194 -0
- package/dist/capabilities/dist/placeholder/placeholder-codegen.js +54 -0
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +13 -0
- package/dist/capabilities/dist/placeholder/placeholder-schemas.js +33 -0
- package/dist/capabilities/dist/placeholder/placeholder.js +451 -0
- package/dist/capabilities/dist/shape/shape-codegen.js +236 -0
- package/dist/capabilities/dist/shape/shape-declaration.js +45 -0
- package/dist/capabilities/dist/shape/shape-elements.js +12 -0
- package/dist/capabilities/dist/shape/shape-import.js +628 -0
- package/dist/capabilities/dist/shape/shape-xml.js +6 -0
- package/dist/capabilities/dist/shape/shape.js +320 -0
- package/dist/capabilities/dist/shared/geometry.js +1681 -0
- package/dist/capabilities/dist/shared/identity.js +205 -0
- package/dist/capabilities/dist/shared/morph-api.js +11 -0
- package/dist/capabilities/dist/shared/placeholder-import.js +238 -0
- package/dist/capabilities/dist/shared/preset-definitions.js +22423 -0
- package/dist/capabilities/dist/shared/style-inheritance.js +161 -0
- package/dist/capabilities/dist/shared/text-schemas.js +241 -0
- package/dist/capabilities/dist/shared/text-service.js +2252 -0
- package/dist/capabilities/dist/shared/visual.js +1197 -0
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
- package/dist/capabilities/dist/slide-background/slide-background-import.js +166 -0
- package/dist/capabilities/dist/slide-background/slide-background-xml.js +34 -0
- package/dist/capabilities/dist/slide-background/slide-background.js +238 -0
- package/dist/capabilities/dist/table/table-codegen.js +125 -0
- package/dist/capabilities/dist/table/table-declaration.js +15 -0
- package/dist/capabilities/dist/table/table-elements.js +27 -0
- package/dist/capabilities/dist/table/table-import.js +606 -0
- package/dist/capabilities/dist/table/table-schemas.js +334 -0
- package/dist/capabilities/dist/table/table-xml.js +30 -0
- package/dist/capabilities/dist/table/table.js +739 -0
- package/dist/capabilities/dist/text/text-codegen.js +198 -0
- package/dist/capabilities/dist/text/text-declaration.js +27 -0
- package/dist/capabilities/dist/text/text-elements.js +54 -0
- package/dist/capabilities/dist/text/text-import.js +1224 -0
- package/dist/capabilities/dist/text/text-xml.js +9 -0
- package/dist/capabilities/dist/text/text.js +320 -0
- package/dist/capabilities/dist/transition/transition-api.js +136 -0
- package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
- package/dist/capabilities/dist/transition/transition-import.js +477 -0
- package/dist/capabilities/dist/transition/transition.js +260 -0
- package/dist/capability-BbKW9w4O.d.ts +2131 -0
- package/dist/cli.js +20 -0
- package/dist/codegen/dist/assets.js +79 -0
- package/dist/codegen/dist/codegen.js +691 -0
- package/dist/codegen/dist/identifiers.js +203 -0
- package/dist/codegen/dist/index.js +3 -0
- package/dist/codegen/dist/printer.js +143 -0
- package/dist/codegen/dist/types.js +77 -0
- package/dist/core/dist/author-ids.js +51 -0
- package/dist/core/dist/author-schemas.js +330 -0
- package/dist/core/dist/block-flex-layout.js +801 -0
- package/dist/core/dist/build.js +4 -0
- package/dist/core/dist/capability.js +15 -0
- package/dist/core/dist/declaration.js +16 -0
- package/dist/core/dist/diagnostics.js +353 -0
- package/dist/core/dist/document-internals.js +26 -0
- package/dist/core/dist/document.js +417 -0
- package/dist/core/dist/font-seal.js +204 -0
- package/dist/core/dist/geometry-schemas.js +256 -0
- package/dist/core/dist/grid-layout.js +449 -0
- package/dist/core/dist/host.js +40 -0
- package/dist/core/dist/index.js +15 -0
- package/dist/core/dist/input-values.js +61 -0
- package/dist/core/dist/layout-protocol.js +61 -0
- package/dist/core/dist/layout-schemas.js +201 -0
- package/dist/core/dist/layout.js +340 -0
- package/dist/core/dist/masters.js +194 -0
- package/dist/core/dist/morph.js +30 -0
- package/dist/core/dist/placeholders.js +275 -0
- package/dist/core/dist/query.js +190 -0
- package/dist/core/dist/resolution.js +12 -0
- package/dist/core/dist/resolve.js +2246 -0
- package/dist/core/dist/stage-options.js +300 -0
- package/dist/core/dist/theme.js +1023 -0
- package/dist/core/dist/transform-geometry.js +72 -0
- package/dist/document-41spD7bq.d.ts +1350 -0
- package/dist/emit/dist/emit.js +957 -0
- package/dist/emit/dist/index.js +5 -0
- package/dist/emit/dist/ooxml.js +661 -0
- package/dist/emit/dist/shape-tree.js +12 -0
- package/dist/import/dist/alternate-content.js +54 -0
- package/dist/import/dist/diagnostics.js +157 -0
- package/dist/import/dist/fonts.js +309 -0
- package/dist/import/dist/import.js +513 -0
- package/dist/import/dist/index.js +16 -0
- package/dist/import/dist/masters.js +1293 -0
- package/dist/import/dist/mechanism.js +10 -0
- package/dist/import/dist/namespaces.js +61 -0
- package/dist/import/dist/notes-masters.js +300 -0
- package/dist/import/dist/opc.js +233 -0
- package/dist/import/dist/resources.js +166 -0
- package/dist/import/dist/sections.js +139 -0
- package/dist/import/dist/themes.js +777 -0
- package/dist/import/dist/visual.js +821 -0
- package/dist/import/dist/xml-fragments.js +277 -0
- package/dist/import/dist/xml-reader.js +267 -0
- package/dist/index-1ag7U9Jt.d.ts +63 -0
- package/dist/index-BEwhk7c8.d.ts +72 -0
- package/dist/index-cK2KtukZ.d.ts +161 -0
- package/dist/index-v77CTJev.d.ts +55 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +82 -0
- package/dist/node.d.ts +53 -0
- package/dist/node.js +225 -0
- package/dist/pptxdk/src/cli-commands.js +907 -0
- package/dist/pptxdk/src/compose.js +53 -0
- package/dist/pptxdk/src/slide.js +9 -0
- package/dist/preview/dist/index.js +342 -0
- package/dist/preview/dist/options.js +40 -0
- package/dist/preview/dist/svg-guard.js +1089 -0
- package/dist/preview.d.ts +12 -0
- package/dist/preview.js +29 -0
- package/dist/react/dist/append.js +66 -0
- package/dist/react/dist/document-adapter.js +404 -0
- package/dist/react/dist/elements.js +82 -0
- package/dist/react/dist/from-vanilla.js +57 -0
- package/dist/react/dist/index.js +89 -0
- package/dist/react/dist/mount.js +34 -0
- package/dist/react/dist/reconciler.js +290 -0
- package/dist/react.d.ts +235 -0
- package/dist/react.js +31 -0
- package/dist/transition-6n8GZxSg.d.ts +9 -0
- package/dist/vanilla.d.ts +4 -0
- package/dist/vanilla.js +15 -0
- package/package.json +79 -3
- package/README.md +0 -3
package/dist/node.js
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { BuildError, toBuildDiagnostic } from "./core/dist/diagnostics.js";
|
|
2
|
+
import { buildDiagnosticSchema, buildOptionsShape, previewErrorSchema, previewPlaceholderSchema, resolveOptionsSchema, resolveOptionsShape } from "./core/dist/stage-options.js";
|
|
3
|
+
import "./core/dist/build.js";
|
|
4
|
+
import { validateOptions } from "./emit/dist/emit.js";
|
|
5
|
+
import { CommonNode } from "./core/dist/document.js";
|
|
6
|
+
import "./emit/dist/index.js";
|
|
7
|
+
import { ImportError } from "./import/dist/diagnostics.js";
|
|
8
|
+
import { resolveDocumentInput } from "./pptxdk/src/compose.js";
|
|
9
|
+
import { build, importPptx, resolve as resolve$1 } from "./index.js";
|
|
10
|
+
import { registerHooks } from "node:module";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import { extname, sep } from "node:path";
|
|
13
|
+
import { readFileSync } from "node:fs";
|
|
14
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
15
|
+
import { readFile } from "node:fs/promises";
|
|
16
|
+
import { transformSync } from "esbuild";
|
|
17
|
+
// src/node.ts
|
|
18
|
+
const sourceLoaders = {
|
|
19
|
+
".ts": "ts",
|
|
20
|
+
".tsx": "tsx",
|
|
21
|
+
".mts": "ts",
|
|
22
|
+
".jsx": "jsx"
|
|
23
|
+
};
|
|
24
|
+
const rawExportNameSchema = z.string().min(1);
|
|
25
|
+
const exportNameSchema = rawExportNameSchema;
|
|
26
|
+
const buildFromSourceOptionsSchema = z.strictObject({
|
|
27
|
+
...buildOptionsShape,
|
|
28
|
+
exportName: rawExportNameSchema.optional()
|
|
29
|
+
}).readonly();
|
|
30
|
+
const previewFromSourceOptionsSchema = z.strictObject({
|
|
31
|
+
pages: z.array(z.int().positive()).readonly().optional(),
|
|
32
|
+
signal: z.instanceof(AbortSignal).optional(),
|
|
33
|
+
exportName: rawExportNameSchema.optional()
|
|
34
|
+
}).readonly();
|
|
35
|
+
const resolveFromSourceOptionsSchema = z.strictObject({
|
|
36
|
+
...resolveOptionsShape,
|
|
37
|
+
exportName: rawExportNameSchema.optional()
|
|
38
|
+
}).readonly();
|
|
39
|
+
/**
|
|
40
|
+
* Reads a Transitional PPTX file from disk and imports it into an editable CommonNode document
|
|
41
|
+
* and structured `ImportReport`, detaching completely from the file buffer after import.
|
|
42
|
+
*/
|
|
43
|
+
async function importPptxFile(entry, options = {}) {
|
|
44
|
+
if (options.signal?.aborted) throw options.signal.reason;
|
|
45
|
+
const bytes = await readFile(entry, options.signal === void 0 ? void 0 : { signal: options.signal });
|
|
46
|
+
return importPptx(new Uint8Array(bytes), options);
|
|
47
|
+
}
|
|
48
|
+
/** Error thrown when loading author deck source fails. */
|
|
49
|
+
var SourceLoadError = class extends Error {
|
|
50
|
+
constructor(message, options) {
|
|
51
|
+
super(message, options);
|
|
52
|
+
this.name = "SourceLoadError";
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
function registerSourceLoader() {
|
|
56
|
+
return registerHooks({ load(url, context, nextLoad) {
|
|
57
|
+
if (!url.startsWith("file:")) return nextLoad(url, context);
|
|
58
|
+
const file = fileURLToPath(url);
|
|
59
|
+
if (file.split(sep).includes("node_modules")) return nextLoad(url, context);
|
|
60
|
+
const loader = sourceLoaders[extname(file)];
|
|
61
|
+
if (loader === void 0) return nextLoad(url, context);
|
|
62
|
+
return {
|
|
63
|
+
format: "module",
|
|
64
|
+
source: transformSync(readFileSync(file, "utf8"), {
|
|
65
|
+
loader,
|
|
66
|
+
format: "esm",
|
|
67
|
+
jsx: "automatic",
|
|
68
|
+
jsxImportSource: "react",
|
|
69
|
+
sourcemap: "inline",
|
|
70
|
+
sourcefile: file,
|
|
71
|
+
target: "node24"
|
|
72
|
+
}).code,
|
|
73
|
+
shortCircuit: true
|
|
74
|
+
};
|
|
75
|
+
} });
|
|
76
|
+
}
|
|
77
|
+
function sourceUrl(entry) {
|
|
78
|
+
if (entry instanceof URL) {
|
|
79
|
+
if (entry.protocol !== "file:") throw new SourceLoadError("Deck entry must be a local file path or file URL");
|
|
80
|
+
return entry;
|
|
81
|
+
}
|
|
82
|
+
return pathToFileURL(entry);
|
|
83
|
+
}
|
|
84
|
+
function settleWithSignal(promise, signal) {
|
|
85
|
+
return new Promise((resolve) => {
|
|
86
|
+
let settled = false;
|
|
87
|
+
const settle = (result) => {
|
|
88
|
+
if (settled) return;
|
|
89
|
+
settled = true;
|
|
90
|
+
signal?.removeEventListener("abort", onAbort);
|
|
91
|
+
resolve(result);
|
|
92
|
+
};
|
|
93
|
+
const onAbort = () => settle({ kind: "cancelled" });
|
|
94
|
+
if (signal?.aborted) {
|
|
95
|
+
onAbort();
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
99
|
+
if (signal?.aborted) {
|
|
100
|
+
onAbort();
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
Promise.resolve(promise).then((value) => settle({
|
|
104
|
+
kind: "resolved",
|
|
105
|
+
value
|
|
106
|
+
}), (cause) => settle({
|
|
107
|
+
kind: "rejected",
|
|
108
|
+
cause
|
|
109
|
+
}));
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
function isPromiseLike(value) {
|
|
113
|
+
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
114
|
+
}
|
|
115
|
+
async function awaitSourcePromise(promise, filePath, signal) {
|
|
116
|
+
const settled = await settleWithSignal(promise, signal);
|
|
117
|
+
if (settled.kind === "cancelled") throw signal?.reason;
|
|
118
|
+
if (settled.kind === "rejected") {
|
|
119
|
+
if (signal?.aborted && settled.cause === signal.reason) throw settled.cause;
|
|
120
|
+
throw new SourceLoadError(`Failed to load deck source at ${filePath}:\n${settled.cause instanceof Error ? settled.cause.stack ?? settled.cause.message : String(settled.cause)}`, { cause: settled.cause });
|
|
121
|
+
}
|
|
122
|
+
return settled.value;
|
|
123
|
+
}
|
|
124
|
+
async function loadDeck(url, exportName, signal) {
|
|
125
|
+
const filePath = fileURLToPath(url);
|
|
126
|
+
const deckModule = await awaitSourcePromise(import(url.href), filePath, signal);
|
|
127
|
+
if (!Object.hasOwn(deckModule, exportName) || deckModule[exportName] === void 0) throw new SourceLoadError(`Deck source at ${filePath} does not export ${JSON.stringify(exportName)}`);
|
|
128
|
+
const exported = deckModule[exportName];
|
|
129
|
+
if (exported instanceof CommonNode) return exported;
|
|
130
|
+
if (isPromiseLike(exported)) {
|
|
131
|
+
const resolved = await awaitSourcePromise(exported, filePath, signal);
|
|
132
|
+
if (resolved instanceof CommonNode) return resolved;
|
|
133
|
+
throw new SourceLoadError(`Deck source at ${filePath} export ${JSON.stringify(exportName)} resolved to an unsupported value; expected an editable document node`);
|
|
134
|
+
}
|
|
135
|
+
if (typeof exported === "function") {
|
|
136
|
+
const { createElement } = await import("react");
|
|
137
|
+
return createElement(exported);
|
|
138
|
+
}
|
|
139
|
+
if (typeof exported === "object" && exported !== null && !Array.isArray(exported)) {
|
|
140
|
+
const { isValidElement } = await import("react");
|
|
141
|
+
if (isValidElement(exported)) return exported;
|
|
142
|
+
}
|
|
143
|
+
throw new SourceLoadError(`Deck source at ${filePath} must export an editable document node, Promise of document node, React element, or zero-arg React component named ${JSON.stringify(exportName)}`);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Run a formal build from a Node.js local ESM source entry. TS, TSX, MTS, and JSX are loaded by this entry;
|
|
147
|
+
* the entry and its source dependencies are resolved according to Node file locations. Cancellation signals
|
|
148
|
+
* also cover source import, async deck promises, and expansion, preserving the original cancellation reason.
|
|
149
|
+
* The return value is identical to `build`.
|
|
150
|
+
*/
|
|
151
|
+
async function buildFromSource(entry, options = {}) {
|
|
152
|
+
const url = sourceUrl(entry);
|
|
153
|
+
const parsed = buildFromSourceOptionsSchema.safeParse(options);
|
|
154
|
+
if (!parsed.success) {
|
|
155
|
+
if (typeof options !== "object" || options === null || Array.isArray(options)) validateOptions(options);
|
|
156
|
+
const { exportName: _exportName, ...buildOptions } = options;
|
|
157
|
+
validateOptions(buildOptions);
|
|
158
|
+
throw new BuildError([toBuildDiagnostic("build.exportName", "invalid-options", "exportName must be a non-empty string", { field: "exportName" })]);
|
|
159
|
+
}
|
|
160
|
+
const { exportName = "default", ...buildOptions } = parsed.data;
|
|
161
|
+
if (buildOptions.signal?.aborted) throw buildOptions.signal.reason;
|
|
162
|
+
const hooks = registerSourceLoader();
|
|
163
|
+
try {
|
|
164
|
+
const deck = await loadDeck(url, exportName, buildOptions.signal);
|
|
165
|
+
return await build(deck, buildOptions);
|
|
166
|
+
} finally {
|
|
167
|
+
hooks.deregister();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Run a formal static preview from a Node.js local ESM source entry. Shares source loading, export selection,
|
|
172
|
+
* and cancellation semantics with `buildFromSource`.
|
|
173
|
+
* The return value is identical to `preview`.
|
|
174
|
+
*/
|
|
175
|
+
async function previewFromSource(entry, options = {}) {
|
|
176
|
+
const url = sourceUrl(entry);
|
|
177
|
+
if (typeof options === "object" && options !== null && "signal" in options && options.signal instanceof AbortSignal && options.signal.aborted) throw options.signal.reason;
|
|
178
|
+
const parsed = previewFromSourceOptionsSchema.safeParse(options);
|
|
179
|
+
if (!parsed.success) {
|
|
180
|
+
const issue = parsed.error.issues[0];
|
|
181
|
+
if (issue?.path[0] === "pages") throw new RangeError("Preview page numbers must be positive integers");
|
|
182
|
+
if (issue?.path[0] === "exportName") throw new TypeError("Preview options exportName must be a non-empty string");
|
|
183
|
+
if (issue?.path[0] === "signal") throw new TypeError("Preview options signal must be an AbortSignal");
|
|
184
|
+
if (issue?.path.length === 0 && issue.code === "unrecognized_keys") throw new TypeError(`Preview options contain unknown parameter ${issue.keys[0]}`);
|
|
185
|
+
throw new TypeError("Preview options must be an object");
|
|
186
|
+
}
|
|
187
|
+
const { exportName = "default", ...previewOptions } = parsed.data;
|
|
188
|
+
const { preview } = await import("./preview.js");
|
|
189
|
+
const hooks = registerSourceLoader();
|
|
190
|
+
try {
|
|
191
|
+
return await preview(await loadDeck(url, exportName, previewOptions.signal), previewOptions);
|
|
192
|
+
} finally {
|
|
193
|
+
hooks.deregister();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Run a read-only resolve from a Node.js local ESM source entry. Shares source loading, export selection,
|
|
198
|
+
* and cancellation semantics with `buildFromSource` and `previewFromSource`, without emitting PPTX or PNGs.
|
|
199
|
+
* The return value is identical to `resolve`.
|
|
200
|
+
*/
|
|
201
|
+
async function resolveFromSource(entry, options = {}) {
|
|
202
|
+
const url = sourceUrl(entry);
|
|
203
|
+
const parsed = resolveFromSourceOptionsSchema.safeParse(options);
|
|
204
|
+
if (!parsed.success) {
|
|
205
|
+
if (typeof options !== "object" || options === null || Array.isArray(options)) throw new BuildError([toBuildDiagnostic("resolve", "invalid-options", "Resolve options must be an object")]);
|
|
206
|
+
const issue = parsed.error.issues[0];
|
|
207
|
+
if (issue?.path.length === 0 && issue.code === "unrecognized_keys") throw new BuildError([toBuildDiagnostic("resolve", "unknown-parameter", `Resolve options contain unknown parameter ${issue.keys[0]}`, {
|
|
208
|
+
prop: String(issue.keys[0]),
|
|
209
|
+
scope: "options"
|
|
210
|
+
})]);
|
|
211
|
+
if (issue?.path[0] === "signal") throw new BuildError([toBuildDiagnostic("resolve.signal", "invalid-options", "Resolve options signal must be an AbortSignal", { field: "signal" })]);
|
|
212
|
+
if (issue?.path[0] === "exportName") throw new BuildError([toBuildDiagnostic("resolve.exportName", "invalid-options", "exportName must be a non-empty string", { field: "exportName" })]);
|
|
213
|
+
throw new BuildError([toBuildDiagnostic("resolve", "invalid-options", "Resolve options must be an object")]);
|
|
214
|
+
}
|
|
215
|
+
const { exportName = "default", ...resolveOptions } = parsed.data;
|
|
216
|
+
if (resolveOptions.signal?.aborted) throw resolveOptions.signal.reason;
|
|
217
|
+
const hooks = registerSourceLoader();
|
|
218
|
+
try {
|
|
219
|
+
const deck = await loadDeck(url, exportName, resolveOptions.signal);
|
|
220
|
+
return await resolveDocumentInput(resolve$1, deck, resolveOptions);
|
|
221
|
+
} finally {
|
|
222
|
+
hooks.deregister();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
export { ImportError, SourceLoadError, buildDiagnosticSchema, buildFromSource, buildFromSourceOptionsSchema, exportNameSchema, importPptxFile, previewErrorSchema, previewFromSource, previewFromSourceOptionsSchema, previewPlaceholderSchema, resolveFromSource, resolveFromSourceOptionsSchema, resolveOptionsSchema };
|