@alulore/kumiko 0.15.1 → 0.17.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.
Files changed (91) hide show
  1. package/dist/media-viewer/icons.d.ts +4 -0
  2. package/dist/media-viewer/icons.js +18 -0
  3. package/dist/media-viewer/index.d.ts +4 -0
  4. package/dist/media-viewer/index.js +3 -0
  5. package/dist/media-viewer/media-slide.d.ts +14 -0
  6. package/dist/media-viewer/media-slide.js +67 -0
  7. package/dist/media-viewer/media-viewer.css +611 -0
  8. package/dist/media-viewer/media-viewer.d.ts +17 -0
  9. package/dist/media-viewer/media-viewer.js +241 -0
  10. package/dist/media-viewer/pager-drag.d.ts +10 -0
  11. package/dist/media-viewer/pager-drag.js +53 -0
  12. package/dist/media-viewer/types.d.ts +58 -0
  13. package/dist/media-viewer/types.js +17 -0
  14. package/dist/media-viewer/video-controls.d.ts +3 -0
  15. package/dist/media-viewer/video-controls.js +62 -0
  16. package/dist/media-viewer/view-gesture.d.ts +74 -0
  17. package/dist/media-viewer/view-gesture.js +465 -0
  18. package/dist/media-viewer/viewer-chrome.d.ts +13 -0
  19. package/dist/media-viewer/viewer-chrome.js +35 -0
  20. package/dist/media-viewer/viewer-motion.d.ts +9 -0
  21. package/dist/media-viewer/viewer-motion.js +126 -0
  22. package/dist/media-viewer/zoom-pan.d.ts +35 -0
  23. package/dist/media-viewer/zoom-pan.js +102 -0
  24. package/dist/shortcuts/bindings.d.ts +44 -0
  25. package/dist/shortcuts/bindings.js +71 -0
  26. package/dist/shortcuts/capture.d.ts +7 -0
  27. package/dist/shortcuts/capture.js +92 -0
  28. package/dist/shortcuts/guard.d.ts +9 -0
  29. package/dist/shortcuts/guard.js +48 -0
  30. package/dist/shortcuts/help.d.ts +25 -0
  31. package/dist/shortcuts/help.js +26 -0
  32. package/dist/shortcuts/hints.d.ts +19 -0
  33. package/dist/shortcuts/hints.js +33 -0
  34. package/dist/shortcuts/index.d.ts +11 -0
  35. package/dist/shortcuts/index.js +11 -0
  36. package/dist/shortcuts/judge.d.ts +42 -0
  37. package/dist/shortcuts/judge.js +34 -0
  38. package/dist/shortcuts/keys.d.ts +11 -0
  39. package/dist/shortcuts/keys.js +89 -0
  40. package/dist/shortcuts/list.d.ts +16 -0
  41. package/dist/shortcuts/list.js +43 -0
  42. package/dist/shortcuts/notes.d.ts +28 -0
  43. package/dist/shortcuts/notes.js +27 -0
  44. package/dist/shortcuts/provider.d.ts +98 -0
  45. package/dist/shortcuts/provider.js +116 -0
  46. package/dist/shortcuts/rebinder.d.ts +23 -0
  47. package/dist/shortcuts/rebinder.js +84 -0
  48. package/dist/shortcuts/registration.d.ts +19 -0
  49. package/dist/shortcuts/registration.js +84 -0
  50. package/dist/shortcuts/shortcuts.css +171 -0
  51. package/dist/stored/index.d.ts +4 -0
  52. package/dist/stored/index.js +4 -0
  53. package/dist/stored/storage.d.ts +22 -0
  54. package/dist/stored/storage.js +10 -0
  55. package/dist/stored/stored.d.ts +93 -0
  56. package/dist/stored/stored.js +209 -0
  57. package/dist/stored/use-stored.d.ts +6 -0
  58. package/dist/stored/use-stored.js +12 -0
  59. package/dist/stored/validators.d.ts +6 -0
  60. package/dist/stored/validators.js +13 -0
  61. package/dist/titlebar/index.d.ts +2 -0
  62. package/dist/titlebar/index.js +2 -0
  63. package/dist/titlebar/titlebar-looks.d.ts +53 -0
  64. package/dist/titlebar/titlebar-looks.js +26 -0
  65. package/dist/titlebar/titlebar.css +561 -0
  66. package/dist/titlebar/titlebar.d.ts +54 -0
  67. package/dist/titlebar/titlebar.js +68 -0
  68. package/dist/undo/history.d.ts +62 -0
  69. package/dist/undo/history.js +151 -0
  70. package/dist/undo/index.d.ts +10 -0
  71. package/dist/undo/index.js +10 -0
  72. package/dist/undo/undo-adapter.d.ts +35 -0
  73. package/dist/undo/undo-adapter.js +35 -0
  74. package/dist/undo/undo-feedback.d.ts +28 -0
  75. package/dist/undo/undo-feedback.js +69 -0
  76. package/dist/undo/undo-keys.d.ts +32 -0
  77. package/dist/undo/undo-keys.js +76 -0
  78. package/dist/undo/undo-options.d.ts +51 -0
  79. package/dist/undo/undo-options.js +6 -0
  80. package/dist/undo/undo-panel.d.ts +23 -0
  81. package/dist/undo/undo-panel.js +56 -0
  82. package/dist/undo/undo-provider.d.ts +88 -0
  83. package/dist/undo/undo-provider.js +104 -0
  84. package/dist/undo/undo-reveal.d.ts +9 -0
  85. package/dist/undo/undo-reveal.js +45 -0
  86. package/dist/undo/undo-store.d.ts +89 -0
  87. package/dist/undo/undo-store.js +243 -0
  88. package/dist/undo/undo.css +135 -0
  89. package/dist/undo/use-undo-value.d.ts +43 -0
  90. package/dist/undo/use-undo-value.js +85 -0
  91. package/package.json +42 -1
@@ -0,0 +1,4 @@
1
+ export type IconName = "close" | "previous" | "next" | "fullscreen" | "download" | "play" | "pause" | "sound" | "muted" | "plus" | "minus";
2
+ export declare function Icon({ name }: {
3
+ name: IconName;
4
+ }): React.JSX.Element;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ const paths = {
3
+ close: "M6 6l12 12M18 6L6 18",
4
+ previous: "M15 5l-7 7 7 7",
5
+ next: "M9 5l7 7-7 7",
6
+ fullscreen: "M8 3H3v5M16 3h5v5M8 21H3v-5M16 21h5v-5",
7
+ download: "M12 3v12m0 0l-4-4m4 4l4-4M4 19h16",
8
+ play: "M8 5l11 7-11 7z",
9
+ pause: "M8 5v14M16 5v14",
10
+ sound: "M4 9v6h4l5 4V5L8 9zM17 8c1.5 1.2 1.5 6.8 0 8",
11
+ muted: "M4 9v6h4l5 4V5L8 9zM17 9l4 6M21 9l-4 6",
12
+ plus: "M12 5v14M5 12h14",
13
+ minus: "M5 12h14"
14
+ };
15
+ /* Strokes in the text colour, so they follow forced colours and any token. */
16
+ export function Icon({ name }) {
17
+ return (_jsx("svg", { "data-mv-icon": "", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: paths[name] }) }));
18
+ }
@@ -0,0 +1,4 @@
1
+ export { MediaViewer, type MediaViewerProps } from "./media-viewer";
2
+ export { behaviourDefaults, lookDefaults, type Background, type Chrome, type DoubleTap, type Indicator, type Layout, type MediaViewerBehaviour, type MediaViewerItem, type MediaViewerLook, type OpenMotion, type PagingMotion, type VideoControls, type WheelMode, type ZoomedDrag } from "./types";
3
+ export { FIT, actualScale, clampPan, fitSize, maxScale, panLimits, zoomTo, type View, type ZoomAnchor } from "./zoom-pan";
4
+ export type { OriginOf } from "./viewer-motion";
@@ -0,0 +1,3 @@
1
+ export { MediaViewer } from "./media-viewer";
2
+ export { behaviourDefaults, lookDefaults } from "./types";
3
+ export { FIT, actualScale, clampPan, fitSize, maxScale, panLimits, zoomTo } from "./zoom-pan";
@@ -0,0 +1,14 @@
1
+ import type { MediaViewerItem, VideoControls as VideoControlsMode } from "./types";
2
+ import { ViewGesture, type GestureHooks, type GestureOptions } from "./view-gesture";
3
+ export type SlideSignals = Omit<GestureHooks, "natural">;
4
+ export interface MediaSlideProps {
5
+ item: MediaViewerItem;
6
+ /** Only the slide in view takes gestures; the others rest at fit. */
7
+ active: boolean;
8
+ options: GestureOptions;
9
+ signals: SlideSignals;
10
+ videoControls: VideoControlsMode;
11
+ /** Receives the slide's gesture while it is active, so buttons and keys can zoom it. */
12
+ gestureRef: React.RefObject<ViewGesture | null>;
13
+ }
14
+ export declare function MediaSlide(props: MediaSlideProps): React.JSX.Element;
@@ -0,0 +1,67 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef } from "react";
3
+ import { VideoControls } from "./video-controls";
4
+ import { ViewGesture } from "./view-gesture";
5
+ function naturalOf(item, media) {
6
+ if (media instanceof HTMLImageElement && media.naturalWidth > 0) {
7
+ return { w: media.naturalWidth, h: media.naturalHeight };
8
+ }
9
+ if (media instanceof HTMLVideoElement && media.videoWidth > 0) {
10
+ return { w: media.videoWidth, h: media.videoHeight };
11
+ }
12
+ return { w: item.width ?? 0, h: item.height ?? 0 };
13
+ }
14
+ /* Keeps the newest value in a ref, so a gesture made once always reads current props. */
15
+ function useLatest(value) {
16
+ const ref = useRef(value);
17
+ useEffect(() => {
18
+ ref.current = value;
19
+ });
20
+ return ref;
21
+ }
22
+ function useGesture(stage, media, props) {
23
+ const options = useLatest(props.options);
24
+ const signals = useLatest(props.signals);
25
+ const { active, item, gestureRef } = props;
26
+ useEffect(() => {
27
+ const el = stage.current;
28
+ if (!active || !el) {
29
+ return undefined;
30
+ }
31
+ const hooks = () => ({
32
+ ...signals.current,
33
+ natural: () => naturalOf(item, media.current)
34
+ });
35
+ const gesture = new ViewGesture(el, () => options.current, hooks);
36
+ gestureRef.current = gesture;
37
+ return () => {
38
+ gesture.destroy();
39
+ gestureRef.current = null;
40
+ };
41
+ }, [active, item, gestureRef, stage, media, options, signals]);
42
+ }
43
+ function useVideoPause(video, active) {
44
+ useEffect(() => {
45
+ if (!active) {
46
+ video.current?.pause();
47
+ }
48
+ }, [active, video]);
49
+ }
50
+ function Picture({ item, media }) {
51
+ return (_jsx("img", { ref: media, "data-mv-media": "", src: item.src, alt: item.name, width: item.width, height: item.height, draggable: false }));
52
+ }
53
+ function Clip({ item, video, controls }) {
54
+ const ratio = item.width && item.height ? item.width / item.height : 16 / 9;
55
+ const style = { "--mv-ratio": String(ratio) };
56
+ return (_jsxs("div", { "data-mv-clip": "", style: style, children: [_jsx("video", { ref: video, "data-mv-media": "", src: item.src, poster: item.poster, "aria-label": item.name, controls: controls === "native", playsInline: true, loop: true, preload: "metadata" }), controls === "custom" ? _jsx(VideoControls, { video: video }) : null] }));
57
+ }
58
+ export function MediaSlide(props) {
59
+ const { item, active, videoControls } = props;
60
+ const stage = useRef(null);
61
+ const image = useRef(null);
62
+ const video = useRef(null);
63
+ const isVideo = item.kind === "video";
64
+ useGesture(stage, isVideo ? video : image, props);
65
+ useVideoPause(video, active);
66
+ return (_jsx("div", { ref: stage, "data-mv-stage": "", "data-active": active ? "" : undefined, "data-kind": isVideo ? "video" : "image", "data-native-controls": isVideo && videoControls === "native" ? "" : undefined, children: isVideo ? (_jsx(Clip, { item: item, video: video, controls: videoControls })) : (_jsx(Picture, { item: item, media: image })) }));
67
+ }