@lofcz/embedpdf-plugin-commands 2.15.1 → 3.0.0-next.7
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 +192 -21
- package/dist/index.cjs +196 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +150 -0
- package/dist/index.d.ts +150 -1
- package/dist/index.js +189 -379
- package/dist/index.js.map +1 -1
- package/package.json +21 -40
- package/dist/lib/actions.d.ts +0 -8
- package/dist/lib/commands-plugin.d.ts +0 -40
- package/dist/lib/index.d.ts +0 -8
- package/dist/lib/manifest.d.ts +0 -4
- package/dist/lib/reducer.d.ts +0 -5
- package/dist/lib/types.d.ts +0 -116
- package/dist/react/adapter.d.ts +0 -2
- package/dist/react/core.d.ts +0 -1
- package/dist/react/index.cjs +0 -2
- package/dist/react/index.cjs.map +0 -1
- package/dist/react/index.d.ts +0 -1
- package/dist/react/index.js +0 -90
- package/dist/react/index.js.map +0 -1
- package/dist/shared/components/index.d.ts +0 -1
- package/dist/shared/components/keyboard-shortcuts.d.ts +0 -6
- package/dist/shared/hooks/index.d.ts +0 -1
- package/dist/shared/hooks/use-commands.d.ts +0 -23
- package/dist/shared/index.d.ts +0 -4
- package/dist/shared/utils/index.d.ts +0 -1
- package/dist/shared/utils/keyboard-handler.d.ts +0 -10
- package/dist/shared-react/components/index.d.ts +0 -1
- package/dist/shared-react/components/keyboard-shortcuts.d.ts +0 -6
- package/dist/shared-react/hooks/index.d.ts +0 -1
- package/dist/shared-react/hooks/use-commands.d.ts +0 -23
- package/dist/shared-react/index.d.ts +0 -4
- package/dist/shared-react/utils/index.d.ts +0 -1
- package/dist/shared-react/utils/keyboard-handler.d.ts +0 -10
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { CapabilityToken, CoreState } from "@embedpdf/core";
|
|
2
|
+
import { KeyStroke } from "@embedpdf/core-ui";
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* @embedpdf/plugin-commands — the contract.
|
|
6
|
+
*
|
|
7
|
+
* Commands are the single vocabulary of verbs: toolbars, menus, contextual
|
|
8
|
+
* strips, shortcuts, and the palette are all projections of this registry.
|
|
9
|
+
* The plugin ships ZERO commands (mechanism here, definitions in the product
|
|
10
|
+
* — same split as plugin-i18n's locale packs).
|
|
11
|
+
*
|
|
12
|
+
* Command state is a pure DERIVATION over the store: `resolve()` reads other
|
|
13
|
+
* capabilities' selectors at call time, so any store change is reflected on
|
|
14
|
+
* the next read and the framework binding's one change stream makes every
|
|
15
|
+
* consumer reactive. There is no CommandStateChangedEvent, no diffing, no
|
|
16
|
+
* cache — v2's entire notification apparatus has no v3 equivalent because
|
|
17
|
+
* the reactive store subsumes it.
|
|
18
|
+
*
|
|
19
|
+
* Definitions hold functions, so they live in the plugin's registry (config
|
|
20
|
+
* + `register()`), never in the store; store state is only the serializable
|
|
21
|
+
* `disabledCategories`.
|
|
22
|
+
*/
|
|
23
|
+
/** What a derivation or `run` sees: capability resolution bound to the
|
|
24
|
+
* command's target document (explicit, else the active one). */
|
|
25
|
+
interface CommandCtx {
|
|
26
|
+
/** The target document, or null when no document is open. */
|
|
27
|
+
readonly documentId: string | null;
|
|
28
|
+
core(): CoreState;
|
|
29
|
+
/** Resolve a capability; document-scoped tokens bind to the target document. */
|
|
30
|
+
get<T>(token: CapabilityToken<T>): T;
|
|
31
|
+
/** Like `get`, but null when unavailable (no provider / no document). */
|
|
32
|
+
tryGet<T>(token: CapabilityToken<T>): T | null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Up to two theme colors accompanying a command's icon — typed FACTS any
|
|
36
|
+
* renderer can interpret (tint a glyph's slots, show a swatch), never
|
|
37
|
+
* renderer props. The registry carries it the way it carries `icon`: as
|
|
38
|
+
* data it doesn't interpret. Deliberately NOT v2's `iconProps` bag —
|
|
39
|
+
* renderer-specific needs live app-side, joined by command id.
|
|
40
|
+
*/
|
|
41
|
+
interface IconAccent {
|
|
42
|
+
/** The mark: stroke / markup / font color. */
|
|
43
|
+
readonly primary?: string;
|
|
44
|
+
/** The fill, when there is one. */
|
|
45
|
+
readonly secondary?: string;
|
|
46
|
+
}
|
|
47
|
+
interface CommandDef {
|
|
48
|
+
/** Convention: 'domain:verb' — 'zoom:in', 'mode:annotate', 'panel:search'. */
|
|
49
|
+
readonly id: string;
|
|
50
|
+
/** i18n key, resolved through I18nToken when present (else shown verbatim). */
|
|
51
|
+
readonly labelKey: string;
|
|
52
|
+
readonly icon?: string;
|
|
53
|
+
/** Live color accent for the icon (a tool previewing its drawing defaults).
|
|
54
|
+
* A pure derivation over the store, exactly like `active`/`enabled`. */
|
|
55
|
+
readonly iconAccent?: (ctx: CommandCtx) => IconAccent | null;
|
|
56
|
+
/** 'Mod+K' style (ui-core grammar). Multiple bindings allowed. */
|
|
57
|
+
readonly shortcut?: string | readonly string[];
|
|
58
|
+
/** Feature-gating tags: a disabled category hides its commands everywhere. */
|
|
59
|
+
readonly categories?: readonly string[];
|
|
60
|
+
/** Toggles a named dropdown menu (a MenuSchema id in the app's chrome). */
|
|
61
|
+
readonly menu?: string;
|
|
62
|
+
/** Toggles a named shell surface, optionally exclusive within a tag ('left'…). */
|
|
63
|
+
readonly panel?: string | {
|
|
64
|
+
readonly id: string;
|
|
65
|
+
readonly exclusive?: string;
|
|
66
|
+
};
|
|
67
|
+
/** Toggles a modal surface (exclusive within the built-in 'modal' tag). */
|
|
68
|
+
readonly modal?: string;
|
|
69
|
+
readonly enabled?: (ctx: CommandCtx) => boolean;
|
|
70
|
+
readonly active?: (ctx: CommandCtx) => boolean;
|
|
71
|
+
readonly visible?: (ctx: CommandCtx) => boolean;
|
|
72
|
+
/** The verb. Optional for pure surface-target commands. Runs before the
|
|
73
|
+
* default target routing when both are present. */
|
|
74
|
+
readonly run?: (ctx: CommandCtx) => void;
|
|
75
|
+
}
|
|
76
|
+
/** A command as a renderer sees it — everything resolved for the target document. */
|
|
77
|
+
interface ResolvedCommand {
|
|
78
|
+
readonly id: string;
|
|
79
|
+
readonly label: string;
|
|
80
|
+
readonly icon?: string;
|
|
81
|
+
readonly iconAccent?: IconAccent;
|
|
82
|
+
readonly shortcuts: readonly string[];
|
|
83
|
+
readonly menu?: string;
|
|
84
|
+
readonly enabled: boolean;
|
|
85
|
+
readonly active: boolean;
|
|
86
|
+
readonly visible: boolean;
|
|
87
|
+
readonly categories: readonly string[];
|
|
88
|
+
}
|
|
89
|
+
/** Value equality over resolved commands — `resolve()` mints a fresh object
|
|
90
|
+
* per read, so reactive bindings memo by value to re-render on real change. */
|
|
91
|
+
declare const resolvedCommandsEqual: (a: ResolvedCommand | null, b: ResolvedCommand | null) => boolean;
|
|
92
|
+
interface CommandsState {
|
|
93
|
+
readonly disabledCategories: readonly string[];
|
|
94
|
+
}
|
|
95
|
+
type CommandsAction = {
|
|
96
|
+
type: 'COMMANDS/DISABLE_CATEGORY';
|
|
97
|
+
category: string;
|
|
98
|
+
} | {
|
|
99
|
+
type: 'COMMANDS/ENABLE_CATEGORY';
|
|
100
|
+
category: string;
|
|
101
|
+
} | {
|
|
102
|
+
type: 'COMMANDS/SET_DISABLED_CATEGORIES';
|
|
103
|
+
categories: readonly string[];
|
|
104
|
+
};
|
|
105
|
+
interface CommandsConfig {
|
|
106
|
+
/** The app's command definitions (content — the plugin ships none). */
|
|
107
|
+
commands?: readonly CommandDef[];
|
|
108
|
+
/** Categories disabled at startup (host feature-gating). */
|
|
109
|
+
disabledCategories?: readonly string[];
|
|
110
|
+
}
|
|
111
|
+
interface CommandsCapability {
|
|
112
|
+
register(def: CommandDef): void;
|
|
113
|
+
unregister(id: string): void;
|
|
114
|
+
has(id: string): boolean;
|
|
115
|
+
ids(): string[];
|
|
116
|
+
resolve(id: string, documentId?: string): ResolvedCommand | null;
|
|
117
|
+
/** Palette query: visible commands whose resolved label matches. */
|
|
118
|
+
search(query: string, documentId?: string): ResolvedCommand[];
|
|
119
|
+
/** The one fact the overflow projection needs (ResolveMenuTarget-shaped). */
|
|
120
|
+
menuTarget(id: string): {
|
|
121
|
+
menu?: string;
|
|
122
|
+
} | null;
|
|
123
|
+
execute(id: string, documentId?: string): void;
|
|
124
|
+
/** Match a keystroke against every registered shortcut → command id or null. */
|
|
125
|
+
matchStroke(stroke: KeyStroke, opts: {
|
|
126
|
+
isMac: boolean;
|
|
127
|
+
}): string | null;
|
|
128
|
+
disabledCategories(): readonly string[];
|
|
129
|
+
isCategoryDisabled(category: string): boolean;
|
|
130
|
+
disableCategory(category: string): void;
|
|
131
|
+
enableCategory(category: string): void;
|
|
132
|
+
setDisabledCategories(categories: readonly string[]): void;
|
|
133
|
+
}
|
|
134
|
+
declare const CommandsToken: CapabilityToken<CommandsCapability>;
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/commands.plugin.d.ts
|
|
137
|
+
/**
|
|
138
|
+
* The commands plugin: workspace-scoped (one vocabulary for the whole
|
|
139
|
+
* workspace; resolution/execution bind to a target document per call).
|
|
140
|
+
* Definitions live in this closure — never in the store (they hold
|
|
141
|
+
* functions); the store slice holds only `disabledCategories`.
|
|
142
|
+
*/
|
|
143
|
+
declare const commandsPlugin: (config?: CommandsConfig) => import("@embedpdf/core").PluginDef<CommandsState, CommandsAction, CommandsCapability>;
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/reducer.d.ts
|
|
146
|
+
declare const initialCommandsState: CommandsState;
|
|
147
|
+
declare function commandsReducer(state: CommandsState, action: CommandsAction): CommandsState;
|
|
148
|
+
//#endregion
|
|
149
|
+
export { type CommandCtx, type CommandDef, type CommandsAction, type CommandsCapability, type CommandsConfig, type CommandsState, CommandsToken, type IconAccent, type ResolvedCommand, commandsPlugin, commandsReducer, initialCommandsState, resolvedCommandsEqual };
|
|
150
|
+
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,150 @@
|
|
|
1
|
-
|
|
1
|
+
import { CapabilityToken, CoreState } from "@embedpdf/core";
|
|
2
|
+
import { KeyStroke } from "@embedpdf/core-ui";
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* @embedpdf/plugin-commands — the contract.
|
|
6
|
+
*
|
|
7
|
+
* Commands are the single vocabulary of verbs: toolbars, menus, contextual
|
|
8
|
+
* strips, shortcuts, and the palette are all projections of this registry.
|
|
9
|
+
* The plugin ships ZERO commands (mechanism here, definitions in the product
|
|
10
|
+
* — same split as plugin-i18n's locale packs).
|
|
11
|
+
*
|
|
12
|
+
* Command state is a pure DERIVATION over the store: `resolve()` reads other
|
|
13
|
+
* capabilities' selectors at call time, so any store change is reflected on
|
|
14
|
+
* the next read and the framework binding's one change stream makes every
|
|
15
|
+
* consumer reactive. There is no CommandStateChangedEvent, no diffing, no
|
|
16
|
+
* cache — v2's entire notification apparatus has no v3 equivalent because
|
|
17
|
+
* the reactive store subsumes it.
|
|
18
|
+
*
|
|
19
|
+
* Definitions hold functions, so they live in the plugin's registry (config
|
|
20
|
+
* + `register()`), never in the store; store state is only the serializable
|
|
21
|
+
* `disabledCategories`.
|
|
22
|
+
*/
|
|
23
|
+
/** What a derivation or `run` sees: capability resolution bound to the
|
|
24
|
+
* command's target document (explicit, else the active one). */
|
|
25
|
+
interface CommandCtx {
|
|
26
|
+
/** The target document, or null when no document is open. */
|
|
27
|
+
readonly documentId: string | null;
|
|
28
|
+
core(): CoreState;
|
|
29
|
+
/** Resolve a capability; document-scoped tokens bind to the target document. */
|
|
30
|
+
get<T>(token: CapabilityToken<T>): T;
|
|
31
|
+
/** Like `get`, but null when unavailable (no provider / no document). */
|
|
32
|
+
tryGet<T>(token: CapabilityToken<T>): T | null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Up to two theme colors accompanying a command's icon — typed FACTS any
|
|
36
|
+
* renderer can interpret (tint a glyph's slots, show a swatch), never
|
|
37
|
+
* renderer props. The registry carries it the way it carries `icon`: as
|
|
38
|
+
* data it doesn't interpret. Deliberately NOT v2's `iconProps` bag —
|
|
39
|
+
* renderer-specific needs live app-side, joined by command id.
|
|
40
|
+
*/
|
|
41
|
+
interface IconAccent {
|
|
42
|
+
/** The mark: stroke / markup / font color. */
|
|
43
|
+
readonly primary?: string;
|
|
44
|
+
/** The fill, when there is one. */
|
|
45
|
+
readonly secondary?: string;
|
|
46
|
+
}
|
|
47
|
+
interface CommandDef {
|
|
48
|
+
/** Convention: 'domain:verb' — 'zoom:in', 'mode:annotate', 'panel:search'. */
|
|
49
|
+
readonly id: string;
|
|
50
|
+
/** i18n key, resolved through I18nToken when present (else shown verbatim). */
|
|
51
|
+
readonly labelKey: string;
|
|
52
|
+
readonly icon?: string;
|
|
53
|
+
/** Live color accent for the icon (a tool previewing its drawing defaults).
|
|
54
|
+
* A pure derivation over the store, exactly like `active`/`enabled`. */
|
|
55
|
+
readonly iconAccent?: (ctx: CommandCtx) => IconAccent | null;
|
|
56
|
+
/** 'Mod+K' style (ui-core grammar). Multiple bindings allowed. */
|
|
57
|
+
readonly shortcut?: string | readonly string[];
|
|
58
|
+
/** Feature-gating tags: a disabled category hides its commands everywhere. */
|
|
59
|
+
readonly categories?: readonly string[];
|
|
60
|
+
/** Toggles a named dropdown menu (a MenuSchema id in the app's chrome). */
|
|
61
|
+
readonly menu?: string;
|
|
62
|
+
/** Toggles a named shell surface, optionally exclusive within a tag ('left'…). */
|
|
63
|
+
readonly panel?: string | {
|
|
64
|
+
readonly id: string;
|
|
65
|
+
readonly exclusive?: string;
|
|
66
|
+
};
|
|
67
|
+
/** Toggles a modal surface (exclusive within the built-in 'modal' tag). */
|
|
68
|
+
readonly modal?: string;
|
|
69
|
+
readonly enabled?: (ctx: CommandCtx) => boolean;
|
|
70
|
+
readonly active?: (ctx: CommandCtx) => boolean;
|
|
71
|
+
readonly visible?: (ctx: CommandCtx) => boolean;
|
|
72
|
+
/** The verb. Optional for pure surface-target commands. Runs before the
|
|
73
|
+
* default target routing when both are present. */
|
|
74
|
+
readonly run?: (ctx: CommandCtx) => void;
|
|
75
|
+
}
|
|
76
|
+
/** A command as a renderer sees it — everything resolved for the target document. */
|
|
77
|
+
interface ResolvedCommand {
|
|
78
|
+
readonly id: string;
|
|
79
|
+
readonly label: string;
|
|
80
|
+
readonly icon?: string;
|
|
81
|
+
readonly iconAccent?: IconAccent;
|
|
82
|
+
readonly shortcuts: readonly string[];
|
|
83
|
+
readonly menu?: string;
|
|
84
|
+
readonly enabled: boolean;
|
|
85
|
+
readonly active: boolean;
|
|
86
|
+
readonly visible: boolean;
|
|
87
|
+
readonly categories: readonly string[];
|
|
88
|
+
}
|
|
89
|
+
/** Value equality over resolved commands — `resolve()` mints a fresh object
|
|
90
|
+
* per read, so reactive bindings memo by value to re-render on real change. */
|
|
91
|
+
declare const resolvedCommandsEqual: (a: ResolvedCommand | null, b: ResolvedCommand | null) => boolean;
|
|
92
|
+
interface CommandsState {
|
|
93
|
+
readonly disabledCategories: readonly string[];
|
|
94
|
+
}
|
|
95
|
+
type CommandsAction = {
|
|
96
|
+
type: 'COMMANDS/DISABLE_CATEGORY';
|
|
97
|
+
category: string;
|
|
98
|
+
} | {
|
|
99
|
+
type: 'COMMANDS/ENABLE_CATEGORY';
|
|
100
|
+
category: string;
|
|
101
|
+
} | {
|
|
102
|
+
type: 'COMMANDS/SET_DISABLED_CATEGORIES';
|
|
103
|
+
categories: readonly string[];
|
|
104
|
+
};
|
|
105
|
+
interface CommandsConfig {
|
|
106
|
+
/** The app's command definitions (content — the plugin ships none). */
|
|
107
|
+
commands?: readonly CommandDef[];
|
|
108
|
+
/** Categories disabled at startup (host feature-gating). */
|
|
109
|
+
disabledCategories?: readonly string[];
|
|
110
|
+
}
|
|
111
|
+
interface CommandsCapability {
|
|
112
|
+
register(def: CommandDef): void;
|
|
113
|
+
unregister(id: string): void;
|
|
114
|
+
has(id: string): boolean;
|
|
115
|
+
ids(): string[];
|
|
116
|
+
resolve(id: string, documentId?: string): ResolvedCommand | null;
|
|
117
|
+
/** Palette query: visible commands whose resolved label matches. */
|
|
118
|
+
search(query: string, documentId?: string): ResolvedCommand[];
|
|
119
|
+
/** The one fact the overflow projection needs (ResolveMenuTarget-shaped). */
|
|
120
|
+
menuTarget(id: string): {
|
|
121
|
+
menu?: string;
|
|
122
|
+
} | null;
|
|
123
|
+
execute(id: string, documentId?: string): void;
|
|
124
|
+
/** Match a keystroke against every registered shortcut → command id or null. */
|
|
125
|
+
matchStroke(stroke: KeyStroke, opts: {
|
|
126
|
+
isMac: boolean;
|
|
127
|
+
}): string | null;
|
|
128
|
+
disabledCategories(): readonly string[];
|
|
129
|
+
isCategoryDisabled(category: string): boolean;
|
|
130
|
+
disableCategory(category: string): void;
|
|
131
|
+
enableCategory(category: string): void;
|
|
132
|
+
setDisabledCategories(categories: readonly string[]): void;
|
|
133
|
+
}
|
|
134
|
+
declare const CommandsToken: CapabilityToken<CommandsCapability>;
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/commands.plugin.d.ts
|
|
137
|
+
/**
|
|
138
|
+
* The commands plugin: workspace-scoped (one vocabulary for the whole
|
|
139
|
+
* workspace; resolution/execution bind to a target document per call).
|
|
140
|
+
* Definitions live in this closure — never in the store (they hold
|
|
141
|
+
* functions); the store slice holds only `disabledCategories`.
|
|
142
|
+
*/
|
|
143
|
+
declare const commandsPlugin: (config?: CommandsConfig) => import("@embedpdf/core").PluginDef<CommandsState, CommandsAction, CommandsCapability>;
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/reducer.d.ts
|
|
146
|
+
declare const initialCommandsState: CommandsState;
|
|
147
|
+
declare function commandsReducer(state: CommandsState, action: CommandsAction): CommandsState;
|
|
148
|
+
//#endregion
|
|
149
|
+
export { type CommandCtx, type CommandDef, type CommandsAction, type CommandsCapability, type CommandsConfig, type CommandsState, CommandsToken, type IconAccent, type ResolvedCommand, commandsPlugin, commandsReducer, initialCommandsState, resolvedCommandsEqual };
|
|
150
|
+
//# sourceMappingURL=index.d.ts.map
|