@embedpdf/plugin-measurement 3.0.0-next.14

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/LICENSE ADDED
@@ -0,0 +1,215 @@
1
+ REPOSITORY LICENSING NOTICE
2
+
3
+ This repository contains code under more than one license.
4
+
5
+ The Apache License 2.0 below applies only to the portions identified as
6
+ Apache-2.0 in LICENSING.md. It does not apply to cloudpdf/server, which is
7
+ licensed under the Fair Core License, FCL-1.0-ALv2. The authoritative terms
8
+ for that component are in cloudpdf/server/LICENSE.
9
+
10
+ Website content may have separate terms as described in LICENSING.md.
11
+
12
+ This notice describes the scope of the licenses and does not modify the
13
+ Apache License 2.0 text below.
14
+
15
+ Apache License
16
+ Version 2.0, January 2004
17
+ http://www.apache.org/licenses/
18
+
19
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
20
+
21
+ 1. Definitions.
22
+
23
+ "License" shall mean the terms and conditions for use, reproduction,
24
+ and distribution as defined by Sections 1 through 9 of this document.
25
+
26
+ "Licensor" shall mean the copyright owner or entity authorized by
27
+ the copyright owner that is granting the License.
28
+
29
+ "Legal Entity" shall mean the union of the acting entity and all
30
+ other entities that control, are controlled by, or are under common
31
+ control with that entity. For the purposes of this definition,
32
+ "control" means (i) the power, direct or indirect, to cause the
33
+ direction or management of such entity, whether by contract or
34
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
35
+ outstanding shares, or (iii) beneficial ownership of such entity.
36
+
37
+ "You" (or "Your") shall mean an individual or Legal Entity
38
+ exercising permissions granted by this License.
39
+
40
+ "Source" form shall mean the preferred form for making modifications,
41
+ including but not limited to software source code, documentation
42
+ source, and configuration files.
43
+
44
+ "Object" form shall mean any form resulting from mechanical
45
+ transformation or translation of a Source form, including but
46
+ not limited to compiled object code, generated documentation,
47
+ and conversions to other media types.
48
+
49
+ "Work" shall mean the work of authorship, whether in Source or
50
+ Object form, made available under the License, as indicated by a
51
+ copyright notice that is included in or attached to the work
52
+ (an example is provided in the Appendix below).
53
+
54
+ "Derivative Works" shall mean any work, whether in Source or Object
55
+ form, that is based on (or derived from) the Work and for which the
56
+ editorial revisions, annotations, elaborations, or other modifications
57
+ represent, as a whole, an original work of authorship. For the purposes
58
+ of this License, Derivative Works shall not include works that remain
59
+ separable from, or merely link (or bind by name) to the interfaces of,
60
+ the Work and Derivative Works thereof.
61
+
62
+ "Contribution" shall mean any work of authorship, including
63
+ the original version of the Work and any modifications or additions
64
+ to that Work or Derivative Works thereof, that is intentionally
65
+ submitted to Licensor for inclusion in the Work by the copyright owner
66
+ or by an individual or Legal Entity authorized to submit on behalf of
67
+ the copyright owner. For the purposes of this definition, "submitted"
68
+ means any form of electronic, verbal, or written communication sent
69
+ to the Licensor or its representatives, including but not limited to
70
+ communication on electronic mailing lists, source code control systems,
71
+ and issue tracking systems that are managed by, or on behalf of, the
72
+ Licensor for the purpose of discussing and improving the Work, but
73
+ excluding communication that is conspicuously marked or otherwise
74
+ designated in writing by the copyright owner as "Not a Contribution."
75
+
76
+ "Contributor" shall mean Licensor and any individual or Legal Entity
77
+ on behalf of whom a Contribution has been received by Licensor and
78
+ subsequently incorporated within the Work.
79
+
80
+ 2. Grant of Copyright License. Subject to the terms and conditions of
81
+ this License, each Contributor hereby grants to You a perpetual,
82
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
83
+ copyright license to reproduce, prepare Derivative Works of,
84
+ publicly display, publicly perform, sublicense, and distribute the
85
+ Work and such Derivative Works in Source or Object form.
86
+
87
+ 3. Grant of Patent License. Subject to the terms and conditions of
88
+ this License, each Contributor hereby grants to You a perpetual,
89
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
90
+ (except as stated in this section) patent license to make, have made,
91
+ use, offer to sell, sell, import, and otherwise transfer the Work,
92
+ where such license applies only to those patent claims licensable
93
+ by such Contributor that are necessarily infringed by their
94
+ Contribution(s) alone or by combination of their Contribution(s)
95
+ with the Work to which such Contribution(s) was submitted. If You
96
+ institute patent litigation against any entity (including a
97
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
98
+ or a Contribution incorporated within the Work constitutes direct
99
+ or contributory patent infringement, then any patent licenses
100
+ granted to You under this License for that Work shall terminate
101
+ as of the date such litigation is filed.
102
+
103
+ 4. Redistribution. You may reproduce and distribute copies of the
104
+ Work or Derivative Works thereof in any medium, with or without
105
+ modifications, and in Source or Object form, provided that You
106
+ meet the following conditions:
107
+
108
+ (a) You must give any other recipients of the Work or
109
+ Derivative Works a copy of this License; and
110
+
111
+ (b) You must cause any modified files to carry prominent notices
112
+ stating that You changed the files; and
113
+
114
+ (c) You must retain, in the Source form of any Derivative Works
115
+ that You distribute, all copyright, patent, trademark, and
116
+ attribution notices from the Source form of the Work,
117
+ excluding those notices that do not pertain to any part of
118
+ the Derivative Works; and
119
+
120
+ (d) If the Work includes a "NOTICE" text file as part of its
121
+ distribution, then any Derivative Works that You distribute must
122
+ include a readable copy of the attribution notices contained
123
+ within such NOTICE file, excluding those notices that do not
124
+ pertain to any part of the Derivative Works, in at least one
125
+ of the following places: within a NOTICE text file distributed
126
+ as part of the Derivative Works; within the Source form or
127
+ documentation, if provided along with the Derivative Works; or,
128
+ within a display generated by the Derivative Works, if and
129
+ wherever such third-party notices normally appear. The contents
130
+ of the NOTICE file are for informational purposes only and
131
+ do not modify the License. You may add Your own attribution
132
+ notices within Derivative Works that You distribute, alongside
133
+ or as an addendum to the NOTICE text from the Work, provided
134
+ that such additional attribution notices cannot be construed
135
+ as modifying the License.
136
+
137
+ You may add Your own copyright statement to Your modifications and
138
+ may provide additional or different license terms and conditions
139
+ for use, reproduction, or distribution of Your modifications, or
140
+ for any such Derivative Works as a whole, provided Your use,
141
+ reproduction, and distribution of the Work otherwise complies with
142
+ the conditions stated in this License.
143
+
144
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
145
+ any Contribution intentionally submitted for inclusion in the Work
146
+ by You to the Licensor shall be under the terms and conditions of
147
+ this License, without any additional terms or conditions.
148
+ Notwithstanding the above, nothing herein shall supersede or modify
149
+ the terms of any separate license agreement you may have executed
150
+ with Licensor regarding such Contributions.
151
+
152
+ 6. Trademarks. This License does not grant permission to use the trade
153
+ names, trademarks, service marks, or product names of the Licensor,
154
+ except as required for reasonable and customary use in describing the
155
+ origin of the Work and reproducing the content of the NOTICE file.
156
+
157
+ 7. Disclaimer of Warranty. Unless required by applicable law or
158
+ agreed to in writing, Licensor provides the Work (and each
159
+ Contributor provides its Contributions) on an "AS IS" BASIS,
160
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
161
+ implied, including, without limitation, any warranties or conditions
162
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
163
+ PARTICULAR PURPOSE. You are solely responsible for determining the
164
+ appropriateness of using or redistributing the Work and assume any
165
+ risks associated with Your exercise of permissions under this License.
166
+
167
+ 8. Limitation of Liability. In no event and under no legal theory,
168
+ whether in tort (including negligence), contract, or otherwise,
169
+ unless required by applicable law (such as deliberate and grossly
170
+ negligent acts) or agreed to in writing, shall any Contributor be
171
+ liable to You for damages, including any direct, indirect, special,
172
+ incidental, or consequential damages of any character arising as a
173
+ result of this License or out of the use or inability to use the
174
+ Work (including but not limited to damages for loss of goodwill,
175
+ work stoppage, computer failure or malfunction, or any and all
176
+ other commercial damages or losses), even if such Contributor
177
+ has been advised of the possibility of such damages.
178
+
179
+ 9. Accepting Warranty or Additional Liability. While redistributing
180
+ the Work or Derivative Works thereof, You may choose to offer,
181
+ and charge a fee for, acceptance of support, warranty, indemnity,
182
+ or other liability obligations and/or rights consistent with this
183
+ License. However, in accepting such obligations, You may act only
184
+ on Your own behalf and on Your sole responsibility, not on behalf
185
+ of any other Contributor, and only if You agree to indemnify,
186
+ defend, and hold each Contributor harmless for any liability
187
+ incurred by, or claims asserted against, such Contributor by reason
188
+ of your accepting any such warranty or additional liability.
189
+
190
+ END OF TERMS AND CONDITIONS
191
+
192
+ APPENDIX: How to apply the Apache License to your work.
193
+
194
+ To apply the Apache License to your work, attach the following
195
+ boilerplate notice, with the fields enclosed by brackets "[]"
196
+ replaced with your own identifying information. (Don't include
197
+ the brackets!) The text should be enclosed in the appropriate
198
+ comment syntax for the file format. We also recommend that a
199
+ file or class name and description of purpose be included on the
200
+ same "printed page" as the copyright notice for easier
201
+ identification within third-party archives.
202
+
203
+ Copyright [yyyy] [name of copyright owner]
204
+
205
+ Licensed under the Apache License, Version 2.0 (the "License");
206
+ you may not use this file except in compliance with the License.
207
+ You may obtain a copy of the License at
208
+
209
+ http://www.apache.org/licenses/LICENSE-2.0
210
+
211
+ Unless required by applicable law or agreed to in writing, software
212
+ distributed under the License is distributed on an "AS IS" BASIS,
213
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
214
+ See the License for the specific language governing permissions and
215
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # @embedpdf/plugin-measurement
2
+
3
+ Document-scoped page calibration, distance authoring, and measurement readouts.
4
+ Install alongside `annotationPlugin()` and `interactionPlugin()`:
5
+
6
+ ```ts
7
+ import {
8
+ measurementPlugin,
9
+ MeasurementToken,
10
+ } from '@embedpdf/plugin-measurement';
11
+
12
+ const plugins = [
13
+ /* interaction, annotation, ... */ measurementPlugin({
14
+ defaultScale: 'metric',
15
+ }),
16
+ ];
17
+ const measurements = viewer.get(MeasurementToken);
18
+ await measurements.calibrate(pageObjectNumber, fromPdfPoint, toPdfPoint, {
19
+ value: 5,
20
+ unit: 'm',
21
+ });
22
+ ```
23
+
24
+ `calibrate` points are original PDF user space: y-up, including the page's CropBox
25
+ origin. The line's length is rounded through the engine's float32 coordinate
26
+ rules. `UserUnit` participates in ratio presets; a calibration from a known
27
+ length already expresses the full conversion.
28
+
29
+ The annotation plugin supplies the `distance` and `calibrate` tools. Distance
30
+ captures the last viewport containing its **first point**. A foreign or invalid
31
+ winning viewport prevents creation; a default is used only outside all viewports.
32
+ Until viewport reads finish, distance creation is unavailable.
33
+
34
+ `setPageScale`, `setPreset`, `setUnit`, `setPrecision`, and `calibrate` accept
35
+ `{ recalculate?: boolean, allPages?: boolean }`. Recalculation defaults to true.
36
+ Every annotation stores its own scale snapshot. Setting `recalculate: false`
37
+ changes subsequent measurements while preserving existing values.
38
+
39
+ Recalculation reports list updated, skipped, and failed annotations. A page-wide
40
+ annotation read failure appears as `error`. A single-page viewport write failure
41
+ rejects before annotation writes; all-pages operations return per-page
42
+ `scaleError` results and finish the remaining pages. Page scales persist in the
43
+ PDF when the engine provides `page.measure`; older engines retain them for the
44
+ session (`pageScale().persistent === false`).
45
+
46
+ `canCalibrate()` mirrors `doc.annotate.modify`; `canMeasure(pon)` combines
47
+ annotation creation authority and viewport readiness. Per-record permissions and
48
+ PDF flags gate recalculation and caption dragging. Distance contents are derived
49
+ and cannot be edited as comment text.
50
+
51
+ React consumers import `measurementPlugin`, `useMeasurement`, `usePageScale`, and
52
+ `useMeasurementReadout` from `@embedpdf/react/measurement`. The full viewer includes
53
+ a Measure toolbar, scale sidebar, and known-length calibration dialog.
54
+
55
+ Distance captions use standard PDF line-axis offsets. Their live layout uses an
56
+ estimated Helvetica advance; committed annotations render the native PDF
57
+ appearance. Perimeter and area authoring tools are not included in this package's
58
+ initial viewer increment; readouts and page recalculation support their existing
59
+ engine annotations.
@@ -0,0 +1,101 @@
1
+ import { AnnotationRef, AnnotationRef as AnnotationRef$1, AreaUnit, AreaUnit as AreaUnit$1, LengthUnit, LengthUnit as LengthUnit$1, MeasurementReadout, MeasurementReadout as MeasurementReadout$1, MeasurementUnavailable, MeasurementUnavailable as MeasurementUnavailable$1, PageMeasurementViewport, PdfMeasure, PdfMeasure as PdfMeasure$1, PdfMeasurement, PdfPoint, SerializedEngineError } from "@embedpdf/engine-core/runtime";
2
+ import { RecalibrationReport, RecalibrationReport as RecalibrationReport$1 } from "@embedpdf/plugin-annotation/contract/host";
3
+ //#region src/types.d.ts
4
+ interface ScalePreset {
5
+ id: string;
6
+ label: string;
7
+ paper: number;
8
+ real: number;
9
+ unit: LengthUnit;
10
+ }
11
+ interface MeasurementConfig {
12
+ defaultScale?: 'metric' | 'imperial' | PdfMeasure;
13
+ presets?: ScalePreset[];
14
+ }
15
+ interface SetScaleOptions {
16
+ recalculate?: boolean;
17
+ allPages?: boolean;
18
+ }
19
+ interface PageScale {
20
+ measure: PdfMeasurement | null;
21
+ source: 'owned' | 'foreign' | 'default';
22
+ ready: boolean;
23
+ persistent: boolean;
24
+ error?: SerializedEngineError;
25
+ }
26
+ interface CalibrationRequest {
27
+ pon: number;
28
+ from: PdfPoint;
29
+ to: PdfPoint;
30
+ userSpaceLength: number;
31
+ }
32
+ /** A failed viewport write is reported per page for an all-pages operation.
33
+ * Single-page viewport failures reject before any annotation write. */
34
+ type ScaleChangeReport = (RecalibrationReport & {
35
+ scaleError?: never;
36
+ }) | {
37
+ pon: number;
38
+ scale?: never;
39
+ error?: never;
40
+ updated: [];
41
+ skipped: [];
42
+ failed: [];
43
+ scaleError: SerializedEngineError;
44
+ };
45
+ interface MeasurementState {
46
+ pages: Record<number, {
47
+ viewports: PageMeasurementViewport[];
48
+ scale: PageScale;
49
+ }>;
50
+ pending: number;
51
+ calibration: CalibrationRequest | null;
52
+ reports: ScaleChangeReport[];
53
+ }
54
+ type MeasurementAction = {
55
+ type: 'PAGE_SCALE';
56
+ pon: number;
57
+ viewports: PageMeasurementViewport[];
58
+ scale: PageScale;
59
+ } | {
60
+ type: 'PENDING';
61
+ delta: number;
62
+ } | {
63
+ type: 'CALIBRATION';
64
+ request: CalibrationRequest | null;
65
+ } | {
66
+ type: 'REPORTS';
67
+ reports: ScaleChangeReport[];
68
+ };
69
+ interface MeasurementCapability {
70
+ canCalibrate(): boolean;
71
+ canMeasure(pon: number): boolean;
72
+ pageScale(pon: number): PageScale;
73
+ isBusy(): boolean;
74
+ lastReports(): ScaleChangeReport[];
75
+ prepare(pon: number): Promise<void>;
76
+ setPageScale(pon: number, measure: PdfMeasure, opts?: SetScaleOptions): Promise<ScaleChangeReport[]>;
77
+ calibrate(pon: number, from: PdfPoint, to: PdfPoint, real: {
78
+ value: number;
79
+ unit: LengthUnit;
80
+ }, opts?: SetScaleOptions): Promise<ScaleChangeReport[]>;
81
+ setUnit(pon: number | 'all', unit: LengthUnit, areaUnit?: AreaUnit, opts?: SetScaleOptions): Promise<ScaleChangeReport[]>;
82
+ setPrecision(pon: number | 'all', precision: number, opts?: SetScaleOptions): Promise<ScaleChangeReport[]>;
83
+ setPreset(pon: number, id: string, opts?: SetScaleOptions): Promise<ScaleChangeReport[]>;
84
+ presets(): readonly ScalePreset[];
85
+ units(): readonly LengthUnit[];
86
+ areaUnits(): readonly AreaUnit[];
87
+ setAreaUnit(pon: number | 'all', unit: AreaUnit, options?: SetScaleOptions): Promise<ScaleChangeReport[]>;
88
+ readout(ref: AnnotationRef): MeasurementReadout | MeasurementUnavailable;
89
+ startCalibration(): void;
90
+ calibrationRequest(): CalibrationRequest | null;
91
+ dismissCalibration(): void;
92
+ onCalibrationRequested(cb: (request: CalibrationRequest) => void): () => void;
93
+ onScaleChanged(cb: (event: {
94
+ pon: number;
95
+ report: ScaleChangeReport;
96
+ }) => void): () => void;
97
+ }
98
+ declare const MeasurementToken: import("@embedpdf/core").CapabilityToken<MeasurementCapability>;
99
+ //#endregion
100
+ export { SetScaleOptions as _, MeasurementAction as a, MeasurementReadout$1 as c, MeasurementUnavailable$1 as d, PageScale as f, ScalePreset as g, ScaleChangeReport as h, LengthUnit$1 as i, MeasurementState as l, RecalibrationReport$1 as m, AreaUnit$1 as n, MeasurementCapability as o, PdfMeasure$1 as p, CalibrationRequest as r, MeasurementConfig as s, AnnotationRef$1 as t, MeasurementToken as u };
101
+ //# sourceMappingURL=contract-BnLRuw-Z.d.cts.map
@@ -0,0 +1,101 @@
1
+ import { RecalibrationReport, RecalibrationReport as RecalibrationReport$1 } from "@embedpdf/plugin-annotation/contract/host";
2
+ import { AnnotationRef, AnnotationRef as AnnotationRef$1, AreaUnit, AreaUnit as AreaUnit$1, LengthUnit, LengthUnit as LengthUnit$1, MeasurementReadout, MeasurementReadout as MeasurementReadout$1, MeasurementUnavailable, MeasurementUnavailable as MeasurementUnavailable$1, PageMeasurementViewport, PdfMeasure, PdfMeasure as PdfMeasure$1, PdfMeasurement, PdfPoint, SerializedEngineError } from "@embedpdf/engine-core/runtime";
3
+ //#region src/types.d.ts
4
+ interface ScalePreset {
5
+ id: string;
6
+ label: string;
7
+ paper: number;
8
+ real: number;
9
+ unit: LengthUnit;
10
+ }
11
+ interface MeasurementConfig {
12
+ defaultScale?: 'metric' | 'imperial' | PdfMeasure;
13
+ presets?: ScalePreset[];
14
+ }
15
+ interface SetScaleOptions {
16
+ recalculate?: boolean;
17
+ allPages?: boolean;
18
+ }
19
+ interface PageScale {
20
+ measure: PdfMeasurement | null;
21
+ source: 'owned' | 'foreign' | 'default';
22
+ ready: boolean;
23
+ persistent: boolean;
24
+ error?: SerializedEngineError;
25
+ }
26
+ interface CalibrationRequest {
27
+ pon: number;
28
+ from: PdfPoint;
29
+ to: PdfPoint;
30
+ userSpaceLength: number;
31
+ }
32
+ /** A failed viewport write is reported per page for an all-pages operation.
33
+ * Single-page viewport failures reject before any annotation write. */
34
+ type ScaleChangeReport = (RecalibrationReport & {
35
+ scaleError?: never;
36
+ }) | {
37
+ pon: number;
38
+ scale?: never;
39
+ error?: never;
40
+ updated: [];
41
+ skipped: [];
42
+ failed: [];
43
+ scaleError: SerializedEngineError;
44
+ };
45
+ interface MeasurementState {
46
+ pages: Record<number, {
47
+ viewports: PageMeasurementViewport[];
48
+ scale: PageScale;
49
+ }>;
50
+ pending: number;
51
+ calibration: CalibrationRequest | null;
52
+ reports: ScaleChangeReport[];
53
+ }
54
+ type MeasurementAction = {
55
+ type: 'PAGE_SCALE';
56
+ pon: number;
57
+ viewports: PageMeasurementViewport[];
58
+ scale: PageScale;
59
+ } | {
60
+ type: 'PENDING';
61
+ delta: number;
62
+ } | {
63
+ type: 'CALIBRATION';
64
+ request: CalibrationRequest | null;
65
+ } | {
66
+ type: 'REPORTS';
67
+ reports: ScaleChangeReport[];
68
+ };
69
+ interface MeasurementCapability {
70
+ canCalibrate(): boolean;
71
+ canMeasure(pon: number): boolean;
72
+ pageScale(pon: number): PageScale;
73
+ isBusy(): boolean;
74
+ lastReports(): ScaleChangeReport[];
75
+ prepare(pon: number): Promise<void>;
76
+ setPageScale(pon: number, measure: PdfMeasure, opts?: SetScaleOptions): Promise<ScaleChangeReport[]>;
77
+ calibrate(pon: number, from: PdfPoint, to: PdfPoint, real: {
78
+ value: number;
79
+ unit: LengthUnit;
80
+ }, opts?: SetScaleOptions): Promise<ScaleChangeReport[]>;
81
+ setUnit(pon: number | 'all', unit: LengthUnit, areaUnit?: AreaUnit, opts?: SetScaleOptions): Promise<ScaleChangeReport[]>;
82
+ setPrecision(pon: number | 'all', precision: number, opts?: SetScaleOptions): Promise<ScaleChangeReport[]>;
83
+ setPreset(pon: number, id: string, opts?: SetScaleOptions): Promise<ScaleChangeReport[]>;
84
+ presets(): readonly ScalePreset[];
85
+ units(): readonly LengthUnit[];
86
+ areaUnits(): readonly AreaUnit[];
87
+ setAreaUnit(pon: number | 'all', unit: AreaUnit, options?: SetScaleOptions): Promise<ScaleChangeReport[]>;
88
+ readout(ref: AnnotationRef): MeasurementReadout | MeasurementUnavailable;
89
+ startCalibration(): void;
90
+ calibrationRequest(): CalibrationRequest | null;
91
+ dismissCalibration(): void;
92
+ onCalibrationRequested(cb: (request: CalibrationRequest) => void): () => void;
93
+ onScaleChanged(cb: (event: {
94
+ pon: number;
95
+ report: ScaleChangeReport;
96
+ }) => void): () => void;
97
+ }
98
+ declare const MeasurementToken: import("@embedpdf/core").CapabilityToken<MeasurementCapability>;
99
+ //#endregion
100
+ export { SetScaleOptions as _, MeasurementAction as a, MeasurementReadout$1 as c, MeasurementUnavailable$1 as d, PageScale as f, ScalePreset as g, ScaleChangeReport as h, LengthUnit$1 as i, MeasurementState as l, RecalibrationReport$1 as m, AreaUnit$1 as n, MeasurementCapability as o, PdfMeasure$1 as p, CalibrationRequest as r, MeasurementConfig as s, AnnotationRef$1 as t, MeasurementToken as u };
101
+ //# sourceMappingURL=contract-C_ugpRGJ.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { createCapabilityToken } from "@embedpdf/core";
2
+ //#region src/types.ts
3
+ const MeasurementToken = createCapabilityToken("measurement");
4
+ //#endregion
5
+ export { MeasurementToken as t };
6
+
7
+ //# sourceMappingURL=contract-DO0emN-T.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-DO0emN-T.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import { createCapabilityToken } from '@embedpdf/core';\nimport type {\n AnnotationRef,\n AreaUnit,\n LengthUnit,\n MeasurementReadout,\n MeasurementUnavailable,\n PageMeasurementViewport,\n PdfMeasure,\n PdfMeasurement,\n PdfPoint,\n SerializedEngineError,\n} from '@embedpdf/engine-core/runtime';\nimport type { RecalibrationReport } from '@embedpdf/plugin-annotation/contract/host';\n\nexport type { RecalibrationReport } from '@embedpdf/plugin-annotation/contract/host';\n\nexport type {\n LengthUnit,\n AreaUnit,\n PdfMeasure,\n MeasurementReadout,\n MeasurementUnavailable,\n} from '@embedpdf/engine-core/runtime';\n\nexport interface ScalePreset {\n id: string;\n label: string;\n paper: number;\n real: number;\n unit: LengthUnit;\n}\n\nexport interface MeasurementConfig {\n defaultScale?: 'metric' | 'imperial' | PdfMeasure;\n presets?: ScalePreset[];\n}\n\nexport interface SetScaleOptions {\n recalculate?: boolean;\n allPages?: boolean;\n}\n\nexport interface PageScale {\n measure: PdfMeasurement | null;\n source: 'owned' | 'foreign' | 'default';\n ready: boolean;\n persistent: boolean;\n error?: SerializedEngineError;\n}\n\nexport interface CalibrationRequest {\n pon: number;\n from: PdfPoint;\n to: PdfPoint;\n userSpaceLength: number;\n}\n/** A failed viewport write is reported per page for an all-pages operation.\n * Single-page viewport failures reject before any annotation write. */\nexport type ScaleChangeReport =\n | (RecalibrationReport & { scaleError?: never })\n | {\n pon: number;\n scale?: never;\n error?: never;\n updated: [];\n skipped: [];\n failed: [];\n scaleError: SerializedEngineError;\n };\n\nexport interface MeasurementState {\n pages: Record<number, { viewports: PageMeasurementViewport[]; scale: PageScale }>;\n pending: number;\n calibration: CalibrationRequest | null;\n reports: ScaleChangeReport[];\n}\n\nexport type MeasurementAction =\n | { type: 'PAGE_SCALE'; pon: number; viewports: PageMeasurementViewport[]; scale: PageScale }\n | { type: 'PENDING'; delta: number }\n | { type: 'CALIBRATION'; request: CalibrationRequest | null }\n | { type: 'REPORTS'; reports: ScaleChangeReport[] };\n\nexport interface MeasurementCapability {\n canCalibrate(): boolean;\n canMeasure(pon: number): boolean;\n pageScale(pon: number): PageScale;\n isBusy(): boolean;\n lastReports(): ScaleChangeReport[];\n prepare(pon: number): Promise<void>;\n setPageScale(\n pon: number,\n measure: PdfMeasure,\n opts?: SetScaleOptions,\n ): Promise<ScaleChangeReport[]>;\n calibrate(\n pon: number,\n from: PdfPoint,\n to: PdfPoint,\n real: { value: number; unit: LengthUnit },\n opts?: SetScaleOptions,\n ): Promise<ScaleChangeReport[]>;\n setUnit(\n pon: number | 'all',\n unit: LengthUnit,\n areaUnit?: AreaUnit,\n opts?: SetScaleOptions,\n ): Promise<ScaleChangeReport[]>;\n setPrecision(\n pon: number | 'all',\n precision: number,\n opts?: SetScaleOptions,\n ): Promise<ScaleChangeReport[]>;\n setPreset(pon: number, id: string, opts?: SetScaleOptions): Promise<ScaleChangeReport[]>;\n presets(): readonly ScalePreset[];\n units(): readonly LengthUnit[];\n areaUnits(): readonly AreaUnit[];\n setAreaUnit(\n pon: number | 'all',\n unit: AreaUnit,\n options?: SetScaleOptions,\n ): Promise<ScaleChangeReport[]>;\n readout(ref: AnnotationRef): MeasurementReadout | MeasurementUnavailable;\n startCalibration(): void;\n calibrationRequest(): CalibrationRequest | null;\n dismissCalibration(): void;\n onCalibrationRequested(cb: (request: CalibrationRequest) => void): () => void;\n onScaleChanged(cb: (event: { pon: number; report: ScaleChangeReport }) => void): () => void;\n}\n\nexport const MeasurementToken = createCapabilityToken<MeasurementCapability>('measurement');\n"],"mappings":";;AAmIA,MAAa,mBAAmB,sBAA6C,aAAa"}
@@ -0,0 +1,11 @@
1
+ //#region src/types.ts
2
+ const MeasurementToken = (0, require("@embedpdf/core").createCapabilityToken)("measurement");
3
+ //#endregion
4
+ Object.defineProperty(exports, "MeasurementToken", {
5
+ enumerable: true,
6
+ get: function() {
7
+ return MeasurementToken;
8
+ }
9
+ });
10
+
11
+ //# sourceMappingURL=contract-Dy7X9nSj.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-Dy7X9nSj.cjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["import { createCapabilityToken } from '@embedpdf/core';\nimport type {\n AnnotationRef,\n AreaUnit,\n LengthUnit,\n MeasurementReadout,\n MeasurementUnavailable,\n PageMeasurementViewport,\n PdfMeasure,\n PdfMeasurement,\n PdfPoint,\n SerializedEngineError,\n} from '@embedpdf/engine-core/runtime';\nimport type { RecalibrationReport } from '@embedpdf/plugin-annotation/contract/host';\n\nexport type { RecalibrationReport } from '@embedpdf/plugin-annotation/contract/host';\n\nexport type {\n LengthUnit,\n AreaUnit,\n PdfMeasure,\n MeasurementReadout,\n MeasurementUnavailable,\n} from '@embedpdf/engine-core/runtime';\n\nexport interface ScalePreset {\n id: string;\n label: string;\n paper: number;\n real: number;\n unit: LengthUnit;\n}\n\nexport interface MeasurementConfig {\n defaultScale?: 'metric' | 'imperial' | PdfMeasure;\n presets?: ScalePreset[];\n}\n\nexport interface SetScaleOptions {\n recalculate?: boolean;\n allPages?: boolean;\n}\n\nexport interface PageScale {\n measure: PdfMeasurement | null;\n source: 'owned' | 'foreign' | 'default';\n ready: boolean;\n persistent: boolean;\n error?: SerializedEngineError;\n}\n\nexport interface CalibrationRequest {\n pon: number;\n from: PdfPoint;\n to: PdfPoint;\n userSpaceLength: number;\n}\n/** A failed viewport write is reported per page for an all-pages operation.\n * Single-page viewport failures reject before any annotation write. */\nexport type ScaleChangeReport =\n | (RecalibrationReport & { scaleError?: never })\n | {\n pon: number;\n scale?: never;\n error?: never;\n updated: [];\n skipped: [];\n failed: [];\n scaleError: SerializedEngineError;\n };\n\nexport interface MeasurementState {\n pages: Record<number, { viewports: PageMeasurementViewport[]; scale: PageScale }>;\n pending: number;\n calibration: CalibrationRequest | null;\n reports: ScaleChangeReport[];\n}\n\nexport type MeasurementAction =\n | { type: 'PAGE_SCALE'; pon: number; viewports: PageMeasurementViewport[]; scale: PageScale }\n | { type: 'PENDING'; delta: number }\n | { type: 'CALIBRATION'; request: CalibrationRequest | null }\n | { type: 'REPORTS'; reports: ScaleChangeReport[] };\n\nexport interface MeasurementCapability {\n canCalibrate(): boolean;\n canMeasure(pon: number): boolean;\n pageScale(pon: number): PageScale;\n isBusy(): boolean;\n lastReports(): ScaleChangeReport[];\n prepare(pon: number): Promise<void>;\n setPageScale(\n pon: number,\n measure: PdfMeasure,\n opts?: SetScaleOptions,\n ): Promise<ScaleChangeReport[]>;\n calibrate(\n pon: number,\n from: PdfPoint,\n to: PdfPoint,\n real: { value: number; unit: LengthUnit },\n opts?: SetScaleOptions,\n ): Promise<ScaleChangeReport[]>;\n setUnit(\n pon: number | 'all',\n unit: LengthUnit,\n areaUnit?: AreaUnit,\n opts?: SetScaleOptions,\n ): Promise<ScaleChangeReport[]>;\n setPrecision(\n pon: number | 'all',\n precision: number,\n opts?: SetScaleOptions,\n ): Promise<ScaleChangeReport[]>;\n setPreset(pon: number, id: string, opts?: SetScaleOptions): Promise<ScaleChangeReport[]>;\n presets(): readonly ScalePreset[];\n units(): readonly LengthUnit[];\n areaUnits(): readonly AreaUnit[];\n setAreaUnit(\n pon: number | 'all',\n unit: AreaUnit,\n options?: SetScaleOptions,\n ): Promise<ScaleChangeReport[]>;\n readout(ref: AnnotationRef): MeasurementReadout | MeasurementUnavailable;\n startCalibration(): void;\n calibrationRequest(): CalibrationRequest | null;\n dismissCalibration(): void;\n onCalibrationRequested(cb: (request: CalibrationRequest) => void): () => void;\n onScaleChanged(cb: (event: { pon: number; report: ScaleChangeReport }) => void): () => void;\n}\n\nexport const MeasurementToken = createCapabilityToken<MeasurementCapability>('measurement');\n"],"mappings":";AAmIA,MAAa,oBAAA,2BAAA,CAAA,CAAA,sBAAA,CAAgE,aAAa"}
@@ -0,0 +1,3 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_contract = require("./contract-Dy7X9nSj.cjs");
3
+ exports.MeasurementToken = require_contract.MeasurementToken;
@@ -0,0 +1,2 @@
1
+ import { _ as SetScaleOptions, a as MeasurementAction, c as MeasurementReadout, d as MeasurementUnavailable, f as PageScale, g as ScalePreset, h as ScaleChangeReport, i as LengthUnit, l as MeasurementState, m as RecalibrationReport, n as AreaUnit, o as MeasurementCapability, p as PdfMeasure, r as CalibrationRequest, s as MeasurementConfig, t as AnnotationRef, u as MeasurementToken } from "./contract-BnLRuw-Z.cjs";
2
+ export { type AnnotationRef, type AreaUnit, type CalibrationRequest, type LengthUnit, type MeasurementAction, type MeasurementCapability, type MeasurementConfig, type MeasurementReadout, type MeasurementState, MeasurementToken, type MeasurementUnavailable, type PageScale, type PdfMeasure, type RecalibrationReport, type ScaleChangeReport, type ScalePreset, type SetScaleOptions };
@@ -0,0 +1,2 @@
1
+ import { _ as SetScaleOptions, a as MeasurementAction, c as MeasurementReadout, d as MeasurementUnavailable, f as PageScale, g as ScalePreset, h as ScaleChangeReport, i as LengthUnit, l as MeasurementState, m as RecalibrationReport, n as AreaUnit, o as MeasurementCapability, p as PdfMeasure, r as CalibrationRequest, s as MeasurementConfig, t as AnnotationRef, u as MeasurementToken } from "./contract-C_ugpRGJ.js";
2
+ export { type AnnotationRef, type AreaUnit, type CalibrationRequest, type LengthUnit, type MeasurementAction, type MeasurementCapability, type MeasurementConfig, type MeasurementReadout, type MeasurementState, MeasurementToken, type MeasurementUnavailable, type PageScale, type PdfMeasure, type RecalibrationReport, type ScaleChangeReport, type ScalePreset, type SetScaleOptions };
@@ -0,0 +1,2 @@
1
+ import { t as MeasurementToken } from "./contract-DO0emN-T.js";
2
+ export { MeasurementToken };