@arbidocs/blocks 0.4.70 → 0.4.72

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 (179) hide show
  1. package/README.md +90 -14
  2. package/bin/arbidocs-copy-pdf-assets.mjs +112 -0
  3. package/dist/{StreamedArtifactEditor-OPL4KXOT.js → StreamedArtifactEditor-HTNPG4NB.js} +3 -2
  4. package/dist/StreamedArtifactEditor-HTNPG4NB.js.map +1 -0
  5. package/dist/{StreamedArtifactEditor-RIKG6CJQ.cjs → StreamedArtifactEditor-IZWYNFMM.cjs} +3 -2
  6. package/dist/StreamedArtifactEditor-IZWYNFMM.cjs.map +1 -0
  7. package/dist/agents/index.cjs +224 -224
  8. package/dist/agents/index.js +8 -8
  9. package/dist/artifacts/editor/index.cjs +1 -0
  10. package/dist/artifacts/editor/index.js +1 -0
  11. package/dist/artifacts/index.cjs +1 -0
  12. package/dist/artifacts/index.js +1 -0
  13. package/dist/auth/index.cjs +1 -0
  14. package/dist/auth/index.js +1 -0
  15. package/dist/calendar/CalendarGrid.d.ts +2 -0
  16. package/dist/calendar/CalendarList.d.ts +2 -0
  17. package/dist/calendar/CalendarSettingsForm.d.ts +2 -0
  18. package/dist/calendar/EventDetails.d.ts +2 -0
  19. package/dist/calendar/EventEditor.d.ts +2 -0
  20. package/dist/calendar/MiniMonth.d.ts +2 -0
  21. package/dist/calendar/RecurrenceEditor.d.ts +13 -0
  22. package/dist/calendar/RoomFinder.d.ts +2 -0
  23. package/dist/calendar/SchedulingAssistant.d.ts +2 -0
  24. package/dist/calendar/ScopeDialog.d.ts +2 -0
  25. package/dist/calendar/TimeZonePicker.d.ts +2 -0
  26. package/dist/calendar/colors.d.ts +4 -0
  27. package/dist/calendar/draft.d.ts +43 -0
  28. package/dist/calendar/format.d.ts +14 -0
  29. package/dist/calendar/grid-model.d.ts +24 -0
  30. package/dist/calendar/index.cjs +4122 -0
  31. package/dist/calendar/index.cjs.map +1 -0
  32. package/dist/calendar/index.d.ts +30 -0
  33. package/dist/calendar/index.js +4043 -0
  34. package/dist/calendar/index.js.map +1 -0
  35. package/dist/calendar/labels.d.ts +4 -0
  36. package/dist/calendar/recurrence-labels.d.ts +22 -0
  37. package/dist/calendar/recurrence.d.ts +66 -0
  38. package/dist/calendar/reminders.d.ts +26 -0
  39. package/dist/calendar/scheduling.d.ts +27 -0
  40. package/dist/calendar/types.d.ts +605 -0
  41. package/dist/calendar/ui.d.ts +16 -0
  42. package/dist/calendar/zone.d.ts +56 -0
  43. package/dist/chat/index.cjs +124 -123
  44. package/dist/chat/index.js +4 -3
  45. package/dist/{chunk-XNRGCQPZ.cjs → chunk-3SFFTSOI.cjs} +5 -5
  46. package/dist/{chunk-XNRGCQPZ.cjs.map → chunk-3SFFTSOI.cjs.map} +1 -1
  47. package/dist/{chunk-EHXSBH6U.js → chunk-5HOAOKZL.js} +4 -2
  48. package/dist/chunk-5HOAOKZL.js.map +1 -0
  49. package/dist/{chunk-7WM62NMM.cjs → chunk-6OL5S7MJ.cjs} +5 -2
  50. package/dist/chunk-6OL5S7MJ.cjs.map +1 -0
  51. package/dist/{chunk-VUEZARW5.cjs → chunk-B3WCKBJ7.cjs} +278 -5
  52. package/dist/chunk-B3WCKBJ7.cjs.map +1 -0
  53. package/dist/{chunk-L5UPP2HC.js → chunk-D46ZAPEE.js} +5 -2
  54. package/dist/chunk-D46ZAPEE.js.map +1 -0
  55. package/dist/chunk-DES3K4SD.cjs +18 -0
  56. package/dist/chunk-DES3K4SD.cjs.map +1 -0
  57. package/dist/{chunk-7M22KND4.cjs → chunk-DH7C2UJO.cjs} +10 -10
  58. package/dist/{chunk-7M22KND4.cjs.map → chunk-DH7C2UJO.cjs.map} +1 -1
  59. package/dist/{chunk-CXWESDIZ.cjs → chunk-F4RUCUXF.cjs} +6 -6
  60. package/dist/{chunk-CXWESDIZ.cjs.map → chunk-F4RUCUXF.cjs.map} +1 -1
  61. package/dist/{chunk-DABEWNL2.js → chunk-G5DP27DU.js} +3 -3
  62. package/dist/{chunk-DABEWNL2.js.map → chunk-G5DP27DU.js.map} +1 -1
  63. package/dist/{chunk-BR2CPKFU.cjs → chunk-G5QTGKDJ.cjs} +8 -8
  64. package/dist/{chunk-BR2CPKFU.cjs.map → chunk-G5QTGKDJ.cjs.map} +1 -1
  65. package/dist/{chunk-VZGBCBYB.js → chunk-GJV2G4FC.js} +276 -7
  66. package/dist/chunk-GJV2G4FC.js.map +1 -0
  67. package/dist/{chunk-HLMFU7L2.js → chunk-IMC2Z32C.js} +8 -8
  68. package/dist/{chunk-HLMFU7L2.js.map → chunk-IMC2Z32C.js.map} +1 -1
  69. package/dist/{chunk-5DM6VU4L.cjs → chunk-KJ3QEKOJ.cjs} +3 -3
  70. package/dist/{chunk-5DM6VU4L.cjs.map → chunk-KJ3QEKOJ.cjs.map} +1 -1
  71. package/dist/{chunk-CW4WXGEN.js → chunk-KOXUBCLL.js} +4 -4
  72. package/dist/{chunk-CW4WXGEN.js.map → chunk-KOXUBCLL.js.map} +1 -1
  73. package/dist/{chunk-ILGHS6ZV.js → chunk-SB5ZKOYN.js} +3 -3
  74. package/dist/{chunk-ILGHS6ZV.js.map → chunk-SB5ZKOYN.js.map} +1 -1
  75. package/dist/{chunk-TLQQV7WW.cjs → chunk-THO7DZNN.cjs} +4 -2
  76. package/dist/chunk-THO7DZNN.cjs.map +1 -0
  77. package/dist/{chunk-CPMNAJLF.js → chunk-TX2ZICS7.js} +24 -4
  78. package/dist/chunk-TX2ZICS7.js.map +1 -0
  79. package/dist/{chunk-2ZTONLT5.cjs → chunk-ULWRNGGE.cjs} +25 -4
  80. package/dist/chunk-ULWRNGGE.cjs.map +1 -0
  81. package/dist/{chunk-BMWZTNZB.js → chunk-VRPRAU3J.js} +3 -3
  82. package/dist/{chunk-BMWZTNZB.js.map → chunk-VRPRAU3J.js.map} +1 -1
  83. package/dist/chunk-VUNV25KB.js +15 -0
  84. package/dist/chunk-VUNV25KB.js.map +1 -0
  85. package/dist/citations/index.cjs +1 -0
  86. package/dist/citations/index.js +1 -0
  87. package/dist/collaboration/index.cjs +45 -45
  88. package/dist/collaboration/index.js +3 -3
  89. package/dist/connect/docx.cjs +3 -2
  90. package/dist/connect/docx.cjs.map +1 -1
  91. package/dist/connect/docx.js +2 -1
  92. package/dist/connect/docx.js.map +1 -1
  93. package/dist/connect/index.cjs +79 -49
  94. package/dist/connect/index.cjs.map +1 -1
  95. package/dist/connect/index.d.ts +1 -1
  96. package/dist/connect/index.js +39 -11
  97. package/dist/connect/index.js.map +1 -1
  98. package/dist/connection/ConnectedSettings.d.ts +13 -0
  99. package/dist/connection/ConnectionProvider.d.ts +5 -0
  100. package/dist/connection/types.d.ts +6 -0
  101. package/dist/document-tools/SignatureStatus.d.ts +4 -2
  102. package/dist/document-tools/index.cjs +14 -11
  103. package/dist/document-tools/index.cjs.map +1 -1
  104. package/dist/document-tools/index.js +12 -9
  105. package/dist/document-tools/index.js.map +1 -1
  106. package/dist/document-tools/production/ProductionSetDialog.d.ts +23 -0
  107. package/dist/document-tools/production/index.cjs +102 -0
  108. package/dist/document-tools/production/index.cjs.map +1 -0
  109. package/dist/document-tools/production/index.d.ts +1 -0
  110. package/dist/document-tools/production/index.js +100 -0
  111. package/dist/document-tools/production/index.js.map +1 -0
  112. package/dist/document-tools/viewer/index.cjs +1 -1
  113. package/dist/document-tools/viewer/index.js +1 -1
  114. package/dist/docx/index.cjs +1 -0
  115. package/dist/docx/index.cjs.map +1 -1
  116. package/dist/docx/index.js +1 -0
  117. package/dist/docx/index.js.map +1 -1
  118. package/dist/facts/index.cjs +3 -2
  119. package/dist/facts/index.cjs.map +1 -1
  120. package/dist/facts/index.js +3 -2
  121. package/dist/facts/index.js.map +1 -1
  122. package/dist/files/import/index.d.ts +0 -1
  123. package/dist/files/index.cjs +25 -88
  124. package/dist/files/index.cjs.map +1 -1
  125. package/dist/files/index.js +7 -68
  126. package/dist/files/index.js.map +1 -1
  127. package/dist/home/index.cjs +2 -1
  128. package/dist/home/index.cjs.map +1 -1
  129. package/dist/home/index.js +2 -1
  130. package/dist/home/index.js.map +1 -1
  131. package/dist/index.cjs +537 -537
  132. package/dist/index.js +14 -14
  133. package/dist/lib-6QPUXAQS.cjs +9674 -0
  134. package/dist/lib-6QPUXAQS.cjs.map +1 -0
  135. package/dist/lib-NRGL2JGF.js +9672 -0
  136. package/dist/lib-NRGL2JGF.js.map +1 -0
  137. package/dist/retrieval/index.cjs +1 -0
  138. package/dist/retrieval/index.js +1 -0
  139. package/dist/settings/Billing.d.ts +4 -0
  140. package/dist/settings/IdentityVerification.d.ts +83 -0
  141. package/dist/settings/PlanBadge.d.ts +2 -2
  142. package/dist/settings/PlanCard.d.ts +6 -1
  143. package/dist/settings/ProfileCard.d.ts +5 -1
  144. package/dist/settings/SubscriptionParts.d.ts +6 -2
  145. package/dist/settings/index.cjs +129 -95
  146. package/dist/settings/index.cjs.map +1 -1
  147. package/dist/settings/index.d.ts +1 -0
  148. package/dist/settings/index.js +65 -47
  149. package/dist/settings/index.js.map +1 -1
  150. package/dist/shell/ActionCluster.d.ts +3 -1
  151. package/dist/shell/index.cjs +56 -55
  152. package/dist/shell/index.js +4 -3
  153. package/dist/site/index.cjs +1 -0
  154. package/dist/site/index.js +1 -0
  155. package/dist/studio/index.cjs +8 -7
  156. package/dist/studio/index.cjs.map +1 -1
  157. package/dist/studio/index.js +6 -5
  158. package/dist/studio/index.js.map +1 -1
  159. package/dist/timeline/index.cjs +1 -0
  160. package/dist/timeline/index.js +1 -0
  161. package/dist/workspaces/index.cjs +3 -3
  162. package/dist/workspaces/index.js +2 -2
  163. package/package.json +35 -5
  164. package/src/calendar/calendar.css +316 -0
  165. package/dist/StreamedArtifactEditor-OPL4KXOT.js.map +0 -1
  166. package/dist/StreamedArtifactEditor-RIKG6CJQ.cjs.map +0 -1
  167. package/dist/chunk-2ZTONLT5.cjs.map +0 -1
  168. package/dist/chunk-7WM62NMM.cjs.map +0 -1
  169. package/dist/chunk-CPMNAJLF.js.map +0 -1
  170. package/dist/chunk-DCDVWPMB.cjs +0 -29
  171. package/dist/chunk-DCDVWPMB.cjs.map +0 -1
  172. package/dist/chunk-EHXSBH6U.js.map +0 -1
  173. package/dist/chunk-L5UPP2HC.js.map +0 -1
  174. package/dist/chunk-TJMKFY5P.js +0 -27
  175. package/dist/chunk-TJMKFY5P.js.map +0 -1
  176. package/dist/chunk-TLQQV7WW.cjs.map +0 -1
  177. package/dist/chunk-VUEZARW5.cjs.map +0 -1
  178. package/dist/chunk-VZGBCBYB.js.map +0 -1
  179. package/dist/files/import/CalendarImportRow.d.ts +0 -26
package/README.md CHANGED
@@ -167,28 +167,49 @@ merged in), "Show original", "Download with markup", the notes about markup on a
167
167
  ("Copy open comments here") and about marks left in this browser, Freeze (a separate annotated or
168
168
  redacted copy, with a redaction log), e-signing (choose where the signature goes, sign with the
169
169
  password; only the signature and optionally the date are drawn), the signature details with "View
170
- certificate", the public certificate page, and the read-only version bar.
170
+ certificate", the public certificate page, the read-only version bar and production sets (Bates
171
+ numbering).
171
172
 
172
173
  | Import | What |
173
174
  | --- | --- |
174
- | `@arbidocs/react/document-tools` | `DocumentToolsProvider`, `useDocumentMarkup`, `createMarkupStore`, `fetchMarkupPdf`, `canAnnotate`, `useDocumentSignatures`, `useSignDocument`, `useSignatureVerification` |
175
+ | `@arbidocs/react/document-tools` | `DocumentToolsProvider`, `fetchDocumentPdf`, `fetchDocumentFile`, `useDocumentMarkup`, `createMarkupStore`, `fetchMarkupPdf`, `canAnnotate`, `useDocumentSignatures`, `useSignDocument`, `useSignatureVerification`, `buildProduction`, `saveProductionFiles` |
175
176
  | `@arbidocs/blocks/document-tools` | `AnnotateButton`, `ShowOriginalButton`, `DownloadMarkupButton`, `SignButton`, `MarkupNotices`, `MarkupViewNote`, `SignDocumentDialog`, `SignatureStatus`, `SignatureCertificate`, `VersionSnapshotBar` |
176
177
  | `@arbidocs/blocks/document-tools/viewer` | `AnnotatedPdfViewer`, `SignaturePlacementViewer` (load lazily: pdf-lib) |
178
+ | `@arbidocs/blocks/document-tools/production` | `ProductionSetDialog` (load lazily; pdf-lib and JSZip load on confirm) |
177
179
 
178
180
  What the host provides, once, around the viewer (the tools import no store, router or toast
179
181
  library of their own):
180
182
 
181
183
  - an ARBI API client signed in as the user: `arbi.getClient().fetch` from an `@arbidocs/sdk`
182
184
  `Arbi`, or `createArbiClient(...).fetch` from `@arbidocs/client`;
183
- - `deploymentDomain` (the one the user's keys are derived for) and `user: { name, email }`, for
184
- signing; without a user marks are authored as "You";
185
+ - `user: { name, email }` for signing (without a user marks are authored as "You") and the
186
+ `deploymentDomain` the user's keys are derived for. Inside an `ArbiProvider` (or
187
+ `ArbiAppProvider`, which mounts one) `deploymentDomain` defaults to the SDK's own,
188
+ `arbi.getDeploymentDomain()` (the `deploymentDomain` option, else the API URL's hostname), which
189
+ is also `useDeploymentDomain()` from `@arbidocs/react` and `deploymentDomain` on
190
+ `useConnection()`. Pass it only when the API is served from another host than the one users
191
+ registered on (`ArbiConnectionConfig.deploymentDomain` sets it for the whole app);
185
192
  - callbacks, all optional: `notify(message, kind, { description, action })`, `openDocument(ref)`
186
- (the copy just frozen, the signed copy), `onDocumentsChanged(ids, 'markup' | 'copy' | 'signed')`
187
- to refresh your lists, `emailDocument(ref)` (adds "Email it" after signing), `uploadDocument`,
188
- `saveFile` and `certificateUrl` (defaults: the API client, a download link, `/verify/{ref}`);
189
- - a React Query `QueryClientProvider`, the blocks styles (see Styles), and the pdf.js assets the
190
- kit `PdfViewer` loads (`/pdf.worker.min.mjs`, `/cmaps/`, `/standard_fonts/` by default) plus the
191
- optional peers `react-pdf`, `pdfjs-dist` and `pdf-lib`.
193
+ (the copy just frozen, the signed copy, a saved production), `onDocumentsChanged(ids, 'markup' |
194
+ 'copy' | 'signed')` to refresh your lists, `emailDocument(ref)` (adds "Email it" after signing),
195
+ `uploadDocument`, `saveFile` and `certificateUrl` (defaults: the API client, a download link, the
196
+ backend's certificate link; see Signature certificates);
197
+ - a React Query `QueryClientProvider`, the blocks styles (see Styles), the optional peers
198
+ `react-pdf`, `pdfjs-dist` and `pdf-lib`, and the pdf.js runtime (see below).
199
+
200
+ The PDF the tools draw on is the document's `/view` rendering (the file itself for a PDF, its PDF
201
+ rendering for a Word or text file). Fetch it with the function the tools use:
202
+
203
+ ```ts
204
+ import { fetchDocumentPdf } from '@arbidocs/react/document-tools'
205
+
206
+ // GET /v1/document/{id}/view?version= with Accept: application/pdf; a `doc-…@v2` reference
207
+ // names a version too. Throws a DocumentFetchError (with `status`) when there is no PDF yet.
208
+ const pdf = await fetchDocumentPdf(arbi.getClient().fetch, doc.external_id, { version: 2 })
209
+ ```
210
+
211
+ Put the version in your cache key: a document keeps its id across versions (a signed copy is the
212
+ next version), so a new version must never show the previous one's file.
192
213
 
193
214
  ```tsx
194
215
  import { lazy, Suspense, useState } from 'react'
@@ -199,11 +220,11 @@ const AnnotatedPdfViewer = lazy(() =>
199
220
 
200
221
  <DocumentToolsProvider
201
222
  client={arbi.getClient().fetch}
202
- deploymentDomain={deploymentDomain}
203
223
  user={{ name: 'Ana Lopez', email: 'ana@firm.example' }}
204
224
  notify={(message, kind) => toast[kind](message)}
205
225
  openDocument={(ref) => navigate(`/documents/${ref}`)}
206
226
  onDocumentsChanged={() => queryClient.invalidateQueries({ queryKey: ['documents'] })}
227
+ certificateUrl={(ref) => `${location.origin}/verify/${ref}`}
207
228
  >
208
229
  <DocumentPage doc={doc} pdf={pdfBlob} />
209
230
  </DocumentToolsProvider>
@@ -237,9 +258,64 @@ editor of a signed version ("Editing creates a new unsigned version").
237
258
 
238
259
  `AnnotatedPdfViewer` and `SignaturePlacementViewer` take your own binding of the kit viewer as
239
260
  `viewer` (for example one that reports the visible page); `SignaturePlacementViewer`'s
240
- `onContinue(appearance)` hands the box to `SignDocumentDialog`. Serve `SignatureCertificate` on a
241
- route that needs no sign-in (ARBI uses `/verify/:reference`), inside a `DocumentToolsProvider` with
242
- an unauthenticated client: it is the page the signature on a signed PDF links to.
261
+ `onContinue(appearance)` hands the box to `SignDocumentDialog`.
262
+
263
+ ### Signature certificates
264
+
265
+ Serve `SignatureCertificate` on a route that needs no sign-in (ARBI uses `/verify/:reference`),
266
+ inside a `DocumentToolsProvider` with an unauthenticated client. "View certificate" (in
267
+ `SignatureStatus`, and after signing) opens the provider's `certificateUrl(reference)` when you
268
+ give one, so it lands on your own page; without it, the `certificate_url` the backend returned,
269
+ else `/verify/{reference}` on this origin. The link drawn into the signed PDF itself is set by the
270
+ backend and always points at the deployment domain (`https://{DEPLOYMENT_DOMAIN}/verify/{ref}`):
271
+ serve the certificate page there too, or redirect that path to yours.
272
+
273
+ ### Production sets
274
+
275
+ `ProductionSetDialog` numbers the selected documents with Bates labels (optionally a QR code back
276
+ to each document and an index page), downloads the result (one PDF, or a ZIP with each file and an
277
+ `index.csv`) and saves it to the workspace as new documents derived from all their sources
278
+ (`derived_from` repeated, role `production`) in a Productions folder, shared only if every source
279
+ is. A PDF is numbered as stored, anything else through its `/view` PDF; media are left out. It uses
280
+ the provider's client, `uploadDocument`, `saveFile`, `notify`, `onDocumentsChanged(ids, 'copy')`
281
+ and `openDocument` (its "Open" action); you give it the selection and your deep link:
282
+
283
+ ```tsx
284
+ const ProductionSetDialog = lazy(() =>
285
+ import('@arbidocs/blocks/document-tools/production').then((m) => ({ default: m.ProductionSetDialog })))
286
+
287
+ <ProductionSetDialog open={open} onOpenChange={setOpen} documents={selectedDocs}
288
+ documentUrl={(id) => `${location.origin}/documents/${id}`} />
289
+ ```
290
+
291
+ A custom `uploadDocument` receives the upload query typed from the API schema
292
+ (`DocumentUploadQuery`: `derived_from` is a list, `shared` a boolean). If you post the upload
293
+ yourself (an XHR with progress), build the query string with `uploadQueryString(query)`, which
294
+ repeats `derived_from` for each source; the default, `clientUpload(client)`, does this already.
295
+
296
+ ### The pdf.js runtime
297
+
298
+ The kit `PdfViewer` loads the pdf.js worker and its data from your site: `/pdf.worker.min.mjs`,
299
+ `/cmaps/`, `/standard_fonts/` and `/wasm/` (the JPEG 2000 and JBIG2 decoders: without them
300
+ scanned PDFs render blank). `@arbidocs/blocks` ships a command that copies them from your installed
301
+ `pdfjs-dist` into your public directory, with shims for the newer built-ins pdf.js needs in older
302
+ browsers. It fails if your `pdfjs-dist` differs from the one `react-pdf` runs, which would break
303
+ every PDF with "API version does not match Worker version":
304
+
305
+ ```json
306
+ {
307
+ "scripts": {
308
+ "pdf-assets": "arbidocs-copy-pdf-assets public",
309
+ "predev": "npm run pdf-assets",
310
+ "prebuild": "npm run pdf-assets"
311
+ }
312
+ }
313
+ ```
314
+
315
+ Pin `pdfjs-dist` to the exact version `react-pdf` depends on, and keep the copied files out of
316
+ version control (`public/pdf.worker*.mjs`, `public/cmaps/`, `public/standard_fonts/`,
317
+ `public/wasm/`). `--images` also copies the pdf.js annotation icons to `/images/`. To serve them
318
+ elsewhere, pass `assets` (`workerSrc`, `cMapUrl`, `standardFontDataUrl`, `wasmUrl`) to the viewer.
243
319
 
244
320
  ## Editorial site parts
245
321
 
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * arbidocs-copy-pdf-assets <publicDir> [--images]
4
+ *
5
+ * Serve the pdf.js runtime the document tools' PDF viewer loads (the kit `PdfViewer` of
6
+ * @arbidocs/react/viewers, whose default asset paths these are):
7
+ *
8
+ * /pdf.worker.min.mjs, /pdf.worker.mjs the worker, with shims for newer built-ins
9
+ * /cmaps/ character maps (CJK and other non-embedded encodings)
10
+ * /standard_fonts/ the standard 14 fonts
11
+ * /wasm/ JPEG 2000 / JBIG2 / colour decoders: without them a
12
+ * scanned PDF renders blank white pages
13
+ * /images/ (with --images) pdf.js annotation icons
14
+ *
15
+ * Copied from the pdfjs-dist installed for the app (resolved from the current directory), so the
16
+ * worker always matches the library react-pdf runs: a mismatch fails every PDF with "API version
17
+ * does not match Worker version". Run it before dev and build, e.g. in `predev` / `prebuild`.
18
+ *
19
+ * The worker gets small shims for the newer built-ins pdf.js 5+ relies on (Uint8Array hex,
20
+ * Map.prototype.getOrInsertComputed, Math.sumPrecise); each steps aside where the browser has the
21
+ * real one. Without them older browsers fail to parse ("x.toHex is not a function") or draw no
22
+ * pages at all.
23
+ */
24
+
25
+ import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
26
+ import { createRequire } from 'node:module'
27
+ import { dirname, join, resolve } from 'node:path'
28
+
29
+ const args = process.argv.slice(2)
30
+ const withImages = args.includes('--images')
31
+ const target = args.find((arg) => !arg.startsWith('--'))
32
+ if (!target || args.includes('--help')) {
33
+ console.error('Usage: arbidocs-copy-pdf-assets <publicDir> [--images]')
34
+ process.exit(target ? 0 : 1)
35
+ }
36
+
37
+ // Resolve from the app (the current directory), not from this package: the app's pdfjs-dist is
38
+ // the one its bundle runs.
39
+ const appRequire = createRequire(join(process.cwd(), 'package.json'))
40
+ let pdfjsRoot
41
+ try {
42
+ pdfjsRoot = dirname(appRequire.resolve('pdfjs-dist/package.json'))
43
+ } catch {
44
+ console.error('arbidocs-copy-pdf-assets: pdfjs-dist is not installed (npm install pdfjs-dist)')
45
+ process.exit(1)
46
+ }
47
+ const versionOf = (dir) => JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8')).version
48
+
49
+ // react-pdf may use a nested copy of pdfjs-dist; the worker must match that one.
50
+ try {
51
+ const reactPdfRequire = createRequire(appRequire.resolve('react-pdf'))
52
+ const reactPdfPdfjs = dirname(reactPdfRequire.resolve('pdfjs-dist/package.json'))
53
+ if (versionOf(reactPdfPdfjs) !== versionOf(pdfjsRoot)) {
54
+ console.error(
55
+ `arbidocs-copy-pdf-assets: pdfjs-dist ${versionOf(pdfjsRoot)} differs from the ` +
56
+ `${versionOf(reactPdfPdfjs)} react-pdf uses. Pin "pdfjs-dist" to ` +
57
+ `"${versionOf(reactPdfPdfjs)}" (no ^) in package.json and reinstall.`
58
+ )
59
+ process.exit(1)
60
+ }
61
+ } catch {
62
+ // No react-pdf installed: nothing to match.
63
+ }
64
+
65
+ const SHIMS = `
66
+ if (typeof Uint8Array.prototype.toHex !== 'function') {
67
+ Object.defineProperty(Uint8Array.prototype, 'toHex', { configurable: true, writable: true,
68
+ value() { let s = ''; for (let i = 0; i < this.length; i++) s += this[i].toString(16).padStart(2, '0'); return s; } });
69
+ }
70
+ if (typeof Uint8Array.fromHex !== 'function') {
71
+ Object.defineProperty(Uint8Array, 'fromHex', { configurable: true, writable: true,
72
+ value(hex) { const h = hex.replace(/\\s+/g, ''); if (h.length % 2) throw new SyntaxError('Uint8Array.fromHex: odd length');
73
+ const out = new Uint8Array(h.length / 2);
74
+ for (let i = 0; i < out.length; i++) { const b = parseInt(h.slice(i * 2, i * 2 + 2), 16);
75
+ if (Number.isNaN(b)) throw new SyntaxError('Uint8Array.fromHex: non-hex digit'); out[i] = b; }
76
+ return out; } });
77
+ }
78
+ if (typeof Map.prototype.getOrInsertComputed !== 'function') {
79
+ Object.defineProperty(Map.prototype, 'getOrInsertComputed', { configurable: true, writable: true,
80
+ value(key, make) { if (this.has(key)) return this.get(key); const v = make(key); this.set(key, v); return v; } });
81
+ }
82
+ if (typeof Math.sumPrecise !== 'function') {
83
+ Object.defineProperty(Math, 'sumPrecise', { configurable: true, writable: true,
84
+ value(values) { let sum = 0, c = 0; for (const v of values) { const t = sum + v;
85
+ c += Math.abs(sum) >= Math.abs(v) ? sum - t + v : v - t + sum; sum = t; } return sum + c; } });
86
+ }
87
+ `
88
+
89
+ const publicDir = resolve(target)
90
+ mkdirSync(publicDir, { recursive: true })
91
+ for (const name of ['pdf.worker.min.mjs', 'pdf.worker.mjs']) {
92
+ const source = readFileSync(join(pdfjsRoot, 'build', name), 'utf8')
93
+ writeFileSync(join(publicDir, name), SHIMS + source)
94
+ }
95
+ const dirs = [
96
+ ['cmaps', 'cmaps'],
97
+ ['standard_fonts', 'standard_fonts'],
98
+ ['wasm', 'wasm'],
99
+ ...(withImages ? [['web/images', 'images']] : []),
100
+ ]
101
+ for (const [from, to] of dirs) {
102
+ const source = join(pdfjsRoot, from)
103
+ if (!existsSync(source)) {
104
+ console.error(`arbidocs-copy-pdf-assets: pdfjs-dist ${versionOf(pdfjsRoot)} has no ${from}/`)
105
+ process.exit(1)
106
+ }
107
+ cpSync(source, join(publicDir, to), { recursive: true })
108
+ }
109
+ console.log(
110
+ `pdf.js ${versionOf(pdfjsRoot)} worker, ${dirs.map(([, to]) => `${to}/`).join(', ')} ` +
111
+ `copied to ${publicDir}`
112
+ )
@@ -3,6 +3,7 @@ import { ArtifactMarkdownEditor } from './chunk-NEFHQHQV.js';
3
3
  import { ArtifactEditor, ArtifactRedlineView } from './chunk-65HZ36MY.js';
4
4
  import './chunk-LOJVUGBJ.js';
5
5
  import './chunk-7F6CBP3Z.js';
6
+ import './chunk-VUNV25KB.js';
6
7
  import { useState } from 'react';
7
8
  import { Copy, Download } from 'lucide-react';
8
9
  import { Button, cn } from '@arbidocs/react/ui';
@@ -100,5 +101,5 @@ function StreamedArtifactEditor({
100
101
  }
101
102
 
102
103
  export { StreamedArtifactEditor as default };
103
- //# sourceMappingURL=StreamedArtifactEditor-OPL4KXOT.js.map
104
- //# sourceMappingURL=StreamedArtifactEditor-OPL4KXOT.js.map
104
+ //# sourceMappingURL=StreamedArtifactEditor-HTNPG4NB.js.map
105
+ //# sourceMappingURL=StreamedArtifactEditor-HTNPG4NB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/connection/StreamedArtifactEditor.tsx"],"names":[],"mappings":";;;;;;;;;;;AAmCe,SAAR,sBAAA,CAAwC;AAAA,EAC7C,WAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA,OAAA;AAAA,EACA,WAAA;AAAA,EACA,OAAA;AAAA,EACA,kBAAA;AAAA,EACA;AACF,CAAA,EAAgC;AAC9B,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAI,SAAS,KAAK,CAAA;AAC1C,EAAA,MAAM,IAAI,kBAAA,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or-HTNPG4NB.js","sourcesContent":["import { useState, type ReactNode } from 'react'\nimport { Copy, Download } from 'lucide-react'\nimport { Button, cn } from '@arbidocs/react/ui'\nimport { renderArtifactMarkdown, useArtifactSession } from '@arbidocs/react/artifacts'\nimport { ArtifactEditor, ArtifactRedlineView, type ArtifactEditorLabels } from '../artifacts'\nimport {\n ArtifactMarkdownEditor,\n type ArtifactMarkdownEditorProps,\n} from '../artifacts/editor/ArtifactMarkdownEditor'\n\nexport interface StreamedArtifactEditorProps {\n workspaceId: string | undefined\n /** The stored first version (the lineage's root as far as this panel goes). */\n docId: string\n /** File name for the versions saved from here. */\n title: string\n testId: string\n className?: string\n /** Extra props of the rich-text editor (`dictation`, labels). */\n editorProps?: Partial<Omit<ArtifactMarkdownEditorProps, 'markdown' | 'onChange' | 'onNormalized'>>\n /** Called after a version is saved. */\n onSaved?: (docId: string | undefined) => void\n onSaveError?: (error: unknown) => void\n /** Extra header actions next to the toolbar. */\n actions?: (ctx: { content: string; title: string }) => ReactNode\n /** Hide the default Copy and Download buttons. */\n hideDefaultActions?: boolean\n labels?: Partial<ArtifactEditorLabels>\n}\n\n/**\n * The editing stage of `StreamedArtifact`: `ArtifactEditor` bound to `useArtifactSession`. It is\n * a separate module because it pulls the rich-text editor (Lexical), which must stay behind a\n * `lazy()` boundary.\n */\nexport default function StreamedArtifactEditor({\n workspaceId,\n docId,\n title,\n testId,\n className,\n editorProps,\n onSaved,\n onSaveError,\n actions,\n hideDefaultActions,\n labels,\n}: StreamedArtifactEditorProps) {\n const [openId, setOpenId] = useState(docId)\n const s = useArtifactSession({\n workspaceId,\n docId: openId,\n title,\n onSaved: ({ docId: next }) => {\n if (next) setOpenId(next)\n onSaved?.(next)\n },\n onSaveError,\n })\n\n const copy = () => void navigator.clipboard.writeText(s.content)\n const download = () => {\n const url = URL.createObjectURL(new Blob([s.content], { type: 'text/markdown' }))\n const a = document.createElement('a')\n a.href = url\n a.download = `${title.replace(/\\.md$/i, '')}.md`\n a.click()\n URL.revokeObjectURL(url)\n }\n\n return (\n <div\n className={cn(\n 'flex min-h-[560px] flex-col rounded-xl border border-border bg-card',\n className\n )}\n data-testid={testId}\n >\n <ArtifactEditor\n {...s.view}\n className=\"min-h-[560px] flex-1\"\n labels={labels}\n onOpenVersion={setOpenId}\n renderMarkdown={renderArtifactMarkdown}\n editor={<ArtifactMarkdownEditor {...editorProps} {...s.editorProps} />}\n redline={\n <ArtifactRedlineView {...s.redlineProps} renderMarkdown={renderArtifactMarkdown} />\n }\n actions={\n <>\n {!hideDefaultActions && (\n <>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={copy}\n data-testid={`${testId}-copy`}\n className=\"pointer-coarse:min-h-11\"\n >\n <Copy className=\"size-4\" aria-hidden /> Copy\n </Button>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={download}\n data-testid={`${testId}-download`}\n className=\"pointer-coarse:min-h-11\"\n >\n <Download className=\"size-4\" aria-hidden /> Download\n </Button>\n </>\n )}\n {actions?.({ content: s.content, title })}\n </>\n }\n />\n </div>\n )\n}\n"]}
@@ -5,6 +5,7 @@ var chunkQS4RV3MA_cjs = require('./chunk-QS4RV3MA.cjs');
5
5
  var chunkSVJQWLOF_cjs = require('./chunk-SVJQWLOF.cjs');
6
6
  require('./chunk-QVBZESYQ.cjs');
7
7
  require('./chunk-MHVNT4J3.cjs');
8
+ require('./chunk-DES3K4SD.cjs');
8
9
  var react = require('react');
9
10
  var lucideReact = require('lucide-react');
10
11
  var ui = require('@arbidocs/react/ui');
@@ -102,5 +103,5 @@ function StreamedArtifactEditor({
102
103
  }
103
104
 
104
105
  module.exports = StreamedArtifactEditor;
105
- //# sourceMappingURL=StreamedArtifactEditor-RIKG6CJQ.cjs.map
106
- //# sourceMappingURL=StreamedArtifactEditor-RIKG6CJQ.cjs.map
106
+ //# sourceMappingURL=StreamedArtifactEditor-IZWYNFMM.cjs.map
107
+ //# sourceMappingURL=StreamedArtifactEditor-IZWYNFMM.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/connection/StreamedArtifactEditor.tsx"],"names":["useState","useArtifactSession","jsx","cn","ArtifactEditor","renderArtifactMarkdown","ArtifactMarkdownEditor","ArtifactRedlineView","jsxs","Fragment","Button","Copy","Download"],"mappings":";;;;;;;;;;;;;AAmCe,SAAR,sBAAA,CAAwC;AAAA,EAC7C,WAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA,OAAA;AAAA,EACA,WAAA;AAAA,EACA,OAAA;AAAA,EACA,kBAAA;AAAA,EACA;AACF,CAAA,EAAgC;AAC9B,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAIA,eAAS,KAAK,CAAA;AAC1C,EAAA,MAAM,IAAIC,4BAAA,CAAmB;AAAA,IAC3B,WAAA;AAAA,IACA,KAAA,EAAO,MAAA;AAAA,IACP,KAAA;AAAA,IACA,OAAA,EAAS,CAAC,EAAE,KAAA,EAAO,MAAK,KAAM;AAC5B,MAAA,IAAI,IAAA,YAAgB,IAAI,CAAA;AACxB,MAAA,OAAA,GAAU,IAAI,CAAA;AAAA,IAChB,CAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,MAAM,OAAO,MAAM,KAAK,UAAU,SAAA,CAAU,SAAA,CAAU,EAAE,OAAO,CAAA;AAC/D,EAAA,MAAM,WAAW,MAAM;AACrB,IAAA,MAAM,GAAA,GAAM,GAAA,CAAI,eAAA,CAAgB,IAAI,IAAA,CAAK,CAAC,CAAA,CAAE,OAAO,CAAA,EAAG,EAAE,IAAA,EAAM,eAAA,EAAiB,CAAC,CAAA;AAChF,IAAA,MAAM,CAAA,GAAI,QAAA,CAAS,aAAA,CAAc,GAAG,CAAA;AACpC,IAAA,CAAA,CAAE,IAAA,GAAO,GAAA;AACT,IAAA,CAAA,CAAE,WAAW,CAAA,EAAG,KAAA,CAAM,OAAA,CAAQ,QAAA,EA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;AAAA,8BACAH,eAAA;AAAA,gBAACE,SAAA;AAAA,gBAAA;AAAA,kBACC,OAAA,EAAQ,OAAA;AAAA,kBACR,IAAA,EAAK,IAAA;AAAA,kBACL,OAAA,EAAS,QAAA;AAAA,kBACT,aAAA,EAAa,GAAG,MAAM,CAAA,SAAA,CAAA;AAAA,kBACtB,SAAA,EAAU,yBAAA;AAAA,kBAEV,QAAA,EAAA;AAAA,oCAAAR,cAAA,CAACU,oBAAA,EAAA,EAAS,SAAA,EAAU,QAAA,EAAS,aAAA,EAAW,IAAA,EAAC,CAAA;AAAA,oBAAE;AAAA;AAAA;AAAA;AAC7C,aAAA,EACF,CAAA;AAAA,YAED,UAAU,EAAE,OAAA,EAAS,CAAA,CAAE,OAAA,EAAS,OAAO;AAAA,WAAA,EAC1C;AAAA;AAAA;AAEJ;AAAA,GACF;AAEJ","file":"StreamedArtifactEditor-IZWYNFMM.cjs","sourcesContent":["import { useState, type ReactNode } from 'react'\nimport { Copy, Download } from 'lucide-react'\nimport { Button, cn } from '@arbidocs/react/ui'\nimport { renderArtifactMarkdown, useArtifactSession } from '@arbidocs/react/artifacts'\nimport { ArtifactEditor, ArtifactRedlineView, type ArtifactEditorLabels } from '../artifacts'\nimport {\n ArtifactMarkdownEditor,\n type ArtifactMarkdownEditorProps,\n} from '../artifacts/editor/ArtifactMarkdownEditor'\n\nexport interface StreamedArtifactEditorProps {\n workspaceId: string | undefined\n /** The stored first version (the lineage's root as far as this panel goes). */\n docId: string\n /** File name for the versions saved from here. */\n title: string\n testId: string\n className?: string\n /** Extra props of the rich-text editor (`dictation`, labels). */\n editorProps?: Partial<Omit<ArtifactMarkdownEditorProps, 'markdown' | 'onChange' | 'onNormalized'>>\n /** Called after a version is saved. */\n onSaved?: (docId: string | undefined) => void\n onSaveError?: (error: unknown) => void\n /** Extra header actions next to the toolbar. */\n actions?: (ctx: { content: string; title: string }) => ReactNode\n /** Hide the default Copy and Download buttons. */\n hideDefaultActions?: boolean\n labels?: Partial<ArtifactEditorLabels>\n}\n\n/**\n * The editing stage of `StreamedArtifact`: `ArtifactEditor` bound to `useArtifactSession`. It is\n * a separate module because it pulls the rich-text editor (Lexical), which must stay behind a\n * `lazy()` boundary.\n */\nexport default function StreamedArtifactEditor({\n workspaceId,\n docId,\n title,\n testId,\n className,\n editorProps,\n onSaved,\n onSaveError,\n actions,\n hideDefaultActions,\n labels,\n}: StreamedArtifactEditorProps) {\n const [openId, setOpenId] = useState(docId)\n const s = useArtifactSession({\n workspaceId,\n docId: openId,\n title,\n onSaved: ({ docId: next }) => {\n if (next) setOpenId(next)\n onSaved?.(next)\n },\n onSaveError,\n })\n\n const copy = () => void navigator.clipboard.writeText(s.content)\n const download = () => {\n const url = URL.createObjectURL(new Blob([s.content], { type: 'text/markdown' }))\n const a = document.createElement('a')\n a.href = url\n a.download = `${title.replace(/\\.md$/i, '')}.md`\n a.click()\n URL.revokeObjectURL(url)\n }\n\n return (\n <div\n className={cn(\n 'flex min-h-[560px] flex-col rounded-xl border border-border bg-card',\n className\n )}\n data-testid={testId}\n >\n <ArtifactEditor\n {...s.view}\n className=\"min-h-[560px] flex-1\"\n labels={labels}\n onOpenVersion={setOpenId}\n renderMarkdown={renderArtifactMarkdown}\n editor={<ArtifactMarkdownEditor {...editorProps} {...s.editorProps} />}\n redline={\n <ArtifactRedlineView {...s.redlineProps} renderMarkdown={renderArtifactMarkdown} />\n }\n actions={\n <>\n {!hideDefaultActions && (\n <>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={copy}\n data-testid={`${testId}-copy`}\n className=\"pointer-coarse:min-h-11\"\n >\n <Copy className=\"size-4\" aria-hidden /> Copy\n </Button>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={download}\n data-testid={`${testId}-download`}\n className=\"pointer-coarse:min-h-11\"\n >\n <Download className=\"size-4\" aria-hidden /> Download\n </Button>\n </>\n )}\n {actions?.({ content: s.content, title })}\n </>\n }\n />\n </div>\n )\n}\n"]}