@embedpdf/viewer-chrome 3.0.0-next.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 +215 -0
- package/README.md +317 -0
- package/dist/chrome.cjs +228 -0
- package/dist/chrome.cjs.map +1 -0
- package/dist/chrome.d.cts +36 -0
- package/dist/chrome.d.ts +36 -0
- package/dist/chrome.js +224 -0
- package/dist/chrome.js.map +1 -0
- package/dist/commands.cjs +497 -0
- package/dist/commands.cjs.map +1 -0
- package/dist/commands.d.cts +22 -0
- package/dist/commands.d.ts +22 -0
- package/dist/commands.js +494 -0
- package/dist/commands.js.map +1 -0
- package/dist/es-C5084JO6.cjs +166 -0
- package/dist/es-C5084JO6.cjs.map +1 -0
- package/dist/es-D0PzYE9Z.js +166 -0
- package/dist/es-D0PzYE9Z.js.map +1 -0
- package/dist/index.cjs +3700 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +121 -0
- package/dist/index.d.ts +121 -0
- package/dist/index.js +3529 -0
- package/dist/index.js.map +1 -0
- package/package.json +61 -0
- package/src/styles.css +132 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { defaultChrome } from "./chrome.cjs";
|
|
2
|
+
import { defaultCommands } from "./commands.cjs";
|
|
3
|
+
import { AddItemSpec, BarChild, BarGroup, BarItem, BarSchema, BarSections, ChromeHelpers, ChromeHelpers as ChromeHelpers$1, ChromeSchema, ChromeSchema as ChromeSchema$1, CustomItem, Importance, MenuSchema, MenuSection, Variant, addItem, chromeHelpers, custom, defineChrome, group, item, removeItems, replaceItem, validateChrome } from "@embedpdf/react/toolbar";
|
|
4
|
+
import { CommandDef, CommandDef as CommandDef$1, CommandsToken, ResolvedCommand, ResolvedCommand as ResolvedCommand$1 } from "@embedpdf/react/commands";
|
|
5
|
+
import { ReactNode } from "react";
|
|
6
|
+
import { CapabilityToken, CapabilityToken as CapabilityToken$1, DocInfo, DocumentsCapability, DocumentsCapability as DocumentsCapability$1, DocumentsToken, Engine, Engine as Engine$1, EngineFactory, EngineFactory as EngineFactory$1, InitialDocument, InitialDocument as InitialDocument$1, Kernel, Unsubscribe, Unsubscribe as Unsubscribe$1 } from "@embedpdf/react/runtime";
|
|
7
|
+
import { I18nToken, TranslationDictionary } from "@embedpdf/react/i18n";
|
|
8
|
+
import { AnnotationToken } from "@embedpdf/react/annotation";
|
|
9
|
+
import { StageToken } from "@embedpdf/react/stage";
|
|
10
|
+
import { SearchToken } from "@embedpdf/react/search";
|
|
11
|
+
import { SelectionToken } from "@embedpdf/react/selection";
|
|
12
|
+
import { FormToken } from "@embedpdf/react/form";
|
|
13
|
+
import { RedactionToken } from "@embedpdf/react/redaction";
|
|
14
|
+
import { InteractionToken } from "@embedpdf/react/interaction";
|
|
15
|
+
import { ShellToken } from "@embedpdf/react/shell";
|
|
16
|
+
import { MetadataToken } from "@embedpdf/react/metadata";
|
|
17
|
+
//#region src/handle.d.ts
|
|
18
|
+
/** `get`/`tryGet` bound to one document (see {@link ViewerHandle.forDocument}). */
|
|
19
|
+
interface ScopedViewerHandle {
|
|
20
|
+
get<T>(token: CapabilityToken$1<T>): T;
|
|
21
|
+
tryGet<T>(token: CapabilityToken$1<T>): T | null;
|
|
22
|
+
}
|
|
23
|
+
interface ViewerHandle extends ScopedViewerHandle {
|
|
24
|
+
/** The document registry — the tab model: list/open/close/setActive/…. */
|
|
25
|
+
readonly documents: DocumentsCapability$1;
|
|
26
|
+
/** `get`/`tryGet` with document-scoped tokens bound to `documentId`
|
|
27
|
+
* instead of the active document. */
|
|
28
|
+
forDocument(documentId: string): ScopedViewerHandle;
|
|
29
|
+
/**
|
|
30
|
+
* Re-run `select` on every kernel change; call `cb` when the selected value
|
|
31
|
+
* really changed (`isEqual`, default `Object.is` — capability getters return
|
|
32
|
+
* stable references between model changes, so identity works). Returns the
|
|
33
|
+
* unsubscribe. This is the ONLY reactivity primitive; DOM events on the
|
|
34
|
+
* element are sugar over it.
|
|
35
|
+
*/
|
|
36
|
+
watch<T>(select: () => T, cb: (value: T, previous: T) => void, isEqual?: (a: T, b: T) => boolean): Unsubscribe$1;
|
|
37
|
+
execute(id: string, documentId?: string): void;
|
|
38
|
+
resolve(id: string, documentId?: string): ResolvedCommand$1 | null;
|
|
39
|
+
/** `watch` sugar for one command's resolved state (label/icon/enabled/active). */
|
|
40
|
+
watchCommand(id: string, cb: (cmd: ResolvedCommand$1 | null) => void): Unsubscribe$1;
|
|
41
|
+
}
|
|
42
|
+
declare function createViewerHandle(kernel: Kernel): ViewerHandle;
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/ui/icons.d.ts
|
|
45
|
+
type PathSpec = string | {
|
|
46
|
+
d: string;
|
|
47
|
+
/** Fill paint: `true` = currentColor (a filled glyph part); a slot
|
|
48
|
+
* name = that accent color (nothing when the accent is absent). */
|
|
49
|
+
fill?: boolean | 'primary' | 'secondary';
|
|
50
|
+
/** Stroke paint: a slot name = that accent color (currentColor when
|
|
51
|
+
* the accent is absent). */
|
|
52
|
+
stroke?: 'primary' | 'secondary';
|
|
53
|
+
};
|
|
54
|
+
/** A registrable icon: 24×24 stroke path data (Tabler/Lucide-style), exactly
|
|
55
|
+
* the shape of the built-in set — user icons are not a lesser kind. */
|
|
56
|
+
type IconDef = readonly PathSpec[];
|
|
57
|
+
declare const ICON_PATHS: Record<string, readonly PathSpec[]>;
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/ui/theme.d.ts
|
|
60
|
+
type ThemeMode = 'light' | 'dark';
|
|
61
|
+
type ThemePreference = ThemeMode | 'system';
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/viewer.d.ts
|
|
64
|
+
/**
|
|
65
|
+
* The customization surface — identical in the vanilla snippet and every
|
|
66
|
+
* framework wrapper. See README.md for the ladder this implements.
|
|
67
|
+
*/
|
|
68
|
+
interface ViewerCustomization {
|
|
69
|
+
/** ADDITIVE over the default vocabulary; a colliding id overrides. */
|
|
70
|
+
commands?: readonly CommandDef$1[];
|
|
71
|
+
/** ADDITIVE 24×24 stroke icons by name; a colliding name overrides. */
|
|
72
|
+
icons?: Readonly<Record<string, IconDef>>;
|
|
73
|
+
/** Per-locale translation overrides/additions; dotted keys expand. A code
|
|
74
|
+
* with no built-in pack becomes a new locale (falls back to English). */
|
|
75
|
+
strings?: Readonly<Record<string, TranslationDictionary>>;
|
|
76
|
+
/** 'auto' (default) negotiates from the browser languages. */
|
|
77
|
+
locale?: 'auto' | (string & {});
|
|
78
|
+
/** Feature gating: a disabled category vanishes from every surface. */
|
|
79
|
+
disabledCategories?: readonly string[];
|
|
80
|
+
/** The structure — a value you OWN: the default (pass nothing), a transform
|
|
81
|
+
* of it, or your own schema. Never merged. */
|
|
82
|
+
chrome?: ChromeSchema$1 | ((base: ChromeSchema$1, helpers: ChromeHelpers$1) => ChromeSchema$1);
|
|
83
|
+
/** Light/dark preference (string shorthand), or the full theme config with
|
|
84
|
+
* `--ep-*` token overrides. Tokens are applied by the DELIVERY (the custom
|
|
85
|
+
* element adopts them into its shadow root); direct consumers of this
|
|
86
|
+
* package set the `--ep-*` variables in their own CSS instead. */
|
|
87
|
+
theme?: ThemePreference | ThemeConfig;
|
|
88
|
+
}
|
|
89
|
+
/** Token overrides — names WITHOUT the `--ep-` prefix ('accent', 'surface'…). */
|
|
90
|
+
type ThemeTokens = Readonly<Record<string, string>>;
|
|
91
|
+
interface ThemeConfig {
|
|
92
|
+
/** 'system' (default) follows the OS. */
|
|
93
|
+
preference?: ThemePreference;
|
|
94
|
+
/** Applied in BOTH modes (a later sheet: wins over the defaults). */
|
|
95
|
+
tokens?: ThemeTokens;
|
|
96
|
+
/** Dark-mode-only overrides, applied over `tokens`. */
|
|
97
|
+
dark?: ThemeTokens;
|
|
98
|
+
}
|
|
99
|
+
/** Normalize the shorthand — deliveries use this to read one shape. */
|
|
100
|
+
declare const themeConfigOf: (theme: ThemePreference | ThemeConfig | undefined) => ThemeConfig;
|
|
101
|
+
interface FullViewerProps extends ViewerCustomization {
|
|
102
|
+
/** Instance (borrowed) or thunk (viewer-owned) — the Viewer's own contract. */
|
|
103
|
+
engine: Engine$1 | EngineFactory$1;
|
|
104
|
+
/** Documents to open at mount; more arrive via the tab bar's open button. */
|
|
105
|
+
initialDocuments?: InitialDocument$1[];
|
|
106
|
+
/** Shown while the workspace boots. Default: a translated pulse line. */
|
|
107
|
+
fallback?: ReactNode;
|
|
108
|
+
/** Where the theme's `.dark` class goes — a DELIVERY concern, not user
|
|
109
|
+
* config: the custom element passes its shadow wrapper so theming never
|
|
110
|
+
* touches the host page. Default: document.documentElement. */
|
|
111
|
+
themeTarget?: HTMLElement | null;
|
|
112
|
+
/** Called once the workspace kernel is live, with the viewer handle — the
|
|
113
|
+
* DRIVE surface (`el.viewer` on the custom element, `onReady` on the
|
|
114
|
+
* wrappers). Capabilities resolve from the moment this fires; document-
|
|
115
|
+
* scoped calls simply await their document. */
|
|
116
|
+
onViewer?: (viewer: ViewerHandle) => void;
|
|
117
|
+
}
|
|
118
|
+
declare function FullViewer({ engine, initialDocuments, fallback, commands, icons, strings, locale, disabledCategories, chrome, theme, themeTarget, onViewer }: FullViewerProps): import("react/jsx-runtime").JSX.Element;
|
|
119
|
+
//#endregion
|
|
120
|
+
export { type AddItemSpec, AnnotationToken, type BarChild, type BarGroup, type BarItem, type BarSchema, type BarSections, type CapabilityToken, type ChromeHelpers, type ChromeSchema, type CommandDef, CommandsToken, type CustomItem, type DocInfo, type DocumentsCapability, DocumentsToken, type Engine, type EngineFactory, FormToken, FullViewer, type FullViewerProps, I18nToken, type IconDef, type Importance, type InitialDocument, InteractionToken, type MenuSchema, type MenuSection, MetadataToken, type PathSpec, RedactionToken, type ResolvedCommand, type ScopedViewerHandle, SearchToken, SelectionToken, ShellToken, StageToken, type ThemeConfig, type ThemeMode, type ThemePreference, type ThemeTokens, type Unsubscribe, type Variant, type ViewerCustomization, type ViewerHandle, addItem, chromeHelpers, createViewerHandle, custom, defaultChrome, defaultCommands, ICON_PATHS as defaultIcons, defineChrome, group, item, removeItems, replaceItem, themeConfigOf, validateChrome };
|
|
121
|
+
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { defaultChrome } from "./chrome.js";
|
|
2
|
+
import { defaultCommands } from "./commands.js";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { CapabilityToken, CapabilityToken as CapabilityToken$1, DocInfo, DocumentsCapability, DocumentsCapability as DocumentsCapability$1, DocumentsToken, Engine, Engine as Engine$1, EngineFactory, EngineFactory as EngineFactory$1, InitialDocument, InitialDocument as InitialDocument$1, Kernel, Unsubscribe, Unsubscribe as Unsubscribe$1 } from "@embedpdf/react/runtime";
|
|
5
|
+
import { StageToken } from "@embedpdf/react/stage";
|
|
6
|
+
import { InteractionToken } from "@embedpdf/react/interaction";
|
|
7
|
+
import { SelectionToken } from "@embedpdf/react/selection";
|
|
8
|
+
import { AnnotationToken } from "@embedpdf/react/annotation";
|
|
9
|
+
import { RedactionToken } from "@embedpdf/react/redaction";
|
|
10
|
+
import { FormToken } from "@embedpdf/react/form";
|
|
11
|
+
import { SearchToken } from "@embedpdf/react/search";
|
|
12
|
+
import { I18nToken, TranslationDictionary } from "@embedpdf/react/i18n";
|
|
13
|
+
import { CommandDef, CommandDef as CommandDef$1, CommandsToken, ResolvedCommand, ResolvedCommand as ResolvedCommand$1 } from "@embedpdf/react/commands";
|
|
14
|
+
import { ShellToken } from "@embedpdf/react/shell";
|
|
15
|
+
import { AddItemSpec, BarChild, BarGroup, BarItem, BarSchema, BarSections, ChromeHelpers, ChromeHelpers as ChromeHelpers$1, ChromeSchema, ChromeSchema as ChromeSchema$1, CustomItem, Importance, MenuSchema, MenuSection, Variant, addItem, chromeHelpers, custom, defineChrome, group, item, removeItems, replaceItem, validateChrome } from "@embedpdf/react/toolbar";
|
|
16
|
+
import { MetadataToken } from "@embedpdf/react/metadata";
|
|
17
|
+
//#region src/handle.d.ts
|
|
18
|
+
/** `get`/`tryGet` bound to one document (see {@link ViewerHandle.forDocument}). */
|
|
19
|
+
interface ScopedViewerHandle {
|
|
20
|
+
get<T>(token: CapabilityToken$1<T>): T;
|
|
21
|
+
tryGet<T>(token: CapabilityToken$1<T>): T | null;
|
|
22
|
+
}
|
|
23
|
+
interface ViewerHandle extends ScopedViewerHandle {
|
|
24
|
+
/** The document registry — the tab model: list/open/close/setActive/…. */
|
|
25
|
+
readonly documents: DocumentsCapability$1;
|
|
26
|
+
/** `get`/`tryGet` with document-scoped tokens bound to `documentId`
|
|
27
|
+
* instead of the active document. */
|
|
28
|
+
forDocument(documentId: string): ScopedViewerHandle;
|
|
29
|
+
/**
|
|
30
|
+
* Re-run `select` on every kernel change; call `cb` when the selected value
|
|
31
|
+
* really changed (`isEqual`, default `Object.is` — capability getters return
|
|
32
|
+
* stable references between model changes, so identity works). Returns the
|
|
33
|
+
* unsubscribe. This is the ONLY reactivity primitive; DOM events on the
|
|
34
|
+
* element are sugar over it.
|
|
35
|
+
*/
|
|
36
|
+
watch<T>(select: () => T, cb: (value: T, previous: T) => void, isEqual?: (a: T, b: T) => boolean): Unsubscribe$1;
|
|
37
|
+
execute(id: string, documentId?: string): void;
|
|
38
|
+
resolve(id: string, documentId?: string): ResolvedCommand$1 | null;
|
|
39
|
+
/** `watch` sugar for one command's resolved state (label/icon/enabled/active). */
|
|
40
|
+
watchCommand(id: string, cb: (cmd: ResolvedCommand$1 | null) => void): Unsubscribe$1;
|
|
41
|
+
}
|
|
42
|
+
declare function createViewerHandle(kernel: Kernel): ViewerHandle;
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/ui/icons.d.ts
|
|
45
|
+
type PathSpec = string | {
|
|
46
|
+
d: string;
|
|
47
|
+
/** Fill paint: `true` = currentColor (a filled glyph part); a slot
|
|
48
|
+
* name = that accent color (nothing when the accent is absent). */
|
|
49
|
+
fill?: boolean | 'primary' | 'secondary';
|
|
50
|
+
/** Stroke paint: a slot name = that accent color (currentColor when
|
|
51
|
+
* the accent is absent). */
|
|
52
|
+
stroke?: 'primary' | 'secondary';
|
|
53
|
+
};
|
|
54
|
+
/** A registrable icon: 24×24 stroke path data (Tabler/Lucide-style), exactly
|
|
55
|
+
* the shape of the built-in set — user icons are not a lesser kind. */
|
|
56
|
+
type IconDef = readonly PathSpec[];
|
|
57
|
+
declare const ICON_PATHS: Record<string, readonly PathSpec[]>;
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/ui/theme.d.ts
|
|
60
|
+
type ThemeMode = 'light' | 'dark';
|
|
61
|
+
type ThemePreference = ThemeMode | 'system';
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/viewer.d.ts
|
|
64
|
+
/**
|
|
65
|
+
* The customization surface — identical in the vanilla snippet and every
|
|
66
|
+
* framework wrapper. See README.md for the ladder this implements.
|
|
67
|
+
*/
|
|
68
|
+
interface ViewerCustomization {
|
|
69
|
+
/** ADDITIVE over the default vocabulary; a colliding id overrides. */
|
|
70
|
+
commands?: readonly CommandDef$1[];
|
|
71
|
+
/** ADDITIVE 24×24 stroke icons by name; a colliding name overrides. */
|
|
72
|
+
icons?: Readonly<Record<string, IconDef>>;
|
|
73
|
+
/** Per-locale translation overrides/additions; dotted keys expand. A code
|
|
74
|
+
* with no built-in pack becomes a new locale (falls back to English). */
|
|
75
|
+
strings?: Readonly<Record<string, TranslationDictionary>>;
|
|
76
|
+
/** 'auto' (default) negotiates from the browser languages. */
|
|
77
|
+
locale?: 'auto' | (string & {});
|
|
78
|
+
/** Feature gating: a disabled category vanishes from every surface. */
|
|
79
|
+
disabledCategories?: readonly string[];
|
|
80
|
+
/** The structure — a value you OWN: the default (pass nothing), a transform
|
|
81
|
+
* of it, or your own schema. Never merged. */
|
|
82
|
+
chrome?: ChromeSchema$1 | ((base: ChromeSchema$1, helpers: ChromeHelpers$1) => ChromeSchema$1);
|
|
83
|
+
/** Light/dark preference (string shorthand), or the full theme config with
|
|
84
|
+
* `--ep-*` token overrides. Tokens are applied by the DELIVERY (the custom
|
|
85
|
+
* element adopts them into its shadow root); direct consumers of this
|
|
86
|
+
* package set the `--ep-*` variables in their own CSS instead. */
|
|
87
|
+
theme?: ThemePreference | ThemeConfig;
|
|
88
|
+
}
|
|
89
|
+
/** Token overrides — names WITHOUT the `--ep-` prefix ('accent', 'surface'…). */
|
|
90
|
+
type ThemeTokens = Readonly<Record<string, string>>;
|
|
91
|
+
interface ThemeConfig {
|
|
92
|
+
/** 'system' (default) follows the OS. */
|
|
93
|
+
preference?: ThemePreference;
|
|
94
|
+
/** Applied in BOTH modes (a later sheet: wins over the defaults). */
|
|
95
|
+
tokens?: ThemeTokens;
|
|
96
|
+
/** Dark-mode-only overrides, applied over `tokens`. */
|
|
97
|
+
dark?: ThemeTokens;
|
|
98
|
+
}
|
|
99
|
+
/** Normalize the shorthand — deliveries use this to read one shape. */
|
|
100
|
+
declare const themeConfigOf: (theme: ThemePreference | ThemeConfig | undefined) => ThemeConfig;
|
|
101
|
+
interface FullViewerProps extends ViewerCustomization {
|
|
102
|
+
/** Instance (borrowed) or thunk (viewer-owned) — the Viewer's own contract. */
|
|
103
|
+
engine: Engine$1 | EngineFactory$1;
|
|
104
|
+
/** Documents to open at mount; more arrive via the tab bar's open button. */
|
|
105
|
+
initialDocuments?: InitialDocument$1[];
|
|
106
|
+
/** Shown while the workspace boots. Default: a translated pulse line. */
|
|
107
|
+
fallback?: ReactNode;
|
|
108
|
+
/** Where the theme's `.dark` class goes — a DELIVERY concern, not user
|
|
109
|
+
* config: the custom element passes its shadow wrapper so theming never
|
|
110
|
+
* touches the host page. Default: document.documentElement. */
|
|
111
|
+
themeTarget?: HTMLElement | null;
|
|
112
|
+
/** Called once the workspace kernel is live, with the viewer handle — the
|
|
113
|
+
* DRIVE surface (`el.viewer` on the custom element, `onReady` on the
|
|
114
|
+
* wrappers). Capabilities resolve from the moment this fires; document-
|
|
115
|
+
* scoped calls simply await their document. */
|
|
116
|
+
onViewer?: (viewer: ViewerHandle) => void;
|
|
117
|
+
}
|
|
118
|
+
declare function FullViewer({ engine, initialDocuments, fallback, commands, icons, strings, locale, disabledCategories, chrome, theme, themeTarget, onViewer }: FullViewerProps): import("react/jsx-runtime").JSX.Element;
|
|
119
|
+
//#endregion
|
|
120
|
+
export { type AddItemSpec, AnnotationToken, type BarChild, type BarGroup, type BarItem, type BarSchema, type BarSections, type CapabilityToken, type ChromeHelpers, type ChromeSchema, type CommandDef, CommandsToken, type CustomItem, type DocInfo, type DocumentsCapability, DocumentsToken, type Engine, type EngineFactory, FormToken, FullViewer, type FullViewerProps, I18nToken, type IconDef, type Importance, type InitialDocument, InteractionToken, type MenuSchema, type MenuSection, MetadataToken, type PathSpec, RedactionToken, type ResolvedCommand, type ScopedViewerHandle, SearchToken, SelectionToken, ShellToken, StageToken, type ThemeConfig, type ThemeMode, type ThemePreference, type ThemeTokens, type Unsubscribe, type Variant, type ViewerCustomization, type ViewerHandle, addItem, chromeHelpers, createViewerHandle, custom, defaultChrome, defaultCommands, ICON_PATHS as defaultIcons, defineChrome, group, item, removeItems, replaceItem, themeConfigOf, validateChrome };
|
|
121
|
+
//# sourceMappingURL=index.d.ts.map
|