@w100n/documents 0.12.0 → 0.13.0

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.
Files changed (35) hide show
  1. package/dist/{SheetView-CIHVWANF.js → SheetView-3UAFXGZS.js} +4 -4
  2. package/dist/{TextEditor-OTGUXXRU.js → TextEditor-OLBLWC6F.js} +5 -5
  3. package/dist/{TextEditor-OTGUXXRU.js.map → TextEditor-OLBLWC6F.js.map} +1 -1
  4. package/dist/{chunk-EEYBFQAJ.js → chunk-MRP3EURG.js} +3 -3
  5. package/dist/chunk-MRP3EURG.js.map +1 -0
  6. package/dist/{chunk-RI7SQZIW.js → chunk-T7XCGDE5.js} +2 -2
  7. package/dist/{chunk-BKUFGMEA.js → chunk-WR3MT7KP.js} +40 -4
  8. package/dist/{chunk-BKUFGMEA.js.map → chunk-WR3MT7KP.js.map} +1 -1
  9. package/dist/collab.cjs +40 -4
  10. package/dist/collab.cjs.map +1 -1
  11. package/dist/collab.d.cts +1 -1
  12. package/dist/collab.d.ts +1 -1
  13. package/dist/collab.js +2 -2
  14. package/dist/index.cjs +859 -605
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.css +131 -3
  17. package/dist/index.css.map +1 -1
  18. package/dist/index.d.cts +2 -2
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.js +547 -329
  21. package/dist/index.js.map +1 -1
  22. package/dist/kinds.d.cts +1 -1
  23. package/dist/kinds.d.ts +1 -1
  24. package/dist/memory.cjs +9 -1
  25. package/dist/memory.cjs.map +1 -1
  26. package/dist/memory.d.cts +1 -1
  27. package/dist/memory.d.ts +1 -1
  28. package/dist/memory.js +9 -1
  29. package/dist/memory.js.map +1 -1
  30. package/dist/{types-B5oF25dn.d.cts → types-Er60M5kL.d.cts} +6 -0
  31. package/dist/{types-B5oF25dn.d.ts → types-Er60M5kL.d.ts} +6 -0
  32. package/package.json +7 -3
  33. package/dist/chunk-EEYBFQAJ.js.map +0 -1
  34. /package/dist/{SheetView-CIHVWANF.js.map → SheetView-3UAFXGZS.js.map} +0 -0
  35. /package/dist/{chunk-RI7SQZIW.js.map → chunk-T7XCGDE5.js.map} +0 -0
package/dist/kinds.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { b as DocumentKind } from './types-B5oF25dn.cjs';
1
+ import { b as DocumentKind } from './types-Er60M5kL.cjs';
2
2
 
3
3
  declare const kinds: DocumentKind[];
4
4
  declare function kindOf(name: string, mimeType?: string | null): DocumentKind | null;
package/dist/kinds.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { b as DocumentKind } from './types-B5oF25dn.js';
1
+ import { b as DocumentKind } from './types-Er60M5kL.js';
2
2
 
3
3
  declare const kinds: DocumentKind[];
4
4
  declare function kindOf(name: string, mimeType?: string | null): DocumentKind | null;
package/dist/memory.cjs CHANGED
@@ -143,7 +143,15 @@ function memoryHost({ me, spaces, files, collab }) {
143
143
  const file = find(id);
144
144
  if ((format === "md" ? "markdown" : format) !== kindOf(file.name)) throw new Error("this format needs a converter on the host");
145
145
  return new Blob([encode(file.bytes)], { type: mimes[format] });
146
- }
146
+ },
147
+ ...spaces.length ? {
148
+ createIn: `${spaces[0].name} / Documents`,
149
+ create: async ({ name, bytes }) => {
150
+ const file = { id: `new-${files.length + 1}`, spaceId: spaces[0].id, name, folder: "Documents", bytes, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
151
+ files.push(file);
152
+ return summary(file);
153
+ }
154
+ } : {}
147
155
  };
148
156
  }
149
157
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/memory.ts","../src/kinds.ts"],"sourcesContent":["import { kindOf } from './kinds';\nimport type { Comment, DocumentsHost, Person, Rights, Signature, Space } from './types';\n\ntype Bytes = ArrayBuffer | string;\n\nexport type MemoryFile = {\n id: string;\n spaceId: string;\n name: string;\n folder?: string;\n bytes: Bytes;\n version?: string;\n note?: string;\n updatedAt?: string;\n rights?: Partial<Rights>;\n versions?: { id: string; createdAt: string; bytes: Bytes; note?: string }[];\n signatures?: Signature[];\n comments?: Comment[];\n};\n\nconst mimes = { pdf: 'application/pdf', docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', md: 'text/markdown' };\n\nconst encode = (bytes: Bytes) => typeof bytes === 'string' ? new TextEncoder().encode(bytes).buffer as ArrayBuffer : bytes;\n\nexport function memoryHost({ me, spaces, files, collab }: { me: Person; spaces: Space[]; files: MemoryFile[]; collab?: string }): DocumentsHost {\n const find = (id: string) => {\n const file = files.find(item => item.id === id);\n if (!file) throw new Error('document not found');\n return file;\n };\n const own = (file: MemoryFile, commentId: string) => {\n const found = file.comments?.find(c => c.id === commentId);\n if (!found || found.author.id !== me.id) throw new Error('only the author changes a comment');\n return found;\n };\n const summary = (file: MemoryFile) => ({\n id: file.id, spaceId: file.spaceId, name: file.name, kind: kindOf(file.name)!, size: encode(file.bytes).byteLength,\n updatedAt: file.updatedAt ?? '2026-10-19T09:00:00Z', updatedBy: me, folder: file.folder ?? null,\n });\n const archive = (file: MemoryFile, bytes: Bytes, note?: string) => {\n const versions = [{ id: file.version ?? `v${(file.versions?.length ?? 0) + 1}`, createdAt: file.updatedAt ?? '2026-10-19T09:00:00Z', bytes: file.bytes, note: file.note }, ...(file.versions ?? [])];\n const version = `v${versions.length + 1}`;\n Object.assign(file, { versions, version, bytes, note, updatedAt: new Date().toISOString() });\n return version;\n };\n return {\n me,\n ...(collab ? { collab: { url: `memory:${collab}`, token: async () => me.id } } : {}),\n spaces: async () => spaces,\n documents: async spaceId => files.filter(file => file.spaceId === spaceId && kindOf(file.name)).map(summary),\n document: async id => ({ ...summary(find(id)), rights: { view: true, comment: true, edit: true, ...find(id).rights }, live: !!collab }),\n versions: async id => {\n const file = find(id);\n return [\n { id: file.version ?? 'current', createdAt: summary(file).updatedAt, size: summary(file).size, author: me, note: file.note ?? null, current: true },\n ...(file.versions ?? []).map(v => ({ id: v.id, createdAt: v.createdAt, size: encode(v.bytes).byteLength, author: me, note: v.note ?? null, current: false })),\n ];\n },\n content: async (id, versionId) => {\n const file = find(id);\n const old = versionId && versionId !== 'current' && versionId !== file.version ? file.versions?.find(v => v.id === versionId) : undefined;\n return encode(old ? old.bytes : file.bytes);\n },\n restore: async (id, versionId) => {\n const file = find(id);\n const old = file.versions?.find(v => v.id === versionId);\n if (!old) throw new Error('version not found');\n archive(file, old.bytes);\n },\n save: async (id, bytes, note) => ({ versionId: archive(find(id), bytes, note) }),\n signatures: async id => [...(find(id).signatures ?? [])].reverse(),\n sign: async (id, entry) => {\n const file = find(id);\n const signature = { id: `s${(file.signatures?.length ?? 0) + 1}`, signer: me, signedAt: new Date().toISOString(), ...entry };\n file.signatures = [...(file.signatures ?? []), signature];\n return signature;\n },\n comments: async id => [...(find(id).comments ?? [])],\n comment: async (id, entry) => {\n const file = find(id);\n let n = (file.comments?.length ?? 0) + 1;\n while (file.comments?.some(c => c.id === `c${n}`)) n++;\n const made: Comment = { id: `c${n}`, documentId: id, author: me, body: entry.body, createdAt: new Date().toISOString(), quote: entry.quote, replyTo: entry.replyTo, resolved: false };\n file.comments = [...(file.comments ?? []), made];\n return made;\n },\n resolveComment: async (id, commentId, resolved) => {\n const file = find(id);\n file.comments = (file.comments ?? []).map(c => c.id === commentId ? { ...c, resolved } : c);\n },\n editComment: async (id, commentId, body) => {\n const file = find(id);\n const mine = own(file, commentId);\n const edited = { ...mine, body };\n file.comments = file.comments!.map(c => c === mine ? edited : c);\n return edited;\n },\n deleteComment: async (id, commentId) => {\n const file = find(id);\n if (!file.comments?.find(c => c.id === commentId)?.author.id.startsWith('guest:')) own(file, commentId);\n file.comments = file.comments!.filter(c => c.id !== commentId && c.replyTo !== commentId);\n },\n exportAs: async (id, format) => {\n const file = find(id);\n if ((format === 'md' ? 'markdown' : format) !== kindOf(file.name)) throw new Error('this format needs a converter on the host');\n return new Blob([encode(file.bytes)], { type: mimes[format] });\n },\n };\n}\n","import type { DocumentKind } from './types';\n\nconst byExtension: Record<string, DocumentKind> = {\n docx: 'docx', md: 'markdown', markdown: 'markdown', pdf: 'pdf', xlsx: 'sheet', csv: 'sheet', xls: 'sheet', ods: 'sheet', tsv: 'sheet', html: 'slides', htm: 'slides',\n};\n\nconst byMime: Record<string, DocumentKind> = {\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'docx',\n 'text/markdown': 'markdown',\n 'application/pdf': 'pdf',\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'sheet',\n 'text/csv': 'sheet',\n 'text/html': 'slides',\n};\n\nexport const kinds: DocumentKind[] = ['docx', 'markdown', 'pdf', 'sheet', 'slides'];\n\nexport function kindOf(name: string, mimeType?: string | null): DocumentKind | null {\n const extension = name.includes('.') ? name.split('.').pop()!.toLowerCase() : '';\n return byExtension[extension] ?? (mimeType ? byMime[mimeType.split(';')[0].trim().toLowerCase()] : undefined) ?? null;\n}\n\nexport function readable(name: string, mimeType?: string | null): DocumentKind | null {\n const kind = kindOf(name, mimeType);\n return kind !== 'sheet' || /\\.(xlsx|csv)$/i.test(name) || /spreadsheetml|text\\/csv/.test(mimeType ?? '') ? kind : null;\n}\n\nexport function matches(doc: { name: string; kind: DocumentKind }, query: string, kind: DocumentKind | 'all') {\n const words = query.toLocaleLowerCase().split(/\\s+/).filter(Boolean);\n return (kind === 'all' || doc.kind === kind) && words.every(word => doc.name.toLocaleLowerCase().includes(word));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,IAAM,cAA4C;AAAA,EAChD,MAAM;AAAA,EAAQ,IAAI;AAAA,EAAY,UAAU;AAAA,EAAY,KAAK;AAAA,EAAO,MAAM;AAAA,EAAS,KAAK;AAAA,EAAS,KAAK;AAAA,EAAS,KAAK;AAAA,EAAS,KAAK;AAAA,EAAS,MAAM;AAAA,EAAU,KAAK;AAC9J;AAEA,IAAM,SAAuC;AAAA,EAC3C,2EAA2E;AAAA,EAC3E,iBAAiB;AAAA,EACjB,mBAAmB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kinds.ts"],"sourcesContent":["import { kindOf } from './kinds';\nimport type { Comment, DocumentsHost, Person, Rights, Signature, Space } from './types';\n\ntype Bytes = ArrayBuffer | string;\n\nexport type MemoryFile = {\n id: string;\n spaceId: string;\n name: string;\n folder?: string;\n bytes: Bytes;\n version?: string;\n note?: string;\n updatedAt?: string;\n rights?: Partial<Rights>;\n versions?: { id: string; createdAt: string; bytes: Bytes; note?: string }[];\n signatures?: Signature[];\n comments?: Comment[];\n};\n\nconst mimes = { pdf: 'application/pdf', docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', md: 'text/markdown' };\n\nconst encode = (bytes: Bytes) => typeof bytes === 'string' ? new TextEncoder().encode(bytes).buffer as ArrayBuffer : bytes;\n\nexport function memoryHost({ me, spaces, files, collab }: { me: Person; spaces: Space[]; files: MemoryFile[]; collab?: string }): DocumentsHost {\n const find = (id: string) => {\n const file = files.find(item => item.id === id);\n if (!file) throw new Error('document not found');\n return file;\n };\n const own = (file: MemoryFile, commentId: string) => {\n const found = file.comments?.find(c => c.id === commentId);\n if (!found || found.author.id !== me.id) throw new Error('only the author changes a comment');\n return found;\n };\n const summary = (file: MemoryFile) => ({\n id: file.id, spaceId: file.spaceId, name: file.name, kind: kindOf(file.name)!, size: encode(file.bytes).byteLength,\n updatedAt: file.updatedAt ?? '2026-10-19T09:00:00Z', updatedBy: me, folder: file.folder ?? null,\n });\n const archive = (file: MemoryFile, bytes: Bytes, note?: string) => {\n const versions = [{ id: file.version ?? `v${(file.versions?.length ?? 0) + 1}`, createdAt: file.updatedAt ?? '2026-10-19T09:00:00Z', bytes: file.bytes, note: file.note }, ...(file.versions ?? [])];\n const version = `v${versions.length + 1}`;\n Object.assign(file, { versions, version, bytes, note, updatedAt: new Date().toISOString() });\n return version;\n };\n return {\n me,\n ...(collab ? { collab: { url: `memory:${collab}`, token: async () => me.id } } : {}),\n spaces: async () => spaces,\n documents: async spaceId => files.filter(file => file.spaceId === spaceId && kindOf(file.name)).map(summary),\n document: async id => ({ ...summary(find(id)), rights: { view: true, comment: true, edit: true, ...find(id).rights }, live: !!collab }),\n versions: async id => {\n const file = find(id);\n return [\n { id: file.version ?? 'current', createdAt: summary(file).updatedAt, size: summary(file).size, author: me, note: file.note ?? null, current: true },\n ...(file.versions ?? []).map(v => ({ id: v.id, createdAt: v.createdAt, size: encode(v.bytes).byteLength, author: me, note: v.note ?? null, current: false })),\n ];\n },\n content: async (id, versionId) => {\n const file = find(id);\n const old = versionId && versionId !== 'current' && versionId !== file.version ? file.versions?.find(v => v.id === versionId) : undefined;\n return encode(old ? old.bytes : file.bytes);\n },\n restore: async (id, versionId) => {\n const file = find(id);\n const old = file.versions?.find(v => v.id === versionId);\n if (!old) throw new Error('version not found');\n archive(file, old.bytes);\n },\n save: async (id, bytes, note) => ({ versionId: archive(find(id), bytes, note) }),\n signatures: async id => [...(find(id).signatures ?? [])].reverse(),\n sign: async (id, entry) => {\n const file = find(id);\n const signature = { id: `s${(file.signatures?.length ?? 0) + 1}`, signer: me, signedAt: new Date().toISOString(), ...entry };\n file.signatures = [...(file.signatures ?? []), signature];\n return signature;\n },\n comments: async id => [...(find(id).comments ?? [])],\n comment: async (id, entry) => {\n const file = find(id);\n let n = (file.comments?.length ?? 0) + 1;\n while (file.comments?.some(c => c.id === `c${n}`)) n++;\n const made: Comment = { id: `c${n}`, documentId: id, author: me, body: entry.body, createdAt: new Date().toISOString(), quote: entry.quote, replyTo: entry.replyTo, resolved: false };\n file.comments = [...(file.comments ?? []), made];\n return made;\n },\n resolveComment: async (id, commentId, resolved) => {\n const file = find(id);\n file.comments = (file.comments ?? []).map(c => c.id === commentId ? { ...c, resolved } : c);\n },\n editComment: async (id, commentId, body) => {\n const file = find(id);\n const mine = own(file, commentId);\n const edited = { ...mine, body };\n file.comments = file.comments!.map(c => c === mine ? edited : c);\n return edited;\n },\n deleteComment: async (id, commentId) => {\n const file = find(id);\n if (!file.comments?.find(c => c.id === commentId)?.author.id.startsWith('guest:')) own(file, commentId);\n file.comments = file.comments!.filter(c => c.id !== commentId && c.replyTo !== commentId);\n },\n exportAs: async (id, format) => {\n const file = find(id);\n if ((format === 'md' ? 'markdown' : format) !== kindOf(file.name)) throw new Error('this format needs a converter on the host');\n return new Blob([encode(file.bytes)], { type: mimes[format] });\n },\n ...(spaces.length ? {\n createIn: `${spaces[0].name} / Documents`,\n create: async ({ name, bytes }: { name: string; bytes: ArrayBuffer }) => {\n const file = { id: `new-${files.length + 1}`, spaceId: spaces[0].id, name, folder: 'Documents', bytes, updatedAt: new Date().toISOString() };\n files.push(file);\n return summary(file);\n },\n } : {}),\n };\n}\n","import type { DocumentKind } from './types';\n\nconst byExtension: Record<string, DocumentKind> = {\n docx: 'docx', md: 'markdown', markdown: 'markdown', pdf: 'pdf', xlsx: 'sheet', csv: 'sheet', xls: 'sheet', ods: 'sheet', tsv: 'sheet', html: 'slides', htm: 'slides',\n};\n\nconst byMime: Record<string, DocumentKind> = {\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'docx',\n 'text/markdown': 'markdown',\n 'application/pdf': 'pdf',\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'sheet',\n 'text/csv': 'sheet',\n 'text/html': 'slides',\n};\n\nexport const kinds: DocumentKind[] = ['docx', 'markdown', 'pdf', 'sheet', 'slides'];\n\nexport function kindOf(name: string, mimeType?: string | null): DocumentKind | null {\n const extension = name.includes('.') ? name.split('.').pop()!.toLowerCase() : '';\n return byExtension[extension] ?? (mimeType ? byMime[mimeType.split(';')[0].trim().toLowerCase()] : undefined) ?? null;\n}\n\nexport function readable(name: string, mimeType?: string | null): DocumentKind | null {\n const kind = kindOf(name, mimeType);\n return kind !== 'sheet' || /\\.(xlsx|csv)$/i.test(name) || /spreadsheetml|text\\/csv/.test(mimeType ?? '') ? kind : null;\n}\n\nexport function matches(doc: { name: string; kind: DocumentKind }, query: string, kind: DocumentKind | 'all') {\n const words = query.toLocaleLowerCase().split(/\\s+/).filter(Boolean);\n return (kind === 'all' || doc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AAM,SAAS;AACtG,WAAK,WAAW,KAAK,SAAU,OAAO,OAAK,EAAE,OAAO,aAAa,EAAE,YAAY,SAAS;AAAA,IAC1F;AAAA,IACA,UAAU,OAAO,IAAI,WAAW;AAC9B,YAAM,OAAO,KAAK,EAAE;AACpB,WAAK,WAAW,OAAO,aAAa,YAAY,OAAO,KAAK,IAAI,EAAG,OAAM,IAAI,MAAM,2CAA2C;AAC9H,aAAO,IAAI,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,GAAG,EAAE,MAAM,MAAM,MAAM,EAAE,CAAC;AAAA,IAC/D;AAAA,IACA,GAAI,OAAO,SAAS;AAAA,MAClB,UAAU,GAAG,OAAO,CAAC,EAAE,IAAI;AAAA,MAC3B,QAAQ,OAAO,EAAE,MAAM,MAAM,MAA4C;AACvE,cAAM,OAAO,EAAE,IAAI,OAAO,MAAM,SAAS,CAAC,IAAI,SAAS,OAAO,CAAC,EAAE,IAAI,MAAM,QAAQ,aAAa,OAAO,YAAW,oBAAI,KAAK,GAAE,YAAY,EAAE;AAC3I,cAAM,KAAK,IAAI;AACf,eAAO,QAAQ,IAAI;AAAA,MACrB;AAAA,IACF,IAAI,CAAC;AAAA,EACP;AACF;","names":[]}
package/dist/memory.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { R as Rights, S as Signature, C as Comment, h as Person, j as Space, D as DocumentsHost } from './types-B5oF25dn.cjs';
1
+ import { R as Rights, S as Signature, C as Comment, h as Person, j as Space, D as DocumentsHost } from './types-Er60M5kL.cjs';
2
2
 
3
3
  type Bytes = ArrayBuffer | string;
4
4
  type MemoryFile = {
package/dist/memory.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { R as Rights, S as Signature, C as Comment, h as Person, j as Space, D as DocumentsHost } from './types-B5oF25dn.js';
1
+ import { R as Rights, S as Signature, C as Comment, h as Person, j as Space, D as DocumentsHost } from './types-Er60M5kL.js';
2
2
 
3
3
  type Bytes = ArrayBuffer | string;
4
4
  type MemoryFile = {
package/dist/memory.js CHANGED
@@ -94,7 +94,15 @@ function memoryHost({ me, spaces, files, collab }) {
94
94
  const file = find(id);
95
95
  if ((format === "md" ? "markdown" : format) !== kindOf(file.name)) throw new Error("this format needs a converter on the host");
96
96
  return new Blob([encode(file.bytes)], { type: mimes[format] });
97
- }
97
+ },
98
+ ...spaces.length ? {
99
+ createIn: `${spaces[0].name} / Documents`,
100
+ create: async ({ name, bytes }) => {
101
+ const file = { id: `new-${files.length + 1}`, spaceId: spaces[0].id, name, folder: "Documents", bytes, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
102
+ files.push(file);
103
+ return summary(file);
104
+ }
105
+ } : {}
98
106
  };
99
107
  }
100
108
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/memory.ts"],"sourcesContent":["import { kindOf } from './kinds';\nimport type { Comment, DocumentsHost, Person, Rights, Signature, Space } from './types';\n\ntype Bytes = ArrayBuffer | string;\n\nexport type MemoryFile = {\n id: string;\n spaceId: string;\n name: string;\n folder?: string;\n bytes: Bytes;\n version?: string;\n note?: string;\n updatedAt?: string;\n rights?: Partial<Rights>;\n versions?: { id: string; createdAt: string; bytes: Bytes; note?: string }[];\n signatures?: Signature[];\n comments?: Comment[];\n};\n\nconst mimes = { pdf: 'application/pdf', docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', md: 'text/markdown' };\n\nconst encode = (bytes: Bytes) => typeof bytes === 'string' ? new TextEncoder().encode(bytes).buffer as ArrayBuffer : bytes;\n\nexport function memoryHost({ me, spaces, files, collab }: { me: Person; spaces: Space[]; files: MemoryFile[]; collab?: string }): DocumentsHost {\n const find = (id: string) => {\n const file = files.find(item => item.id === id);\n if (!file) throw new Error('document not found');\n return file;\n };\n const own = (file: MemoryFile, commentId: string) => {\n const found = file.comments?.find(c => c.id === commentId);\n if (!found || found.author.id !== me.id) throw new Error('only the author changes a comment');\n return found;\n };\n const summary = (file: MemoryFile) => ({\n id: file.id, spaceId: file.spaceId, name: file.name, kind: kindOf(file.name)!, size: encode(file.bytes).byteLength,\n updatedAt: file.updatedAt ?? '2026-10-19T09:00:00Z', updatedBy: me, folder: file.folder ?? null,\n });\n const archive = (file: MemoryFile, bytes: Bytes, note?: string) => {\n const versions = [{ id: file.version ?? `v${(file.versions?.length ?? 0) + 1}`, createdAt: file.updatedAt ?? '2026-10-19T09:00:00Z', bytes: file.bytes, note: file.note }, ...(file.versions ?? [])];\n const version = `v${versions.length + 1}`;\n Object.assign(file, { versions, version, bytes, note, updatedAt: new Date().toISOString() });\n return version;\n };\n return {\n me,\n ...(collab ? { collab: { url: `memory:${collab}`, token: async () => me.id } } : {}),\n spaces: async () => spaces,\n documents: async spaceId => files.filter(file => file.spaceId === spaceId && kindOf(file.name)).map(summary),\n document: async id => ({ ...summary(find(id)), rights: { view: true, comment: true, edit: true, ...find(id).rights }, live: !!collab }),\n versions: async id => {\n const file = find(id);\n return [\n { id: file.version ?? 'current', createdAt: summary(file).updatedAt, size: summary(file).size, author: me, note: file.note ?? null, current: true },\n ...(file.versions ?? []).map(v => ({ id: v.id, createdAt: v.createdAt, size: encode(v.bytes).byteLength, author: me, note: v.note ?? null, current: false })),\n ];\n },\n content: async (id, versionId) => {\n const file = find(id);\n const old = versionId && versionId !== 'current' && versionId !== file.version ? file.versions?.find(v => v.id === versionId) : undefined;\n return encode(old ? old.bytes : file.bytes);\n },\n restore: async (id, versionId) => {\n const file = find(id);\n const old = file.versions?.find(v => v.id === versionId);\n if (!old) throw new Error('version not found');\n archive(file, old.bytes);\n },\n save: async (id, bytes, note) => ({ versionId: archive(find(id), bytes, note) }),\n signatures: async id => [...(find(id).signatures ?? [])].reverse(),\n sign: async (id, entry) => {\n const file = find(id);\n const signature = { id: `s${(file.signatures?.length ?? 0) + 1}`, signer: me, signedAt: new Date().toISOString(), ...entry };\n file.signatures = [...(file.signatures ?? []), signature];\n return signature;\n },\n comments: async id => [...(find(id).comments ?? [])],\n comment: async (id, entry) => {\n const file = find(id);\n let n = (file.comments?.length ?? 0) + 1;\n while (file.comments?.some(c => c.id === `c${n}`)) n++;\n const made: Comment = { id: `c${n}`, documentId: id, author: me, body: entry.body, createdAt: new Date().toISOString(), quote: entry.quote, replyTo: entry.replyTo, resolved: false };\n file.comments = [...(file.comments ?? []), made];\n return made;\n },\n resolveComment: async (id, commentId, resolved) => {\n const file = find(id);\n file.comments = (file.comments ?? []).map(c => c.id === commentId ? { ...c, resolved } : c);\n },\n editComment: async (id, commentId, body) => {\n const file = find(id);\n const mine = own(file, commentId);\n const edited = { ...mine, body };\n file.comments = file.comments!.map(c => c === mine ? edited : c);\n return edited;\n },\n deleteComment: async (id, commentId) => {\n const file = find(id);\n if (!file.comments?.find(c => c.id === commentId)?.author.id.startsWith('guest:')) own(file, commentId);\n file.comments = file.comments!.filter(c => c.id !== commentId && c.replyTo !== commentId);\n },\n exportAs: async (id, format) => {\n const file = find(id);\n if ((format === 'md' ? 'markdown' : format) !== kindOf(file.name)) throw new Error('this format needs a converter on the host');\n return new Blob([encode(file.bytes)], { type: mimes[format] });\n },\n };\n}\n"],"mappings":";;;;;;AAoBA,IAAM,QAAQ,EAAE,KAAK,mBAAmB,MAAM,2EAA2E,IAAI,gBAAgB;AAE7I,IAAM,SAAS,CAAC,UAAiB,OAAO,UAAU,WAAW,IAAI,YAAY,EAAE,OAAO,KAAK,EAAE,SAAwB;AAE9G,SAAS,WAAW,EAAE,IAAI,QAAQ,OAAO,OAAO,GAAyF;AAC9I,QAAM,OAAO,CAAC,OAAe;AAC3B,UAAM,OAAO,MAAM,KAAK,UAAQ,KAAK,OAAO,EAAE;AAC9C,QAAI,CAAC,KAAM,OAAM,IAAI,MAAM,oBAAoB;AAC/C,WAAO;AAAA,EACT;AACA,QAAM,MAAM,CAAC,MAAkB,cAAsB;AACnD,UAAM,QAAQ,KAAK,UAAU,KAAK,OAAK,EAAE,OAAO,SAAS;AACzD,QAAI,CAAC,SAAS,MAAM,OAAO,OAAO,GAAG,GAAI,OAAM,IAAI,MAAM,mCAAmC;AAC5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AAa,EAAE,YAAY,SAAS;AAAA,IAC1F;AAAA,IACA,UAAU,OAAO,IAAI,WAAW;AAC9B,YAAM,OAAO,KAAK,EAAE;AACpB,WAAK,WAAW,OAAO,aAAa,YAAY,OAAO,KAAK,IAAI,EAAG,OAAM,IAAI,MAAM,2CAA2C;AAC9H,aAAO,IAAI,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,GAAG,EAAE,MAAM,MAAM,MAAM,EAAE,CAAC;AAAA,IAC/D;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/memory.ts"],"sourcesContent":["import { kindOf } from './kinds';\nimport type { Comment, DocumentsHost, Person, Rights, Signature, Space } from './types';\n\ntype Bytes = ArrayBuffer | string;\n\nexport type MemoryFile = {\n id: string;\n spaceId: string;\n name: string;\n folder?: string;\n bytes: Bytes;\n version?: string;\n note?: string;\n updatedAt?: string;\n rights?: Partial<Rights>;\n versions?: { id: string; createdAt: string; bytes: Bytes; note?: string }[];\n signatures?: Signature[];\n comments?: Comment[];\n};\n\nconst mimes = { pdf: 'application/pdf', docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', md: 'text/markdown' };\n\nconst encode = (bytes: Bytes) => typeof bytes === 'string' ? new TextEncoder().encode(bytes).buffer as ArrayBuffer : bytes;\n\nexport function memoryHost({ me, spaces, files, collab }: { me: Person; spaces: Space[]; files: MemoryFile[]; collab?: string }): DocumentsHost {\n const find = (id: string) => {\n const file = files.find(item => item.id === id);\n if (!file) throw new Error('document not found');\n return file;\n };\n const own = (file: MemoryFile, commentId: string) => {\n const found = file.comments?.find(c => c.id === commentId);\n if (!found || found.author.id !== me.id) throw new Error('only the author changes a comment');\n return found;\n };\n const summary = (file: MemoryFile) => ({\n id: file.id, spaceId: file.spaceId, name: file.name, kind: kindOf(file.name)!, size: encode(file.bytes).byteLength,\n updatedAt: file.updatedAt ?? '2026-10-19T09:00:00Z', updatedBy: me, folder: file.folder ?? null,\n });\n const archive = (file: MemoryFile, bytes: Bytes, note?: string) => {\n const versions = [{ id: file.version ?? `v${(file.versions?.length ?? 0) + 1}`, createdAt: file.updatedAt ?? '2026-10-19T09:00:00Z', bytes: file.bytes, note: file.note }, ...(file.versions ?? [])];\n const version = `v${versions.length + 1}`;\n Object.assign(file, { versions, version, bytes, note, updatedAt: new Date().toISOString() });\n return version;\n };\n return {\n me,\n ...(collab ? { collab: { url: `memory:${collab}`, token: async () => me.id } } : {}),\n spaces: async () => spaces,\n documents: async spaceId => files.filter(file => file.spaceId === spaceId && kindOf(file.name)).map(summary),\n document: async id => ({ ...summary(find(id)), rights: { view: true, comment: true, edit: true, ...find(id).rights }, live: !!collab }),\n versions: async id => {\n const file = find(id);\n return [\n { id: file.version ?? 'current', createdAt: summary(file).updatedAt, size: summary(file).size, author: me, note: file.note ?? null, current: true },\n ...(file.versions ?? []).map(v => ({ id: v.id, createdAt: v.createdAt, size: encode(v.bytes).byteLength, author: me, note: v.note ?? null, current: false })),\n ];\n },\n content: async (id, versionId) => {\n const file = find(id);\n const old = versionId && versionId !== 'current' && versionId !== file.version ? file.versions?.find(v => v.id === versionId) : undefined;\n return encode(old ? old.bytes : file.bytes);\n },\n restore: async (id, versionId) => {\n const file = find(id);\n const old = file.versions?.find(v => v.id === versionId);\n if (!old) throw new Error('version not found');\n archive(file, old.bytes);\n },\n save: async (id, bytes, note) => ({ versionId: archive(find(id), bytes, note) }),\n signatures: async id => [...(find(id).signatures ?? [])].reverse(),\n sign: async (id, entry) => {\n const file = find(id);\n const signature = { id: `s${(file.signatures?.length ?? 0) + 1}`, signer: me, signedAt: new Date().toISOString(), ...entry };\n file.signatures = [...(file.signatures ?? []), signature];\n return signature;\n },\n comments: async id => [...(find(id).comments ?? [])],\n comment: async (id, entry) => {\n const file = find(id);\n let n = (file.comments?.length ?? 0) + 1;\n while (file.comments?.some(c => c.id === `c${n}`)) n++;\n const made: Comment = { id: `c${n}`, documentId: id, author: me, body: entry.body, createdAt: new Date().toISOString(), quote: entry.quote, replyTo: entry.replyTo, resolved: false };\n file.comments = [...(file.comments ?? []), made];\n return made;\n },\n resolveComment: async (id, commentId, resolved) => {\n const file = find(id);\n file.comments = (file.comments ?? []).map(c => c.id === commentId ? { ...c, resolved } : c);\n },\n editComment: async (id, commentId, body) => {\n const file = find(id);\n const mine = own(file, commentId);\n const edited = { ...mine, body };\n file.comments = file.comments!.map(c => c === mine ? edited : c);\n return edited;\n },\n deleteComment: async (id, commentId) => {\n const file = find(id);\n if (!file.comments?.find(c => c.id === commentId)?.author.id.startsWith('guest:')) own(file, commentId);\n file.comments = file.comments!.filter(c => c.id !== commentId && c.replyTo !== commentId);\n },\n exportAs: async (id, format) => {\n const file = find(id);\n if ((format === 'md' ? 'markdown' : format) !== kindOf(file.name)) throw new Error('this format needs a converter on the host');\n return new Blob([encode(file.bytes)], { type: mimes[format] });\n },\n ...(spaces.length ? {\n createIn: `${spaces[0].name} / Documents`,\n create: async ({ name, bytes }: { name: string; bytes: ArrayBuffer }) => {\n const file = { id: `new-${files.length + 1}`, spaceId: spaces[0].id, name, folder: 'Documents', bytes, updatedAt: new Date().toISOString() };\n files.push(file);\n return summary(file);\n },\n } : {}),\n };\n}\n"],"mappings":";;;;;;AAoBA,IAAM,QAAQ,EAAE,KAAK,mBAAmB,MAAM,2EAA2E,IAAI,gBAAgB;AAE7I,IAAM,SAAS,CAAC,UAAiB,OAAO,UAAU,WAAW,IAAI,YAAY,EAAE,OAAO,KAAK,EAAE,SAAwB;AAE9G,SAAS,WAAW,EAAE,IAAI,QAAQ,OAAO,OAAO,GAAyF;AAC9I,QAAM,OAAO,CAAC,OAAe;AAC3B,UAAM,OAAO,MAAM,KAAK,UAAQ,KAAK,OAAO,EAAE;AAC9C,QAAI,CAAC,KAAM,OAAM,IAAI,MAAM,oBAAoB;AAC/C,WAAO;AAAA,EACT;AACA,QAAM,MAAM,CAAC,MAAkB,cAAsB;AACnD,UAAM,QAAQ,KAAK,UAAU,KAAK,OAAK,EAAE,OAAO,SAAS;AACzD,QAAI,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KAAI,MAAM,SAAS;AACtG,WAAK,WAAW,KAAK,SAAU,OAAO,OAAK,EAAE,OAAO,aAAa,EAAE,YAAY,SAAS;AAAA,IAC1F;AAAA,IACA,UAAU,OAAO,IAAI,WAAW;AAC9B,YAAM,OAAO,KAAK,EAAE;AACpB,WAAK,WAAW,OAAO,aAAa,YAAY,OAAO,KAAK,IAAI,EAAG,OAAM,IAAI,MAAM,2CAA2C;AAC9H,aAAO,IAAI,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,GAAG,EAAE,MAAM,MAAM,MAAM,EAAE,CAAC;AAAA,IAC/D;AAAA,IACA,GAAI,OAAO,SAAS;AAAA,MAClB,UAAU,GAAG,OAAO,CAAC,EAAE,IAAI;AAAA,MAC3B,QAAQ,OAAO,EAAE,MAAM,MAAM,MAA4C;AACvE,cAAM,OAAO,EAAE,IAAI,OAAO,MAAM,SAAS,CAAC,IAAI,SAAS,OAAO,CAAC,EAAE,IAAI,MAAM,QAAQ,aAAa,OAAO,YAAW,oBAAI,KAAK,GAAE,YAAY,EAAE;AAC3I,cAAM,KAAK,IAAI;AACf,eAAO,QAAQ,IAAI;AAAA,MACrB;AAAA,IACF,IAAI,CAAC;AAAA,EACP;AACF;","names":[]}
@@ -148,6 +148,12 @@ interface DocumentsHost {
148
148
  deleteComment?(id: string, commentId: string): Promise<void>;
149
149
  exportAs?(id: string, format: 'pdf' | 'docx' | 'md'): Promise<Blob>;
150
150
  copyAs?(id: string, format: 'xlsx'): Promise<DocumentSummary>;
151
+ create?(entry: {
152
+ name: string;
153
+ bytes: ArrayBuffer;
154
+ mimeType: string;
155
+ }): Promise<DocumentSummary>;
156
+ createIn?: string;
151
157
  links?(id: string, opts?: Fetch): Promise<GuestLink[]>;
152
158
  share?(id: string, entry: LinkEntry): Promise<GuestLink>;
153
159
  relink?(linkId: string, entry: LinkEntry): Promise<GuestLink>;
@@ -148,6 +148,12 @@ interface DocumentsHost {
148
148
  deleteComment?(id: string, commentId: string): Promise<void>;
149
149
  exportAs?(id: string, format: 'pdf' | 'docx' | 'md'): Promise<Blob>;
150
150
  copyAs?(id: string, format: 'xlsx'): Promise<DocumentSummary>;
151
+ create?(entry: {
152
+ name: string;
153
+ bytes: ArrayBuffer;
154
+ mimeType: string;
155
+ }): Promise<DocumentSummary>;
156
+ createIn?: string;
151
157
  links?(id: string, opts?: Fetch): Promise<GuestLink[]>;
152
158
  share?(id: string, entry: LinkEntry): Promise<GuestLink>;
153
159
  relink?(linkId: string, entry: LinkEntry): Promise<GuestLink>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w100n/documents",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Documents workspace for Web100Now projects: DOCX, Markdown, PDF, slides and sheets",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -31,8 +31,12 @@
31
31
  "./styles.css": "./dist/index.css",
32
32
  "./package.json": "./package.json"
33
33
  },
34
- "files": ["dist"],
35
- "sideEffects": ["*.css"],
34
+ "files": [
35
+ "dist"
36
+ ],
37
+ "sideEffects": [
38
+ "*.css"
39
+ ],
36
40
  "scripts": {
37
41
  "build": "tsup",
38
42
  "dev": "vite playground",