forked from MozillaReality/ieeevr-spoke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentry.js
49 lines (42 loc) · 1.36 KB
/
entry.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const { JSDOM } = require("jsdom");
const jsdom = new JSDOM("<!doctype html><html><body></body></html>");
const { window } = jsdom;
function copyProps(src, target) {
Object.defineProperties(target, {
...Object.getOwnPropertyDescriptors(src),
...Object.getOwnPropertyDescriptors(target)
});
}
global.window = window;
global.document = window.document;
global.navigator = {
userAgent: "node.js"
};
global.requestAnimationFrame = function(callback) {
return setTimeout(callback, 0);
};
global.cancelAnimationFrame = function(id) {
clearTimeout(id);
};
copyProps(window, global);
window.Number = global.Number;
const { AudioContext, AudioNode } = require("standardized-audio-context-mock");
window.AudioContext = AudioContext;
AudioContext.prototype.createPanner = () => {
return new AudioNode({
context: new AudioContext()
});
};
function warnSkipAsset(mod) {
console.warn(`Skip loading Webpack Asset "${mod.filename}" in file: "${mod.parent.filename}"`);
mod.exports = "https://example.com";
return mod;
}
[".css", ".scss", ".jpg", ".png", ".glb", ".gltf", ".mp4", ".webm", ".spoke", ".wasm"].forEach(extension => {
require.extensions[extension] = warnSkipAsset;
});
require.extensions[".worker.js"] = mod => {
console.warn(`Skip loading WebWorker "${mod.filename}" in file: "${mod.parent.filename}"`);
mod.exports = function() {};
return mod;
};