@twip/web 0.1.0-alpha.1 → 0.1.0-pre.1

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 +35 -0
  2. package/dist/THIRD-PARTY-NOTICES.md +1009 -221
  3. package/dist/commands.d.ts +637 -0
  4. package/dist/commands.js +188 -0
  5. package/dist/editor.d.ts +218 -0
  6. package/dist/editor.js +460 -0
  7. package/dist/errors.d.ts +21 -0
  8. package/dist/errors.js +26 -0
  9. package/dist/events.d.ts +126 -0
  10. package/dist/events.js +1 -0
  11. package/dist/fonts/google.d.ts +3 -0
  12. package/dist/fonts/google.js +39 -0
  13. package/dist/fonts/library.d.ts +65 -0
  14. package/dist/fonts/library.js +130 -0
  15. package/dist/host/a11y.d.ts +3 -0
  16. package/dist/host/a11y.js +62 -0
  17. package/dist/host/chrome.d.ts +28 -0
  18. package/dist/host/chrome.js +144 -0
  19. package/dist/host/clipboard.d.ts +16 -0
  20. package/dist/host/clipboard.js +128 -0
  21. package/dist/host/dom.d.ts +45 -0
  22. package/dist/host/dom.js +122 -0
  23. package/dist/host/frames.d.ts +14 -0
  24. package/dist/host/frames.js +87 -0
  25. package/dist/host/gpu.d.ts +58 -0
  26. package/dist/host/gpu.js +79 -0
  27. package/dist/host/ime.d.ts +3 -0
  28. package/dist/host/ime.js +11 -0
  29. package/dist/host/input.d.ts +12 -0
  30. package/dist/host/input.js +86 -0
  31. package/dist/host/keys.d.ts +16 -0
  32. package/dist/host/keys.js +27 -0
  33. package/dist/host/mount.d.ts +11 -0
  34. package/dist/host/mount.js +72 -0
  35. package/dist/host/pointer.d.ts +4 -0
  36. package/dist/host/pointer.js +171 -0
  37. package/dist/host/scroll.d.ts +14 -0
  38. package/dist/host/scroll.js +95 -0
  39. package/dist/index.d.ts +27 -98
  40. package/dist/index.js +10 -0
  41. package/dist/review.d.ts +156 -0
  42. package/dist/review.js +38 -0
  43. package/dist/services/accessibility.d.ts +52 -0
  44. package/dist/services/accessibility.js +71 -0
  45. package/dist/services/dialogs.d.ts +181 -0
  46. package/dist/services/dialogs.js +18 -0
  47. package/dist/services/elements.d.ts +146 -0
  48. package/dist/services/elements.js +18 -0
  49. package/dist/services/find.d.ts +50 -0
  50. package/dist/services/find.js +12 -0
  51. package/dist/services/menus.d.ts +82 -0
  52. package/dist/services/menus.js +8 -0
  53. package/dist/services/navigation.d.ts +58 -0
  54. package/dist/services/navigation.js +12 -0
  55. package/dist/services/ruler.d.ts +95 -0
  56. package/dist/services/ruler.js +16 -0
  57. package/dist/services/spelling.d.ts +34 -0
  58. package/dist/services/spelling.js +14 -0
  59. package/dist/services/view.d.ts +70 -0
  60. package/dist/services/view.js +19 -0
  61. package/dist/state.d.ts +483 -0
  62. package/dist/state.js +1 -0
  63. package/dist/transport/direct.d.ts +31 -0
  64. package/dist/transport/direct.js +405 -0
  65. package/dist/transport/module.d.ts +51 -0
  66. package/dist/transport/module.js +17 -0
  67. package/dist/transport/protocol.d.ts +265 -0
  68. package/dist/transport/protocol.js +132 -0
  69. package/dist/transport/worker.d.ts +54 -0
  70. package/dist/transport/worker.js +203 -0
  71. package/dist/twip-wasm.js +1 -1
  72. package/dist/twip_wasm.wasm +0 -0
  73. package/dist/types.d.ts +134 -0
  74. package/dist/types.js +16 -0
  75. package/dist/worker/entry.d.ts +1 -0
  76. package/dist/worker/entry.js +53 -0
  77. package/dist/worker.d.ts +1 -0
  78. package/dist/worker.js +2 -0
  79. package/package.json +12 -7
  80. package/dist/AccessibleNode.d.ts +0 -51
  81. package/dist/AccessibleNode.mjs +0 -177
  82. package/dist/Alignment.d.ts +0 -38
  83. package/dist/Alignment.mjs +0 -90
  84. package/dist/BorderEdges.d.ts +0 -50
  85. package/dist/BorderEdges.mjs +0 -114
  86. package/dist/BorderStyle.d.ts +0 -27
  87. package/dist/BorderStyle.mjs +0 -81
  88. package/dist/Bytes.d.ts +0 -19
  89. package/dist/Bytes.mjs +0 -76
  90. package/dist/CaretPosition.d.ts +0 -34
  91. package/dist/CaretPosition.mjs +0 -148
  92. package/dist/CellAlignment.d.ts +0 -25
  93. package/dist/CellAlignment.mjs +0 -75
  94. package/dist/CellShift.d.ts +0 -30
  95. package/dist/CellShift.mjs +0 -78
  96. package/dist/Clipboard.d.ts +0 -22
  97. package/dist/Clipboard.mjs +0 -90
  98. package/dist/ColumnSide.d.ts +0 -24
  99. package/dist/ColumnSide.mjs +0 -72
  100. package/dist/ControlKind.d.ts +0 -28
  101. package/dist/ControlKind.mjs +0 -84
  102. package/dist/ControlLock.d.ts +0 -42
  103. package/dist/ControlLock.mjs +0 -96
  104. package/dist/DocumentStatus.d.ts +0 -34
  105. package/dist/DocumentStatus.mjs +0 -148
  106. package/dist/Editor.d.ts +0 -773
  107. package/dist/Editor.mjs +0 -2269
  108. package/dist/EditorMode.d.ts +0 -34
  109. package/dist/EditorMode.mjs +0 -84
  110. package/dist/Element.d.ts +0 -57
  111. package/dist/Element.mjs +0 -201
  112. package/dist/ElementKind.d.ts +0 -28
  113. package/dist/ElementKind.mjs +0 -78
  114. package/dist/ElementList.d.ts +0 -20
  115. package/dist/ElementList.mjs +0 -71
  116. package/dist/ElementText.d.ts +0 -34
  117. package/dist/ElementText.mjs +0 -84
  118. package/dist/Event.d.ts +0 -45
  119. package/dist/Event.mjs +0 -159
  120. package/dist/EventKind.d.ts +0 -39
  121. package/dist/EventKind.mjs +0 -93
  122. package/dist/EventList.d.ts +0 -20
  123. package/dist/EventList.mjs +0 -71
  124. package/dist/Fonts.d.ts +0 -29
  125. package/dist/Fonts.mjs +0 -107
  126. package/dist/Highlight.d.ts +0 -41
  127. package/dist/Highlight.mjs +0 -117
  128. package/dist/MarginPreset.d.ts +0 -38
  129. package/dist/MarginPreset.mjs +0 -90
  130. package/dist/MarkSeverity.d.ts +0 -25
  131. package/dist/MarkSeverity.mjs +0 -75
  132. package/dist/Modifiers.d.ts +0 -34
  133. package/dist/Modifiers.mjs +0 -148
  134. package/dist/OpenError.d.ts +0 -30
  135. package/dist/OpenError.mjs +0 -78
  136. package/dist/Orientation.d.ts +0 -30
  137. package/dist/Orientation.mjs +0 -78
  138. package/dist/PageNumber.d.ts +0 -34
  139. package/dist/PageNumber.mjs +0 -84
  140. package/dist/PaperSize.d.ts +0 -50
  141. package/dist/PaperSize.mjs +0 -108
  142. package/dist/ParagraphBorders.d.ts +0 -34
  143. package/dist/ParagraphBorders.mjs +0 -84
  144. package/dist/PictureWrap.d.ts +0 -34
  145. package/dist/PictureWrap.mjs +0 -90
  146. package/dist/PointerKind.d.ts +0 -23
  147. package/dist/PointerKind.mjs +0 -75
  148. package/dist/Rect.d.ts +0 -34
  149. package/dist/Rect.mjs +0 -148
  150. package/dist/Request.d.ts +0 -55
  151. package/dist/Request.mjs +0 -207
  152. package/dist/RequestKind.d.ts +0 -45
  153. package/dist/RequestKind.mjs +0 -105
  154. package/dist/RequestList.d.ts +0 -20
  155. package/dist/RequestList.mjs +0 -71
  156. package/dist/RowHeightRule.d.ts +0 -34
  157. package/dist/RowHeightRule.mjs +0 -84
  158. package/dist/RowSide.d.ts +0 -24
  159. package/dist/RowSide.mjs +0 -72
  160. package/dist/SaveError.d.ts +0 -24
  161. package/dist/SaveError.mjs +0 -72
  162. package/dist/SelectionInfo.d.ts +0 -39
  163. package/dist/SelectionInfo.mjs +0 -166
  164. package/dist/SelectionKind.d.ts +0 -37
  165. package/dist/SelectionKind.mjs +0 -93
  166. package/dist/TableAlignment.d.ts +0 -25
  167. package/dist/TableAlignment.mjs +0 -75
  168. package/dist/TableSelection.d.ts +0 -38
  169. package/dist/TableSelection.mjs +0 -90
  170. package/dist/TableWidthUnit.d.ts +0 -31
  171. package/dist/TableWidthUnit.mjs +0 -81
  172. package/dist/TextUnit.d.ts +0 -25
  173. package/dist/TextUnit.mjs +0 -75
  174. package/dist/diplomat-runtime.d.ts +0 -15
  175. package/dist/diplomat-runtime.mjs +0 -786
  176. package/dist/diplomat-wasm.mjs +0 -18
  177. package/dist/gpu.d.ts +0 -15
  178. package/dist/gpu.mjs +0 -42
  179. package/dist/index.mjs +0 -101
@@ -1,18 +0,0 @@
1
- // Replaces Diplomat's loader (which instantiates a bare wasm32-unknown-unknown module): the engine is an emscripten
2
- // module, so its exports live on the emscripten Module as `_name`, and its memory can grow. Copied over the
3
- // generated diplomat-wasm.mjs by `moon run web:generate`.
4
- import createTwip from './twip-wasm.js';
5
-
6
- const module = await createTwip();
7
-
8
- /** The emscripten module itself: its `WebGPU` and `GL` helpers import browser GPU objects (gpu.mjs). */
9
- export const emscripten = module;
10
-
11
- const wasm = new Proxy({}, {
12
- get(_, name) {
13
- if (name === 'memory') return { get buffer() { return module.HEAPU8.buffer; } };
14
- return module[`_${String(name)}`];
15
- },
16
- });
17
-
18
- export default wasm;
package/dist/gpu.d.ts DELETED
@@ -1,15 +0,0 @@
1
- import type { Editor } from './Editor';
2
-
3
- export interface WebGpuTarget { canvas: HTMLCanvasElement; context: GPUCanvasContext; bgra: boolean }
4
- export interface WebGlTarget { canvas: HTMLCanvasElement; handle: number }
5
-
6
- /** Adopts a GPUDevice for every editor; false if the engine can't use it (paint with WebGL instead). */
7
- export function attachWebGpu(device: GPUDevice): boolean;
8
- /** Configures `canvas` for WebGPU painting with `device`. */
9
- export function webGpuTarget(canvas: HTMLCanvasElement, device: GPUDevice): WebGpuTarget;
10
- /** Paints `editor` into the target's current texture; the page stack's top-left at (`originX`, `originY`) CSS px. */
11
- export function paintWebGpu(editor: Editor, target: WebGpuTarget, originX: number, originY: number, dpr?: number): boolean;
12
- /** Creates a WebGL 2 context on `canvas` for `editor` (one per canvas). */
13
- export function webGlTarget(editor: Editor, canvas: HTMLCanvasElement): WebGlTarget;
14
- /** Paints `editor` into its WebGL canvas; the page stack's top-left at (`originX`, `originY`) CSS px. */
15
- export function paintWebGl(editor: Editor, target: WebGlTarget, originX: number, originY: number, dpr?: number): boolean;
package/dist/gpu.mjs DELETED
@@ -1,42 +0,0 @@
1
- // Browser GPU painting: imports the page's WebGPU device and canvas textures, or a WebGL 2 context, into the engine
2
- // module and paints an editor through them. Hosts call these instead of the raw handle methods on Editor.
3
- import { emscripten } from './diplomat-wasm.mjs';
4
- import { Editor } from './Editor.mjs';
5
-
6
- /** Adopts a GPUDevice for every editor; false if the engine can't use it (paint with WebGL instead). */
7
- export function attachWebGpu(device) {
8
- const instance = Editor.webgpuInstance();
9
- const { WebGPU } = emscripten;
10
- return Editor.attachWebgpu(instance, WebGPU.importJsDevice(device, instance), WebGPU.importJsQueue(device.queue, instance));
11
- }
12
-
13
- /** Configures `canvas` for WebGPU painting with `device`; pass the result to `paintWebGpu`. */
14
- export function webGpuTarget(canvas, device) {
15
- const context = canvas.getContext('webgpu');
16
- const format = navigator.gpu.getPreferredCanvasFormat();
17
- // COPY_SRC | COPY_DST | TEXTURE_BINDING | RENDER_ATTACHMENT: what Graphite needs of the canvas texture.
18
- context.configure({ device, format, alphaMode: 'premultiplied', usage: 0x01 | 0x02 | 0x04 | 0x10 });
19
- return { canvas, context, bgra: format === 'bgra8unorm' };
20
- }
21
-
22
- /** Paints `editor` into the target's current texture; the page stack's top-left at (`originX`, `originY`) CSS px. */
23
- export function paintWebGpu(editor, target, originX, originY, dpr = globalThis.devicePixelRatio ?? 1) {
24
- const texture = emscripten.WebGPU.importJsTexture(target.context.getCurrentTexture());
25
- return editor.paintWebgpu(texture, target.bgra, originX, originY, target.canvas.height, dpr);
26
- }
27
-
28
- /** Creates a WebGL 2 context on `canvas` for `editor` (one per canvas); pass the result to `paintWebGl`. */
29
- export function webGlTarget(editor, canvas) {
30
- const { GL } = emscripten;
31
- const handle = GL.createContext(canvas, { majorVersion: 2, minorVersion: 0, alpha: 1, depth: 0, stencil: 8, antialias: 0, premultipliedAlpha: 1 });
32
- if (!handle) throw new Error('WebGL 2 is unavailable');
33
- GL.makeContextCurrent(handle);
34
- if (!editor.attachWebgl()) throw new Error('the engine could not use the WebGL context');
35
- return { canvas, handle };
36
- }
37
-
38
- /** Paints `editor` into its WebGL canvas; the page stack's top-left at (`originX`, `originY`) CSS px. */
39
- export function paintWebGl(editor, target, originX, originY, dpr = globalThis.devicePixelRatio ?? 1) {
40
- emscripten.GL.makeContextCurrent(target.handle);
41
- return editor.paintWebgl(originX, originY, target.canvas.width, target.canvas.height, dpr);
42
- }
package/dist/index.mjs DELETED
@@ -1,101 +0,0 @@
1
-
2
-
3
- export { CaretPosition } from "./CaretPosition.mjs"
4
-
5
- export { DocumentStatus } from "./DocumentStatus.mjs"
6
-
7
- export { Modifiers } from "./Modifiers.mjs"
8
-
9
- export { Rect } from "./Rect.mjs"
10
-
11
- export { SelectionInfo } from "./SelectionInfo.mjs"
12
-
13
- export { AccessibleNode } from "./AccessibleNode.mjs"
14
-
15
- export { Bytes } from "./Bytes.mjs"
16
-
17
- export { Clipboard } from "./Clipboard.mjs"
18
-
19
- export { Editor } from "./Editor.mjs"
20
-
21
- export { Element } from "./Element.mjs"
22
-
23
- export { ElementList } from "./ElementList.mjs"
24
-
25
- export { Event } from "./Event.mjs"
26
-
27
- export { EventList } from "./EventList.mjs"
28
-
29
- export { Fonts } from "./Fonts.mjs"
30
-
31
- export { Request } from "./Request.mjs"
32
-
33
- export { RequestList } from "./RequestList.mjs"
34
-
35
- export { Alignment } from "./Alignment.mjs"
36
-
37
- export { BorderEdges } from "./BorderEdges.mjs"
38
-
39
- export { BorderStyle } from "./BorderStyle.mjs"
40
-
41
- export { CellAlignment } from "./CellAlignment.mjs"
42
-
43
- export { CellShift } from "./CellShift.mjs"
44
-
45
- export { ColumnSide } from "./ColumnSide.mjs"
46
-
47
- export { ControlKind } from "./ControlKind.mjs"
48
-
49
- export { ControlLock } from "./ControlLock.mjs"
50
-
51
- export { EditorMode } from "./EditorMode.mjs"
52
-
53
- export { ElementKind } from "./ElementKind.mjs"
54
-
55
- export { ElementText } from "./ElementText.mjs"
56
-
57
- export { EventKind } from "./EventKind.mjs"
58
-
59
- export { Highlight } from "./Highlight.mjs"
60
-
61
- export { MarginPreset } from "./MarginPreset.mjs"
62
-
63
- export { MarkSeverity } from "./MarkSeverity.mjs"
64
-
65
- export { OpenError } from "./OpenError.mjs"
66
-
67
- export { Orientation } from "./Orientation.mjs"
68
-
69
- export { PageNumber } from "./PageNumber.mjs"
70
-
71
- export { PaperSize } from "./PaperSize.mjs"
72
-
73
- export { ParagraphBorders } from "./ParagraphBorders.mjs"
74
-
75
- export { PictureWrap } from "./PictureWrap.mjs"
76
-
77
- export { PointerKind } from "./PointerKind.mjs"
78
-
79
- export { RequestKind } from "./RequestKind.mjs"
80
-
81
- export { RowHeightRule } from "./RowHeightRule.mjs"
82
-
83
- export { RowSide } from "./RowSide.mjs"
84
-
85
- export { SaveError } from "./SaveError.mjs"
86
-
87
- export { SelectionKind } from "./SelectionKind.mjs"
88
-
89
- export { TableAlignment } from "./TableAlignment.mjs"
90
-
91
- export { TableSelection } from "./TableSelection.mjs"
92
-
93
- export { TableWidthUnit } from "./TableWidthUnit.mjs"
94
-
95
- export { TextUnit } from "./TextUnit.mjs"
96
-
97
- import wasm from "./diplomat-wasm.mjs";
98
- import {FUNCTION_PARAM_ALLOC, internalConstructor} from "./diplomat-runtime.mjs";
99
-
100
- FUNCTION_PARAM_ALLOC.reserve(internalConstructor, wasm, 63);
101
- export * from './gpu.mjs';