Repository navigation
Expand file tree
/
Copy pathpreload.js
More file actions
48 lines (35 loc) · 1.48 KB
/
Copy pathpreload.js
File metadata and controls
48 lines (35 loc) · 1.48 KB
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
var fs = require('fs');
const path = require('path');
const dev = require('./js/touchstone/obsolete api/main/dev');
const stackFactory = require('./js/touchstone/obsolete api/main/stackFactory');
const Module = require('./js/touchstone/obsolete api/modelling/module');
const Entity = require('./js/touchstone/obsolete api/modelling/entity');
const setimmediate = require("setimmediate");
// All of the Node.js APIs are available in the preload process.
global.setimmediate = setimmediate;
// It has the same sandbox as a Chrome extension.
window.addEventListener('DOMContentLoaded', () => {
const replaceText = (selector, text) => {
const element = document.getElementById(selector)
if (element) element.innerText = text
}
for (const type of ['chrome', 'node', 'electron']) {
replaceText(`${type}-version`, process.versions[type])
}
})
window.addEventListener('loadschema', function (e) {
window.schema = JSON.parse(fs.readFileSync(path.join(__dirname, 'storage/schema.json'), 'utf8'));
}, false);
window.addEventListener('saveschema', function (e) {
fs.writeFileSync(path.join(__dirname, 'storage/schema.json'), JSON.stringify(window.schema,null,4));
}, false);
window.Dev = dev;
window.Stack = stackFactory.resolveStack;
window.Module = Module;
window.Entity = Entity;
window.screen = {};
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = '1';
var _setImmediate = setImmediate;
process.once('loaded', function() {
global.setImmediate = _setImmediate;
});