14 lines
544 B
TypeScript
14 lines
544 B
TypeScript
import { randomUUID } from 'node:crypto'
|
|
|
|
// Keep print content in memory. The renderer receives a short local URL even when stamps are large.
|
|
export class PrintDocumentStore {
|
|
private documents=new Map<string,string>()
|
|
publish(html:string):{url:string;dispose:()=>void}{
|
|
const url='receipt://print/'+randomUUID()+'/index.html'
|
|
this.documents.set(url,html)
|
|
return {url,dispose:()=>{this.documents.delete(url)}}
|
|
}
|
|
read(url:string):string|undefined{return this.documents.get(url)}
|
|
}
|
|
export const printDocuments=new PrintDocumentStore()
|