@embedpdf/plugin-history 2.15.0 → 3.0.0-next.15
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/README.md +65 -0
- package/dist/contract-B7QL_Q3D.js +11 -0
- package/dist/contract-B7QL_Q3D.js.map +1 -0
- package/dist/contract-DHipVkAd.cjs +21 -0
- package/dist/contract-DHipVkAd.cjs.map +1 -0
- package/dist/contract-J_XQyhyq.d.cts +66 -0
- package/dist/contract-J_XQyhyq.d.ts +66 -0
- package/dist/contract.cjs +4 -0
- package/dist/contract.d.cts +2 -0
- package/dist/contract.d.ts +2 -0
- package/dist/contract.js +2 -0
- package/dist/index.cjs +356 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -0
- package/dist/index.d.ts +56 -1
- package/dist/index.js +348 -377
- package/dist/index.js.map +1 -1
- package/package.json +25 -57
- package/dist/lib/actions.d.ts +0 -34
- package/dist/lib/history-plugin.d.ts +0 -33
- 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 -151
- package/dist/preact/adapter.d.ts +0 -1
- package/dist/preact/core.d.ts +0 -1
- package/dist/preact/index.cjs +0 -2
- package/dist/preact/index.cjs.map +0 -1
- package/dist/preact/index.d.ts +0 -1
- package/dist/preact/index.js +0 -10
- package/dist/preact/index.js.map +0 -1
- package/dist/react/adapter.d.ts +0 -1
- 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 -10
- package/dist/react/index.js.map +0 -1
- package/dist/shared/hooks/index.d.ts +0 -1
- package/dist/shared/hooks/use-history.d.ts +0 -11
- package/dist/shared/index.d.ts +0 -2
- package/dist/shared-preact/hooks/index.d.ts +0 -1
- package/dist/shared-preact/hooks/use-history.d.ts +0 -11
- package/dist/shared-preact/index.d.ts +0 -2
- package/dist/shared-react/hooks/index.d.ts +0 -1
- package/dist/shared-react/hooks/use-history.d.ts +0 -11
- package/dist/shared-react/index.d.ts +0 -2
- package/dist/svelte/hooks/index.d.ts +0 -1
- package/dist/svelte/hooks/use-history.d.ts +0 -11
- package/dist/svelte/index.cjs +0 -2
- package/dist/svelte/index.cjs.map +0 -1
- package/dist/svelte/index.d.ts +0 -2
- package/dist/svelte/index.js +0 -10
- package/dist/svelte/index.js.map +0 -1
- package/dist/vue/hooks/index.d.ts +0 -1
- package/dist/vue/hooks/use-history.d.ts +0 -3
- package/dist/vue/index.cjs +0 -2
- package/dist/vue/index.cjs.map +0 -1
- package/dist/vue/index.d.ts +0 -2
- package/dist/vue/index.js +0 -10
- package/dist/vue/index.js.map +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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};\n","import { Action } from '@embedpdf/core';\nimport { HistoryDocumentState } from './types';\n\n// Document lifecycle actions\nexport const INIT_HISTORY_STATE = 'HISTORY/INIT_STATE';\nexport const CLEANUP_HISTORY_STATE = 'HISTORY/CLEANUP_STATE';\n\n// History state updates\nexport const SET_HISTORY_DOCUMENT_STATE = 'HISTORY/SET_DOCUMENT_STATE';\nexport const SET_ACTIVE_HISTORY_DOCUMENT = 'HISTORY/SET_ACTIVE_DOCUMENT';\n\n// Document lifecycle action interfaces\nexport interface InitHistoryStateAction extends Action {\n type: typeof INIT_HISTORY_STATE;\n payload: {\n documentId: string;\n };\n}\n\nexport interface CleanupHistoryStateAction extends Action {\n type: typeof CLEANUP_HISTORY_STATE;\n payload: {\n documentId: string;\n };\n}\n\n// State update action interfaces\nexport interface SetHistoryDocumentStateAction extends Action {\n type: typeof SET_HISTORY_DOCUMENT_STATE;\n payload: {\n documentId: string;\n state: HistoryDocumentState;\n };\n}\n\nexport interface SetActiveHistoryDocumentAction extends Action {\n type: typeof SET_ACTIVE_HISTORY_DOCUMENT;\n payload: string | null; // documentId\n}\n\nexport type HistoryAction =\n | InitHistoryStateAction\n | CleanupHistoryStateAction\n | SetHistoryDocumentStateAction\n | SetActiveHistoryDocumentAction;\n\n// Action creators\nexport const initHistoryState = (documentId: string): InitHistoryStateAction => ({\n type: INIT_HISTORY_STATE,\n payload: { documentId },\n});\n\nexport const cleanupHistoryState = (documentId: string): CleanupHistoryStateAction => ({\n type: CLEANUP_HISTORY_STATE,\n payload: { documentId },\n});\n\nexport const setHistoryDocumentState = (\n documentId: string,\n state: HistoryDocumentState,\n): SetHistoryDocumentStateAction => ({\n type: SET_HISTORY_DOCUMENT_STATE,\n payload: { documentId, state },\n});\n\nexport const setActiveHistoryDocument = (\n documentId: string | null,\n): SetActiveHistoryDocumentAction => ({\n type: SET_ACTIVE_HISTORY_DOCUMENT,\n payload: documentId,\n});\n","import { BasePlugin, createEmitter, Listener, PluginRegistry } from '@embedpdf/core';\nimport {\n Command,\n HistoryCapability,\n HistoryChangeEvent,\n HistoryDocumentState,\n HistoryEntry,\n HistoryPluginConfig,\n HistoryScope,\n HistoryState,\n} from './types';\nimport {\n HistoryAction,\n initHistoryState,\n cleanupHistoryState,\n setHistoryDocumentState,\n} from './actions';\n\ninterface DocumentHistoryData {\n topicHistories: Map<string, { commands: Command[]; currentIndex: number }>;\n globalTimeline: HistoryEntry[];\n globalIndex: number;\n}\n\nexport class HistoryPlugin extends BasePlugin<\n HistoryPluginConfig,\n HistoryCapability,\n HistoryState,\n HistoryAction\n> {\n static readonly id = 'history' as const;\n\n // Per-document history data (persisted with state)\n private readonly documentHistories = new Map<string, DocumentHistoryData>();\n\n // Event emitter for history changes\n private readonly historyChange$ = createEmitter<HistoryChangeEvent>();\n\n constructor(id: string, registry: PluginRegistry) {\n super(id, registry);\n }\n\n async initialize(_: HistoryPluginConfig): Promise<void> {\n this.logger.info('HistoryPlugin', 'Initialize', 'History plugin initialized');\n }\n\n // ─────────────────────────────────────────────────────────\n // Document Lifecycle (from BasePlugin)\n // ─────────────────────────────────────────────────────────\n\n protected override onDocumentLoadingStarted(documentId: string): void {\n // Initialize history state for this document\n this.dispatch(initHistoryState(documentId));\n\n // Create document history data\n this.documentHistories.set(documentId, {\n topicHistories: new Map(),\n globalTimeline: [],\n globalIndex: -1,\n });\n\n this.logger.debug(\n 'HistoryPlugin',\n 'DocumentOpened',\n `Initialized history state for document: ${documentId}`,\n );\n }\n\n protected override onDocumentClosed(documentId: string): void {\n // Cleanup history state\n this.dispatch(cleanupHistoryState(documentId));\n\n // Cleanup document history data\n this.documentHistories.delete(documentId);\n\n this.logger.debug(\n 'HistoryPlugin',\n 'DocumentClosed',\n `Cleaned up history state for document: ${documentId}`,\n );\n }\n\n // ─────────────────────────────────────────────────────────\n // Helper Methods\n // ─────────────────────────────────────────────────────────\n\n private getDocumentHistoryData(documentId?: string): DocumentHistoryData {\n const id = documentId ?? this.getActiveDocumentId();\n const data = this.documentHistories.get(id);\n if (!data) {\n throw new Error(`History data not found for document: ${id}`);\n }\n return data;\n }\n\n private getDocumentHistoryState(documentId: string): HistoryDocumentState {\n const data = this.documentHistories.get(documentId);\n if (!data) {\n throw new Error(`History data not found for document: ${documentId}`);\n }\n\n const topics: HistoryDocumentState['topics'] = {};\n Array.from(data.topicHistories.entries()).forEach(([topic, history]) => {\n topics[topic] = {\n canUndo: history.currentIndex > -1,\n canRedo: history.currentIndex < history.commands.length - 1,\n };\n });\n\n return {\n global: {\n canUndo: data.globalIndex > -1,\n canRedo: data.globalIndex < data.globalTimeline.length - 1,\n },\n topics,\n };\n }\n\n private emitHistoryChange(documentId: string, topic: string | undefined) {\n // Update the state\n const state = this.getDocumentHistoryState(documentId);\n this.dispatch(setHistoryDocumentState(documentId, state));\n\n // Emit the event\n this.historyChange$.emit({\n documentId,\n topic,\n state,\n });\n }\n\n // ─────────────────────────────────────────────────────────\n // History Operations (per document)\n // ─────────────────────────────────────────────────────────\n\n private register(command: Command, topic: string, documentId: string): void {\n const data = this.getDocumentHistoryData(documentId);\n\n // 1. Manage Topic History\n if (!data.topicHistories.has(topic)) {\n data.topicHistories.set(topic, { commands: [], currentIndex: -1 });\n }\n const topicHistory = data.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 data.globalTimeline.splice(data.globalIndex + 1);\n data.globalTimeline.push(historyEntry);\n data.globalIndex++;\n\n // 3. Execute and notify with the specific topic\n command.execute();\n this.emitHistoryChange(documentId, topic);\n }\n\n private undo(topic: string | undefined, documentId: string): void {\n const data = this.getDocumentHistoryData(documentId);\n let affectedTopic: string | undefined;\n\n if (topic) {\n // Scoped Undo\n const topicHistory = data.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 (data.globalIndex > -1) {\n const entry = data.globalTimeline[data.globalIndex];\n entry.command.undo();\n data.topicHistories.get(entry.topic)!.currentIndex--;\n data.globalIndex--;\n affectedTopic = entry.topic;\n }\n }\n\n if (affectedTopic) {\n this.emitHistoryChange(documentId, affectedTopic);\n }\n }\n\n private redo(topic: string | undefined, documentId: string): void {\n const data = this.getDocumentHistoryData(documentId);\n let affectedTopic: string | undefined;\n\n if (topic) {\n // Scoped Redo\n const topicHistory = data.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 (data.globalIndex < data.globalTimeline.length - 1) {\n data.globalIndex++;\n const entry = data.globalTimeline[data.globalIndex];\n entry.command.execute();\n data.topicHistories.get(entry.topic)!.currentIndex++;\n affectedTopic = entry.topic;\n }\n }\n\n if (affectedTopic) {\n this.emitHistoryChange(documentId, affectedTopic);\n }\n }\n\n private canUndo(topic: string | undefined, documentId: string): boolean {\n const data = this.getDocumentHistoryData(documentId);\n\n if (topic) {\n const history = data.topicHistories.get(topic);\n return !!history && history.currentIndex > -1;\n }\n return data.globalIndex > -1;\n }\n\n private canRedo(topic: string | undefined, documentId: string): boolean {\n const data = this.getDocumentHistoryData(documentId);\n\n if (topic) {\n const history = data.topicHistories.get(topic);\n return !!history && history.currentIndex < history.commands.length - 1;\n }\n return data.globalIndex < data.globalTimeline.length - 1;\n }\n\n /**\n * Purges history entries that match the given predicate based on command metadata.\n * Used to remove commands that are no longer valid (e.g., after a permanent redaction commit).\n *\n * @param predicate A function that returns true for commands that should be purged\n * @param topic If provided, only purges entries for that specific topic\n * @param documentId The document to purge history for\n * @returns The number of entries that were purged\n */\n private purgeByMetadata<T>(\n predicate: (metadata: T | undefined) => boolean,\n topic: string | undefined,\n documentId: string,\n ): number {\n const data = this.getDocumentHistoryData(documentId);\n let purgedCount = 0;\n\n // Helper to check if a command should be purged\n const shouldPurge = (command: Command): boolean => {\n return predicate(command.metadata as T | undefined);\n };\n\n // 1. Purge from topic histories\n const topicsToProcess = topic ? [topic] : Array.from(data.topicHistories.keys());\n\n for (const topicName of topicsToProcess) {\n const topicHistory = data.topicHistories.get(topicName);\n if (!topicHistory) continue;\n\n const newCommands: Command[] = [];\n let indexAdjustment = 0;\n\n for (let i = 0; i < topicHistory.commands.length; i++) {\n const command = topicHistory.commands[i];\n if (shouldPurge(command)) {\n // If this entry is at or before currentIndex, we need to adjust\n if (i <= topicHistory.currentIndex) {\n indexAdjustment++;\n }\n purgedCount++;\n } else {\n newCommands.push(command);\n }\n }\n\n topicHistory.commands = newCommands;\n topicHistory.currentIndex = Math.max(-1, topicHistory.currentIndex - indexAdjustment);\n }\n\n // 2. Purge from global timeline\n const newTimeline: HistoryEntry[] = [];\n let globalIndexAdjustment = 0;\n\n for (let i = 0; i < data.globalTimeline.length; i++) {\n const entry = data.globalTimeline[i];\n const matchesTopic = !topic || entry.topic === topic;\n\n if (matchesTopic && shouldPurge(entry.command)) {\n // If this entry is at or before globalIndex, we need to adjust\n if (i <= data.globalIndex) {\n globalIndexAdjustment++;\n }\n } else {\n newTimeline.push(entry);\n }\n }\n\n data.globalTimeline = newTimeline;\n data.globalIndex = Math.max(-1, data.globalIndex - globalIndexAdjustment);\n\n // 3. Emit history change if anything was purged\n if (purgedCount > 0) {\n this.emitHistoryChange(documentId, topic);\n this.logger.debug(\n 'HistoryPlugin',\n 'PurgeByMetadata',\n `Purged ${purgedCount} history entries for document: ${documentId}${topic ? `, topic: ${topic}` : ''}`,\n );\n }\n\n return purgedCount;\n }\n\n // ─────────────────────────────────────────────────────────\n // Document Scoping\n // ─────────────────────────────────────────────────────────\n\n private createHistoryScope(documentId: string): HistoryScope {\n return {\n register: (command: Command, topic: string) => this.register(command, topic, documentId),\n undo: (topic?: string) => this.undo(topic, documentId),\n redo: (topic?: string) => this.redo(topic, documentId),\n canUndo: (topic?: string) => this.canUndo(topic, documentId),\n canRedo: (topic?: string) => this.canRedo(topic, documentId),\n getHistoryState: () => this.getDocumentHistoryState(documentId),\n onHistoryChange: (listener: Listener<string | undefined>) =>\n this.historyChange$.on((event) => {\n if (event.documentId === documentId) {\n listener(event.topic);\n }\n }),\n purgeByMetadata: <T>(predicate: (metadata: T | undefined) => boolean, topic?: string) =>\n this.purgeByMetadata(predicate, topic, documentId),\n };\n }\n\n // ─────────────────────────────────────────────────────────\n // Capability\n // ─────────────────────────────────────────────────────────\n\n protected buildCapability(): HistoryCapability {\n return {\n // Active document operations\n register: (command: Command, topic: string) => {\n const documentId = this.getActiveDocumentId();\n this.register(command, topic, documentId);\n },\n\n undo: (topic?: string) => {\n const documentId = this.getActiveDocumentId();\n this.undo(topic, documentId);\n },\n\n redo: (topic?: string) => {\n const documentId = this.getActiveDocumentId();\n this.redo(topic, documentId);\n },\n\n canUndo: (topic?: string) => {\n const documentId = this.getActiveDocumentId();\n return this.canUndo(topic, documentId);\n },\n\n canRedo: (topic?: string) => {\n const documentId = this.getActiveDocumentId();\n return this.canRedo(topic, documentId);\n },\n\n getHistoryState: () => {\n const documentId = this.getActiveDocumentId();\n return this.getDocumentHistoryState(documentId);\n },\n\n // Document-scoped operations\n forDocument: (documentId: string) => this.createHistoryScope(documentId),\n\n // Events\n onHistoryChange: this.historyChange$.on,\n\n // Purge operations\n purgeByMetadata: <T>(predicate: (metadata: T | undefined) => boolean, topic?: string) => {\n const documentId = this.getActiveDocumentId();\n return this.purgeByMetadata(predicate, topic, documentId);\n },\n };\n }\n\n // ─────────────────────────────────────────────────────────\n // Lifecycle\n // ─────────────────────────────────────────────────────────\n\n async destroy(): Promise<void> {\n // Clear all emitters\n this.historyChange$.clear();\n\n // Clear document histories\n this.documentHistories.clear();\n\n super.destroy();\n }\n}\n","import { Reducer } from '@embedpdf/core';\nimport {\n HistoryAction,\n INIT_HISTORY_STATE,\n CLEANUP_HISTORY_STATE,\n SET_HISTORY_DOCUMENT_STATE,\n SET_ACTIVE_HISTORY_DOCUMENT,\n} from './actions';\nimport { HistoryState, HistoryDocumentState } from './types';\n\nconst initialDocumentState: HistoryDocumentState = {\n global: {\n canUndo: false,\n canRedo: false,\n },\n topics: {},\n};\n\nexport const initialState: HistoryState = {\n documents: {},\n activeDocumentId: null,\n};\n\nexport const reducer: Reducer<HistoryState, HistoryAction> = (state = initialState, action) => {\n switch (action.type) {\n case INIT_HISTORY_STATE: {\n const { documentId } = action.payload;\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: { ...initialDocumentState },\n },\n };\n }\n\n case CLEANUP_HISTORY_STATE: {\n const { documentId } = action.payload;\n const { [documentId]: removed, ...remainingDocs } = state.documents;\n\n return {\n ...state,\n documents: remainingDocs,\n activeDocumentId: state.activeDocumentId === documentId ? null : state.activeDocumentId,\n };\n }\n\n case SET_HISTORY_DOCUMENT_STATE: {\n const { documentId, state: docState } = action.payload;\n if (!state.documents[documentId]) {\n return state;\n }\n\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: docState,\n },\n };\n }\n\n case SET_ACTIVE_HISTORY_DOCUMENT: {\n return {\n ...state,\n activeDocumentId: action.payload,\n };\n }\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) => 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,CAAA;AAAA,EACV,UAAU,CAAA;AAAA,EACV,eAAe,CAAA;AACjB;ACTO,MAAM,qBAAqB;AAC3B,MAAM,wBAAwB;AAG9B,MAAM,6BAA6B;AACnC,MAAM,8BAA8B;AAsCpC,MAAM,mBAAmB,CAAC,gBAAgD;AAAA,EAC/E,MAAM;AAAA,EACN,SAAS,EAAE,WAAA;AACb;AAEO,MAAM,sBAAsB,CAAC,gBAAmD;AAAA,EACrF,MAAM;AAAA,EACN,SAAS,E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AkB;AACpB;AAEO,MAAM,UAAgD,CAAC,QAAQ,cAAc,WAAW;AAC7F,UAAQ,OAAO,MAAA;AAAA,IACb,KAAK,oBAAoB;AACvB,YAAM,EAAE,eAAe,OAAO;AAC9B,aAAO;AAAA,QACL,GAAG;AAAA,QACH,WAAW;AAAA,UACT,GAAG,MAAM;AAAA,UACT,CAAC,UAAU,GAAG,EAAE,GAAG,qBAAA;AAAA,QAAqB;AAAA,MAC1C;AAAA,IAEJ;AAAA,IAEA,KAAK,uBAAuB;AAC1B,YAAM,EAAE,eAAe,OAAO;AAC9B,YAAM,EAAE,CAAC,UAAU,GAAG,SAAS,GAAG,cAAA,IAAkB,MAAM;AAE1D,aAAO;AAAA,QACL,GAAG;AAAA,QACH,WAAW;AAAA,QACX,kBAAkB,MAAM,qBAAqB,aAAa,OAAO,MAAM;AAAA,MAAA;AAAA,IAE3E;AAAA,IAEA,KAAK,4BAA4B;AAC/B,YAAM,EAAE,YAAY,OAAO,SAAA,IAAa,OAAO;AAC/C,UAAI,CAAC,MAAM,UAAU,UAAU,GAAG;AAChC,eAAO;AAAA,MACT;AAEA,aAAO;AAAA,QACL,GAAG;AAAA,QACH,WAAW;AAAA,UACT,GAAG,MAAM;AAAA,UACT,CAAC,UAAU,GAAG;AAAA,QAAA;AAAA,MAChB;AAAA,IAEJ;AAAA,IAEA,KAAK,6BAA6B;AAChC,aAAO;AAAA,QACL,GAAG;AAAA,QACH,kBAAkB,OAAO;AAAA,MAAA;AAAA,IAE7B;AAAA,IAEA;AACE,aAAO;AAAA,EAAA;AAEb;ACjEO,MAAM,uBAKT;AAAA,EACF;AAAA,EACA,QAAQ,CAAC,aAAa,IAAI,cAAc,mBAAmB,QAAQ;AAAA,EACnE;AAAA,EACA;AACF;"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/model.ts","../src/controller.ts","../src/history.plugin.ts","../src/state.ts"],"sourcesContent":["/**\n * The history as a value, and the pure steps that change it.\n *\n * An entry is one step of the history: one change this session staged, or the\n * changes of one typing session (its pauses). Each change is a part. A part is\n * named by the change the next step undoes: the change itself at first, then\n * the undo that undid it, then the redo that undid that undo, and so on. An\n * undo and a redo are the same thing to the engine: the undo of a change.\n *\n * Entries are numbered in the order they were recorded (`seq`). The undo\n * stack holds them oldest first and the redo stack newest first, so the next\n * step is always the last of its stack, and an entry put back after a refused\n * step finds its place by its number.\n */\nimport type { ChangeLabel, PredictedOp } from '@embedpdf/core';\n\nexport interface HistoryPart {\n /** The order it was recorded in. */\n readonly seq: number;\n /** The change it began as, which is what a refusal of that change names. Never changes. */\n readonly id: string;\n /** The change the next step undoes: the change itself, or its latest undo or redo. */\n readonly opId: string;\n /** What the change shows: what a redo of it shows until the engine answers. */\n readonly forward: readonly PredictedOp[];\n /** What undoing it shows until the engine answers. */\n readonly backward: readonly PredictedOp[];\n}\n\nexport interface HistoryEntry {\n /** The order it was recorded in. */\n readonly seq: number;\n readonly label: ChangeLabel;\n /** Consecutive changes with this key join it (typing); `null` for every other change. */\n readonly merge: string | null;\n /** Its changes, oldest first. */\n readonly parts: readonly HistoryPart[];\n}\n\nexport interface History {\n /** What undo undoes, oldest first: the last is next. */\n readonly undo: readonly HistoryEntry[];\n /** What redo redoes, newest first: the last is next. */\n readonly redo: readonly HistoryEntry[];\n /**\n * The merge key the newest entry still takes changes under: set when a change with a key is\n * recorded, `null` again once anything else happens.\n */\n readonly merging: string | null;\n readonly nextSeq: number;\n}\n\nexport type Direction = 'undo' | 'redo';\n\n/** A change this session staged, as the history records it. */\nexport interface RecordedChange {\n readonly opId: string;\n readonly label: ChangeLabel;\n readonly merge: string | null;\n readonly shows: readonly PredictedOp[];\n readonly undo: readonly PredictedOp[];\n}\n\nexport const emptyHistory = (): History => ({ undo: [], redo: [], merging: null, nextSeq: 0 });\n\n/** The stack a step takes its entry from, and the one it puts it on. */\nconst stacksOf = (direction: Direction) =>\n direction === 'undo'\n ? ({ from: 'undo', to: 'redo' } as const)\n : ({ from: 'redo', to: 'undo' } as const);\n\n/** The entry the next step of `direction` takes, or `null`. */\nexport const nextOf = (history: History, direction: Direction): HistoryEntry | null =>\n history[direction].at(-1) ?? null;\n\n/**\n * A new change: it joins the newest entry when typing goes on under the same key, else it is a\n * new entry on top, and the oldest go past `limit`. Anything that could be redone is forgotten.\n */\nexport function recorded(history: History, change: RecordedChange, limit: number): History {\n const part: HistoryPart = {\n seq: history.nextSeq,\n id: change.opId,\n opId: change.opId,\n forward: change.shows,\n backward: change.undo,\n };\n const top = history.undo.at(-1);\n if (top && change.merge !== null && history.merging === change.merge) {\n return {\n undo: [...history.undo.slice(0, -1), { ...top, parts: [...top.parts, part] }],\n redo: [],\n merging: change.merge,\n nextSeq: history.nextSeq + 1,\n };\n }\n const entry: HistoryEntry = {\n seq: part.seq,\n label: change.label,\n merge: change.merge,\n parts: [part],\n };\n return {\n undo: [...history.undo, entry].slice(-Math.max(1, limit)),\n redo: [],\n merging: change.merge,\n nextSeq: history.nextSeq + 1,\n };\n}\n\n/**\n * A step was staged: the entry `seq` leaves the top of its stack for the top of the other, each\n * part now named by the change that staged it (`opIds`, by part id).\n */\nexport function stepped(\n history: History,\n direction: Direction,\n seq: number,\n opIds: ReadonlyMap<string, string>,\n): History {\n const { from, to } = stacksOf(direction);\n const entry = history[from].find((candidate) => candidate.seq === seq);\n if (!entry) return history;\n const moved: HistoryEntry = {\n ...entry,\n parts: entry.parts.map((part) => ({ ...part, opId: opIds.get(part.id) ?? part.opId })),\n };\n return {\n ...history,\n [from]: history[from].filter((candidate) => candidate !== entry),\n [to]: [...history[to], moved],\n merging: null,\n } as History;\n}\n\n/** Every entry without the parts `drop` picks, and without the entries left with none. */\nconst withoutParts = (\n entries: readonly HistoryEntry[],\n drop: (part: HistoryPart) => boolean,\n): readonly HistoryEntry[] => {\n let changed = false;\n const kept: HistoryEntry[] = [];\n for (const entry of entries) {\n const parts = entry.parts.filter((part) => !drop(part));\n if (parts.length === entry.parts.length) {\n kept.push(entry);\n continue;\n }\n changed = true;\n if (parts.length) kept.push({ ...entry, parts });\n }\n return changed ? kept : entries;\n};\n\n/**\n * The change `id` never happened (the engine refused it), or did nothing that can be undone:\n * its part goes, from whichever stack holds it.\n */\nexport function forgotten(history: History, id: string): History {\n const undo = withoutParts(history.undo, (part) => part.id === id);\n const redo = withoutParts(history.redo, (part) => part.id === id);\n return undo === history.undo && redo === history.redo ? history : { ...history, undo, redo };\n}\n\n/**\n * The engine refused one change of a step, so that part didn't move: it goes back where it\n * was, as `part` was before the step, into its entry there (or a new one with the entry's\n * number, in its place), wherever a later step had put it since. Its other parts stay where\n * the step put them.\n */\nexport function stepRefused(\n history: History,\n direction: Direction,\n entry: Pick<HistoryEntry, 'seq' | 'label' | 'merge'>,\n part: HistoryPart,\n): History {\n const { from } = stacksOf(direction);\n const { undo, redo } = forgotten(history, part.id);\n const left = { undo, redo };\n const back = [...left[from]];\n const at = back.findIndex((candidate) => candidate.seq === entry.seq);\n if (at >= 0) {\n const parts = [...back[at]!.parts, part].sort((left, right) => left.seq - right.seq);\n back[at] = { ...back[at]!, parts };\n } else {\n // The undo stack is oldest first, the redo stack newest first.\n const before = (candidate: HistoryEntry) =>\n from === 'undo' ? candidate.seq < entry.seq : candidate.seq > entry.seq;\n const index = back.filter(before).length;\n back.splice(index, 0, { ...entry, parts: [part] });\n }\n return { ...history, ...left, [from]: back, merging: null };\n}\n\n/**\n * The engine can no longer undo the entry `seq` (a final change or a new version came after\n * it, or it is too old): it goes, and so does everything recorded before it.\n */\nexport function unavailable(history: History, seq: number): History {\n const newer = (entry: HistoryEntry) => entry.seq > seq;\n return {\n ...history,\n undo: history.undo.filter(newer),\n redo: history.redo.filter(newer),\n merging: null,\n };\n}\n\n/** Nothing can be undone or redone. */\nexport const cleared = (history: History): History =>\n history.undo.length === 0 && history.redo.length === 0 && history.merging === null\n ? history\n : { ...history, undo: [], redo: [], merging: null };\n","/**\n * The history controller. It records every change this session stages on the\n * document's change queue, as it is staged, so an undo right after an action\n * undoes that action even before the engine answered it. Undo and redo are\n * changes on the same queue: the undo of a change, by its `opId`. The views\n * show them at once, from what the change said undoing it looks like, and\n * the engine applies the reverse it recorded.\n *\n * The history keeps no copy of the document. What it holds is names, labels\n * and what each step looks like, and it changes on four things: a change\n * staged, a step staged, an answer, and a change that ends undo (a final\n * change, a new version).\n */\nimport type { PendingChange, PluginContext, PluginError } from '@embedpdf/core';\nimport { EngineError, EngineErrorCode, type ChangeResult } from '@embedpdf/engine-core/runtime';\n\nimport type {\n HistoryCapability,\n HistorySettings,\n HistoryUndoFailedEvent,\n HistoryUndoneEvent,\n} from './contract';\nimport {\n cleared,\n forgotten,\n nextOf,\n recorded,\n stepped,\n stepRefused,\n unavailable,\n type Direction,\n type History,\n type HistoryEntry,\n type HistoryPart,\n} from './model';\n\n/** The document events after which nothing before them can be undone. */\nconst ENDS_UNDO = new Set([\n 'redaction.applied',\n 'pages.flattened',\n 'signatures.completed',\n 'forms.repaired',\n 'document.versioned',\n]);\n\n/** Whether the engine refused an undo because it can't be undone any more. */\nconst isUnavailable = (error: PluginError): boolean =>\n EngineError.is((error as { cause?: unknown }).cause, EngineErrorCode.UndoUnavailable);\n\n/** How many of an undo's parts were left alone, in whole or in part. */\nconst skippedIn = (result: ChangeResult): number =>\n result.items.filter(\n (item) => item.type === 'skipped' || ('skipped' in item && (item.skipped?.length ?? 0) > 0),\n ).length;\n\nexport function createHistoryController(ctx: PluginContext<History, HistorySettings>) {\n const settings = ctx.settings();\n const undone = ctx.events.source<HistoryUndoneEvent>();\n const undoFailed = ctx.events.source<HistoryUndoFailedEvent>();\n\n /**\n * The changes the engine will never apply, while a step is on its way: a refused change, and\n * a step that undid one. A step that names one is refused too, and changes nothing more.\n */\n const dead = new Set<string>();\n /** The parts forgotten while a step is on its way: a refusal of their step puts nothing back. */\n const gone = new Set<string>();\n let inFlight = 0;\n\n const forget = (ids: Iterable<string>): void => {\n if (inFlight === 0) return;\n for (const id of ids) gone.add(id);\n };\n const partsOf = (entries: readonly HistoryEntry[]) =>\n entries.flatMap((entry) => entry.parts.map((part) => part.id));\n\n const clear = (): void => {\n const history = ctx.state.get();\n forget(partsOf([...history.undo, ...history.redo]));\n ctx.state.update(cleared);\n };\n\n /**\n * One step's change for one part, and what its answer does. `moot`: it named a change the\n * engine never applied, or a part the history forgot, so its refusal says nothing new.\n */\n const answerOf = (\n direction: Direction,\n entry: HistoryEntry,\n part: HistoryPart,\n change: PendingChange,\n ): Promise<{ skipped: number } | { error: PluginError } | { moot: true }> =>\n change.result.then(\n (result) => {\n if (!result.meta.undoable) {\n // It did nothing (every part was left alone): there is nothing to step back over.\n forget([part.id]);\n ctx.state.update(forgotten, part.id);\n }\n return { skipped: skippedIn(result) };\n },\n (error: PluginError) => {\n dead.add(change.opId);\n if (dead.has(part.opId) || gone.has(part.id)) return { moot: true };\n if (isUnavailable(error)) {\n const history = ctx.state.get();\n const older = [...history.undo, ...history.redo].filter(\n (other) => other.seq <= entry.seq,\n );\n forget(partsOf(older));\n ctx.state.update(unavailable, entry.seq);\n } else {\n // The part didn't move: it goes back, and the step can be tried again.\n ctx.state.update(stepRefused, direction, entry, part);\n }\n return { error };\n },\n );\n\n /**\n * Take one step: the undo of each part of the next entry, as one change each (undo goes\n * newest first, redo oldest first), staged now, so the views show it at once.\n */\n const step = (direction: Direction): void => {\n // What is still being typed is part of the history from now on: send it first.\n ctx.changes.sendHolds();\n const entry = nextOf(ctx.state.get(), direction);\n if (!entry) return;\n const parts = direction === 'undo' ? [...entry.parts].reverse() : entry.parts;\n const staged: { part: HistoryPart; change: PendingChange }[] = [];\n for (const part of parts) {\n try {\n const change = ctx.changes.stage({\n label: entry.label,\n undoOf: part.opId,\n shows: direction === 'undo' ? part.backward : part.forward,\n });\n staged.push({ part, change });\n } catch (error) {\n // The document closed: the parts staged so far move, the rest stay.\n if (staged.length === 0) throw error;\n break;\n }\n }\n ctx.state.update(\n stepped,\n direction,\n entry.seq,\n new Map(staged.map(({ part, change }) => [part.id, change.opId])),\n );\n inFlight += 1;\n void Promise.all(\n staged.map(({ part, change }) => answerOf(direction, entry, part, change)),\n ).then((answers) => {\n inFlight -= 1;\n if (inFlight === 0) {\n dead.clear();\n gone.clear();\n }\n const redo = direction === 'redo';\n if (answers.every((answer) => 'moot' in answer)) return;\n const failure = answers.find((answer) => 'error' in answer);\n if (failure && 'error' in failure) {\n undoFailed.emit({\n label: entry.label,\n redo,\n reason: isUnavailable(failure.error) ? 'unavailable' : 'refused',\n error: failure.error,\n });\n return;\n }\n const skipped = answers.reduce(\n (sum, answer) => sum + ('skipped' in answer ? answer.skipped : 0),\n 0,\n );\n undone.emit({ label: entry.label, redo, skipped });\n });\n };\n\n /** A change still being typed: what undo would undo before anything in the history. */\n const openHold = (): PendingChange | null =>\n ctx.changes.pending().find((change) => change.held && change.history) ?? null;\n\n const api: HistoryCapability = {\n ...settings.api,\n undo: () => step('undo'),\n redo: () => step('redo'),\n canUndo: () => openHold() !== null || ctx.state.get().undo.length > 0,\n canRedo: () => openHold() === null && ctx.state.get().redo.length > 0,\n getUndoLabel: () => openHold()?.label ?? nextOf(ctx.state.get(), 'undo')?.label ?? null,\n getRedoLabel: () =>\n openHold() === null ? (nextOf(ctx.state.get(), 'redo')?.label ?? null) : null,\n clear,\n onUndone: undone.on,\n onUndoFailed: undoFailed.on,\n };\n\n return {\n api,\n connect() {\n // A change this session staged is a step of the history, unless it moves along the\n // history (an undo or a redo) or isn't one (`history: false`).\n ctx.listen(ctx.changes.onStaged, (change) => {\n if (change.undoOf !== null || !change.history) return;\n ctx.state.update(recorded, change, settings.get().limit);\n });\n ctx.listen(ctx.changes.onSettled, (settled) => {\n const { change } = settled;\n if (change.undoOf !== null || !change.history) return;\n // A change the engine refused never happened; one that did nothing can't be undone.\n if (settled.status === 'refused' || !settled.result.meta.undoable) {\n if (settled.status === 'refused' && inFlight > 0) dead.add(change.opId);\n forget([change.opId]);\n ctx.state.update(forgotten, change.opId);\n }\n });\n ctx.listen(ctx.doc.events, (event) => {\n if (ENDS_UNDO.has(event.type)) clear();\n });\n },\n };\n}\n","import { definePlugin } from '@embedpdf/core';\n\nimport { HISTORY_DEFAULTS, HistoryToken, type HistoryConfig } from './contract';\nimport { createHistoryController } from './controller';\nimport { emptyHistory } from './model';\n\n/**\n * Undo and redo, one history per open document, of what this session changes through the\n * viewer's plugins: every change they stage on the document's change queue is a step. No\n * dependencies and no engine state of its own. `config` is the settings the app registers,\n * over {@link HISTORY_DEFAULTS}.\n */\nexport const historyPlugin = (config?: HistoryConfig) =>\n definePlugin({\n id: 'history',\n token: HistoryToken,\n scope: 'document',\n state: emptyHistory,\n settings: { defaults: HISTORY_DEFAULTS, registered: config },\n create: createHistoryController,\n });\n","/**\n * The history page's State table as code: what `useHistoryState()` returns,\n * and the same fields in every other framework. What the undo and redo\n * buttons read.\n */\nimport { defineState } from '@embedpdf/core';\n\nimport { HistoryToken } from './contract';\n\nexport const historyState = defineState(HistoryToken, {\n read: (history) => ({\n canUndo: history.canUndo(),\n canRedo: history.canRedo(),\n undoLabel: history.getUndoLabel(),\n redoLabel: history.getRedoLabel(),\n }),\n empty: {\n canUndo: false,\n canRedo: false,\n undoLabel: null,\n redoLabel: null,\n },\n});\n"],"mappings":";;;;AA+DA,MAAa,sBAA+B;CAAE,MAAM,CAAC;CAAG,MAAM,CAAC;CAAG,SAAS;CAAM,SAAS;AAAE;;AAG5F,MAAM,YAAY,cAChB,cAAc,SACT;CAAE,MAAM;CAAQ,IAAI;AAAO,IAC3B;CAAE,MAAM;CAAQ,IAAI;AAAO;;AAGlC,MAAa,UAAU,SAAkB,cACvC,QAAQ,UAAU,CAAC,GAAG,EAAE,KAAK;;;;;AAM/B,SAAgB,SAAS,SAAkB,QAAwB,OAAwB;CACzF,MAAM,OAAoB;EACxB,KAAK,QAAQ;EACb,IAAI,OAAO;EACX,MAAM,OAAO;EACb,SAAS,OAAO;EAChB,UAAU,OAAO;CACnB;CACA,MAAM,MAAM,QAAQ,KAAK,GAAG,EAAE;CAC9B,IAAI,OAAO,OAAO,UAAU,Q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EACF,UAAU;GAGR,IAAI,OAAO,IAAI,QAAQ,WAAW,WAAW;IAC3C,IAAI,OAAO,WAAW,QAAQ,CAAC,OAAO,SAAS;IAC/C,IAAI,MAAM,OAAO,UAAU,QAAQ,SAAS,IAAI,CAAC,CAAC,KAAK;GACzD,CAAC;GACD,IAAI,OAAO,IAAI,QAAQ,YAAY,YAAY;IAC7C,MAAM,EAAE,WAAW;IACnB,IAAI,OAAO,WAAW,QAAQ,CAAC,OAAO,SAAS;IAE/C,IAAI,QAAQ,WAAW,aAAa,CAAC,QAAQ,OAAO,KAAK,UAAU;KACjE,IAAI,QAAQ,WAAW,aAAa,WAAW,GAAG,KAAK,IAAI,OAAO,IAAI;KACtE,OAAO,CAAC,OAAO,IAAI,CAAC;KACpB,IAAI,MAAM,OAAO,WAAW,OAAO,IAAI;IACzC;GACF,CAAC;GACD,IAAI,OAAO,IAAI,IAAI,SAAS,UAAU;IACpC,IAAI,UAAU,IAAI,MAAM,IAAI,GAAG,MAAM;GACvC,CAAC;EACH;CACF;AACF;;;;;;;;;ACjNA,MAAa,iBAAiB,WAC5B,aAAa;CACX,IAAI;CACJ,OAAO;CACP,OAAO;CACP,OAAO;CACP,UAAU;EAAE,UAAU;EAAkB,YAAY;CAAO;CAC3D,QAAQ;AACV,CAAC;;;;;;;;ACXH,MAAa,eAAe,YAAY,cAAc;CACpD,OAAO,aAAa;EAClB,SAAS,QAAQ,QAAQ;EACzB,SAAS,QAAQ,QAAQ;EACzB,WAAW,QAAQ,aAAa;EAChC,WAAW,QAAQ,aAAa;CAClC;CACA,OAAO;EACL,SAAS;EACT,SAAS;EACT,WAAW;EACX,WAAW;CACb;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,81 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/plugin-history",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-next.15",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Undo and redo per open document, built on the document's change queue: every change the viewer's plugins stage is a step, undone by reference while still pending.",
|
|
4
6
|
"type": "module",
|
|
5
|
-
"
|
|
6
|
-
"main": "./dist/index.cjs",
|
|
7
|
+
"main": "./dist/index.js",
|
|
7
8
|
"module": "./dist/index.js",
|
|
8
9
|
"types": "./dist/index.d.ts",
|
|
9
10
|
"exports": {
|
|
10
11
|
".": {
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
12
|
"import": "./dist/index.js",
|
|
13
13
|
"require": "./dist/index.cjs"
|
|
14
14
|
},
|
|
15
|
-
"./
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"require": "./dist/preact/index.cjs"
|
|
15
|
+
"./contract": {
|
|
16
|
+
"import": "./dist/contract.js",
|
|
17
|
+
"require": "./dist/contract.cjs"
|
|
19
18
|
},
|
|
20
|
-
"./
|
|
21
|
-
"types": "./dist/react/index.d.ts",
|
|
22
|
-
"import": "./dist/react/index.js",
|
|
23
|
-
"require": "./dist/react/index.cjs"
|
|
24
|
-
},
|
|
25
|
-
"./vue": {
|
|
26
|
-
"types": "./dist/vue/index.d.ts",
|
|
27
|
-
"import": "./dist/vue/index.js",
|
|
28
|
-
"require": "./dist/vue/index.cjs"
|
|
29
|
-
},
|
|
30
|
-
"./svelte": {
|
|
31
|
-
"types": "./dist/svelte/index.d.ts",
|
|
32
|
-
"svelte": "./dist/svelte/index.js",
|
|
33
|
-
"import": "./dist/svelte/index.js",
|
|
34
|
-
"require": "./dist/svelte/index.cjs"
|
|
35
|
-
}
|
|
19
|
+
"./package.json": "./package.json"
|
|
36
20
|
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
37
24
|
"dependencies": {
|
|
38
|
-
"@embedpdf/
|
|
25
|
+
"@embedpdf/core": "3.0.0-next.15",
|
|
26
|
+
"@embedpdf/engine-core": "3.0.0-next.15"
|
|
39
27
|
},
|
|
40
28
|
"devDependencies": {
|
|
41
|
-
"@types/react": "^18.2.0",
|
|
42
29
|
"typescript": "^5.0.0",
|
|
43
|
-
"
|
|
44
|
-
"@embedpdf/build": "
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
"react-dom": ">=16.8.0",
|
|
49
|
-
"preact": "^10.26.4",
|
|
50
|
-
"vue": ">=3.2.0",
|
|
51
|
-
"svelte": ">=5 <6",
|
|
52
|
-
"@embedpdf/core": "2.15.0"
|
|
30
|
+
"vitest": "^2.1.9",
|
|
31
|
+
"@embedpdf/tooling-build": "0.0.0",
|
|
32
|
+
"@embedpdf/engine": "3.0.0-next.15",
|
|
33
|
+
"@embedpdf/plugin-interaction": "3.0.0-next.15",
|
|
34
|
+
"@embedpdf/plugin-annotation": "3.0.0-next.15"
|
|
53
35
|
},
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
"README.md"
|
|
57
|
-
],
|
|
36
|
+
"license": "Apache-2.0",
|
|
37
|
+
"sideEffects": false,
|
|
58
38
|
"repository": {
|
|
59
39
|
"type": "git",
|
|
60
|
-
"url": "https://github.com/embedpdf/embed-pdf-viewer",
|
|
61
|
-
"directory": "packages/plugin
|
|
62
|
-
},
|
|
63
|
-
"homepage": "https://www.embedpdf.com/docs",
|
|
64
|
-
"bugs": {
|
|
65
|
-
"url": "https://github.com/embedpdf/embed-pdf-viewer/issues"
|
|
66
|
-
},
|
|
67
|
-
"publishConfig": {
|
|
68
|
-
"access": "public"
|
|
40
|
+
"url": "git+https://github.com/embedpdf/embed-pdf-viewer.git",
|
|
41
|
+
"directory": "packages/plugin/history"
|
|
69
42
|
},
|
|
70
43
|
"scripts": {
|
|
71
|
-
"build
|
|
72
|
-
"build:react": "vite build --mode react",
|
|
73
|
-
"build:preact": "vite build --mode preact",
|
|
74
|
-
"build:vue": "vite build --mode vue",
|
|
75
|
-
"build:svelte": "vite build --mode svelte",
|
|
76
|
-
"build": "pnpm run clean && concurrently -c auto -n base,react,preact,vue,svelte \"vite build --mode base\" \"vite build --mode react\" \"vite build --mode preact\" \"vite build --mode vue\" \"vite build --mode svelte\"",
|
|
44
|
+
"build": "epdf-build",
|
|
77
45
|
"clean": "rimraf dist",
|
|
78
|
-
"
|
|
79
|
-
"
|
|
46
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
47
|
+
"test": "vitest run"
|
|
80
48
|
}
|
|
81
49
|
}
|
package/dist/lib/actions.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Action } from '@embedpdf/core';
|
|
2
|
-
import { HistoryDocumentState } from './types';
|
|
3
|
-
export declare const INIT_HISTORY_STATE = "HISTORY/INIT_STATE";
|
|
4
|
-
export declare const CLEANUP_HISTORY_STATE = "HISTORY/CLEANUP_STATE";
|
|
5
|
-
export declare const SET_HISTORY_DOCUMENT_STATE = "HISTORY/SET_DOCUMENT_STATE";
|
|
6
|
-
export declare const SET_ACTIVE_HISTORY_DOCUMENT = "HISTORY/SET_ACTIVE_DOCUMENT";
|
|
7
|
-
export interface InitHistoryStateAction extends Action {
|
|
8
|
-
type: typeof INIT_HISTORY_STATE;
|
|
9
|
-
payload: {
|
|
10
|
-
documentId: string;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export interface CleanupHistoryStateAction extends Action {
|
|
14
|
-
type: typeof CLEANUP_HISTORY_STATE;
|
|
15
|
-
payload: {
|
|
16
|
-
documentId: string;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
export interface SetHistoryDocumentStateAction extends Action {
|
|
20
|
-
type: typeof SET_HISTORY_DOCUMENT_STATE;
|
|
21
|
-
payload: {
|
|
22
|
-
documentId: string;
|
|
23
|
-
state: HistoryDocumentState;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export interface SetActiveHistoryDocumentAction extends Action {
|
|
27
|
-
type: typeof SET_ACTIVE_HISTORY_DOCUMENT;
|
|
28
|
-
payload: string | null;
|
|
29
|
-
}
|
|
30
|
-
export type HistoryAction = InitHistoryStateAction | CleanupHistoryStateAction | SetHistoryDocumentStateAction | SetActiveHistoryDocumentAction;
|
|
31
|
-
export declare const initHistoryState: (documentId: string) => InitHistoryStateAction;
|
|
32
|
-
export declare const cleanupHistoryState: (documentId: string) => CleanupHistoryStateAction;
|
|
33
|
-
export declare const setHistoryDocumentState: (documentId: string, state: HistoryDocumentState) => SetHistoryDocumentStateAction;
|
|
34
|
-
export declare const setActiveHistoryDocument: (documentId: string | null) => SetActiveHistoryDocumentAction;
|
|
@@ -1,33 +0,0 @@
|
|
|
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 documentHistories;
|
|
7
|
-
private readonly historyChange$;
|
|
8
|
-
constructor(id: string, registry: PluginRegistry);
|
|
9
|
-
initialize(_: HistoryPluginConfig): Promise<void>;
|
|
10
|
-
protected onDocumentLoadingStarted(documentId: string): void;
|
|
11
|
-
protected onDocumentClosed(documentId: string): void;
|
|
12
|
-
private getDocumentHistoryData;
|
|
13
|
-
private getDocumentHistoryState;
|
|
14
|
-
private emitHistoryChange;
|
|
15
|
-
private register;
|
|
16
|
-
private undo;
|
|
17
|
-
private redo;
|
|
18
|
-
private canUndo;
|
|
19
|
-
private canRedo;
|
|
20
|
-
/**
|
|
21
|
-
* Purges history entries that match the given predicate based on command metadata.
|
|
22
|
-
* Used to remove commands that are no longer valid (e.g., after a permanent redaction commit).
|
|
23
|
-
*
|
|
24
|
-
* @param predicate A function that returns true for commands that should be purged
|
|
25
|
-
* @param topic If provided, only purges entries for that specific topic
|
|
26
|
-
* @param documentId The document to purge history for
|
|
27
|
-
* @returns The number of entries that were purged
|
|
28
|
-
*/
|
|
29
|
-
private purgeByMetadata;
|
|
30
|
-
private createHistoryScope;
|
|
31
|
-
protected buildCapability(): HistoryCapability;
|
|
32
|
-
destroy(): Promise<void>;
|
|
33
|
-
}
|
package/dist/lib/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
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';
|
package/dist/lib/manifest.d.ts
DELETED
package/dist/lib/reducer.d.ts
DELETED
package/dist/lib/types.d.ts
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { BasePluginConfig, EventHook } from '@embedpdf/core';
|
|
2
|
-
export interface HistoryPluginConfig extends BasePluginConfig {
|
|
3
|
-
}
|
|
4
|
-
/**
|
|
5
|
-
* The core Command interface that other plugins will implement.
|
|
6
|
-
* @template T - Optional metadata type for identifying/filtering commands
|
|
7
|
-
*/
|
|
8
|
-
export interface Command<T = unknown> {
|
|
9
|
-
/** A function that applies the change. */
|
|
10
|
-
execute(): void;
|
|
11
|
-
/** A function that reverts the change. */
|
|
12
|
-
undo(): void;
|
|
13
|
-
/** Optional metadata for identifying/filtering commands (e.g., for purging) */
|
|
14
|
-
metadata?: T;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* An entry in the global timeline, associating a command with its topic.
|
|
18
|
-
*/
|
|
19
|
-
export interface HistoryEntry {
|
|
20
|
-
command: Command;
|
|
21
|
-
topic: string;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Per-document history state
|
|
25
|
-
*/
|
|
26
|
-
export interface HistoryDocumentState {
|
|
27
|
-
global: {
|
|
28
|
-
canUndo: boolean;
|
|
29
|
-
canRedo: boolean;
|
|
30
|
-
};
|
|
31
|
-
topics: Record<string, {
|
|
32
|
-
canUndo: boolean;
|
|
33
|
-
canRedo: boolean;
|
|
34
|
-
}>;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Information about the history state, to be emitted for UI updates.
|
|
38
|
-
* Includes per-document history states.
|
|
39
|
-
*/
|
|
40
|
-
export interface HistoryState {
|
|
41
|
-
documents: Record<string, HistoryDocumentState>;
|
|
42
|
-
activeDocumentId: string | null;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Event payload for history changes
|
|
46
|
-
*/
|
|
47
|
-
export interface HistoryChangeEvent {
|
|
48
|
-
documentId: string;
|
|
49
|
-
topic: string | undefined;
|
|
50
|
-
state: HistoryDocumentState;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Scoped history capability for a specific document
|
|
54
|
-
*/
|
|
55
|
-
export interface HistoryScope {
|
|
56
|
-
/**
|
|
57
|
-
* Registers a command with the history stack.
|
|
58
|
-
* @param command The command to register, with `execute` and `undo` methods.
|
|
59
|
-
* @param topic A string identifier for the history scope (e.g., 'annotations').
|
|
60
|
-
*/
|
|
61
|
-
register: (command: Command, topic: string) => void;
|
|
62
|
-
/**
|
|
63
|
-
* Undoes the last command.
|
|
64
|
-
* @param topic If provided, undoes the last command for that specific topic.
|
|
65
|
-
* If omitted, performs a global undo of the very last action.
|
|
66
|
-
*/
|
|
67
|
-
undo: (topic?: string) => void;
|
|
68
|
-
/**
|
|
69
|
-
* Redoes the last undone command.
|
|
70
|
-
* @param topic If provided, redoes the last command for that specific topic.
|
|
71
|
-
* If omitted, performs a global redo.
|
|
72
|
-
*/
|
|
73
|
-
redo: (topic?: string) => void;
|
|
74
|
-
/**
|
|
75
|
-
* Checks if an undo operation is possible.
|
|
76
|
-
* @param topic If provided, checks for the specific topic. Otherwise, checks globally.
|
|
77
|
-
*/
|
|
78
|
-
canUndo: (topic?: string) => boolean;
|
|
79
|
-
/**
|
|
80
|
-
* Checks if a redo operation is possible.
|
|
81
|
-
* @param topic If provided, checks for the specific topic. Otherwise, checks globally.
|
|
82
|
-
*/
|
|
83
|
-
canRedo: (topic?: string) => boolean;
|
|
84
|
-
/**
|
|
85
|
-
* Returns the current undo/redo state for all topics and the global timeline.
|
|
86
|
-
*/
|
|
87
|
-
getHistoryState: () => HistoryDocumentState;
|
|
88
|
-
/**
|
|
89
|
-
* An event hook that fires whenever a history action occurs for this document.
|
|
90
|
-
* @param topic The topic string that was affected by the action.
|
|
91
|
-
*/
|
|
92
|
-
onHistoryChange: EventHook<string | undefined>;
|
|
93
|
-
/**
|
|
94
|
-
* Purges history entries that match the given predicate based on command metadata.
|
|
95
|
-
* Used to remove commands that are no longer valid (e.g., after a permanent redaction commit).
|
|
96
|
-
* @param predicate A function that returns true for commands that should be purged
|
|
97
|
-
* @param topic If provided, only purges entries for that specific topic
|
|
98
|
-
* @returns The number of entries that were purged
|
|
99
|
-
*/
|
|
100
|
-
purgeByMetadata: <T>(predicate: (metadata: T | undefined) => boolean, topic?: string) => number;
|
|
101
|
-
}
|
|
102
|
-
export interface HistoryCapability {
|
|
103
|
-
/**
|
|
104
|
-
* Registers a command with the history stack for the active document.
|
|
105
|
-
* @param command The command to register, with `execute` and `undo` methods.
|
|
106
|
-
* @param topic A string identifier for the history scope (e.g., 'annotations').
|
|
107
|
-
*/
|
|
108
|
-
register: (command: Command, topic: string) => void;
|
|
109
|
-
/**
|
|
110
|
-
* Undoes the last command for the active document.
|
|
111
|
-
* @param topic If provided, undoes the last command for that specific topic.
|
|
112
|
-
* If omitted, performs a global undo of the very last action.
|
|
113
|
-
*/
|
|
114
|
-
undo: (topic?: string) => void;
|
|
115
|
-
/**
|
|
116
|
-
* Redoes the last undone command for the active document.
|
|
117
|
-
* @param topic If provided, redoes the last command for that specific topic.
|
|
118
|
-
* If omitted, performs a global redo.
|
|
119
|
-
*/
|
|
120
|
-
redo: (topic?: string) => void;
|
|
121
|
-
/**
|
|
122
|
-
* Checks if an undo operation is possible for the active document.
|
|
123
|
-
* @param topic If provided, checks for the specific topic. Otherwise, checks globally.
|
|
124
|
-
*/
|
|
125
|
-
canUndo: (topic?: string) => boolean;
|
|
126
|
-
/**
|
|
127
|
-
* Checks if a redo operation is possible for the active document.
|
|
128
|
-
* @param topic If provided, checks for the specific topic. Otherwise, checks globally.
|
|
129
|
-
*/
|
|
130
|
-
canRedo: (topic?: string) => boolean;
|
|
131
|
-
/**
|
|
132
|
-
* Returns the current undo/redo state for the active document.
|
|
133
|
-
*/
|
|
134
|
-
getHistoryState: () => HistoryDocumentState;
|
|
135
|
-
/**
|
|
136
|
-
* Get document-scoped history operations
|
|
137
|
-
*/
|
|
138
|
-
forDocument: (documentId: string) => HistoryScope;
|
|
139
|
-
/**
|
|
140
|
-
* An event hook that fires whenever a history action occurs.
|
|
141
|
-
*/
|
|
142
|
-
onHistoryChange: EventHook<HistoryChangeEvent>;
|
|
143
|
-
/**
|
|
144
|
-
* Purges history entries that match the given predicate based on command metadata.
|
|
145
|
-
* Used to remove commands that are no longer valid (e.g., after a permanent redaction commit).
|
|
146
|
-
* @param predicate A function that returns true for commands that should be purged
|
|
147
|
-
* @param topic If provided, only purges entries for that specific topic
|
|
148
|
-
* @returns The number of entries that were purged
|
|
149
|
-
*/
|
|
150
|
-
purgeByMetadata: <T>(predicate: (metadata: T | undefined) => boolean, topic?: string) => number;
|
|
151
|
-
}
|
package/dist/preact/adapter.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useEffect, useRef, useState, useCallback } from 'preact/hooks';
|
package/dist/preact/core.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@embedpdf/core/preact';
|
package/dist/preact/index.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/preact"),t=require("@embedpdf/plugin-history");exports.useHistoryCapability=()=>e.useCapability(t.HistoryPlugin.id),exports.useHistoryPlugin=()=>e.usePlugin(t.HistoryPlugin.id),Object.keys(t).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
|
|
2
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/preact/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../shared-preact';
|
package/dist/preact/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { useCapability, usePlugin } from "@embedpdf/core/preact";
|
|
2
|
-
import { HistoryPlugin } from "@embedpdf/plugin-history";
|
|
3
|
-
export * from "@embedpdf/plugin-history";
|
|
4
|
-
const useHistoryPlugin = () => usePlugin(HistoryPlugin.id);
|
|
5
|
-
const useHistoryCapability = () => useCapability(HistoryPlugin.id);
|
|
6
|
-
export {
|
|
7
|
-
useHistoryCapability,
|
|
8
|
-
useHistoryPlugin
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
package/dist/preact/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;"}
|
package/dist/react/adapter.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useEffect, useRef, useCallback, useState } from 'react';
|
package/dist/react/core.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@embedpdf/core/react';
|
package/dist/react/index.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/react"),t=require("@embedpdf/plugin-history");exports.useHistoryCapability=()=>e.useCapability(t.HistoryPlugin.id),exports.useHistoryPlugin=()=>e.usePlugin(t.HistoryPlugin.id),Object.keys(t).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
|
|
2
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/react/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/react/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../shared-react';
|
package/dist/react/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { useCapability, usePlugin } from "@embedpdf/core/react";
|
|
2
|
-
import { HistoryPlugin } from "@embedpdf/plugin-history";
|
|
3
|
-
export * from "@embedpdf/plugin-history";
|
|
4
|
-
const useHistoryPlugin = () => usePlugin(HistoryPlugin.id);
|
|
5
|
-
const useHistoryCapability = () => useCapability(HistoryPlugin.id);
|
|
6
|
-
export {
|
|
7
|
-
useHistoryCapability,
|
|
8
|
-
useHistoryPlugin
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
package/dist/react/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './use-history';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { HistoryPlugin } from '../../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('../../index.ts').HistoryCapability> | null;
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
ready: Promise<void>;
|
|
11
|
-
};
|
package/dist/shared/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './use-history';
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './use-history';
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './use-history';
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/svelte/index.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/svelte"),t=require("@embedpdf/plugin-history");exports.useHistoryCapability=()=>e.useCapability(t.HistoryPlugin.id),exports.useHistoryPlugin=()=>e.usePlugin(t.HistoryPlugin.id),Object.keys(t).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
|
|
2
|
-
//# sourceMappingURL=index.cjs.map
|