@universal-material/data-grid 0.0.0-stage → 0.1.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 (234) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +155 -2
  3. package/custom-elements.json +4624 -0
  4. package/dist/attribute-converters.d.ts +53 -0
  5. package/dist/attribute-converters.js +98 -0
  6. package/dist/attribute-converters.js.map +1 -0
  7. package/dist/change-source.d.ts +3 -0
  8. package/dist/change-source.js +2 -0
  9. package/dist/change-source.js.map +1 -0
  10. package/dist/data/data-source.d.ts +164 -0
  11. package/dist/data/data-source.js +75 -0
  12. package/dist/data/data-source.js.map +1 -0
  13. package/dist/data/local-source.d.ts +20 -0
  14. package/dist/data/local-source.js +94 -0
  15. package/dist/data/local-source.js.map +1 -0
  16. package/dist/data/remote-loader.d.ts +190 -0
  17. package/dist/data/remote-loader.js +608 -0
  18. package/dist/data/remote-loader.js.map +1 -0
  19. package/dist/export/csv.d.ts +28 -0
  20. package/dist/export/csv.js +61 -0
  21. package/dist/export/csv.js.map +1 -0
  22. package/dist/export/download.d.ts +7 -0
  23. package/dist/export/download.js +17 -0
  24. package/dist/export/download.js.map +1 -0
  25. package/dist/export/rows.d.ts +75 -0
  26. package/dist/export/rows.js +134 -0
  27. package/dist/export/rows.js.map +1 -0
  28. package/dist/export/slice.d.ts +15 -0
  29. package/dist/export/slice.js +35 -0
  30. package/dist/export/slice.js.map +1 -0
  31. package/dist/export/types.d.ts +155 -0
  32. package/dist/export/types.js +2 -0
  33. package/dist/export/types.js.map +1 -0
  34. package/dist/export/write.d.ts +38 -0
  35. package/dist/export/write.js +178 -0
  36. package/dist/export/write.js.map +1 -0
  37. package/dist/export-pdf/client.d.ts +75 -0
  38. package/dist/export-pdf/client.js +155 -0
  39. package/dist/export-pdf/client.js.map +1 -0
  40. package/dist/export-pdf/engine.d.ts +73 -0
  41. package/dist/export-pdf/engine.js +131 -0
  42. package/dist/export-pdf/engine.js.map +1 -0
  43. package/dist/export-pdf/grid-pdf.wasm +0 -0
  44. package/dist/export-pdf/index.d.ts +27 -0
  45. package/dist/export-pdf/index.js +566 -0
  46. package/dist/export-pdf/index.js.map +1 -0
  47. package/dist/export-pdf/serialize.d.ts +23 -0
  48. package/dist/export-pdf/serialize.js +127 -0
  49. package/dist/export-pdf/serialize.js.map +1 -0
  50. package/dist/export-pdf/types.d.ts +150 -0
  51. package/dist/export-pdf/types.js +2 -0
  52. package/dist/export-pdf/types.js.map +1 -0
  53. package/dist/export-pdf/worker.d.ts +2 -0
  54. package/dist/export-pdf/worker.js +81 -0
  55. package/dist/export-pdf/worker.js.map +1 -0
  56. package/dist/export-xlsx/formats.d.ts +14 -0
  57. package/dist/export-xlsx/formats.js +40 -0
  58. package/dist/export-xlsx/formats.js.map +1 -0
  59. package/dist/export-xlsx/index.d.ts +74 -0
  60. package/dist/export-xlsx/index.js +137 -0
  61. package/dist/export-xlsx/index.js.map +1 -0
  62. package/dist/features/adaptive.d.ts +25 -0
  63. package/dist/features/adaptive.js +47 -0
  64. package/dist/features/adaptive.js.map +1 -0
  65. package/dist/features/cell-content-focus.d.ts +29 -0
  66. package/dist/features/cell-content-focus.js +95 -0
  67. package/dist/features/cell-content-focus.js.map +1 -0
  68. package/dist/features/cell-range.d.ts +97 -0
  69. package/dist/features/cell-range.js +75 -0
  70. package/dist/features/cell-range.js.map +1 -0
  71. package/dist/features/clipboard.d.ts +28 -0
  72. package/dist/features/clipboard.js +48 -0
  73. package/dist/features/clipboard.js.map +1 -0
  74. package/dist/features/column-chooser.d.ts +91 -0
  75. package/dist/features/column-chooser.js +450 -0
  76. package/dist/features/column-chooser.js.map +1 -0
  77. package/dist/features/column-dnd.d.ts +10 -0
  78. package/dist/features/column-dnd.js +126 -0
  79. package/dist/features/column-dnd.js.map +1 -0
  80. package/dist/features/context-menu.d.ts +122 -0
  81. package/dist/features/context-menu.js +153 -0
  82. package/dist/features/context-menu.js.map +1 -0
  83. package/dist/features/drag-helper.d.ts +39 -0
  84. package/dist/features/drag-helper.js +108 -0
  85. package/dist/features/drag-helper.js.map +1 -0
  86. package/dist/features/drop-position.d.ts +15 -0
  87. package/dist/features/drop-position.js +24 -0
  88. package/dist/features/drop-position.js.map +1 -0
  89. package/dist/features/editing.d.ts +111 -0
  90. package/dist/features/editing.js +244 -0
  91. package/dist/features/editing.js.map +1 -0
  92. package/dist/features/filter-row.d.ts +80 -0
  93. package/dist/features/filter-row.js +537 -0
  94. package/dist/features/filter-row.js.map +1 -0
  95. package/dist/features/filtering.d.ts +55 -0
  96. package/dist/features/filtering.js +209 -0
  97. package/dist/features/filtering.js.map +1 -0
  98. package/dist/features/group-dnd.d.ts +11 -0
  99. package/dist/features/group-dnd.js +119 -0
  100. package/dist/features/group-dnd.js.map +1 -0
  101. package/dist/features/header-filter.d.ts +96 -0
  102. package/dist/features/header-filter.js +579 -0
  103. package/dist/features/header-filter.js.map +1 -0
  104. package/dist/features/host-label.d.ts +36 -0
  105. package/dist/features/host-label.js +184 -0
  106. package/dist/features/host-label.js.map +1 -0
  107. package/dist/features/keyboard.d.ts +59 -0
  108. package/dist/features/keyboard.js +127 -0
  109. package/dist/features/keyboard.js.map +1 -0
  110. package/dist/features/menu.d.ts +113 -0
  111. package/dist/features/menu.js +491 -0
  112. package/dist/features/menu.js.map +1 -0
  113. package/dist/features/resize.d.ts +82 -0
  114. package/dist/features/resize.js +214 -0
  115. package/dist/features/resize.js.map +1 -0
  116. package/dist/features/search.d.ts +45 -0
  117. package/dist/features/search.js +123 -0
  118. package/dist/features/search.js.map +1 -0
  119. package/dist/features/selection.d.ts +37 -0
  120. package/dist/features/selection.js +103 -0
  121. package/dist/features/selection.js.map +1 -0
  122. package/dist/features/sorting.d.ts +39 -0
  123. package/dist/features/sorting.js +53 -0
  124. package/dist/features/sorting.js.map +1 -0
  125. package/dist/features/toolbar.d.ts +125 -0
  126. package/dist/features/toolbar.js +135 -0
  127. package/dist/features/toolbar.js.map +1 -0
  128. package/dist/features/tree.d.ts +53 -0
  129. package/dist/features/tree.js +94 -0
  130. package/dist/features/tree.js.map +1 -0
  131. package/dist/features/validation.d.ts +48 -0
  132. package/dist/features/validation.js +172 -0
  133. package/dist/features/validation.js.map +1 -0
  134. package/dist/grid-column-def.d.ts +509 -0
  135. package/dist/grid-column-def.js +32 -0
  136. package/dist/grid-column-def.js.map +1 -0
  137. package/dist/grid-column.d.ts +167 -0
  138. package/dist/grid-column.js +376 -0
  139. package/dist/grid-column.js.map +1 -0
  140. package/dist/grid-i18n.d.ts +469 -0
  141. package/dist/grid-i18n.js +3222 -0
  142. package/dist/grid-i18n.js.map +1 -0
  143. package/dist/grid.d.ts +1484 -0
  144. package/dist/grid.js +15579 -0
  145. package/dist/grid.js.map +1 -0
  146. package/dist/grid.min.js +3858 -0
  147. package/dist/grid.styles.d.ts +2 -0
  148. package/dist/grid.styles.js +2747 -0
  149. package/dist/grid.styles.js.map +1 -0
  150. package/dist/render/cell.d.ts +16 -0
  151. package/dist/render/cell.js +78 -0
  152. package/dist/render/cell.js.map +1 -0
  153. package/dist/render/column-window.d.ts +18 -0
  154. package/dist/render/column-window.js +50 -0
  155. package/dist/render/column-window.js.map +1 -0
  156. package/dist/render/content.d.ts +45 -0
  157. package/dist/render/content.js +140 -0
  158. package/dist/render/content.js.map +1 -0
  159. package/dist/render/editors.d.ts +28 -0
  160. package/dist/render/editors.js +41 -0
  161. package/dist/render/editors.js.map +1 -0
  162. package/dist/render/footer.d.ts +61 -0
  163. package/dist/render/footer.js +61 -0
  164. package/dist/render/footer.js.map +1 -0
  165. package/dist/render/group-row.d.ts +35 -0
  166. package/dist/render/group-row.js +59 -0
  167. package/dist/render/group-row.js.map +1 -0
  168. package/dist/render/header.d.ts +92 -0
  169. package/dist/render/header.js +103 -0
  170. package/dist/render/header.js.map +1 -0
  171. package/dist/render/keyed-rows.d.ts +25 -0
  172. package/dist/render/keyed-rows.js +98 -0
  173. package/dist/render/keyed-rows.js.map +1 -0
  174. package/dist/render/virtualizer.d.ts +110 -0
  175. package/dist/render/virtualizer.js +509 -0
  176. package/dist/render/virtualizer.js.map +1 -0
  177. package/dist/row-model/added-rows.d.ts +32 -0
  178. package/dist/row-model/added-rows.js +95 -0
  179. package/dist/row-model/added-rows.js.map +1 -0
  180. package/dist/row-model/cell-range.d.ts +71 -0
  181. package/dist/row-model/cell-range.js +187 -0
  182. package/dist/row-model/cell-range.js.map +1 -0
  183. package/dist/row-model/columns.d.ts +80 -0
  184. package/dist/row-model/columns.js +207 -0
  185. package/dist/row-model/columns.js.map +1 -0
  186. package/dist/row-model/compare.d.ts +40 -0
  187. package/dist/row-model/compare.js +590 -0
  188. package/dist/row-model/compare.js.map +1 -0
  189. package/dist/row-model/distinct.d.ts +39 -0
  190. package/dist/row-model/distinct.js +105 -0
  191. package/dist/row-model/distinct.js.map +1 -0
  192. package/dist/row-model/filter.d.ts +80 -0
  193. package/dist/row-model/filter.js +582 -0
  194. package/dist/row-model/filter.js.map +1 -0
  195. package/dist/row-model/flatten.d.ts +129 -0
  196. package/dist/row-model/flatten.js +511 -0
  197. package/dist/row-model/flatten.js.map +1 -0
  198. package/dist/row-model/fold.d.ts +25 -0
  199. package/dist/row-model/fold.js +104 -0
  200. package/dist/row-model/fold.js.map +1 -0
  201. package/dist/row-model/format.d.ts +58 -0
  202. package/dist/row-model/format.js +239 -0
  203. package/dist/row-model/format.js.map +1 -0
  204. package/dist/row-model/group.d.ts +30 -0
  205. package/dist/row-model/group.js +173 -0
  206. package/dist/row-model/group.js.map +1 -0
  207. package/dist/row-model/lru.d.ts +19 -0
  208. package/dist/row-model/lru.js +48 -0
  209. package/dist/row-model/lru.js.map +1 -0
  210. package/dist/row-model/sort.d.ts +30 -0
  211. package/dist/row-model/sort.js +107 -0
  212. package/dist/row-model/sort.js.map +1 -0
  213. package/dist/row-model/summary.d.ts +64 -0
  214. package/dist/row-model/summary.js +213 -0
  215. package/dist/row-model/summary.js.map +1 -0
  216. package/dist/row-model/tree.d.ts +116 -0
  217. package/dist/row-model/tree.js +478 -0
  218. package/dist/row-model/tree.js.map +1 -0
  219. package/dist/row-model/types.d.ts +109 -0
  220. package/dist/row-model/types.js +5 -0
  221. package/dist/row-model/types.js.map +1 -0
  222. package/dist/row-model/value.d.ts +20 -0
  223. package/dist/row-model/value.js +57 -0
  224. package/dist/row-model/value.js.map +1 -0
  225. package/dist/state/grid-state.d.ts +147 -0
  226. package/dist/state/grid-state.js +295 -0
  227. package/dist/state/grid-state.js.map +1 -0
  228. package/dist/state/storage.d.ts +33 -0
  229. package/dist/state/storage.js +62 -0
  230. package/dist/state/storage.js.map +1 -0
  231. package/dist/state/versioned.d.ts +18 -0
  232. package/dist/state/versioned.js +56 -0
  233. package/dist/state/versioned.js.map +1 -0
  234. package/package.json +141 -6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/export-pdf/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAoCjE,uDAAuD;AACvD,MAAM,QAAQ,GAAG,CAAC,CAAC;AAEnB,gFAAgF;AAChF,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAAE,OAAe,EAAmB,EAAE;IACpE,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB,CAAC,MAAM,WAAW,CAAC,WAAW,CAAC,MAAM,aAAa,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAA6D,CAChI,CAAC;IAEF,iDAAiD;IACjD,MAAM,GAAG,GAAG,CAAI,CAAU,EAAc,EAAE,CAAC,IAAI,OAAO,CAAI,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAEnF,OAAO;QACL,OAAO,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAA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,MAAM,KAAK,CAAC,kBAAkB,CAAC,CAAC;YAChC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC1E,CAAC;QACD,MAAM,EAAE,KAAK,IAAI,EAAE;YACjB,QAAQ,CAAC,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;YAC7D,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC;YAEf,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;YAC3D,CAAC;YAED,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACzB,CAAC;QACD,OAAO,EAAE,GAAG,EAAE;YACZ,MAAM,CAAC,SAAS,EAAE,CAAC;YACnB,eAAe,CAAC,SAAS,EAAE,CAAC;YAC5B,MAAM,KAAK,GAAG,IAAI,YAAY,CAAC,6BAA6B,EAAE,YAAY,CAAC,CAAC;YAC5E,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnB,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * O motor de um lado só: no Web Worker (mensagens) ou na thread principal\n * (fatias de tempo). A API é a mesma; o PDF volta em blocos.\n */\nimport { yieldToHost } from '../export/slice.js';\nimport { compileEngine, Engine, EngineError } from './engine.js';\n\nexport interface RowsResult {\n chunks: Uint8Array[];\n pages: number;\n done: boolean;\n}\n\nexport interface Client {\n addFont(bytes: Uint8Array, bold: boolean, italic: boolean): Promise<void>;\n begin(config: Uint8Array): Promise<void>;\n addImage(bytes: Uint8Array, format: number, width: number, height: number): Promise<number>;\n /** Entrega um bloco de linhas (passa a ser do cliente) e espera o layout dele (`last`: fecha a entrada). */\n rows(data: Uint8Array, last: boolean): Promise<RowsResult>;\n finish(): Promise<Uint8Array[]>;\n dispose(): void;\n}\n\n/** Pedido ao worker. */\nexport type WorkerRequest =\n | { id: number; op: 'init'; module: WebAssembly.Module; role: 'engine' | 'assembler'; deferred: boolean }\n | { id: number; op: 'segments'; data: ArrayBuffer[] }\n | { id: number; op: 'font'; bytes: ArrayBuffer; bold: boolean; italic: boolean }\n | { id: number; op: 'begin'; config: ArrayBuffer }\n | { id: number; op: 'image'; bytes: ArrayBuffer; format: number; width: number; height: number }\n | { id: number; op: 'rows'; data: ArrayBuffer; last: boolean }\n | { id: number; op: 'finish' };\n\n/** Pedido sem o `id` (cada variante). */\ntype RequestBody = { [K in WorkerRequest['op']]: Omit<Extract<WorkerRequest, { op: K }>, 'id'> }[WorkerRequest['op']];\n\n/** Resposta do worker. */\nexport type WorkerResponse =\n | { id: number; ok: true; value?: number; chunks?: ArrayBuffer[]; pages?: number; done?: boolean }\n | { id: number; ok: false; code: number; message: string };\n\n/** Orçamento de uma fatia na thread principal (ms). */\nconst SLICE_MS = 8;\n\n/** Na thread principal: layout em fatias com `scheduler.yield()` entre elas. */\nexport const localClient = async (wasmUrl: string): Promise<Client> => {\n const engine = new Engine(\n (await WebAssembly.instantiate(await compileEngine(wasmUrl), {})).exports as unknown as ConstructorParameters<typeof Engine>[0],\n );\n\n // erro síncrono do motor vira promessa rejeitada\n const run = <T>(f: () => T): Promise<T> => new Promise<T>(resolve => resolve(f()));\n\n return {\n addFont: (bytes, bold, italic) => run(() => engine.addFont(bytes, bold, italic)),\n begin: config => run(() => engine.begin(config)),\n addImage: (bytes, format, width, height) => run(() => engine.addImage(bytes, format, width, height)),\n rows: async (data, last) => {\n engine.pushRows(data);\n\n if (last) {\n engine.endInput();\n }\n\n let done = false;\n const chunks: Uint8Array[] = [];\n\n for (;;) {\n const start = performance.now();\n\n do {\n done = engine.layout(1);\n } while (!done && engine.pendingRows > 0 && performance.now() - start < SLICE_MS);\n\n chunks.push(...engine.takeChunks());\n\n if (done || engine.pendingRows === 0) {\n break;\n }\n\n await yieldToHost();\n }\n\n return { chunks, pages: engine.pageCount, done };\n },\n finish: () => run(() => {\n engine.finish();\n return engine.takeChunks();\n }),\n dispose: () => engine.dispose(),\n };\n};\n\n/** Cópia do conteúdo num `ArrayBuffer` próprio (pode ser transferido sem esvaziar o do hospedeiro). */\nconst own = (bytes: Uint8Array): ArrayBuffer => bytes.slice().buffer;\n\n/** Canal de pedidos a um worker: cada pedido com `id`, resposta casada pelo `id`. */\nconst channel = (worker: Worker) => {\n let next = 0;\n const pending = new Map<number, { resolve: (r: WorkerResponse & { ok: true }) => void; reject: (e: unknown) => void }>();\n\n const fail = (error: unknown) => {\n for (const p of pending.values()) {\n p.reject(error);\n }\n\n pending.clear();\n };\n\n worker.onmessage = (event: MessageEvent<WorkerResponse>) => {\n const r = event.data;\n const p = pending.get(r.id);\n\n if (!p) {\n return;\n }\n\n pending.delete(r.id);\n\n if (r.ok) {\n p.resolve(r);\n } else {\n p.reject(new EngineError(r.code, r.message));\n }\n };\n\n worker.onerror = event => {\n event.preventDefault();\n fail(new Error(`PDF worker failed: ${event.message || 'unknown error'}`));\n };\n\n const call = (request: RequestBody, transfer: Transferable[] = []): Promise<WorkerResponse & { ok: true }> => new Promise((resolve, reject) => {\n const id = ++next;\n pending.set(id, { resolve, reject });\n worker.postMessage({ ...request, id }, transfer);\n });\n\n return { call, fail };\n};\n\n/** Montagens em voo antes de o motor esperar (limita os segmentos crus na fila do montador). */\nconst ASSEMBLER_INFLIGHT = 2;\n\n/**\n * Em Web Workers: o motor faz o layout e entrega segmentos crus; o montador\n * (segundo worker) comprime e escreve o arquivo, em paralelo com o layout das\n * próximas linhas. Encerrar (`dispose`) rejeita o pedido pendente com\n * `AbortError`.\n */\nexport const workerClient = async (worker: Worker, assemblerWorker: Worker, wasmUrl: string): Promise<Client> => {\n const engine = channel(worker);\n const asm = channel(assemblerWorker);\n // o módulo compilado uma vez na thread principal (o código e a otimização ficam entre exportações)\n const module = await compileEngine(wasmUrl);\n await Promise.all([\n engine.call({ op: 'init', module, role: 'engine', deferred: true }),\n asm.call({ op: 'init', module, role: 'assembler', deferred: false }),\n ]);\n\n // blocos do arquivo na ordem em que o montador os devolve; montagens em voo, na ordem\n const ready: Uint8Array[] = [];\n const inflight: Promise<unknown>[] = [];\n let done = false;\n\n const assemble = (segments: ArrayBuffer[]) => {\n const p = asm.call({ op: 'segments', data: segments }, segments).then(r => {\n ready.push(...(r.chunks ?? []).map(c => new Uint8Array(c)));\n done ||= !!r.done;\n });\n // falha tratada no próximo `await` dela (sem \"unhandled rejection\")\n p.catch(() => undefined);\n inflight.push(p);\n };\n\n const drain = async (keep: number) => {\n while (inflight.length > keep) {\n await inflight.shift();\n }\n };\n\n return {\n addFont: async (bytes, bold, italic) => {\n const buffer = own(bytes);\n await engine.call({ op: 'font', bytes: buffer, bold, italic }, [buffer]);\n },\n begin: async config => {\n const buffer = own(config);\n await engine.call({ op: 'begin', config: buffer }, [buffer]);\n },\n addImage: async (bytes, format, width, height) => {\n const buffer = own(bytes);\n return (await engine.call({ op: 'image', bytes: buffer, format, width, height }, [buffer])).value ?? 0;\n },\n rows: async (data, last) => {\n // o bloco é do cliente a partir daqui: transfere sem copiar quando ocupa o buffer inteiro\n const buffer = data.byteOffset === 0 && data.byteLength === data.buffer.byteLength ? data.buffer as ArrayBuffer : own(data);\n const r = await engine.call({ op: 'rows', data: buffer, last }, [buffer]);\n assemble(r.chunks ?? []);\n await drain(ASSEMBLER_INFLIGHT);\n return { chunks: ready.splice(0), pages: r.pages ?? 0, done: !!r.done };\n },\n finish: async () => {\n assemble((await engine.call({ op: 'finish' })).chunks ?? []);\n await drain(0);\n\n if (!done) {\n throw new Error('PDF assembler did not finish the file');\n }\n\n return ready.splice(0);\n },\n dispose: () => {\n worker.terminate();\n assemblerWorker.terminate();\n const abort = new DOMException('The PDF export was aborted.', 'AbortError');\n engine.fail(abort);\n asm.fail(abort);\n },\n };\n};\n"]}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * O motor WebAssembly (`grid-pdf.wasm`, crate `pdf/`) por trás de uma API
3
+ * síncrona. Roda no worker ou na thread principal. Sem imports do grid.
4
+ */
5
+ export interface Exports {
6
+ memory: WebAssembly.Memory;
7
+ alloc(len: number): number;
8
+ create(deferred: number): void;
9
+ asm_create(): void;
10
+ asm_push(ptr: number, len: number): number;
11
+ add_font(ptr: number, len: number, bold: number, italic: number): number;
12
+ begin(ptr: number, len: number): number;
13
+ add_image(ptr: number, len: number, format: number, width: number, height: number): number;
14
+ push_rows(ptr: number, len: number): number;
15
+ end_input(): void;
16
+ layout(pages: number): number;
17
+ pending_rows(): number;
18
+ page_count(): number;
19
+ rows_done(): number;
20
+ finish(): number;
21
+ take_chunk(): number;
22
+ out_ptr(): number;
23
+ error(): number;
24
+ dispose(): void;
25
+ }
26
+ /** Códigos de erro do motor (`pdf/src/lib.rs`). */
27
+ export declare const EngineCode: {
28
+ readonly Invalid: -1;
29
+ readonly Font: -2;
30
+ readonly MissingGlyph: -3;
31
+ readonly Image: -4;
32
+ readonly State: -5;
33
+ };
34
+ export declare class EngineError extends Error {
35
+ readonly code: number;
36
+ constructor(code: number, message: string);
37
+ }
38
+ /** `file:` no Node (o `fetch` do Node não lê `file:`). O especificador fica numa variável para os bundlers não o seguirem. */
39
+ export declare const readFileUrl: (url: string) => Promise<Uint8Array>;
40
+ /** Compila o `.wasm` (uma vez por URL). */
41
+ export declare const compileEngine: (url: string) => Promise<WebAssembly.Module>;
42
+ /**
43
+ * O motor: layout e escrita. `deferred`: a saída são segmentos crus (sem
44
+ * deflate nem offsets) para um {@link Assembler} noutro worker, que comprime
45
+ * em paralelo com o layout das próximas linhas.
46
+ */
47
+ export declare class Engine {
48
+ #private;
49
+ constructor(x: Exports, deferred?: boolean);
50
+ addFont(bytes: Uint8Array, bold: boolean, italic: boolean): void;
51
+ begin(config: Uint8Array): void;
52
+ addImage(bytes: Uint8Array, format: number, width: number, height: number): number;
53
+ pushRows(data: Uint8Array): void;
54
+ endInput(): void;
55
+ /** Até `pages` páginas novas; `true` quando terminou (depois de `endInput`). */
56
+ layout(pages: number): boolean;
57
+ get pendingRows(): number;
58
+ get pageCount(): number;
59
+ finish(): void;
60
+ /** Blocos prontos do arquivo (ou segmentos, no modo adiado). */
61
+ takeChunks(): Uint8Array[];
62
+ dispose(): void;
63
+ }
64
+ /** Montador do arquivo a partir dos segmentos de um {@link Engine} adiado (outra instância). */
65
+ export declare class Assembler {
66
+ #private;
67
+ constructor(x: Exports);
68
+ /** Consome um bloco de segmentos; `true` depois do fim do documento. */
69
+ push(segments: Uint8Array): boolean;
70
+ takeChunks(): Uint8Array[];
71
+ dispose(): void;
72
+ }
73
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1,131 @@
1
+ /**
2
+ * O motor WebAssembly (`grid-pdf.wasm`, crate `pdf/`) por trás de uma API
3
+ * síncrona. Roda no worker ou na thread principal. Sem imports do grid.
4
+ */
5
+ /** Códigos de erro do motor (`pdf/src/lib.rs`). */
6
+ export const EngineCode = { Invalid: -1, Font: -2, MissingGlyph: -3, Image: -4, State: -5 };
7
+ export class EngineError extends Error {
8
+ constructor(code, message) {
9
+ super(message);
10
+ this.code = code;
11
+ }
12
+ }
13
+ /** Módulos compilados por URL (uma ou duas entradas na prática). */
14
+ const compiled = new Map();
15
+ /** `file:` no Node (o `fetch` do Node não lê `file:`). O especificador fica numa variável para os bundlers não o seguirem. */
16
+ export const readFileUrl = async (url) => {
17
+ const specifier = 'node:fs/promises';
18
+ const fs = await import(/* @vite-ignore */ specifier);
19
+ return new Uint8Array(await fs.readFile(new URL(url)));
20
+ };
21
+ /** Compila o `.wasm` (uma vez por URL). */
22
+ export const compileEngine = (url) => {
23
+ let module = compiled.get(url);
24
+ if (!module) {
25
+ module = (async () => {
26
+ if (url.startsWith('file:')) {
27
+ return WebAssembly.compile((await readFileUrl(url)));
28
+ }
29
+ const response = await fetch(url);
30
+ if (!response.ok) {
31
+ throw new Error(`could not load ${url} (${response.status})`);
32
+ }
33
+ return typeof WebAssembly.compileStreaming === 'function' && response.headers.get('content-type')?.includes('wasm')
34
+ ? WebAssembly.compileStreaming(response)
35
+ : WebAssembly.compile(await response.arrayBuffer());
36
+ })();
37
+ module.catch(() => compiled.delete(url));
38
+ compiled.set(url, module);
39
+ }
40
+ return module;
41
+ };
42
+ /** Copia `bytes` para a memória do wasm (o motor consome o buffer). */
43
+ const put = (x, bytes) => {
44
+ const ptr = x.alloc(bytes.length);
45
+ new Uint8Array(x.memory.buffer, ptr, bytes.length).set(bytes);
46
+ return ptr;
47
+ };
48
+ /** Código negativo vira `EngineError` com a mensagem do motor. */
49
+ const check = (x, code) => {
50
+ if (code < 0) {
51
+ const len = x.error();
52
+ const message = new TextDecoder().decode(new Uint8Array(x.memory.buffer, x.out_ptr(), len));
53
+ throw new EngineError(code, message);
54
+ }
55
+ return code;
56
+ };
57
+ /** Blocos prontos (cópias: a memória do wasm não guarda o PDF). */
58
+ const takeChunks = (x) => {
59
+ const chunks = [];
60
+ let len;
61
+ while ((len = x.take_chunk()) > 0) {
62
+ chunks.push(new Uint8Array(x.memory.buffer, x.out_ptr(), len).slice());
63
+ }
64
+ return chunks;
65
+ };
66
+ /**
67
+ * O motor: layout e escrita. `deferred`: a saída são segmentos crus (sem
68
+ * deflate nem offsets) para um {@link Assembler} noutro worker, que comprime
69
+ * em paralelo com o layout das próximas linhas.
70
+ */
71
+ export class Engine {
72
+ #x;
73
+ constructor(x, deferred = false) {
74
+ this.#x = x;
75
+ x.create(deferred ? 1 : 0);
76
+ }
77
+ addFont(bytes, bold, italic) {
78
+ check(this.#x, this.#x.add_font(put(this.#x, bytes), bytes.length, bold ? 1 : 0, italic ? 1 : 0));
79
+ }
80
+ begin(config) {
81
+ check(this.#x, this.#x.begin(put(this.#x, config), config.length));
82
+ }
83
+ addImage(bytes, format, width, height) {
84
+ return check(this.#x, this.#x.add_image(put(this.#x, bytes), bytes.length, format, width, height));
85
+ }
86
+ pushRows(data) {
87
+ check(this.#x, this.#x.push_rows(put(this.#x, data), data.length));
88
+ }
89
+ endInput() {
90
+ this.#x.end_input();
91
+ }
92
+ /** Até `pages` páginas novas; `true` quando terminou (depois de `endInput`). */
93
+ layout(pages) {
94
+ return check(this.#x, this.#x.layout(pages)) === 1;
95
+ }
96
+ get pendingRows() {
97
+ return this.#x.pending_rows();
98
+ }
99
+ get pageCount() {
100
+ return this.#x.page_count();
101
+ }
102
+ finish() {
103
+ check(this.#x, this.#x.finish());
104
+ }
105
+ /** Blocos prontos do arquivo (ou segmentos, no modo adiado). */
106
+ takeChunks() {
107
+ return takeChunks(this.#x);
108
+ }
109
+ dispose() {
110
+ this.#x.dispose();
111
+ }
112
+ }
113
+ /** Montador do arquivo a partir dos segmentos de um {@link Engine} adiado (outra instância). */
114
+ export class Assembler {
115
+ #x;
116
+ constructor(x) {
117
+ this.#x = x;
118
+ x.asm_create();
119
+ }
120
+ /** Consome um bloco de segmentos; `true` depois do fim do documento. */
121
+ push(segments) {
122
+ return check(this.#x, this.#x.asm_push(put(this.#x, segments), segments.length)) === 1;
123
+ }
124
+ takeChunks() {
125
+ return takeChunks(this.#x);
126
+ }
127
+ dispose() {
128
+ this.#x.dispose();
129
+ }
130
+ }
131
+ //# sourceMappingURL=engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/export-pdf/engine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAwBH,mDAAmD;AACnD,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAW,CAAC;AAErG,MAAM,OAAO,WAAY,SAA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AG,CAAC,CAAC;QACZ,CAAC,CAAC,UAAU,EAAE,CAAC;IACjB,CAAC;IAED,wEAAwE;IACxE,IAAI,CAAC,QAAoB;QACvB,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC;IACzF,CAAC;IAED,UAAU;QACR,OAAO,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO;QACL,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACF","sourcesContent":["/**\n * O motor WebAssembly (`grid-pdf.wasm`, crate `pdf/`) por trás de uma API\n * síncrona. Roda no worker ou na thread principal. Sem imports do grid.\n */\n\nexport interface Exports {\n memory: WebAssembly.Memory;\n alloc(len: number): number;\n create(deferred: number): void;\n asm_create(): void;\n asm_push(ptr: number, len: number): number;\n add_font(ptr: number, len: number, bold: number, italic: number): number;\n begin(ptr: number, len: number): number;\n add_image(ptr: number, len: number, format: number, width: number, height: number): number;\n push_rows(ptr: number, len: number): number;\n end_input(): void;\n layout(pages: number): number;\n pending_rows(): number;\n page_count(): number;\n rows_done(): number;\n finish(): number;\n take_chunk(): number;\n out_ptr(): number;\n error(): number;\n dispose(): void;\n}\n\n/** Códigos de erro do motor (`pdf/src/lib.rs`). */\nexport const EngineCode = { Invalid: -1, Font: -2, MissingGlyph: -3, Image: -4, State: -5 } as const;\n\nexport class EngineError extends Error {\n readonly code: number;\n\n constructor(code: number, message: string) {\n super(message);\n this.code = code;\n }\n}\n\n/** Módulos compilados por URL (uma ou duas entradas na prática). */\nconst compiled = new Map<string, Promise<WebAssembly.Module>>();\n\n/** `file:` no Node (o `fetch` do Node não lê `file:`). O especificador fica numa variável para os bundlers não o seguirem. */\nexport const readFileUrl = async (url: string): Promise<Uint8Array> => {\n const specifier = 'node:fs/promises';\n const fs = await import(/* @vite-ignore */ specifier) as { readFile(path: URL): Promise<Uint8Array> };\n return new Uint8Array(await fs.readFile(new URL(url)));\n};\n\n/** Compila o `.wasm` (uma vez por URL). */\nexport const compileEngine = (url: string): Promise<WebAssembly.Module> => {\n let module = compiled.get(url);\n\n if (!module) {\n module = (async () => {\n if (url.startsWith('file:')) {\n return WebAssembly.compile((await readFileUrl(url)) as Uint8Array<ArrayBuffer>);\n }\n\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(`could not load ${url} (${response.status})`);\n }\n\n return typeof WebAssembly.compileStreaming === 'function' && response.headers.get('content-type')?.includes('wasm')\n ? WebAssembly.compileStreaming(response)\n : WebAssembly.compile(await response.arrayBuffer());\n })();\n module.catch(() => compiled.delete(url));\n compiled.set(url, module);\n }\n\n return module;\n};\n\n/** Copia `bytes` para a memória do wasm (o motor consome o buffer). */\nconst put = (x: Exports, bytes: Uint8Array): number => {\n const ptr = x.alloc(bytes.length);\n new Uint8Array(x.memory.buffer, ptr, bytes.length).set(bytes);\n return ptr;\n};\n\n/** Código negativo vira `EngineError` com a mensagem do motor. */\nconst check = (x: Exports, code: number): number => {\n if (code < 0) {\n const len = x.error();\n const message = new TextDecoder().decode(new Uint8Array(x.memory.buffer, x.out_ptr(), len));\n throw new EngineError(code, message);\n }\n\n return code;\n};\n\n/** Blocos prontos (cópias: a memória do wasm não guarda o PDF). */\nconst takeChunks = (x: Exports): Uint8Array[] => {\n const chunks: Uint8Array[] = [];\n let len: number;\n\n while ((len = x.take_chunk()) > 0) {\n chunks.push(new Uint8Array(x.memory.buffer, x.out_ptr(), len).slice());\n }\n\n return chunks;\n};\n\n/**\n * O motor: layout e escrita. `deferred`: a saída são segmentos crus (sem\n * deflate nem offsets) para um {@link Assembler} noutro worker, que comprime\n * em paralelo com o layout das próximas linhas.\n */\nexport class Engine {\n readonly #x: Exports;\n\n constructor(x: Exports, deferred = false) {\n this.#x = x;\n x.create(deferred ? 1 : 0);\n }\n\n addFont(bytes: Uint8Array, bold: boolean, italic: boolean): void {\n check(this.#x, this.#x.add_font(put(this.#x, bytes), bytes.length, bold ? 1 : 0, italic ? 1 : 0));\n }\n\n begin(config: Uint8Array): void {\n check(this.#x, this.#x.begin(put(this.#x, config), config.length));\n }\n\n addImage(bytes: Uint8Array, format: number, width: number, height: number): number {\n return check(this.#x, this.#x.add_image(put(this.#x, bytes), bytes.length, format, width, height));\n }\n\n pushRows(data: Uint8Array): void {\n check(this.#x, this.#x.push_rows(put(this.#x, data), data.length));\n }\n\n endInput(): void {\n this.#x.end_input();\n }\n\n /** Até `pages` páginas novas; `true` quando terminou (depois de `endInput`). */\n layout(pages: number): boolean {\n return check(this.#x, this.#x.layout(pages)) === 1;\n }\n\n get pendingRows(): number {\n return this.#x.pending_rows();\n }\n\n get pageCount(): number {\n return this.#x.page_count();\n }\n\n finish(): void {\n check(this.#x, this.#x.finish());\n }\n\n /** Blocos prontos do arquivo (ou segmentos, no modo adiado). */\n takeChunks(): Uint8Array[] {\n return takeChunks(this.#x);\n }\n\n dispose(): void {\n this.#x.dispose();\n }\n}\n\n/** Montador do arquivo a partir dos segmentos de um {@link Engine} adiado (outra instância). */\nexport class Assembler {\n readonly #x: Exports;\n\n constructor(x: Exports) {\n this.#x = x;\n x.asm_create();\n }\n\n /** Consome um bloco de segmentos; `true` depois do fim do documento. */\n push(segments: Uint8Array): boolean {\n return check(this.#x, this.#x.asm_push(put(this.#x, segments), segments.length)) === 1;\n }\n\n takeChunks(): Uint8Array[] {\n return takeChunks(this.#x);\n }\n\n dispose(): void {\n this.#x.dispose();\n }\n}\n"]}
Binary file
@@ -0,0 +1,27 @@
1
+ import type { GridExportData, GridExporter } from '../export/types.js';
2
+ import type { DataGrid } from '../grid.js';
3
+ import type { GridPdfDownloadOptions, GridPdfExporterOptions, GridPdfOptions } from './types.js';
4
+ export type { GridPdfCell, GridPdfCellStyle, GridPdfDownloadOptions, GridPdfExporterOptions, GridPdfFont, GridPdfImage, GridPdfLayout, GridPdfLink, GridPdfOptions, GridPdfOrientation, GridPdfPaperSize, GridPdfProgress, GridPdfTheme, } from './types.js';
5
+ /** Some characters have no glyph in any of the `fonts`: the PDF would lose them (PDF/UA). Add a font that covers them. */
6
+ export declare class GridPdfMissingGlyphError extends Error {
7
+ /** The code points without a glyph. */
8
+ readonly codePoints: readonly number[];
9
+ constructor(codePoints: readonly number[]);
10
+ }
11
+ /**
12
+ * The PDF of what the user sees (with a grid: visible columns in the current
13
+ * order, filter, sorting, groups and summaries) or of ready data: a tagged PDF
14
+ * (PDF/UA-1 target) with the given fonts embedded. Runs in a Web Worker; the
15
+ * `.wasm` and the worker load on the first export.
16
+ */
17
+ export declare const exportPdf: (source: DataGrid | GridExportData, options: GridPdfOptions) => Promise<Blob>;
18
+ /** Builds the PDF (`exportPdf`) and downloads it as `fileName` (default `export.pdf`). */
19
+ export declare const downloadPdf: (source: DataGrid | GridExportData, options: GridPdfDownloadOptions) => Promise<void>;
20
+ /**
21
+ * The PDF entry of the grid export UI: `grid.pdfExporter =
22
+ * createPdfExporter({ fonts })` (with `export-formats="… pdf"`). The grid
23
+ * passes `selectedOnly`, a `signal` (cancel, disconnect) and `onProgress`
24
+ * (shown in the export button). Options are checked now (`TypeError`).
25
+ */
26
+ export declare const createPdfExporter: (options: GridPdfExporterOptions) => GridExporter;
27
+ //# sourceMappingURL=index.d.ts.map