@qikdev/sdk 0.1.206 → 0.1.208
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/main.js +1323 -1313
- package/package.json +1 -1
- package/src/api/qik.content.js +33 -4
- package/src/version.js +1 -1
package/package.json
CHANGED
package/src/api/qik.content.js
CHANGED
|
@@ -67,11 +67,26 @@ export default function (qik) {
|
|
|
67
67
|
|
|
68
68
|
let inflightGlossaryRequest;
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Yield to the event loop to keep the UI responsive
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
function yieldToMain() {
|
|
75
|
+
return new Promise((resolve) => {
|
|
76
|
+
if (typeof requestIdleCallback === "function") {
|
|
77
|
+
requestIdleCallback(resolve, { timeout: 50 });
|
|
78
|
+
} else {
|
|
79
|
+
setTimeout(resolve, 0);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
70
84
|
/**
|
|
71
85
|
* Inflate compressed glossary data from the /glossary/compressed endpoint
|
|
86
|
+
* Processes in chunks to avoid blocking the main thread
|
|
72
87
|
* @private
|
|
73
88
|
*/
|
|
74
|
-
function inflateGlossary({ _s: strings, _k: keyMap, types }) {
|
|
89
|
+
async function inflateGlossary({ _s: strings, _k: keyMap, types }) {
|
|
75
90
|
function inflate(val) {
|
|
76
91
|
if (typeof val === "string" && val[0] === "~") {
|
|
77
92
|
return strings[parseInt(val.slice(1))];
|
|
@@ -86,7 +101,21 @@ export default function (qik) {
|
|
|
86
101
|
}
|
|
87
102
|
return val;
|
|
88
103
|
}
|
|
89
|
-
|
|
104
|
+
|
|
105
|
+
const CHUNK_SIZE = 50;
|
|
106
|
+
const results = [];
|
|
107
|
+
|
|
108
|
+
for (let i = 0; i < types.length; i += CHUNK_SIZE) {
|
|
109
|
+
const chunk = types.slice(i, i + CHUNK_SIZE);
|
|
110
|
+
results.push(...chunk.map(inflate));
|
|
111
|
+
|
|
112
|
+
// Yield to main thread between chunks
|
|
113
|
+
if (i + CHUNK_SIZE < types.length) {
|
|
114
|
+
await yieldToMain();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return results;
|
|
90
119
|
}
|
|
91
120
|
|
|
92
121
|
/**
|
|
@@ -133,9 +162,9 @@ export default function (qik) {
|
|
|
133
162
|
// Now we have the glossary
|
|
134
163
|
const { data } = await inflightGlossaryRequest;
|
|
135
164
|
|
|
136
|
-
// Inflate if compressed format
|
|
165
|
+
// Inflate if compressed format (async to avoid blocking UI)
|
|
137
166
|
const glossaryData =
|
|
138
|
-
data._s && data._k && data.types ? inflateGlossary(data) : data;
|
|
167
|
+
data._s && data._k && data.types ? await inflateGlossary(data) : data;
|
|
139
168
|
|
|
140
169
|
// Cache it for later
|
|
141
170
|
glossaryCache.set("glossary", glossaryData);
|
package/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "0.1.
|
|
1
|
+
export const version = "0.1.208";
|