dcp-client 4.3.1 → 4.3.2-webgpu.0
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/README.md +0 -2
- package/dist/dcp-client-bundle.js +6280 -2
- package/generated/sandbox-definitions.json +1 -1
- package/libexec/sandbox/access-lists.js +20 -42
- package/libexec/sandbox/calculate-capabilities.js +3 -18
- package/package.json +1 -1
- package/libexec/sandbox/webgpu-worker-environment.js +0 -122
- package/portal-emails.txt +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"browser":["deny-node","kvin/kvin.js","script-load-wrapper","wrap-event-listeners","timer-classes","event-loop-virtualization","unique-timing","access-lists","bravojs-init","bravojs/bravo.js","bravojs-env","calculate-capabilities","bootstrap"],"node":["kvin/kvin.js","sa-ww-simulation","script-load-wrapper","wrap-event-listeners","timer-classes","event-loop-virtualization","unique-timing","access-lists","bravojs-init","bravojs/bravo.js","bravojs-env","calculate-capabilities","bootstrap"],"native":["deny-node","kvin/kvin.js","sa-ww-simulation","script-load-wrapper","native-event-loop","wrap-event-listeners","timer-classes","event-loop-virtualization","unique-timing","access-lists","bravojs-init","bravojs/bravo.js","bravojs-env","calculate-capabilities","bootstrap"],"
|
|
1
|
+
{"browser":["deny-node","kvin/kvin.js","script-load-wrapper","wrap-event-listeners","timer-classes","event-loop-virtualization","unique-timing","access-lists","bravojs-init","bravojs/bravo.js","bravojs-env","calculate-capabilities","bootstrap"],"node":["kvin/kvin.js","sa-ww-simulation","script-load-wrapper","wrap-event-listeners","timer-classes","event-loop-virtualization","unique-timing","access-lists","bravojs-init","bravojs/bravo.js","bravojs-env","calculate-capabilities","bootstrap"],"native":["deny-node","kvin/kvin.js","sa-ww-simulation","script-load-wrapper","native-event-loop","wrap-event-listeners","timer-classes","event-loop-virtualization","unique-timing","access-lists","bravojs-init","bravojs/bravo.js","bravojs-env","calculate-capabilities","bootstrap"],"nodeTesting":["kvin/kvin.js","sa-ww-simulation","script-load-wrapper","wrap-event-listeners","timer-classes","event-loop-virtualization","unique-timing","access-lists","bravojs-init","bravojs/bravo.js","bravojs-env","calculate-capabilities","bootstrap","testing.js"],"testing":["deny-node","kvin/kvin.js","sa-ww-simulation","script-load-wrapper","native-event-loop","wrap-event-listeners","timer-classes","event-loop-virtualization","unique-timing","access-lists","bravojs-init","bravojs/bravo.js","bravojs-env","calculate-capabilities","bootstrap","testing.js"]}
|
|
@@ -659,10 +659,9 @@ self.wrapScriptLoading({ scriptName: 'access-lists', ringTransition: true }, fun
|
|
|
659
659
|
*
|
|
660
660
|
* @param {object} obj - The object, which will have the allow list applied to its properties.
|
|
661
661
|
* @param {Set} allowList - A set of properties to allow people to access.
|
|
662
|
-
* @param {
|
|
663
|
-
* @param {Set} polyfills - An object of property names that have been polyfilled.
|
|
662
|
+
* @param {Object} blockList - An object of property names mapping to booleans to indicate whether access is allowed or not.
|
|
664
663
|
*/
|
|
665
|
-
function applyAccessLists(obj, allowList, blockList = {}
|
|
664
|
+
function applyAccessLists(obj, allowList, blockList = {}) {
|
|
666
665
|
if (!obj) { return; }
|
|
667
666
|
Object.getOwnPropertyNames(obj).forEach(function (prop) {
|
|
668
667
|
if (Object.getOwnPropertyDescriptor(obj, prop).configurable) {
|
|
@@ -670,17 +669,13 @@ self.wrapScriptLoading({ scriptName: 'access-lists', ringTransition: true }, fun
|
|
|
670
669
|
let isSet = false;
|
|
671
670
|
let propValue;
|
|
672
671
|
Object.defineProperty(obj, prop, {
|
|
673
|
-
get: function () {
|
|
674
|
-
if (isSet)
|
|
672
|
+
get: function getProtectedProperty() {
|
|
673
|
+
if (isSet)
|
|
675
674
|
return propValue;
|
|
676
|
-
|
|
677
|
-
if (prop in polyfills) {
|
|
678
|
-
return polyfills[prop];
|
|
679
|
-
}
|
|
675
|
+
else
|
|
680
676
|
return undefined;
|
|
681
|
-
}
|
|
682
677
|
},
|
|
683
|
-
set: function (value) {
|
|
678
|
+
set: function setProtectedProperty(value) {
|
|
684
679
|
propValue = value;
|
|
685
680
|
isSet = true;
|
|
686
681
|
},
|
|
@@ -712,16 +707,17 @@ self.wrapScriptLoading({ scriptName: 'access-lists', ringTransition: true }, fun
|
|
|
712
707
|
|
|
713
708
|
/**
|
|
714
709
|
* Applies a list of polyfills to symbols not present in the global object. Will apply
|
|
715
|
-
*
|
|
710
|
+
* check the prototype chain for the symbol, and add it to the supplied 'obj' only if not
|
|
711
|
+
* present in the chain.
|
|
716
712
|
*
|
|
717
713
|
* @param {Object} obj - The global object to add properties on
|
|
718
|
-
* @param {
|
|
714
|
+
* @param {Object} polyfills - An object of property names to create/polyfill
|
|
719
715
|
*/
|
|
720
|
-
function applyPolyfills(obj, polyfills
|
|
716
|
+
function applyPolyfills(obj, polyfills){
|
|
721
717
|
// Apply symbols from polyfill object
|
|
722
718
|
for (let prop in polyfills) {
|
|
723
719
|
let found = false;
|
|
724
|
-
for (let o = obj;
|
|
720
|
+
for (let o = obj; Object.getPrototypeOf(o); o = Object.getPrototypeOf(o)) {
|
|
725
721
|
if (o.hasOwnProperty(prop)) {
|
|
726
722
|
found = true;
|
|
727
723
|
break;
|
|
@@ -730,11 +726,11 @@ self.wrapScriptLoading({ scriptName: 'access-lists', ringTransition: true }, fun
|
|
|
730
726
|
if (found) { continue; }
|
|
731
727
|
let propValue = polyfills[prop];
|
|
732
728
|
Object.defineProperty(obj, prop, {
|
|
733
|
-
get: function () {
|
|
729
|
+
get: function getPolyfill() {
|
|
734
730
|
return propValue;
|
|
735
731
|
|
|
736
732
|
},
|
|
737
|
-
set: function (value) {
|
|
733
|
+
set: function setPolyfill(value) {
|
|
738
734
|
propValue = value;
|
|
739
735
|
},
|
|
740
736
|
configurable: false
|
|
@@ -748,43 +744,25 @@ self.wrapScriptLoading({ scriptName: 'access-lists', ringTransition: true }, fun
|
|
|
748
744
|
* so that the blockList is accessible to modify w/o adding it to the allowList.
|
|
749
745
|
*/
|
|
750
746
|
function applyAllAccessLists() {
|
|
751
|
-
// We need to apply the access lists to global, global
|
|
752
|
-
// because there's networking-accessing functions inside
|
|
747
|
+
// We need to apply the access lists to global, and the entirety of global's prototype chain
|
|
748
|
+
// because there's networking-accessing functions inside the chain, like fetch.
|
|
753
749
|
//
|
|
754
750
|
// If we're in a robust environment (node, browser, WebWorker, basically anything but v8),
|
|
755
751
|
// then we have to climb the prototype chain and apply the allowList there, but we have to stop
|
|
756
752
|
// before we allow Object's properties
|
|
757
753
|
|
|
758
754
|
var global = typeof globalThis === 'undefined' ? self : globalThis;
|
|
759
|
-
|
|
760
|
-
// Ternary expression to avoid a ReferenceError on navigator
|
|
761
|
-
let _GPU = ((typeof navigator !== 'undefined') && (typeof navigator.gpu !== 'undefined')) ? navigator.gpu :
|
|
762
|
-
(typeof GPU !== 'undefined'? GPU : undefined);
|
|
763
|
-
|
|
764
|
-
for (let g = global; g.__proto__ && (g.__proto__ !== Object); g = g.__proto__) {
|
|
755
|
+
for (let g = global; Object.getPrototypeOf(g); g = Object.getPrototypeOf(g))
|
|
765
756
|
applyAccessLists(g, allowList, blockList, polyfills);
|
|
766
|
-
}
|
|
767
757
|
|
|
768
758
|
if (typeof navigator === 'undefined')
|
|
759
|
+
navigator = { userAgent: 'not a browser', gpu: undefined };
|
|
760
|
+
else
|
|
769
761
|
{
|
|
770
762
|
navigator = {
|
|
771
|
-
userAgent: 'not a browser',
|
|
772
|
-
gpu:
|
|
773
|
-
};
|
|
774
|
-
}
|
|
775
|
-
else if (!protectedStorage.createdNewNavigator)
|
|
776
|
-
{
|
|
777
|
-
// We also want to allowList certain parts of navigator, but not others.
|
|
778
|
-
const navAllowlist = new Set([
|
|
779
|
-
'userAgent',
|
|
780
|
-
'gpu',
|
|
781
|
-
]);
|
|
782
|
-
let navPolyfill = {
|
|
783
|
-
userAgent: typeof navigator.userAgent !== 'undefined'? navigator.userAgent : 'not a browser',
|
|
784
|
-
gpu: _GPU,
|
|
763
|
+
userAgent: navigator.userAgent ? navigator.userAgent : 'not a browser',
|
|
764
|
+
gpu: navigator.gpu
|
|
785
765
|
};
|
|
786
|
-
applyAccessLists(navigator.__proto__, navAllowlist, {}, {}, navPolyfill);
|
|
787
|
-
applyPolyfills(navigator.__proto__, navPolyfill);
|
|
788
766
|
}
|
|
789
767
|
}
|
|
790
768
|
|
|
@@ -49,28 +49,13 @@ self.wrapScriptLoading({ scriptName: 'calculate-capabilities' }, function calcul
|
|
|
49
49
|
});`
|
|
50
50
|
|
|
51
51
|
webgpu =
|
|
52
|
-
typeof GPU !== 'undefined' ||
|
|
53
52
|
(typeof navigator !== 'undefined' &&
|
|
54
53
|
typeof navigator.gpu !== 'undefined');
|
|
55
54
|
|
|
56
55
|
if (webgpu) {
|
|
57
56
|
try {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (typeof WebGPUWindow !== 'undefined') {
|
|
61
|
-
const gpuWindow = new WebGPUWindow({
|
|
62
|
-
width: 640,
|
|
63
|
-
height: 480,
|
|
64
|
-
title: 'DCP-evaluator',
|
|
65
|
-
visible: false,
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
const adapter = await GPU.requestAdapter({ window: gpuWindow });
|
|
69
|
-
await adapter.requestDevice(adapter.extensions);
|
|
70
|
-
} else {
|
|
71
|
-
const adapter = await navigator.gpu.requestAdapter();
|
|
72
|
-
await adapter.requestDevice();
|
|
73
|
-
}
|
|
57
|
+
const adapter = await navigator.gpu.requestAdapter();
|
|
58
|
+
await adapter.requestDevice();
|
|
74
59
|
} catch (err) {
|
|
75
60
|
// if glfw fails or the symbols exist but webgpu hasn't been
|
|
76
61
|
// properly enabled (mozilla)
|
|
@@ -119,7 +104,7 @@ self.wrapScriptLoading({ scriptName: 'calculate-capabilities' }, function calcul
|
|
|
119
104
|
}
|
|
120
105
|
|
|
121
106
|
if(eval(testCode)(1) !== 1)
|
|
122
|
-
useStrict = false;
|
|
107
|
+
useStrict = false;
|
|
123
108
|
|
|
124
109
|
return {
|
|
125
110
|
engine: {
|
package/package.json
CHANGED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file libexec/sandbox/webgpu-worker-environment.js
|
|
3
|
-
* @author Dominic Cerisano, dcerisano@kingsds.network
|
|
4
|
-
* @date May 2020
|
|
5
|
-
* @author Jason Erb, jason@kingsds.network
|
|
6
|
-
* @date February 2022
|
|
7
|
-
* @note Adapted from:
|
|
8
|
-
* https://github.com/Kings-Distributed-Systems/webgpu/blob/dcp/release/index.js
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
self.wrapScriptLoading({ scriptName: 'webgpu-evaluator' }, function webGpuWorkerEnvironment$$fn(protectedStorage, postMessage)
|
|
12
|
-
{
|
|
13
|
-
if (typeof GPU !== 'undefined') {
|
|
14
|
-
try {
|
|
15
|
-
if (typeof self.navigator === 'undefined')
|
|
16
|
-
{
|
|
17
|
-
self.navigator = {};
|
|
18
|
-
protectedStorage.createdNewNavigator = true;
|
|
19
|
-
}
|
|
20
|
-
self.navigator.gpu = GPU;
|
|
21
|
-
|
|
22
|
-
{
|
|
23
|
-
let devices = [];
|
|
24
|
-
|
|
25
|
-
//Timeouts for polyfills
|
|
26
|
-
//Negative numbers to signal clamping override in evaluator engine.
|
|
27
|
-
//nextTickTimeout is for process.nextTick() polyfill
|
|
28
|
-
//immediateTimeout is for setImmediate() polyfill
|
|
29
|
-
|
|
30
|
-
self.nextTickTimeout = -0;
|
|
31
|
-
self.immediateTimeout = -0;
|
|
32
|
-
|
|
33
|
-
function deviceTick()
|
|
34
|
-
{
|
|
35
|
-
if (devices) {
|
|
36
|
-
for (let ii = 0; ii < devices.length; ++ii) {
|
|
37
|
-
devices[ii].tick();
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
self.setTimeout(deviceTick, self.nextTickTimeout);
|
|
43
|
-
|
|
44
|
-
GPUAdapter.prototype.requestDevice = function() {
|
|
45
|
-
let args = arguments;
|
|
46
|
-
|
|
47
|
-
return new Promise((resolve, reject) => {
|
|
48
|
-
this._requestDevice(...args).then(device => {
|
|
49
|
-
device._onErrorCallback = function(type, msg) {
|
|
50
|
-
//Polyfill for process.nextTick
|
|
51
|
-
self.setTimeout(() => {
|
|
52
|
-
switch (type) {
|
|
53
|
-
case "Error": throw new Error(msg);
|
|
54
|
-
case "Type": throw new TypeError(msg);
|
|
55
|
-
case "Range": throw new RangeError(msg);
|
|
56
|
-
case "Reference": throw new ReferenceError(msg);
|
|
57
|
-
case "Internal": throw new InternalError(msg);
|
|
58
|
-
case "Syntax": throw new SyntaxError(msg);
|
|
59
|
-
default: throw new Error(msg);
|
|
60
|
-
};
|
|
61
|
-
}, self.immediateTimeout);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
devices.push(device);
|
|
65
|
-
resolve(device);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
//Return a promise instead of a callback
|
|
72
|
-
|
|
73
|
-
GPUFence.prototype.onCompletion = function(completionValue) {
|
|
74
|
-
return new Promise(resolve => {
|
|
75
|
-
//Polyfill for setImmediate
|
|
76
|
-
self.setTimeout(() => {
|
|
77
|
-
this._onCompletion(completionValue, resolve);
|
|
78
|
-
}, self.immediateTimeout);
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
GPUBuffer.prototype.mapReadAsync = function() {
|
|
83
|
-
return new Promise(resolve => {
|
|
84
|
-
//Polyfill for setImmediate
|
|
85
|
-
self.setTimeout(() => {
|
|
86
|
-
this._mapReadAsync(resolve);
|
|
87
|
-
}, self.immediateTimeout);
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
GPUBuffer.prototype.mapWriteAsync = function() {
|
|
92
|
-
return new Promise(resolve => {
|
|
93
|
-
//Polyfill for setImmediate
|
|
94
|
-
self.setTimeout(() => {
|
|
95
|
-
this._mapWriteAsync(resolve);
|
|
96
|
-
}, self.immediateTimeout);
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
GPUDevice.prototype.createBufferMappedAsync = function(descriptor) {
|
|
101
|
-
return new Promise(resolve => {
|
|
102
|
-
//Polyfill for setImmediate
|
|
103
|
-
self.setTimeout(() => {
|
|
104
|
-
this._createBufferMappedAsync(descriptor, resolve);
|
|
105
|
-
}, self.immediateTimeout);
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
GPUDevice.prototype.createBufferMapped = function(descriptor) {
|
|
110
|
-
return new Promise(resolve => {
|
|
111
|
-
//Polyfill for setImmediate
|
|
112
|
-
self.setTimeout(() => {
|
|
113
|
-
this._createBufferMapped(descriptor, resolve);
|
|
114
|
-
}, self.immediateTimeout);
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
} catch (err) {
|
|
119
|
-
console.log("ERROR: ", err);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
});
|
package/portal-emails.txt
DELETED
|
File without changes
|