@openpresentation/opf-pptx 0.0.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.
- package/LICENSE +21 -0
- package/README.md +108 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.js +1776 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OpenPresentation
|
|
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,108 @@
|
|
|
1
|
+
# OPF PPTX
|
|
2
|
+
|
|
3
|
+
Pure local PowerPoint conversion tooling for Open Presentation Format documents. This repo owns the Phase 3 and Phase 4 toolkit lanes: OPF to PPTX export and PPTX to OPF import.
|
|
4
|
+
|
|
5
|
+
## Scope
|
|
6
|
+
|
|
7
|
+
- Package: `@openpresentation/opf-pptx`
|
|
8
|
+
- Repository: `OpenPresentation/opf-pptx`
|
|
9
|
+
- License: MIT
|
|
10
|
+
- Compatibility target: `@openpresentation/opf`
|
|
11
|
+
- Renderer relationship: may use `@openpresentation/opf-render` for chart rasterization and visual verification
|
|
12
|
+
- Public export API: `toPptx(opf, opts)`
|
|
13
|
+
- Public import API: `fromPptx(buffer, opts)`
|
|
14
|
+
|
|
15
|
+
The export path validates OPF with `@openpresentation/opf`, maps slide titles and common content payloads to editable PowerPoint objects through `pptxgenjs`, then normalizes the generated ZIP for stable entry ordering, fixed timestamps, and reproducible bytes.
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import { toPptx } from "@openpresentation/opf-pptx";
|
|
19
|
+
|
|
20
|
+
const bytes = await toPptx({
|
|
21
|
+
$schema: "https://openpresentation.org/schema/opf/v1",
|
|
22
|
+
name: "Quarterly Review",
|
|
23
|
+
slides: [
|
|
24
|
+
{
|
|
25
|
+
title: "Revenue grew across all regions",
|
|
26
|
+
items: ["North America +18%", "EMEA +14%", "APAC +11%"]
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
await fs.promises.writeFile("quarterly-review.pptx", bytes);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`toPptx` returns a `Uint8Array` containing a PowerPoint-openable `.pptx`. It does not fetch remote assets. Data URI images and local paths can be embedded directly; hosts that need private asset loading should pass `imageResolver(src, context)`. Set `strictAssets: true` to turn unresolved or remote image assets into structured `OPFPptxError` failures instead of editable placeholder boxes.
|
|
35
|
+
|
|
36
|
+
`fromPptx` parses an existing `.pptx` buffer locally and returns an OPF document that validates with `@openpresentation/opf`:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
import { fromPptx, toPptx } from "@openpresentation/opf-pptx";
|
|
40
|
+
|
|
41
|
+
const opf = await fromPptx(await fs.promises.readFile("source.pptx"));
|
|
42
|
+
const roundTripBytes = await toPptx(opf);
|
|
43
|
+
|
|
44
|
+
await fs.promises.writeFile("round-trip.pptx", roundTripBytes);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The importer reads core properties, slide order, text boxes, speaker notes, embedded images, tables, and basic cached chart data from the OOXML parts. Slides or objects that do not map cleanly fall back to editable `blocks[]` payloads; OOXML positions are used for deterministic ordering and title/subtitle detection while keeping the emitted OPF schema-valid.
|
|
48
|
+
|
|
49
|
+
## v1 Placeholder and OOXML Mapping
|
|
50
|
+
|
|
51
|
+
The first exporter keeps the public API stable while using `pptxgenjs` internally:
|
|
52
|
+
|
|
53
|
+
- `Slide.title`, `Slide.subtitle`, and `Slide.tag` become editable text boxes, not PowerPoint master placeholders.
|
|
54
|
+
- Root payloads, `blocks[]`, and promoted region keys become editable slide objects in deterministic regions. Promoted keys use the OPF 3x3 region vocabulary (`top`, `middle`, `bottom`, `left`, `center`, `right`).
|
|
55
|
+
- Text, lists, metrics, quotes, timelines, code, tables, and inline-data charts are emitted as editable PowerPoint text, table, and chart objects.
|
|
56
|
+
- Image assets are embedded only when supplied as data URIs, local paths, or host-resolved bytes/paths. Remote asset URLs are never fetched by the runtime path.
|
|
57
|
+
- ZIP entries, generated chart/workbook part names, core-property timestamps, and nested chart workbook timestamps are normalized for reproducible bytes.
|
|
58
|
+
|
|
59
|
+
This pass did not require an OPF schema change. The deferred full OOXML placeholder mapping from `docs/plans/layout-placeholders.md` remains a later hand-written OOXML emitter concern.
|
|
60
|
+
|
|
61
|
+
## v1 Import Mapping
|
|
62
|
+
|
|
63
|
+
The first importer is mechanical and schema-compatible:
|
|
64
|
+
|
|
65
|
+
- Presentation core properties map to OPF `name`, `description`, and `author`.
|
|
66
|
+
- Slide text placeholders and large top-of-slide text boxes map to `title` and `subtitle` when recognizable.
|
|
67
|
+
- Remaining text boxes map to `blocks[]` as text or list payloads, sorted by OOXML position.
|
|
68
|
+
- PowerPoint tables map to OPF table blocks, embedded images map to data URI image blocks, and cached chart series map to basic OPF chart blocks.
|
|
69
|
+
- Unknown non-text shapes and unsupported graphic frames become editable text fallback blocks instead of failing the import.
|
|
70
|
+
|
|
71
|
+
There is no AI classification pass in the OSS runtime. Hosts can run optional cleanup or semantic remapping after `fromPptx` returns.
|
|
72
|
+
|
|
73
|
+
## Runtime Policy
|
|
74
|
+
|
|
75
|
+
The package runtime must stay local and deterministic:
|
|
76
|
+
|
|
77
|
+
- No hosted service in the critical path
|
|
78
|
+
- No telemetry or hidden analytics
|
|
79
|
+
- No commercial SDK dependency in the critical path
|
|
80
|
+
- No required network calls
|
|
81
|
+
- No required AI dependency
|
|
82
|
+
- No required AI cleanup or classification pass for PPTX import
|
|
83
|
+
- No required LibreOffice dependency in the runtime path; LibreOffice is allowed only as an optional verification tool in CI
|
|
84
|
+
- Host applications own auth, storage, queues, analytics, collaboration, branding, and product workflow
|
|
85
|
+
|
|
86
|
+
## Development
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
npm ci
|
|
90
|
+
npm run build
|
|
91
|
+
npm run typecheck
|
|
92
|
+
npm test
|
|
93
|
+
npm run validate
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
LibreOffice is not a runtime dependency. When it is installed in CI or a local verification environment, generated `.pptx` files can be smoke-opened there as an optional export check.
|
|
97
|
+
|
|
98
|
+
## Release Lane
|
|
99
|
+
|
|
100
|
+
Public npm package publication is handled by `.github/workflows/release.yml` with npm provenance.
|
|
101
|
+
|
|
102
|
+
Required first-publish setup:
|
|
103
|
+
|
|
104
|
+
1. An npm owner for the `@openpresentation` scope must run the first publish or reserve/grant the `@openpresentation/opf-pptx` package.
|
|
105
|
+
2. Configure npm Trusted Publishing for GitHub repository `OpenPresentation/opf-pptx` and workflow `.github/workflows/release.yml`.
|
|
106
|
+
3. Publish by creating a GitHub Release or manually running the Release workflow after CI passes.
|
|
107
|
+
|
|
108
|
+
This repo does not require an npm automation token when Trusted Publishing is configured.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export declare const packageName = "@openpresentation/opf-pptx";
|
|
2
|
+
|
|
3
|
+
export declare const releaseLane: Readonly<{
|
|
4
|
+
githubRepository: "OpenPresentation/opf-pptx";
|
|
5
|
+
npmPackage: "@openpresentation/opf-pptx";
|
|
6
|
+
compatibilityPackage: "@openpresentation/opf";
|
|
7
|
+
rendererPackage: "@openpresentation/opf-render";
|
|
8
|
+
}>;
|
|
9
|
+
|
|
10
|
+
export declare const runtimePolicy: Readonly<{
|
|
11
|
+
hostedServiceInCriticalPath: false;
|
|
12
|
+
telemetry: false;
|
|
13
|
+
commercialSdkInCriticalPath: false;
|
|
14
|
+
requiredAiDependency: false;
|
|
15
|
+
requiredLibreOfficeDependency: false;
|
|
16
|
+
requiredNetworkCalls: false;
|
|
17
|
+
deterministicLocalExecution: true;
|
|
18
|
+
}>;
|
|
19
|
+
|
|
20
|
+
export type ImageResolverResult =
|
|
21
|
+
| string
|
|
22
|
+
| Uint8Array
|
|
23
|
+
| {
|
|
24
|
+
data?: string | Uint8Array;
|
|
25
|
+
path?: string;
|
|
26
|
+
mediaType?: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export interface ImageResolverContext {
|
|
30
|
+
asset: unknown;
|
|
31
|
+
presentation: unknown;
|
|
32
|
+
path: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface ToPptxOptions {
|
|
36
|
+
baseDir?: string;
|
|
37
|
+
compressionLevel?: number;
|
|
38
|
+
imageResolver?: (src: string, context: ImageResolverContext) => ImageResolverResult | Promise<ImageResolverResult | null | undefined> | null | undefined;
|
|
39
|
+
seed?: number;
|
|
40
|
+
strictAssets?: boolean;
|
|
41
|
+
timestamp?: string;
|
|
42
|
+
zipDate?: string | number | Date;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface FromPptxOptions {
|
|
46
|
+
fallbackName?: string;
|
|
47
|
+
schema?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export declare class OPFPptxError extends Error {
|
|
51
|
+
readonly code: string;
|
|
52
|
+
readonly details: Record<string, unknown>;
|
|
53
|
+
readonly issues?: unknown[];
|
|
54
|
+
readonly path?: string;
|
|
55
|
+
constructor(code: string, message: string, details?: Record<string, unknown>);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export declare function toPptx(input: unknown, options?: ToPptxOptions): Promise<Uint8Array>;
|
|
59
|
+
|
|
60
|
+
export declare function fromPptx(input: Uint8Array | ArrayBuffer, options?: FromPptxOptions): Promise<Record<string, unknown>>;
|