larry babby and threejs for glsl

This commit is contained in:
Sam
2024-06-24 21:24:00 +12:00
parent 87d5dc634d
commit 907ebae4c0
6474 changed files with 1279596 additions and 8 deletions

View File

@@ -0,0 +1,58 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
function _nullthrows() {
const data = _interopRequireDefault(require("nullthrows"));
_nullthrows = function () {
return data;
};
return data;
}
var _childState = require("../childState");
var _child = require("../child");
function _core() {
const data = require("@parcel/core");
_core = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class ProcessChild {
constructor(onMessage, onExit) {
if (!process.send) {
throw new Error('Only create ProcessChild instances in a worker!');
}
this.onMessage = onMessage;
this.onExit = onExit;
process.on('message', data => this.handleMessage(data));
}
handleMessage(data) {
if (data === 'die') {
return this.stop();
}
this.onMessage((0, _core().deserialize)(Buffer.from(data, 'base64')));
}
send(data) {
let processSend = (0, _nullthrows().default)(process.send).bind(process);
processSend((0, _core().serialize)(data).toString('base64'), err => {
if (err && err instanceof Error) {
// $FlowFixMe[prop-missing]
if (err.code === 'ERR_IPC_CHANNEL_CLOSED') {
// IPC connection closed
// no need to keep the worker running if it can't send or receive data
return this.stop();
}
}
});
}
stop() {
this.onExit(0);
process.exit();
}
}
exports.default = ProcessChild;
(0, _childState.setChild)(new _child.Child(ProcessChild));

View File

@@ -0,0 +1,83 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
function _child_process() {
const data = _interopRequireDefault(require("child_process"));
_child_process = function () {
return data;
};
return data;
}
function _path() {
const data = _interopRequireDefault(require("path"));
_path = function () {
return data;
};
return data;
}
function _core() {
const data = require("@parcel/core");
_core = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const WORKER_PATH = _path().default.join(__dirname, 'ProcessChild.js');
class ProcessWorker {
processQueue = true;
sendQueue = [];
constructor(execArgv, onMessage, onError, onExit) {
this.execArgv = execArgv;
this.onMessage = onMessage;
this.onError = onError;
this.onExit = onExit;
}
start() {
this.child = _child_process().default.fork(WORKER_PATH, process.argv, {
execArgv: this.execArgv,
env: process.env,
cwd: process.cwd()
});
this.child.on('message', data => {
this.onMessage((0, _core().deserialize)(Buffer.from(data, 'base64')));
});
this.child.once('exit', this.onExit);
this.child.on('error', this.onError);
return Promise.resolve();
}
async stop() {
this.child.send('die');
let forceKill = setTimeout(() => this.child.kill('SIGINT'), 500);
await new Promise(resolve => {
this.child.once('exit', resolve);
});
clearTimeout(forceKill);
}
send(data) {
if (!this.processQueue) {
this.sendQueue.push(data);
return;
}
let result = this.child.send((0, _core().serialize)(data).toString('base64'), error => {
if (error && error instanceof Error) {
// Ignore this, the workerfarm handles child errors
return;
}
this.processQueue = true;
if (this.sendQueue.length > 0) {
let queueCopy = this.sendQueue.slice(0);
this.sendQueue = [];
queueCopy.forEach(entry => this.send(entry));
}
});
if (!result || /^win/.test(process.platform)) {
// Queue is handling too much messages throttle it
this.processQueue = false;
}
}
}
exports.default = ProcessWorker;