@ingcreators/annot-core 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.
- package/CHANGELOG.md +7 -0
- package/LICENSE +201 -0
- package/README.md +56 -0
- package/dist/auto-capture-options.d.ts +78 -0
- package/dist/editor/arrow-markers.d.ts +142 -0
- package/dist/editor/bake-translate.d.ts +192 -0
- package/dist/editor/font-registry.d.ts +58 -0
- package/dist/editor/gradient-utils.d.ts +23 -0
- package/dist/editor/history-core.d.ts +48 -0
- package/dist/editor/icons/brand-icons.d.ts +53 -0
- package/dist/editor/icons/material-symbols.d.ts +105 -0
- package/dist/editor/icons/registry.d.ts +179 -0
- package/dist/editor/icons/render.d.ts +22 -0
- package/dist/editor/icons/sanitize.d.ts +60 -0
- package/dist/editor/index.d.ts +13 -0
- package/dist/editor/path-utils.d.ts +32 -0
- package/dist/editor/property-schema.d.ts +263 -0
- package/dist/editor/rich-text-mapper.d.ts +8 -0
- package/dist/editor/selection-geometry.d.ts +66 -0
- package/dist/editor/shape-utils.d.ts +27 -0
- package/dist/editor/svg-format.d.ts +68 -0
- package/dist/editor/svg-id-utils.d.ts +37 -0
- package/dist/editor/svg-to-annotation-shapes.d.ts +34 -0
- package/dist/editor/text-utils.d.ts +212 -0
- package/dist/editor/tool-lifecycle.d.ts +56 -0
- package/dist/editor/tool-options.d.ts +126 -0
- package/dist/editor/tool-panel-adapter.d.ts +105 -0
- package/dist/editor/tool-preset-serde.d.ts +43 -0
- package/dist/editor/tool-registry.d.ts +320 -0
- package/dist/editor/tool-style-reader.d.ts +36 -0
- package/dist/editor/tool-style-writer.d.ts +33 -0
- package/dist/editor/toolbar-icons.d.ts +84 -0
- package/dist/editor/transform-utils.d.ts +127 -0
- package/dist/editor/viewport-math.d.ts +69 -0
- package/dist/encode/index.d.ts +4 -0
- package/dist/encode/options.d.ts +79 -0
- package/dist/encode/png8.d.ts +10 -0
- package/dist/headless.d.ts +29 -0
- package/dist/icons/index.d.ts +15 -0
- package/dist/icons/types.d.ts +108 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3164 -0
- package/dist/storage/errors.d.ts +59 -0
- package/dist/storage/index.d.ts +6 -0
- package/dist/storage/metadata-cache.d.ts +231 -0
- package/dist/storage/path.d.ts +49 -0
- package/dist/storage/thumbnail-cache.d.ts +110 -0
- package/dist/storage/thumbnail.d.ts +31 -0
- package/dist/storage/types.d.ts +677 -0
- package/dist/utils/assert.d.ts +31 -0
- package/dist/utils/constants.d.ts +10 -0
- package/dist/utils/dash-utils.d.ts +6 -0
- package/dist/utils/desktop-bridge.d.ts +349 -0
- package/dist/utils/filename.d.ts +48 -0
- package/dist/utils/id.d.ts +21 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/types.d.ts +20 -0
- package/dist/xmp/xmp-browser.d.ts +39 -0
- package/dist/zip/zip-builder.d.ts +8 -0
- package/dist/zip/zip-bytes.d.ts +22 -0
- package/package.json +58 -0
- package/styles/editor.css +1912 -0
- package/styles/fonts.css +46 -0
- package/styles/property-panel.css +779 -0
- package/styles/toolbar.css +673 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 ingcreators
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# @ingcreators/annot-core
|
|
2
|
+
|
|
3
|
+
The shared core of [Annot](../../README.md). Two tiers live here:
|
|
4
|
+
|
|
5
|
+
- **Tier A** — pure Node, DOM-free. Storage types, SVG format
|
|
6
|
+
versioning, path utilities, ZIP builder, capability predicates,
|
|
7
|
+
encode helpers.
|
|
8
|
+
- **Tier B** — jsdom-friendly element-takers. SVG-element helpers
|
|
9
|
+
(`arrow-markers`, `transform-utils`, `shape-utils`, `text-utils`,
|
|
10
|
+
`gradient-utils`), the `TOOL_REGISTRY` / `PROPERTY_CONTROLS`
|
|
11
|
+
registries, the OOXML shape mapping (`svg-to-annotation-shapes`).
|
|
12
|
+
No `<canvas>`, no live editor.
|
|
13
|
+
|
|
14
|
+
Live-browser editor primitives (CanvasManager, SelectionManager,
|
|
15
|
+
PropertyPanel, tools) live in [`@ingcreators/annot-editor`](../editor).
|
|
16
|
+
Data-driven canvas rendering (gallery thumbnails, the shared OOXML
|
|
17
|
+
DrawingML builder) lives in [`@ingcreators/annot-render`](../render).
|
|
18
|
+
|
|
19
|
+
## Public entry points
|
|
20
|
+
|
|
21
|
+
| Subpath | Tier | Surface |
|
|
22
|
+
|---------|------|---------|
|
|
23
|
+
| `@ingcreators/annot-core` | A | Re-exports everything from `/headless` — DOM-free root entry |
|
|
24
|
+
| `@ingcreators/annot-core/headless` | A | Same as root, kept as an alias for callers that want to be explicit |
|
|
25
|
+
| `@ingcreators/annot-core/storage` | A | `ImageRecord`, `FolderRecord`, `PageElement`, `PageMetadata`, `StorageProvider` |
|
|
26
|
+
| `@ingcreators/annot-core/utils` | A | `assertNonNull`, `computeDasharray`, `newIdB58`, defaults |
|
|
27
|
+
| `@ingcreators/annot-core/zip` | A | ZIP builder used by PPTX export |
|
|
28
|
+
| `@ingcreators/annot-core/encode` | A | Image encode helpers |
|
|
29
|
+
| `@ingcreators/annot-core/editor` | B | jsdom-friendly element helpers + `TOOL_REGISTRY` / `PROPERTY_CONTROLS` |
|
|
30
|
+
| `@ingcreators/annot-core/xmp` | browser | `createEditableImage` / `readEditableImage` round-trip |
|
|
31
|
+
| `@ingcreators/annot-core/desktop-bridge` | browser | Electron desktop-host IPC + `isDesktop` detection |
|
|
32
|
+
|
|
33
|
+
The Tier A surface is CI-enforced by
|
|
34
|
+
[`src/headless.test.ts`](./src/headless.test.ts): it imports every
|
|
35
|
+
documented subpath in a pure-Node Vitest environment and asserts no
|
|
36
|
+
DOM globals leak in. It also walks the loader cache to prove that
|
|
37
|
+
no `annot-core` module transitively pulls `annot-editor` or
|
|
38
|
+
`annot-render` (cycle invariant).
|
|
39
|
+
|
|
40
|
+
## Build
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pnpm --filter @ingcreators/annot-core build # vite library build
|
|
44
|
+
pnpm --filter @ingcreators/annot-core typecheck # tsc --noEmit
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## See also
|
|
48
|
+
|
|
49
|
+
- [Root README](../../README.md) — monorepo overview, getting started.
|
|
50
|
+
- [`PRODUCT_DIRECTION.md`](../../PRODUCT_DIRECTION.md) — strategic north star (this package is the future
|
|
51
|
+
headless library boundary).
|
|
52
|
+
- [`CLAUDE.md`](../../CLAUDE.md) — Tier model rationale and the rules for adding new symbols.
|
|
53
|
+
|
|
54
|
+
## License
|
|
55
|
+
|
|
56
|
+
[Apache License, Version 2.0](../../LICENSE) © ingcreators.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto Capture engine settings — shared between
|
|
3
|
+
* `@ingcreators/annot-web` (live) and `@ingcreators/annot-extension`
|
|
4
|
+
* (future, when the extension grows its own Auto Capture surface).
|
|
5
|
+
*
|
|
6
|
+
* Three discrete-choice presets cover the spec §6.6 settings —
|
|
7
|
+
* raw millisecond / ratio numbers stay internal so the UI can
|
|
8
|
+
* surface readable labels and the encoder doesn't have to validate
|
|
9
|
+
* arbitrary user input.
|
|
10
|
+
*
|
|
11
|
+
* Persistence shape on each host:
|
|
12
|
+
* - Web: `localStorage["annot-auto-capture-options"]` mirrors this
|
|
13
|
+
* `AutoCaptureOptions` blob 1:1, with `loadAutoCaptureOptions()`
|
|
14
|
+
* doing the merge / validation.
|
|
15
|
+
* - Extension (future): one nested record under
|
|
16
|
+
* `Settings.autoCapture` in `chrome.storage.sync`, mirroring the
|
|
17
|
+
* `Settings.quality` precedent.
|
|
18
|
+
*
|
|
19
|
+
* The engine consumes the resolved milliseconds via the Tier C
|
|
20
|
+
* `<annot-capture-workspace>` wiring; this Tier A leaf is pure
|
|
21
|
+
* data + helpers so it pulls into a Node test harness without the
|
|
22
|
+
* DOM / Lit / engine code.
|
|
23
|
+
*/
|
|
24
|
+
/** Sampling cadence — how often the engine grabs a comparison
|
|
25
|
+
* frame. Faster catches sub-second flickers; slower reduces
|
|
26
|
+
* CPU pressure on low-end machines. */
|
|
27
|
+
export type CaptureIntervalPreset = "fast" | "standard" | "slow";
|
|
28
|
+
/** How aggressively the engine treats a frame diff as "meaningful".
|
|
29
|
+
* - sensitive: small UI changes (a button hover) trigger captures
|
|
30
|
+
* - standard: typical procedure-doc flow (page navigation, dialog open)
|
|
31
|
+
* - major: only obvious changes (full-page navigation, modal swap) */
|
|
32
|
+
export type ChangeSensitivityPreset = "sensitive" | "standard" | "major";
|
|
33
|
+
/** How long the engine waits for the screen to settle before
|
|
34
|
+
* capturing — protects against capturing mid-animation frames.
|
|
35
|
+
* - none: capture immediately when diff drops below threshold
|
|
36
|
+
* - short: spec default (700ms)
|
|
37
|
+
* - long: animation-heavy sites that take >1s to settle */
|
|
38
|
+
export type StableWaitPreset = "none" | "short" | "long";
|
|
39
|
+
export interface AutoCaptureOptions {
|
|
40
|
+
/** Sampling cadence preset. */
|
|
41
|
+
interval: CaptureIntervalPreset;
|
|
42
|
+
/** Diff-detection threshold preset. */
|
|
43
|
+
sensitivity: ChangeSensitivityPreset;
|
|
44
|
+
/** Stable-wait duration preset. */
|
|
45
|
+
stableWait: StableWaitPreset;
|
|
46
|
+
/** When true, frames whose only change is a localized cursor-
|
|
47
|
+
* shaped region are dropped (no candidate created). Default
|
|
48
|
+
* on — most users want stable workflow captures, not cursor
|
|
49
|
+
* movements. */
|
|
50
|
+
ignoreCursorOnlyChanges: boolean;
|
|
51
|
+
}
|
|
52
|
+
export declare const DEFAULT_AUTO_CAPTURE_OPTIONS: AutoCaptureOptions;
|
|
53
|
+
/** Preset → millisecond mapping. Engine consumes the resolved
|
|
54
|
+
* milliseconds; UI surfaces the preset key + the human label
|
|
55
|
+
* via {@link CAPTURE_INTERVAL_LABEL}. */
|
|
56
|
+
export declare const CAPTURE_INTERVAL_MS: Record<CaptureIntervalPreset, number>;
|
|
57
|
+
export declare const CAPTURE_INTERVAL_LABEL: Record<CaptureIntervalPreset, string>;
|
|
58
|
+
/** Preset → diff ratio threshold. Higher = more change required
|
|
59
|
+
* before the engine treats the frame as meaningful. */
|
|
60
|
+
export declare const CHANGE_SENSITIVITY_RATIO: Record<ChangeSensitivityPreset, number>;
|
|
61
|
+
export declare const CHANGE_SENSITIVITY_LABEL: Record<ChangeSensitivityPreset, string>;
|
|
62
|
+
/** Preset → stable-wait milliseconds. */
|
|
63
|
+
export declare const STABLE_WAIT_MS: Record<StableWaitPreset, number>;
|
|
64
|
+
export declare const STABLE_WAIT_LABEL: Record<StableWaitPreset, string>;
|
|
65
|
+
/** Engine-facing resolved values. The Tier C
|
|
66
|
+
* `<annot-capture-workspace>` calls this once when starting the
|
|
67
|
+
* engine and passes the result into `AutoCaptureEngine`. */
|
|
68
|
+
export interface ResolvedAutoCaptureSettings {
|
|
69
|
+
intervalMs: number;
|
|
70
|
+
changeRatioThreshold: number;
|
|
71
|
+
stableWaitMs: number;
|
|
72
|
+
ignoreCursorOnlyChanges: boolean;
|
|
73
|
+
}
|
|
74
|
+
export declare function resolveAutoCaptureOptions(opts?: AutoCaptureOptions): ResolvedAutoCaptureSettings;
|
|
75
|
+
/** Type guards — useful for the persistence layer's merge step. */
|
|
76
|
+
export declare function isCaptureIntervalPreset(v: unknown): v is CaptureIntervalPreset;
|
|
77
|
+
export declare function isChangeSensitivityPreset(v: unknown): v is ChangeSensitivityPreset;
|
|
78
|
+
export declare function isStableWaitPreset(v: unknown): v is StableWaitPreset;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { ArrowDim, ArrowShape } from './tool-options.js';
|
|
2
|
+
export interface Point {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
}
|
|
6
|
+
export interface ArrowSpec {
|
|
7
|
+
shape: ArrowShape;
|
|
8
|
+
/** OOXML `w` — perpendicular-to-stem thickness preset. */
|
|
9
|
+
width: ArrowDim;
|
|
10
|
+
/** OOXML `len` — along-stem length preset. */
|
|
11
|
+
length: ArrowDim;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Minimal adapter that mirrors the subset of `AbstractCanvas2D`
|
|
15
|
+
* maxGraph's marker factories call. Internally it just accumulates
|
|
16
|
+
* SVG path commands into a `d` attribute string.
|
|
17
|
+
*/
|
|
18
|
+
declare class SvgPathCanvas {
|
|
19
|
+
#private;
|
|
20
|
+
begin(): void;
|
|
21
|
+
moveTo(x: number, y: number): void;
|
|
22
|
+
lineTo(x: number, y: number): void;
|
|
23
|
+
quadTo(cx: number, cy: number, x: number, y: number): void;
|
|
24
|
+
close(): void;
|
|
25
|
+
/** maxGraph emits `canvas.ellipse(x, y, w, h)` for the oval
|
|
26
|
+
* marker (box top-left + box dimensions). We render it as two
|
|
27
|
+
* half-arc commands — SVG A commands can't draw a full ellipse
|
|
28
|
+
* in a single sweep. */
|
|
29
|
+
ellipse(x: number, y: number, w: number, h: number): void;
|
|
30
|
+
stroke(): void;
|
|
31
|
+
fillAndStroke(): void;
|
|
32
|
+
get d(): string;
|
|
33
|
+
clear(): void;
|
|
34
|
+
}
|
|
35
|
+
export interface ArrowRenderResult {
|
|
36
|
+
/** Whether the arrow head is a filled (closed) shape. Used by the
|
|
37
|
+
* caller to decide whether to route this head's path data into
|
|
38
|
+
* the "filled" head `<path>` (fill=stroke) or the "open" head
|
|
39
|
+
* `<path>` (fill=none). Splitting is REQUIRED when mixing filled
|
|
40
|
+
* and open heads on the same arrow — e.g. start=oval + end=arrow
|
|
41
|
+
* — because a single `<path>` with fill=stroke would auto-close
|
|
42
|
+
* the open chevron subpath and render it as a filled triangle. */
|
|
43
|
+
filled: boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Render one arrow head into `canvas` at endpoint `pe`, mutating
|
|
47
|
+
* `pe` to the shortened line endpoint. The returned `filled` flag
|
|
48
|
+
* tells the caller whether to set fill=stroke on the parent path.
|
|
49
|
+
*/
|
|
50
|
+
export declare function renderArrowHead(canvas: SvgPathCanvas, spec: ArrowSpec, pe: Point, unitX: number, unitY: number, strokeWidth: number): ArrowRenderResult;
|
|
51
|
+
/**
|
|
52
|
+
* Compute the stem and arrow-head path-data strings independently.
|
|
53
|
+
*
|
|
54
|
+
* The heads mutate their respective endpoints inward so the stem
|
|
55
|
+
* stops exactly where the head begins. The two `d` strings are
|
|
56
|
+
* returned separately so the caller can render them in separate
|
|
57
|
+
* `<path>` elements — that lets the stem carry a dash pattern
|
|
58
|
+
* (`stroke-dasharray`) WITHOUT the dashes bleeding into the arrow-
|
|
59
|
+
* head outlines (a single `<path>` would apply its dasharray to
|
|
60
|
+
* every subpath including the closed heads).
|
|
61
|
+
*
|
|
62
|
+
* `anyFilled` signals that at least one head is a filled (closed)
|
|
63
|
+
* shape, so the head `<path>` should use `fill=stroke` to paint
|
|
64
|
+
* the interiors.
|
|
65
|
+
*/
|
|
66
|
+
export declare function computeArrowParts(x1: number, y1: number, x2: number, y2: number, specStart: ArrowSpec, specEnd: ArrowSpec, strokeWidth: number, control?: Point | null): {
|
|
67
|
+
stemD: string;
|
|
68
|
+
headFilledD: string;
|
|
69
|
+
headOpenD: string;
|
|
70
|
+
};
|
|
71
|
+
/** Read the per-end arrow spec off an existing arrow <path> element.
|
|
72
|
+
* Mirrors the data-* attribute contract applyArrowPath writes. */
|
|
73
|
+
export declare function detectArrowSpec(el: SVGElement, end: "start" | "end"): ArrowSpec;
|
|
74
|
+
/** Write the arrow spec back onto an element. */
|
|
75
|
+
export declare function writeArrowSpec(el: SVGElement, end: "start" | "end", spec: ArrowSpec): void;
|
|
76
|
+
/** Read the geometric endpoints of an arrow `<path>` element. The
|
|
77
|
+
* x1/y1/x2/y2 values are stored as data attrs (the `d` string is
|
|
78
|
+
* derived from them). */
|
|
79
|
+
export declare function readArrowEndpoints(el: SVGElement): {
|
|
80
|
+
x1: number;
|
|
81
|
+
y1: number;
|
|
82
|
+
x2: number;
|
|
83
|
+
y2: number;
|
|
84
|
+
};
|
|
85
|
+
export declare function writeArrowEndpoints(el: SVGElement, x1: number, y1: number, x2: number, y2: number): void;
|
|
86
|
+
/** Read the quadratic-bezier control point for a curved arrow, or
|
|
87
|
+
* null if the arrow is straight (no data-cx/cy set). */
|
|
88
|
+
export declare function readArrowControl(el: SVGElement): Point | null;
|
|
89
|
+
/** Write the control point (turns the arrow curved) or clear it
|
|
90
|
+
* (back to straight). Pass null to straighten. */
|
|
91
|
+
export declare function writeArrowControl(el: SVGElement, control: Point | null): void;
|
|
92
|
+
/**
|
|
93
|
+
* Rebuild the stem and arrow-head `<path>` children of an arrow
|
|
94
|
+
* `<g>` wrapper from its current endpoint and arrow-spec data attrs.
|
|
95
|
+
* Called after any endpoint drag / arrow-head change / stroke-width
|
|
96
|
+
* change so the composed geometry stays in sync.
|
|
97
|
+
*
|
|
98
|
+
* DOM shape expected:
|
|
99
|
+
* <g data-type="arrow" data-x1=.. data-y1=.. data-x2=.. data-y2=..
|
|
100
|
+
* data-arrow-start-* ... data-arrow-end-* ...
|
|
101
|
+
* stroke=.. stroke-width=.. stroke-dasharray=.. fill=..>
|
|
102
|
+
* <path data-role="stem" d="..."/>
|
|
103
|
+
* <path data-role="head-filled" d="..." fill=stroke/>
|
|
104
|
+
* <path data-role="head-open" d="..." fill="none"/>
|
|
105
|
+
* </g>
|
|
106
|
+
*
|
|
107
|
+
* Missing children are created on the fly so old DOM upgrades
|
|
108
|
+
* cleanly. We use TWO head paths so mixed configurations (e.g.
|
|
109
|
+
* oval at start + open arrow at end) render correctly — a single
|
|
110
|
+
* head path with fill=stroke would implicitly close the open
|
|
111
|
+
* chevron into a filled triangle.
|
|
112
|
+
*/
|
|
113
|
+
export declare function refreshArrowPath(el: SVGElement): void;
|
|
114
|
+
/**
|
|
115
|
+
* Inline SVG for an arrow-end shape used by the per-end pulldown
|
|
116
|
+
* cells. Shared 40×14 viewBox with `arrowSizePreview` so Begin/End
|
|
117
|
+
* type and size buttons render at the same apparent stem length —
|
|
118
|
+
* the four rows line up visually in the right panel instead of
|
|
119
|
+
* looking like mismatched pairs.
|
|
120
|
+
*/
|
|
121
|
+
export declare function arrowPreview(shape: ArrowShape, dir?: "left" | "right"): string;
|
|
122
|
+
/**
|
|
123
|
+
* Inner SVG for `arrowPreview` — the head + stem geometry without
|
|
124
|
+
* the wrapping `<svg>` element. Exposed separately so callers can
|
|
125
|
+
* compose it inside their own `<svg>` (used by the toolbar's
|
|
126
|
+
* variant flyout).
|
|
127
|
+
*
|
|
128
|
+
* 40×14 viewBox. Stem along y=7, head occupies x∈[28,38], 10-unit
|
|
129
|
+
* long × 10-unit wide (tip at x=38, base at x=28). The stem's
|
|
130
|
+
* right endpoint varies per shape so it touches the marker's
|
|
131
|
+
* attachment point (chevron tip, stealth notch, filled base, etc).
|
|
132
|
+
*/
|
|
133
|
+
export declare function arrowPreviewContent(shape: ArrowShape): string;
|
|
134
|
+
/**
|
|
135
|
+
* Render an arrow head preview at the requested width × length so
|
|
136
|
+
* the per-end size pulldown's cells accurately reflect the actual
|
|
137
|
+
* canvas rendering. Uses the same `computeArrowParts` engine the
|
|
138
|
+
* canvas uses, eliminating the previous ad-hoc scale table that
|
|
139
|
+
* tended to drift from real geometry.
|
|
140
|
+
*/
|
|
141
|
+
export declare function arrowSizePreview(w: ArrowDim, l: ArrowDim, dir?: "left" | "right"): string;
|
|
142
|
+
export {};
|