@embedpdf/plugin-history 1.0.11 → 1.0.13

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/index.cjs CHANGED
@@ -1,199 +1,2 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- HISTORY_PLUGIN_ID: () => HISTORY_PLUGIN_ID,
24
- HistoryPlugin: () => HistoryPlugin,
25
- HistoryPluginPackage: () => HistoryPluginPackage,
26
- manifest: () => manifest
27
- });
28
- module.exports = __toCommonJS(index_exports);
29
-
30
- // src/lib/manifest.ts
31
- var HISTORY_PLUGIN_ID = "history";
32
- var manifest = {
33
- id: HISTORY_PLUGIN_ID,
34
- name: "History Plugin",
35
- version: "1.0.0",
36
- provides: ["history"],
37
- requires: [],
38
- optional: [],
39
- defaultConfig: {
40
- enabled: true
41
- }
42
- };
43
-
44
- // src/lib/history-plugin.ts
45
- var import_core = require("@embedpdf/core");
46
-
47
- // src/lib/actions.ts
48
- var SET_HISTORY_STATE = "HISTORY/SET_STATE";
49
- var setHistoryState = (state) => ({
50
- type: SET_HISTORY_STATE,
51
- payload: state
52
- });
53
-
54
- // src/lib/history-plugin.ts
55
- var HistoryPlugin = class extends import_core.BasePlugin {
56
- constructor(id, registry) {
57
- super(id, registry);
58
- this.topicHistories = /* @__PURE__ */ new Map();
59
- this.globalTimeline = [];
60
- this.globalIndex = -1;
61
- // This emitter will now broadcast the topic string of the affected history.
62
- this.historyChange$ = (0, import_core.createEmitter)();
63
- }
64
- async initialize(_) {
65
- }
66
- getHistoryState() {
67
- const topics = {};
68
- Array.from(this.topicHistories.entries()).forEach(([topic, history]) => {
69
- topics[topic] = {
70
- canUndo: history.currentIndex > -1,
71
- canRedo: history.currentIndex < history.commands.length - 1
72
- };
73
- });
74
- return {
75
- global: {
76
- canUndo: this.globalIndex > -1,
77
- canRedo: this.globalIndex < this.globalTimeline.length - 1
78
- },
79
- topics
80
- };
81
- }
82
- // The emit function now accepts the topic to broadcast.
83
- emitHistoryChange(topic) {
84
- this.dispatch(setHistoryState(this.getHistoryState()));
85
- this.historyChange$.emit(topic);
86
- }
87
- buildCapability() {
88
- return {
89
- getHistoryState: () => this.state,
90
- onHistoryChange: this.historyChange$.on,
91
- register: (command, topic) => {
92
- if (!this.topicHistories.has(topic)) {
93
- this.topicHistories.set(topic, { commands: [], currentIndex: -1 });
94
- }
95
- const topicHistory = this.topicHistories.get(topic);
96
- topicHistory.commands.splice(topicHistory.currentIndex + 1);
97
- topicHistory.commands.push(command);
98
- topicHistory.currentIndex++;
99
- const historyEntry = { command, topic };
100
- this.globalTimeline.splice(this.globalIndex + 1);
101
- this.globalTimeline.push(historyEntry);
102
- this.globalIndex++;
103
- command.execute();
104
- this.emitHistoryChange(topic);
105
- },
106
- undo: (topic) => {
107
- let affectedTopic;
108
- if (topic) {
109
- const topicHistory = this.topicHistories.get(topic);
110
- if (topicHistory && topicHistory.currentIndex > -1) {
111
- topicHistory.commands[topicHistory.currentIndex].undo();
112
- topicHistory.currentIndex--;
113
- affectedTopic = topic;
114
- }
115
- } else {
116
- if (this.globalIndex > -1) {
117
- const entry = this.globalTimeline[this.globalIndex];
118
- entry.command.undo();
119
- this.topicHistories.get(entry.topic).currentIndex--;
120
- this.globalIndex--;
121
- affectedTopic = entry.topic;
122
- }
123
- }
124
- if (affectedTopic) this.emitHistoryChange(affectedTopic);
125
- },
126
- redo: (topic) => {
127
- let affectedTopic;
128
- if (topic) {
129
- const topicHistory = this.topicHistories.get(topic);
130
- if (topicHistory && topicHistory.currentIndex < topicHistory.commands.length - 1) {
131
- topicHistory.currentIndex++;
132
- topicHistory.commands[topicHistory.currentIndex].execute();
133
- affectedTopic = topic;
134
- }
135
- } else {
136
- if (this.globalIndex < this.globalTimeline.length - 1) {
137
- this.globalIndex++;
138
- const entry = this.globalTimeline[this.globalIndex];
139
- entry.command.execute();
140
- this.topicHistories.get(entry.topic).currentIndex++;
141
- affectedTopic = entry.topic;
142
- }
143
- }
144
- if (affectedTopic) this.emitHistoryChange(affectedTopic);
145
- },
146
- canUndo: (topic) => {
147
- if (topic) {
148
- const history = this.topicHistories.get(topic);
149
- return !!history && history.currentIndex > -1;
150
- }
151
- return this.globalIndex > -1;
152
- },
153
- canRedo: (topic) => {
154
- if (topic) {
155
- const history = this.topicHistories.get(topic);
156
- return !!history && history.currentIndex < history.commands.length - 1;
157
- }
158
- return this.globalIndex < this.globalTimeline.length - 1;
159
- }
160
- };
161
- }
162
- };
163
- HistoryPlugin.id = "history";
164
-
165
- // src/lib/reducer.ts
166
- var initialState = {
167
- global: {
168
- canUndo: false,
169
- canRedo: false
170
- },
171
- topics: {}
172
- };
173
- var reducer = (state = initialState, action) => {
174
- switch (action.type) {
175
- case SET_HISTORY_STATE:
176
- return {
177
- ...state,
178
- ...action.payload
179
- };
180
- default:
181
- return state;
182
- }
183
- };
184
-
185
- // src/lib/index.ts
186
- var HistoryPluginPackage = {
187
- manifest,
188
- create: (registry, _engine) => new HistoryPlugin(HISTORY_PLUGIN_ID, registry),
189
- reducer,
190
- initialState
191
- };
192
- // Annotate the CommonJS export names for ESM import in node:
193
- 0 && (module.exports = {
194
- HISTORY_PLUGIN_ID,
195
- HistoryPlugin,
196
- HistoryPluginPackage,
197
- manifest
198
- });
199
- //# sourceMappingURL=index.cjs.map
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@embedpdf/core"),e="history",i={id:e,name:"History Plugin",version:"1.0.0",provides:["history"],requires:[],optional:[],defaultConfig:{enabled:!0}},s="HISTORY/SET_STATE",n=class extends t.BasePlugin{constructor(e,i){super(e,i),this.topicHistories=new Map,this.globalTimeline=[],this.globalIndex=-1,this.historyChange$=t.createEmitter()}async initialize(t){}getHistoryState(){const t={};return Array.from(this.topicHistories.entries()).forEach((([e,i])=>{t[e]={canUndo:i.currentIndex>-1,canRedo:i.currentIndex<i.commands.length-1}})),{global:{canUndo:this.globalIndex>-1,canRedo:this.globalIndex<this.globalTimeline.length-1},topics:t}}emitHistoryChange(t){var e;this.dispatch((e=this.getHistoryState(),{type:s,payload:e})),this.historyChange$.emit(t)}buildCapability(){return{getHistoryState:()=>this.state,onHistoryChange:this.historyChange$.on,register:(t,e)=>{this.topicHistories.has(e)||this.topicHistories.set(e,{commands:[],currentIndex:-1});const i=this.topicHistories.get(e);i.commands.splice(i.currentIndex+1),i.commands.push(t),i.currentIndex++;const s={command:t,topic:e};this.globalTimeline.splice(this.globalIndex+1),this.globalTimeline.push(s),this.globalIndex++,t.execute(),this.emitHistoryChange(e)},undo:t=>{let e;if(t){const i=this.topicHistories.get(t);i&&i.currentIndex>-1&&(i.commands[i.currentIndex].undo(),i.currentIndex--,e=t)}else if(this.globalIndex>-1){const t=this.globalTimeline[this.globalIndex];t.command.undo(),this.topicHistories.get(t.topic).currentIndex--,this.globalIndex--,e=t.topic}e&&this.emitHistoryChange(e)},redo:t=>{let e;if(t){const i=this.topicHistories.get(t);i&&i.currentIndex<i.commands.length-1&&(i.currentIndex++,i.commands[i.currentIndex].execute(),e=t)}else if(this.globalIndex<this.globalTimeline.length-1){this.globalIndex++;const t=this.globalTimeline[this.globalIndex];t.command.execute(),this.topicHistories.get(t.topic).currentIndex++,e=t.topic}e&&this.emitHistoryChange(e)},canUndo:t=>{if(t){const e=this.topicHistories.get(t);return!!e&&e.currentIndex>-1}return this.globalIndex>-1},canRedo:t=>{if(t){const e=this.topicHistories.get(t);return!!e&&e.currentIndex<e.commands.length-1}return this.globalIndex<this.globalTimeline.length-1}}}};n.id="history";let o=n;const r={global:{canUndo:!1,canRedo:!1},topics:{}},a={manifest:i,create:(t,i)=>new o(e,t),reducer:(t=r,e)=>e.type===s?{...t,...e.payload}:t,initialState:r};exports.HISTORY_PLUGIN_ID=e,exports.HistoryPlugin=o,exports.HistoryPluginPackage=a,exports.manifest=i;
2
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/lib/manifest.ts","../src/lib/history-plugin.ts","../src/lib/actions.ts","../src/lib/reducer.ts","../src/lib/index.ts"],"sourcesContent":["export * from './lib';\n","import { PluginManifest } from '@embedpdf/core';\nimport { HistoryPluginConfig } from './types';\n\nexport const HISTORY_PLUGIN_ID = 'history';\n\nexport const manifest: PluginManifest<HistoryPluginConfig> = {\n id: HISTORY_PLUGIN_ID,\n name: 'History Plugin',\n version: '1.0.0',\n provides: ['history'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n },\n};\n","import { BasePlugin, createEmitter, PluginRegistry } from '@embedpdf/core';\nimport {\n Command,\n HistoryCapability,\n HistoryEntry,\n HistoryPluginConfig,\n HistoryState,\n} from './types';\nimport { HistoryAction, setHistoryState } from './actions';\n\nexport class HistoryPlugin extends BasePlugin<\n HistoryPluginConfig,\n HistoryCapability,\n HistoryState,\n HistoryAction\n> {\n static readonly id = 'history' as const;\n\n private readonly topicHistories = new Map<\n string,\n { commands: Command[]; currentIndex: number }\n >();\n private globalTimeline: HistoryEntry[] = [];\n private globalIndex = -1;\n\n // This emitter will now broadcast the topic string of the affected history.\n private readonly historyChange$ = createEmitter<string | undefined>();\n\n constructor(id: string, registry: PluginRegistry) {\n super(id, registry);\n }\n\n async initialize(_: HistoryPluginConfig): Promise<void> {}\n\n private getHistoryState(): HistoryState {\n const topics: HistoryState['topics'] = {};\n Array.from(this.topicHistories.entries()).forEach(([topic, history]) => {\n topics[topic] = {\n canUndo: history.currentIndex > -1,\n canRedo: history.currentIndex < history.commands.length - 1,\n };\n });\n return {\n global: {\n canUndo: this.globalIndex > -1,\n canRedo: this.globalIndex < this.globalTimeline.length - 1,\n },\n topics,\n };\n }\n\n // The emit function now accepts the topic to broadcast.\n private emitHistoryChange(topic: string) {\n // update the state\n this.dispatch(setHistoryState(this.getHistoryState()));\n\n // emit the event\n this.historyChange$.emit(topic);\n }\n\n protected buildCapability(): HistoryCapability {\n return {\n getHistoryState: () => this.state,\n onHistoryChange: this.historyChange$.on,\n\n register: (command: Command, topic: string) => {\n // 1. Manage Topic History\n if (!this.topicHistories.has(topic)) {\n this.topicHistories.set(topic, { commands: [], currentIndex: -1 });\n }\n const topicHistory = this.topicHistories.get(topic)!;\n topicHistory.commands.splice(topicHistory.currentIndex + 1);\n topicHistory.commands.push(command);\n topicHistory.currentIndex++;\n\n // 2. Manage Global History\n const historyEntry: HistoryEntry = { command, topic };\n this.globalTimeline.splice(this.globalIndex + 1);\n this.globalTimeline.push(historyEntry);\n this.globalIndex++;\n\n // 3. Execute and notify with the specific topic\n command.execute();\n this.emitHistoryChange(topic);\n },\n\n undo: (topic?: string) => {\n let affectedTopic: string | undefined;\n\n if (topic) {\n // Scoped Undo\n const topicHistory = this.topicHistories.get(topic);\n if (topicHistory && topicHistory.currentIndex > -1) {\n topicHistory.commands[topicHistory.currentIndex].undo();\n topicHistory.currentIndex--;\n affectedTopic = topic;\n }\n } else {\n // Global Undo\n if (this.globalIndex > -1) {\n const entry = this.globalTimeline[this.globalIndex];\n entry.command.undo();\n this.topicHistories.get(entry.topic)!.currentIndex--;\n this.globalIndex--;\n affectedTopic = entry.topic;\n }\n }\n if (affectedTopic) this.emitHistoryChange(affectedTopic);\n },\n\n redo: (topic?: string) => {\n let affectedTopic: string | undefined;\n\n if (topic) {\n // Scoped Redo\n const topicHistory = this.topicHistories.get(topic);\n if (topicHistory && topicHistory.currentIndex < topicHistory.commands.length - 1) {\n topicHistory.currentIndex++;\n topicHistory.commands[topicHistory.currentIndex].execute();\n affectedTopic = topic;\n }\n } else {\n // Global Redo\n if (this.globalIndex < this.globalTimeline.length - 1) {\n this.globalIndex++;\n const entry = this.globalTimeline[this.globalIndex];\n entry.command.execute();\n this.topicHistories.get(entry.topic)!.currentIndex++;\n affectedTopic = entry.topic;\n }\n }\n if (affectedTopic) this.emitHistoryChange(affectedTopic);\n },\n\n canUndo: (topic?: string) => {\n if (topic) {\n const history = this.topicHistories.get(topic);\n return !!history && history.currentIndex > -1;\n }\n return this.globalIndex > -1;\n },\n\n canRedo: (topic?: string) => {\n if (topic) {\n const history = this.topicHistories.get(topic);\n return !!history && history.currentIndex < history.commands.length - 1;\n }\n return this.globalIndex < this.globalTimeline.length - 1;\n },\n };\n }\n}\n","import { Action } from '@embedpdf/core';\nimport { HistoryState } from './types';\n\nexport const SET_HISTORY_STATE = 'HISTORY/SET_STATE';\n\nexport interface SetHistoryStateAction extends Action {\n type: typeof SET_HISTORY_STATE;\n payload: HistoryState;\n}\n\nexport type HistoryAction = SetHistoryStateAction;\n\nexport const setHistoryState = (state: HistoryState): SetHistoryStateAction => ({\n type: SET_HISTORY_STATE,\n payload: state,\n});\n","import { Reducer } from '@embedpdf/core';\nimport { HistoryAction, SET_HISTORY_STATE } from './actions';\nimport { HistoryState } from './types';\n\nexport const initialState: HistoryState = {\n global: {\n canUndo: false,\n canRedo: false,\n },\n topics: {},\n};\n\nexport const reducer: Reducer<HistoryState, HistoryAction> = (state = initialState, action) => {\n switch (action.type) {\n case SET_HISTORY_STATE:\n return {\n ...state,\n ...action.payload,\n };\n default:\n return state;\n }\n};\n","import { PluginPackage } from '@embedpdf/core';\nimport { manifest, HISTORY_PLUGIN_ID } from './manifest';\nimport { HistoryPluginConfig, HistoryState } from './types';\nimport { HistoryPlugin } from './history-plugin';\nimport { initialState, reducer } from './reducer';\nimport { HistoryAction } from './actions';\n\nexport const HistoryPluginPackage: PluginPackage<\n HistoryPlugin,\n HistoryPluginConfig,\n HistoryState,\n HistoryAction\n> = {\n manifest,\n create: (registry, _engine) => new HistoryPlugin(HISTORY_PLUGIN_ID, registry),\n reducer,\n initialState,\n};\n\nexport * from './history-plugin';\nexport * from './types';\nexport * from './manifest';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,IAAM,oBAAoB;AAE1B,IAAM,WAAgD;AAAA,EAC3D,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU,CAAC,SAAS;AAAA,EACpB,UAAU,CAAC;AAAA,EACX,UAAU,CAAC;AAAA,EACX,eAAe;AAAA,IACb,SAAS;AAAA,EACX;AACF;;;ACfA,kBAA0D;;;ACGnD,IAAM,oBAAoB;AAS1B,IAAM,kBAAkB,CAAC,WAAgD;AAAA,EAC9E,MAAM;AAAA,EACN,SAAS;AACX;;;ADLO,IAAM,gBAAN,cAA4B,uBAKjC;AAAA,EAaA,YAAY,IAAY,UAA0B;AAChD,UAAM,IAAI,QAAQ;AAXpB,SAAiB,iBAAiB,oBAAI,IAGpC;AACF,SAAQ,iBAAiC,CAAC;AAC1C,SAAQ,cAAc;AAGtB;AAAA,SAAiB,qBAAiB,2BAAkC;AAAA,EAIpE;AAAA,EAEA,MAAM,WAAW,GAAuC;AAAA,EAAC;AAAA,EAEjD,kBAAgC;AACtC,UAAM,SAAiC,CAAC;AACxC,UAAM,KAAK,KAAK,eAAe,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,OAAO,OAAO,MAAM;AACtE,aAAO,KAAK,IAAI;AAAA,QACd,SAAS,QAAQ,eAAe;AAAA,QAChC,SAAS,QAAQ,eAAe,QAAQ,SAAS,SAAS;AAAA,MAC5D;AAAA,IACF,CAAC;AACD,WA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M,UAAgD,CAAC,QAAQ,cAAc,WAAW;AAC7F,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH,GAAG,OAAO;AAAA,MACZ;AAAA,IACF;AACE,aAAO;AAAA,EACX;AACF;;;ACfO,IAAM,uBAKT;AAAA,EACF;AAAA,EACA,QAAQ,CAAC,UAAU,YAAY,IAAI,cAAc,mBAAmB,QAAQ;AAAA,EAC5E;AAAA,EACA;AACF;","names":[]}
1
+ {"version":3,"file":"index.cjs","sources":["../src/lib/manifest.ts","../src/lib/actions.ts","../src/lib/history-plugin.ts","../src/lib/reducer.ts","../src/lib/index.ts"],"sourcesContent":["import { PluginManifest } from '@embedpdf/core';\nimport { HistoryPluginConfig } from './types';\n\nexport const HISTORY_PLUGIN_ID = 'history';\n\nexport const manifest: PluginManifest<HistoryPluginConfig> = {\n id: HISTORY_PLUGIN_ID,\n name: 'History Plugin',\n version: '1.0.0',\n provides: ['history'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n },\n};\n","import { Action } from '@embedpdf/core';\nimport { HistoryState } from './types';\n\nexport const SET_HISTORY_STATE = 'HISTORY/SET_STATE';\n\nexport interface SetHistoryStateAction extends Action {\n type: typeof SET_HISTORY_STATE;\n payload: HistoryState;\n}\n\nexport type HistoryAction = SetHistoryStateAction;\n\nexport const setHistoryState = (state: HistoryState): SetHistoryStateAction => ({\n type: SET_HISTORY_STATE,\n payload: state,\n});\n","import { BasePlugin, createEmitter, PluginRegistry } from '@embedpdf/core';\nimport {\n Command,\n HistoryCapability,\n HistoryEntry,\n HistoryPluginConfig,\n HistoryState,\n} from './types';\nimport { HistoryAction, setHistoryState } from './actions';\n\nexport class HistoryPlugin extends BasePlugin<\n HistoryPluginConfig,\n HistoryCapability,\n HistoryState,\n HistoryAction\n> {\n static readonly id = 'history' as const;\n\n private readonly topicHistories = new Map<\n string,\n { commands: Command[]; currentIndex: number }\n >();\n private globalTimeline: HistoryEntry[] = [];\n private globalIndex = -1;\n\n // This emitter will now broadcast the topic string of the affected history.\n private readonly historyChange$ = createEmitter<string | undefined>();\n\n constructor(id: string, registry: PluginRegistry) {\n super(id, registry);\n }\n\n async initialize(_: HistoryPluginConfig): Promise<void> {}\n\n private getHistoryState(): HistoryState {\n const topics: HistoryState['topics'] = {};\n Array.from(this.topicHistories.entries()).forEach(([topic, history]) => {\n topics[topic] = {\n canUndo: history.currentIndex > -1,\n canRedo: history.currentIndex < history.commands.length - 1,\n };\n });\n return {\n global: {\n canUndo: this.globalIndex > -1,\n canRedo: this.globalIndex < this.globalTimeline.length - 1,\n },\n topics,\n };\n }\n\n // The emit function now accepts the topic to broadcast.\n private emitHistoryChange(topic: string) {\n // update the state\n this.dispatch(setHistoryState(this.getHistoryState()));\n\n // emit the event\n this.historyChange$.emit(topic);\n }\n\n protected buildCapability(): HistoryCapability {\n return {\n getHistoryState: () => this.state,\n onHistoryChange: this.historyChange$.on,\n\n register: (command: Command, topic: string) => {\n // 1. Manage Topic History\n if (!this.topicHistories.has(topic)) {\n this.topicHistories.set(topic, { commands: [], currentIndex: -1 });\n }\n const topicHistory = this.topicHistories.get(topic)!;\n topicHistory.commands.splice(topicHistory.currentIndex + 1);\n topicHistory.commands.push(command);\n topicHistory.currentIndex++;\n\n // 2. Manage Global History\n const historyEntry: HistoryEntry = { command, topic };\n this.globalTimeline.splice(this.globalIndex + 1);\n this.globalTimeline.push(historyEntry);\n this.globalIndex++;\n\n // 3. Execute and notify with the specific topic\n command.execute();\n this.emitHistoryChange(topic);\n },\n\n undo: (topic?: string) => {\n let affectedTopic: string | undefined;\n\n if (topic) {\n // Scoped Undo\n const topicHistory = this.topicHistories.get(topic);\n if (topicHistory && topicHistory.currentIndex > -1) {\n topicHistory.commands[topicHistory.currentIndex].undo();\n topicHistory.currentIndex--;\n affectedTopic = topic;\n }\n } else {\n // Global Undo\n if (this.globalIndex > -1) {\n const entry = this.globalTimeline[this.globalIndex];\n entry.command.undo();\n this.topicHistories.get(entry.topic)!.currentIndex--;\n this.globalIndex--;\n affectedTopic = entry.topic;\n }\n }\n if (affectedTopic) this.emitHistoryChange(affectedTopic);\n },\n\n redo: (topic?: string) => {\n let affectedTopic: string | undefined;\n\n if (topic) {\n // Scoped Redo\n const topicHistory = this.topicHistories.get(topic);\n if (topicHistory && topicHistory.currentIndex < topicHistory.commands.length - 1) {\n topicHistory.currentIndex++;\n topicHistory.commands[topicHistory.currentIndex].execute();\n affectedTopic = topic;\n }\n } else {\n // Global Redo\n if (this.globalIndex < this.globalTimeline.length - 1) {\n this.globalIndex++;\n const entry = this.globalTimeline[this.globalIndex];\n entry.command.execute();\n this.topicHistories.get(entry.topic)!.currentIndex++;\n affectedTopic = entry.topic;\n }\n }\n if (affectedTopic) this.emitHistoryChange(affectedTopic);\n },\n\n canUndo: (topic?: string) => {\n if (topic) {\n const history = this.topicHistories.get(topic);\n return !!history && history.currentIndex > -1;\n }\n return this.globalIndex > -1;\n },\n\n canRedo: (topic?: string) => {\n if (topic) {\n const history = this.topicHistories.get(topic);\n return !!history && history.currentIndex < history.commands.length - 1;\n }\n return this.globalIndex < this.globalTimeline.length - 1;\n },\n };\n }\n}\n","import { Reducer } from '@embedpdf/core';\nimport { HistoryAction, SET_HISTORY_STATE } from './actions';\nimport { HistoryState } from './types';\n\nexport const initialState: HistoryState = {\n global: {\n canUndo: false,\n canRedo: false,\n },\n topics: {},\n};\n\nexport const reducer: Reducer<HistoryState, HistoryAction> = (state = initialState, action) => {\n switch (action.type) {\n case SET_HISTORY_STATE:\n return {\n ...state,\n ...action.payload,\n };\n default:\n return state;\n }\n};\n","import { PluginPackage } from '@embedpdf/core';\nimport { manifest, HISTORY_PLUGIN_ID } from './manifest';\nimport { HistoryPluginConfig, HistoryState } from './types';\nimport { HistoryPlugin } from './history-plugin';\nimport { initialState, reducer } from './reducer';\nimport { HistoryAction } from './actions';\n\nexport const HistoryPluginPackage: PluginPackage<\n HistoryPlugin,\n HistoryPluginConfig,\n HistoryState,\n HistoryAction\n> = {\n manifest,\n create: (registry, _engine) => new HistoryPlugin(HISTORY_PLUGIN_ID, registry),\n reducer,\n initialState,\n};\n\nexport * from './history-plugin';\nexport * from './types';\nexport * from './manifest';\n"],"names":["HISTORY_PLUGIN_ID","manifest","id","name","version","provides","requires","optional","defaultConfig","enabled","SET_HISTORY_STATE","_HistoryPlugin","BasePlugin","constructor","registry","super","this","topicHistories","Map","globalTimeline","globalIndex","historyChange$","createEmitter","initialize","_","getHistoryState","topics","Array","from","entries","forEach","topic","history","canUndo","currentIndex","canRedo","commands","length","global","emitHistoryChange","state","dispatch","type","payload","emit","buildCapability","onHistoryChange","on","register","command","has","set","topicHistory","get","splice","push","historyEntry","execute","undo","affectedTopic","entry","redo","HistoryPlugin","initialState","HistoryPluginPackage","create","_engine","reducer","action"],"mappings":"kHAGaA,EAAoB,UAEpBC,EAAgD,CAC3DC,GAAIF,EACJG,KAAM,iBACNC,QAAS,QACTC,SAAU,CAAC,WACXC,SAAU,GACVC,SAAU,GACVC,cAAe,CACbC,SAAS,ICVAC,EAAoB,oBCOpBC,EAAN,cAA4BC,EAAAA,WAkBjC,WAAAC,CAAYX,EAAYY,GACtBC,MAAMb,EAAIY,GAXKE,KAAAC,mBAAqBC,IAItCF,KAAQG,eAAiC,GACzCH,KAAQI,aAAc,EAGLJ,KAAAK,eAAiBC,iBAAkC,CAMpE,gBAAMC,CAAWC,GAAuC,CAEhD,eAAAC,GACN,MAAMC,EAAiC,CAAC,EAOjC,OANDC,MAAAC,KAAKZ,KAAKC,eAAeY,WAAWC,SAAQ,EAAEC,EAAOC,MACzDN,EAAOK,GAAS,CACdE,QAASD,EAAQE,cAAe,EAChCC,QAASH,EAAQE,aAAeF,EAAQI,SAASC,OAAS,EAC5D,IAEK,CACLC,OAAQ,CACNL,QAASjB,KAAKI,aAAc,EAC5Be,QAASnB,KAAKI,YAAcJ,KAAKG,eAAekB,OAAS,GAE3DX,SACF,CAIM,iBAAAa,CAAkBR,GDxCG,I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AASC,OAAS,IAChEe,EAAAlB,eACbkB,EAAahB,SAASgB,EAAalB,cAAcuB,UACjCE,EAAA5B,EAClB,MAGA,GAAIf,KAAKI,YAAcJ,KAAKG,eAAekB,OAAS,EAAG,CAChDrB,KAAAI,cACL,MAAMwC,EAAQ5C,KAAKG,eAAeH,KAAKI,aACvCwC,EAAMX,QAAQQ,UACdzC,KAAKC,eAAeoC,IAAIO,EAAM7B,OAAQG,eACtCyB,EAAgBC,EAAM7B,KAAA,CAGtB4B,GAAoB3C,KAAAuB,kBAAkBoB,EAAa,EAGzD1B,QAAUF,IACR,GAAIA,EAAO,CACT,MAAMC,EAAUhB,KAAKC,eAAeoC,IAAItB,GACxC,QAASC,GAAWA,EAAQE,cAAe,CAAA,CAE7C,OAAOlB,KAAKI,aAAc,CAAA,EAG5Be,QAAUJ,IACR,GAAIA,EAAO,CACT,MAAMC,EAAUhB,KAAKC,eAAeoC,IAAItB,GACxC,QAASC,GAAWA,EAAQE,aAAeF,EAAQI,SAASC,OAAS,CAAA,CAEvE,OAAOrB,KAAKI,YAAcJ,KAAKG,eAAekB,OAAS,CAAA,EAE3D,GArIF1B,EAAgBT,GAAK,UANhB,IAAM4D,EAANnD,ECNA,MAAMoD,EAA6B,CACxCzB,OAAQ,CACNL,SAAS,EACTE,SAAS,GAEXT,OAAQ,CAAA,GCFGsC,EAKT,CACF/D,WACAgE,OAAQ,CAACnD,EAAUoD,IAAY,IAAIJ,EAAc9D,EAAmBc,GACpEqD,QDH2D,CAAC3B,EAAQuB,EAAcK,IAC1EA,EAAO1B,OACRhC,EACI,IACF8B,KACA4B,EAAOzB,SAGLH,ECJXuB"}
package/dist/index.d.ts CHANGED
@@ -1,100 +1 @@
1
- import { BasePluginConfig, EventHook, Action, BasePlugin, PluginRegistry, PluginManifest, PluginPackage } from '@embedpdf/core';
2
-
3
- interface HistoryPluginConfig extends BasePluginConfig {
4
- }
5
- /**
6
- * The core Command interface that other plugins will implement.
7
- */
8
- interface Command {
9
- /** A function that applies the change. */
10
- execute(): void;
11
- /** A function that reverts the change. */
12
- undo(): void;
13
- }
14
- /**
15
- * An entry in the global timeline, associating a command with its topic.
16
- */
17
- interface HistoryEntry {
18
- command: Command;
19
- topic: string;
20
- }
21
- /**
22
- * Information about the history state, to be emitted for UI updates.
23
- * Includes a global state and a record of each topic's state.
24
- */
25
- interface HistoryState {
26
- global: {
27
- canUndo: boolean;
28
- canRedo: boolean;
29
- };
30
- topics: Record<string, {
31
- canUndo: boolean;
32
- canRedo: boolean;
33
- }>;
34
- }
35
- interface HistoryCapability {
36
- /**
37
- * Registers a command with the history stack.
38
- * @param command The command to register, with `execute` and `undo` methods.
39
- * @param topic A string identifier for the history scope (e.g., 'annotations').
40
- */
41
- register: (command: Command, topic: string) => void;
42
- /**
43
- * Undoes the last command.
44
- * @param topic If provided, undoes the last command for that specific topic.
45
- * If omitted, performs a global undo of the very last action.
46
- */
47
- undo: (topic?: string) => void;
48
- /**
49
- * Redoes the last undone command.
50
- * @param topic If provided, redoes the last command for that specific topic.
51
- * If omitted, performs a global redo.
52
- */
53
- redo: (topic?: string) => void;
54
- /**
55
- * Checks if an undo operation is possible.
56
- * @param topic If provided, checks for the specific topic. Otherwise, checks globally.
57
- */
58
- canUndo: (topic?: string) => boolean;
59
- /**
60
- * Checks if a redo operation is possible.
61
- * @param topic If provided, checks for the specific topic. Otherwise, checks globally.
62
- */
63
- canRedo: (topic?: string) => boolean;
64
- /**
65
- * An event hook that fires whenever a history action occurs.
66
- * @param topic The topic string that was affected by the action.
67
- */
68
- onHistoryChange: EventHook<string | undefined>;
69
- /**
70
- * Returns the current undo/redo state for all topics and the global timeline.
71
- */
72
- getHistoryState: () => HistoryState;
73
- }
74
-
75
- declare const SET_HISTORY_STATE = "HISTORY/SET_STATE";
76
- interface SetHistoryStateAction extends Action {
77
- type: typeof SET_HISTORY_STATE;
78
- payload: HistoryState;
79
- }
80
- type HistoryAction = SetHistoryStateAction;
81
-
82
- declare class HistoryPlugin extends BasePlugin<HistoryPluginConfig, HistoryCapability, HistoryState, HistoryAction> {
83
- static readonly id: "history";
84
- private readonly topicHistories;
85
- private globalTimeline;
86
- private globalIndex;
87
- private readonly historyChange$;
88
- constructor(id: string, registry: PluginRegistry);
89
- initialize(_: HistoryPluginConfig): Promise<void>;
90
- private getHistoryState;
91
- private emitHistoryChange;
92
- protected buildCapability(): HistoryCapability;
93
- }
94
-
95
- declare const HISTORY_PLUGIN_ID = "history";
96
- declare const manifest: PluginManifest<HistoryPluginConfig>;
97
-
98
- declare const HistoryPluginPackage: PluginPackage<HistoryPlugin, HistoryPluginConfig, HistoryState, HistoryAction>;
99
-
100
- export { type Command, HISTORY_PLUGIN_ID, type HistoryCapability, type HistoryEntry, HistoryPlugin, type HistoryPluginConfig, HistoryPluginPackage, type HistoryState, manifest };
1
+ export * from './lib';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- // src/lib/manifest.ts
2
- var HISTORY_PLUGIN_ID = "history";
3
- var manifest = {
1
+ import { BasePlugin, createEmitter } from "@embedpdf/core";
2
+ const HISTORY_PLUGIN_ID = "history";
3
+ const manifest = {
4
4
  id: HISTORY_PLUGIN_ID,
5
5
  name: "History Plugin",
6
6
  version: "1.0.0",
@@ -11,25 +11,17 @@ var manifest = {
11
11
  enabled: true
12
12
  }
13
13
  };
14
-
15
- // src/lib/history-plugin.ts
16
- import { BasePlugin, createEmitter } from "@embedpdf/core";
17
-
18
- // src/lib/actions.ts
19
- var SET_HISTORY_STATE = "HISTORY/SET_STATE";
20
- var setHistoryState = (state) => ({
14
+ const SET_HISTORY_STATE = "HISTORY/SET_STATE";
15
+ const setHistoryState = (state) => ({
21
16
  type: SET_HISTORY_STATE,
22
17
  payload: state
23
18
  });
24
-
25
- // src/lib/history-plugin.ts
26
- var HistoryPlugin = class extends BasePlugin {
19
+ const _HistoryPlugin = class _HistoryPlugin extends BasePlugin {
27
20
  constructor(id, registry) {
28
21
  super(id, registry);
29
22
  this.topicHistories = /* @__PURE__ */ new Map();
30
23
  this.globalTimeline = [];
31
24
  this.globalIndex = -1;
32
- // This emitter will now broadcast the topic string of the affected history.
33
25
  this.historyChange$ = createEmitter();
34
26
  }
35
27
  async initialize(_) {
@@ -131,17 +123,16 @@ var HistoryPlugin = class extends BasePlugin {
131
123
  };
132
124
  }
133
125
  };
134
- HistoryPlugin.id = "history";
135
-
136
- // src/lib/reducer.ts
137
- var initialState = {
126
+ _HistoryPlugin.id = "history";
127
+ let HistoryPlugin = _HistoryPlugin;
128
+ const initialState = {
138
129
  global: {
139
130
  canUndo: false,
140
131
  canRedo: false
141
132
  },
142
133
  topics: {}
143
134
  };
144
- var reducer = (state = initialState, action) => {
135
+ const reducer = (state = initialState, action) => {
145
136
  switch (action.type) {
146
137
  case SET_HISTORY_STATE:
147
138
  return {
@@ -152,9 +143,7 @@ var reducer = (state = initialState, action) => {
152
143
  return state;
153
144
  }
154
145
  };
155
-
156
- // src/lib/index.ts
157
- var HistoryPluginPackage = {
146
+ const HistoryPluginPackage = {
158
147
  manifest,
159
148
  create: (registry, _engine) => new HistoryPlugin(HISTORY_PLUGIN_ID, registry),
160
149
  reducer,
@@ -166,4 +155,4 @@ export {
166
155
  HistoryPluginPackage,
167
156
  manifest
168
157
  };
169
- //# sourceMappingURL=index.js.map
158
+ //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/manifest.ts","../src/lib/history-plugin.ts","../src/lib/actions.ts","../src/lib/reducer.ts","../src/lib/index.ts"],"sourcesContent":["import { PluginManifest } from '@embedpdf/core';\nimport { HistoryPluginConfig } from './types';\n\nexport const HISTORY_PLUGIN_ID = 'history';\n\nexport const manifest: PluginManifest<HistoryPluginConfig> = {\n id: HISTORY_PLUGIN_ID,\n name: 'History Plugin',\n version: '1.0.0',\n provides: ['history'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n },\n};\n","import { BasePlugin, createEmitter, PluginRegistry } from '@embedpdf/core';\nimport {\n Command,\n HistoryCapability,\n HistoryEntry,\n HistoryPluginConfig,\n HistoryState,\n} from './types';\nimport { HistoryAction, setHistoryState } from './actions';\n\nexport class HistoryPlugin extends BasePlugin<\n HistoryPluginConfig,\n HistoryCapability,\n HistoryState,\n HistoryAction\n> {\n static readonly id = 'history' as const;\n\n private readonly topicHistories = new Map<\n string,\n { commands: Command[]; currentIndex: number }\n >();\n private globalTimeline: HistoryEntry[] = [];\n private globalIndex = -1;\n\n // This emitter will now broadcast the topic string of the affected history.\n private readonly historyChange$ = createEmitter<string | undefined>();\n\n constructor(id: string, registry: PluginRegistry) {\n super(id, registry);\n }\n\n async initialize(_: HistoryPluginConfig): Promise<void> {}\n\n private getHistoryState(): HistoryState {\n const topics: HistoryState['topics'] = {};\n Array.from(this.topicHistories.entries()).forEach(([topic, history]) => {\n topics[topic] = {\n canUndo: history.currentIndex > -1,\n canRedo: history.currentIndex < history.commands.length - 1,\n };\n });\n return {\n global: {\n canUndo: this.globalIndex > -1,\n canRedo: this.globalIndex < this.globalTimeline.length - 1,\n },\n topics,\n };\n }\n\n // The emit function now accepts the topic to broadcast.\n private emitHistoryChange(topic: string) {\n // update the state\n this.dispatch(setHistoryState(this.getHistoryState()));\n\n // emit the event\n this.historyChange$.emit(topic);\n }\n\n protected buildCapability(): HistoryCapability {\n return {\n getHistoryState: () => this.state,\n onHistoryChange: this.historyChange$.on,\n\n register: (command: Command, topic: string) => {\n // 1. Manage Topic History\n if (!this.topicHistories.has(topic)) {\n this.topicHistories.set(topic, { commands: [], currentIndex: -1 });\n }\n const topicHistory = this.topicHistories.get(topic)!;\n topicHistory.commands.splice(topicHistory.currentIndex + 1);\n topicHistory.commands.push(command);\n topicHistory.currentIndex++;\n\n // 2. Manage Global History\n const historyEntry: HistoryEntry = { command, topic };\n this.globalTimeline.splice(this.globalIndex + 1);\n this.globalTimeline.push(historyEntry);\n this.globalIndex++;\n\n // 3. Execute and notify with the specific topic\n command.execute();\n this.emitHistoryChange(topic);\n },\n\n undo: (topic?: string) => {\n let affectedTopic: string | undefined;\n\n if (topic) {\n // Scoped Undo\n const topicHistory = this.topicHistories.get(topic);\n if (topicHistory && topicHistory.currentIndex > -1) {\n topicHistory.commands[topicHistory.currentIndex].undo();\n topicHistory.currentIndex--;\n affectedTopic = topic;\n }\n } else {\n // Global Undo\n if (this.globalIndex > -1) {\n const entry = this.globalTimeline[this.globalIndex];\n entry.command.undo();\n this.topicHistories.get(entry.topic)!.currentIndex--;\n this.globalIndex--;\n affectedTopic = entry.topic;\n }\n }\n if (affectedTopic) this.emitHistoryChange(affectedTopic);\n },\n\n redo: (topic?: string) => {\n let affectedTopic: string | undefined;\n\n if (topic) {\n // Scoped Redo\n const topicHistory = this.topicHistories.get(topic);\n if (topicHistory && topicHistory.currentIndex < topicHistory.commands.length - 1) {\n topicHistory.currentIndex++;\n topicHistory.commands[topicHistory.currentIndex].execute();\n affectedTopic = topic;\n }\n } else {\n // Global Redo\n if (this.globalIndex < this.globalTimeline.length - 1) {\n this.globalIndex++;\n const entry = this.globalTimeline[this.globalIndex];\n entry.command.execute();\n this.topicHistories.get(entry.topic)!.currentIndex++;\n affectedTopic = entry.topic;\n }\n }\n if (affectedTopic) this.emitHistoryChange(affectedTopic);\n },\n\n canUndo: (topic?: string) => {\n if (topic) {\n const history = this.topicHistories.get(topic);\n return !!history && history.currentIndex > -1;\n }\n return this.globalIndex > -1;\n },\n\n canRedo: (topic?: string) => {\n if (topic) {\n const history = this.topicHistories.get(topic);\n return !!history && history.currentIndex < history.commands.length - 1;\n }\n return this.globalIndex < this.globalTimeline.length - 1;\n },\n };\n }\n}\n","import { Action } from '@embedpdf/core';\nimport { HistoryState } from './types';\n\nexport const SET_HISTORY_STATE = 'HISTORY/SET_STATE';\n\nexport interface SetHistoryStateAction extends Action {\n type: typeof SET_HISTORY_STATE;\n payload: HistoryState;\n}\n\nexport type HistoryAction = SetHistoryStateAction;\n\nexport const setHistoryState = (state: HistoryState): SetHistoryStateAction => ({\n type: SET_HISTORY_STATE,\n payload: state,\n});\n","import { Reducer } from '@embedpdf/core';\nimport { HistoryAction, SET_HISTORY_STATE } from './actions';\nimport { HistoryState } from './types';\n\nexport const initialState: HistoryState = {\n global: {\n canUndo: false,\n canRedo: false,\n },\n topics: {},\n};\n\nexport const reducer: Reducer<HistoryState, HistoryAction> = (state = initialState, action) => {\n switch (action.type) {\n case SET_HISTORY_STATE:\n return {\n ...state,\n ...action.payload,\n };\n default:\n return state;\n }\n};\n","import { PluginPackage } from '@embedpdf/core';\nimport { manifest, HISTORY_PLUGIN_ID } from './manifest';\nimport { HistoryPluginConfig, HistoryState } from './types';\nimport { HistoryPlugin } from './history-plugin';\nimport { initialState, reducer } from './reducer';\nimport { HistoryAction } from './actions';\n\nexport const HistoryPluginPackage: PluginPackage<\n HistoryPlugin,\n HistoryPluginConfig,\n HistoryState,\n HistoryAction\n> = {\n manifest,\n create: (registry, _engine) => new HistoryPlugin(HISTORY_PLUGIN_ID, registry),\n reducer,\n initialState,\n};\n\nexport * from './history-plugin';\nexport * from './types';\nexport * from './manifest';\n"],"mappings":";AAGO,IAAM,oBAAoB;AAE1B,IAAM,WAAgD;AAAA,EAC3D,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU,CAAC,SAAS;AAAA,EACpB,UAAU,CAAC;AAAA,EACX,UAAU,CAAC;AAAA,EACX,eAAe;AAAA,IACb,SAAS;AAAA,EACX;AACF;;;ACfA,SAAS,YAAY,qBAAqC;;;ACGnD,IAAM,oBAAoB;AAS1B,IAAM,kBAAkB,CAAC,WAAgD;AAAA,EAC9E,MAAM;AAAA,EACN,SAAS;AACX;;;ADLO,IAAM,gBAAN,cAA4B,WAKjC;AAAA,EAaA,YAAY,IAAY,UAA0B;AAChD,UAAM,IAAI,QAAQ;AAXpB,SAAiB,iBAAiB,oBAAI,IAGpC;AACF,SAAQ,iBAAiC,CAAC;AAC1C,SAAQ,cAAc;AAGtB;AAAA,SAAiB,iBAAiB,cAAkC;A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AAU,KAAK,eAAe,IAAI,KAAK;AAC7C,iBAAO,CAAC,CAAC,WAAW,QAAQ,eAAe,QAAQ,SAAS,SAAS;AAAA,QACvE;AACA,eAAO,KAAK,cAAc,KAAK,eAAe,SAAS;AAAA,MACzD;AAAA,IACF;AAAA,EACF;AACF;AA7Ia,cAMK,KAAK;;;AEZhB,IAAM,eAA6B;AAAA,EACxC,QAAQ;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,EACX;AAAA,EACA,QAAQ,CAAC;AACX;AAEO,IAAM,UAAgD,CAAC,QAAQ,cAAc,WAAW;AAC7F,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK;AACH,aAAO;AAAA,QACL,GAAG;AAAA,QACH,GAAG,OAAO;AAAA,MACZ;AAAA,IACF;AACE,aAAO;AAAA,EACX;AACF;;;ACfO,IAAM,uBAKT;AAAA,EACF;AAAA,EACA,QAAQ,CAAC,UAAU,YAAY,IAAI,cAAc,mBAAmB,QAAQ;AAAA,EAC5E;AAAA,EACA;AACF;","names":[]}
1
+ {"version":3,"file":"index.js","sources":["../src/lib/manifest.ts","../src/lib/actions.ts","../src/lib/history-plugin.ts","../src/lib/reducer.ts","../src/lib/index.ts"],"sourcesContent":["import { PluginManifest } from '@embedpdf/core';\nimport { HistoryPluginConfig } from './types';\n\nexport const HISTORY_PLUGIN_ID = 'history';\n\nexport const manifest: PluginManifest<HistoryPluginConfig> = {\n id: HISTORY_PLUGIN_ID,\n name: 'History Plugin',\n version: '1.0.0',\n provides: ['history'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n },\n};\n","import { Action } from '@embedpdf/core';\nimport { HistoryState } from './types';\n\nexport const SET_HISTORY_STATE = 'HISTORY/SET_STATE';\n\nexport interface SetHistoryStateAction extends Action {\n type: typeof SET_HISTORY_STATE;\n payload: HistoryState;\n}\n\nexport type HistoryAction = SetHistoryStateAction;\n\nexport const setHistoryState = (state: HistoryState): SetHistoryStateAction => ({\n type: SET_HISTORY_STATE,\n payload: state,\n});\n","import { BasePlugin, createEmitter, PluginRegistry } from '@embedpdf/core';\nimport {\n Command,\n HistoryCapability,\n HistoryEntry,\n HistoryPluginConfig,\n HistoryState,\n} from './types';\nimport { HistoryAction, setHistoryState } from './actions';\n\nexport class HistoryPlugin extends BasePlugin<\n HistoryPluginConfig,\n HistoryCapability,\n HistoryState,\n HistoryAction\n> {\n static readonly id = 'history' as const;\n\n private readonly topicHistories = new Map<\n string,\n { commands: Command[]; currentIndex: number }\n >();\n private globalTimeline: HistoryEntry[] = [];\n private globalIndex = -1;\n\n // This emitter will now broadcast the topic string of the affected history.\n private readonly historyChange$ = createEmitter<string | undefined>();\n\n constructor(id: string, registry: PluginRegistry) {\n super(id, registry);\n }\n\n async initialize(_: HistoryPluginConfig): Promise<void> {}\n\n private getHistoryState(): HistoryState {\n const topics: HistoryState['topics'] = {};\n Array.from(this.topicHistories.entries()).forEach(([topic, history]) => {\n topics[topic] = {\n canUndo: history.currentIndex > -1,\n canRedo: history.currentIndex < history.commands.length - 1,\n };\n });\n return {\n global: {\n canUndo: this.globalIndex > -1,\n canRedo: this.globalIndex < this.globalTimeline.length - 1,\n },\n topics,\n };\n }\n\n // The emit function now accepts the topic to broadcast.\n private emitHistoryChange(topic: string) {\n // update the state\n this.dispatch(setHistoryState(this.getHistoryState()));\n\n // emit the event\n this.historyChange$.emit(topic);\n }\n\n protected buildCapability(): HistoryCapability {\n return {\n getHistoryState: () => this.state,\n onHistoryChange: this.historyChange$.on,\n\n register: (command: Command, topic: string) => {\n // 1. Manage Topic History\n if (!this.topicHistories.has(topic)) {\n this.topicHistories.set(topic, { commands: [], currentIndex: -1 });\n }\n const topicHistory = this.topicHistories.get(topic)!;\n topicHistory.commands.splice(topicHistory.currentIndex + 1);\n topicHistory.commands.push(command);\n topicHistory.currentIndex++;\n\n // 2. Manage Global History\n const historyEntry: HistoryEntry = { command, topic };\n this.globalTimeline.splice(this.globalIndex + 1);\n this.globalTimeline.push(historyEntry);\n this.globalIndex++;\n\n // 3. Execute and notify with the specific topic\n command.execute();\n this.emitHistoryChange(topic);\n },\n\n undo: (topic?: string) => {\n let affectedTopic: string | undefined;\n\n if (topic) {\n // Scoped Undo\n const topicHistory = this.topicHistories.get(topic);\n if (topicHistory && topicHistory.currentIndex > -1) {\n topicHistory.commands[topicHistory.currentIndex].undo();\n topicHistory.currentIndex--;\n affectedTopic = topic;\n }\n } else {\n // Global Undo\n if (this.globalIndex > -1) {\n const entry = this.globalTimeline[this.globalIndex];\n entry.command.undo();\n this.topicHistories.get(entry.topic)!.currentIndex--;\n this.globalIndex--;\n affectedTopic = entry.topic;\n }\n }\n if (affectedTopic) this.emitHistoryChange(affectedTopic);\n },\n\n redo: (topic?: string) => {\n let affectedTopic: string | undefined;\n\n if (topic) {\n // Scoped Redo\n const topicHistory = this.topicHistories.get(topic);\n if (topicHistory && topicHistory.currentIndex < topicHistory.commands.length - 1) {\n topicHistory.currentIndex++;\n topicHistory.commands[topicHistory.currentIndex].execute();\n affectedTopic = topic;\n }\n } else {\n // Global Redo\n if (this.globalIndex < this.globalTimeline.length - 1) {\n this.globalIndex++;\n const entry = this.globalTimeline[this.globalIndex];\n entry.command.execute();\n this.topicHistories.get(entry.topic)!.currentIndex++;\n affectedTopic = entry.topic;\n }\n }\n if (affectedTopic) this.emitHistoryChange(affectedTopic);\n },\n\n canUndo: (topic?: string) => {\n if (topic) {\n const history = this.topicHistories.get(topic);\n return !!history && history.currentIndex > -1;\n }\n return this.globalIndex > -1;\n },\n\n canRedo: (topic?: string) => {\n if (topic) {\n const history = this.topicHistories.get(topic);\n return !!history && history.currentIndex < history.commands.length - 1;\n }\n return this.globalIndex < this.globalTimeline.length - 1;\n },\n };\n }\n}\n","import { Reducer } from '@embedpdf/core';\nimport { HistoryAction, SET_HISTORY_STATE } from './actions';\nimport { HistoryState } from './types';\n\nexport const initialState: HistoryState = {\n global: {\n canUndo: false,\n canRedo: false,\n },\n topics: {},\n};\n\nexport const reducer: Reducer<HistoryState, HistoryAction> = (state = initialState, action) => {\n switch (action.type) {\n case SET_HISTORY_STATE:\n return {\n ...state,\n ...action.payload,\n };\n default:\n return state;\n }\n};\n","import { PluginPackage } from '@embedpdf/core';\nimport { manifest, HISTORY_PLUGIN_ID } from './manifest';\nimport { HistoryPluginConfig, HistoryState } from './types';\nimport { HistoryPlugin } from './history-plugin';\nimport { initialState, reducer } from './reducer';\nimport { HistoryAction } from './actions';\n\nexport const HistoryPluginPackage: PluginPackage<\n HistoryPlugin,\n HistoryPluginConfig,\n HistoryState,\n HistoryAction\n> = {\n manifest,\n create: (registry, _engine) => new HistoryPlugin(HISTORY_PLUGIN_ID, registry),\n reducer,\n initialState,\n};\n\nexport * from './history-plugin';\nexport * from './types';\nexport * from './manifest';\n"],"names":[],"mappings":";AAGO,MAAM,oBAAoB;AAE1B,MAAM,WAAgD;AAAA,EAC3D,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU,CAAC,SAAS;AAAA,EACpB,UAAU,CAAC;AAAA,EACX,UAAU,CAAC;AAAA,EACX,eAAe;AAAA,IACb,SAAS;AAAA,EAAA;AAEb;ACZO,MAAM,oBAAoB;AASpB,MAAA,kBAAkB,CAAC,WAAgD;AAAA,EAC9E,MAAM;AAAA,EACN,SAAS;AACX;ACLO,MAAM,iBAAN,MAAM,uBAAsB,WAKjC;AAAA,EAaA,YAAY,IAAY,UAA0B;AAChD,UAAM,IAAI,QAAQ;AAXH,SAAA,qCAAqB,IAGpC;AACF,SAAQ,iBAAiC,CAAC;AAC1C,SAAQ,cAAc;AAGtB,SAAiB,iBAAiB,cAAkC;AAAA,EAAA;AAAA,EAMpE,MAAM,WAAW,GAAuC;AAAA,EAAA;AAAA,EAEhD,kBAAgC;AACtC,UAAM,SAAiC,CAAC;AAClC,UAAA,KAAK,KAAK,eAAe,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,OAAO,OAAO,MAAM;AACtE,aAAO,KAAK,IAAI;AAAA,QACd,SAAS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,gBAAN;ACNA,MAAM,eAA6B;AAAA,EACxC,QAAQ;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,EACX;AAAA,EACA,QAAQ,CAAA;AACV;AAEO,MAAM,UAAgD,CAAC,QAAQ,cAAc,WAAW;AAC7F,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK;AACI,aAAA;AAAA,QACL,GAAG;AAAA,QACH,GAAG,OAAO;AAAA,MACZ;AAAA,IACF;AACS,aAAA;AAAA,EAAA;AAEb;ACfO,MAAM,uBAKT;AAAA,EACF;AAAA,EACA,QAAQ,CAAC,UAAU,YAAY,IAAI,cAAc,mBAAmB,QAAQ;AAAA,EAC5E;AAAA,EACA;AACF;"}
@@ -0,0 +1,9 @@
1
+ import { Action } from '@embedpdf/core';
2
+ import { HistoryState } from './types';
3
+ export declare const SET_HISTORY_STATE = "HISTORY/SET_STATE";
4
+ export interface SetHistoryStateAction extends Action {
5
+ type: typeof SET_HISTORY_STATE;
6
+ payload: HistoryState;
7
+ }
8
+ export type HistoryAction = SetHistoryStateAction;
9
+ export declare const setHistoryState: (state: HistoryState) => SetHistoryStateAction;
@@ -0,0 +1,15 @@
1
+ import { BasePlugin, PluginRegistry } from '@embedpdf/core';
2
+ import { HistoryCapability, HistoryPluginConfig, HistoryState } from './types';
3
+ import { HistoryAction } from './actions';
4
+ export declare class HistoryPlugin extends BasePlugin<HistoryPluginConfig, HistoryCapability, HistoryState, HistoryAction> {
5
+ static readonly id: "history";
6
+ private readonly topicHistories;
7
+ private globalTimeline;
8
+ private globalIndex;
9
+ private readonly historyChange$;
10
+ constructor(id: string, registry: PluginRegistry);
11
+ initialize(_: HistoryPluginConfig): Promise<void>;
12
+ private getHistoryState;
13
+ private emitHistoryChange;
14
+ protected buildCapability(): HistoryCapability;
15
+ }
@@ -0,0 +1,8 @@
1
+ import { PluginPackage } from '@embedpdf/core';
2
+ import { HistoryPluginConfig, HistoryState } from './types';
3
+ import { HistoryPlugin } from './history-plugin';
4
+ import { HistoryAction } from './actions';
5
+ export declare const HistoryPluginPackage: PluginPackage<HistoryPlugin, HistoryPluginConfig, HistoryState, HistoryAction>;
6
+ export * from './history-plugin';
7
+ export * from './types';
8
+ export * from './manifest';
@@ -0,0 +1,4 @@
1
+ import { PluginManifest } from '@embedpdf/core';
2
+ import { HistoryPluginConfig } from './types';
3
+ export declare const HISTORY_PLUGIN_ID = "history";
4
+ export declare const manifest: PluginManifest<HistoryPluginConfig>;
@@ -0,0 +1,5 @@
1
+ import { Reducer } from '@embedpdf/core';
2
+ import { HistoryAction } from './actions';
3
+ import { HistoryState } from './types';
4
+ export declare const initialState: HistoryState;
5
+ export declare const reducer: Reducer<HistoryState, HistoryAction>;
@@ -1,11 +1,10 @@
1
- import { BasePluginConfig, EventHook, Action, BasePlugin, PluginRegistry, PluginManifest, PluginPackage } from '@embedpdf/core';
2
-
3
- interface HistoryPluginConfig extends BasePluginConfig {
1
+ import { BasePluginConfig, EventHook } from '@embedpdf/core';
2
+ export interface HistoryPluginConfig extends BasePluginConfig {
4
3
  }
5
4
  /**
6
5
  * The core Command interface that other plugins will implement.
7
6
  */
8
- interface Command {
7
+ export interface Command {
9
8
  /** A function that applies the change. */
10
9
  execute(): void;
11
10
  /** A function that reverts the change. */
@@ -14,7 +13,7 @@ interface Command {
14
13
  /**
15
14
  * An entry in the global timeline, associating a command with its topic.
16
15
  */
17
- interface HistoryEntry {
16
+ export interface HistoryEntry {
18
17
  command: Command;
19
18
  topic: string;
20
19
  }
@@ -22,7 +21,7 @@ interface HistoryEntry {
22
21
  * Information about the history state, to be emitted for UI updates.
23
22
  * Includes a global state and a record of each topic's state.
24
23
  */
25
- interface HistoryState {
24
+ export interface HistoryState {
26
25
  global: {
27
26
  canUndo: boolean;
28
27
  canRedo: boolean;
@@ -32,7 +31,7 @@ interface HistoryState {
32
31
  canRedo: boolean;
33
32
  }>;
34
33
  }
35
- interface HistoryCapability {
34
+ export interface HistoryCapability {
36
35
  /**
37
36
  * Registers a command with the history stack.
38
37
  * @param command The command to register, with `execute` and `undo` methods.
@@ -71,30 +70,3 @@ interface HistoryCapability {
71
70
  */
72
71
  getHistoryState: () => HistoryState;
73
72
  }
74
-
75
- declare const SET_HISTORY_STATE = "HISTORY/SET_STATE";
76
- interface SetHistoryStateAction extends Action {
77
- type: typeof SET_HISTORY_STATE;
78
- payload: HistoryState;
79
- }
80
- type HistoryAction = SetHistoryStateAction;
81
-
82
- declare class HistoryPlugin extends BasePlugin<HistoryPluginConfig, HistoryCapability, HistoryState, HistoryAction> {
83
- static readonly id: "history";
84
- private readonly topicHistories;
85
- private globalTimeline;
86
- private globalIndex;
87
- private readonly historyChange$;
88
- constructor(id: string, registry: PluginRegistry);
89
- initialize(_: HistoryPluginConfig): Promise<void>;
90
- private getHistoryState;
91
- private emitHistoryChange;
92
- protected buildCapability(): HistoryCapability;
93
- }
94
-
95
- declare const HISTORY_PLUGIN_ID = "history";
96
- declare const manifest: PluginManifest<HistoryPluginConfig>;
97
-
98
- declare const HistoryPluginPackage: PluginPackage<HistoryPlugin, HistoryPluginConfig, HistoryState, HistoryAction>;
99
-
100
- export { type Command, HISTORY_PLUGIN_ID, type HistoryCapability, type HistoryEntry, HistoryPlugin, type HistoryPluginConfig, HistoryPluginPackage, type HistoryState, manifest };
@@ -0,0 +1 @@
1
+ export { useEffect, useRef, useState, useCallback } from 'preact/hooks';
@@ -0,0 +1 @@
1
+ export * from '@embedpdf/core/preact';
@@ -1,38 +1,2 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/preact/index.ts
21
- var preact_exports = {};
22
- __export(preact_exports, {
23
- useHistoryCapability: () => useHistoryCapability,
24
- useHistoryPlugin: () => useHistoryPlugin
25
- });
26
- module.exports = __toCommonJS(preact_exports);
27
-
28
- // src/preact/hooks/use-history.ts
29
- var import_preact = require("@embedpdf/core/preact");
30
- var import_plugin_history = require("@embedpdf/plugin-history");
31
- var useHistoryPlugin = () => (0, import_preact.usePlugin)(import_plugin_history.HistoryPlugin.id);
32
- var useHistoryCapability = () => (0, import_preact.useCapability)(import_plugin_history.HistoryPlugin.id);
33
- // Annotate the CommonJS export names for ESM import in node:
34
- 0 && (module.exports = {
35
- useHistoryCapability,
36
- useHistoryPlugin
37
- });
38
- //# sourceMappingURL=index.cjs.map
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/preact"),i=require("@embedpdf/plugin-history");exports.useHistoryCapability=()=>e.useCapability(i.HistoryPlugin.id),exports.useHistoryPlugin=()=>e.usePlugin(i.HistoryPlugin.id);
2
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/preact/index.ts","../../src/preact/hooks/use-history.ts"],"sourcesContent":["export * from './hooks';\n","import { useCapability, usePlugin } from '@embedpdf/core/preact';\nimport { HistoryPlugin } from '@embedpdf/plugin-history';\n\nexport const useHistoryPlugin = () => usePlugin<HistoryPlugin>(HistoryPlugin.id);\nexport const useHistoryCapability = () => useCapability<HistoryPlugin>(HistoryPlugin.id);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAyC;AACzC,4BAA8B;AAEvB,IAAM,mBAAmB,UAAM,yBAAyB,oCAAc,EAAE;AACxE,IAAM,uBAAuB,UAAM,6BAA6B,oCAAc,EAAE;","names":[]}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-history.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { HistoryPlugin } from '@embedpdf/plugin-history';\n\nexport const useHistoryPlugin = () => usePlugin<HistoryPlugin>(HistoryPlugin.id);\nexport const useHistoryCapability = () => useCapability<HistoryPlugin>(HistoryPlugin.id);\n"],"names":["useCapability","HistoryPlugin","id","usePlugin"],"mappings":"4LAIoC,IAAMA,gBAA6BC,EAAAA,cAAcC,6BADrD,IAAMC,YAAyBF,EAAAA,cAAcC"}
@@ -1,15 +1 @@
1
- import * as _embedpdf_plugin_history from '@embedpdf/plugin-history';
2
- import { HistoryPlugin } from '@embedpdf/plugin-history';
3
-
4
- declare const useHistoryPlugin: () => {
5
- plugin: HistoryPlugin | null;
6
- isLoading: boolean;
7
- ready: Promise<void>;
8
- };
9
- declare const useHistoryCapability: () => {
10
- provides: Readonly<_embedpdf_plugin_history.HistoryCapability> | null;
11
- isLoading: boolean;
12
- ready: Promise<void>;
13
- };
14
-
15
- export { useHistoryCapability, useHistoryPlugin };
1
+ export * from '../shared-preact';
@@ -1,10 +1,9 @@
1
- // src/preact/hooks/use-history.ts
2
- import { useCapability, usePlugin } from "@embedpdf/core/preact";
1
+ import { usePlugin, useCapability } from "@embedpdf/core/preact";
3
2
  import { HistoryPlugin } from "@embedpdf/plugin-history";
4
- var useHistoryPlugin = () => usePlugin(HistoryPlugin.id);
5
- var useHistoryCapability = () => useCapability(HistoryPlugin.id);
3
+ const useHistoryPlugin = () => usePlugin(HistoryPlugin.id);
4
+ const useHistoryCapability = () => useCapability(HistoryPlugin.id);
6
5
  export {
7
6
  useHistoryCapability,
8
7
  useHistoryPlugin
9
8
  };
10
- //# sourceMappingURL=index.js.map
9
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/preact/hooks/use-history.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/preact';\nimport { HistoryPlugin } from '@embedpdf/plugin-history';\n\nexport const useHistoryPlugin = () => usePlugin<HistoryPlugin>(HistoryPlugin.id);\nexport const useHistoryCapability = () => useCapability<HistoryPlugin>(HistoryPlugin.id);\n"],"mappings":";AAAA,SAAS,eAAe,iBAAiB;AACzC,SAAS,qBAAqB;AAEvB,IAAM,mBAAmB,MAAM,UAAyB,cAAc,EAAE;AACxE,IAAM,uBAAuB,MAAM,cAA6B,cAAc,EAAE;","names":[]}
1
+ {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-history.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { HistoryPlugin } from '@embedpdf/plugin-history';\n\nexport const useHistoryPlugin = () => usePlugin<HistoryPlugin>(HistoryPlugin.id);\nexport const useHistoryCapability = () => useCapability<HistoryPlugin>(HistoryPlugin.id);\n"],"names":[],"mappings":";;AAGO,MAAM,mBAAmB,MAAM,UAAyB,cAAc,EAAE;AACxE,MAAM,uBAAuB,MAAM,cAA6B,cAAc,EAAE;"}
@@ -0,0 +1 @@
1
+ export { useEffect, useRef, useCallback, useState } from 'react';
@@ -0,0 +1 @@
1
+ export * from '@embedpdf/core/react';
@@ -1,38 +1,2 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/react/index.ts
21
- var react_exports = {};
22
- __export(react_exports, {
23
- useHistoryCapability: () => useHistoryCapability,
24
- useHistoryPlugin: () => useHistoryPlugin
25
- });
26
- module.exports = __toCommonJS(react_exports);
27
-
28
- // src/react/hooks/use-history.ts
29
- var import_react = require("@embedpdf/core/react");
30
- var import_plugin_history = require("@embedpdf/plugin-history");
31
- var useHistoryPlugin = () => (0, import_react.usePlugin)(import_plugin_history.HistoryPlugin.id);
32
- var useHistoryCapability = () => (0, import_react.useCapability)(import_plugin_history.HistoryPlugin.id);
33
- // Annotate the CommonJS export names for ESM import in node:
34
- 0 && (module.exports = {
35
- useHistoryCapability,
36
- useHistoryPlugin
37
- });
38
- //# sourceMappingURL=index.cjs.map
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/react"),i=require("@embedpdf/plugin-history");exports.useHistoryCapability=()=>e.useCapability(i.HistoryPlugin.id),exports.useHistoryPlugin=()=>e.usePlugin(i.HistoryPlugin.id);
2
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/react/index.ts","../../src/react/hooks/use-history.ts"],"sourcesContent":["export * from './hooks';\n","import { useCapability, usePlugin } from '@embedpdf/core/react';\nimport { HistoryPlugin } from '@embedpdf/plugin-history';\n\nexport const useHistoryPlugin = () => usePlugin<HistoryPlugin>(HistoryPlugin.id);\nexport const useHistoryCapability = () => useCapability<HistoryPlugin>(HistoryPlugin.id);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAyC;AACzC,4BAA8B;AAEvB,IAAM,mBAAmB,UAAM,wBAAyB,oCAAc,EAAE;AACxE,IAAM,uBAAuB,UAAM,4BAA6B,oCAAc,EAAE;","names":[]}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-history.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { HistoryPlugin } from '@embedpdf/plugin-history';\n\nexport const useHistoryPlugin = () => usePlugin<HistoryPlugin>(HistoryPlugin.id);\nexport const useHistoryCapability = () => useCapability<HistoryPlugin>(HistoryPlugin.id);\n"],"names":["useCapability","HistoryPlugin","id","usePlugin"],"mappings":"2LAIoC,IAAMA,gBAA6BC,EAAAA,cAAcC,6BADrD,IAAMC,YAAyBF,EAAAA,cAAcC"}
@@ -1,15 +1 @@
1
- import * as _embedpdf_plugin_history from '@embedpdf/plugin-history';
2
- import { HistoryPlugin } from '@embedpdf/plugin-history';
3
-
4
- declare const useHistoryPlugin: () => {
5
- plugin: HistoryPlugin | null;
6
- isLoading: boolean;
7
- ready: Promise<void>;
8
- };
9
- declare const useHistoryCapability: () => {
10
- provides: Readonly<_embedpdf_plugin_history.HistoryCapability> | null;
11
- isLoading: boolean;
12
- ready: Promise<void>;
13
- };
14
-
15
- export { useHistoryCapability, useHistoryPlugin };
1
+ export * from '../shared-react';
@@ -1,10 +1,9 @@
1
- // src/react/hooks/use-history.ts
2
- import { useCapability, usePlugin } from "@embedpdf/core/react";
1
+ import { usePlugin, useCapability } from "@embedpdf/core/react";
3
2
  import { HistoryPlugin } from "@embedpdf/plugin-history";
4
- var useHistoryPlugin = () => usePlugin(HistoryPlugin.id);
5
- var useHistoryCapability = () => useCapability(HistoryPlugin.id);
3
+ const useHistoryPlugin = () => usePlugin(HistoryPlugin.id);
4
+ const useHistoryCapability = () => useCapability(HistoryPlugin.id);
6
5
  export {
7
6
  useHistoryCapability,
8
7
  useHistoryPlugin
9
8
  };
10
- //# sourceMappingURL=index.js.map
9
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/react/hooks/use-history.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/react';\nimport { HistoryPlugin } from '@embedpdf/plugin-history';\n\nexport const useHistoryPlugin = () => usePlugin<HistoryPlugin>(HistoryPlugin.id);\nexport const useHistoryCapability = () => useCapability<HistoryPlugin>(HistoryPlugin.id);\n"],"mappings":";AAAA,SAAS,eAAe,iBAAiB;AACzC,SAAS,qBAAqB;AAEvB,IAAM,mBAAmB,MAAM,UAAyB,cAAc,EAAE;AACxE,IAAM,uBAAuB,MAAM,cAA6B,cAAc,EAAE;","names":[]}
1
+ {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-history.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { HistoryPlugin } from '@embedpdf/plugin-history';\n\nexport const useHistoryPlugin = () => usePlugin<HistoryPlugin>(HistoryPlugin.id);\nexport const useHistoryCapability = () => useCapability<HistoryPlugin>(HistoryPlugin.id);\n"],"names":[],"mappings":";;AAGO,MAAM,mBAAmB,MAAM,UAAyB,cAAc,EAAE;AACxE,MAAM,uBAAuB,MAAM,cAA6B,cAAc,EAAE;"}
@@ -0,0 +1 @@
1
+ export * from './use-history';
@@ -0,0 +1,11 @@
1
+ import { HistoryPlugin } from '../../lib/index.ts';
2
+ export declare const useHistoryPlugin: () => {
3
+ plugin: HistoryPlugin | null;
4
+ isLoading: boolean;
5
+ ready: Promise<void>;
6
+ };
7
+ export declare const useHistoryCapability: () => {
8
+ provides: Readonly<import('../../lib/index.ts').HistoryCapability> | null;
9
+ isLoading: boolean;
10
+ ready: Promise<void>;
11
+ };
@@ -0,0 +1 @@
1
+ export * from './hooks';
@@ -0,0 +1 @@
1
+ export * from './use-history';
@@ -0,0 +1,11 @@
1
+ import { HistoryPlugin } from '../../lib/index.ts';
2
+ export declare const useHistoryPlugin: () => {
3
+ plugin: HistoryPlugin | null;
4
+ isLoading: boolean;
5
+ ready: Promise<void>;
6
+ };
7
+ export declare const useHistoryCapability: () => {
8
+ provides: Readonly<import('../../lib/index.ts').HistoryCapability> | null;
9
+ isLoading: boolean;
10
+ ready: Promise<void>;
11
+ };
@@ -0,0 +1 @@
1
+ export * from './hooks';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embedpdf/plugin-history",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -23,19 +23,19 @@
23
23
  }
24
24
  },
25
25
  "dependencies": {
26
- "@embedpdf/models": "1.0.11"
26
+ "@embedpdf/models": "1.0.13"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/react": "^18.2.0",
30
- "tsup": "^8.0.0",
31
30
  "typescript": "^5.0.0",
32
- "@embedpdf/core": "1.0.11"
31
+ "@embedpdf/core": "1.0.13",
32
+ "@embedpdf/build": "1.0.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": ">=16.8.0",
36
36
  "react-dom": ">=16.8.0",
37
37
  "preact": "^10.26.4",
38
- "@embedpdf/core": "1.0.11"
38
+ "@embedpdf/core": "1.0.13"
39
39
  },
40
40
  "files": [
41
41
  "dist",
@@ -54,11 +54,12 @@
54
54
  "access": "public"
55
55
  },
56
56
  "scripts": {
57
- "build": "PROJECT_CWD=$(pwd) pnpm -w p:build",
58
- "build:watch": "PROJECT_CWD=$(pwd) pnpm -w p:build:watch",
59
- "clean": "PROJECT_CWD=$(pwd) pnpm -w p:clean",
60
- "lint": "PROJECT_CWD=$(pwd) pnpm -w p:lint",
61
- "lint:fix": "PROJECT_CWD=$(pwd) pnpm -w p:lint:fix",
62
- "typecheck": "PROJECT_CWD=$(pwd) pnpm -w p:typecheck"
57
+ "build:base": "vite build --mode base",
58
+ "build:react": "vite build --mode react",
59
+ "build:preact": "vite build --mode preact",
60
+ "build": "pnpm run clean && concurrently -c auto -n base,react,preact \"vite build --mode base\" \"vite build --mode react\" \"vite build --mode preact\"",
61
+ "clean": "rimraf dist",
62
+ "lint": "eslint src --color",
63
+ "lint:fix": "eslint src --color --fix"
63
64
  }
64
65
  }
@@ -1,15 +0,0 @@
1
- import * as _embedpdf_plugin_history from '@embedpdf/plugin-history';
2
- import { HistoryPlugin } from '@embedpdf/plugin-history';
3
-
4
- declare const useHistoryPlugin: () => {
5
- plugin: HistoryPlugin | null;
6
- isLoading: boolean;
7
- ready: Promise<void>;
8
- };
9
- declare const useHistoryCapability: () => {
10
- provides: Readonly<_embedpdf_plugin_history.HistoryCapability> | null;
11
- isLoading: boolean;
12
- ready: Promise<void>;
13
- };
14
-
15
- export { useHistoryCapability, useHistoryPlugin };
@@ -1,15 +0,0 @@
1
- import * as _embedpdf_plugin_history from '@embedpdf/plugin-history';
2
- import { HistoryPlugin } from '@embedpdf/plugin-history';
3
-
4
- declare const useHistoryPlugin: () => {
5
- plugin: HistoryPlugin | null;
6
- isLoading: boolean;
7
- ready: Promise<void>;
8
- };
9
- declare const useHistoryCapability: () => {
10
- provides: Readonly<_embedpdf_plugin_history.HistoryCapability> | null;
11
- isLoading: boolean;
12
- ready: Promise<void>;
13
- };
14
-
15
- export { useHistoryCapability, useHistoryPlugin };