@xtctwins/tctwins-pdf-core 0.1.0 → 0.1.2
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/dist/PdfViewer.d.ts +13 -3
- package/dist/PdfViewer.d.ts.map +1 -1
- package/dist/components/MobileConsole.vue.d.ts +13 -0
- package/dist/components/MobileConsole.vue.d.ts.map +1 -0
- package/dist/components/PdfViewer.d.ts +4 -4
- package/dist/components/PdfViewer.vue.d.ts +18 -8
- package/dist/components/PdfViewer.vue.d.ts.map +1 -1
- package/dist/components/useAnnotationCanvas.d.ts +9 -2
- package/dist/components/useAnnotationCanvas.d.ts.map +1 -1
- package/dist/components/useViewerLayout.d.ts +49 -26
- package/dist/components/useViewerLayout.d.ts.map +1 -1
- package/dist/components/useViewerManager.d.ts +2 -0
- package/dist/components/useViewerManager.d.ts.map +1 -1
- package/dist/core/ColorInverter.d.ts +70 -0
- package/dist/core/ColorInverter.d.ts.map +1 -0
- package/dist/core/PageCanvasRenderer.d.ts +190 -0
- package/dist/core/PageCanvasRenderer.d.ts.map +1 -0
- package/dist/core/TileRenderer.d.ts +0 -1
- package/dist/core/TileRenderer.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/pdf-core.js +968 -363
- package/dist/style.css +1 -1
- package/dist/types/components.d.ts +19 -0
- package/dist/types/components.d.ts.map +1 -1
- package/dist/vue/usePdfCore.d.ts +56 -2
- package/dist/vue/usePdfCore.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/pdf-core.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import * as e from "pdfjs-dist";
|
|
2
|
-
import {
|
|
2
|
+
import { Fragment as t, computed as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createTextVNode as o, createVNode as s, defineComponent as c, nextTick as l, normalizeClass as u, normalizeStyle as d, onBeforeUnmount as f, onMounted as p, openBlock as m, ref as h, renderList as g, shallowRef as _, toDisplayString as v, unref as y, vShow as b, watch as x, withDirectives as S, withModifiers as C } from "vue";
|
|
3
3
|
//#region src/core/PDFLoader.ts
|
|
4
|
-
function
|
|
4
|
+
function w(t) {
|
|
5
5
|
t && (e.GlobalWorkerOptions.workerSrc = t);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function ee(t = "/pdf.worker.min.mjs") {
|
|
8
8
|
e.GlobalWorkerOptions.workerSrc = t, fetch(t, { method: "HEAD" }).catch(() => {
|
|
9
9
|
e.GlobalWorkerOptions.workerSrc = "https://unpkg.com/pdfjs-dist@5.7.284/legacy/build/pdf.worker.min.mjs";
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
|
-
async function
|
|
12
|
+
async function T(t, n = {}) {
|
|
13
13
|
let r = t instanceof File ? await t.arrayBuffer() : t, i = r.slice(0);
|
|
14
|
-
n.workerSrc &&
|
|
14
|
+
n.workerSrc && w(n.workerSrc);
|
|
15
15
|
let a = await e.getDocument({ data: i }).promise;
|
|
16
16
|
return {
|
|
17
17
|
arrayBuffer: r,
|
|
@@ -20,8 +20,396 @@ async function g(t, n = {}) {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
|
-
//#region src/core/
|
|
24
|
-
var
|
|
23
|
+
//#region src/core/ColorInverter.ts
|
|
24
|
+
var E = "invert(1)", te = "invert(1) hue-rotate(180deg)", ne = 24, re = "\nattribute vec2 aPos;\nvarying vec2 vUv;\nvoid main() {\n vUv = aPos * 0.5 + 0.5;\n gl_Position = vec4(aPos, 0.0, 1.0);\n}", ie = "\nprecision mediump float;\nuniform sampler2D uTex;\nuniform float uThreshold;\nuniform float uUnblend;\nvarying vec2 vUv;\nvoid main() {\n vec4 c = texture2D(uTex, vUv);\n float mx = max(c.r, max(c.g, c.b));\n float mn = min(c.r, min(c.g, c.b));\n float chroma = mx - mn;\n float luma = dot(c.rgb, vec3(0.299, 0.587, 0.114));\n if (chroma <= uThreshold) {\n // 灰度(含抗锯齿灰阶):按亮度反色 → 纸白→纸黑、黑线→白线,斜坡平滑\n gl_FragColor = vec4(vec3(1.0 - luma), 1.0);\n } else if (uUnblend > 0.5) {\n // 彩色 + 覆盖度反解:像素 - min(通道) = 原墨色 × 覆盖度(新纸色为黑)\n gl_FragColor = vec4(c.rgb - mn, 1.0);\n } else {\n // 彩色原样保留(\"achromatic\" 模式;代价是边缘会有一圈亮边)\n gl_FragColor = vec4(c.rgb, 1.0);\n }\n}", D = (e, t, n) => Math.max(t, Math.min(n, e)), O = class {
|
|
25
|
+
constructor() {
|
|
26
|
+
this.glCanvas = null, this.gl = null, this.program = null, this.texture = null, this.thresholdLoc = null, this.unblendLoc = null, this.webglReady = null, this.loggedPath = !1;
|
|
27
|
+
}
|
|
28
|
+
get usingWebGL() {
|
|
29
|
+
return this.webglReady === !0;
|
|
30
|
+
}
|
|
31
|
+
presentPerPixel(e, t, n, r, i, a = "unblend", o = 24) {
|
|
32
|
+
if (r <= 0 || i <= 0) return !1;
|
|
33
|
+
if (this.ensureWebGL()) try {
|
|
34
|
+
return this.drawWithGL(e, n, r, i, a, o), this.loggedPath || (this.loggedPath = !0, console.debug("[PDF-CORE] 智能反色:WebGL 着色器快路径")), !0;
|
|
35
|
+
} catch {
|
|
36
|
+
this.disableWebGL();
|
|
37
|
+
}
|
|
38
|
+
return this.loggedPath || (this.loggedPath = !0, console.debug("[PDF-CORE] 智能反色:WebGL 不可用,降级为逐像素处理(较慢)")), this.invertPixels(t, n, r, i, a, o), !1;
|
|
39
|
+
}
|
|
40
|
+
presentAchromatic(e, t, n, r, i, a = 24) {
|
|
41
|
+
return this.presentPerPixel(e, t, n, r, i, "achromatic", a);
|
|
42
|
+
}
|
|
43
|
+
dispose() {
|
|
44
|
+
this.disableWebGL(), this.webglReady = !1;
|
|
45
|
+
}
|
|
46
|
+
ensureWebGL() {
|
|
47
|
+
if (this.webglReady === !1) return !1;
|
|
48
|
+
if (this.webglReady === !0) return !0;
|
|
49
|
+
try {
|
|
50
|
+
let e = document.createElement("canvas"), t = e.getContext("webgl", {
|
|
51
|
+
alpha: !1,
|
|
52
|
+
antialias: !1,
|
|
53
|
+
depth: !1,
|
|
54
|
+
stencil: !1,
|
|
55
|
+
premultipliedAlpha: !1,
|
|
56
|
+
preserveDrawingBuffer: !0
|
|
57
|
+
});
|
|
58
|
+
if (!t) throw Error("WebGL 不可用");
|
|
59
|
+
let n = this.buildProgram(t), r = t.createTexture(), i = t.createBuffer();
|
|
60
|
+
if (!r || !i) throw Error("WebGL 资源创建失败");
|
|
61
|
+
t.useProgram(n), t.bindBuffer(t.ARRAY_BUFFER, i), t.bufferData(t.ARRAY_BUFFER, new Float32Array([
|
|
62
|
+
-1,
|
|
63
|
+
-1,
|
|
64
|
+
1,
|
|
65
|
+
-1,
|
|
66
|
+
-1,
|
|
67
|
+
1,
|
|
68
|
+
1,
|
|
69
|
+
1
|
|
70
|
+
]), t.STATIC_DRAW);
|
|
71
|
+
let a = t.getAttribLocation(n, "aPos");
|
|
72
|
+
return t.enableVertexAttribArray(a), t.vertexAttribPointer(a, 2, t.FLOAT, !1, 0, 0), t.bindTexture(t.TEXTURE_2D, r), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.LINEAR), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.uniform1i(t.getUniformLocation(n, "uTex"), 0), e.addEventListener("webglcontextlost", (e) => {
|
|
73
|
+
e.preventDefault(), this.disableWebGL();
|
|
74
|
+
}), this.glCanvas = e, this.gl = t, this.program = n, this.texture = r, this.thresholdLoc = t.getUniformLocation(n, "uThreshold"), this.unblendLoc = t.getUniformLocation(n, "uUnblend"), this.webglReady = !0, !0;
|
|
75
|
+
} catch {
|
|
76
|
+
return this.webglReady = !1, !1;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
buildProgram(e) {
|
|
80
|
+
let t = e.createShader(e.VERTEX_SHADER), n = e.createShader(e.FRAGMENT_SHADER);
|
|
81
|
+
if (!t || !n) throw Error("shader 创建失败");
|
|
82
|
+
if (e.shaderSource(t, re), e.compileShader(t), e.shaderSource(n, ie), e.compileShader(n), !e.getShaderParameter(t, e.COMPILE_STATUS) || !e.getShaderParameter(n, e.COMPILE_STATUS)) throw Error("shader 编译失败");
|
|
83
|
+
let r = e.createProgram();
|
|
84
|
+
if (!r) throw Error("program 创建失败");
|
|
85
|
+
if (e.attachShader(r, t), e.attachShader(r, n), e.linkProgram(r), !e.getProgramParameter(r, e.LINK_STATUS)) throw Error("program 链接失败");
|
|
86
|
+
return e.deleteShader(t), e.deleteShader(n), r;
|
|
87
|
+
}
|
|
88
|
+
drawWithGL(e, t, n, r, i, a) {
|
|
89
|
+
let o = this.gl, s = this.glCanvas;
|
|
90
|
+
if (!o || !s || !this.texture) throw Error("WebGL 未就绪");
|
|
91
|
+
(s.width !== n || s.height !== r) && (s.width = n, s.height = r), o.viewport(0, 0, n, r), o.useProgram(this.program), o.activeTexture(o.TEXTURE0), o.bindTexture(o.TEXTURE_2D, this.texture), o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, 1), o.texImage2D(o.TEXTURE_2D, 0, o.RGBA, o.RGBA, o.UNSIGNED_BYTE, e), this.thresholdLoc && o.uniform1f(this.thresholdLoc, D(a, 0, 255) / 255), this.unblendLoc && o.uniform1f(this.unblendLoc, +(i === "unblend")), o.drawArrays(o.TRIANGLE_STRIP, 0, 4), t.setTransform(1, 0, 0, 1, 0, 0), t.drawImage(s, 0, 0);
|
|
92
|
+
}
|
|
93
|
+
disableWebGL() {
|
|
94
|
+
let e = this.gl;
|
|
95
|
+
e && (this.texture && e.deleteTexture(this.texture), this.program && e.deleteProgram(this.program), e.getExtension("WEBGL_lose_context")?.loseContext()), this.glCanvas = null, this.gl = null, this.program = null, this.texture = null, this.thresholdLoc = null, this.unblendLoc = null, this.webglReady = !1;
|
|
96
|
+
}
|
|
97
|
+
invertPixels(e, t, n, r, i, a) {
|
|
98
|
+
let o = e.getImageData(0, 0, n, r), s = o.data;
|
|
99
|
+
for (let e = 0; e < s.length; e += 4) {
|
|
100
|
+
let t = s[e], n = s[e + 1], r = s[e + 2], o = t > n ? t > r ? t : r : n > r ? n : r, c = t < n ? t < r ? t : r : n < r ? n : r;
|
|
101
|
+
if (o - c <= a) {
|
|
102
|
+
let i = 255 - ((t * 299 + n * 587 + r * 114) / 1e3 | 0);
|
|
103
|
+
s[e] = i, s[e + 1] = i, s[e + 2] = i;
|
|
104
|
+
} else i === "unblend" && (s[e] = t - c, s[e + 1] = n - c, s[e + 2] = r - c);
|
|
105
|
+
}
|
|
106
|
+
t.setTransform(1, 0, 0, 1, 0, 0), t.putImageData(o, 0, 0);
|
|
107
|
+
}
|
|
108
|
+
}, ae = 8192, oe = 1.25, se = .05, ce = 128, k = (e, t, n) => Math.max(t, Math.min(n, e)), le = (() => {
|
|
109
|
+
try {
|
|
110
|
+
let e = document.createElement("canvas").getContext("2d");
|
|
111
|
+
return e ? (e.filter = "invert(1)", e.filter === "invert(1)") : !1;
|
|
112
|
+
} catch {
|
|
113
|
+
return !1;
|
|
114
|
+
}
|
|
115
|
+
})(), A = class {
|
|
116
|
+
constructor(e) {
|
|
117
|
+
this.doc = null, this.page = null, this.pageW = 0, this.pageH = 0, this.inkCenter = {
|
|
118
|
+
x: 0,
|
|
119
|
+
y: 0
|
|
120
|
+
}, this.zoomValue = 1, this.centerValue = {
|
|
121
|
+
x: 0,
|
|
122
|
+
y: 0
|
|
123
|
+
}, this.presentedValue = {
|
|
124
|
+
zoom: 1,
|
|
125
|
+
center: {
|
|
126
|
+
x: 0,
|
|
127
|
+
y: 0
|
|
128
|
+
},
|
|
129
|
+
region: {
|
|
130
|
+
x: 0,
|
|
131
|
+
y: 0,
|
|
132
|
+
w: 0,
|
|
133
|
+
h: 0,
|
|
134
|
+
tiled: !1
|
|
135
|
+
},
|
|
136
|
+
offset: {
|
|
137
|
+
x: 0,
|
|
138
|
+
y: 0
|
|
139
|
+
}
|
|
140
|
+
}, this.unpresented = {
|
|
141
|
+
x: 0,
|
|
142
|
+
y: 0
|
|
143
|
+
}, this.dragExtra = {
|
|
144
|
+
x: 0,
|
|
145
|
+
y: 0
|
|
146
|
+
}, this.seq = 0, this.task = null, this.rafId = null, this.backgroundColor = "rgb(255,255,255)", this.invertColorsValue = !1, this.invertModeValue = "unblend", this.invertThresholdValue = 24, this.inverter = new O(), this.destroyed = !1, this.stageBox = {
|
|
147
|
+
left: 0,
|
|
148
|
+
top: 0,
|
|
149
|
+
w: 0,
|
|
150
|
+
h: 0
|
|
151
|
+
}, this.canvas = e.canvas, this.stage = e.stage, this.wrap = e.wrap ?? null, this.dprOf = e.dpr ?? (() => window.devicePixelRatio || 1), this.maxSide = e.maxSide ?? ae, this.prefetch = e.prefetch ?? oe, this.minZoom = e.minZoom ?? se, this.maxZoomValue = e.maxZoom ?? ce, this.onPresented = e.onPresented ?? null, this.backgroundColor = e.backgroundColor ?? "rgb(255,255,255)", this.invertColorsValue = e.invertColors ?? !1, this.invertModeValue = e.invertMode ?? "unblend", this.invertThresholdValue = e.invertThreshold ?? 24;
|
|
152
|
+
let t = this.canvas.getContext("2d");
|
|
153
|
+
if (!t) throw Error("[PDF-CORE] 2d context 不可用");
|
|
154
|
+
this.ctx = t, this.off = document.createElement("canvas");
|
|
155
|
+
let n = this.off.getContext("2d");
|
|
156
|
+
if (!n) throw Error("[PDF-CORE] 离屏 2d context 不可用");
|
|
157
|
+
this.offCtx = n, this.canvas.style.position = "absolute", this.canvas.style.display = "block", this.canvas.style.transformOrigin = "0 0";
|
|
158
|
+
}
|
|
159
|
+
get zoom() {
|
|
160
|
+
return this.zoomValue;
|
|
161
|
+
}
|
|
162
|
+
get center() {
|
|
163
|
+
return { ...this.centerValue };
|
|
164
|
+
}
|
|
165
|
+
get size() {
|
|
166
|
+
return {
|
|
167
|
+
wPt: this.pageW,
|
|
168
|
+
hPt: this.pageH
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
get presented() {
|
|
172
|
+
return this.presentedValue;
|
|
173
|
+
}
|
|
174
|
+
get pageRef() {
|
|
175
|
+
return this.page;
|
|
176
|
+
}
|
|
177
|
+
async open(e) {
|
|
178
|
+
this.doc = e, this.page = await e.getPage(1);
|
|
179
|
+
let t = this.page.getViewport({ scale: 1 });
|
|
180
|
+
return this.pageW = t.width, this.pageH = t.height, this.inkCenter = await this.detectInkCenter(this.page), this.centerValue = { ...this.inkCenter }, {
|
|
181
|
+
wPt: this.pageW,
|
|
182
|
+
hPt: this.pageH
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
async detectInkCenter(e) {
|
|
186
|
+
let t = {
|
|
187
|
+
x: this.pageW / 2,
|
|
188
|
+
y: this.pageH / 2
|
|
189
|
+
};
|
|
190
|
+
try {
|
|
191
|
+
let n = e.getViewport({ scale: 1 }), r = 220 / Math.max(n.width, n.height), i = e.getViewport({ scale: r }), a = document.createElement("canvas");
|
|
192
|
+
a.width = Math.max(1, Math.floor(i.width)), a.height = Math.max(1, Math.floor(i.height));
|
|
193
|
+
let o = a.getContext("2d", { willReadFrequently: !0 });
|
|
194
|
+
if (!o) return t;
|
|
195
|
+
await e.render({
|
|
196
|
+
canvas: a,
|
|
197
|
+
canvasContext: o,
|
|
198
|
+
viewport: i
|
|
199
|
+
}).promise;
|
|
200
|
+
let s = o.getImageData(0, 0, a.width, a.height).data, c = Infinity, l = Infinity, u = -1, d = -1;
|
|
201
|
+
for (let e = 0; e < a.height; e += 3) for (let t = 0; t < a.width; t += 3) {
|
|
202
|
+
let n = (e * a.width + t) * 4;
|
|
203
|
+
(s[n] < 250 || s[n + 1] < 250 || s[n + 2] < 250) && (t < c && (c = t), e < l && (l = e), t > u && (u = t), e > d && (d = e));
|
|
204
|
+
}
|
|
205
|
+
return a.width = 0, a.height = 0, u < 0 ? t : {
|
|
206
|
+
x: (c + u) / 2 / r,
|
|
207
|
+
y: (l + d) / 2 / r
|
|
208
|
+
};
|
|
209
|
+
} catch {
|
|
210
|
+
return t;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
destroy() {
|
|
214
|
+
this.destroyed = !0, this.cancel(), this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null), this.doc = null, this.page = null, this.canvas.width = 0, this.canvas.height = 0, this.canvas.style.filter = "", this.inverter.dispose(), this.off.width = 0, this.off.height = 0;
|
|
215
|
+
}
|
|
216
|
+
unload() {
|
|
217
|
+
this.cancel(), this.seq++, this.doc = null, this.page = null, this.pageW = 0, this.pageH = 0, this.canvas.width = 0, this.canvas.height = 0, this.canvas.style.transform = "", this.unpresented = {
|
|
218
|
+
x: 0,
|
|
219
|
+
y: 0
|
|
220
|
+
}, this.dragExtra = {
|
|
221
|
+
x: 0,
|
|
222
|
+
y: 0
|
|
223
|
+
}, this.wrap && (this.wrap.style.width = "0px", this.wrap.style.height = "0px");
|
|
224
|
+
}
|
|
225
|
+
cancel() {
|
|
226
|
+
if (this.task) {
|
|
227
|
+
try {
|
|
228
|
+
this.task.cancel();
|
|
229
|
+
} catch {}
|
|
230
|
+
this.task = null;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
setBackgroundColor(e) {
|
|
234
|
+
this.backgroundColor = e, this.canvas.style.background = e, this.requestRender();
|
|
235
|
+
}
|
|
236
|
+
get invertColors() {
|
|
237
|
+
return this.invertColorsValue;
|
|
238
|
+
}
|
|
239
|
+
get invertMode() {
|
|
240
|
+
return this.invertModeValue;
|
|
241
|
+
}
|
|
242
|
+
setInvertColors(e) {
|
|
243
|
+
e !== this.invertColorsValue && (this.invertColorsValue = e, this.requestRender());
|
|
244
|
+
}
|
|
245
|
+
setInvertMode(e, t) {
|
|
246
|
+
let n = t ?? this.invertThresholdValue;
|
|
247
|
+
e === this.invertModeValue && n === this.invertThresholdValue || (this.invertModeValue = e, this.invertThresholdValue = n, this.requestRender());
|
|
248
|
+
}
|
|
249
|
+
get usingWebGLInvert() {
|
|
250
|
+
return this.inverter.usingWebGL;
|
|
251
|
+
}
|
|
252
|
+
get maxZoom() {
|
|
253
|
+
return this.maxZoomValue;
|
|
254
|
+
}
|
|
255
|
+
setMaxZoom(e) {
|
|
256
|
+
!(e > 0) || e === this.maxZoomValue || (this.maxZoomValue = e, this.zoomValue > e && (this.zoomValue = e, this.requestRender()));
|
|
257
|
+
}
|
|
258
|
+
setZoom(e) {
|
|
259
|
+
let t = k(e, this.minZoom, this.maxZoomValue);
|
|
260
|
+
t !== this.zoomValue && (this.zoomValue = t, this.requestRender());
|
|
261
|
+
}
|
|
262
|
+
anchorAt(e, t, n, r) {
|
|
263
|
+
let i = k(r, this.minZoom, this.maxZoomValue);
|
|
264
|
+
this.zoomValue = i;
|
|
265
|
+
let a = this.stageCenterOnScreen();
|
|
266
|
+
this.centerValue = {
|
|
267
|
+
x: n.x - (e - a.x) / i,
|
|
268
|
+
y: n.y - (t - a.y) / i
|
|
269
|
+
}, this.requestRender();
|
|
270
|
+
}
|
|
271
|
+
zoomAt(e, t, n) {
|
|
272
|
+
let r = k(this.zoomValue * n, this.minZoom, this.maxZoomValue);
|
|
273
|
+
if (r === this.zoomValue) return !1;
|
|
274
|
+
let i = this.screenToPt(e, t);
|
|
275
|
+
return this.anchorAt(e, t, i, r), !0;
|
|
276
|
+
}
|
|
277
|
+
setDragOffset(e, t) {
|
|
278
|
+
this.dragExtra = {
|
|
279
|
+
x: e,
|
|
280
|
+
y: t
|
|
281
|
+
}, this.applyBitmapOffset();
|
|
282
|
+
}
|
|
283
|
+
commitDrag(e, t) {
|
|
284
|
+
let n = this.presentedValue.zoom || 1;
|
|
285
|
+
this.centerValue = {
|
|
286
|
+
x: this.centerValue.x - e / n,
|
|
287
|
+
y: this.centerValue.y - t / n
|
|
288
|
+
}, this.unpresented = {
|
|
289
|
+
x: this.unpresented.x + e,
|
|
290
|
+
y: this.unpresented.y + t
|
|
291
|
+
}, this.dragExtra = {
|
|
292
|
+
x: 0,
|
|
293
|
+
y: 0
|
|
294
|
+
}, this.requestRender();
|
|
295
|
+
}
|
|
296
|
+
centerOnContent() {
|
|
297
|
+
this.centerValue = { ...this.inkCenter }, this.requestRender();
|
|
298
|
+
}
|
|
299
|
+
applyBitmapOffset() {
|
|
300
|
+
let e = this.unpresented.x + this.dragExtra.x, t = this.unpresented.y + this.dragExtra.y;
|
|
301
|
+
this.canvas.style.transform = e === 0 && t === 0 ? "" : `translate(${e}px, ${t}px)`;
|
|
302
|
+
}
|
|
303
|
+
screenToPt(e, t) {
|
|
304
|
+
let n = this.presentedValue, r = n.zoom || 1, i = this.stageCenterOnScreen(), a = {
|
|
305
|
+
x: this.unpresented.x + this.dragExtra.x,
|
|
306
|
+
y: this.unpresented.y + this.dragExtra.y
|
|
307
|
+
};
|
|
308
|
+
return {
|
|
309
|
+
x: n.center.x + (e - i.x - a.x) / r,
|
|
310
|
+
y: n.center.y + (t - i.y - a.y) / r
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
ptToScreen(e) {
|
|
314
|
+
let t = this.presentedValue, n = t.zoom || 1, r = this.stageCenterOnScreen(), i = {
|
|
315
|
+
x: this.unpresented.x + this.dragExtra.x,
|
|
316
|
+
y: this.unpresented.y + this.dragExtra.y
|
|
317
|
+
};
|
|
318
|
+
return {
|
|
319
|
+
x: r.x + (e.x - t.center.x) * n + i.x,
|
|
320
|
+
y: r.y + (e.y - t.center.y) * n + i.y
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
refreshStageBox() {
|
|
324
|
+
let e = this.stage.getBoundingClientRect(), t = this.stage.clientWidth || e.width, n = this.stage.clientHeight || e.height;
|
|
325
|
+
this.stageBox = {
|
|
326
|
+
left: e.left + (e.width - t) / 2,
|
|
327
|
+
top: e.top + (e.height - n) / 2,
|
|
328
|
+
w: t,
|
|
329
|
+
h: n
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
stageCenterOnScreen() {
|
|
333
|
+
return {
|
|
334
|
+
x: this.stageBox.left + this.stageBox.w / 2,
|
|
335
|
+
y: this.stageBox.top + this.stageBox.h / 2
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
computeRegion() {
|
|
339
|
+
let e = this.zoomValue * this.dprOf();
|
|
340
|
+
if (Math.max(this.pageW * e, this.pageH * e) <= this.maxSide) return null;
|
|
341
|
+
let t = (this.stageBox.w || 1) / this.zoomValue * this.prefetch, n = (this.stageBox.h || 1) / this.zoomValue * this.prefetch, r = Math.min(t, this.pageW), i = Math.min(n, this.pageH), a = k(this.centerValue.x - r / 2, 0, Math.max(this.pageW - r, 0)), o = k(this.centerValue.y - i / 2, 0, Math.max(this.pageH - i, 0)), s = {
|
|
342
|
+
x: a,
|
|
343
|
+
y: o,
|
|
344
|
+
w: r,
|
|
345
|
+
h: i,
|
|
346
|
+
tiled: !0
|
|
347
|
+
};
|
|
348
|
+
return this.centerValue = {
|
|
349
|
+
x: a + r / 2,
|
|
350
|
+
y: o + i / 2
|
|
351
|
+
}, s;
|
|
352
|
+
}
|
|
353
|
+
layout(e) {
|
|
354
|
+
let t = this.zoomValue;
|
|
355
|
+
this.wrap && (this.wrap.style.position = "absolute", this.wrap.style.left = "0", this.wrap.style.top = "0", this.wrap.style.width = `${Math.round(this.pageW * t)}px`, this.wrap.style.height = `${Math.round(this.pageH * t)}px`, this.wrap.style.transformOrigin = "0 0", this.wrap.style.transform = `translate(${this.stageBox.w / 2 - this.centerValue.x * t}px, ${this.stageBox.h / 2 - this.centerValue.y * t}px)`);
|
|
356
|
+
let n = this.wrap ? 0 : this.stageBox.w / 2 - this.centerValue.x * t, r = this.wrap ? 0 : this.stageBox.h / 2 - this.centerValue.y * t;
|
|
357
|
+
this.canvas.style.left = `${n + e.x * t}px`, this.canvas.style.top = `${r + e.y * t}px`, this.canvas.style.width = `${Math.round(e.w * t)}px`, this.canvas.style.height = `${Math.round(e.h * t)}px`, this.unpresented = {
|
|
358
|
+
x: 0,
|
|
359
|
+
y: 0
|
|
360
|
+
}, this.dragExtra = {
|
|
361
|
+
x: 0,
|
|
362
|
+
y: 0
|
|
363
|
+
}, this.canvas.style.transform = "";
|
|
364
|
+
}
|
|
365
|
+
requestRender() {
|
|
366
|
+
this.destroyed || this.rafId !== null || (this.rafId = requestAnimationFrame(() => {
|
|
367
|
+
this.rafId = null, this.render();
|
|
368
|
+
}));
|
|
369
|
+
}
|
|
370
|
+
async render() {
|
|
371
|
+
if (this.destroyed || !this.page || this.pageW <= 0) return;
|
|
372
|
+
let e = ++this.seq;
|
|
373
|
+
this.cancel(), this.refreshStageBox();
|
|
374
|
+
let t = this.zoomValue * this.dprOf(), n = this.computeRegion(), r = n ?? {
|
|
375
|
+
x: 0,
|
|
376
|
+
y: 0,
|
|
377
|
+
w: this.pageW,
|
|
378
|
+
h: this.pageH,
|
|
379
|
+
tiled: !1
|
|
380
|
+
}, i = this.page.getViewport({ scale: t });
|
|
381
|
+
n && (i = i.clone({
|
|
382
|
+
offsetX: -n.x * t,
|
|
383
|
+
offsetY: -n.y * t
|
|
384
|
+
}));
|
|
385
|
+
let a = Math.max(1, Math.floor(r.w * t)), o = Math.max(1, Math.floor(r.h * t));
|
|
386
|
+
this.off.width = a, this.off.height = o, this.offCtx.setTransform(1, 0, 0, 1, 0, 0), this.offCtx.fillStyle = this.invertColorsValue ? "#ffffff" : this.backgroundColor, this.offCtx.fillRect(0, 0, a, o);
|
|
387
|
+
let s = null;
|
|
388
|
+
try {
|
|
389
|
+
s = this.page.render({
|
|
390
|
+
canvas: this.off,
|
|
391
|
+
canvasContext: this.offCtx,
|
|
392
|
+
viewport: i
|
|
393
|
+
}), this.task = s, await s.promise;
|
|
394
|
+
} catch (t) {
|
|
395
|
+
if (e !== this.seq || (t?.name ?? "") === "RenderingCancelledException") return;
|
|
396
|
+
throw t;
|
|
397
|
+
} finally {
|
|
398
|
+
this.task === s && (this.task = null);
|
|
399
|
+
}
|
|
400
|
+
if (e !== this.seq) return;
|
|
401
|
+
let c = this.invertColorsValue, l = this.invertModeValue, u = c && (l === "unblend" || l === "achromatic"), d = l === "all" ? E : te, f = c && !u && le;
|
|
402
|
+
this.canvas.width = a, this.canvas.height = o, u ? this.inverter.presentPerPixel(this.off, this.offCtx, this.ctx, a, o, l, this.invertThresholdValue) : (this.ctx.setTransform(1, 0, 0, 1, 0, 0), f && (this.ctx.filter = d), this.ctx.drawImage(this.off, 0, 0), f && (this.ctx.filter = "none")), this.canvas.style.filter = c && !u && !f ? d : "", this.canvas.style.background = this.backgroundColor, this.presentedValue = {
|
|
403
|
+
zoom: this.zoomValue,
|
|
404
|
+
center: { ...this.centerValue },
|
|
405
|
+
region: r,
|
|
406
|
+
offset: {
|
|
407
|
+
x: 0,
|
|
408
|
+
y: 0
|
|
409
|
+
}
|
|
410
|
+
}, this.layout(r), this.onPresented?.(this.presentedValue);
|
|
411
|
+
}
|
|
412
|
+
}, j = class e {
|
|
25
413
|
constructor(e = 100) {
|
|
26
414
|
this.cache = /* @__PURE__ */ new Map(), this.capacity = e;
|
|
27
415
|
}
|
|
@@ -57,82 +445,99 @@ var _ = class e {
|
|
|
57
445
|
get size() {
|
|
58
446
|
return this.cache.size;
|
|
59
447
|
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
448
|
+
}, M = () => typeof navigator < "u" && /Mobi|Android|iPhone|iPad/i.test(navigator.userAgent);
|
|
449
|
+
function ue(e) {
|
|
450
|
+
let t = window.devicePixelRatio ?? 1;
|
|
451
|
+
return e >= 32 ? 1 : e >= 16 ? Math.min(t, 2) : t;
|
|
452
|
+
}
|
|
453
|
+
function N(e) {
|
|
454
|
+
return e ? 2048 : 4096;
|
|
65
455
|
}
|
|
66
|
-
var
|
|
67
|
-
async function
|
|
68
|
-
let n = t.scale ?? 1.5, r = t.
|
|
456
|
+
var P = 4096, de = 128;
|
|
457
|
+
async function F(e, t = {}) {
|
|
458
|
+
let n = t.scale ?? 1.5, r = M(), i = t.backgroundColor ?? "rgb(255,255,255)";
|
|
69
459
|
t.cache;
|
|
70
|
-
let
|
|
71
|
-
|
|
72
|
-
let
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
460
|
+
let a = ue(n), o = e.getViewport({ scale: n * a }), s = o.width, c = o.height, l = N(r), u = Math.min(l, P, Math.max(s, c)), d = Math.ceil(s / u), f = Math.ceil(c / u), p = d * f;
|
|
461
|
+
p > de && console.warn(`[PDF-CORE] scale=${n} dpr=${a}, tile=${p} (${d}×${f}), tileSize=${u}px (physical). IntersectionObserver 将按需渲染。`);
|
|
462
|
+
let m = s / a, h = c / a, g = document.createElement("div");
|
|
463
|
+
g.style.cssText = [
|
|
464
|
+
"position:relative",
|
|
465
|
+
`width:${m}px`,
|
|
466
|
+
`height:${h}px`,
|
|
467
|
+
"overflow:hidden",
|
|
468
|
+
`background:${i}`
|
|
469
|
+
].join(";");
|
|
470
|
+
let _ = /* @__PURE__ */ new Set(), v = /* @__PURE__ */ new Set(), y = r ? 2 : 4, b = 0, x = [], S = () => {
|
|
471
|
+
for (; x.length > 0 && b < y;) x.shift()();
|
|
472
|
+
}, C = (t, r, o) => {
|
|
473
|
+
let s = t.dataset.tileKey;
|
|
474
|
+
if (_.has(s) || v.has(s)) return;
|
|
475
|
+
v.add(s), b++;
|
|
476
|
+
let c = t.getContext("2d", { alpha: !1 });
|
|
477
|
+
c.setTransform(1, 0, 0, 1, 0, 0), c.fillStyle = i, c.fillRect(0, 0, t.width, t.height);
|
|
478
|
+
let l = r * u, d = o * u, f = e.getViewport({ scale: n * a });
|
|
479
|
+
c.translate(-l, -d), e.render({
|
|
480
|
+
canvas: t,
|
|
481
|
+
canvasContext: c,
|
|
482
|
+
viewport: f
|
|
483
|
+
}).promise.then(() => {
|
|
484
|
+
_.add(s);
|
|
485
|
+
}).catch(() => {
|
|
486
|
+
c.setTransform(1, 0, 0, 1, 0, 0), c.fillStyle = i, c.fillRect(0, 0, t.width, t.height);
|
|
487
|
+
}).finally(() => {
|
|
488
|
+
v.delete(s), b--, S();
|
|
79
489
|
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
let [s, c] = t.split(",").map(Number), l = s * r, u = c * r, d = e.getViewport({ scale: n * a }), f = o.getContext("2d");
|
|
91
|
-
f.setTransform(1, 0, 0, 1, 0, 0), f.translate(-l, -u), e.render({
|
|
92
|
-
canvas: o,
|
|
93
|
-
canvasContext: f,
|
|
94
|
-
viewport: d,
|
|
95
|
-
background: i
|
|
96
|
-
}).promise.then(() => {
|
|
97
|
-
m.add(t), h.delete(t);
|
|
98
|
-
}).catch(() => {
|
|
99
|
-
h.delete(t);
|
|
100
|
-
});
|
|
101
|
-
} else {
|
|
102
|
-
let e = o.dataset.tileKey;
|
|
103
|
-
n > 8 && m.has(e) && (o.getContext("2d").clearRect(0, 0, o.width, o.height), m.delete(e));
|
|
490
|
+
}, w = r ? "128px" : "256px", ee = r ? 2 : 3, T = new IntersectionObserver((e) => {
|
|
491
|
+
e.forEach((e) => {
|
|
492
|
+
let t = e.target, r = t.dataset.tileKey, [a, o] = (t.dataset.tilePos ?? "0,0").split(",").map(Number);
|
|
493
|
+
if (e.isIntersecting) {
|
|
494
|
+
if (_.has(r) || v.has(r)) return;
|
|
495
|
+
let e = () => C(t, a, o);
|
|
496
|
+
b >= y ? x.push(e) : e();
|
|
497
|
+
} else if (n >= ee && _.has(r)) {
|
|
498
|
+
let e = t.getContext("2d", { alpha: !1 });
|
|
499
|
+
e.setTransform(1, 0, 0, 1, 0, 0), e.fillStyle = i, e.fillRect(0, 0, t.width, t.height), _.delete(r);
|
|
104
500
|
}
|
|
105
501
|
});
|
|
106
502
|
}, {
|
|
107
503
|
root: null,
|
|
108
|
-
rootMargin:
|
|
504
|
+
rootMargin: w,
|
|
109
505
|
threshold: 0
|
|
110
|
-
}),
|
|
111
|
-
for (let
|
|
112
|
-
let
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
506
|
+
}), E = [];
|
|
507
|
+
for (let t = 0; t < f; t++) for (let r = 0; r < d; r++) {
|
|
508
|
+
let o = r * u, l = t * u, d = Math.round(Math.min(u, s - o)), f = Math.round(Math.min(u, c - l)), p = o / a, m = l / a, h = d / a, _ = f / a, v = document.createElement("canvas");
|
|
509
|
+
v.width = d, v.height = f;
|
|
510
|
+
let y = v.getContext("2d", { alpha: !1 });
|
|
511
|
+
y.fillStyle = i, y.fillRect(0, 0, d, f), v.style.cssText = [
|
|
512
|
+
"position:absolute",
|
|
513
|
+
`left:${p}px`,
|
|
514
|
+
`top:${m}px`,
|
|
515
|
+
`width:${h}px`,
|
|
516
|
+
`height:${_}px`,
|
|
517
|
+
`background:${i}`
|
|
518
|
+
].join(";"), v.dataset.tileKey = j.makeKey(e.pageNumber, n, r, t), v.dataset.tilePos = `${r},${t}`, g.appendChild(v), T.observe(v), E.push({
|
|
519
|
+
canvas: v,
|
|
520
|
+
col: r,
|
|
521
|
+
row: t,
|
|
522
|
+
x: o,
|
|
523
|
+
y: l,
|
|
524
|
+
cssWidth: h,
|
|
525
|
+
cssHeight: _
|
|
121
526
|
});
|
|
122
527
|
}
|
|
123
528
|
return {
|
|
124
529
|
tiledPage: {
|
|
125
|
-
container:
|
|
126
|
-
pageWidth:
|
|
127
|
-
pageHeight:
|
|
128
|
-
tiles:
|
|
530
|
+
container: g,
|
|
531
|
+
pageWidth: m,
|
|
532
|
+
pageHeight: h,
|
|
533
|
+
tiles: E
|
|
129
534
|
},
|
|
130
|
-
observer:
|
|
535
|
+
observer: T
|
|
131
536
|
};
|
|
132
537
|
}
|
|
133
538
|
//#endregion
|
|
134
539
|
//#region src/core/coords/CoordTransformer.ts
|
|
135
|
-
var
|
|
540
|
+
var I = class {
|
|
136
541
|
constructor(e, t, n) {
|
|
137
542
|
if (this.viewport = e, this.scale = t, this.pageSizePt = n, t <= 0) throw RangeError(`scale 必须大于 0,收到: ${t}`);
|
|
138
543
|
}
|
|
@@ -178,7 +583,7 @@ var S = class {
|
|
|
178
583
|
get pageSize() {
|
|
179
584
|
return this.pageSizePt;
|
|
180
585
|
}
|
|
181
|
-
},
|
|
586
|
+
}, L = [
|
|
182
587
|
5,
|
|
183
588
|
10,
|
|
184
589
|
25,
|
|
@@ -196,13 +601,21 @@ var S = class {
|
|
|
196
601
|
800,
|
|
197
602
|
1200,
|
|
198
603
|
1600,
|
|
199
|
-
|
|
200
|
-
|
|
604
|
+
1800,
|
|
605
|
+
2e3,
|
|
606
|
+
2200,
|
|
607
|
+
2800,
|
|
608
|
+
3200,
|
|
609
|
+
4e3,
|
|
610
|
+
6e3,
|
|
611
|
+
8e3,
|
|
612
|
+
1e4,
|
|
613
|
+
12800
|
|
201
614
|
];
|
|
202
|
-
function
|
|
203
|
-
return t === "in" ?
|
|
615
|
+
function R(e, t) {
|
|
616
|
+
return t === "in" ? L.find((t) => t > e) ?? L[L.length - 1] : [...L].reverse().find((t) => t < e) ?? L[0];
|
|
204
617
|
}
|
|
205
|
-
var
|
|
618
|
+
var z = class {
|
|
206
619
|
constructor() {
|
|
207
620
|
this.interaction = null, this.toolManager = null, this.drawCallback = null, this.domContainerId = null, this.zoomCtrl = null, this.initialScale = 1.5;
|
|
208
621
|
}
|
|
@@ -240,12 +653,12 @@ var T = class {
|
|
|
240
653
|
}
|
|
241
654
|
zoomIn() {
|
|
242
655
|
if (!this.zoomCtrl) return;
|
|
243
|
-
let e = this.zoomCtrl.getScale(), t =
|
|
656
|
+
let e = this.zoomCtrl.getScale(), t = R(Math.round(e * 100), "in");
|
|
244
657
|
this.zoomCtrl.setScale(t / 100);
|
|
245
658
|
}
|
|
246
659
|
zoomOut() {
|
|
247
660
|
if (!this.zoomCtrl) return;
|
|
248
|
-
let e = this.zoomCtrl.getScale(), t =
|
|
661
|
+
let e = this.zoomCtrl.getScale(), t = R(Math.round(e * 100), "out");
|
|
249
662
|
this.zoomCtrl.setScale(t / 100);
|
|
250
663
|
}
|
|
251
664
|
setScale(e) {
|
|
@@ -257,10 +670,11 @@ var T = class {
|
|
|
257
670
|
getScalePercent() {
|
|
258
671
|
return Math.round((this.zoomCtrl?.getScale() ?? 1) * 100);
|
|
259
672
|
}
|
|
260
|
-
resetView() {
|
|
261
|
-
this.zoomCtrl && this.zoomCtrl.setScale(this.initialScale);
|
|
262
|
-
|
|
263
|
-
|
|
673
|
+
async resetView() {
|
|
674
|
+
this.zoomCtrl && await this.zoomCtrl.setScale(this.initialScale), this.zoomCtrl?.resetPosition();
|
|
675
|
+
}
|
|
676
|
+
toggleTheme() {
|
|
677
|
+
this.zoomCtrl?.toggleTheme();
|
|
264
678
|
}
|
|
265
679
|
getAnnotations() {
|
|
266
680
|
return this.toolManager ? this.toolManager.measureTool.getResults().map((e) => ({
|
|
@@ -305,7 +719,7 @@ var T = class {
|
|
|
305
719
|
};
|
|
306
720
|
//#endregion
|
|
307
721
|
//#region src/annotations/utils.ts
|
|
308
|
-
function
|
|
722
|
+
function B(e, t = 0, n = "px") {
|
|
309
723
|
return {
|
|
310
724
|
id: `measure-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
311
725
|
kind: "measure",
|
|
@@ -317,7 +731,7 @@ function E(e, t = 0, n = "px") {
|
|
|
317
731
|
createdAt: Date.now()
|
|
318
732
|
};
|
|
319
733
|
}
|
|
320
|
-
function
|
|
734
|
+
function V(e, t = "rectangle") {
|
|
321
735
|
return {
|
|
322
736
|
id: `shape-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
323
737
|
kind: "shape",
|
|
@@ -328,12 +742,12 @@ function D(e, t = "rectangle") {
|
|
|
328
742
|
createdAt: Date.now()
|
|
329
743
|
};
|
|
330
744
|
}
|
|
331
|
-
function
|
|
745
|
+
function fe(e) {
|
|
332
746
|
return JSON.parse(JSON.stringify(e));
|
|
333
747
|
}
|
|
334
748
|
//#endregion
|
|
335
749
|
//#region src/utils/EventTrigger.ts
|
|
336
|
-
var
|
|
750
|
+
var H = class {
|
|
337
751
|
constructor() {
|
|
338
752
|
this._events = /* @__PURE__ */ new Map();
|
|
339
753
|
}
|
|
@@ -374,90 +788,133 @@ var k = class {
|
|
|
374
788
|
};
|
|
375
789
|
//#endregion
|
|
376
790
|
//#region src/vue/usePdfCore.ts
|
|
377
|
-
function
|
|
378
|
-
let t =
|
|
379
|
-
|
|
791
|
+
function pe(e = {}) {
|
|
792
|
+
let t = h(null), n = _(null), r = _(null), i = _(null), a = h(0), o = h(1), s = h(e.scale ?? 1), c = h(e.backgroundColor ?? "rgb(255,255,255)"), l = h(e.invertColors ?? !1), u = h(!1), d = h(null), f = new H(), p = (i) => {
|
|
793
|
+
let { canvas: a, stage: u, wrap: d } = i;
|
|
794
|
+
if (!a || !u) return null;
|
|
795
|
+
n.value && n.value.destroy();
|
|
796
|
+
let p = new A({
|
|
797
|
+
canvas: a,
|
|
798
|
+
stage: u,
|
|
799
|
+
wrap: d ?? null,
|
|
800
|
+
maxSide: e.maxSide,
|
|
801
|
+
maxZoom: e.maxZoom,
|
|
802
|
+
backgroundColor: c.value,
|
|
803
|
+
invertColors: l.value,
|
|
804
|
+
invertMode: e.invertMode,
|
|
805
|
+
invertThreshold: e.invertThreshold ?? 24,
|
|
806
|
+
onPresented: (t) => {
|
|
807
|
+
s.value = t.zoom, f.emit("render_complete", {
|
|
808
|
+
pageNum: o.value,
|
|
809
|
+
scale: t.zoom
|
|
810
|
+
}), e.onPresented?.({
|
|
811
|
+
zoom: t.zoom,
|
|
812
|
+
pageNum: o.value,
|
|
813
|
+
tiled: t.region.tiled
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
});
|
|
817
|
+
p.refreshStageBox(), n.value = p, t.value = u;
|
|
818
|
+
let m = r.value;
|
|
819
|
+
return m && m.destroyed !== !0 && (async () => {
|
|
820
|
+
try {
|
|
821
|
+
if (n.value !== p || (await p.open(m), p.setZoom(s.value), n.value !== p)) return;
|
|
822
|
+
await p.render();
|
|
823
|
+
} catch (e) {
|
|
824
|
+
console.error("[PDF-CORE] 重新挂载后恢复渲染失败:", e);
|
|
825
|
+
}
|
|
826
|
+
})(), p;
|
|
827
|
+
}, m = () => {
|
|
828
|
+
n.value?.destroy(), n.value = null;
|
|
829
|
+
}, g = async (e) => {
|
|
830
|
+
u.value = !0, d.value = null;
|
|
380
831
|
try {
|
|
381
|
-
let t = await
|
|
382
|
-
|
|
832
|
+
let t = await T(e);
|
|
833
|
+
r.value = t.doc, a.value = t.pageCount, o.value = 1;
|
|
834
|
+
let c = n.value;
|
|
835
|
+
if (c) {
|
|
836
|
+
let e = await c.open(t.doc);
|
|
837
|
+
c.setZoom(s.value), c.refreshStageBox(), e.wPt > 0 && (i.value = c.pageRef);
|
|
838
|
+
}
|
|
839
|
+
await v(), f.emit("loaded", {
|
|
383
840
|
pageCount: t.pageCount,
|
|
384
841
|
currentPage: 1
|
|
385
842
|
});
|
|
386
843
|
} catch (e) {
|
|
387
844
|
let t = e instanceof Error ? e.message : "Failed to load PDF";
|
|
388
|
-
|
|
845
|
+
d.value = t, f.emit("error_occurred", { message: t });
|
|
389
846
|
} finally {
|
|
390
|
-
|
|
847
|
+
u.value = !1;
|
|
391
848
|
}
|
|
392
|
-
},
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
r.value = e;
|
|
399
|
-
let { tiledPage: i, observer: c } = await x(e, {
|
|
400
|
-
scale: o.value,
|
|
401
|
-
cache: p,
|
|
402
|
-
backgroundColor: s
|
|
403
|
-
});
|
|
404
|
-
h = c, t.value.replaceChildren(i.container), f.emit("render_complete", {
|
|
405
|
-
pageNum: a.value,
|
|
406
|
-
scale: o.value
|
|
407
|
-
});
|
|
408
|
-
} catch (e) {
|
|
409
|
-
console.error("[PDF-CORE] renderCurrentPage failed:", e), f.emit("error_occurred", { message: e instanceof Error ? e.message : "Render failed" });
|
|
410
|
-
} finally {
|
|
411
|
-
m = !1;
|
|
412
|
-
}
|
|
849
|
+
}, v = async () => {
|
|
850
|
+
let e = n.value;
|
|
851
|
+
if (!(!e || !r.value)) try {
|
|
852
|
+
await e.render();
|
|
853
|
+
} catch (e) {
|
|
854
|
+
console.error("[PDF-CORE] render failed:", e), f.emit("error_occurred", { message: e instanceof Error ? e.message : "Render failed" });
|
|
413
855
|
}
|
|
414
856
|
};
|
|
415
|
-
return
|
|
857
|
+
return {
|
|
416
858
|
containerRef: t,
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
859
|
+
renderer: n,
|
|
860
|
+
doc: r,
|
|
861
|
+
page: i,
|
|
862
|
+
pageCount: a,
|
|
863
|
+
currentPageNum: o,
|
|
864
|
+
currentScale: s,
|
|
865
|
+
backgroundColor: c,
|
|
866
|
+
isLoading: u,
|
|
867
|
+
error: d,
|
|
424
868
|
events: f,
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
869
|
+
attach: p,
|
|
870
|
+
detach: m,
|
|
871
|
+
loadFile: g,
|
|
872
|
+
renderCurrentPage: v,
|
|
873
|
+
setScale: async (e) => {
|
|
874
|
+
let t = n.value;
|
|
875
|
+
if (!t || e <= 0) return;
|
|
876
|
+
let r = t.zoom;
|
|
877
|
+
t.setZoom(e), await t.render(), r !== t.zoom && f.emit("scale_changed", {
|
|
878
|
+
scale: t.zoom,
|
|
879
|
+
previousScale: r
|
|
880
|
+
});
|
|
881
|
+
},
|
|
882
|
+
setBackgroundColor: async (e) => {
|
|
883
|
+
c.value = e;
|
|
884
|
+
let t = n.value;
|
|
885
|
+
t && (t.setBackgroundColor(e), t.pageRef && await t.render());
|
|
886
|
+
},
|
|
887
|
+
setInvertColors: (e) => {
|
|
888
|
+
l.value = e;
|
|
889
|
+
let t = n.value;
|
|
890
|
+
t && (t.setInvertColors(e), t.pageRef && t.render());
|
|
891
|
+
},
|
|
892
|
+
setInvertMode: (e, t) => {
|
|
893
|
+
n.value?.setInvertMode(e, t);
|
|
894
|
+
},
|
|
895
|
+
setMaxZoom: (e) => {
|
|
896
|
+
n.value?.setMaxZoom(e);
|
|
897
|
+
},
|
|
898
|
+
invertColors: l,
|
|
899
|
+
resetView: () => {
|
|
900
|
+
n.value?.centerOnContent(), n.value?.requestRender();
|
|
901
|
+
},
|
|
445
902
|
reset: () => {
|
|
446
|
-
n.value = null,
|
|
903
|
+
n.value?.unload(), r.value = null, i.value = null, a.value = 0, o.value = 1, d.value = null, u.value = !1, f.emit("cleared");
|
|
447
904
|
}
|
|
448
905
|
};
|
|
449
906
|
}
|
|
450
907
|
//#endregion
|
|
451
908
|
//#region src/vue/useAnnotations.ts
|
|
452
|
-
function
|
|
453
|
-
let e =
|
|
909
|
+
function U() {
|
|
910
|
+
let e = h([]);
|
|
454
911
|
return {
|
|
455
912
|
annotations: e,
|
|
456
913
|
addMeasureAnnotation: (t, n = 0, r = "px") => {
|
|
457
|
-
e.value = [...e.value,
|
|
914
|
+
e.value = [...e.value, B(t, n, r)];
|
|
458
915
|
},
|
|
459
916
|
addShapeAnnotation: (t, n = "rectangle") => {
|
|
460
|
-
e.value = [...e.value,
|
|
917
|
+
e.value = [...e.value, V(t, n)];
|
|
461
918
|
},
|
|
462
919
|
removeAnnotation: (t) => {
|
|
463
920
|
e.value = e.value.filter((e) => e.id !== t);
|
|
@@ -466,14 +923,14 @@ function j() {
|
|
|
466
923
|
e.value = [];
|
|
467
924
|
},
|
|
468
925
|
replaceAnnotations: (t) => {
|
|
469
|
-
e.value = t.map(
|
|
926
|
+
e.value = t.map(fe);
|
|
470
927
|
}
|
|
471
928
|
};
|
|
472
929
|
}
|
|
473
930
|
//#endregion
|
|
474
931
|
//#region src/vue/useMeasurement.ts
|
|
475
|
-
function
|
|
476
|
-
let e =
|
|
932
|
+
function W() {
|
|
933
|
+
let e = h([]);
|
|
477
934
|
return {
|
|
478
935
|
points: e,
|
|
479
936
|
addPoint: (t) => {
|
|
@@ -482,7 +939,7 @@ function M() {
|
|
|
482
939
|
clearPoints: () => {
|
|
483
940
|
e.value = [];
|
|
484
941
|
},
|
|
485
|
-
distance:
|
|
942
|
+
distance: n(() => {
|
|
486
943
|
if (e.value.length < 2) return 0;
|
|
487
944
|
let [t, n] = e.value.slice(-2);
|
|
488
945
|
return Math.hypot(n.x - t.x, n.y - t.y);
|
|
@@ -491,8 +948,8 @@ function M() {
|
|
|
491
948
|
}
|
|
492
949
|
//#endregion
|
|
493
950
|
//#region src/vue/useInteraction.ts
|
|
494
|
-
function
|
|
495
|
-
let { annotations: e, addMeasureAnnotation: t, clearAnnotations: n } =
|
|
951
|
+
function me() {
|
|
952
|
+
let { annotations: e, addMeasureAnnotation: t, clearAnnotations: n } = U(), { points: r, addPoint: i, clearPoints: a, distance: o } = W(), s = h(!1);
|
|
496
953
|
return {
|
|
497
954
|
points: r,
|
|
498
955
|
annotations: e,
|
|
@@ -513,7 +970,7 @@ function N() {
|
|
|
513
970
|
}
|
|
514
971
|
//#endregion
|
|
515
972
|
//#region src/components/interaction.ts
|
|
516
|
-
function
|
|
973
|
+
function he() {
|
|
517
974
|
let e = [], t = [], n = "none", r = null;
|
|
518
975
|
return {
|
|
519
976
|
get points() {
|
|
@@ -533,11 +990,11 @@ function P() {
|
|
|
533
990
|
},
|
|
534
991
|
addPoint(i) {
|
|
535
992
|
if (e = [...e, i], n === "measure" && e.length >= 2) {
|
|
536
|
-
let n =
|
|
993
|
+
let n = B([e[e.length - 2], e[e.length - 1]], Math.hypot(e[e.length - 1].x - e[e.length - 2].x, e[e.length - 1].y - e[e.length - 2].y));
|
|
537
994
|
return t = [...t, n], r = n.id, e = [], n;
|
|
538
995
|
}
|
|
539
996
|
if (n === "rectangle" && e.length >= 2) {
|
|
540
|
-
let n =
|
|
997
|
+
let n = V([e[e.length - 2], e[e.length - 1]], "rectangle");
|
|
541
998
|
return t = [...t, n], r = n.id, e = [], n;
|
|
542
999
|
}
|
|
543
1000
|
return null;
|
|
@@ -559,67 +1016,71 @@ function P() {
|
|
|
559
1016
|
}
|
|
560
1017
|
//#endregion
|
|
561
1018
|
//#region src/components/useAnnotationCanvas.ts
|
|
562
|
-
function
|
|
563
|
-
let { annotationCanvas: t, rootRef: n,
|
|
1019
|
+
function ge(e) {
|
|
1020
|
+
let { annotationCanvas: t, rootRef: n, pdfLayerRef: r, interaction: i, previewPoint: a } = e, o = (e) => {
|
|
564
1021
|
let t = e.currentTarget.getBoundingClientRect();
|
|
565
1022
|
return {
|
|
566
1023
|
x: e.clientX - t.left,
|
|
567
1024
|
y: e.clientY - t.top
|
|
568
1025
|
};
|
|
569
|
-
},
|
|
1026
|
+
}, s = (e, t, n) => {
|
|
570
1027
|
let r = n.x - t.x, i = n.y - t.y, a = r * r + i * i;
|
|
571
1028
|
if (a === 0) return Math.hypot(e.x - t.x, e.y - t.y);
|
|
572
|
-
let o = Math.max(0, Math.min(1, ((e.x - t.x) * r + (e.y - t.y) * i) / a))
|
|
573
|
-
return Math.hypot(e.x -
|
|
574
|
-
},
|
|
1029
|
+
let o = Math.max(0, Math.min(1, ((e.x - t.x) * r + (e.y - t.y) * i) / a));
|
|
1030
|
+
return Math.hypot(e.x - (t.x + o * r), e.y - (t.y + o * i));
|
|
1031
|
+
}, c = (e, t) => {
|
|
575
1032
|
if (t.kind === "measure") {
|
|
576
1033
|
let [n, r] = t.points;
|
|
577
|
-
return
|
|
1034
|
+
return s(e, n, r) <= 8;
|
|
578
1035
|
}
|
|
579
1036
|
if (t.kind === "shape" && t.shapeType === "rectangle") {
|
|
580
1037
|
let [n, r] = t.points, i = Math.min(n.x, r.x), a = Math.min(n.y, r.y), o = Math.abs(n.x - r.x), s = Math.abs(n.y - r.y);
|
|
581
1038
|
return e.x >= i - 4 && e.x <= i + o + 4 && e.y >= a - 4 && e.y <= a + s + 4;
|
|
582
1039
|
}
|
|
583
1040
|
return !1;
|
|
584
|
-
},
|
|
1041
|
+
}, l = () => {
|
|
585
1042
|
if (!t.value) return;
|
|
586
1043
|
let e = t.value.getContext("2d");
|
|
587
|
-
e && (e.clearRect(0, 0, t.value.width, t.value.height),
|
|
588
|
-
let n = t.id ===
|
|
589
|
-
t.kind === "measure" &&
|
|
590
|
-
}),
|
|
591
|
-
},
|
|
1044
|
+
e && (e.clearRect(0, 0, t.value.width, t.value.height), i.annotations.forEach((t) => {
|
|
1045
|
+
let n = t.id === i.selectedAnnotationId, r = t.color ?? (t.kind === "measure" ? "#10b981" : "#3b82f6"), a = (t.strokeWidth ?? 2) + (n ? 2 : 0);
|
|
1046
|
+
t.kind === "measure" && u(e, t, n, r, a), t.kind === "shape" && t.shapeType === "rectangle" && d(e, t, n, r, a);
|
|
1047
|
+
}), a.value && i.points.length === 1 && f(e));
|
|
1048
|
+
}, u = (e, t, n, r, i) => {
|
|
592
1049
|
let [a, o] = t.points;
|
|
593
1050
|
e.save(), e.strokeStyle = n ? "#ef4444" : r, e.lineWidth = i, e.setLineDash(n ? [6, 4] : []), e.beginPath(), e.moveTo(a.x, a.y), e.lineTo(o.x, o.y), e.stroke(), e.setLineDash([]), e.fillStyle = n ? "#ef4444" : r, e.beginPath(), e.arc(a.x, a.y, n ? 4 : 3, 0, Math.PI * 2), e.arc(o.x, o.y, n ? 4 : 3, 0, Math.PI * 2), e.fill(), e.font = "12px sans-serif", e.fillText(t.label ?? `${t.value?.toFixed(1) ?? 0}`, o.x + 6, o.y - 6), e.restore();
|
|
594
|
-
},
|
|
1051
|
+
}, d = (e, t, n, r, i) => {
|
|
595
1052
|
let [a, o] = t.points, s = Math.min(a.x, o.x), c = Math.min(a.y, o.y), l = Math.abs(a.x - o.x), u = Math.abs(a.y - o.y);
|
|
596
1053
|
e.save(), e.strokeStyle = n ? "#ef4444" : r, e.lineWidth = i, e.setLineDash(n ? [6, 4] : []), e.strokeRect(s, c, l, u), e.fillStyle = n ? "rgba(239, 68, 68, 0.12)" : "rgba(59, 130, 246, 0.12)", e.fillRect(s, c, l, u), e.setLineDash([]), e.fillStyle = n ? "#ef4444" : r, e.font = "12px sans-serif", e.fillText(t.label ?? "", s + 6, c + 16), e.restore();
|
|
597
|
-
},
|
|
598
|
-
let t =
|
|
599
|
-
if (e.save(), e.strokeStyle =
|
|
600
|
-
else if (
|
|
601
|
-
let r = Math.min(t.x, n.x), i = Math.min(t.y, n.y)
|
|
602
|
-
e.strokeRect(r, i,
|
|
1054
|
+
}, f = (e) => {
|
|
1055
|
+
let t = i.points[0], n = a.value;
|
|
1056
|
+
if (e.save(), e.strokeStyle = i.mode === "measure" ? "#8b5cf6" : "#2563eb", e.lineWidth = 2, e.setLineDash([6, 4]), i.mode === "measure") e.beginPath(), e.moveTo(t.x, t.y), e.lineTo(n.x, n.y), e.stroke(), e.beginPath(), e.arc(t.x, t.y, 3, 0, Math.PI * 2), e.arc(n.x, n.y, 3, 0, Math.PI * 2), e.fillStyle = "#8b5cf6", e.fill();
|
|
1057
|
+
else if (i.mode === "rectangle") {
|
|
1058
|
+
let r = Math.min(t.x, n.x), i = Math.min(t.y, n.y);
|
|
1059
|
+
e.strokeRect(r, i, Math.abs(t.x - n.x), Math.abs(t.y - n.y));
|
|
603
1060
|
}
|
|
604
1061
|
e.restore();
|
|
605
1062
|
};
|
|
606
1063
|
return {
|
|
607
|
-
getCanvasPoint:
|
|
608
|
-
getDistanceToSegment:
|
|
609
|
-
hitTestAnnotation:
|
|
610
|
-
drawAnnotations:
|
|
1064
|
+
getCanvasPoint: o,
|
|
1065
|
+
getDistanceToSegment: s,
|
|
1066
|
+
hitTestAnnotation: c,
|
|
1067
|
+
drawAnnotations: l,
|
|
611
1068
|
syncCanvasSize: () => {
|
|
612
|
-
if (!
|
|
613
|
-
let e =
|
|
614
|
-
|
|
615
|
-
let i =
|
|
616
|
-
|
|
1069
|
+
if (!t.value) return;
|
|
1070
|
+
let e = r?.value ?? n.value;
|
|
1071
|
+
if (!e) return;
|
|
1072
|
+
let i = e.scrollWidth || e.offsetWidth, a = e.scrollHeight || e.offsetHeight;
|
|
1073
|
+
if (i === 0 || a === 0) return;
|
|
1074
|
+
let o = t.value, s = window.devicePixelRatio || 1;
|
|
1075
|
+
(o.width !== Math.round(i * s) || o.height !== Math.round(a * s)) && (o.width = Math.round(i * s), o.height = Math.round(a * s)), o.style.width = `${i}px`, o.style.height = `${a}px`;
|
|
1076
|
+
let c = o.getContext("2d");
|
|
1077
|
+
c && c.setTransform(s, 0, 0, s, 0, 0);
|
|
617
1078
|
}
|
|
618
1079
|
};
|
|
619
1080
|
}
|
|
620
1081
|
//#endregion
|
|
621
1082
|
//#region src/components/usePointerInteraction.ts
|
|
622
|
-
function
|
|
1083
|
+
function _e(e) {
|
|
623
1084
|
let { annotationCanvas: t, interaction: n, previewPoint: r, isRectangleDragging: i, getCanvasPoint: a, hitTestAnnotation: o, drawAnnotations: s, deleteSelectedAnnotation: c, emit: l } = e;
|
|
624
1085
|
return {
|
|
625
1086
|
handlePointerDown: (e) => {
|
|
@@ -684,88 +1145,110 @@ function I(e) {
|
|
|
684
1145
|
}
|
|
685
1146
|
//#endregion
|
|
686
1147
|
//#region src/components/useViewerLayout.ts
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
let
|
|
698
|
-
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
1148
|
+
function ve(e) {
|
|
1149
|
+
let { viewerRef: t, renderer: r, zoomSpeed: i, theme: a, onViewChanged: o } = e, s = n(() => ({
|
|
1150
|
+
width: "100%",
|
|
1151
|
+
height: "100%",
|
|
1152
|
+
background: a.value === "dark" ? "#000000" : "#ffffff",
|
|
1153
|
+
overflow: "hidden",
|
|
1154
|
+
position: "relative",
|
|
1155
|
+
touchAction: "none",
|
|
1156
|
+
display: "block"
|
|
1157
|
+
})), c = (e = !1) => {
|
|
1158
|
+
let t = r.value;
|
|
1159
|
+
t && (t.refreshStageBox(), e && t.centerOnContent(), t.requestRender(), o?.());
|
|
1160
|
+
}, l = h(!1), u = /* @__PURE__ */ new Map(), d = null, f = null, p = (e, t) => Math.hypot(e.x - t.x, e.y - t.y), m = (e, t) => ({
|
|
1161
|
+
x: (e.x + t.x) / 2,
|
|
1162
|
+
y: (e.y + t.y) / 2
|
|
1163
|
+
}), g = (e) => {
|
|
1164
|
+
try {
|
|
1165
|
+
t.value?.setPointerCapture?.(e);
|
|
1166
|
+
} catch {}
|
|
1167
|
+
}, _ = (e) => {
|
|
1168
|
+
try {
|
|
1169
|
+
t.value?.releasePointerCapture?.(e);
|
|
1170
|
+
} catch {}
|
|
1171
|
+
}, v = () => {
|
|
1172
|
+
f = null;
|
|
1173
|
+
}, y = (e) => {
|
|
1174
|
+
let t = r.value;
|
|
1175
|
+
if (t && !(e.pointerType === "mouse" && e.button !== 0)) {
|
|
1176
|
+
if (u.set(e.pointerId, {
|
|
1177
|
+
x: e.clientX,
|
|
1178
|
+
y: e.clientY
|
|
1179
|
+
}), g(e.pointerId), u.size === 1) {
|
|
1180
|
+
d = {
|
|
1181
|
+
id: e.pointerId,
|
|
1182
|
+
sx: e.clientX,
|
|
1183
|
+
sy: e.clientY
|
|
1184
|
+
}, l.value = !0, e.preventDefault();
|
|
1185
|
+
return;
|
|
1186
|
+
}
|
|
1187
|
+
if (u.size === 2) {
|
|
1188
|
+
if (d) {
|
|
1189
|
+
let e = u.get(d.id);
|
|
1190
|
+
e && t.commitDrag(e.x - d.sx, e.y - d.sy), d = null, l.value = !1;
|
|
1191
|
+
}
|
|
1192
|
+
let [n, r] = [...u.values()], i = m(n, r);
|
|
1193
|
+
f = {
|
|
1194
|
+
dist: Math.max(1, p(n, r)),
|
|
1195
|
+
zoom: t.zoom,
|
|
1196
|
+
pt: t.screenToPt(i.x, i.y)
|
|
1197
|
+
}, e.preventDefault();
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
}, b = (e) => {
|
|
1201
|
+
let t = r.value;
|
|
1202
|
+
if (!(!t || !u.has(e.pointerId))) {
|
|
1203
|
+
if (u.set(e.pointerId, {
|
|
1204
|
+
x: e.clientX,
|
|
1205
|
+
y: e.clientY
|
|
1206
|
+
}), u.size >= 2 && f) {
|
|
1207
|
+
let [n, r] = [...u.values()], i = m(n, r), a = f.zoom * p(n, r) / f.dist;
|
|
1208
|
+
t.anchorAt(i.x, i.y, f.pt, a), e.preventDefault();
|
|
1209
|
+
return;
|
|
1210
|
+
}
|
|
1211
|
+
d && e.pointerId === d.id && (t.setDragOffset(e.clientX - d.sx, e.clientY - d.sy), e.preventDefault());
|
|
1212
|
+
}
|
|
1213
|
+
}, x = (e) => {
|
|
1214
|
+
let t = r.value;
|
|
1215
|
+
if (u.delete(e.pointerId), _(e.pointerId), t && (f && u.size < 2 && v(), d && e.pointerId === d.id && (t.commitDrag(e.clientX - d.sx, e.clientY - d.sy), d = null, l.value = !1, o?.()), !d && u.size === 1)) {
|
|
1216
|
+
let [e, t] = [...u.entries()][0];
|
|
1217
|
+
d = {
|
|
1218
|
+
id: e,
|
|
1219
|
+
sx: t.x,
|
|
1220
|
+
sy: t.y
|
|
1221
|
+
}, l.value = !0;
|
|
1222
|
+
}
|
|
1223
|
+
};
|
|
704
1224
|
return {
|
|
705
|
-
containerStyle:
|
|
706
|
-
|
|
707
|
-
height: "100%",
|
|
708
|
-
background: c === "dark" ? "#1e1e1e" : "#ffffff",
|
|
709
|
-
overflow: "auto",
|
|
710
|
-
borderRadius: "8px",
|
|
711
|
-
border: c === "dark" ? "1px solid #374151" : "1px solid #e2e8f0",
|
|
712
|
-
position: "relative",
|
|
713
|
-
touchAction: "pan-x pan-y",
|
|
714
|
-
display: "flex"
|
|
715
|
-
})),
|
|
716
|
-
adjustLayout: (e = !1) => {
|
|
717
|
-
let t = n.value, a = r.value, o = i.value;
|
|
718
|
-
if (!t || !a || !o) return;
|
|
719
|
-
let s = t.clientWidth, c = t.clientHeight, d = o.scrollWidth || s, f = o.scrollHeight || c, p = Math.max(d, s * 1.5), m = Math.max(f, c * 1.5);
|
|
720
|
-
a.style.width = `${p}px`, a.style.height = `${m}px`, e && (t.scrollLeft = p - s, t.scrollTop = (m - c) / 2), l(), u();
|
|
721
|
-
},
|
|
1225
|
+
containerStyle: s,
|
|
1226
|
+
adjustLayout: c,
|
|
722
1227
|
handleWheel: (e) => {
|
|
1228
|
+
let t = r.value;
|
|
1229
|
+
if (!t) return;
|
|
723
1230
|
e.preventDefault();
|
|
724
|
-
let
|
|
725
|
-
|
|
726
|
-
let u = e.deltaY < 0 ? "in" : "out", d = Math.max(1, s ?? 1), f = Math.round(a.value * 100);
|
|
727
|
-
for (let e = 0; e < d; e++) {
|
|
728
|
-
let e = w(f, u);
|
|
729
|
-
if (e === f) break;
|
|
730
|
-
f = e;
|
|
731
|
-
}
|
|
732
|
-
let p = f / 100;
|
|
733
|
-
if (p === a.value) return;
|
|
734
|
-
let m = a.value, h = p / m, g = t.getBoundingClientRect(), _ = e.clientX - g.left, v = e.clientY - g.top, y = _ + t.scrollLeft, b = v + t.scrollTop, x = l.scrollWidth, S = l.scrollHeight, C = x / m, T = S / m, E = C * p, D = T * p, O = t.clientWidth, k = t.clientHeight, A = y * h - _, j = b * h - v;
|
|
735
|
-
c.style.width = `${Math.max(E, A + O, O * 1.5)}px`, c.style.height = `${Math.max(D, j + k, k * 1.5)}px`, c.offsetWidth, t.scrollLeft = A, t.scrollTop = j, o(p);
|
|
736
|
-
},
|
|
737
|
-
handleTouchStart: (e) => {
|
|
738
|
-
e.touches.length === 2 && (d = L(e.touches), f = a.value, p = R(e.touches), m = a.value);
|
|
1231
|
+
let n = Math.max(1, Math.round(i || 1)), a = (e.deltaY < 0 ? 1.12 : 1 / 1.12) ** n;
|
|
1232
|
+
t.zoomAt(e.clientX, e.clientY, a), o?.();
|
|
739
1233
|
},
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
let s = t / d, c = f * s, l = z(Math.round(Math.max(.05, Math.min(128, c)) * 100)) / 100;
|
|
746
|
-
if (l === m) return;
|
|
747
|
-
m = l;
|
|
748
|
-
let u = n.value;
|
|
749
|
-
if (u && p) {
|
|
750
|
-
let e = u.getBoundingClientRect(), t = p.x - e.left, n = p.y - e.top, s = t + u.scrollLeft, c = n + u.scrollTop, d = l / a.value, f = r.value, m = i.value;
|
|
751
|
-
if (f && m) {
|
|
752
|
-
let e = u.clientWidth, r = u.clientHeight, i = a.value, o = m.scrollWidth / i, p = m.scrollHeight / i, h = o * l, g = p * l, _ = s * d - t, v = c * d - n;
|
|
753
|
-
f.style.width = `${Math.max(h, _ + e, e * 1.5)}px`, f.style.height = `${Math.max(g, v + r, r * 1.5)}px`, f.offsetWidth;
|
|
754
|
-
}
|
|
755
|
-
u.scrollLeft = s * d - t, u.scrollTop = c * d - n, o(l);
|
|
756
|
-
}
|
|
1234
|
+
handlePointerDown: y,
|
|
1235
|
+
handlePointerMove: b,
|
|
1236
|
+
handlePointerUp: x,
|
|
1237
|
+
handlePointerCancel: (e) => {
|
|
1238
|
+
u.has(e.pointerId) ? x(e) : u.delete(e.pointerId);
|
|
757
1239
|
},
|
|
758
|
-
|
|
759
|
-
|
|
1240
|
+
isMouseDragging: l,
|
|
1241
|
+
cleanupMouseDrag: () => {
|
|
1242
|
+
u.clear(), d = null, v(), l.value = !1;
|
|
760
1243
|
}
|
|
761
1244
|
};
|
|
762
1245
|
}
|
|
763
1246
|
//#endregion
|
|
764
1247
|
//#region src/types/tools.ts
|
|
765
|
-
var
|
|
1248
|
+
var ye = {
|
|
766
1249
|
mode: "none",
|
|
767
1250
|
measureSubType: "distance"
|
|
768
|
-
},
|
|
1251
|
+
}, G = class {
|
|
769
1252
|
constructor(e) {
|
|
770
1253
|
this.TOOLNAME = "measure", this._active = !1, this._isStart = !1, this._isEnd = !1, this._isMeasuring = !1, this._isDragging = !1, this._startPoint = null, this._endPoint = null, this._points = [], this._measureList = /* @__PURE__ */ new Map(), this._dragStart = null, this._dragThreshold = 3, this.coordProvider = e.coordProvider, this.calibration = e.calibration ?? {
|
|
771
1254
|
scale: 1,
|
|
@@ -850,7 +1333,7 @@ var V = {
|
|
|
850
1333
|
destroy() {
|
|
851
1334
|
this._measureList.clear(), this.resetState(), this._active = !1;
|
|
852
1335
|
}
|
|
853
|
-
},
|
|
1336
|
+
}, K = class extends G {
|
|
854
1337
|
constructor(e) {
|
|
855
1338
|
super(e), this.currentType = "distance", this._previewEnd = null;
|
|
856
1339
|
}
|
|
@@ -902,7 +1385,7 @@ var V = {
|
|
|
902
1385
|
interrupt() {
|
|
903
1386
|
this._previewEnd = null, super.interrupt();
|
|
904
1387
|
}
|
|
905
|
-
},
|
|
1388
|
+
}, q = class extends G {
|
|
906
1389
|
constructor(e) {
|
|
907
1390
|
super(e), this.currentType = "angle", this._secondPoint = null, this._thirdPoint = null;
|
|
908
1391
|
}
|
|
@@ -932,7 +1415,7 @@ var V = {
|
|
|
932
1415
|
let u = Math.max(-1, Math.min(1, s / (c * l)));
|
|
933
1416
|
return parseFloat((Math.acos(u) * 180 / Math.PI).toFixed(2));
|
|
934
1417
|
}
|
|
935
|
-
},
|
|
1418
|
+
}, J = class extends G {
|
|
936
1419
|
constructor(e) {
|
|
937
1420
|
super(e), this.currentType = "area";
|
|
938
1421
|
}
|
|
@@ -960,7 +1443,7 @@ var V = {
|
|
|
960
1443
|
}
|
|
961
1444
|
return Math.abs(t) / 2;
|
|
962
1445
|
}
|
|
963
|
-
},
|
|
1446
|
+
}, Y = class {
|
|
964
1447
|
get currentType() {
|
|
965
1448
|
return this._currentSubType;
|
|
966
1449
|
}
|
|
@@ -969,7 +1452,7 @@ var V = {
|
|
|
969
1452
|
this._isCreating = !0;
|
|
970
1453
|
}, this._onMeasureCreated = (e) => {
|
|
971
1454
|
this._isCreating = !1, this._resultList.set(e.result.id, e.result);
|
|
972
|
-
}, this.events = e.eventTrigger ?? new
|
|
1455
|
+
}, this.events = e.eventTrigger ?? new H();
|
|
973
1456
|
let t = {
|
|
974
1457
|
coordProvider: e.coordProvider,
|
|
975
1458
|
calibration: e.calibration ?? {
|
|
@@ -979,7 +1462,7 @@ var V = {
|
|
|
979
1462
|
},
|
|
980
1463
|
eventTrigger: this.events
|
|
981
1464
|
};
|
|
982
|
-
this.distanceMeasure = new
|
|
1465
|
+
this.distanceMeasure = new K(t), this.angleMeasure = new q(t), this.areaMeasure = new J(t), this._subTools = /* @__PURE__ */ new Map([
|
|
983
1466
|
["distance", this.distanceMeasure],
|
|
984
1467
|
["angle", this.angleMeasure],
|
|
985
1468
|
["area", this.areaMeasure]
|
|
@@ -1049,9 +1532,9 @@ var V = {
|
|
|
1049
1532
|
for (let e of this._subTools.values()) e.destroy();
|
|
1050
1533
|
this._subTools.clear(), this._resultList.clear(), this._active = !1;
|
|
1051
1534
|
}
|
|
1052
|
-
},
|
|
1535
|
+
}, X = class {
|
|
1053
1536
|
constructor(e) {
|
|
1054
|
-
this._activeTool = null, this._activeMode = "none", this._tools = /* @__PURE__ */ new Map(), this.events = new
|
|
1537
|
+
this._activeTool = null, this._activeMode = "none", this._tools = /* @__PURE__ */ new Map(), this.events = new H(), this.measureTool = new Y({
|
|
1055
1538
|
coordProvider: e.coordProvider,
|
|
1056
1539
|
calibration: e.calibration,
|
|
1057
1540
|
eventTrigger: this.events
|
|
@@ -1099,14 +1582,14 @@ var V = {
|
|
|
1099
1582
|
};
|
|
1100
1583
|
//#endregion
|
|
1101
1584
|
//#region src/components/useViewerManager.ts
|
|
1102
|
-
function
|
|
1103
|
-
let { drawAnnotations: t, currentScale: n, setScale: r, viewerRef: i, adjustLayout:
|
|
1104
|
-
screenToScene:
|
|
1585
|
+
function be(e) {
|
|
1586
|
+
let { drawAnnotations: t, currentScale: n, setScale: r, viewerRef: i, adjustLayout: a, screenToScene: o, toggleTheme: s } = e, c = new X({ coordProvider: {
|
|
1587
|
+
screenToScene: o,
|
|
1105
1588
|
sceneToScreen: (e) => ({
|
|
1106
1589
|
x: 0,
|
|
1107
1590
|
y: 0
|
|
1108
1591
|
})
|
|
1109
|
-
} }),
|
|
1592
|
+
} }), u = _([]), d = _(null), f = () => {
|
|
1110
1593
|
let e = c.measureTool.getResults().map((e) => ({
|
|
1111
1594
|
id: e.id,
|
|
1112
1595
|
kind: "measure",
|
|
@@ -1121,19 +1604,19 @@ function ee(e) {
|
|
|
1121
1604
|
strokeWidth: 2,
|
|
1122
1605
|
createdAt: e.createdAt
|
|
1123
1606
|
}));
|
|
1124
|
-
|
|
1607
|
+
u.value = e, t();
|
|
1125
1608
|
};
|
|
1126
1609
|
c.events.on("measure_created", (e) => {
|
|
1127
1610
|
f();
|
|
1128
1611
|
}), c.events.on("measure_cancel", () => {
|
|
1129
1612
|
t();
|
|
1130
1613
|
});
|
|
1131
|
-
let p =
|
|
1614
|
+
let p = _("none");
|
|
1132
1615
|
return {
|
|
1133
1616
|
toolManager: c,
|
|
1134
1617
|
mode: p,
|
|
1135
|
-
annotations:
|
|
1136
|
-
selectedAnnotationId:
|
|
1618
|
+
annotations: u,
|
|
1619
|
+
selectedAnnotationId: d,
|
|
1137
1620
|
setMode: (e) => {
|
|
1138
1621
|
let n = {
|
|
1139
1622
|
measure: "measure",
|
|
@@ -1146,23 +1629,29 @@ function ee(e) {
|
|
|
1146
1629
|
c.measureTool.setSubType(e);
|
|
1147
1630
|
},
|
|
1148
1631
|
clearInteraction: () => {
|
|
1149
|
-
c.interrupt(), c.measureTool.clearResults(),
|
|
1632
|
+
c.interrupt(), c.measureTool.clearResults(), u.value = [], d.value = null, t();
|
|
1150
1633
|
},
|
|
1151
1634
|
deleteSelectedAnnotation: () => {
|
|
1152
|
-
|
|
1635
|
+
d.value && (c.measureTool.removeResult(d.value), d.value = null, f());
|
|
1153
1636
|
},
|
|
1154
1637
|
selectAnnotation: (e) => {
|
|
1155
|
-
|
|
1638
|
+
d.value = e, t();
|
|
1156
1639
|
},
|
|
1157
1640
|
registerManager: () => {
|
|
1158
1641
|
let e = {
|
|
1159
1642
|
setScale: async (e) => {
|
|
1160
|
-
await r(e), await
|
|
1643
|
+
await r(e), await l(), a(!1);
|
|
1161
1644
|
},
|
|
1162
1645
|
getScale: () => n.value,
|
|
1163
|
-
getContainerEl: () => i.value
|
|
1164
|
-
|
|
1165
|
-
|
|
1646
|
+
getContainerEl: () => i.value,
|
|
1647
|
+
resetPosition: () => {
|
|
1648
|
+
a(!0);
|
|
1649
|
+
},
|
|
1650
|
+
toggleTheme: () => {
|
|
1651
|
+
s();
|
|
1652
|
+
}
|
|
1653
|
+
}, o = new z();
|
|
1654
|
+
o.registerWithToolManager(c, t, e), window.pdfViewer = o;
|
|
1166
1655
|
},
|
|
1167
1656
|
unregisterManager: () => {
|
|
1168
1657
|
window.pdfViewer?.unregister(), window.pdfViewer = null, c.destroy();
|
|
@@ -1170,12 +1659,91 @@ function ee(e) {
|
|
|
1170
1659
|
};
|
|
1171
1660
|
}
|
|
1172
1661
|
//#endregion
|
|
1173
|
-
//#region src/components/
|
|
1174
|
-
var
|
|
1662
|
+
//#region src/components/MobileConsole.vue?vue&type=script&setup=true&lang.ts
|
|
1663
|
+
var xe = { class: "mobile-console__title" }, Se = { class: "mobile-console__count" }, Ce = { class: "mobile-console__actions" }, Z = { class: "mobile-console__toggle" }, we = { class: "mobile-console__level" }, Q = { class: "mobile-console__msg" }, Te = {
|
|
1664
|
+
key: 0,
|
|
1665
|
+
class: "mobile-console__empty"
|
|
1666
|
+
}, Ee = /*@__PURE__*/ c({
|
|
1667
|
+
__name: "MobileConsole",
|
|
1668
|
+
props: {
|
|
1669
|
+
visible: {
|
|
1670
|
+
type: Boolean,
|
|
1671
|
+
default: !1
|
|
1672
|
+
},
|
|
1673
|
+
maxLogs: { default: 200 }
|
|
1674
|
+
},
|
|
1675
|
+
setup(e) {
|
|
1676
|
+
let n = e, s = h([]), c = h(!1), d = h(null), _ = console.log.bind(console), y = (e, t) => {
|
|
1677
|
+
if (!n.visible) return;
|
|
1678
|
+
let r = t.map((e) => {
|
|
1679
|
+
if (typeof e == "string") return e;
|
|
1680
|
+
try {
|
|
1681
|
+
return JSON.stringify(e);
|
|
1682
|
+
} catch {
|
|
1683
|
+
return String(e);
|
|
1684
|
+
}
|
|
1685
|
+
}).join(" ");
|
|
1686
|
+
s.value.push({
|
|
1687
|
+
level: e,
|
|
1688
|
+
message: r
|
|
1689
|
+
}), s.value.length > n.maxLogs && s.value.splice(0, s.value.length - n.maxLogs);
|
|
1690
|
+
};
|
|
1691
|
+
x(() => s.value.length, async () => {
|
|
1692
|
+
await l(), d.value && !c.value && (d.value.scrollTop = d.value.scrollHeight);
|
|
1693
|
+
});
|
|
1694
|
+
let w = () => {
|
|
1695
|
+
s.value = [];
|
|
1696
|
+
}, ee = async () => {
|
|
1697
|
+
let e = s.value.map((e) => `[${e.level.toUpperCase()}] ${e.message}`).join("\n");
|
|
1698
|
+
if (e) try {
|
|
1699
|
+
await navigator.clipboard.writeText(e);
|
|
1700
|
+
} catch {
|
|
1701
|
+
let t = document.createElement("textarea");
|
|
1702
|
+
t.value = e, t.style.position = "fixed", t.style.left = "-9999px", document.body.appendChild(t), t.select(), document.execCommand("copy"), document.body.removeChild(t);
|
|
1703
|
+
}
|
|
1704
|
+
}, T = () => {
|
|
1705
|
+
c.value = !c.value, c.value || l(() => {
|
|
1706
|
+
d.value && (d.value.scrollTop = d.value.scrollHeight);
|
|
1707
|
+
});
|
|
1708
|
+
};
|
|
1709
|
+
return p(() => {
|
|
1710
|
+
n.visible && (console.log = (...e) => {
|
|
1711
|
+
y("log", e), _(...e);
|
|
1712
|
+
});
|
|
1713
|
+
}), f(() => {
|
|
1714
|
+
console.log = _;
|
|
1715
|
+
}), (n, l) => e.visible ? (m(), i("div", {
|
|
1716
|
+
key: 0,
|
|
1717
|
+
class: u(["mobile-console", { collapsed: c.value }])
|
|
1718
|
+
}, [a("div", {
|
|
1719
|
+
class: "mobile-console__header",
|
|
1720
|
+
onClick: T
|
|
1721
|
+
}, [a("span", xe, [l[0] ||= o(" 📟 Console ", -1), a("span", Se, v(s.value.length), 1)]), a("span", Ce, [
|
|
1722
|
+
a("button", {
|
|
1723
|
+
class: "mobile-console__btn",
|
|
1724
|
+
title: "清空",
|
|
1725
|
+
onClick: C(w, ["stop"])
|
|
1726
|
+
}, "🗑"),
|
|
1727
|
+
a("button", {
|
|
1728
|
+
class: "mobile-console__btn",
|
|
1729
|
+
title: "复制全部",
|
|
1730
|
+
onClick: C(ee, ["stop"])
|
|
1731
|
+
}, "📋"),
|
|
1732
|
+
a("span", Z, v(c.value ? "▲" : "▼"), 1)
|
|
1733
|
+
])]), S(a("div", {
|
|
1734
|
+
ref_key: "logListRef",
|
|
1735
|
+
ref: d,
|
|
1736
|
+
class: "mobile-console__list"
|
|
1737
|
+
}, [(m(!0), i(t, null, g(s.value, (e, t) => (m(), i("div", {
|
|
1738
|
+
key: t,
|
|
1739
|
+
class: u(["mobile-console__entry", "mobile-console__entry--" + e.level])
|
|
1740
|
+
}, [a("span", we, v(e.level.toUpperCase()), 1), a("span", Q, v(e.message), 1)], 2))), 128)), s.value.length === 0 ? (m(), i("div", Te, "暂无日志")) : r("", !0)], 512), [[b, !c.value]])], 2)) : r("", !0);
|
|
1741
|
+
}
|
|
1742
|
+
}), $ = (e, t) => {
|
|
1175
1743
|
let n = e.__vccOpts || e;
|
|
1176
1744
|
for (let [e, r] of t) n[e] = r;
|
|
1177
1745
|
return n;
|
|
1178
|
-
})(/* @__PURE__ */
|
|
1746
|
+
}, De = /*#__PURE__*/ $(Ee, [["__scopeId", "data-v-ef8b578a"]]), Oe = /*#__PURE__*/ $(/* @__PURE__ */ c({
|
|
1179
1747
|
__name: "PdfViewer",
|
|
1180
1748
|
props: {
|
|
1181
1749
|
modelValue: { default: null },
|
|
@@ -1187,122 +1755,159 @@ var J = /*#__PURE__*/ ((e, t) => {
|
|
|
1187
1755
|
type: Boolean,
|
|
1188
1756
|
default: !1
|
|
1189
1757
|
},
|
|
1190
|
-
zoomSpeed: { default: 1 }
|
|
1758
|
+
zoomSpeed: { default: 1 },
|
|
1759
|
+
invertDarkContent: {
|
|
1760
|
+
type: Boolean,
|
|
1761
|
+
default: !0
|
|
1762
|
+
},
|
|
1763
|
+
invertMode: { default: "unblend" },
|
|
1764
|
+
invertThreshold: { default: 24 },
|
|
1765
|
+
maxZoom: { default: 128 },
|
|
1766
|
+
showConsole: {
|
|
1767
|
+
type: Boolean,
|
|
1768
|
+
default: !1
|
|
1769
|
+
}
|
|
1191
1770
|
},
|
|
1192
1771
|
emits: [
|
|
1193
1772
|
"loaded",
|
|
1194
1773
|
"error",
|
|
1195
1774
|
"annotation-added"
|
|
1196
1775
|
],
|
|
1197
|
-
setup(e, { expose: t, emit:
|
|
1198
|
-
let
|
|
1776
|
+
setup(e, { expose: t, emit: r }) {
|
|
1777
|
+
let o = e, c = r, u = h(null), g = h(null), _ = h(null), v = h(null), b = h(o.theme), S = n(() => b.value === "dark" ? "#000000" : "rgb(255,255,255)"), C = n(() => b.value === "dark" && o.invertDarkContent !== !1), w = () => {
|
|
1778
|
+
b.value = b.value === "light" ? "dark" : "light";
|
|
1779
|
+
}, { containerRef: ee, renderer: T, loadFile: E, doc: te, pageCount: ne, currentPageNum: re, error: ie, currentScale: D, setScale: O, setBackgroundColor: ae, setInvertColors: oe, setInvertMode: se, setMaxZoom: ce, reset: k, resetView: le, attach: A, detach: j, events: M } = pe({
|
|
1199
1780
|
autoLoad: !1,
|
|
1200
|
-
scale:
|
|
1201
|
-
backgroundColor:
|
|
1202
|
-
|
|
1781
|
+
scale: o.scale,
|
|
1782
|
+
backgroundColor: S.value,
|
|
1783
|
+
invertColors: C.value,
|
|
1784
|
+
invertMode: o.invertMode,
|
|
1785
|
+
invertThreshold: o.invertThreshold,
|
|
1786
|
+
maxZoom: o.maxZoom,
|
|
1787
|
+
onPresented: () => ue()
|
|
1788
|
+
});
|
|
1789
|
+
function ue() {
|
|
1790
|
+
I(), F();
|
|
1791
|
+
}
|
|
1792
|
+
let N = he(), P = h(null), de = h(!1), { drawAnnotations: F, syncCanvasSize: I, getCanvasPoint: L, hitTestAnnotation: R } = ge({
|
|
1203
1793
|
annotationCanvas: v,
|
|
1204
1794
|
rootRef: g,
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1795
|
+
pdfLayerRef: g,
|
|
1796
|
+
interaction: N,
|
|
1797
|
+
previewPoint: P
|
|
1798
|
+
}), { containerStyle: z, adjustLayout: B, handleWheel: V, handlePointerDown: fe, handlePointerMove: H, handlePointerUp: U, handlePointerCancel: W, isMouseDragging: me, cleanupMouseDrag: ye } = ve({
|
|
1799
|
+
viewerRef: u,
|
|
1800
|
+
renderer: T,
|
|
1801
|
+
zoomSpeed: o.zoomSpeed ?? 1,
|
|
1802
|
+
theme: b
|
|
1803
|
+
}), G = (e) => {
|
|
1804
|
+
N.mode === "none" && fe(e);
|
|
1805
|
+
}, K = n(() => ({
|
|
1806
|
+
...z.value,
|
|
1807
|
+
cursor: me.value ? "grabbing" : "grab"
|
|
1808
|
+
})), { setMode: q, clearInteraction: J, deleteSelectedAnnotation: Y, selectAnnotation: X, registerManager: xe, unregisterManager: Se } = be({
|
|
1809
|
+
drawAnnotations: F,
|
|
1810
|
+
currentScale: D,
|
|
1811
|
+
setScale: O,
|
|
1812
|
+
viewerRef: u,
|
|
1813
|
+
adjustLayout: B,
|
|
1223
1814
|
screenToScene: (e) => {
|
|
1224
|
-
let t =
|
|
1815
|
+
let t = L(e);
|
|
1225
1816
|
return {
|
|
1226
1817
|
x: t.x,
|
|
1227
1818
|
y: t.y
|
|
1228
1819
|
};
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1820
|
+
},
|
|
1821
|
+
toggleTheme: w
|
|
1822
|
+
}), { handlePointerDown: Ce, handlePointerMove: Z, handlePointerUp: we, handleKeydown: Q } = _e({
|
|
1231
1823
|
annotationCanvas: v,
|
|
1232
|
-
interaction:
|
|
1233
|
-
previewPoint:
|
|
1234
|
-
isRectangleDragging:
|
|
1235
|
-
getCanvasPoint:
|
|
1236
|
-
hitTestAnnotation:
|
|
1237
|
-
drawAnnotations:
|
|
1824
|
+
interaction: N,
|
|
1825
|
+
previewPoint: P,
|
|
1826
|
+
isRectangleDragging: de,
|
|
1827
|
+
getCanvasPoint: L,
|
|
1828
|
+
hitTestAnnotation: R,
|
|
1829
|
+
drawAnnotations: F,
|
|
1238
1830
|
deleteSelectedAnnotation: Y,
|
|
1239
|
-
emit:
|
|
1240
|
-
})
|
|
1241
|
-
|
|
1242
|
-
|
|
1831
|
+
emit: c
|
|
1832
|
+
}), Te = async (e) => {
|
|
1833
|
+
await E(e);
|
|
1834
|
+
}, Ee = () => {
|
|
1835
|
+
k();
|
|
1836
|
+
};
|
|
1837
|
+
M.on("loaded", (e) => {
|
|
1838
|
+
c("loaded", {
|
|
1243
1839
|
pageCount: e.pageCount,
|
|
1244
1840
|
currentPage: e.currentPage
|
|
1245
1841
|
});
|
|
1246
|
-
}),
|
|
1247
|
-
|
|
1248
|
-
}),
|
|
1249
|
-
|
|
1250
|
-
}),
|
|
1251
|
-
e && e !==
|
|
1252
|
-
}),
|
|
1253
|
-
e && (await
|
|
1842
|
+
}), M.on("error_occurred", (e) => {
|
|
1843
|
+
c("error", { message: e.message });
|
|
1844
|
+
}), x(() => N.annotations.length, () => {
|
|
1845
|
+
F();
|
|
1846
|
+
}), x(() => o.scale, async (e) => {
|
|
1847
|
+
e && e !== D.value && (await O(e), await l(), B());
|
|
1848
|
+
}), x(() => o.modelValue, async (e) => {
|
|
1849
|
+
e && (await E(e), await l(), B(!0));
|
|
1254
1850
|
}, {
|
|
1255
1851
|
immediate: !0,
|
|
1256
1852
|
flush: "post"
|
|
1257
|
-
}),
|
|
1258
|
-
|
|
1259
|
-
}),
|
|
1260
|
-
|
|
1853
|
+
}), x([b, C], async () => {
|
|
1854
|
+
oe(C.value), await ae(S.value);
|
|
1855
|
+
}), x([() => o.invertMode, () => o.invertThreshold], () => {
|
|
1856
|
+
se(o.invertMode ?? "unblend", o.invertThreshold);
|
|
1857
|
+
}), x(() => o.maxZoom, (e) => {
|
|
1858
|
+
e && e > 0 && ce(e);
|
|
1859
|
+
});
|
|
1860
|
+
let $ = null;
|
|
1861
|
+
return p(() => {
|
|
1862
|
+
A({
|
|
1863
|
+
canvas: _.value,
|
|
1864
|
+
stage: u.value,
|
|
1865
|
+
wrap: g.value
|
|
1866
|
+
}), I(), F(), window.addEventListener("keydown", Q), xe(), $ = new ResizeObserver(() => {
|
|
1867
|
+
T.value?.refreshStageBox(), T.value?.requestRender();
|
|
1868
|
+
}), u.value && $.observe(u.value);
|
|
1869
|
+
}), f(() => {
|
|
1870
|
+
$?.disconnect(), $ = null, window.removeEventListener("keydown", Q), ye(), Se(), j();
|
|
1261
1871
|
}), t({
|
|
1262
|
-
load:
|
|
1263
|
-
|
|
1264
|
-
},
|
|
1265
|
-
clear: () => {
|
|
1266
|
-
D();
|
|
1267
|
-
},
|
|
1872
|
+
load: Te,
|
|
1873
|
+
clear: Ee,
|
|
1268
1874
|
setMode: q,
|
|
1269
1875
|
clearInteraction: J,
|
|
1270
1876
|
deleteSelectedAnnotation: Y,
|
|
1271
|
-
selectAnnotation:
|
|
1272
|
-
|
|
1877
|
+
selectAnnotation: X,
|
|
1878
|
+
resetView: le,
|
|
1879
|
+
zoomIn: () => O(T.value ? T.value.zoom * 1.25 : D.value),
|
|
1880
|
+
zoomOut: () => O(T.value ? T.value.zoom / 1.25 : D.value)
|
|
1881
|
+
}), (t, n) => (m(), i("div", {
|
|
1273
1882
|
ref_key: "viewerRef",
|
|
1274
|
-
ref:
|
|
1883
|
+
ref: u,
|
|
1275
1884
|
class: "pdf-core-viewer",
|
|
1276
|
-
style:
|
|
1277
|
-
onWheel:
|
|
1278
|
-
|
|
1885
|
+
style: d(K.value),
|
|
1886
|
+
onWheel: n[3] ||= (...e) => y(V) && y(V)(...e),
|
|
1887
|
+
onPointerdown: G,
|
|
1888
|
+
onPointermove: n[4] ||= (...e) => y(H) && y(H)(...e),
|
|
1889
|
+
onPointerup: n[5] ||= (...e) => y(U) && y(U)(...e),
|
|
1890
|
+
onPointercancel: n[6] ||= (...e) => y(W) && y(W)(...e)
|
|
1891
|
+
}, [a("div", {
|
|
1279
1892
|
ref_key: "rootRef",
|
|
1280
1893
|
ref: g,
|
|
1281
|
-
class: "pdf-core-
|
|
1282
|
-
}, [
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
class: "pdf-core-overlay",
|
|
1295
|
-
onPointerdown: t[0] ||= (...e) => f(X) && f(X)(...e),
|
|
1296
|
-
onPointerup: t[1] ||= (...e) => f(Q) && f(Q)(...e),
|
|
1297
|
-
onPointermove: t[2] ||= (...e) => f(Z) && f(Z)(...e)
|
|
1298
|
-
}, null, 32)
|
|
1299
|
-
], 512)], 36));
|
|
1300
|
-
}
|
|
1301
|
-
}), [["__scopeId", "data-v-0e4941dc"]]);
|
|
1894
|
+
class: "pdf-core-content"
|
|
1895
|
+
}, [a("canvas", {
|
|
1896
|
+
ref_key: "pageCanvas",
|
|
1897
|
+
ref: _,
|
|
1898
|
+
class: "pdf-core-page-canvas"
|
|
1899
|
+
}, null, 512), a("div", {
|
|
1900
|
+
class: "pdf-core-overlay",
|
|
1901
|
+
onPointerdown: n[0] ||= (...e) => y(Ce) && y(Ce)(...e),
|
|
1902
|
+
onPointerup: n[1] ||= (...e) => y(we) && y(we)(...e),
|
|
1903
|
+
onPointermove: n[2] ||= (...e) => y(Z) && y(Z)(...e)
|
|
1904
|
+
}, null, 32)], 512), s(De, { visible: e.showConsole }, null, 8, ["visible"])], 36));
|
|
1905
|
+
}
|
|
1906
|
+
}), [["__scopeId", "data-v-dc25679e"]]);
|
|
1302
1907
|
//#endregion
|
|
1303
1908
|
//#region src/vue/plugin.ts
|
|
1304
|
-
function
|
|
1305
|
-
e.component("PdfViewer",
|
|
1909
|
+
function ke(e) {
|
|
1910
|
+
e.component("PdfViewer", Oe);
|
|
1306
1911
|
}
|
|
1307
1912
|
//#endregion
|
|
1308
|
-
export {
|
|
1913
|
+
export { q as AngleMeasure, J as AreaMeasure, O as ColorInverter, I as CoordTransformer, ne as DEFAULT_ACHROMATIC_THRESHOLD, ye as DEFAULT_TOOL_STATE, K as DistanceMeasure, H as EventTrigger, E as INVERT_FILTER_ALL, te as INVERT_FILTER_HUE, G as MeasureBase, Y as MeasureTool, A as PageCanvasRenderer, Oe as PdfViewer, z as PdfViewerCore, j as TileLRUCache, X as ToolManager, L as ZOOM_LEVELS, B as createMeasureAnnotation, V as createShapeAnnotation, R as getNextZoom, ke as installPdfCore, T as loadPDF, F as renderPageTiledVirtual, w as setPDFWorkerSrc, U as useAnnotations, ee as useDefaultWorker, me as useInteraction, W as useMeasurement, pe as usePdfCore };
|