web-doc 0.7.0 → 0.9.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 (65) hide show
  1. package/THIRD_PARTY_NOTICES.md +10 -3
  2. package/dist/contracts.d.ts +6 -0
  3. package/dist/edit/ai/outline.d.ts +47 -0
  4. package/dist/edit/ai/outline.js +338 -0
  5. package/dist/edit/ai/targets.d.ts +16 -0
  6. package/dist/edit/ai/targets.js +309 -0
  7. package/dist/edit/ai/tools.d.ts +28 -0
  8. package/dist/edit/ai/tools.js +607 -0
  9. package/dist/edit/ai/types.d.ts +175 -0
  10. package/dist/edit/ai/types.js +1 -0
  11. package/dist/edit/docx/elements.js +19 -1
  12. package/dist/edit/docx/engine.d.ts +10 -4
  13. package/dist/edit/docx/engine.js +80 -6
  14. package/dist/edit/docx/model.d.ts +2 -0
  15. package/dist/edit/docx/model.js +11 -0
  16. package/dist/edit/docx/operations.d.ts +10 -0
  17. package/dist/edit/docx/provider.d.ts +4 -1
  18. package/dist/edit/docx/provider.js +3 -0
  19. package/dist/edit/docx/session.d.ts +12 -1
  20. package/dist/edit/docx/session.js +41 -0
  21. package/dist/edit/docx/structure-ops.js +39 -4
  22. package/dist/edit/docx/table-ops.js +26 -4
  23. package/dist/edit/docx/text-ops.d.ts +22 -0
  24. package/dist/edit/docx/text-ops.js +49 -16
  25. package/dist/edit/docx/text.js +21 -0
  26. package/dist/edit/docx/tracked.d.ts +52 -0
  27. package/dist/edit/docx/tracked.js +347 -0
  28. package/dist/edit/docx/types.d.ts +24 -1
  29. package/dist/edit/docx/write.d.ts +19 -5
  30. package/dist/edit/docx/write.js +31 -8
  31. package/dist/edit/engine.d.ts +14 -3
  32. package/dist/edit/history.d.ts +27 -3
  33. package/dist/edit/history.js +29 -7
  34. package/dist/edit/pdf/engine/document.js +48 -3
  35. package/dist/edit/pdf/engine/elements.d.ts +6 -0
  36. package/dist/edit/pdf/engine/fonts.js +13 -10
  37. package/dist/edit/pdf/engine/pages.js +9 -1
  38. package/dist/edit/pdf/range-map.d.ts +4 -2
  39. package/dist/edit/pdf/schemas.js +4 -1
  40. package/dist/edit/pdf/session.d.ts +10 -0
  41. package/dist/edit/pdf/session.js +39 -0
  42. package/dist/edit/pdf/types.d.ts +15 -3
  43. package/dist/edit/pptx/handler.js +10 -2
  44. package/dist/edit/pptx/session.d.ts +10 -0
  45. package/dist/edit/pptx/session.js +31 -0
  46. package/dist/edit/session.d.ts +11 -0
  47. package/dist/edit/session.js +269 -27
  48. package/dist/edit/types.d.ts +17 -3
  49. package/dist/edit/worker-engine.d.ts +2 -2
  50. package/dist/edit/worker-engine.js +2 -2
  51. package/dist/fonts/THIRD_PARTY_NOTICES.md +6 -3
  52. package/dist/fonts/manifest.json +4 -4
  53. package/dist/fonts/noto-sans-latin-cyrillic.ttf +0 -0
  54. package/dist/fuzzy-alignment.d.ts +11 -4
  55. package/dist/fuzzy-alignment.js +3 -9
  56. package/dist/headless.d.ts +1 -1
  57. package/dist/headless.js +4 -1
  58. package/dist/index.d.ts +5 -2
  59. package/dist/index.js +11 -2
  60. package/dist/limits.js +3 -0
  61. package/dist/worker-protocol.d.ts +1 -1
  62. package/dist/workers/fuzzy-search-worker.js +1 -1
  63. package/dist/workers/ooxml-edit-worker.js +1415 -860
  64. package/dist/workers/pdf-edit-worker.js +64 -16
  65. package/package.json +1 -1
@@ -6,7 +6,14 @@
6
6
  * than a page × query traceback matrix. Equal-cost occurrences prefer the
7
7
  * earliest end, so an unmatched character after a passage cannot extend it.
8
8
  */
9
- export declare function alignFuzzyPassage(text: string, query: string, caseSensitive: boolean, maxScore: number): {
10
- start: number;
11
- end: number;
12
- } | undefined;
9
+ /** The best contiguous alignment of a query in a text, with its edit cost. */
10
+ export interface FuzzyPassage {
11
+ /** Offsets into the original text, in UTF-16 code units. */
12
+ readonly start: number;
13
+ readonly end: number;
14
+ /** Edits between the query and the passage; `cost / length` is the score Fuse bounds. */
15
+ readonly cost: number;
16
+ /** The normalized query's length. */
17
+ readonly length: number;
18
+ }
19
+ export declare function alignFuzzyPassage(text: string, query: string, caseSensitive: boolean, maxScore: number): FuzzyPassage | undefined;
@@ -1,12 +1,4 @@
1
1
  import { normalizeSearchText, normalizeWithMap } from "./search-text.js";
2
- /**
3
- * Fuse's indices describe character masks, not a contiguous edit alignment.
4
- * Refine an accepted page with semi-global Levenshtein alignment: consume the
5
- * whole query, allowing free text before and after one occurrence. Tracking
6
- * the start alongside each cost needs O(query length) working memory rather
7
- * than a page × query traceback matrix. Equal-cost occurrences prefer the
8
- * earliest end, so an unmatched character after a passage cannot extend it.
9
- */
10
2
  export function alignFuzzyPassage(text, query, caseSensitive, maxScore) {
11
3
  const source = normalizeWithMap(text, caseSensitive);
12
4
  const pattern = normalizeSearchText(query, caseSensitive);
@@ -59,5 +51,7 @@ export function alignFuzzyPassage(text, query, caseSensitive, maxScore) {
59
51
  return undefined;
60
52
  const start = source.starts[bestStart];
61
53
  const end = source.ends[bestEnd - 1];
62
- return start === undefined || end === undefined ? undefined : { start, end };
54
+ return start === undefined || end === undefined
55
+ ? undefined
56
+ : { start, end, cost: bestCost, length };
63
57
  }
@@ -6,7 +6,7 @@ export * from "./edit/pptx/types.js";
6
6
  export * from "./client.js";
7
7
  export * from "./viewer.js";
8
8
  export * from "./detect.js";
9
- export * from "./errors.js";
9
+ export { abortError, errorFromData, normalizeError, ViewerError, } from "./errors.js";
10
10
  export * from "./format.js";
11
11
  export * from "./limits.js";
12
12
  export * from "./interaction.js";
package/dist/headless.js CHANGED
@@ -6,7 +6,10 @@ export * from "./edit/pptx/types.js";
6
6
  export * from "./client.js";
7
7
  export * from "./viewer.js";
8
8
  export * from "./detect.js";
9
- export * from "./errors.js";
9
+ // Named on purpose: a bundler that inlines the lazily loaded edit engines
10
+ // (esbuild without code splitting) initialises this module lazily, and a
11
+ // star re-export would then hand a consumer an undefined class.
12
+ export { abortError, errorFromData, normalizeError, ViewerError, } from "./errors.js";
10
13
  export * from "./format.js";
11
14
  export * from "./limits.js";
12
15
  export * from "./interaction.js";
package/dist/index.d.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  export * from "./contracts.js";
2
2
  export * from "./edit/types.js";
3
+ export * from "./edit/ai/types.js";
4
+ export { describeReceipt } from "./edit/ai/tools.js";
3
5
  export * from "./edit/sessions.js";
4
6
  export * from "./edit/pdf/types.js";
5
7
  export * from "./edit/pptx/types.js";
6
8
  export * from "./edit/docx/types.js";
7
9
  export * from "./client.js";
8
10
  export * from "./detect.js";
9
- export * from "./errors.js";
11
+ export { abortError, errorFromData, normalizeError, ViewerError, } from "./errors.js";
10
12
  export * from "./format.js";
11
13
  export * from "./limits.js";
12
14
  export * from "./interaction.js";
@@ -23,7 +25,8 @@ export * from "./ui.js";
23
25
  export * from "./ui-styles.js";
24
26
  export * from "./registry.js";
25
27
  export * from "./viewer.js";
26
- export * from "./worker-client.js";
28
+ export { WorkerRpcClient } from "./worker-client.js";
29
+ export type { WorkerLike, WorkerRequestOptions } from "./worker-client.js";
27
30
  export * from "./worker-adapter.js";
28
31
  export * from "./worker-endpoint.js";
29
32
  export * from "./worker-protocol.js";
package/dist/index.js CHANGED
@@ -1,12 +1,17 @@
1
1
  export * from "./contracts.js";
2
2
  export * from "./edit/types.js";
3
+ export * from "./edit/ai/types.js";
4
+ export { describeReceipt } from "./edit/ai/tools.js";
3
5
  export * from "./edit/sessions.js";
4
6
  export * from "./edit/pdf/types.js";
5
7
  export * from "./edit/pptx/types.js";
6
8
  export * from "./edit/docx/types.js";
7
9
  export * from "./client.js";
8
10
  export * from "./detect.js";
9
- export * from "./errors.js";
11
+ // Named like the worker client below: the error class is reached from the
12
+ // lazily loaded engines too and must not come out undefined in a consumer
13
+ // bundle without code splitting.
14
+ export { abortError, errorFromData, normalizeError, ViewerError, } from "./errors.js";
10
15
  export * from "./format.js";
11
16
  export * from "./limits.js";
12
17
  export * from "./interaction.js";
@@ -23,7 +28,11 @@ export * from "./ui.js";
23
28
  export * from "./ui-styles.js";
24
29
  export * from "./registry.js";
25
30
  export * from "./viewer.js";
26
- export * from "./worker-client.js";
31
+ // Named on purpose: a bundler that inlines the lazily loaded edit engines
32
+ // (esbuild without code splitting) initialises this module lazily, and a
33
+ // star re-export would then hand a consumer an undefined class
34
+ // (`scripts/consumer-bundle.test.mjs` guards every class and constant).
35
+ export { WorkerRpcClient } from "./worker-client.js";
27
36
  export * from "./worker-adapter.js";
28
37
  export * from "./worker-endpoint.js";
29
38
  export * from "./worker-protocol.js";
package/dist/limits.js CHANGED
@@ -13,6 +13,9 @@ export const defaultResourceLimits = Object.freeze({
13
13
  maxEditOperations: 500,
14
14
  maxEditHistory: 200,
15
15
  maxEditCheckpointBytes: 64 * 1024 * 1024,
16
+ maxOutlineNodes: 5000,
17
+ maxDescribeChars: 200_000,
18
+ maxEditCheckpoints: 20,
16
19
  });
17
20
  export function resolveLimits(base = {}, override = {}) {
18
21
  const result = { ...defaultResourceLimits, ...base, ...override };
@@ -2,7 +2,7 @@ import type { DocumentFormat, DocumentInfo, ResourceLimits, TextRun, ViewerError
2
2
  import type { EditableFormat } from "./edit/types.js";
3
3
  export type DocumentWorkerOperation = "init" | "open" | "get-info" | "render" | "get-text-map" | "close" | "destroy";
4
4
  /** Operations of an edit engine worker; payloads mirror the engine interface. */
5
- export type EditWorkerOperation = "edit-init" | "edit-open" | "edit-validate" | "edit-apply" | "edit-materialize" | "edit-restore" | "edit-put-asset" | "edit-elements" | "edit-element" | "edit-elements-at" | "edit-find-text" | "edit-text-layout" | "edit-position-at" | "edit-range-rects" | "edit-render-without" | "edit-page-layout" | "edit-pptx-slides" | "edit-pptx-layouts" | "edit-dispose";
5
+ export type EditWorkerOperation = "edit-init" | "edit-open" | "edit-validate" | "edit-apply" | "edit-materialize" | "edit-restore" | "edit-put-asset" | "edit-elements" | "edit-element" | "edit-elements-at" | "edit-find-text" | "edit-text-layout" | "edit-position-at" | "edit-range-rects" | "edit-render-without" | "edit-page-layout" | "edit-pptx-slides" | "edit-pptx-layouts" | "edit-docx-revisions" | "edit-dispose";
6
6
  export type WorkerOperation = DocumentWorkerOperation | EditWorkerOperation;
7
7
  export interface WorkerRequest {
8
8
  readonly kind: "request";
@@ -1634,7 +1634,7 @@ function alignFuzzyPassage(text, query, caseSensitive, maxScore) {
1634
1634
  if (bestEnd <= bestStart || bestCost / length > maxScore) return void 0;
1635
1635
  const start = source.starts[bestStart];
1636
1636
  const end = source.ends[bestEnd - 1];
1637
- return start === void 0 || end === void 0 ? void 0 : { start, end };
1637
+ return start === void 0 || end === void 0 ? void 0 : { start, end, cost: bestCost, length };
1638
1638
  }
1639
1639
 
1640
1640
  // src/fuzzy-search.ts