@twintag/twintag-core 0.2.286 → 0.2.287
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/cjs/@worker-helper-fa4712a7.js +240 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/stencil-web-components.cjs.js +1 -1
- package/dist/cjs/twintag-offline-support.cjs.entry.js +1 -1
- package/dist/cjs/twintag-pdf-viewer.cjs.entry.js +2 -193
- package/dist/cjs/twintag-qr-scanner.cjs.entry.js +182 -320
- package/dist/collection/components/twintag-scanner/twintag-qr-scanner.js +136 -74
- package/dist/collection/scanner-store.js +4 -0
- package/dist/collection/utils/create-local-store.js +43 -0
- package/dist/collection/utils/is-empty.js +3 -0
- package/dist/collection/version.js +1 -1
- package/dist/components/index3.js +237 -0
- package/dist/components/twintag-offline-support.js +1 -1
- package/dist/components/twintag-pdf-viewer2.js +2 -193
- package/dist/components/twintag-qr-scanner.js +184 -324
- package/dist/esm/@worker-helper-e45428b7.js +237 -0
- package/dist/esm/{index-174285a2.js → index-e1a48b05.js} +1 -1
- package/dist/esm/loader.js +2 -2
- package/dist/esm/stencil-web-components.js +2 -2
- package/dist/esm/twintag-auth-callback.entry.js +1 -1
- package/dist/esm/twintag-auth-logout.entry.js +1 -1
- package/dist/esm/twintag-media.entry.js +1 -1
- package/dist/esm/twintag-ocr-scanner.entry.js +1 -1
- package/dist/esm/twintag-offline-actions.entry.js +1 -1
- package/dist/esm/twintag-offline-state.entry.js +1 -1
- package/dist/esm/twintag-offline-support.entry.js +2 -2
- package/dist/esm/twintag-pdf-viewer.entry.js +2 -193
- package/dist/esm/twintag-preview.entry.js +1 -1
- package/dist/esm/twintag-qr-scanner.entry.js +183 -321
- package/dist/esm/twintag-share.entry.js +1 -1
- package/dist/esm/twintag-spinner.entry.js +1 -1
- package/dist/stencil-web-components/p-1807206d.entry.js +1 -0
- package/dist/stencil-web-components/{p-67e2625e.entry.js → p-1e296694.entry.js} +1 -1
- package/dist/stencil-web-components/{p-4a001573.entry.js → p-5bd6d110.entry.js} +1 -1
- package/dist/stencil-web-components/{p-84e1cfed.entry.js → p-6cd7075c.entry.js} +1 -1
- package/dist/stencil-web-components/p-7943b86a.entry.js +1 -0
- package/dist/stencil-web-components/p-7b959006.js +1 -0
- package/dist/stencil-web-components/p-8806444b.entry.js +1 -0
- package/dist/stencil-web-components/{p-37b2160f.entry.js → p-9f7518ab.entry.js} +1 -1
- package/dist/stencil-web-components/p-a53a2c70.entry.js +1 -0
- package/dist/stencil-web-components/{p-feeba1cd.entry.js → p-a6f626bb.entry.js} +1 -1
- package/dist/stencil-web-components/{p-fb43176d.entry.js → p-d1230452.entry.js} +1 -1
- package/dist/stencil-web-components/{p-dff77416.entry.js → p-d428ed6b.entry.js} +1 -1
- package/dist/stencil-web-components/{p-cb286d41.js → p-d5d0e2ee.js} +1 -1
- package/dist/stencil-web-components/{p-0be73e86.entry.js → p-f58c7a83.entry.js} +1 -1
- package/dist/stencil-web-components/stencil-web-components.esm.js +1 -1
- package/dist/types/components/twintag-scanner/twintag-qr-scanner.d.ts +5 -5
- package/dist/types/drone/src/libs/stencil-web-components/.stencil/libs/twintag-sdk/src/lib/version.d.ts +1 -1
- package/dist/types/scanner-store.d.ts +3 -0
- package/dist/types/utils/create-local-store.d.ts +1 -0
- package/dist/types/utils/is-empty.d.ts +1 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/twintag-sdk/src/lib/version.js +1 -1
- package/dist/cjs/@worker-helper-6877046e.js +0 -48
- package/dist/components/@worker-helper.js +0 -46
- package/dist/esm/@worker-helper-f3e880f2.js +0 -46
- package/dist/stencil-web-components/p-01d4afb8.entry.js +0 -1
- package/dist/stencil-web-components/p-18087e0a.entry.js +0 -1
- package/dist/stencil-web-components/p-5e046324.js +0 -1
- package/dist/stencil-web-components/p-821ba724.entry.js +0 -1
- package/dist/stencil-web-components/p-a2df3118.entry.js +0 -1
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const index = require('./index-2c25b2e9.js');
|
|
4
|
+
|
|
5
|
+
const appendToMap = (map, propName, value) => {
|
|
6
|
+
const items = map.get(propName);
|
|
7
|
+
if (!items) {
|
|
8
|
+
map.set(propName, [value]);
|
|
9
|
+
}
|
|
10
|
+
else if (!items.includes(value)) {
|
|
11
|
+
items.push(value);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const debounce = (fn, ms) => {
|
|
15
|
+
let timeoutId;
|
|
16
|
+
return (...args) => {
|
|
17
|
+
if (timeoutId) {
|
|
18
|
+
clearTimeout(timeoutId);
|
|
19
|
+
}
|
|
20
|
+
timeoutId = setTimeout(() => {
|
|
21
|
+
timeoutId = 0;
|
|
22
|
+
fn(...args);
|
|
23
|
+
}, ms);
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Check if a possible element isConnected.
|
|
29
|
+
* The property might not be there, so we check for it.
|
|
30
|
+
*
|
|
31
|
+
* We want it to return true if isConnected is not a property,
|
|
32
|
+
* otherwise we would remove these elements and would not update.
|
|
33
|
+
*
|
|
34
|
+
* Better leak in Edge than to be useless.
|
|
35
|
+
*/
|
|
36
|
+
const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
|
|
37
|
+
const cleanupElements = debounce((map) => {
|
|
38
|
+
for (let key of map.keys()) {
|
|
39
|
+
map.set(key, map.get(key).filter(isConnected));
|
|
40
|
+
}
|
|
41
|
+
}, 2000);
|
|
42
|
+
const stencilSubscription = () => {
|
|
43
|
+
if (typeof index.getRenderingRef !== 'function') {
|
|
44
|
+
// If we are not in a stencil project, we do nothing.
|
|
45
|
+
// This function is not really exported by @stencil/core.
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
const elmsToUpdate = new Map();
|
|
49
|
+
return {
|
|
50
|
+
dispose: () => elmsToUpdate.clear(),
|
|
51
|
+
get: (propName) => {
|
|
52
|
+
const elm = index.getRenderingRef();
|
|
53
|
+
if (elm) {
|
|
54
|
+
appendToMap(elmsToUpdate, propName, elm);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
set: (propName) => {
|
|
58
|
+
const elements = elmsToUpdate.get(propName);
|
|
59
|
+
if (elements) {
|
|
60
|
+
elmsToUpdate.set(propName, elements.filter(index.forceUpdate));
|
|
61
|
+
}
|
|
62
|
+
cleanupElements(elmsToUpdate);
|
|
63
|
+
},
|
|
64
|
+
reset: () => {
|
|
65
|
+
elmsToUpdate.forEach((elms) => elms.forEach(index.forceUpdate));
|
|
66
|
+
cleanupElements(elmsToUpdate);
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const unwrap = (val) => (typeof val === 'function' ? val() : val);
|
|
72
|
+
const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
|
|
73
|
+
const unwrappedState = unwrap(defaultState);
|
|
74
|
+
let states = new Map(Object.entries(unwrappedState !== null && unwrappedState !== void 0 ? unwrappedState : {}));
|
|
75
|
+
const handlers = {
|
|
76
|
+
dispose: [],
|
|
77
|
+
get: [],
|
|
78
|
+
set: [],
|
|
79
|
+
reset: [],
|
|
80
|
+
};
|
|
81
|
+
const reset = () => {
|
|
82
|
+
var _a;
|
|
83
|
+
// When resetting the state, the default state may be a function - unwrap it to invoke it.
|
|
84
|
+
// otherwise, the state won't be properly reset
|
|
85
|
+
states = new Map(Object.entries((_a = unwrap(defaultState)) !== null && _a !== void 0 ? _a : {}));
|
|
86
|
+
handlers.reset.forEach((cb) => cb());
|
|
87
|
+
};
|
|
88
|
+
const dispose = () => {
|
|
89
|
+
// Call first dispose as resetting the state would
|
|
90
|
+
// cause less updates ;)
|
|
91
|
+
handlers.dispose.forEach((cb) => cb());
|
|
92
|
+
reset();
|
|
93
|
+
};
|
|
94
|
+
const get = (propName) => {
|
|
95
|
+
handlers.get.forEach((cb) => cb(propName));
|
|
96
|
+
return states.get(propName);
|
|
97
|
+
};
|
|
98
|
+
const set = (propName, value) => {
|
|
99
|
+
const oldValue = states.get(propName);
|
|
100
|
+
if (shouldUpdate(value, oldValue, propName)) {
|
|
101
|
+
states.set(propName, value);
|
|
102
|
+
handlers.set.forEach((cb) => cb(propName, value, oldValue));
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const state = (typeof Proxy === 'undefined'
|
|
106
|
+
? {}
|
|
107
|
+
: new Proxy(unwrappedState, {
|
|
108
|
+
get(_, propName) {
|
|
109
|
+
return get(propName);
|
|
110
|
+
},
|
|
111
|
+
ownKeys(_) {
|
|
112
|
+
return Array.from(states.keys());
|
|
113
|
+
},
|
|
114
|
+
getOwnPropertyDescriptor() {
|
|
115
|
+
return {
|
|
116
|
+
enumerable: true,
|
|
117
|
+
configurable: true,
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
has(_, propName) {
|
|
121
|
+
return states.has(propName);
|
|
122
|
+
},
|
|
123
|
+
set(_, propName, value) {
|
|
124
|
+
set(propName, value);
|
|
125
|
+
return true;
|
|
126
|
+
},
|
|
127
|
+
}));
|
|
128
|
+
const on = (eventName, callback) => {
|
|
129
|
+
handlers[eventName].push(callback);
|
|
130
|
+
return () => {
|
|
131
|
+
removeFromArray(handlers[eventName], callback);
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
const onChange = (propName, cb) => {
|
|
135
|
+
const unSet = on('set', (key, newValue) => {
|
|
136
|
+
if (key === propName) {
|
|
137
|
+
cb(newValue);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
// We need to unwrap the defaultState because it might be a function.
|
|
141
|
+
// Otherwise we might not be sending the right reset value.
|
|
142
|
+
const unReset = on('reset', () => cb(unwrap(defaultState)[propName]));
|
|
143
|
+
return () => {
|
|
144
|
+
unSet();
|
|
145
|
+
unReset();
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
const use = (...subscriptions) => {
|
|
149
|
+
const unsubs = subscriptions.reduce((unsubs, subscription) => {
|
|
150
|
+
if (subscription.set) {
|
|
151
|
+
unsubs.push(on('set', subscription.set));
|
|
152
|
+
}
|
|
153
|
+
if (subscription.get) {
|
|
154
|
+
unsubs.push(on('get', subscription.get));
|
|
155
|
+
}
|
|
156
|
+
if (subscription.reset) {
|
|
157
|
+
unsubs.push(on('reset', subscription.reset));
|
|
158
|
+
}
|
|
159
|
+
if (subscription.dispose) {
|
|
160
|
+
unsubs.push(on('dispose', subscription.dispose));
|
|
161
|
+
}
|
|
162
|
+
return unsubs;
|
|
163
|
+
}, []);
|
|
164
|
+
return () => unsubs.forEach((unsub) => unsub());
|
|
165
|
+
};
|
|
166
|
+
const forceUpdate = (key) => {
|
|
167
|
+
const oldValue = states.get(key);
|
|
168
|
+
handlers.set.forEach((cb) => cb(key, oldValue, oldValue));
|
|
169
|
+
};
|
|
170
|
+
return {
|
|
171
|
+
state,
|
|
172
|
+
get,
|
|
173
|
+
set,
|
|
174
|
+
on,
|
|
175
|
+
onChange,
|
|
176
|
+
use,
|
|
177
|
+
dispose,
|
|
178
|
+
reset,
|
|
179
|
+
forceUpdate,
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
const removeFromArray = (array, item) => {
|
|
183
|
+
const index = array.indexOf(item);
|
|
184
|
+
if (index >= 0) {
|
|
185
|
+
array[index] = array[array.length - 1];
|
|
186
|
+
array.length--;
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const createStore = (defaultState, shouldUpdate) => {
|
|
191
|
+
const map = createObservableMap(defaultState, shouldUpdate);
|
|
192
|
+
map.use(stencilSubscription());
|
|
193
|
+
return map;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const pending = new Map();
|
|
197
|
+
const callbacks = new Map();
|
|
198
|
+
|
|
199
|
+
const createWorker = (workerPath, workerName, workerMsgId) => {
|
|
200
|
+
const worker = new Worker(workerPath, {name:workerName});
|
|
201
|
+
|
|
202
|
+
worker.addEventListener('message', ({data}) => {
|
|
203
|
+
if (data) {
|
|
204
|
+
const workerMsg = data[0];
|
|
205
|
+
const id = data[1];
|
|
206
|
+
const value = data[2];
|
|
207
|
+
|
|
208
|
+
if (workerMsg === workerMsgId) {
|
|
209
|
+
const err = data[3];
|
|
210
|
+
const [resolve, reject, callbackIds] = pending.get(id);
|
|
211
|
+
pending.delete(id);
|
|
212
|
+
|
|
213
|
+
if (err) {
|
|
214
|
+
const errObj = (err.isError)
|
|
215
|
+
? Object.assign(new Error(err.value.message), err.value)
|
|
216
|
+
: err.value;
|
|
217
|
+
|
|
218
|
+
index.consoleError(errObj);
|
|
219
|
+
reject(errObj);
|
|
220
|
+
} else {
|
|
221
|
+
if (callbackIds) {
|
|
222
|
+
callbackIds.forEach(id => callbacks.delete(id));
|
|
223
|
+
}
|
|
224
|
+
resolve(value);
|
|
225
|
+
}
|
|
226
|
+
} else if (workerMsg === workerMsgId + '.cb') {
|
|
227
|
+
try {
|
|
228
|
+
callbacks.get(id)(...value);
|
|
229
|
+
} catch (e) {
|
|
230
|
+
index.consoleError(e);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
return worker;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
exports.createStore = createStore;
|
|
240
|
+
exports.createWorker = createWorker;
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["twintag-preview.cjs",[[1,"twintag-preview",{"item":[1],"initial":[16],"smoothExtinction":[2,"smooth-extinction"],"extension":[1],"showButtons":[4,"show-buttons"],"previewableItem":[32],"type":[32]}]]],["twintag-auth-callback.cjs",[[1,"twintag-auth-callback"]]],["twintag-auth-logout.cjs",[[1,"twintag-auth-logout"]]],["twintag-media.cjs",[[1,"twintag-media",{"first":[1],"middle":[1],"last":[1]}]]],["twintag-ocr-scanner.cjs",[[1,"twintag-ocr-scanner",{"stream":[1040],"mode":[1],"cropX":[2,"crop-x"],"cropY":[2,"crop-y"],"devices":[32]},[[0,"updateZoom","updateZoom"],[2,"recognize","ocrHandler"]]]]],["twintag-offline-actions.cjs",[[1,"twintag-offline-actions",{"enableSingleRetry":[4,"enable-single-retry"],"header":[1],"showTimestamp":[4,"show-timestamp"],"showDescription":[4,"show-description"],"closeText":[1,"close-text"],"retryText":[1,"retry-text"],"noPendingActionsText":[1,"no-pending-actions-text"],"pendingOfflineRequests":[32],"processing":[32]},[[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-state.cjs",[[1,"twintag-offline-state",{"onlineState":[32],"pendingRequests":[32]},[[8,"onlineChanged","onlineChangedHandler"],[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-support.cjs",[[1,"twintag-offline-support",{"autoSync":[4,"auto-sync"],"forceOffline":[4,"force-offline"],"config":[16]}]]],["twintag-qr-scanner.cjs",[[1,"twintag-qr-scanner",{"stream":[1040],"mode":[1],"format":[1],"crop":[514]
|
|
17
|
+
return index.bootstrapLazy([["twintag-preview.cjs",[[1,"twintag-preview",{"item":[1],"initial":[16],"smoothExtinction":[2,"smooth-extinction"],"extension":[1],"showButtons":[4,"show-buttons"],"previewableItem":[32],"type":[32]}]]],["twintag-auth-callback.cjs",[[1,"twintag-auth-callback"]]],["twintag-auth-logout.cjs",[[1,"twintag-auth-logout"]]],["twintag-media.cjs",[[1,"twintag-media",{"first":[1],"middle":[1],"last":[1]}]]],["twintag-ocr-scanner.cjs",[[1,"twintag-ocr-scanner",{"stream":[1040],"mode":[1],"cropX":[2,"crop-x"],"cropY":[2,"crop-y"],"devices":[32]},[[0,"updateZoom","updateZoom"],[2,"recognize","ocrHandler"]]]]],["twintag-offline-actions.cjs",[[1,"twintag-offline-actions",{"enableSingleRetry":[4,"enable-single-retry"],"header":[1],"showTimestamp":[4,"show-timestamp"],"showDescription":[4,"show-description"],"closeText":[1,"close-text"],"retryText":[1,"retry-text"],"noPendingActionsText":[1,"no-pending-actions-text"],"pendingOfflineRequests":[32],"processing":[32]},[[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-state.cjs",[[1,"twintag-offline-state",{"onlineState":[32],"pendingRequests":[32]},[[8,"onlineChanged","onlineChangedHandler"],[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-support.cjs",[[1,"twintag-offline-support",{"autoSync":[4,"auto-sync"],"forceOffline":[4,"force-offline"],"config":[16]}]]],["twintag-qr-scanner.cjs",[[1,"twintag-qr-scanner",{"stream":[1040],"mode":[1],"format":[1],"crop":[514]},[[1,"updateZoom","updateZoom"]]]]],["twintag-share.cjs",[[1,"twintag-share",{"url":[1],"modalTitle":[1,"modal-title"],"modalSubtitle":[1,"modal-subtitle"],"closeBtn":[1,"close-btn"],"copyClipboardBtn":[1,"copy-clipboard-btn"],"open":[1540]},[[0,"keydown","handleKeyDown"]]]]],["twintag-spinner.cjs",[[1,"twintag-spinner",{"color":[513],"duration":[2],"name":[1]}]]],["twintag-pdf-viewer.cjs",[[0,"twintag-pdf-viewer",{"src":[1],"fileName":[1,"file-name"],"file":[32],"fileURL":[32]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -15,5 +15,5 @@ const patchBrowser = () => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
patchBrowser().then(options => {
|
|
18
|
-
return index.bootstrapLazy([["twintag-preview.cjs",[[1,"twintag-preview",{"item":[1],"initial":[16],"smoothExtinction":[2,"smooth-extinction"],"extension":[1],"showButtons":[4,"show-buttons"],"previewableItem":[32],"type":[32]}]]],["twintag-auth-callback.cjs",[[1,"twintag-auth-callback"]]],["twintag-auth-logout.cjs",[[1,"twintag-auth-logout"]]],["twintag-media.cjs",[[1,"twintag-media",{"first":[1],"middle":[1],"last":[1]}]]],["twintag-ocr-scanner.cjs",[[1,"twintag-ocr-scanner",{"stream":[1040],"mode":[1],"cropX":[2,"crop-x"],"cropY":[2,"crop-y"],"devices":[32]},[[0,"updateZoom","updateZoom"],[2,"recognize","ocrHandler"]]]]],["twintag-offline-actions.cjs",[[1,"twintag-offline-actions",{"enableSingleRetry":[4,"enable-single-retry"],"header":[1],"showTimestamp":[4,"show-timestamp"],"showDescription":[4,"show-description"],"closeText":[1,"close-text"],"retryText":[1,"retry-text"],"noPendingActionsText":[1,"no-pending-actions-text"],"pendingOfflineRequests":[32],"processing":[32]},[[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-state.cjs",[[1,"twintag-offline-state",{"onlineState":[32],"pendingRequests":[32]},[[8,"onlineChanged","onlineChangedHandler"],[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-support.cjs",[[1,"twintag-offline-support",{"autoSync":[4,"auto-sync"],"forceOffline":[4,"force-offline"],"config":[16]}]]],["twintag-qr-scanner.cjs",[[1,"twintag-qr-scanner",{"stream":[1040],"mode":[1],"format":[1],"crop":[514]
|
|
18
|
+
return index.bootstrapLazy([["twintag-preview.cjs",[[1,"twintag-preview",{"item":[1],"initial":[16],"smoothExtinction":[2,"smooth-extinction"],"extension":[1],"showButtons":[4,"show-buttons"],"previewableItem":[32],"type":[32]}]]],["twintag-auth-callback.cjs",[[1,"twintag-auth-callback"]]],["twintag-auth-logout.cjs",[[1,"twintag-auth-logout"]]],["twintag-media.cjs",[[1,"twintag-media",{"first":[1],"middle":[1],"last":[1]}]]],["twintag-ocr-scanner.cjs",[[1,"twintag-ocr-scanner",{"stream":[1040],"mode":[1],"cropX":[2,"crop-x"],"cropY":[2,"crop-y"],"devices":[32]},[[0,"updateZoom","updateZoom"],[2,"recognize","ocrHandler"]]]]],["twintag-offline-actions.cjs",[[1,"twintag-offline-actions",{"enableSingleRetry":[4,"enable-single-retry"],"header":[1],"showTimestamp":[4,"show-timestamp"],"showDescription":[4,"show-description"],"closeText":[1,"close-text"],"retryText":[1,"retry-text"],"noPendingActionsText":[1,"no-pending-actions-text"],"pendingOfflineRequests":[32],"processing":[32]},[[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-state.cjs",[[1,"twintag-offline-state",{"onlineState":[32],"pendingRequests":[32]},[[8,"onlineChanged","onlineChangedHandler"],[8,"offlineRequestsChanged","offlineRequestsChangedHandler"]]]]],["twintag-offline-support.cjs",[[1,"twintag-offline-support",{"autoSync":[4,"auto-sync"],"forceOffline":[4,"force-offline"],"config":[16]}]]],["twintag-qr-scanner.cjs",[[1,"twintag-qr-scanner",{"stream":[1040],"mode":[1],"format":[1],"crop":[514]},[[1,"updateZoom","updateZoom"]]]]],["twintag-share.cjs",[[1,"twintag-share",{"url":[1],"modalTitle":[1,"modal-title"],"modalSubtitle":[1,"modal-subtitle"],"closeBtn":[1,"close-btn"],"copyClipboardBtn":[1,"copy-clipboard-btn"],"open":[1540]},[[0,"keydown","handleKeyDown"]]]]],["twintag-spinner.cjs",[[1,"twintag-spinner",{"color":[513],"duration":[2],"name":[1]}]]],["twintag-pdf-viewer.cjs",[[0,"twintag-pdf-viewer",{"src":[1],"fileName":[1,"file-name"],"file":[32],"fileURL":[32]}]]]], options);
|
|
19
19
|
});
|
|
@@ -3,205 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-2c25b2e9.js');
|
|
6
|
-
const _workerHelper = require('./@worker-helper-
|
|
6
|
+
const _workerHelper = require('./@worker-helper-fa4712a7.js');
|
|
7
7
|
|
|
8
8
|
const workerName = 'pdf-viewer.worker';
|
|
9
9
|
const workerMsgId = 'stencil.pdf-viewer.worker';
|
|
10
10
|
const workerPath = /*@__PURE__*/(typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/pdf-viewer.worker-451433c3.js').href : new URL('pdf-viewer.worker-451433c3.js', document.currentScript && document.currentScript.src || document.baseURI).href);
|
|
11
11
|
const worker = /*@__PURE__*/_workerHelper.createWorker(workerPath, workerName, workerMsgId);
|
|
12
12
|
|
|
13
|
-
const
|
|
14
|
-
const items = map.get(propName);
|
|
15
|
-
if (!items) {
|
|
16
|
-
map.set(propName, [value]);
|
|
17
|
-
}
|
|
18
|
-
else if (!items.includes(value)) {
|
|
19
|
-
items.push(value);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
const debounce = (fn, ms) => {
|
|
23
|
-
let timeoutId;
|
|
24
|
-
return (...args) => {
|
|
25
|
-
if (timeoutId) {
|
|
26
|
-
clearTimeout(timeoutId);
|
|
27
|
-
}
|
|
28
|
-
timeoutId = setTimeout(() => {
|
|
29
|
-
timeoutId = 0;
|
|
30
|
-
fn(...args);
|
|
31
|
-
}, ms);
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Check if a possible element isConnected.
|
|
37
|
-
* The property might not be there, so we check for it.
|
|
38
|
-
*
|
|
39
|
-
* We want it to return true if isConnected is not a property,
|
|
40
|
-
* otherwise we would remove these elements and would not update.
|
|
41
|
-
*
|
|
42
|
-
* Better leak in Edge than to be useless.
|
|
43
|
-
*/
|
|
44
|
-
const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
|
|
45
|
-
const cleanupElements = debounce((map) => {
|
|
46
|
-
for (let key of map.keys()) {
|
|
47
|
-
map.set(key, map.get(key).filter(isConnected));
|
|
48
|
-
}
|
|
49
|
-
}, 2000);
|
|
50
|
-
const stencilSubscription = () => {
|
|
51
|
-
if (typeof index.getRenderingRef !== 'function') {
|
|
52
|
-
// If we are not in a stencil project, we do nothing.
|
|
53
|
-
// This function is not really exported by @stencil/core.
|
|
54
|
-
return {};
|
|
55
|
-
}
|
|
56
|
-
const elmsToUpdate = new Map();
|
|
57
|
-
return {
|
|
58
|
-
dispose: () => elmsToUpdate.clear(),
|
|
59
|
-
get: (propName) => {
|
|
60
|
-
const elm = index.getRenderingRef();
|
|
61
|
-
if (elm) {
|
|
62
|
-
appendToMap(elmsToUpdate, propName, elm);
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
set: (propName) => {
|
|
66
|
-
const elements = elmsToUpdate.get(propName);
|
|
67
|
-
if (elements) {
|
|
68
|
-
elmsToUpdate.set(propName, elements.filter(index.forceUpdate));
|
|
69
|
-
}
|
|
70
|
-
cleanupElements(elmsToUpdate);
|
|
71
|
-
},
|
|
72
|
-
reset: () => {
|
|
73
|
-
elmsToUpdate.forEach((elms) => elms.forEach(index.forceUpdate));
|
|
74
|
-
cleanupElements(elmsToUpdate);
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const unwrap = (val) => (typeof val === 'function' ? val() : val);
|
|
80
|
-
const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
|
|
81
|
-
const unwrappedState = unwrap(defaultState);
|
|
82
|
-
let states = new Map(Object.entries(unwrappedState !== null && unwrappedState !== void 0 ? unwrappedState : {}));
|
|
83
|
-
const handlers = {
|
|
84
|
-
dispose: [],
|
|
85
|
-
get: [],
|
|
86
|
-
set: [],
|
|
87
|
-
reset: [],
|
|
88
|
-
};
|
|
89
|
-
const reset = () => {
|
|
90
|
-
var _a;
|
|
91
|
-
// When resetting the state, the default state may be a function - unwrap it to invoke it.
|
|
92
|
-
// otherwise, the state won't be properly reset
|
|
93
|
-
states = new Map(Object.entries((_a = unwrap(defaultState)) !== null && _a !== void 0 ? _a : {}));
|
|
94
|
-
handlers.reset.forEach((cb) => cb());
|
|
95
|
-
};
|
|
96
|
-
const dispose = () => {
|
|
97
|
-
// Call first dispose as resetting the state would
|
|
98
|
-
// cause less updates ;)
|
|
99
|
-
handlers.dispose.forEach((cb) => cb());
|
|
100
|
-
reset();
|
|
101
|
-
};
|
|
102
|
-
const get = (propName) => {
|
|
103
|
-
handlers.get.forEach((cb) => cb(propName));
|
|
104
|
-
return states.get(propName);
|
|
105
|
-
};
|
|
106
|
-
const set = (propName, value) => {
|
|
107
|
-
const oldValue = states.get(propName);
|
|
108
|
-
if (shouldUpdate(value, oldValue, propName)) {
|
|
109
|
-
states.set(propName, value);
|
|
110
|
-
handlers.set.forEach((cb) => cb(propName, value, oldValue));
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
const state = (typeof Proxy === 'undefined'
|
|
114
|
-
? {}
|
|
115
|
-
: new Proxy(unwrappedState, {
|
|
116
|
-
get(_, propName) {
|
|
117
|
-
return get(propName);
|
|
118
|
-
},
|
|
119
|
-
ownKeys(_) {
|
|
120
|
-
return Array.from(states.keys());
|
|
121
|
-
},
|
|
122
|
-
getOwnPropertyDescriptor() {
|
|
123
|
-
return {
|
|
124
|
-
enumerable: true,
|
|
125
|
-
configurable: true,
|
|
126
|
-
};
|
|
127
|
-
},
|
|
128
|
-
has(_, propName) {
|
|
129
|
-
return states.has(propName);
|
|
130
|
-
},
|
|
131
|
-
set(_, propName, value) {
|
|
132
|
-
set(propName, value);
|
|
133
|
-
return true;
|
|
134
|
-
},
|
|
135
|
-
}));
|
|
136
|
-
const on = (eventName, callback) => {
|
|
137
|
-
handlers[eventName].push(callback);
|
|
138
|
-
return () => {
|
|
139
|
-
removeFromArray(handlers[eventName], callback);
|
|
140
|
-
};
|
|
141
|
-
};
|
|
142
|
-
const onChange = (propName, cb) => {
|
|
143
|
-
const unSet = on('set', (key, newValue) => {
|
|
144
|
-
if (key === propName) {
|
|
145
|
-
cb(newValue);
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
// We need to unwrap the defaultState because it might be a function.
|
|
149
|
-
// Otherwise we might not be sending the right reset value.
|
|
150
|
-
const unReset = on('reset', () => cb(unwrap(defaultState)[propName]));
|
|
151
|
-
return () => {
|
|
152
|
-
unSet();
|
|
153
|
-
unReset();
|
|
154
|
-
};
|
|
155
|
-
};
|
|
156
|
-
const use = (...subscriptions) => {
|
|
157
|
-
const unsubs = subscriptions.reduce((unsubs, subscription) => {
|
|
158
|
-
if (subscription.set) {
|
|
159
|
-
unsubs.push(on('set', subscription.set));
|
|
160
|
-
}
|
|
161
|
-
if (subscription.get) {
|
|
162
|
-
unsubs.push(on('get', subscription.get));
|
|
163
|
-
}
|
|
164
|
-
if (subscription.reset) {
|
|
165
|
-
unsubs.push(on('reset', subscription.reset));
|
|
166
|
-
}
|
|
167
|
-
if (subscription.dispose) {
|
|
168
|
-
unsubs.push(on('dispose', subscription.dispose));
|
|
169
|
-
}
|
|
170
|
-
return unsubs;
|
|
171
|
-
}, []);
|
|
172
|
-
return () => unsubs.forEach((unsub) => unsub());
|
|
173
|
-
};
|
|
174
|
-
const forceUpdate = (key) => {
|
|
175
|
-
const oldValue = states.get(key);
|
|
176
|
-
handlers.set.forEach((cb) => cb(key, oldValue, oldValue));
|
|
177
|
-
};
|
|
178
|
-
return {
|
|
179
|
-
state,
|
|
180
|
-
get,
|
|
181
|
-
set,
|
|
182
|
-
on,
|
|
183
|
-
onChange,
|
|
184
|
-
use,
|
|
185
|
-
dispose,
|
|
186
|
-
reset,
|
|
187
|
-
forceUpdate,
|
|
188
|
-
};
|
|
189
|
-
};
|
|
190
|
-
const removeFromArray = (array, item) => {
|
|
191
|
-
const index = array.indexOf(item);
|
|
192
|
-
if (index >= 0) {
|
|
193
|
-
array[index] = array[array.length - 1];
|
|
194
|
-
array.length--;
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
const createStore = (defaultState, shouldUpdate) => {
|
|
199
|
-
const map = createObservableMap(defaultState, shouldUpdate);
|
|
200
|
-
map.use(stencilSubscription());
|
|
201
|
-
return map;
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
const pdfStore = createStore({
|
|
13
|
+
const pdfStore = _workerHelper.createStore({
|
|
205
14
|
docs: new Map(),
|
|
206
15
|
});
|
|
207
16
|
|