@embedpdf/plugin-rotate 2.0.0-next.1 → 2.0.0-next.3
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 +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@embedpdf/core"),o="rotate",e={id:o,name:"Rotate Plugin",version:"1.0.0",provides:["rotate"],requires:[],optional:[],defaultConfig:{
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@embedpdf/core"),o="rotate",e={id:o,name:"Rotate Plugin",version:"1.0.0",provides:["rotate"],requires:[],optional:[],defaultConfig:{}};function n(t,o,e){let n=1,a=0,i=0,r=1,s=0,c=0;switch(t){case 1:n=0,a=1,i=-1,r=0,s=e;break;case 2:n=-1,a=0,i=0,r=-1,s=o,c=e;break;case 3:n=0,a=-1,i=1,r=0,c=o}return[n,a,i,r,s,c]}function a(t,o,e){const[a,i,r,s,c,u]=n(t,o,e);return`matrix(${a},${i},${r},${s},${c},${u})`}function i(t){return(t+1)%4}function r(t){return(t+3)%4}const s="ROTATE/INIT_STATE",c="ROTATE/CLEANUP_STATE",u="ROTATE/SET_ACTIVE_DOCUMENT",d="ROTATE/SET_ROTATION";function m(t,o){return{type:s,payload:{documentId:t,state:o}}}function l(t){return{type:c,payload:t}}function h(t,o){return{type:d,payload:{documentId:t,rotation:o}}}const R=class extends t.BasePlugin{constructor(o,e,n){super(o,e),this.rotate$=t.createBehaviorEmitter(),this.defaultRotation=n.defaultRotation??0}onDocumentLoadingStarted(o){const e={rotation:this.defaultRotation};this.dispatch(m(o,e)),this.dispatchCoreAction(t.setRotation(this.defaultRotation,o)),this.logger.debug("RotatePlugin","DocumentOpened",`Initialized rotation state for document: ${o}`)}onDocumentClosed(t){this.dispatch(l(t)),this.logger.debug("RotatePlugin","DocumentClosed",`Cleaned up rotation state for document: ${t}`)}buildCapability(){return{setRotation:t=>this.setRotationForDocument(t),getRotation:()=>this.getRotationForDocument(),rotateForward:()=>this.rotateForward(),rotateBackward:()=>this.rotateBackward(),forDocument:t=>this.createRotateScope(t),onRotateChange:this.rotate$.on}}createRotateScope(t){return{setRotation:o=>this.setRotationForDocument(o,t),getRotation:()=>this.getRotationForDocument(t),rotateForward:()=>this.rotateForward(t),rotateBackward:()=>this.rotateBackward(t),onRotateChange:o=>this.rotate$.on(e=>{e.documentId===t&&o(e.rotation)})}}getDocumentState(t){const o=t??this.getActiveDocumentId();return this.state.documents[o]??null}getDocumentStateOrThrow(t){const o=this.getDocumentState(t);if(!o)throw new Error(`Rotation state not found for document: ${t??"active"}`);return o}setRotationForDocument(o,e){const n=e??this.getActiveDocumentId(),a=this.coreState.core.documents[n];if(!(null==a?void 0:a.document))throw new Error(`Document ${n} not loaded`);this.dispatch(h(n,o)),this.dispatchCoreAction(t.setRotation(o,n)),this.rotate$.emit({documentId:n,rotation:o})}getRotationForDocument(t){return this.getDocumentStateOrThrow(t).rotation}rotateForward(t){const o=t??this.getActiveDocumentId(),e=i(this.getRotationForDocument(o));this.setRotationForDocument(e,o)}rotateBackward(t){const o=t??this.getActiveDocumentId(),e=r(this.getRotationForDocument(o));this.setRotationForDocument(e,o)}getMatrixAsString(t){return a(t.rotation,t.width,t.height)}onStoreUpdated(t,o){for(const e in o.documents){const n=t.documents[e],a=o.documents[e];(null==n?void 0:n.rotation)!==a.rotation&&this.logger.debug("RotatePlugin","RotationChanged",`Rotation changed for document ${e}: ${(null==n?void 0:n.rotation)??0} -> ${a.rotation}`)}}async initialize(t){this.logger.info("RotatePlugin","Initialize","Rotate plugin initialized")}async destroy(){this.rotate$.clear(),super.destroy()}};R.id="rotate";let g=R;const p={documents:{},activeDocumentId:null},T=(t=p,o)=>{switch(o.type){case s:{const{documentId:e,state:n}=o.payload;return{...t,documents:{...t.documents,[e]:n},activeDocumentId:t.activeDocumentId??e}}case c:{const e=o.payload,{[e]:n,...a}=t.documents;return{...t,documents:a,activeDocumentId:t.activeDocumentId===e?null:t.activeDocumentId}}case u:return{...t,activeDocumentId:o.payload};case d:{const{documentId:e,rotation:n}=o.payload,a=t.documents[e];return a?{...t,documents:{...t.documents,[e]:{...a,rotation:n}}}:t}default:return t}},D={manifest:e,create:(t,e)=>new g(o,t,e),reducer:T,initialState:p};exports.CLEANUP_ROTATE_STATE=c,exports.INIT_ROTATE_STATE=s,exports.ROTATE_PLUGIN_ID=o,exports.RotatePlugin=g,exports.RotatePluginPackage=D,exports.SET_ACTIVE_ROTATE_DOCUMENT=u,exports.SET_ROTATION=d,exports.cleanupRotateState=l,exports.getNextRotation=i,exports.getPreviousRotation=r,exports.getRotationMatrix=n,exports.getRotationMatrixString=a,exports.initRotateState=m,exports.initialDocumentState={rotation:0},exports.initialState=p,exports.manifest=e,exports.rotateReducer=T,exports.setActiveRotateDocument=function(t){return{type:u,payload:t}},exports.setRotation=h;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/lib/manifest.ts","../src/lib/utils.ts","../src/lib/actions.ts","../src/lib/rotate-plugin.ts","../src/lib/reducer.ts","../src/lib/index.ts"],"sourcesContent":["import { PluginManifest } from '@embedpdf/core';\nimport { RotatePluginConfig } from './types';\n\nexport const ROTATE_PLUGIN_ID = 'rotate';\n\nexport const manifest: PluginManifest<RotatePluginConfig> = {\n id: ROTATE_PLUGIN_ID,\n name: 'Rotate Plugin',\n version: '1.0.0',\n provides: ['rotate'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n },\n};\n","import { Rotation } from '@embedpdf/models';\n\n/**\n * Returns the 6-tuple transformation matrix for rotation.\n * Rotation is clockwise, origin = top-left (0 0).\n *\n * ── Note on e,f ───────────────────────────────\n * For 0°/180° no translation is needed.\n * For 90°/270° you may want to pass the page\n * height / width so the page stays in positive\n * coordinates. Keep them 0 and handle layout\n * elsewhere if that's what you do today.\n */\nexport function getRotationMatrix(\n rotation: Rotation,\n w: number,\n h: number,\n): [number, number, number, number, number, number] {\n let a = 1,\n b = 0,\n c = 0,\n d = 1,\n e = 0,\n f = 0;\n\n switch (rotation) {\n case 1: // 90°\n a = 0;\n b = 1;\n c = -1;\n d = 0;\n e = h;\n break;\n case 2: // 180°\n a = -1;\n b = 0;\n c = 0;\n d = -1;\n e = w;\n f = h;\n break;\n case 3: // 270°\n a = 0;\n b = -1;\n c = 1;\n d = 0;\n f = w;\n break;\n }\n\n return [a, b, c, d, e, f];\n}\n\n/**\n * Returns the CSS matrix transformation string for rotation.\n * Rotation is clockwise, origin = top-left (0 0).\n */\nexport function getRotationMatrixString(rotation: Rotation, w: number, h: number): string {\n const [a, b, c, d, e, f] = getRotationMatrix(rotation, w, h);\n return `matrix(${a},${b},${c},${d},${e},${f})`;\n}\n\n/**\n * Returns the next rotation.\n */\nexport function getNextRotation(current: Rotation): Rotation {\n return ((current + 1) % 4) as Rotation;\n}\n\n/**\n * Returns the previous rotation.\n */\nexport function getPreviousRotation(current: Rotation): Rotation {\n return ((current + 3) % 4) as Rotation; // +3 is equivalent to -1 in modulo 4\n}\n","import { Action } from '@embedpdf/core';\nimport { Rotation } from '@embedpdf/models';\nimport { RotateDocumentState } from './types';\n\n// Document lifecycle\nexport const INIT_ROTATE_STATE = 'ROTATE/INIT_STATE';\nexport const CLEANUP_ROTATE_STATE = 'ROTATE/CLEANUP_STATE';\nexport const SET_ACTIVE_ROTATE_DOCUMENT = 'ROTATE/SET_ACTIVE_DOCUMENT';\n\n// Rotation operations\nexport const SET_ROTATION = 'ROTATE/SET_ROTATION';\n\n// Document lifecycle actions\nexport interface InitRotateStateAction extends Action {\n type: typeof INIT_ROTATE_STATE;\n payload: {\n documentId: string;\n state: RotateDocumentState;\n };\n}\n\nexport interface CleanupRotateStateAction extends Action {\n type: typeof CLEANUP_ROTATE_STATE;\n payload: string; // documentId\n}\n\nexport interface SetActiveRotateDocumentAction extends Action {\n type: typeof SET_ACTIVE_ROTATE_DOCUMENT;\n payload: string | null; // documentId\n}\n\nexport interface SetRotationAction extends Action {\n type: typeof SET_ROTATION;\n payload: {\n documentId: string;\n rotation: Rotation;\n };\n}\n\nexport type RotateAction =\n | InitRotateStateAction\n | CleanupRotateStateAction\n | SetActiveRotateDocumentAction\n | SetRotationAction;\n\n// Action Creators\nexport function initRotateState(\n documentId: string,\n state: RotateDocumentState,\n): InitRotateStateAction {\n return { type: INIT_ROTATE_STATE, payload: { documentId, state } };\n}\n\nexport function cleanupRotateState(documentId: string): CleanupRotateStateAction {\n return { type: CLEANUP_ROTATE_STATE, payload: documentId };\n}\n\nexport function setActiveRotateDocument(documentId: string | null): SetActiveRotateDocumentAction {\n return { type: SET_ACTIVE_ROTATE_DOCUMENT, payload: documentId };\n}\n\nexport function setRotation(documentId: string, rotation: Rotation): SetRotationAction {\n return { type: SET_ROTATION, payload: { documentId, rotation } };\n}\n","import {\n BasePlugin,\n createBehaviorEmitter,\n Listener,\n PluginRegistry,\n setRotation as setCoreRotation,\n} from '@embedpdf/core';\nimport { Rotation } from '@embedpdf/models';\nimport {\n GetMatrixOptions,\n RotateCapability,\n RotatePluginConfig,\n RotateScope,\n RotationChangeEvent,\n RotateState,\n RotateDocumentState,\n} from './types';\nimport { getNextRotation, getPreviousRotation, getRotationMatrixString } from './utils';\nimport { initRotateState, cleanupRotateState, setRotation, RotateAction } from './actions';\n\nexport class RotatePlugin extends BasePlugin<\n RotatePluginConfig,\n RotateCapability,\n RotateState,\n RotateAction\n> {\n static readonly id = 'rotate' as const;\n\n private readonly rotate$ = createBehaviorEmitter<RotationChangeEvent>();\n private readonly defaultRotation: Rotation;\n\n constructor(id: string, registry: PluginRegistry, cfg: RotatePluginConfig) {\n super(id, registry);\n this.defaultRotation = cfg.defaultRotation ?? 0;\n }\n\n // ─────────────────────────────────────────────────────────\n // Document Lifecycle Hooks (from BasePlugin)\n // ─────────────────────────────────────────────────────────\n\n protected override onDocumentLoadingStarted(documentId: string): void {\n // Initialize rotation state for this document\n const docState: RotateDocumentState = {\n rotation: this.defaultRotation,\n };\n\n this.dispatch(initRotateState(documentId, docState));\n\n // Also set in core state for backwards compatibility\n this.dispatchCoreAction(setCoreRotation(this.defaultRotation, documentId));\n\n this.logger.debug(\n 'RotatePlugin',\n 'DocumentOpened',\n `Initialized rotation state for document: ${documentId}`,\n );\n }\n\n protected override onDocumentClosed(documentId: string): void {\n this.dispatch(cleanupRotateState(documentId));\n\n this.logger.debug(\n 'RotatePlugin',\n 'DocumentClosed',\n `Cleaned up rotation state for document: ${documentId}`,\n );\n }\n\n // ─────────────────────────────────────────────────────────\n // Capability\n // ─────────────────────────────────────────────────────────\n\n protected buildCapability(): RotateCapability {\n return {\n // Active document operations\n setRotation: (rotation: Rotation) => this.setRotationForDocument(rotation),\n getRotation: () => this.getRotationForDocument(),\n rotateForward: () => this.rotateForward(),\n rotateBackward: () => this.rotateBackward(),\n\n // Document-scoped operations\n forDocument: (documentId: string) => this.createRotateScope(documentId),\n\n // Events\n onRotateChange: this.rotate$.on,\n };\n }\n\n // ─────────────────────────────────────────────────────────\n // Document Scoping\n // ─────────────────────────────────────────────────────────\n\n private createRotateScope(documentId: string): RotateScope {\n return {\n setRotation: (rotation: Rotation) => this.setRotationForDocument(rotation, documentId),\n getRotation: () => this.getRotationForDocument(documentId),\n rotateForward: () => this.rotateForward(documentId),\n rotateBackward: () => this.rotateBackward(documentId),\n onRotateChange: (listener: Listener<Rotation>) =>\n this.rotate$.on((event) => {\n if (event.documentId === documentId) listener(event.rotation);\n }),\n };\n }\n\n // ─────────────────────────────────────────────────────────\n // State Helpers\n // ─────────────────────────────────────────────────────────\n private getDocumentState(documentId?: string): RotateDocumentState | null {\n const id = documentId ?? this.getActiveDocumentId();\n return this.state.documents[id] ?? null;\n }\n\n private getDocumentStateOrThrow(documentId?: string): RotateDocumentState {\n const state = this.getDocumentState(documentId);\n if (!state) {\n throw new Error(`Rotation state not found for document: ${documentId ?? 'active'}`);\n }\n return state;\n }\n\n // ─────────────────────────────────────────────────────────\n // Core Operations\n // ─────────────────────────────────────────────────────────\n\n private setRotationForDocument(rotation: Rotation, documentId?: string): void {\n const id = documentId ?? this.getActiveDocumentId();\n const coreDoc = this.coreState.core.documents[id];\n\n if (!coreDoc?.document) {\n throw new Error(`Document ${id} not loaded`);\n }\n\n // Update plugin state\n this.dispatch(setRotation(id, rotation));\n\n // Update core state for backwards compatibility\n this.dispatchCoreAction(setCoreRotation(rotation, id));\n\n // Emit event\n this.rotate$.emit({\n documentId: id,\n rotation,\n });\n }\n\n private getRotationForDocument(documentId?: string): Rotation {\n return this.getDocumentStateOrThrow(documentId).rotation;\n }\n\n private rotateForward(documentId?: string): void {\n const id = documentId ?? this.getActiveDocumentId();\n const currentRotation = this.getRotationForDocument(id);\n const nextRotation = getNextRotation(currentRotation);\n this.setRotationForDocument(nextRotation, id);\n }\n\n private rotateBackward(documentId?: string): void {\n const id = documentId ?? this.getActiveDocumentId();\n const currentRotation = this.getRotationForDocument(id);\n const prevRotation = getPreviousRotation(currentRotation);\n this.setRotationForDocument(prevRotation, id);\n }\n\n public getMatrixAsString(options: GetMatrixOptions): string {\n return getRotationMatrixString(options.rotation, options.width, options.height);\n }\n\n // ─────────────────────────────────────────────────────────\n // Store Update Handlers\n // ─────────────────────────────────────────────────────────\n\n override onStoreUpdated(prevState: RotateState, newState: RotateState): void {\n // Emit rotation change events for each changed document\n for (const documentId in newState.documents) {\n const prevDoc = prevState.documents[documentId];\n const newDoc = newState.documents[documentId];\n\n if (prevDoc?.rotation !== newDoc.rotation) {\n this.logger.debug(\n 'RotatePlugin',\n 'RotationChanged',\n `Rotation changed for document ${documentId}: ${prevDoc?.rotation ?? 0} -> ${newDoc.rotation}`,\n );\n }\n }\n }\n\n // ─────────────────────────────────────────────────────────\n // Lifecycle\n // ─────────────────────────────────────────────────────────\n\n async initialize(_config: RotatePluginConfig): Promise<void> {\n this.logger.info('RotatePlugin', 'Initialize', 'Rotate plugin initialized');\n }\n\n async destroy(): Promise<void> {\n this.rotate$.clear();\n super.destroy();\n }\n}\n","import { Reducer } from '@embedpdf/core';\nimport {\n RotateAction,\n INIT_ROTATE_STATE,\n CLEANUP_ROTATE_STATE,\n SET_ACTIVE_ROTATE_DOCUMENT,\n SET_ROTATION,\n} from './actions';\nimport { RotateState, RotateDocumentState } from './types';\n\nexport const initialDocumentState: RotateDocumentState = {\n rotation: 0,\n};\n\nexport const initialState: RotateState = {\n documents: {},\n activeDocumentId: null,\n};\n\nexport const rotateReducer: Reducer<RotateState, RotateAction> = (state = initialState, action) => {\n switch (action.type) {\n case INIT_ROTATE_STATE: {\n const { documentId, state: docState } = action.payload;\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: docState,\n },\n // Set as active if no active document\n activeDocumentId: state.activeDocumentId ?? documentId,\n };\n }\n\n case CLEANUP_ROTATE_STATE: {\n const documentId = action.payload;\n const { [documentId]: removed, ...remainingDocs } = state.documents;\n return {\n ...state,\n documents: remainingDocs,\n activeDocumentId: state.activeDocumentId === documentId ? null : state.activeDocumentId,\n };\n }\n\n case SET_ACTIVE_ROTATE_DOCUMENT: {\n return {\n ...state,\n activeDocumentId: action.payload,\n };\n }\n\n case SET_ROTATION: {\n const { documentId, rotation } = action.payload;\n const docState = state.documents[documentId];\n if (!docState) return state;\n\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n rotation,\n },\n },\n };\n }\n\n default:\n return state;\n }\n};\n","import { PluginPackage } from '@embedpdf/core';\nimport { manifest, ROTATE_PLUGIN_ID } from './manifest';\nimport { RotatePluginConfig, RotateState } from './types';\nimport { RotatePlugin } from './rotate-plugin';\nimport { RotateAction } from './actions';\nimport { rotateReducer, initialState } from './reducer';\n\nexport const RotatePluginPackage: PluginPackage<\n RotatePlugin,\n RotatePluginConfig,\n RotateState,\n RotateAction\n> = {\n manifest,\n create: (registry, config) => new RotatePlugin(ROTATE_PLUGIN_ID, registry, config),\n reducer: rotateReducer,\n initialState,\n};\n\nexport * from './rotate-plugin';\nexport * from './types';\nexport * from './manifest';\nexport * from './actions';\nexport * from './reducer';\nexport * from './utils';\n"],"names":["ROTATE_PLUGIN_ID","manifest","id","name","version","provides","requires","optional","defaultConfig","enabled","getRotationMatrix","rotation","w","h","a","b","c","d","e","f","getRotationMatrixString","getNextRotation","current","getPreviousRotation","INIT_ROTATE_STATE","CLEANUP_ROTATE_STATE","SET_ACTIVE_ROTATE_DOCUMENT","SET_ROTATION","initRotateState","documentId","state","type","payload","cleanupRotateState","setRotation","_RotatePlugin","BasePlugin","constructor","registry","cfg","super","this","rotate$","createBehaviorEmitter","defaultRotation","onDocumentLoadingStarted","docState","dispatch","dispatchCoreAction","setCoreRotation","logger","debug","onDocumentClosed","buildCapability","setRotationForDocument","getRotation","getRotationForDocument","rotateForward","rotateBackward","forDocument","createRotateScope","onRotateChange","on","listener","event","getDocumentState","getActiveDocumentId","documents","getDocumentStateOrThrow","Error","coreDoc","coreState","core","document","emit","nextRotation","prevRotation","getMatrixAsString","options","width","height","onStoreUpdated","prevState","newState","prevDoc","newDoc","initialize","_config","info","destroy","clear","RotatePlugin","initialState","activeDocumentId","rotateReducer","action","removed","remainingDocs","RotatePluginPackage","create","config","reducer"],"mappings":"kHAGaA,EAAmB,SAEnBC,EAA+C,CAC1DC,GAAIF,EACJG,KAAM,gBACNC,QAAS,QACTC,SAAU,CAAC,UACXC,SAAU,GACVC,SAAU,GACVC,cAAe,CACbC,SAAS,ICAN,SAASC,EACdC,EACAC,EACAC,GAEA,IAAIC,EAAI,EACNC,EAAI,EACJC,EAAI,EACJC,EAAI,EACJC,EAAI,EACJC,EAAI,EAEN,OAAQR,GACN,KAAK,EACHG,EAAI,EACJC,EAAI,EACJC,GAAI,EACJC,EAAI,EACJC,EAAIL,EACJ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,GAAaiB,GAGhB+C,iBAAkB/D,EAAM+D,kBAAoBhE,EAEhD,CAEA,KAAKJ,EAAsB,CACzB,MAAMI,EAAakE,EAAO/D,SAClBH,CAACA,GAAamE,KAAYC,GAAkBnE,EAAMqC,UAC1D,MAAO,IACFrC,EACHqC,UAAW8B,EACXJ,iBAAkB/D,EAAM+D,mBAAqBhE,EAAa,KAAOC,EAAM+D,iBAE3E,CAEA,KAAKnE,EACH,MAAO,IACFI,EACH+D,iBAAkBE,EAAO/D,SAI7B,KAAKL,EAAc,CACjB,MAAME,WAAEA,EAAAlB,SAAYA,GAAaoF,EAAO/D,QAClCc,EAAWhB,EAAMqC,UAAUtC,GACjC,OAAKiB,EAEE,IACFhB,EACHqC,UAAW,IACNrC,EAAMqC,UACTtC,CAACA,GAAa,IACTiB,EACHnC,cARgBmB,CAYxB,CAEA,QACE,OAAOA,IC9DAoE,EAKT,CACFjG,WACAkG,OAAQ,CAAC7D,EAAU8D,IAAW,IAAIT,EAAa3F,EAAkBsC,EAAU8D,GAC3EC,QAASP,EACTF,iaDNuD,CACvDjF,SAAU,qGF8CL,SAAiCkB,GACtC,MAAO,CAAEE,KAAML,EAA4BM,QAASH,EACtD"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/lib/manifest.ts","../src/lib/utils.ts","../src/lib/actions.ts","../src/lib/rotate-plugin.ts","../src/lib/reducer.ts","../src/lib/index.ts"],"sourcesContent":["import { PluginManifest } from '@embedpdf/core';\nimport { RotatePluginConfig } from './types';\n\nexport const ROTATE_PLUGIN_ID = 'rotate';\n\nexport const manifest: PluginManifest<RotatePluginConfig> = {\n id: ROTATE_PLUGIN_ID,\n name: 'Rotate Plugin',\n version: '1.0.0',\n provides: ['rotate'],\n requires: [],\n optional: [],\n defaultConfig: {},\n};\n","import { Rotation } from '@embedpdf/models';\n\n/**\n * Returns the 6-tuple transformation matrix for rotation.\n * Rotation is clockwise, origin = top-left (0 0).\n *\n * ── Note on e,f ───────────────────────────────\n * For 0°/180° no translation is needed.\n * For 90°/270° you may want to pass the page\n * height / width so the page stays in positive\n * coordinates. Keep them 0 and handle layout\n * elsewhere if that's what you do today.\n */\nexport function getRotationMatrix(\n rotation: Rotation,\n w: number,\n h: number,\n): [number, number, number, number, number, number] {\n let a = 1,\n b = 0,\n c = 0,\n d = 1,\n e = 0,\n f = 0;\n\n switch (rotation) {\n case 1: // 90°\n a = 0;\n b = 1;\n c = -1;\n d = 0;\n e = h;\n break;\n case 2: // 180°\n a = -1;\n b = 0;\n c = 0;\n d = -1;\n e = w;\n f = h;\n break;\n case 3: // 270°\n a = 0;\n b = -1;\n c = 1;\n d = 0;\n f = w;\n break;\n }\n\n return [a, b, c, d, e, f];\n}\n\n/**\n * Returns the CSS matrix transformation string for rotation.\n * Rotation is clockwise, origin = top-left (0 0).\n */\nexport function getRotationMatrixString(rotation: Rotation, w: number, h: number): string {\n const [a, b, c, d, e, f] = getRotationMatrix(rotation, w, h);\n return `matrix(${a},${b},${c},${d},${e},${f})`;\n}\n\n/**\n * Returns the next rotation.\n */\nexport function getNextRotation(current: Rotation): Rotation {\n return ((current + 1) % 4) as Rotation;\n}\n\n/**\n * Returns the previous rotation.\n */\nexport function getPreviousRotation(current: Rotation): Rotation {\n return ((current + 3) % 4) as Rotation; // +3 is equivalent to -1 in modulo 4\n}\n","import { Action } from '@embedpdf/core';\nimport { Rotation } from '@embedpdf/models';\nimport { RotateDocumentState } from './types';\n\n// Document lifecycle\nexport const INIT_ROTATE_STATE = 'ROTATE/INIT_STATE';\nexport const CLEANUP_ROTATE_STATE = 'ROTATE/CLEANUP_STATE';\nexport const SET_ACTIVE_ROTATE_DOCUMENT = 'ROTATE/SET_ACTIVE_DOCUMENT';\n\n// Rotation operations\nexport const SET_ROTATION = 'ROTATE/SET_ROTATION';\n\n// Document lifecycle actions\nexport interface InitRotateStateAction extends Action {\n type: typeof INIT_ROTATE_STATE;\n payload: {\n documentId: string;\n state: RotateDocumentState;\n };\n}\n\nexport interface CleanupRotateStateAction extends Action {\n type: typeof CLEANUP_ROTATE_STATE;\n payload: string; // documentId\n}\n\nexport interface SetActiveRotateDocumentAction extends Action {\n type: typeof SET_ACTIVE_ROTATE_DOCUMENT;\n payload: string | null; // documentId\n}\n\nexport interface SetRotationAction extends Action {\n type: typeof SET_ROTATION;\n payload: {\n documentId: string;\n rotation: Rotation;\n };\n}\n\nexport type RotateAction =\n | InitRotateStateAction\n | CleanupRotateStateAction\n | SetActiveRotateDocumentAction\n | SetRotationAction;\n\n// Action Creators\nexport function initRotateState(\n documentId: string,\n state: RotateDocumentState,\n): InitRotateStateAction {\n return { type: INIT_ROTATE_STATE, payload: { documentId, state } };\n}\n\nexport function cleanupRotateState(documentId: string): CleanupRotateStateAction {\n return { type: CLEANUP_ROTATE_STATE, payload: documentId };\n}\n\nexport function setActiveRotateDocument(documentId: string | null): SetActiveRotateDocumentAction {\n return { type: SET_ACTIVE_ROTATE_DOCUMENT, payload: documentId };\n}\n\nexport function setRotation(documentId: string, rotation: Rotation): SetRotationAction {\n return { type: SET_ROTATION, payload: { documentId, rotation } };\n}\n","import {\n BasePlugin,\n createBehaviorEmitter,\n Listener,\n PluginRegistry,\n setRotation as setCoreRotation,\n} from '@embedpdf/core';\nimport { Rotation } from '@embedpdf/models';\nimport {\n GetMatrixOptions,\n RotateCapability,\n RotatePluginConfig,\n RotateScope,\n RotationChangeEvent,\n RotateState,\n RotateDocumentState,\n} from './types';\nimport { getNextRotation, getPreviousRotation, getRotationMatrixString } from './utils';\nimport { initRotateState, cleanupRotateState, setRotation, RotateAction } from './actions';\n\nexport class RotatePlugin extends BasePlugin<\n RotatePluginConfig,\n RotateCapability,\n RotateState,\n RotateAction\n> {\n static readonly id = 'rotate' as const;\n\n private readonly rotate$ = createBehaviorEmitter<RotationChangeEvent>();\n private readonly defaultRotation: Rotation;\n\n constructor(id: string, registry: PluginRegistry, cfg: RotatePluginConfig) {\n super(id, registry);\n this.defaultRotation = cfg.defaultRotation ?? 0;\n }\n\n // ─────────────────────────────────────────────────────────\n // Document Lifecycle Hooks (from BasePlugin)\n // ─────────────────────────────────────────────────────────\n\n protected override onDocumentLoadingStarted(documentId: string): void {\n // Initialize rotation state for this document\n const docState: RotateDocumentState = {\n rotation: this.defaultRotation,\n };\n\n this.dispatch(initRotateState(documentId, docState));\n\n // Also set in core state for backwards compatibility\n this.dispatchCoreAction(setCoreRotation(this.defaultRotation, documentId));\n\n this.logger.debug(\n 'RotatePlugin',\n 'DocumentOpened',\n `Initialized rotation state for document: ${documentId}`,\n );\n }\n\n protected override onDocumentClosed(documentId: string): void {\n this.dispatch(cleanupRotateState(documentId));\n\n this.logger.debug(\n 'RotatePlugin',\n 'DocumentClosed',\n `Cleaned up rotation state for document: ${documentId}`,\n );\n }\n\n // ─────────────────────────────────────────────────────────\n // Capability\n // ─────────────────────────────────────────────────────────\n\n protected buildCapability(): RotateCapability {\n return {\n // Active document operations\n setRotation: (rotation: Rotation) => this.setRotationForDocument(rotation),\n getRotation: () => this.getRotationForDocument(),\n rotateForward: () => this.rotateForward(),\n rotateBackward: () => this.rotateBackward(),\n\n // Document-scoped operations\n forDocument: (documentId: string) => this.createRotateScope(documentId),\n\n // Events\n onRotateChange: this.rotate$.on,\n };\n }\n\n // ─────────────────────────────────────────────────────────\n // Document Scoping\n // ─────────────────────────────────────────────────────────\n\n private createRotateScope(documentId: string): RotateScope {\n return {\n setRotation: (rotation: Rotation) => this.setRotationForDocument(rotation, documentId),\n getRotation: () => this.getRotationForDocument(documentId),\n rotateForward: () => this.rotateForward(documentId),\n rotateBackward: () => this.rotateBackward(documentId),\n onRotateChange: (listener: Listener<Rotation>) =>\n this.rotate$.on((event) => {\n if (event.documentId === documentId) listener(event.rotation);\n }),\n };\n }\n\n // ─────────────────────────────────────────────────────────\n // State Helpers\n // ─────────────────────────────────────────────────────────\n private getDocumentState(documentId?: string): RotateDocumentState | null {\n const id = documentId ?? this.getActiveDocumentId();\n return this.state.documents[id] ?? null;\n }\n\n private getDocumentStateOrThrow(documentId?: string): RotateDocumentState {\n const state = this.getDocumentState(documentId);\n if (!state) {\n throw new Error(`Rotation state not found for document: ${documentId ?? 'active'}`);\n }\n return state;\n }\n\n // ─────────────────────────────────────────────────────────\n // Core Operations\n // ─────────────────────────────────────────────────────────\n\n private setRotationForDocument(rotation: Rotation, documentId?: string): void {\n const id = documentId ?? this.getActiveDocumentId();\n const coreDoc = this.coreState.core.documents[id];\n\n if (!coreDoc?.document) {\n throw new Error(`Document ${id} not loaded`);\n }\n\n // Update plugin state\n this.dispatch(setRotation(id, rotation));\n\n // Update core state for backwards compatibility\n this.dispatchCoreAction(setCoreRotation(rotation, id));\n\n // Emit event\n this.rotate$.emit({\n documentId: id,\n rotation,\n });\n }\n\n private getRotationForDocument(documentId?: string): Rotation {\n return this.getDocumentStateOrThrow(documentId).rotation;\n }\n\n private rotateForward(documentId?: string): void {\n const id = documentId ?? this.getActiveDocumentId();\n const currentRotation = this.getRotationForDocument(id);\n const nextRotation = getNextRotation(currentRotation);\n this.setRotationForDocument(nextRotation, id);\n }\n\n private rotateBackward(documentId?: string): void {\n const id = documentId ?? this.getActiveDocumentId();\n const currentRotation = this.getRotationForDocument(id);\n const prevRotation = getPreviousRotation(currentRotation);\n this.setRotationForDocument(prevRotation, id);\n }\n\n public getMatrixAsString(options: GetMatrixOptions): string {\n return getRotationMatrixString(options.rotation, options.width, options.height);\n }\n\n // ─────────────────────────────────────────────────────────\n // Store Update Handlers\n // ─────────────────────────────────────────────────────────\n\n override onStoreUpdated(prevState: RotateState, newState: RotateState): void {\n // Emit rotation change events for each changed document\n for (const documentId in newState.documents) {\n const prevDoc = prevState.documents[documentId];\n const newDoc = newState.documents[documentId];\n\n if (prevDoc?.rotation !== newDoc.rotation) {\n this.logger.debug(\n 'RotatePlugin',\n 'RotationChanged',\n `Rotation changed for document ${documentId}: ${prevDoc?.rotation ?? 0} -> ${newDoc.rotation}`,\n );\n }\n }\n }\n\n // ─────────────────────────────────────────────────────────\n // Lifecycle\n // ─────────────────────────────────────────────────────────\n\n async initialize(_config: RotatePluginConfig): Promise<void> {\n this.logger.info('RotatePlugin', 'Initialize', 'Rotate plugin initialized');\n }\n\n async destroy(): Promise<void> {\n this.rotate$.clear();\n super.destroy();\n }\n}\n","import { Reducer } from '@embedpdf/core';\nimport {\n RotateAction,\n INIT_ROTATE_STATE,\n CLEANUP_ROTATE_STATE,\n SET_ACTIVE_ROTATE_DOCUMENT,\n SET_ROTATION,\n} from './actions';\nimport { RotateState, RotateDocumentState } from './types';\n\nexport const initialDocumentState: RotateDocumentState = {\n rotation: 0,\n};\n\nexport const initialState: RotateState = {\n documents: {},\n activeDocumentId: null,\n};\n\nexport const rotateReducer: Reducer<RotateState, RotateAction> = (state = initialState, action) => {\n switch (action.type) {\n case INIT_ROTATE_STATE: {\n const { documentId, state: docState } = action.payload;\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: docState,\n },\n // Set as active if no active document\n activeDocumentId: state.activeDocumentId ?? documentId,\n };\n }\n\n case CLEANUP_ROTATE_STATE: {\n const documentId = action.payload;\n const { [documentId]: removed, ...remainingDocs } = state.documents;\n return {\n ...state,\n documents: remainingDocs,\n activeDocumentId: state.activeDocumentId === documentId ? null : state.activeDocumentId,\n };\n }\n\n case SET_ACTIVE_ROTATE_DOCUMENT: {\n return {\n ...state,\n activeDocumentId: action.payload,\n };\n }\n\n case SET_ROTATION: {\n const { documentId, rotation } = action.payload;\n const docState = state.documents[documentId];\n if (!docState) return state;\n\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n rotation,\n },\n },\n };\n }\n\n default:\n return state;\n }\n};\n","import { PluginPackage } from '@embedpdf/core';\nimport { manifest, ROTATE_PLUGIN_ID } from './manifest';\nimport { RotatePluginConfig, RotateState } from './types';\nimport { RotatePlugin } from './rotate-plugin';\nimport { RotateAction } from './actions';\nimport { rotateReducer, initialState } from './reducer';\n\nexport const RotatePluginPackage: PluginPackage<\n RotatePlugin,\n RotatePluginConfig,\n RotateState,\n RotateAction\n> = {\n manifest,\n create: (registry, config) => new RotatePlugin(ROTATE_PLUGIN_ID, registry, config),\n reducer: rotateReducer,\n initialState,\n};\n\nexport * from './rotate-plugin';\nexport * from './types';\nexport * from './manifest';\nexport * from './actions';\nexport * from './reducer';\nexport * from './utils';\n"],"names":["ROTATE_PLUGIN_ID","manifest","id","name","version","provides","requires","optional","defaultConfig","getRotationMatrix","rotation","w","h","a","b","c","d","e","f","getRotationMatrixString","getNextRotation","current","getPreviousRotation","INIT_ROTATE_STATE","CLEANUP_ROTATE_STATE","SET_ACTIVE_ROTATE_DOCUMENT","SET_ROTATION","initRotateState","documentId","state","type","payload","cleanupRotateState","setRotation","_RotatePlugin","BasePlugin","constructor","registry","cfg","super","this","rotate$","createBehaviorEmitter","defaultRotation","onDocumentLoadingStarted","docState","dispatch","dispatchCoreAction","setCoreRotation","logger","debug","onDocumentClosed","buildCapability","setRotationForDocument","getRotation","getRotationForDocument","rotateForward","rotateBackward","forDocument","createRotateScope","onRotateChange","on","listener","event","getDocumentState","getActiveDocumentId","documents","getDocumentStateOrThrow","Error","coreDoc","coreState","core","document","emit","nextRotation","prevRotation","getMatrixAsString","options","width","height","onStoreUpdated","prevState","newState","prevDoc","newDoc","initialize","_config","info","destroy","clear","RotatePlugin","initialState","activeDocumentId","rotateReducer","action","removed","remainingDocs","RotatePluginPackage","create","config","reducer"],"mappings":"kHAGaA,EAAmB,SAEnBC,EAA+C,CAC1DC,GAAIF,EACJG,KAAM,gBACNC,QAAS,QACTC,SAAU,CAAC,UACXC,SAAU,GACVC,SAAU,GACVC,cAAe,CAAA,GCCV,SAASC,EACdC,EACAC,EACAC,GAEA,IAAIC,EAAI,EACNC,EAAI,EACJC,EAAI,EACJC,EAAI,EACJC,EAAI,EACJC,EAAI,EAEN,OAAQR,GACN,KAAK,EACHG,EAAI,EACJC,EAAI,EACJC,GAAI,EACJC,EAAI,EACJC,EAAIL,EACJ,MACF,KAAK,EACHC,GAAI,EACJC,EAAI,EACJ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BAAoBhE,EAEhD,CAEA,KAAKJ,EAAsB,CACzB,MAAMI,EAAakE,EAAO/D,SAClBH,CAACA,GAAamE,KAAYC,GAAkBnE,EAAMqC,UAC1D,MAAO,IACFrC,EACHqC,UAAW8B,EACXJ,iBAAkB/D,EAAM+D,mBAAqBhE,EAAa,KAAOC,EAAM+D,iBAE3E,CAEA,KAAKnE,EACH,MAAO,IACFI,EACH+D,iBAAkBE,EAAO/D,SAI7B,KAAKL,EAAc,CACjB,MAAME,WAAEA,EAAAlB,SAAYA,GAAaoF,EAAO/D,QAClCc,EAAWhB,EAAMqC,UAAUtC,GACjC,OAAKiB,EAEE,IACFhB,EACHqC,UAAW,IACNrC,EAAMqC,UACTtC,CAACA,GAAa,IACTiB,EACHnC,cARgBmB,CAYxB,CAEA,QACE,OAAOA,IC9DAoE,EAKT,CACFhG,WACAiG,OAAQ,CAAC7D,EAAU8D,IAAW,IAAIT,EAAa1F,EAAkBqC,EAAU8D,GAC3EC,QAASP,EACTF,iaDNuD,CACvDjF,SAAU,qGF8CL,SAAiCkB,GACtC,MAAO,CAAEE,KAAML,EAA4BM,QAASH,EACtD"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/lib/manifest.ts","../src/lib/utils.ts","../src/lib/actions.ts","../src/lib/rotate-plugin.ts","../src/lib/reducer.ts","../src/lib/index.ts"],"sourcesContent":["import { PluginManifest } from '@embedpdf/core';\nimport { RotatePluginConfig } from './types';\n\nexport const ROTATE_PLUGIN_ID = 'rotate';\n\nexport const manifest: PluginManifest<RotatePluginConfig> = {\n id: ROTATE_PLUGIN_ID,\n name: 'Rotate Plugin',\n version: '1.0.0',\n provides: ['rotate'],\n requires: [],\n optional: [],\n defaultConfig: {\n enabled: true,\n },\n};\n","import { Rotation } from '@embedpdf/models';\n\n/**\n * Returns the 6-tuple transformation matrix for rotation.\n * Rotation is clockwise, origin = top-left (0 0).\n *\n * ── Note on e,f ───────────────────────────────\n * For 0°/180° no translation is needed.\n * For 90°/270° you may want to pass the page\n * height / width so the page stays in positive\n * coordinates. Keep them 0 and handle layout\n * elsewhere if that's what you do today.\n */\nexport function getRotationMatrix(\n rotation: Rotation,\n w: number,\n h: number,\n): [number, number, number, number, number, number] {\n let a = 1,\n b = 0,\n c = 0,\n d = 1,\n e = 0,\n f = 0;\n\n switch (rotation) {\n case 1: // 90°\n a = 0;\n b = 1;\n c = -1;\n d = 0;\n e = h;\n break;\n case 2: // 180°\n a = -1;\n b = 0;\n c = 0;\n d = -1;\n e = w;\n f = h;\n break;\n case 3: // 270°\n a = 0;\n b = -1;\n c = 1;\n d = 0;\n f = w;\n break;\n }\n\n return [a, b, c, d, e, f];\n}\n\n/**\n * Returns the CSS matrix transformation string for rotation.\n * Rotation is clockwise, origin = top-left (0 0).\n */\nexport function getRotationMatrixString(rotation: Rotation, w: number, h: number): string {\n const [a, b, c, d, e, f] = getRotationMatrix(rotation, w, h);\n return `matrix(${a},${b},${c},${d},${e},${f})`;\n}\n\n/**\n * Returns the next rotation.\n */\nexport function getNextRotation(current: Rotation): Rotation {\n return ((current + 1) % 4) as Rotation;\n}\n\n/**\n * Returns the previous rotation.\n */\nexport function getPreviousRotation(current: Rotation): Rotation {\n return ((current + 3) % 4) as Rotation; // +3 is equivalent to -1 in modulo 4\n}\n","import { Action } from '@embedpdf/core';\nimport { Rotation } from '@embedpdf/models';\nimport { RotateDocumentState } from './types';\n\n// Document lifecycle\nexport const INIT_ROTATE_STATE = 'ROTATE/INIT_STATE';\nexport const CLEANUP_ROTATE_STATE = 'ROTATE/CLEANUP_STATE';\nexport const SET_ACTIVE_ROTATE_DOCUMENT = 'ROTATE/SET_ACTIVE_DOCUMENT';\n\n// Rotation operations\nexport const SET_ROTATION = 'ROTATE/SET_ROTATION';\n\n// Document lifecycle actions\nexport interface InitRotateStateAction extends Action {\n type: typeof INIT_ROTATE_STATE;\n payload: {\n documentId: string;\n state: RotateDocumentState;\n };\n}\n\nexport interface CleanupRotateStateAction extends Action {\n type: typeof CLEANUP_ROTATE_STATE;\n payload: string; // documentId\n}\n\nexport interface SetActiveRotateDocumentAction extends Action {\n type: typeof SET_ACTIVE_ROTATE_DOCUMENT;\n payload: string | null; // documentId\n}\n\nexport interface SetRotationAction extends Action {\n type: typeof SET_ROTATION;\n payload: {\n documentId: string;\n rotation: Rotation;\n };\n}\n\nexport type RotateAction =\n | InitRotateStateAction\n | CleanupRotateStateAction\n | SetActiveRotateDocumentAction\n | SetRotationAction;\n\n// Action Creators\nexport function initRotateState(\n documentId: string,\n state: RotateDocumentState,\n): InitRotateStateAction {\n return { type: INIT_ROTATE_STATE, payload: { documentId, state } };\n}\n\nexport function cleanupRotateState(documentId: string): CleanupRotateStateAction {\n return { type: CLEANUP_ROTATE_STATE, payload: documentId };\n}\n\nexport function setActiveRotateDocument(documentId: string | null): SetActiveRotateDocumentAction {\n return { type: SET_ACTIVE_ROTATE_DOCUMENT, payload: documentId };\n}\n\nexport function setRotation(documentId: string, rotation: Rotation): SetRotationAction {\n return { type: SET_ROTATION, payload: { documentId, rotation } };\n}\n","import {\n BasePlugin,\n createBehaviorEmitter,\n Listener,\n PluginRegistry,\n setRotation as setCoreRotation,\n} from '@embedpdf/core';\nimport { Rotation } from '@embedpdf/models';\nimport {\n GetMatrixOptions,\n RotateCapability,\n RotatePluginConfig,\n RotateScope,\n RotationChangeEvent,\n RotateState,\n RotateDocumentState,\n} from './types';\nimport { getNextRotation, getPreviousRotation, getRotationMatrixString } from './utils';\nimport { initRotateState, cleanupRotateState, setRotation, RotateAction } from './actions';\n\nexport class RotatePlugin extends BasePlugin<\n RotatePluginConfig,\n RotateCapability,\n RotateState,\n RotateAction\n> {\n static readonly id = 'rotate' as const;\n\n private readonly rotate$ = createBehaviorEmitter<RotationChangeEvent>();\n private readonly defaultRotation: Rotation;\n\n constructor(id: string, registry: PluginRegistry, cfg: RotatePluginConfig) {\n super(id, registry);\n this.defaultRotation = cfg.defaultRotation ?? 0;\n }\n\n // ─────────────────────────────────────────────────────────\n // Document Lifecycle Hooks (from BasePlugin)\n // ─────────────────────────────────────────────────────────\n\n protected override onDocumentLoadingStarted(documentId: string): void {\n // Initialize rotation state for this document\n const docState: RotateDocumentState = {\n rotation: this.defaultRotation,\n };\n\n this.dispatch(initRotateState(documentId, docState));\n\n // Also set in core state for backwards compatibility\n this.dispatchCoreAction(setCoreRotation(this.defaultRotation, documentId));\n\n this.logger.debug(\n 'RotatePlugin',\n 'DocumentOpened',\n `Initialized rotation state for document: ${documentId}`,\n );\n }\n\n protected override onDocumentClosed(documentId: string): void {\n this.dispatch(cleanupRotateState(documentId));\n\n this.logger.debug(\n 'RotatePlugin',\n 'DocumentClosed',\n `Cleaned up rotation state for document: ${documentId}`,\n );\n }\n\n // ─────────────────────────────────────────────────────────\n // Capability\n // ─────────────────────────────────────────────────────────\n\n protected buildCapability(): RotateCapability {\n return {\n // Active document operations\n setRotation: (rotation: Rotation) => this.setRotationForDocument(rotation),\n getRotation: () => this.getRotationForDocument(),\n rotateForward: () => this.rotateForward(),\n rotateBackward: () => this.rotateBackward(),\n\n // Document-scoped operations\n forDocument: (documentId: string) => this.createRotateScope(documentId),\n\n // Events\n onRotateChange: this.rotate$.on,\n };\n }\n\n // ─────────────────────────────────────────────────────────\n // Document Scoping\n // ─────────────────────────────────────────────────────────\n\n private createRotateScope(documentId: string): RotateScope {\n return {\n setRotation: (rotation: Rotation) => this.setRotationForDocument(rotation, documentId),\n getRotation: () => this.getRotationForDocument(documentId),\n rotateForward: () => this.rotateForward(documentId),\n rotateBackward: () => this.rotateBackward(documentId),\n onRotateChange: (listener: Listener<Rotation>) =>\n this.rotate$.on((event) => {\n if (event.documentId === documentId) listener(event.rotation);\n }),\n };\n }\n\n // ─────────────────────────────────────────────────────────\n // State Helpers\n // ─────────────────────────────────────────────────────────\n private getDocumentState(documentId?: string): RotateDocumentState | null {\n const id = documentId ?? this.getActiveDocumentId();\n return this.state.documents[id] ?? null;\n }\n\n private getDocumentStateOrThrow(documentId?: string): RotateDocumentState {\n const state = this.getDocumentState(documentId);\n if (!state) {\n throw new Error(`Rotation state not found for document: ${documentId ?? 'active'}`);\n }\n return state;\n }\n\n // ─────────────────────────────────────────────────────────\n // Core Operations\n // ─────────────────────────────────────────────────────────\n\n private setRotationForDocument(rotation: Rotation, documentId?: string): void {\n const id = documentId ?? this.getActiveDocumentId();\n const coreDoc = this.coreState.core.documents[id];\n\n if (!coreDoc?.document) {\n throw new Error(`Document ${id} not loaded`);\n }\n\n // Update plugin state\n this.dispatch(setRotation(id, rotation));\n\n // Update core state for backwards compatibility\n this.dispatchCoreAction(setCoreRotation(rotation, id));\n\n // Emit event\n this.rotate$.emit({\n documentId: id,\n rotation,\n });\n }\n\n private getRotationForDocument(documentId?: string): Rotation {\n return this.getDocumentStateOrThrow(documentId).rotation;\n }\n\n private rotateForward(documentId?: string): void {\n const id = documentId ?? this.getActiveDocumentId();\n const currentRotation = this.getRotationForDocument(id);\n const nextRotation = getNextRotation(currentRotation);\n this.setRotationForDocument(nextRotation, id);\n }\n\n private rotateBackward(documentId?: string): void {\n const id = documentId ?? this.getActiveDocumentId();\n const currentRotation = this.getRotationForDocument(id);\n const prevRotation = getPreviousRotation(currentRotation);\n this.setRotationForDocument(prevRotation, id);\n }\n\n public getMatrixAsString(options: GetMatrixOptions): string {\n return getRotationMatrixString(options.rotation, options.width, options.height);\n }\n\n // ─────────────────────────────────────────────────────────\n // Store Update Handlers\n // ─────────────────────────────────────────────────────────\n\n override onStoreUpdated(prevState: RotateState, newState: RotateState): void {\n // Emit rotation change events for each changed document\n for (const documentId in newState.documents) {\n const prevDoc = prevState.documents[documentId];\n const newDoc = newState.documents[documentId];\n\n if (prevDoc?.rotation !== newDoc.rotation) {\n this.logger.debug(\n 'RotatePlugin',\n 'RotationChanged',\n `Rotation changed for document ${documentId}: ${prevDoc?.rotation ?? 0} -> ${newDoc.rotation}`,\n );\n }\n }\n }\n\n // ─────────────────────────────────────────────────────────\n // Lifecycle\n // ─────────────────────────────────────────────────────────\n\n async initialize(_config: RotatePluginConfig): Promise<void> {\n this.logger.info('RotatePlugin', 'Initialize', 'Rotate plugin initialized');\n }\n\n async destroy(): Promise<void> {\n this.rotate$.clear();\n super.destroy();\n }\n}\n","import { Reducer } from '@embedpdf/core';\nimport {\n RotateAction,\n INIT_ROTATE_STATE,\n CLEANUP_ROTATE_STATE,\n SET_ACTIVE_ROTATE_DOCUMENT,\n SET_ROTATION,\n} from './actions';\nimport { RotateState, RotateDocumentState } from './types';\n\nexport const initialDocumentState: RotateDocumentState = {\n rotation: 0,\n};\n\nexport const initialState: RotateState = {\n documents: {},\n activeDocumentId: null,\n};\n\nexport const rotateReducer: Reducer<RotateState, RotateAction> = (state = initialState, action) => {\n switch (action.type) {\n case INIT_ROTATE_STATE: {\n const { documentId, state: docState } = action.payload;\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: docState,\n },\n // Set as active if no active document\n activeDocumentId: state.activeDocumentId ?? documentId,\n };\n }\n\n case CLEANUP_ROTATE_STATE: {\n const documentId = action.payload;\n const { [documentId]: removed, ...remainingDocs } = state.documents;\n return {\n ...state,\n documents: remainingDocs,\n activeDocumentId: state.activeDocumentId === documentId ? null : state.activeDocumentId,\n };\n }\n\n case SET_ACTIVE_ROTATE_DOCUMENT: {\n return {\n ...state,\n activeDocumentId: action.payload,\n };\n }\n\n case SET_ROTATION: {\n const { documentId, rotation } = action.payload;\n const docState = state.documents[documentId];\n if (!docState) return state;\n\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n rotation,\n },\n },\n };\n }\n\n default:\n return state;\n }\n};\n","import { PluginPackage } from '@embedpdf/core';\nimport { manifest, ROTATE_PLUGIN_ID } from './manifest';\nimport { RotatePluginConfig, RotateState } from './types';\nimport { RotatePlugin } from './rotate-plugin';\nimport { RotateAction } from './actions';\nimport { rotateReducer, initialState } from './reducer';\n\nexport const RotatePluginPackage: PluginPackage<\n RotatePlugin,\n RotatePluginConfig,\n RotateState,\n RotateAction\n> = {\n manifest,\n create: (registry, config) => new RotatePlugin(ROTATE_PLUGIN_ID, registry, config),\n reducer: rotateReducer,\n initialState,\n};\n\nexport * from './rotate-plugin';\nexport * from './types';\nexport * from './manifest';\nexport * from './actions';\nexport * from './reducer';\nexport * from './utils';\n"],"names":["setCoreRotation"],"mappings":";AAGO,MAAM,mBAAmB;AAEzB,MAAM,WAA+C;AAAA,EAC1D,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU,CAAC,QAAQ;AAAA,EACnB,UAAU,CAAA;AAAA,EACV,UAAU,CAAA;AAAA,EACV,eAAe;AAAA,IACb,SAAS;AAAA,EAAA;AAEb;ACFO,SAAS,kBACd,UACA,GACA,GACkD;AAClD,MAAI,IAAI,GACN,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI;AAEN,UAAQ,UAAA;AAAA,IACN,KAAK;AACH,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ;AAAA,IACF,KAAK;AACH,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ;AAAA,IACF,KAAK;AACH,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ;AAAA,EAAA;AAGJ,SAAO,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAC1B;AAMO,SAAS,wBAAwB,UAAoB,GAAW,GAAmB;AACxF,QAAM,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,IAAI,kBAAkB,UAAU,GAAG,CAAC;AAC3D,SAAO,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AAC7C;AAKO,SAAS,gBAAgB,SAA6B;AAC3D,UAAS,UAAU,KAAK;AAC1B;AAKO,SAAS,oBAAoB,SAA6B;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AkB,UAAU,MAAM;AAAA,EACjF,SAAS;AAAA,EACT;AACF;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/lib/manifest.ts","../src/lib/utils.ts","../src/lib/actions.ts","../src/lib/rotate-plugin.ts","../src/lib/reducer.ts","../src/lib/index.ts"],"sourcesContent":["import { PluginManifest } from '@embedpdf/core';\nimport { RotatePluginConfig } from './types';\n\nexport const ROTATE_PLUGIN_ID = 'rotate';\n\nexport const manifest: PluginManifest<RotatePluginConfig> = {\n id: ROTATE_PLUGIN_ID,\n name: 'Rotate Plugin',\n version: '1.0.0',\n provides: ['rotate'],\n requires: [],\n optional: [],\n defaultConfig: {},\n};\n","import { Rotation } from '@embedpdf/models';\n\n/**\n * Returns the 6-tuple transformation matrix for rotation.\n * Rotation is clockwise, origin = top-left (0 0).\n *\n * ── Note on e,f ───────────────────────────────\n * For 0°/180° no translation is needed.\n * For 90°/270° you may want to pass the page\n * height / width so the page stays in positive\n * coordinates. Keep them 0 and handle layout\n * elsewhere if that's what you do today.\n */\nexport function getRotationMatrix(\n rotation: Rotation,\n w: number,\n h: number,\n): [number, number, number, number, number, number] {\n let a = 1,\n b = 0,\n c = 0,\n d = 1,\n e = 0,\n f = 0;\n\n switch (rotation) {\n case 1: // 90°\n a = 0;\n b = 1;\n c = -1;\n d = 0;\n e = h;\n break;\n case 2: // 180°\n a = -1;\n b = 0;\n c = 0;\n d = -1;\n e = w;\n f = h;\n break;\n case 3: // 270°\n a = 0;\n b = -1;\n c = 1;\n d = 0;\n f = w;\n break;\n }\n\n return [a, b, c, d, e, f];\n}\n\n/**\n * Returns the CSS matrix transformation string for rotation.\n * Rotation is clockwise, origin = top-left (0 0).\n */\nexport function getRotationMatrixString(rotation: Rotation, w: number, h: number): string {\n const [a, b, c, d, e, f] = getRotationMatrix(rotation, w, h);\n return `matrix(${a},${b},${c},${d},${e},${f})`;\n}\n\n/**\n * Returns the next rotation.\n */\nexport function getNextRotation(current: Rotation): Rotation {\n return ((current + 1) % 4) as Rotation;\n}\n\n/**\n * Returns the previous rotation.\n */\nexport function getPreviousRotation(current: Rotation): Rotation {\n return ((current + 3) % 4) as Rotation; // +3 is equivalent to -1 in modulo 4\n}\n","import { Action } from '@embedpdf/core';\nimport { Rotation } from '@embedpdf/models';\nimport { RotateDocumentState } from './types';\n\n// Document lifecycle\nexport const INIT_ROTATE_STATE = 'ROTATE/INIT_STATE';\nexport const CLEANUP_ROTATE_STATE = 'ROTATE/CLEANUP_STATE';\nexport const SET_ACTIVE_ROTATE_DOCUMENT = 'ROTATE/SET_ACTIVE_DOCUMENT';\n\n// Rotation operations\nexport const SET_ROTATION = 'ROTATE/SET_ROTATION';\n\n// Document lifecycle actions\nexport interface InitRotateStateAction extends Action {\n type: typeof INIT_ROTATE_STATE;\n payload: {\n documentId: string;\n state: RotateDocumentState;\n };\n}\n\nexport interface CleanupRotateStateAction extends Action {\n type: typeof CLEANUP_ROTATE_STATE;\n payload: string; // documentId\n}\n\nexport interface SetActiveRotateDocumentAction extends Action {\n type: typeof SET_ACTIVE_ROTATE_DOCUMENT;\n payload: string | null; // documentId\n}\n\nexport interface SetRotationAction extends Action {\n type: typeof SET_ROTATION;\n payload: {\n documentId: string;\n rotation: Rotation;\n };\n}\n\nexport type RotateAction =\n | InitRotateStateAction\n | CleanupRotateStateAction\n | SetActiveRotateDocumentAction\n | SetRotationAction;\n\n// Action Creators\nexport function initRotateState(\n documentId: string,\n state: RotateDocumentState,\n): InitRotateStateAction {\n return { type: INIT_ROTATE_STATE, payload: { documentId, state } };\n}\n\nexport function cleanupRotateState(documentId: string): CleanupRotateStateAction {\n return { type: CLEANUP_ROTATE_STATE, payload: documentId };\n}\n\nexport function setActiveRotateDocument(documentId: string | null): SetActiveRotateDocumentAction {\n return { type: SET_ACTIVE_ROTATE_DOCUMENT, payload: documentId };\n}\n\nexport function setRotation(documentId: string, rotation: Rotation): SetRotationAction {\n return { type: SET_ROTATION, payload: { documentId, rotation } };\n}\n","import {\n BasePlugin,\n createBehaviorEmitter,\n Listener,\n PluginRegistry,\n setRotation as setCoreRotation,\n} from '@embedpdf/core';\nimport { Rotation } from '@embedpdf/models';\nimport {\n GetMatrixOptions,\n RotateCapability,\n RotatePluginConfig,\n RotateScope,\n RotationChangeEvent,\n RotateState,\n RotateDocumentState,\n} from './types';\nimport { getNextRotation, getPreviousRotation, getRotationMatrixString } from './utils';\nimport { initRotateState, cleanupRotateState, setRotation, RotateAction } from './actions';\n\nexport class RotatePlugin extends BasePlugin<\n RotatePluginConfig,\n RotateCapability,\n RotateState,\n RotateAction\n> {\n static readonly id = 'rotate' as const;\n\n private readonly rotate$ = createBehaviorEmitter<RotationChangeEvent>();\n private readonly defaultRotation: Rotation;\n\n constructor(id: string, registry: PluginRegistry, cfg: RotatePluginConfig) {\n super(id, registry);\n this.defaultRotation = cfg.defaultRotation ?? 0;\n }\n\n // ─────────────────────────────────────────────────────────\n // Document Lifecycle Hooks (from BasePlugin)\n // ─────────────────────────────────────────────────────────\n\n protected override onDocumentLoadingStarted(documentId: string): void {\n // Initialize rotation state for this document\n const docState: RotateDocumentState = {\n rotation: this.defaultRotation,\n };\n\n this.dispatch(initRotateState(documentId, docState));\n\n // Also set in core state for backwards compatibility\n this.dispatchCoreAction(setCoreRotation(this.defaultRotation, documentId));\n\n this.logger.debug(\n 'RotatePlugin',\n 'DocumentOpened',\n `Initialized rotation state for document: ${documentId}`,\n );\n }\n\n protected override onDocumentClosed(documentId: string): void {\n this.dispatch(cleanupRotateState(documentId));\n\n this.logger.debug(\n 'RotatePlugin',\n 'DocumentClosed',\n `Cleaned up rotation state for document: ${documentId}`,\n );\n }\n\n // ─────────────────────────────────────────────────────────\n // Capability\n // ─────────────────────────────────────────────────────────\n\n protected buildCapability(): RotateCapability {\n return {\n // Active document operations\n setRotation: (rotation: Rotation) => this.setRotationForDocument(rotation),\n getRotation: () => this.getRotationForDocument(),\n rotateForward: () => this.rotateForward(),\n rotateBackward: () => this.rotateBackward(),\n\n // Document-scoped operations\n forDocument: (documentId: string) => this.createRotateScope(documentId),\n\n // Events\n onRotateChange: this.rotate$.on,\n };\n }\n\n // ─────────────────────────────────────────────────────────\n // Document Scoping\n // ─────────────────────────────────────────────────────────\n\n private createRotateScope(documentId: string): RotateScope {\n return {\n setRotation: (rotation: Rotation) => this.setRotationForDocument(rotation, documentId),\n getRotation: () => this.getRotationForDocument(documentId),\n rotateForward: () => this.rotateForward(documentId),\n rotateBackward: () => this.rotateBackward(documentId),\n onRotateChange: (listener: Listener<Rotation>) =>\n this.rotate$.on((event) => {\n if (event.documentId === documentId) listener(event.rotation);\n }),\n };\n }\n\n // ─────────────────────────────────────────────────────────\n // State Helpers\n // ─────────────────────────────────────────────────────────\n private getDocumentState(documentId?: string): RotateDocumentState | null {\n const id = documentId ?? this.getActiveDocumentId();\n return this.state.documents[id] ?? null;\n }\n\n private getDocumentStateOrThrow(documentId?: string): RotateDocumentState {\n const state = this.getDocumentState(documentId);\n if (!state) {\n throw new Error(`Rotation state not found for document: ${documentId ?? 'active'}`);\n }\n return state;\n }\n\n // ─────────────────────────────────────────────────────────\n // Core Operations\n // ─────────────────────────────────────────────────────────\n\n private setRotationForDocument(rotation: Rotation, documentId?: string): void {\n const id = documentId ?? this.getActiveDocumentId();\n const coreDoc = this.coreState.core.documents[id];\n\n if (!coreDoc?.document) {\n throw new Error(`Document ${id} not loaded`);\n }\n\n // Update plugin state\n this.dispatch(setRotation(id, rotation));\n\n // Update core state for backwards compatibility\n this.dispatchCoreAction(setCoreRotation(rotation, id));\n\n // Emit event\n this.rotate$.emit({\n documentId: id,\n rotation,\n });\n }\n\n private getRotationForDocument(documentId?: string): Rotation {\n return this.getDocumentStateOrThrow(documentId).rotation;\n }\n\n private rotateForward(documentId?: string): void {\n const id = documentId ?? this.getActiveDocumentId();\n const currentRotation = this.getRotationForDocument(id);\n const nextRotation = getNextRotation(currentRotation);\n this.setRotationForDocument(nextRotation, id);\n }\n\n private rotateBackward(documentId?: string): void {\n const id = documentId ?? this.getActiveDocumentId();\n const currentRotation = this.getRotationForDocument(id);\n const prevRotation = getPreviousRotation(currentRotation);\n this.setRotationForDocument(prevRotation, id);\n }\n\n public getMatrixAsString(options: GetMatrixOptions): string {\n return getRotationMatrixString(options.rotation, options.width, options.height);\n }\n\n // ─────────────────────────────────────────────────────────\n // Store Update Handlers\n // ─────────────────────────────────────────────────────────\n\n override onStoreUpdated(prevState: RotateState, newState: RotateState): void {\n // Emit rotation change events for each changed document\n for (const documentId in newState.documents) {\n const prevDoc = prevState.documents[documentId];\n const newDoc = newState.documents[documentId];\n\n if (prevDoc?.rotation !== newDoc.rotation) {\n this.logger.debug(\n 'RotatePlugin',\n 'RotationChanged',\n `Rotation changed for document ${documentId}: ${prevDoc?.rotation ?? 0} -> ${newDoc.rotation}`,\n );\n }\n }\n }\n\n // ─────────────────────────────────────────────────────────\n // Lifecycle\n // ─────────────────────────────────────────────────────────\n\n async initialize(_config: RotatePluginConfig): Promise<void> {\n this.logger.info('RotatePlugin', 'Initialize', 'Rotate plugin initialized');\n }\n\n async destroy(): Promise<void> {\n this.rotate$.clear();\n super.destroy();\n }\n}\n","import { Reducer } from '@embedpdf/core';\nimport {\n RotateAction,\n INIT_ROTATE_STATE,\n CLEANUP_ROTATE_STATE,\n SET_ACTIVE_ROTATE_DOCUMENT,\n SET_ROTATION,\n} from './actions';\nimport { RotateState, RotateDocumentState } from './types';\n\nexport const initialDocumentState: RotateDocumentState = {\n rotation: 0,\n};\n\nexport const initialState: RotateState = {\n documents: {},\n activeDocumentId: null,\n};\n\nexport const rotateReducer: Reducer<RotateState, RotateAction> = (state = initialState, action) => {\n switch (action.type) {\n case INIT_ROTATE_STATE: {\n const { documentId, state: docState } = action.payload;\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: docState,\n },\n // Set as active if no active document\n activeDocumentId: state.activeDocumentId ?? documentId,\n };\n }\n\n case CLEANUP_ROTATE_STATE: {\n const documentId = action.payload;\n const { [documentId]: removed, ...remainingDocs } = state.documents;\n return {\n ...state,\n documents: remainingDocs,\n activeDocumentId: state.activeDocumentId === documentId ? null : state.activeDocumentId,\n };\n }\n\n case SET_ACTIVE_ROTATE_DOCUMENT: {\n return {\n ...state,\n activeDocumentId: action.payload,\n };\n }\n\n case SET_ROTATION: {\n const { documentId, rotation } = action.payload;\n const docState = state.documents[documentId];\n if (!docState) return state;\n\n return {\n ...state,\n documents: {\n ...state.documents,\n [documentId]: {\n ...docState,\n rotation,\n },\n },\n };\n }\n\n default:\n return state;\n }\n};\n","import { PluginPackage } from '@embedpdf/core';\nimport { manifest, ROTATE_PLUGIN_ID } from './manifest';\nimport { RotatePluginConfig, RotateState } from './types';\nimport { RotatePlugin } from './rotate-plugin';\nimport { RotateAction } from './actions';\nimport { rotateReducer, initialState } from './reducer';\n\nexport const RotatePluginPackage: PluginPackage<\n RotatePlugin,\n RotatePluginConfig,\n RotateState,\n RotateAction\n> = {\n manifest,\n create: (registry, config) => new RotatePlugin(ROTATE_PLUGIN_ID, registry, config),\n reducer: rotateReducer,\n initialState,\n};\n\nexport * from './rotate-plugin';\nexport * from './types';\nexport * from './manifest';\nexport * from './actions';\nexport * from './reducer';\nexport * from './utils';\n"],"names":["setCoreRotation"],"mappings":";AAGO,MAAM,mBAAmB;AAEzB,MAAM,WAA+C;AAAA,EAC1D,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU,CAAC,QAAQ;AAAA,EACnB,UAAU,CAAA;AAAA,EACV,UAAU,CAAA;AAAA,EACV,eAAe,CAAA;AACjB;ACAO,SAAS,kBACd,UACA,GACA,GACkD;AAClD,MAAI,IAAI,GACN,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI;AAEN,UAAQ,UAAA;AAAA,IACN,KAAK;AACH,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ;AAAA,IACF,KAAK;AACH,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ,UAAI;AACJ,UA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AAG;AAAA,QACH,kBAAkB,OAAO;AAAA,MAAA;AAAA,IAE7B;AAAA,IAEA,KAAK,cAAc;AACjB,YAAM,EAAE,YAAY,SAAA,IAAa,OAAO;AACxC,YAAM,WAAW,MAAM,UAAU,UAAU;AAC3C,UAAI,CAAC,SAAU,QAAO;AAEtB,aAAO;AAAA,QACL,GAAG;AAAA,QACH,WAAW;AAAA,UACT,GAAG,MAAM;AAAA,UACT,CAAC,UAAU,GAAG;AAAA,YACZ,GAAG;AAAA,YACH;AAAA,UAAA;AAAA,QACF;AAAA,MACF;AAAA,IAEJ;AAAA,IAEA;AACE,aAAO;AAAA,EAAA;AAEb;AChEO,MAAM,sBAKT;AAAA,EACF;AAAA,EACA,QAAQ,CAAC,UAAU,WAAW,IAAI,aAAa,kBAAkB,UAAU,MAAM;AAAA,EACjF,SAAS;AAAA,EACT;AACF;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/plugin-rotate",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@embedpdf/models": "2.0.0-next.
|
|
37
|
+
"@embedpdf/models": "2.0.0-next.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/react": "^18.2.0",
|
|
41
41
|
"typescript": "^5.0.0",
|
|
42
42
|
"@embedpdf/build": "1.1.0",
|
|
43
|
-
"@embedpdf/core": "2.0.0-next.
|
|
43
|
+
"@embedpdf/core": "2.0.0-next.3"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"preact": "^10.26.4",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"react-dom": ">=16.8.0",
|
|
49
49
|
"vue": ">=3.2.0",
|
|
50
50
|
"svelte": ">=5 <6",
|
|
51
|
-
"@embedpdf/core": "2.0.0-next.
|
|
51
|
+
"@embedpdf/core": "2.0.0-next.3"
|
|
52
52
|
},
|
|
53
53
|
"files": [
|
|
54
54
|
"dist",
|