@open-slide/core 1.8.0 → 1.10.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/dist/{build-CCZDC8eF.js → build-ZM7IfDO-.js} +1 -1
- package/dist/cli/bin.js +3 -3
- package/dist/{config-C7sZtiY2.js → config-BAZeaz2P.js} +248 -232
- package/dist/{config-D1bANimZ.d.ts → config-mwmC1XI1.d.ts} +6 -1
- package/dist/{dev-kLS_4CAI.js → dev-BQkNTG_t.js} +1 -1
- package/dist/format-BvBmqbNW.js +1581 -0
- package/dist/index.d.ts +24 -4
- package/dist/index.js +120 -10
- package/dist/locale/index.d.ts +1 -1
- package/dist/locale/index.js +1 -1135
- package/dist/{preview-DUkOjOx8.js → preview-D8hUtbRA.js} +1 -1
- package/dist/{types-Bvk1pM70.d.ts → types-D_q_ylIe.d.ts} +19 -0
- package/dist/vite/index.d.ts +2 -2
- package/dist/vite/index.js +1 -1
- package/package.json +2 -1
- package/skills/slide-authoring/SKILL.md +42 -0
- package/src/app/components/language-toggle.tsx +39 -0
- package/src/app/components/player.tsx +30 -11
- package/src/app/components/pptx-progress-toast.tsx +32 -0
- package/src/app/components/sidebar/sidebar-footer.tsx +51 -0
- package/src/app/components/sidebar/sidebar.tsx +8 -1
- package/src/app/components/slide-transition-layer.tsx +36 -4
- package/src/app/components/thumbnail-rail.tsx +77 -15
- package/src/app/lib/design-presets.ts +1 -1
- package/src/app/lib/export-pptx.ts +284 -0
- package/src/app/lib/locale-store.ts +67 -0
- package/src/app/lib/step-context.tsx +169 -0
- package/src/app/lib/use-locale.ts +4 -16
- package/src/app/routes/slide.tsx +70 -0
- package/src/app/virtual.d.ts +1 -0
- package/src/locale/en.ts +21 -0
- package/src/locale/ja.ts +22 -0
- package/src/locale/types.ts +21 -0
- package/src/locale/zh-cn.ts +20 -0
- package/src/locale/zh-tw.ts +20 -0
- package/dist/en-hyGpmL1O.js +0 -375
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { Locale, Plural } from "./types-
|
|
2
|
-
import { OpenSlideConfig } from "./config-
|
|
3
|
-
import { CSSProperties, ComponentType, HTMLAttributes } from "react";
|
|
1
|
+
import { Locale, Plural } from "./types-D_q_ylIe.js";
|
|
2
|
+
import { OpenSlideConfig } from "./config-mwmC1XI1.js";
|
|
3
|
+
import { CSSProperties, ComponentType, HTMLAttributes, PropsWithChildren } from "react";
|
|
4
4
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
5
|
+
import * as react_jsx_runtime3 from "react/jsx-runtime";
|
|
6
|
+
import * as react_jsx_runtime4 from "react/jsx-runtime";
|
|
5
7
|
|
|
6
8
|
//#region src/app/components/image-placeholder.d.ts
|
|
7
9
|
type ImagePlaceholderProps = {
|
|
@@ -89,4 +91,22 @@ declare const CANVAS_WIDTH = 1920;
|
|
|
89
91
|
declare const CANVAS_HEIGHT = 1080;
|
|
90
92
|
|
|
91
93
|
//#endregion
|
|
92
|
-
|
|
94
|
+
//#region src/app/lib/step-context.d.ts
|
|
95
|
+
type StepsProps = PropsWithChildren;
|
|
96
|
+
declare function Steps({
|
|
97
|
+
children
|
|
98
|
+
}: StepsProps): react_jsx_runtime3.JSX.Element;
|
|
99
|
+
type StepProps = PropsWithChildren<{
|
|
100
|
+
duration?: number;
|
|
101
|
+
}>;
|
|
102
|
+
type InternalStepProps = StepProps & {
|
|
103
|
+
_revealed?: boolean;
|
|
104
|
+
};
|
|
105
|
+
declare function Step({
|
|
106
|
+
children,
|
|
107
|
+
duration,
|
|
108
|
+
_revealed
|
|
109
|
+
}: InternalStepProps): react_jsx_runtime4.JSX.Element;
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
export { CANVAS_HEIGHT, CANVAS_WIDTH, DesignFonts, DesignPalette, DesignSystem, DesignTypeScale, ImagePlaceholder, ImagePlaceholderProps, Locale, OpenSlideConfig, Page, Plural, SlideMeta, SlideModule, SlideTransition, Step, StepProps, Steps, StepsProps, TransitionPhase, cssVarsToString, defaultDesign, designToCssVars, useSlidePageNumber };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { en } from "./
|
|
1
|
+
import { en, ja, zhCN, zhTW } from "./format-BvBmqbNW.js";
|
|
2
2
|
import { cssVarsToString, defaultDesign, designToCssVars } from "./design-cpzS8aud.js";
|
|
3
|
-
import { createContext, useContext, useRef, useState } from "react";
|
|
3
|
+
import { Children, cloneElement, createContext, isValidElement, useContext, useEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
4
4
|
import { toast } from "sonner";
|
|
5
5
|
import config from "virtual:open-slide/config";
|
|
6
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
|
|
8
8
|
//#region src/app/lib/assets.ts
|
|
9
9
|
async function listAssets(slideId) {
|
|
@@ -79,11 +79,45 @@ function renamedCopy(file, taken) {
|
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/app/lib/locale-store.ts
|
|
84
|
+
const LOCALES = {
|
|
85
|
+
en,
|
|
86
|
+
"zh-TW": zhTW,
|
|
87
|
+
"zh-CN": zhCN,
|
|
88
|
+
ja
|
|
89
|
+
};
|
|
90
|
+
const STORAGE_KEY = "open-slide:locale";
|
|
91
|
+
const configLocale = config.locale;
|
|
92
|
+
function isLocaleId(value) {
|
|
93
|
+
return value === "en" || value === "zh-TW" || value === "zh-CN" || value === "ja";
|
|
94
|
+
}
|
|
95
|
+
function readStored() {
|
|
96
|
+
try {
|
|
97
|
+
const stored = localStorage.getItem(STORAGE_KEY);
|
|
98
|
+
if (isLocaleId(stored)) return LOCALES[stored];
|
|
99
|
+
} catch {}
|
|
100
|
+
return configLocale ?? en;
|
|
101
|
+
}
|
|
102
|
+
let current = readStored();
|
|
103
|
+
const listeners = new Set();
|
|
104
|
+
function subscribe(listener) {
|
|
105
|
+
listeners.add(listener);
|
|
106
|
+
return () => {
|
|
107
|
+
listeners.delete(listener);
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function getSnapshot() {
|
|
111
|
+
return current;
|
|
112
|
+
}
|
|
113
|
+
function useLocaleValue() {
|
|
114
|
+
return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
115
|
+
}
|
|
116
|
+
|
|
82
117
|
//#endregion
|
|
83
118
|
//#region src/app/lib/use-locale.ts
|
|
84
|
-
const resolved = config.locale ?? en;
|
|
85
119
|
function useLocale() {
|
|
86
|
-
return
|
|
120
|
+
return useLocaleValue();
|
|
87
121
|
}
|
|
88
122
|
|
|
89
123
|
//#endregion
|
|
@@ -299,10 +333,10 @@ function PlaceholderIcon() {
|
|
|
299
333
|
|
|
300
334
|
//#endregion
|
|
301
335
|
//#region src/app/lib/page-context.tsx
|
|
302
|
-
const GLOBAL_KEY = "__open_slide_page_context__";
|
|
303
|
-
const g = globalThis;
|
|
304
|
-
if (!g[GLOBAL_KEY]) g[GLOBAL_KEY] = createContext(null);
|
|
305
|
-
const SlidePageContext = g[GLOBAL_KEY];
|
|
336
|
+
const GLOBAL_KEY$1 = "__open_slide_page_context__";
|
|
337
|
+
const g$1 = globalThis;
|
|
338
|
+
if (!g$1[GLOBAL_KEY$1]) g$1[GLOBAL_KEY$1] = createContext(null);
|
|
339
|
+
const SlidePageContext = g$1[GLOBAL_KEY$1];
|
|
306
340
|
function useSlidePageNumber() {
|
|
307
341
|
const ctx = useContext(SlidePageContext);
|
|
308
342
|
if (!ctx) throw new Error("useSlidePageNumber must be called from a slide page rendered by @open-slide/core");
|
|
@@ -318,4 +352,80 @@ const CANVAS_WIDTH = 1920;
|
|
|
318
352
|
const CANVAS_HEIGHT = 1080;
|
|
319
353
|
|
|
320
354
|
//#endregion
|
|
321
|
-
|
|
355
|
+
//#region src/app/lib/use-prefers-reduced-motion.ts
|
|
356
|
+
const QUERY = "(prefers-reduced-motion: reduce)";
|
|
357
|
+
function usePrefersReducedMotion() {
|
|
358
|
+
const [reduce, setReduce] = useState(() => {
|
|
359
|
+
if (typeof window === "undefined") return false;
|
|
360
|
+
return window.matchMedia(QUERY).matches;
|
|
361
|
+
});
|
|
362
|
+
useEffect(() => {
|
|
363
|
+
const mql = window.matchMedia(QUERY);
|
|
364
|
+
const onChange = (e) => setReduce(e.matches);
|
|
365
|
+
mql.addEventListener("change", onChange);
|
|
366
|
+
return () => mql.removeEventListener("change", onChange);
|
|
367
|
+
}, []);
|
|
368
|
+
return reduce;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
//#endregion
|
|
372
|
+
//#region src/app/lib/step-context.tsx
|
|
373
|
+
const GLOBAL_KEY = "__open_slide_step_host_context__";
|
|
374
|
+
const g = globalThis;
|
|
375
|
+
if (!g[GLOBAL_KEY]) g[GLOBAL_KEY] = createContext(null);
|
|
376
|
+
const StepHostContext = g[GLOBAL_KEY];
|
|
377
|
+
function Steps({ children }) {
|
|
378
|
+
const host = useContext(StepHostContext);
|
|
379
|
+
const flat = Children.toArray(children);
|
|
380
|
+
const stepCount = flat.filter((c) => isValidElement(c) && c.type === Step).length;
|
|
381
|
+
const initial = host?.entryDirection === "forward" ? 0 : stepCount;
|
|
382
|
+
const revealedRef = useRef(initial);
|
|
383
|
+
const [revealed, setRevealed] = useState(initial);
|
|
384
|
+
useEffect(() => {
|
|
385
|
+
if (!host) return;
|
|
386
|
+
const ctrl = {
|
|
387
|
+
advance: () => {
|
|
388
|
+
if (revealedRef.current >= stepCount) return false;
|
|
389
|
+
revealedRef.current += 1;
|
|
390
|
+
setRevealed(revealedRef.current);
|
|
391
|
+
return true;
|
|
392
|
+
},
|
|
393
|
+
retreat: () => {
|
|
394
|
+
if (revealedRef.current <= 0) return false;
|
|
395
|
+
revealedRef.current -= 1;
|
|
396
|
+
setRevealed(revealedRef.current);
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
return host.register(ctrl);
|
|
401
|
+
}, [host, stepCount]);
|
|
402
|
+
const effectiveRevealed = host ? revealed : stepCount;
|
|
403
|
+
let stepIdx = 0;
|
|
404
|
+
return /* @__PURE__ */ jsx(Fragment, { children: flat.map((child, key) => {
|
|
405
|
+
if (isValidElement(child) && child.type === Step) {
|
|
406
|
+
const idx = stepIdx++;
|
|
407
|
+
return cloneElement(child, {
|
|
408
|
+
key: child.key ?? key,
|
|
409
|
+
_revealed: idx < effectiveRevealed
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
return child;
|
|
413
|
+
}) });
|
|
414
|
+
}
|
|
415
|
+
function Step({ children, duration = 180, _revealed }) {
|
|
416
|
+
const reduceMotion = usePrefersReducedMotion();
|
|
417
|
+
const revealed = _revealed ?? true;
|
|
418
|
+
const ms = reduceMotion ? 0 : duration;
|
|
419
|
+
return /* @__PURE__ */ jsx("div", {
|
|
420
|
+
"data-osd-step": revealed ? "revealed" : "pending",
|
|
421
|
+
style: {
|
|
422
|
+
opacity: revealed ? 1 : 0,
|
|
423
|
+
visibility: revealed ? "visible" : "hidden",
|
|
424
|
+
transition: `opacity ${ms}ms cubic-bezier(0, 0, 0.2, 1)`
|
|
425
|
+
},
|
|
426
|
+
children
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
//#endregion
|
|
431
|
+
export { CANVAS_HEIGHT, CANVAS_WIDTH, ImagePlaceholder, Step, Steps, cssVarsToString, defaultDesign, designToCssVars, useSlidePageNumber };
|
package/dist/locale/index.d.ts
CHANGED