@progress/kendo-pdfviewer-common 0.3.0-dev.202409251459 → 0.3.0-dev.202410100645

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 (149) hide show
  1. package/dist/es/annotations/annotation-editor-layer-builder.js +139 -0
  2. package/dist/es/annotations/annotation-editor-layer.js +780 -0
  3. package/dist/es/annotations/annotation-editor-ui-manager.js +1690 -0
  4. package/dist/es/annotations/annotation-layer-builder.js +217 -0
  5. package/dist/es/annotations/annotation-layer.js +2793 -0
  6. package/dist/es/annotations/draw-layer-builder.js +65 -0
  7. package/dist/es/annotations/draw-layer.js +220 -0
  8. package/dist/es/annotations/editors/annotation-editor.js +1519 -0
  9. package/dist/es/annotations/editors/free-text-editor.js +783 -0
  10. package/dist/es/annotations/editors/highlight-editor.js +717 -0
  11. package/dist/es/annotations/editors/outliner.js +747 -0
  12. package/dist/es/annotations/helpers/annotation-storage.js +294 -0
  13. package/dist/es/annotations/helpers/color-manager.js +72 -0
  14. package/dist/es/annotations/helpers/command-manager.js +133 -0
  15. package/dist/es/annotations/helpers/id-manager.js +34 -0
  16. package/dist/es/annotations/helpers/image-manager.js +176 -0
  17. package/dist/es/annotations/helpers/text-accessibility-manager.js +212 -0
  18. package/dist/es/annotations/helpers/tools.js +19 -0
  19. package/dist/es/annotations/shared/display_utils.js +1024 -0
  20. package/dist/es/annotations/shared/event_utils.js +213 -0
  21. package/dist/es/annotations/shared/murmurhash3.js +126 -0
  22. package/dist/es/annotations/shared/scripting_utils.js +90 -0
  23. package/dist/es/annotations/shared/ui_utils.js +823 -0
  24. package/dist/es/annotations/shared/utils.js +909 -0
  25. package/dist/es/common/component.js +33 -0
  26. package/dist/es/common/core.js +91 -0
  27. package/dist/es/common/dom.js +11 -0
  28. package/dist/es/common/main.js +4 -0
  29. package/dist/es/common/math.js +1 -0
  30. package/dist/es/enums/PdfViewerInteractionMode.js +6 -0
  31. package/dist/es/links/link-service.js +505 -0
  32. package/dist/es/main.js +2 -0
  33. package/dist/es/scroller.js +29 -30
  34. package/dist/es/text/text-layer-builder.js +288 -0
  35. package/dist/es/utils.js +5 -5
  36. package/dist/es/widget/page.js +762 -0
  37. package/dist/es/widget/pdfviewer.js +1659 -0
  38. package/dist/es2015/annotations/annotation-editor-layer-builder.js +139 -0
  39. package/dist/es2015/annotations/annotation-editor-layer.js +780 -0
  40. package/dist/es2015/annotations/annotation-editor-ui-manager.js +1690 -0
  41. package/dist/es2015/annotations/annotation-layer-builder.js +217 -0
  42. package/dist/es2015/annotations/annotation-layer.js +2793 -0
  43. package/dist/es2015/annotations/draw-layer-builder.js +65 -0
  44. package/dist/es2015/annotations/draw-layer.js +220 -0
  45. package/dist/es2015/annotations/editors/annotation-editor.js +1519 -0
  46. package/dist/es2015/annotations/editors/free-text-editor.js +783 -0
  47. package/dist/es2015/annotations/editors/highlight-editor.js +717 -0
  48. package/dist/es2015/annotations/editors/outliner.js +747 -0
  49. package/dist/es2015/annotations/helpers/annotation-storage.js +294 -0
  50. package/dist/es2015/annotations/helpers/color-manager.js +72 -0
  51. package/dist/es2015/annotations/helpers/command-manager.js +133 -0
  52. package/dist/es2015/annotations/helpers/id-manager.js +34 -0
  53. package/dist/es2015/annotations/helpers/image-manager.js +176 -0
  54. package/dist/es2015/annotations/helpers/text-accessibility-manager.js +212 -0
  55. package/dist/es2015/annotations/helpers/tools.js +19 -0
  56. package/dist/es2015/annotations/shared/display_utils.js +1024 -0
  57. package/dist/es2015/annotations/shared/event_utils.js +213 -0
  58. package/dist/es2015/annotations/shared/murmurhash3.js +126 -0
  59. package/dist/es2015/annotations/shared/scripting_utils.js +90 -0
  60. package/dist/es2015/annotations/shared/ui_utils.js +823 -0
  61. package/dist/es2015/annotations/shared/utils.js +909 -0
  62. package/dist/es2015/common/component.js +33 -0
  63. package/dist/es2015/common/core.js +91 -0
  64. package/dist/es2015/common/dom.js +11 -0
  65. package/dist/es2015/common/main.js +4 -0
  66. package/dist/es2015/common/math.js +1 -0
  67. package/dist/es2015/enums/PdfViewerInteractionMode.js +6 -0
  68. package/dist/es2015/links/link-service.js +505 -0
  69. package/dist/es2015/main.js +2 -0
  70. package/dist/es2015/scroller.js +29 -30
  71. package/dist/es2015/text/text-layer-builder.js +288 -0
  72. package/dist/es2015/utils.js +5 -5
  73. package/dist/es2015/widget/page.js +762 -0
  74. package/dist/es2015/widget/pdfviewer.js +1659 -0
  75. package/dist/npm/annotations/annotation-editor-layer-builder.d.ts +39 -0
  76. package/dist/npm/annotations/annotation-editor-layer-builder.js +142 -0
  77. package/dist/npm/annotations/annotation-editor-layer.d.ts +196 -0
  78. package/dist/npm/annotations/annotation-editor-layer.js +783 -0
  79. package/dist/npm/annotations/annotation-editor-ui-manager.d.ts +281 -0
  80. package/dist/npm/annotations/annotation-editor-ui-manager.js +1694 -0
  81. package/dist/npm/annotations/annotation-layer-builder.d.ts +58 -0
  82. package/dist/npm/annotations/annotation-layer-builder.js +220 -0
  83. package/dist/npm/annotations/annotation-layer.d.ts +134 -0
  84. package/dist/npm/annotations/annotation-layer.js +2794 -0
  85. package/dist/npm/annotations/draw-layer-builder.d.ts +21 -0
  86. package/dist/npm/annotations/draw-layer-builder.js +68 -0
  87. package/dist/npm/annotations/draw-layer.d.ts +33 -0
  88. package/dist/npm/annotations/draw-layer.js +223 -0
  89. package/dist/npm/annotations/editors/annotation-editor.d.ts +349 -0
  90. package/dist/npm/annotations/editors/annotation-editor.js +1523 -0
  91. package/dist/npm/annotations/editors/free-text-editor.d.ts +108 -0
  92. package/dist/npm/annotations/editors/free-text-editor.js +786 -0
  93. package/dist/npm/annotations/editors/highlight-editor.d.ts +114 -0
  94. package/dist/npm/annotations/editors/highlight-editor.js +717 -0
  95. package/dist/npm/annotations/editors/outliner.d.ts +51 -0
  96. package/dist/npm/annotations/editors/outliner.js +750 -0
  97. package/dist/npm/annotations/helpers/annotation-storage.d.ts +98 -0
  98. package/dist/npm/annotations/helpers/annotation-storage.js +299 -0
  99. package/dist/npm/annotations/helpers/color-manager.d.ts +6 -0
  100. package/dist/npm/annotations/helpers/color-manager.js +76 -0
  101. package/dist/npm/annotations/helpers/command-manager.d.ts +42 -0
  102. package/dist/npm/annotations/helpers/command-manager.js +137 -0
  103. package/dist/npm/annotations/helpers/id-manager.d.ts +6 -0
  104. package/dist/npm/annotations/helpers/id-manager.js +38 -0
  105. package/dist/npm/annotations/helpers/image-manager.d.ts +18 -0
  106. package/dist/npm/annotations/helpers/image-manager.js +180 -0
  107. package/dist/npm/annotations/helpers/text-accessibility-manager.d.ts +36 -0
  108. package/dist/npm/annotations/helpers/text-accessibility-manager.js +215 -0
  109. package/dist/npm/annotations/helpers/tools.d.ts +1 -0
  110. package/dist/npm/annotations/helpers/tools.js +23 -0
  111. package/dist/npm/annotations/shared/display_utils.d.ts +6 -0
  112. package/dist/npm/annotations/shared/display_utils.js +1030 -0
  113. package/dist/npm/annotations/shared/event_utils.d.ts +33 -0
  114. package/dist/npm/annotations/shared/event_utils.js +165 -0
  115. package/dist/npm/annotations/shared/murmurhash3.d.ts +8 -0
  116. package/dist/npm/annotations/shared/murmurhash3.js +129 -0
  117. package/dist/npm/annotations/shared/scripting_utils.d.ts +17 -0
  118. package/dist/npm/annotations/shared/scripting_utils.js +93 -0
  119. package/dist/npm/annotations/shared/ui_utils.d.ts +54 -0
  120. package/dist/npm/annotations/shared/ui_utils.js +250 -0
  121. package/dist/npm/annotations/shared/utils.d.ts +148 -0
  122. package/dist/npm/annotations/shared/utils.js +872 -0
  123. package/dist/npm/common/component.d.ts +9 -0
  124. package/dist/npm/common/component.js +37 -0
  125. package/dist/npm/common/core.d.ts +18 -0
  126. package/dist/npm/common/core.js +112 -0
  127. package/dist/npm/common/dom.d.ts +3 -0
  128. package/dist/npm/common/dom.js +17 -0
  129. package/dist/npm/common/main.d.ts +4 -0
  130. package/dist/npm/common/main.js +7 -0
  131. package/dist/npm/common/math.d.ts +1 -0
  132. package/dist/npm/common/math.js +5 -0
  133. package/dist/npm/enums/PdfViewerInteractionMode.d.ts +4 -0
  134. package/dist/npm/enums/PdfViewerInteractionMode.js +9 -0
  135. package/dist/npm/links/link-service.d.ts +116 -0
  136. package/dist/npm/links/link-service.js +501 -0
  137. package/dist/npm/main.d.ts +2 -0
  138. package/dist/npm/main.js +2 -0
  139. package/dist/npm/scroller.d.ts +7 -3
  140. package/dist/npm/scroller.js +32 -32
  141. package/dist/npm/text/text-layer-builder.d.ts +30 -0
  142. package/dist/npm/text/text-layer-builder.js +291 -0
  143. package/dist/npm/utils.d.ts +20 -2
  144. package/dist/npm/utils.js +11 -8
  145. package/dist/npm/widget/page.d.ts +75 -0
  146. package/dist/npm/widget/page.js +763 -0
  147. package/dist/npm/widget/pdfviewer.d.ts +222 -0
  148. package/dist/npm/widget/pdfviewer.js +1663 -0
  149. package/package.json +13 -9
@@ -0,0 +1,98 @@
1
+ declare const SerializableEmpty: Readonly<{
2
+ map: any;
3
+ hash: "";
4
+ transfer: any;
5
+ }>;
6
+ /**
7
+ * Key/value storage for annotation data in forms.
8
+ */
9
+ declare class AnnotationStorage {
10
+ #private;
11
+ onSetModified: any;
12
+ onResetModified: any;
13
+ onAnnotationEditor: any;
14
+ constructor();
15
+ /**
16
+ * Get the value for a given key if it exists, or return the default value.
17
+ * @param {string} key
18
+ * @param {Object} defaultValue
19
+ * @returns {Object}
20
+ */
21
+ getValue(key: any, defaultValue: any): any;
22
+ /**
23
+ * Get the value for a given key.
24
+ * @param {string} key
25
+ * @returns {Object}
26
+ */
27
+ getRawValue(key: any): any;
28
+ /**
29
+ * Remove a value from the storage.
30
+ * @param {string} key
31
+ */
32
+ remove(key: any): void;
33
+ /**
34
+ * Set the value for a given key
35
+ * @param {string} key
36
+ * @param {Object} value
37
+ */
38
+ setValue(key: any, value: any): void;
39
+ /**
40
+ * Check if the storage contains the given key.
41
+ * @param {string} key
42
+ * @returns {boolean}
43
+ */
44
+ has(key: any): boolean;
45
+ /**
46
+ * @returns {Object | null}
47
+ */
48
+ getAll(): any;
49
+ /**
50
+ * @param {Object} obj
51
+ */
52
+ setAll(obj: any): void;
53
+ get size(): number;
54
+ resetModified(): void;
55
+ /**
56
+ * @returns {PrintAnnotationStorage}
57
+ */
58
+ get print(): PrintAnnotationStorage;
59
+ /**
60
+ * PLEASE NOTE: Only intended for usage within the API itself.
61
+ * @ignore
62
+ */
63
+ get serializable(): Readonly<{
64
+ map: any;
65
+ hash: "";
66
+ transfer: any;
67
+ }> | {
68
+ map: Map<any, any>;
69
+ hash: string;
70
+ transfer: any[];
71
+ };
72
+ get editorStats(): any;
73
+ resetModifiedIds(): void;
74
+ /**
75
+ * @returns {{ids: Set<string>, hash: string}}
76
+ */
77
+ get modifiedIds(): any;
78
+ }
79
+ /**
80
+ * A special `AnnotationStorage` for use during printing, where the serializable
81
+ * data is *frozen* upon initialization, to prevent scripting from modifying its
82
+ * contents. (Necessary since printing is triggered synchronously in browsers.)
83
+ */
84
+ declare class PrintAnnotationStorage extends AnnotationStorage {
85
+ #private;
86
+ constructor(parent: any);
87
+ /**
88
+ * @returns {PrintAnnotationStorage}
89
+ */
90
+ get print(): any;
91
+ /**
92
+ * PLEASE NOTE: Only intended for usage within the API itself.
93
+ * @ignore
94
+ */
95
+ get serializable(): any;
96
+ get modifiedIds(): any;
97
+ }
98
+ export { AnnotationStorage, PrintAnnotationStorage, SerializableEmpty };
@@ -0,0 +1,299 @@
1
+ "use strict";
2
+ /* Copyright 2020 Mozilla Foundation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ var _AnnotationStorage_instances, _AnnotationStorage_modified, _AnnotationStorage_modifiedIds, _AnnotationStorage_storage, _AnnotationStorage_setModified, _PrintAnnotationStorage_serializable;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.SerializableEmpty = exports.PrintAnnotationStorage = exports.AnnotationStorage = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const utils_1 = require("../shared/utils");
21
+ const annotation_editor_1 = require("../../annotations/editors/annotation-editor");
22
+ const murmurhash3_1 = require("../shared/murmurhash3");
23
+ const pdf_mjs_1 = require("pdfjs-dist/legacy/build/pdf.mjs");
24
+ const SerializableEmpty = Object.freeze({
25
+ map: null,
26
+ hash: "",
27
+ transfer: undefined,
28
+ });
29
+ exports.SerializableEmpty = SerializableEmpty;
30
+ /**
31
+ * Key/value storage for annotation data in forms.
32
+ */
33
+ class AnnotationStorage {
34
+ constructor() {
35
+ _AnnotationStorage_instances.add(this);
36
+ // todo: props
37
+ this.onSetModified = null;
38
+ this.onResetModified = null;
39
+ this.onAnnotationEditor = null;
40
+ // todo: props
41
+ _AnnotationStorage_modified.set(this, false);
42
+ _AnnotationStorage_modifiedIds.set(this, null);
43
+ _AnnotationStorage_storage.set(this, new Map());
44
+ // Callbacks to signal when the modification state is set or reset.
45
+ // This is used by the viewer to only bind on `beforeunload` if forms
46
+ // are actually edited to prevent doing so unconditionally since that
47
+ // can have undesirable effects.
48
+ this.onSetModified = null;
49
+ this.onResetModified = null;
50
+ this.onAnnotationEditor = null;
51
+ }
52
+ /**
53
+ * Get the value for a given key if it exists, or return the default value.
54
+ * @param {string} key
55
+ * @param {Object} defaultValue
56
+ * @returns {Object}
57
+ */
58
+ getValue(key, defaultValue) {
59
+ const value = tslib_1.__classPrivateFieldGet(this, _AnnotationStorage_storage, "f").get(key);
60
+ if (value === undefined) {
61
+ return defaultValue;
62
+ }
63
+ return Object.assign(defaultValue, value);
64
+ }
65
+ /**
66
+ * Get the value for a given key.
67
+ * @param {string} key
68
+ * @returns {Object}
69
+ */
70
+ getRawValue(key) {
71
+ return tslib_1.__classPrivateFieldGet(this, _AnnotationStorage_storage, "f").get(key);
72
+ }
73
+ /**
74
+ * Remove a value from the storage.
75
+ * @param {string} key
76
+ */
77
+ remove(key) {
78
+ tslib_1.__classPrivateFieldGet(this, _AnnotationStorage_storage, "f").delete(key);
79
+ if (tslib_1.__classPrivateFieldGet(this, _AnnotationStorage_storage, "f").size === 0) {
80
+ this.resetModified();
81
+ }
82
+ if (typeof this.onAnnotationEditor === "function") {
83
+ for (const value of tslib_1.__classPrivateFieldGet(this, _AnnotationStorage_storage, "f").values()) {
84
+ if (value instanceof annotation_editor_1.AnnotationEditor) {
85
+ return;
86
+ }
87
+ }
88
+ this.onAnnotationEditor(null);
89
+ }
90
+ }
91
+ /**
92
+ * Set the value for a given key
93
+ * @param {string} key
94
+ * @param {Object} value
95
+ */
96
+ setValue(key, value) {
97
+ const obj = tslib_1.__classPrivateFieldGet(this, _AnnotationStorage_storage, "f").get(key);
98
+ let modified = false;
99
+ if (obj !== undefined) {
100
+ for (const [entry, val] of Object.entries(value)) {
101
+ if (obj[entry] !== val) {
102
+ modified = true;
103
+ obj[entry] = val;
104
+ }
105
+ }
106
+ }
107
+ else {
108
+ modified = true;
109
+ tslib_1.__classPrivateFieldGet(this, _AnnotationStorage_storage, "f").set(key, value);
110
+ }
111
+ if (modified) {
112
+ tslib_1.__classPrivateFieldGet(this, _AnnotationStorage_instances, "m", _AnnotationStorage_setModified).call(this);
113
+ }
114
+ if (value instanceof annotation_editor_1.AnnotationEditor &&
115
+ typeof this.onAnnotationEditor === "function") {
116
+ this.onAnnotationEditor(value.constructor._type);
117
+ }
118
+ }
119
+ /**
120
+ * Check if the storage contains the given key.
121
+ * @param {string} key
122
+ * @returns {boolean}
123
+ */
124
+ has(key) {
125
+ return tslib_1.__classPrivateFieldGet(this, _AnnotationStorage_storage, "f").has(key);
126
+ }
127
+ /**
128
+ * @returns {Object | null}
129
+ */
130
+ getAll() {
131
+ return tslib_1.__classPrivateFieldGet(this, _AnnotationStorage_storage, "f").size > 0 ? (0, utils_1.objectFromMap)(tslib_1.__classPrivateFieldGet(this, _AnnotationStorage_storage, "f")) : null;
132
+ }
133
+ /**
134
+ * @param {Object} obj
135
+ */
136
+ setAll(obj) {
137
+ for (const [key, val] of Object.entries(obj)) {
138
+ this.setValue(key, val);
139
+ }
140
+ }
141
+ get size() {
142
+ return tslib_1.__classPrivateFieldGet(this, _AnnotationStorage_storage, "f").size;
143
+ }
144
+ resetModified() {
145
+ if (tslib_1.__classPrivateFieldGet(this, _AnnotationStorage_modified, "f")) {
146
+ tslib_1.__classPrivateFieldSet(this, _AnnotationStorage_modified, false, "f");
147
+ if (typeof this.onResetModified === "function") {
148
+ this.onResetModified();
149
+ }
150
+ }
151
+ }
152
+ /**
153
+ * @returns {PrintAnnotationStorage}
154
+ */
155
+ get print() {
156
+ return new PrintAnnotationStorage(this);
157
+ }
158
+ /**
159
+ * PLEASE NOTE: Only intended for usage within the API itself.
160
+ * @ignore
161
+ */
162
+ get serializable() {
163
+ if (tslib_1.__classPrivateFieldGet(this, _AnnotationStorage_storage, "f").size === 0) {
164
+ return SerializableEmpty;
165
+ }
166
+ const map = new Map(), hash = new murmurhash3_1.MurmurHash3_64(null), transfer = [];
167
+ const context = Object.create(null);
168
+ let hasBitmap = false;
169
+ for (const [key, val] of tslib_1.__classPrivateFieldGet(this, _AnnotationStorage_storage, "f")) {
170
+ const serialized = val instanceof annotation_editor_1.AnnotationEditor
171
+ ? val.serialize(/* isForCopying = */ false, context)
172
+ : val;
173
+ if (serialized) {
174
+ map.set(key, serialized);
175
+ hash.update(`${key}:${JSON.stringify(serialized)}`);
176
+ hasBitmap || (hasBitmap = !!serialized.bitmap);
177
+ }
178
+ }
179
+ if (hasBitmap) {
180
+ // We must transfer the bitmap data separately, since it can be changed
181
+ // during serialization with SVG images.
182
+ for (const value of map.values()) {
183
+ if (value.bitmap) {
184
+ transfer.push(value.bitmap);
185
+ }
186
+ }
187
+ }
188
+ return map.size > 0
189
+ ? { map, hash: hash.hexdigest(), transfer }
190
+ : SerializableEmpty;
191
+ }
192
+ get editorStats() {
193
+ var _a;
194
+ let stats = null;
195
+ const typeToEditor = new Map();
196
+ for (const value of tslib_1.__classPrivateFieldGet(this, _AnnotationStorage_storage, "f").values()) {
197
+ if (!(value instanceof annotation_editor_1.AnnotationEditor)) {
198
+ continue;
199
+ }
200
+ const editorStats = value.telemetryFinalData;
201
+ if (!editorStats) {
202
+ continue;
203
+ }
204
+ const { type } = editorStats;
205
+ if (!typeToEditor.has(type)) {
206
+ typeToEditor.set(type, Object.getPrototypeOf(value).constructor);
207
+ }
208
+ stats || (stats = Object.create(null));
209
+ const map = (stats[type] || (stats[type] = new Map()));
210
+ for (const [key, val] of Object.entries(editorStats)) {
211
+ if (key === "type") {
212
+ continue;
213
+ }
214
+ let counters = map.get(key);
215
+ if (!counters) {
216
+ counters = new Map();
217
+ map.set(key, counters);
218
+ }
219
+ const count = (_a = counters.get(val)) !== null && _a !== void 0 ? _a : 0;
220
+ counters.set(val, count + 1);
221
+ }
222
+ }
223
+ for (const [type, editor] of typeToEditor) {
224
+ stats[type] = editor.computeTelemetryFinalData(stats[type]);
225
+ }
226
+ return stats;
227
+ }
228
+ resetModifiedIds() {
229
+ tslib_1.__classPrivateFieldSet(this, _AnnotationStorage_modifiedIds, null, "f");
230
+ }
231
+ /**
232
+ * @returns {{ids: Set<string>, hash: string}}
233
+ */
234
+ get modifiedIds() {
235
+ if (tslib_1.__classPrivateFieldGet(this, _AnnotationStorage_modifiedIds, "f")) {
236
+ return tslib_1.__classPrivateFieldGet(this, _AnnotationStorage_modifiedIds, "f");
237
+ }
238
+ const ids = [];
239
+ for (const value of tslib_1.__classPrivateFieldGet(this, _AnnotationStorage_storage, "f").values()) {
240
+ if (!(value instanceof annotation_editor_1.AnnotationEditor) ||
241
+ !value.annotationElementId ||
242
+ !(value.serialize())) {
243
+ continue;
244
+ }
245
+ ids.push(value.annotationElementId);
246
+ }
247
+ return (tslib_1.__classPrivateFieldSet(this, _AnnotationStorage_modifiedIds, {
248
+ ids: new Set(ids),
249
+ hash: ids.join(","),
250
+ }, "f"));
251
+ }
252
+ }
253
+ exports.AnnotationStorage = AnnotationStorage;
254
+ _AnnotationStorage_modified = new WeakMap(), _AnnotationStorage_modifiedIds = new WeakMap(), _AnnotationStorage_storage = new WeakMap(), _AnnotationStorage_instances = new WeakSet(), _AnnotationStorage_setModified = function _AnnotationStorage_setModified() {
255
+ if (!tslib_1.__classPrivateFieldGet(this, _AnnotationStorage_modified, "f")) {
256
+ tslib_1.__classPrivateFieldSet(this, _AnnotationStorage_modified, true, "f");
257
+ if (typeof this.onSetModified === "function") {
258
+ this.onSetModified();
259
+ }
260
+ }
261
+ };
262
+ /**
263
+ * A special `AnnotationStorage` for use during printing, where the serializable
264
+ * data is *frozen* upon initialization, to prevent scripting from modifying its
265
+ * contents. (Necessary since printing is triggered synchronously in browsers.)
266
+ */
267
+ class PrintAnnotationStorage extends AnnotationStorage {
268
+ constructor(parent) {
269
+ super();
270
+ _PrintAnnotationStorage_serializable.set(this, void 0);
271
+ const { map, hash, transfer } = parent.serializable;
272
+ // Create a *copy* of the data, since Objects are passed by reference in JS.
273
+ const clone = structuredClone(map, transfer ? { transfer } : null);
274
+ tslib_1.__classPrivateFieldSet(this, _PrintAnnotationStorage_serializable, { map: clone, hash, transfer }, "f");
275
+ }
276
+ /**
277
+ * @returns {PrintAnnotationStorage}
278
+ */
279
+ // eslint-disable-next-line getter-return
280
+ get print() {
281
+ // unreachable("Should not call PrintAnnotationStorage.print");
282
+ return null;
283
+ }
284
+ /**
285
+ * PLEASE NOTE: Only intended for usage within the API itself.
286
+ * @ignore
287
+ */
288
+ get serializable() {
289
+ return tslib_1.__classPrivateFieldGet(this, _PrintAnnotationStorage_serializable, "f");
290
+ }
291
+ get modifiedIds() {
292
+ return (0, pdf_mjs_1.shadow)(this, "modifiedIds", {
293
+ ids: new Set(),
294
+ hash: "",
295
+ });
296
+ }
297
+ }
298
+ exports.PrintAnnotationStorage = PrintAnnotationStorage;
299
+ _PrintAnnotationStorage_serializable = new WeakMap();
@@ -0,0 +1,6 @@
1
+ export declare class ColorManager {
2
+ static _colorsMapping: Map<string, number[]>;
3
+ get _colors(): any;
4
+ convert(color: any): any;
5
+ getHexCode(name: any): any;
6
+ }
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ /* Copyright 2022 Mozilla Foundation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.ColorManager = void 0;
18
+ const utils_1 = require("../shared/utils");
19
+ // import {} from "pdfjs-dist/legacy/build/pdf.mjs";
20
+ const display_utils_1 = require("../shared/display_utils");
21
+ class ColorManager {
22
+ get _colors() {
23
+ if (
24
+ // typeof PDFJSDev !== "undefined" &&
25
+ // PDFJSDev.test("LIB") &&
26
+ typeof document === "undefined") {
27
+ return (0, utils_1.shadow)(this, "_colors", ColorManager._colorsMapping);
28
+ }
29
+ const colors = new Map([
30
+ ["CanvasText", null],
31
+ ["Canvas", null]
32
+ ]);
33
+ (0, display_utils_1.getColorValues)(colors);
34
+ return (0, utils_1.shadow)(this, "_colors", colors);
35
+ }
36
+ /*
37
+ * In High Contrast Mode, the color on the screen is not always the
38
+ * real color used in the pdf.
39
+ * For example in some cases white can appear to be black but when saving
40
+ * we want to have white.
41
+ * @param {string} color
42
+ * @returns {Array<number>}
43
+ */
44
+ convert(color) {
45
+ const rgb = (0, display_utils_1.getRGB)(color);
46
+ if (!window.matchMedia("(forced-colors: active)").matches) {
47
+ return rgb;
48
+ }
49
+ for (const [name, RGB] of this._colors) {
50
+ if (RGB.every((x, i) => x === rgb[i])) {
51
+ return ColorManager._colorsMapping.get(name);
52
+ }
53
+ }
54
+ return rgb;
55
+ }
56
+ /*
57
+ * An input element must have its color value as a hex string
58
+ * and not as color name.
59
+ * So this function converts a name into an hex string.
60
+ * @param {string} name
61
+ * @returns {string}
62
+ */
63
+ getHexCode(name) {
64
+ const rgb = this._colors.get(name);
65
+ if (!rgb) {
66
+ return name;
67
+ }
68
+ // @ts-expect-error TS(2556):
69
+ return utils_1.Util.makeHexColor(...rgb);
70
+ }
71
+ }
72
+ exports.ColorManager = ColorManager;
73
+ ColorManager._colorsMapping = new Map([
74
+ ["CanvasText", [0, 0, 0]],
75
+ ["Canvas", [255, 255, 255]]
76
+ ]);
@@ -0,0 +1,42 @@
1
+ export declare class CommandManager {
2
+ #private;
3
+ constructor(maxSize?: number);
4
+ /**
5
+ * @typedef {Object} addOptions
6
+ * @property {function} cmd
7
+ * @property {function} undo
8
+ * @property {function} [post]
9
+ * @property {boolean} mustExec
10
+ * @property {number} type
11
+ * @property {boolean} overwriteIfSameType
12
+ * @property {boolean} keepUndo
13
+ */
14
+ add({ cmd, undo, post, mustExec, type, overwriteIfSameType, keepUndo, }: {
15
+ cmd: any;
16
+ undo: any;
17
+ post: any;
18
+ mustExec: any;
19
+ type?: number;
20
+ overwriteIfSameType?: boolean;
21
+ keepUndo?: boolean;
22
+ }): void;
23
+ /**
24
+ * Undo the last command.
25
+ */
26
+ undo(): void;
27
+ /**
28
+ * Redo the last command.
29
+ */
30
+ redo(): void;
31
+ /**
32
+ * Check if there is something to undo.
33
+ * @returns {boolean}
34
+ */
35
+ hasSomethingToUndo(): boolean;
36
+ /**
37
+ * Check if there is something to redo.
38
+ * @returns {boolean}
39
+ */
40
+ hasSomethingToRedo(): boolean;
41
+ destroy(): void;
42
+ }
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ /* Copyright 2022 Mozilla Foundation
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ var _CommandManager_commands, _CommandManager_locked, _CommandManager_maxSize, _CommandManager_position;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.CommandManager = void 0;
19
+ const tslib_1 = require("tslib");
20
+ /*
21
+ * Class to handle undo/redo.
22
+ * Commands are just saved in a buffer.
23
+ * If we hit some memory issues we could likely use a circular buffer.
24
+ * It has to be used as a singleton.
25
+ */
26
+ class CommandManager {
27
+ constructor(maxSize = 128) {
28
+ _CommandManager_commands.set(this, []);
29
+ _CommandManager_locked.set(this, false);
30
+ _CommandManager_maxSize.set(this, void 0);
31
+ _CommandManager_position.set(this, -1);
32
+ tslib_1.__classPrivateFieldSet(this, _CommandManager_maxSize, maxSize, "f");
33
+ }
34
+ /**
35
+ * @typedef {Object} addOptions
36
+ * @property {function} cmd
37
+ * @property {function} undo
38
+ * @property {function} [post]
39
+ * @property {boolean} mustExec
40
+ * @property {number} type
41
+ * @property {boolean} overwriteIfSameType
42
+ * @property {boolean} keepUndo
43
+ */
44
+ /*
45
+ * Add a new couple of commands to be used in case of redo/undo.
46
+ * @param {addOptions} options
47
+ */
48
+ add({ cmd, undo, post, mustExec, type = NaN, overwriteIfSameType = false, keepUndo = false, }) {
49
+ if (mustExec) {
50
+ cmd();
51
+ }
52
+ if (tslib_1.__classPrivateFieldGet(this, _CommandManager_locked, "f")) {
53
+ return;
54
+ }
55
+ const save = { cmd, undo, post, type };
56
+ if (tslib_1.__classPrivateFieldGet(this, _CommandManager_position, "f") === -1) {
57
+ if (tslib_1.__classPrivateFieldGet(this, _CommandManager_commands, "f").length > 0) {
58
+ // All the commands have been undone and then a new one is added
59
+ // hence we clear the queue.
60
+ tslib_1.__classPrivateFieldGet(this, _CommandManager_commands, "f").length = 0;
61
+ }
62
+ tslib_1.__classPrivateFieldSet(this, _CommandManager_position, 0, "f");
63
+ tslib_1.__classPrivateFieldGet(this, _CommandManager_commands, "f").push(save);
64
+ return;
65
+ }
66
+ if (overwriteIfSameType && tslib_1.__classPrivateFieldGet(this, _CommandManager_commands, "f")[tslib_1.__classPrivateFieldGet(this, _CommandManager_position, "f")].type === type) {
67
+ // For example when we change a color we don't want to
68
+ // be able to undo all the steps, hence we only want to
69
+ // keep the last undoable action in this sequence of actions.
70
+ if (keepUndo) {
71
+ save.undo = tslib_1.__classPrivateFieldGet(this, _CommandManager_commands, "f")[tslib_1.__classPrivateFieldGet(this, _CommandManager_position, "f")].undo;
72
+ }
73
+ tslib_1.__classPrivateFieldGet(this, _CommandManager_commands, "f")[tslib_1.__classPrivateFieldGet(this, _CommandManager_position, "f")] = save;
74
+ return;
75
+ }
76
+ const next = tslib_1.__classPrivateFieldGet(this, _CommandManager_position, "f") + 1;
77
+ if (next === tslib_1.__classPrivateFieldGet(this, _CommandManager_maxSize, "f")) {
78
+ tslib_1.__classPrivateFieldGet(this, _CommandManager_commands, "f").splice(0, 1);
79
+ }
80
+ else {
81
+ tslib_1.__classPrivateFieldSet(this, _CommandManager_position, next, "f");
82
+ if (next < tslib_1.__classPrivateFieldGet(this, _CommandManager_commands, "f").length) {
83
+ tslib_1.__classPrivateFieldGet(this, _CommandManager_commands, "f").splice(next);
84
+ }
85
+ }
86
+ tslib_1.__classPrivateFieldGet(this, _CommandManager_commands, "f").push(save);
87
+ }
88
+ /**
89
+ * Undo the last command.
90
+ */
91
+ undo() {
92
+ if (tslib_1.__classPrivateFieldGet(this, _CommandManager_position, "f") === -1) {
93
+ // Nothing to undo.
94
+ return;
95
+ }
96
+ // Avoid to insert something during the undo execution.
97
+ tslib_1.__classPrivateFieldSet(this, _CommandManager_locked, true, "f");
98
+ const { undo, post } = tslib_1.__classPrivateFieldGet(this, _CommandManager_commands, "f")[tslib_1.__classPrivateFieldGet(this, _CommandManager_position, "f")];
99
+ undo();
100
+ post === null || post === void 0 ? void 0 : post();
101
+ tslib_1.__classPrivateFieldSet(this, _CommandManager_locked, false, "f");
102
+ tslib_1.__classPrivateFieldSet(this, _CommandManager_position, tslib_1.__classPrivateFieldGet(this, _CommandManager_position, "f") - 1, "f");
103
+ }
104
+ /**
105
+ * Redo the last command.
106
+ */
107
+ redo() {
108
+ if (tslib_1.__classPrivateFieldGet(this, _CommandManager_position, "f") < tslib_1.__classPrivateFieldGet(this, _CommandManager_commands, "f").length - 1) {
109
+ tslib_1.__classPrivateFieldSet(this, _CommandManager_position, tslib_1.__classPrivateFieldGet(this, _CommandManager_position, "f") + 1, "f");
110
+ // Avoid to insert something during the redo execution.
111
+ tslib_1.__classPrivateFieldSet(this, _CommandManager_locked, true, "f");
112
+ const { cmd, post } = tslib_1.__classPrivateFieldGet(this, _CommandManager_commands, "f")[tslib_1.__classPrivateFieldGet(this, _CommandManager_position, "f")];
113
+ cmd();
114
+ post === null || post === void 0 ? void 0 : post();
115
+ tslib_1.__classPrivateFieldSet(this, _CommandManager_locked, false, "f");
116
+ }
117
+ }
118
+ /**
119
+ * Check if there is something to undo.
120
+ * @returns {boolean}
121
+ */
122
+ hasSomethingToUndo() {
123
+ return tslib_1.__classPrivateFieldGet(this, _CommandManager_position, "f") !== -1;
124
+ }
125
+ /**
126
+ * Check if there is something to redo.
127
+ * @returns {boolean}
128
+ */
129
+ hasSomethingToRedo() {
130
+ return tslib_1.__classPrivateFieldGet(this, _CommandManager_position, "f") < tslib_1.__classPrivateFieldGet(this, _CommandManager_commands, "f").length - 1;
131
+ }
132
+ destroy() {
133
+ tslib_1.__classPrivateFieldSet(this, _CommandManager_commands, null, "f");
134
+ }
135
+ }
136
+ exports.CommandManager = CommandManager;
137
+ _CommandManager_commands = new WeakMap(), _CommandManager_locked = new WeakMap(), _CommandManager_maxSize = new WeakMap(), _CommandManager_position = new WeakMap();
@@ -0,0 +1,6 @@
1
+ export declare class IdManager {
2
+ #private;
3
+ idPrefix: string;
4
+ constructor(idPrefix?: string);
5
+ get id(): string;
6
+ }