pptx-svelte-viewer 0.1.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/CHANGELOG.md +3 -0
- package/LICENSE +202 -0
- package/NOTICE +18 -0
- package/README.md +71 -0
- package/dist/component-CacEu31z.js +53915 -0
- package/dist/i18n.d.ts +62 -0
- package/dist/i18n.js +9 -0
- package/dist/index.d.ts +209 -0
- package/dist/index.js +16 -0
- package/dist/translator-C44zS1dl.js +2389 -0
- package/dist/viewer/index.d.ts +7257 -0
- package/dist/viewer/index.js +11 -0
- package/package.json +83 -0
package/dist/i18n.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** Build a {@link Translator} bound to a (lazily-read) locale. */
|
|
2
|
+
export declare function createTranslator(getLocale: () => string): Translator;
|
|
3
|
+
|
|
4
|
+
/** Interpolate `{{name}}` placeholders (the shared-dictionary convention). */
|
|
5
|
+
export declare function interpolate(message: string, params: Record<string, string | number> | undefined): string;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Convert a dotted translation key to a human-readable label when no
|
|
9
|
+
* explicit dictionary entry exists yet. Takes the last segment and converts
|
|
10
|
+
* camelCase to Title Case, e.g. "pptx.slideSorter.zoomIn" -> "Zoom In".
|
|
11
|
+
*/
|
|
12
|
+
export declare function keyToLabel(key: string): string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Register (or extend) the dictionary for a locale. Later registrations are
|
|
16
|
+
* merged over earlier ones, so hosts can override individual keys.
|
|
17
|
+
*/
|
|
18
|
+
export declare function registerTranslations(locale: string, dictionary: TranslationDictionary): void;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Translate a key for a locale: exact locale dictionary, then its base
|
|
22
|
+
* language (`fr-CA` falls back to `fr`), then English, then the humanised
|
|
23
|
+
* `keyToLabel` fallback so missing keys never render as raw dotted paths.
|
|
24
|
+
*/
|
|
25
|
+
export declare function translate(locale: string, key: string, params?: Record<string, string | number>): string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Minimal, dependency-free translation layer for the Svelte binding.
|
|
29
|
+
*
|
|
30
|
+
* The canonical English dictionary lives in `pptx-viewer-shared/i18n` (shared
|
|
31
|
+
* with the React, Vue, and Angular bindings, which each plug it into their
|
|
32
|
+
* framework's i18n library). Svelte has no blessed i18n runtime, so this
|
|
33
|
+
* module implements the small subset the viewer needs: dictionary lookup by
|
|
34
|
+
* locale with English fallback, `{{name}}` interpolation, and the shared
|
|
35
|
+
* `keyToLabel` humanised fallback for missing keys.
|
|
36
|
+
*/
|
|
37
|
+
/** A flat dictionary of dotted `pptx.*` keys to display strings. */
|
|
38
|
+
export declare type TranslationDictionary = Record<string, string>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Every key in the English dictionary. A new locale dictionary typed as
|
|
42
|
+
* `Record<TranslationKey, string>` gets a compile error for any key it's
|
|
43
|
+
* missing or misspells, so translation contributions stay complete without a
|
|
44
|
+
* separate parity test.
|
|
45
|
+
*/
|
|
46
|
+
export declare type TranslationKey = keyof typeof translationsEn;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The canonical English UI-string dictionary for pptx-viewer. None of the
|
|
50
|
+
* React/Vue/Angular binding packages ship translations themselves - each
|
|
51
|
+
* only calls its framework's translation function (react-i18next's `t()`,
|
|
52
|
+
* vue-i18n's `t()`, ngx-translate's `TranslateService`/`translate` pipe)
|
|
53
|
+
* against dotted `pptx.*` keys. The host app supplies the dictionary; this
|
|
54
|
+
* module is that dictionary for the demos, shared so all three stay in sync
|
|
55
|
+
* instead of drifting into three separate copies.
|
|
56
|
+
*/
|
|
57
|
+
export declare const translationsEn: Record<string, string>;
|
|
58
|
+
|
|
59
|
+
/** Translate `key`, interpolating `{{name}}` placeholders from `params`. */
|
|
60
|
+
export declare type Translator = (key: string, params?: Record<string, string | number>) => string;
|
|
61
|
+
|
|
62
|
+
export { }
|
package/dist/i18n.js
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { Component } from 'svelte';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Framework-agnostic public types shared by the viewer bindings.
|
|
5
|
+
*
|
|
6
|
+
* These were duplicated in the React (`types-ui.ts`) and Vue (`viewer/types.ts`)
|
|
7
|
+
* packages; this is the canonical copy. Each binding layers its own
|
|
8
|
+
* framework-specific prop/event/handle types on top of these.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Canvas dimensions in pixels. */
|
|
12
|
+
export declare interface CanvasSize {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Build the complete set of CSS custom properties with all defaults.
|
|
19
|
+
* Useful for generating a full fallback stylesheet.
|
|
20
|
+
*/
|
|
21
|
+
export declare function defaultCssVars(): Record<string, string>;
|
|
22
|
+
|
|
23
|
+
/** Default border-radius. */
|
|
24
|
+
export declare const defaultRadius = "0.5rem";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Default dark-theme color values.
|
|
28
|
+
*
|
|
29
|
+
* These correspond to the built-in dark UI of the PowerPoint viewer and
|
|
30
|
+
* use Tailwind's gray palette as the neutral scale with indigo as the
|
|
31
|
+
* primary accent.
|
|
32
|
+
*/
|
|
33
|
+
export declare const defaultThemeColors: ViewerThemeColors;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Explicitly-typed public export of the viewer component.
|
|
37
|
+
*
|
|
38
|
+
* `svelte-check` types the `.svelte` import precisely, but the plain
|
|
39
|
+
* TypeScript pass that emits the published declaration files resolves
|
|
40
|
+
* `.svelte` modules through a loose ambient shim (`src/shims-svelte.d.ts`).
|
|
41
|
+
* Re-exporting through this annotated constant keeps the published `.d.ts`
|
|
42
|
+
* fully typed regardless of which compiler produced it.
|
|
43
|
+
*/
|
|
44
|
+
export declare const PowerPointViewer: Component<PowerPointViewerProps>;
|
|
45
|
+
|
|
46
|
+
/** Props for `<PowerPointViewer>`. */
|
|
47
|
+
export declare interface PowerPointViewerProps {
|
|
48
|
+
/** PowerPoint content as `Uint8Array` (or `ArrayBuffer`). */
|
|
49
|
+
source: Uint8Array | ArrayBuffer | null | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Theme configuration for customising the viewer's appearance. Accepts
|
|
52
|
+
* partial color overrides, a custom border-radius, and arbitrary CSS
|
|
53
|
+
* custom properties. Unset values fall back to the built-in defaults.
|
|
54
|
+
*/
|
|
55
|
+
theme?: ViewerTheme;
|
|
56
|
+
/** UI locale (BCP 47). English ships built in; register others via `pptx-svelte-viewer/i18n`. */
|
|
57
|
+
locale?: string;
|
|
58
|
+
/** Slide shown after load (0-based, clamped). Default 0. */
|
|
59
|
+
initialSlide?: number;
|
|
60
|
+
/** Show the thumbnail sidebar. Default true. */
|
|
61
|
+
showThumbnails?: boolean;
|
|
62
|
+
/** Show the navigation/zoom toolbar. Default true. */
|
|
63
|
+
showToolbar?: boolean;
|
|
64
|
+
/** Optional class name applied to the root element. */
|
|
65
|
+
class?: string;
|
|
66
|
+
/** Fired after a presentation finishes loading. */
|
|
67
|
+
onload?: (detail: ViewerLoadDetail) => void;
|
|
68
|
+
/** Fired when a load fails (message is human-readable). */
|
|
69
|
+
onerror?: (message: string) => void;
|
|
70
|
+
/** Fired when the active slide changes (0-based index). */
|
|
71
|
+
onslidechange?: (index: number) => void;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Register (or extend) the dictionary for a locale. Later registrations are
|
|
76
|
+
* merged over earlier ones, so hosts can override individual keys.
|
|
77
|
+
*/
|
|
78
|
+
export declare function registerTranslations(locale: string, dictionary: TranslationDictionary): void;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Convert a `ViewerTheme` into a flat `Record<string, string>` of CSS
|
|
82
|
+
* custom properties (including the `--` prefix) ready to be spread onto
|
|
83
|
+
* a `style` attribute.
|
|
84
|
+
*
|
|
85
|
+
* Only properties that differ from the built-in defaults are emitted when
|
|
86
|
+
* `omitDefaults` is true (the default).
|
|
87
|
+
*/
|
|
88
|
+
export declare function themeToCssVars(theme: ViewerTheme | undefined, omitDefaults?: boolean): Record<string, string>;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Minimal, dependency-free translation layer for the Svelte binding.
|
|
92
|
+
*
|
|
93
|
+
* The canonical English dictionary lives in `pptx-viewer-shared/i18n` (shared
|
|
94
|
+
* with the React, Vue, and Angular bindings, which each plug it into their
|
|
95
|
+
* framework's i18n library). Svelte has no blessed i18n runtime, so this
|
|
96
|
+
* module implements the small subset the viewer needs: dictionary lookup by
|
|
97
|
+
* locale with English fallback, `{{name}}` interpolation, and the shared
|
|
98
|
+
* `keyToLabel` humanised fallback for missing keys.
|
|
99
|
+
*/
|
|
100
|
+
/** A flat dictionary of dotted `pptx.*` keys to display strings. */
|
|
101
|
+
export declare type TranslationDictionary = Record<string, string>;
|
|
102
|
+
|
|
103
|
+
/** Translate `key`, interpolating `{{name}}` placeholders from `params`. */
|
|
104
|
+
export declare type Translator = (key: string, params?: Record<string, string | number>) => string;
|
|
105
|
+
|
|
106
|
+
/** Dark "presenter" palette: the presenter room with the lights down. */
|
|
107
|
+
export declare const vermilionDarkColors: ViewerThemeColors;
|
|
108
|
+
|
|
109
|
+
/** Dark vermilion theme, ready for the viewer's `theme` prop. */
|
|
110
|
+
export declare const vermilionDarkTheme: ViewerTheme;
|
|
111
|
+
|
|
112
|
+
/** Light "paper" palette: a projection screen in a bright room. */
|
|
113
|
+
export declare const vermilionLightColors: ViewerThemeColors;
|
|
114
|
+
|
|
115
|
+
/** Light vermilion theme, ready for the viewer's `theme` prop. */
|
|
116
|
+
export declare const vermilionLightTheme: ViewerTheme;
|
|
117
|
+
|
|
118
|
+
/** Shared border-radius for the vermilion presets (slightly sharper than the default). */
|
|
119
|
+
export declare const vermilionRadius = "0.375rem";
|
|
120
|
+
|
|
121
|
+
/** Payload for the `onload` callback. */
|
|
122
|
+
export declare interface ViewerLoadDetail {
|
|
123
|
+
/** Number of slides in the loaded presentation. */
|
|
124
|
+
slideCount: number;
|
|
125
|
+
/** Slide canvas size in pixels. */
|
|
126
|
+
canvasSize: CanvasSize;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Full viewer theme configuration.
|
|
131
|
+
*
|
|
132
|
+
* Every property is optional — unset values fall back to the built-in
|
|
133
|
+
* dark theme defaults.
|
|
134
|
+
*/
|
|
135
|
+
export declare interface ViewerTheme {
|
|
136
|
+
/** Semantic UI colors. Each key maps to a `--pptx-<key>` CSS custom property. */
|
|
137
|
+
colors?: Partial<ViewerThemeColors>;
|
|
138
|
+
/** Base border-radius value (e.g. `"0.5rem"`, `"8px"`). */
|
|
139
|
+
radius?: string;
|
|
140
|
+
/**
|
|
141
|
+
* Escape hatch: arbitrary CSS custom properties to set on the viewer
|
|
142
|
+
* root element. Keys should include the `--` prefix.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* { "--my-custom-shadow": "0 4px 12px rgba(0,0,0,0.5)" }
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
cssVars?: Record<string, string>;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Theme configuration types for the PowerPoint viewer.
|
|
154
|
+
*
|
|
155
|
+
* All color values accept any valid CSS color string:
|
|
156
|
+
* hex (`#6366f1`), rgb (`rgb(99 102 241)`), hsl (`hsl(239 84% 67%)`),
|
|
157
|
+
* oklch (`oklch(0.585 0.233 277)`), named colors, etc.
|
|
158
|
+
*
|
|
159
|
+
* Framework-agnostic — shared by the React, Vue, and Angular bindings.
|
|
160
|
+
*/
|
|
161
|
+
/**
|
|
162
|
+
* Semantic color tokens for the viewer UI.
|
|
163
|
+
*
|
|
164
|
+
* These map to CSS custom properties (`--pptx-<token>`) and drive all
|
|
165
|
+
* UI component colors. The naming follows the shadcn/ui convention so
|
|
166
|
+
* that Tailwind + shadcn users get a familiar experience.
|
|
167
|
+
*/
|
|
168
|
+
export declare interface ViewerThemeColors {
|
|
169
|
+
/** Page / root background */
|
|
170
|
+
background: string;
|
|
171
|
+
/** Default text color */
|
|
172
|
+
foreground: string;
|
|
173
|
+
/** Card / panel surface */
|
|
174
|
+
card: string;
|
|
175
|
+
/** Text on card surfaces */
|
|
176
|
+
cardForeground: string;
|
|
177
|
+
/** Popover / dropdown surface */
|
|
178
|
+
popover: string;
|
|
179
|
+
/** Text inside popovers */
|
|
180
|
+
popoverForeground: string;
|
|
181
|
+
/** Primary action color (buttons, active indicators) */
|
|
182
|
+
primary: string;
|
|
183
|
+
/** Text on primary-colored backgrounds */
|
|
184
|
+
primaryForeground: string;
|
|
185
|
+
/** Secondary / subdued action color */
|
|
186
|
+
secondary: string;
|
|
187
|
+
/** Text on secondary backgrounds */
|
|
188
|
+
secondaryForeground: string;
|
|
189
|
+
/** Muted / disabled surface */
|
|
190
|
+
muted: string;
|
|
191
|
+
/** Text on muted surfaces (also used for secondary text) */
|
|
192
|
+
mutedForeground: string;
|
|
193
|
+
/** Accent / hover-highlight surface */
|
|
194
|
+
accent: string;
|
|
195
|
+
/** Text on accent surfaces */
|
|
196
|
+
accentForeground: string;
|
|
197
|
+
/** Destructive / danger action color */
|
|
198
|
+
destructive: string;
|
|
199
|
+
/** Text on destructive backgrounds */
|
|
200
|
+
destructiveForeground: string;
|
|
201
|
+
/** Default border color */
|
|
202
|
+
border: string;
|
|
203
|
+
/** Input field border color */
|
|
204
|
+
input: string;
|
|
205
|
+
/** Focus ring color */
|
|
206
|
+
ring: string;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { _ as r, d as a, f as e, g as i, h as o, l as m, m as t, p as l, t as n, u as h } from "./component-CacEu31z.js";
|
|
2
|
+
import { r as f } from "./translator-C44zS1dl.js";
|
|
3
|
+
import "./i18n.js";
|
|
4
|
+
export {
|
|
5
|
+
n as PowerPointViewer,
|
|
6
|
+
m as defaultCssVars,
|
|
7
|
+
h as defaultRadius,
|
|
8
|
+
a as defaultThemeColors,
|
|
9
|
+
f as registerTranslations,
|
|
10
|
+
e as themeToCssVars,
|
|
11
|
+
l as vermilionDarkColors,
|
|
12
|
+
t as vermilionDarkTheme,
|
|
13
|
+
o as vermilionLightColors,
|
|
14
|
+
i as vermilionLightTheme,
|
|
15
|
+
r as vermilionRadius
|
|
16
|
+
};
|