@woosh/meep-engine 2.119.102 → 2.119.104
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 +1 -1
- package/src/core/process/worker/WorkerBuilder.d.ts.map +1 -1
- package/src/core/process/worker/WorkerBuilder.js +47 -29
- package/src/engine/asset/loaders/image/ImageRGBADataLoader.d.ts +5 -1
- package/src/engine/asset/loaders/image/ImageRGBADataLoader.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/ImageRGBADataLoader.js +8 -2
- package/src/engine/asset/loaders/image/codec/ThreadedImageDecoder.d.ts +5 -0
- package/src/engine/asset/loaders/image/codec/ThreadedImageDecoder.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/codec/ThreadedImageDecoder.js +9 -2
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkerBuilder.d.ts","sourceRoot":"","sources":["../../../../../src/core/process/worker/WorkerBuilder.js"],"names":[],"mappings":";AAQA;IAEI;;;OAGG;IACH,SAFU,MAAM,EAAE,CAEL;IACb,YAAa;IACb;;;OAGG;IACH,WAFU;QAAC,CAAC,WAAU;QAAC,IAAI,EAAC,MAAM,CAAA;KAAC,EAAE,CAEtB;IACf,sBAA6B;IAE7B;;;OAGG;IACH,cAFW,MAAM,QAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM,UACN,WAAS,MAAM,QAIzB;IAED;;;;;OAKG;IACH,6CAKC;IAED;;;OAGG;IACH,mBAFW,MAAM,QAMhB;IAED;;;OAGG;IACH,SAFa,WAAW,
|
|
1
|
+
{"version":3,"file":"WorkerBuilder.d.ts","sourceRoot":"","sources":["../../../../../src/core/process/worker/WorkerBuilder.js"],"names":[],"mappings":";AAQA;IAEI;;;OAGG;IACH,SAFU,MAAM,EAAE,CAEL;IACb,YAAa;IACb;;;OAGG;IACH,WAFU;QAAC,CAAC,WAAU;QAAC,IAAI,EAAC,MAAM,CAAA;KAAC,EAAE,CAEtB;IACf,sBAA6B;IAE7B;;;OAGG;IACH,cAFW,MAAM,QAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM,UACN,WAAS,MAAM,QAIzB;IAED;;;;;OAKG;IACH,6CAKC;IAED;;;OAGG;IACH,mBAFW,MAAM,QAMhB;IAED;;;OAGG;IACH,SAFa,WAAW,CA2HvB;CACJ;wBA3LuB,8BAA8B;wBAC9B,kBAAkB"}
|
|
@@ -116,6 +116,7 @@ class WorkerBuilder {
|
|
|
116
116
|
|
|
117
117
|
//api handler
|
|
118
118
|
Array.prototype.push.apply(codeLines, [
|
|
119
|
+
//language=js
|
|
119
120
|
`function extractTransferables(obj, result) {
|
|
120
121
|
if (typeof obj !== "object") {
|
|
121
122
|
return; //not an object, skip
|
|
@@ -133,35 +134,52 @@ class WorkerBuilder {
|
|
|
133
134
|
}
|
|
134
135
|
}
|
|
135
136
|
}`,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
137
|
+
//language=js
|
|
138
|
+
`globalScope.onmessage = function (event) {
|
|
139
|
+
const eventData = event.data;
|
|
140
|
+
const requestId = eventData.id
|
|
141
|
+
const methodName = eventData.methodName;
|
|
142
|
+
const parameters = eventData.parameters;
|
|
143
|
+
const method = api[methodName];
|
|
144
|
+
|
|
145
|
+
function sendResult(result) {
|
|
146
|
+
const transferables = [];
|
|
147
|
+
extractTransferables(result, transferables);
|
|
148
|
+
globalScope.postMessage({ methodName: methodName, id: requestId, result: result }, transferables);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function sendError(error) {
|
|
152
|
+
let stack = "";
|
|
153
|
+
try {
|
|
154
|
+
stack = error.stack.split("\\n")
|
|
155
|
+
} catch (e) {
|
|
156
|
+
}
|
|
157
|
+
globalScope.postMessage({
|
|
158
|
+
methodName: methodName,
|
|
159
|
+
id: requestId,
|
|
160
|
+
error: { message: error.message, stack: stack }
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (method === undefined) {
|
|
165
|
+
sendError(new Error("API named \'" + methodName + "\' was not found."));
|
|
166
|
+
} else {
|
|
167
|
+
try {
|
|
168
|
+
const method_result = method.apply(null, parameters);
|
|
169
|
+
|
|
170
|
+
if(typeof method_result.then === "function"){
|
|
171
|
+
// thenable
|
|
172
|
+
method_result.then(sendResult, sendError);
|
|
173
|
+
}else{
|
|
174
|
+
// straight value
|
|
175
|
+
sendResult(method_result);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
} catch (e) {
|
|
179
|
+
sendError(e);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
};`
|
|
165
183
|
]);
|
|
166
184
|
|
|
167
185
|
const code = codeLines.join("\n");
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export class ImageRGBADataLoader extends AssetLoader<any, any> {
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param {string} [worker_path] Path to decoder worker, allows flexibility in deployment
|
|
5
|
+
*/
|
|
6
|
+
constructor({ worker_path }?: string);
|
|
3
7
|
decoder: CodecWithFallback;
|
|
4
8
|
link(assetManager: any, engine: any): Promise<void>;
|
|
5
9
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageRGBADataLoader.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/asset/loaders/image/ImageRGBADataLoader.js"],"names":[],"mappings":"AAYA;IACI,
|
|
1
|
+
{"version":3,"file":"ImageRGBADataLoader.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/asset/loaders/image/ImageRGBADataLoader.js"],"names":[],"mappings":"AAYA;IACI;;;OAGG;IACH,8BAFW,MAAM,EAWhB;IAJG,2BAGC;IAGL,oDAOC;IAED;;;;;;OAMG;IACH,4BASC;IAED;;;;;;OAMG;IACH,mBAoBC;IAED,6EAiCC;CACJ;4BAlH2B,mBAAmB;kCACb,8BAA8B"}
|
|
@@ -11,11 +11,17 @@ import { ImageRGBADataAsset } from "./ImageRGBADataAsset.js";
|
|
|
11
11
|
const ASSET_TYPE_ARRAY_BUFFER = "arraybuffer";
|
|
12
12
|
|
|
13
13
|
export class ImageRGBADataLoader extends AssetLoader {
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param {string} [worker_path] Path to decoder worker, allows flexibility in deployment
|
|
17
|
+
*/
|
|
18
|
+
constructor({
|
|
19
|
+
worker_path
|
|
20
|
+
} = {}) {
|
|
15
21
|
super();
|
|
16
22
|
|
|
17
23
|
this.decoder = new CodecWithFallback(
|
|
18
|
-
new ThreadedImageDecoder(),
|
|
24
|
+
new ThreadedImageDecoder({ worker_path }),
|
|
19
25
|
new NativeImageDecoder()
|
|
20
26
|
);
|
|
21
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadedImageDecoder.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/asset/loaders/image/codec/ThreadedImageDecoder.js"],"names":[],"mappings":"AAKA;
|
|
1
|
+
{"version":3,"file":"ThreadedImageDecoder.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/asset/loaders/image/codec/ThreadedImageDecoder.js"],"names":[],"mappings":"AAKA;IACI;;;OAGG;IACH,8BAFW,MAAM,EAuBhB;IAPG;;;OAGG;IACH,QAFU,qBAAqB,CAE+B;IAKlE,kCASC;IAED,gCAEC;CACJ;sBA5CqB,YAAY;sCAHI,6DAA6D"}
|
|
@@ -4,12 +4,19 @@ import { PNG_HEADER_BYTES } from "../png/PNG_HEADER_BYTES.js";
|
|
|
4
4
|
import { Codec } from "./Codec.js";
|
|
5
5
|
|
|
6
6
|
export class ThreadedImageDecoder extends Codec {
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param {string} [worker_path]
|
|
10
|
+
*/
|
|
11
|
+
constructor({
|
|
12
|
+
worker_path = 'bundle-worker-image-decoder.js'
|
|
13
|
+
}={}) {
|
|
14
|
+
|
|
8
15
|
super();
|
|
9
16
|
|
|
10
17
|
const workerBuilder = new WorkerBuilder();
|
|
11
18
|
|
|
12
|
-
workerBuilder.importScript(
|
|
19
|
+
workerBuilder.importScript(worker_path);
|
|
13
20
|
|
|
14
21
|
workerBuilder.addMethod('decode', function (data, type) {
|
|
15
22
|
return Lib.decode(data, type);
|