@qikdev/sdk 0.1.209 → 0.1.210
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/package.json
CHANGED
package/src/api/qik.content.js
CHANGED
|
@@ -117,7 +117,7 @@ export default function (qik) {
|
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* Inflate compressed glossary data using a Web Worker
|
|
120
|
-
*
|
|
120
|
+
* Receives results in chunks to avoid blocking during deserialization
|
|
121
121
|
* @private
|
|
122
122
|
*/
|
|
123
123
|
async function inflateGlossary(data) {
|
|
@@ -130,10 +130,17 @@ export default function (qik) {
|
|
|
130
130
|
const worker = await getInflateWorker();
|
|
131
131
|
|
|
132
132
|
return new Promise((resolve) => {
|
|
133
|
+
const results = [];
|
|
134
|
+
|
|
133
135
|
const handler = (e) => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
const { chunk, done } = e.data;
|
|
137
|
+
results.push(...chunk);
|
|
138
|
+
|
|
139
|
+
if (done) {
|
|
140
|
+
worker.removeEventListener("message", handler);
|
|
141
|
+
worker.removeEventListener("error", errorHandler);
|
|
142
|
+
resolve(results);
|
|
143
|
+
}
|
|
137
144
|
};
|
|
138
145
|
|
|
139
146
|
const errorHandler = () => {
|
package/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "0.1.
|
|
1
|
+
export const version = "0.1.210";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Web Worker for inflating compressed glossary data
|
|
3
|
-
*
|
|
3
|
+
* Streams results back in chunks with delays to avoid blocking the main thread
|
|
4
4
|
*/
|
|
5
|
-
self.onmessage = function (e) {
|
|
5
|
+
self.onmessage = async function (e) {
|
|
6
6
|
const { _s: strings, _k: keyMap, types } = e.data;
|
|
7
7
|
|
|
8
8
|
function inflate(val) {
|
|
@@ -20,6 +20,19 @@ self.onmessage = function (e) {
|
|
|
20
20
|
return val;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
// Send results back in chunks with small delays
|
|
24
|
+
// This lets the main thread process each chunk before receiving the next
|
|
25
|
+
const CHUNK_SIZE = 20;
|
|
26
|
+
const total = types.length;
|
|
27
|
+
|
|
28
|
+
for (let i = 0; i < total; i += CHUNK_SIZE) {
|
|
29
|
+
const chunk = types.slice(i, i + CHUNK_SIZE).map(inflate);
|
|
30
|
+
const done = i + CHUNK_SIZE >= total;
|
|
31
|
+
self.postMessage({ chunk, done });
|
|
32
|
+
|
|
33
|
+
// Small delay between chunks to let main thread breathe
|
|
34
|
+
if (!done) {
|
|
35
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
25
38
|
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
const s = `(function(){"use strict";self.onmessage=function(r){const{_s:o,_k:f,types:i}=r.data;function e(t){if(typeof t=="string"&&t[0]==="~")return o[parseInt(t.slice(1))];if(Array.isArray(t))return t.map(e);if(t&&typeof t=="object"){const s={};for(const[n,u]of Object.entries(t))s[f[n]||n]=e(u);return s}return t}const c=i.map(e);self.postMessage(c)}})();
|
|
2
|
-
`, n = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", s], { type: "text/javascript;charset=utf-8" });
|
|
3
|
-
function o(r) {
|
|
4
|
-
let e;
|
|
5
|
-
try {
|
|
6
|
-
if (e = n && (self.URL || self.webkitURL).createObjectURL(n), !e) throw "";
|
|
7
|
-
const t = new Worker(e, {
|
|
8
|
-
name: r?.name
|
|
9
|
-
});
|
|
10
|
-
return t.addEventListener("error", () => {
|
|
11
|
-
(self.URL || self.webkitURL).revokeObjectURL(e);
|
|
12
|
-
}), t;
|
|
13
|
-
} catch {
|
|
14
|
-
return new Worker(
|
|
15
|
-
"data:text/javascript;charset=utf-8," + encodeURIComponent(s),
|
|
16
|
-
{
|
|
17
|
-
name: r?.name
|
|
18
|
-
}
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export {
|
|
23
|
-
o as default
|
|
24
|
-
};
|