dcp-client 4.2.9 → 4.2.12

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.
@@ -0,0 +1,12 @@
1
+ # @file CODEOWNERS - Defines who develops and maintains a feature, and own
2
+ # the resulting files or directories in the repository.
3
+ #
4
+ # See https://docs.gitlab.com/ee/user/project/code_owners.html
5
+ #
6
+ # @author Bryan Hoang <bryan@distributive.network>
7
+ # @date August 2022
8
+
9
+ # Username mapping:
10
+ # @wesgarland -> Wes Garland <wes@distributive.network>
11
+
12
+ * @wesgarland
@@ -1 +1 @@
1
- {"browser":["deny-node","kvin/kvin.js","script-load-wrapper","wrap-event-listeners","event-loop-virtualization","gpu-timers","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","event-loop-virtualization","gpu-timers","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","event-loop-virtualization","webgpu-worker-environment","gpu-timers","access-lists","bravojs-init","bravojs/bravo.js","bravojs-env","calculate-capabilities","bootstrap"],"webGpuNative":["deny-node","kvin/kvin.js","bootstrap"],"nodeTesting":["kvin/kvin.js","sa-ww-simulation","script-load-wrapper","wrap-event-listeners","event-loop-virtualization","gpu-timers","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","event-loop-virtualization","webgpu-worker-environment","gpu-timers","access-lists","bravojs-init","bravojs/bravo.js","bravojs-env","calculate-capabilities","bootstrap","testing.js"]}
1
+ {"browser":["deny-node","kvin/kvin.js","script-load-wrapper","wrap-event-listeners","event-loop-virtualization","gpu-timers","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","event-loop-virtualization","gpu-timers","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","event-loop-virtualization","gpu-timers","access-lists","bravojs-init","bravojs/bravo.js","bravojs-env","calculate-capabilities","bootstrap"],"webGpuNative":["deny-node","kvin/kvin.js","sa-ww-simulation","script-load-wrapper","native-event-loop","wrap-event-listeners","event-loop-virtualization","webgpu-worker-environment","gpu-timers","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","event-loop-virtualization","gpu-timers","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","event-loop-virtualization","gpu-timers","access-lists","bravojs-init","bravojs/bravo.js","bravojs-env","calculate-capabilities","bootstrap","testing.js"]}
package/index.js CHANGED
@@ -33,6 +33,7 @@ const kvin = require('kvin');
33
33
  const moduleSystem = require('module');
34
34
  const { spawnSync } = require('child_process');
35
35
  const vm = require('vm');
36
+ const protectedDcpConfigKeys = [ 'system' ];
36
37
 
37
38
  exports.debug = false;
38
39
  let initInvoked = false; /* flag to help us detect use of Compute API before init */
@@ -96,6 +97,7 @@ const bundleSandbox = {
96
97
  setImmediate, clearImmediate,
97
98
  crypto: { getRandomValues: require('polyfill-crypto.getrandomvalues') },
98
99
  dcpConfig: {
100
+ build: 'bootstrap',
99
101
  bundleConfig: true,
100
102
  scheduler: {},
101
103
  bank: {
@@ -466,7 +468,11 @@ function addConfigFile(existing /*, file path components ... */) {
466
468
  * becomes the neo config.
467
469
  */
468
470
  async function addConfigRKey(existing, hive, keyTail) {
469
- var neo = await require('./windows-registry').getObject(hive, keyTail);
471
+ var neo;
472
+ // make sure RKey calls do not execute the windows registry calls on non-windows platforms
473
+ if (os.platform() !== 'win32')
474
+ return;
475
+ neo = await require('./windows-registry').getObject(hive, keyTail);
470
476
  debugging() && console.debug(` * Loading configuration from ${hive} ${keyTail}`);
471
477
  if (neo)
472
478
  addConfig(existing, neo);
@@ -485,11 +491,10 @@ function addConfigEnviron(existing, prefix) {
485
491
  continue
486
492
  }
487
493
  if (process.env[v][0] === '{') {
488
- // FIXME(bryan-hoang): fixCase is not defined.
489
494
  let prop = fixCase(v.slice(prefix.length))
490
495
  if (typeof neo[prop] !== 'object') {
491
496
  neo[prop] = {}
492
- addConfig(neo[prop], JSON.parse(process.env[v]))
497
+ addConfig(neo[prop], eval(`"use strict"; (${process.env[v]})`));
493
498
  } else {
494
499
  if (typeof neo[prop] === "object") {
495
500
  throw new Error("Cannot override configuration property " + prop + " with a string (is an object)")
@@ -502,6 +507,18 @@ function addConfigEnviron(existing, prefix) {
502
507
  addConfig(existing, neo);
503
508
  }
504
509
 
510
+ /** Turn UGLY_STRING into uglyString */
511
+ function fixCase(ugly)
512
+ {
513
+ var fixed = ugly.toLowerCase();
514
+ var idx;
515
+
516
+ while ((idx = fixed.indexOf('_')) !== -1)
517
+ fixed = fixed.slice(0, idx) + fixed[idx + 1].toUpperCase() + fixed.slice(idx + 2);
518
+
519
+ return fixed;
520
+ }
521
+
505
522
  /**
506
523
  * Tasks which are run in the early phases of initialization
507
524
  * - plumb in global.XMLHttpRequest which lives forever -- that way KeepAlive etc works.
@@ -606,6 +623,8 @@ function initTail(aggrConfig, finalBundleCode, finalBundleURL) {
606
623
  bundleSandbox.dcpConfig = defaultConfig;
607
624
  }
608
625
 
626
+ bundleSandbox.dcpConfig.build = require('dcp/build').config.build;
627
+
609
628
  Object.defineProperty(exports, 'distDir', {
610
629
  value: function dcpClient$$distDir$getter() {
611
630
  return distDir;
@@ -657,6 +676,7 @@ function initTail(aggrConfig, finalBundleCode, finalBundleURL) {
657
676
  ret = makeInitReturnObject();
658
677
  if (bundle.postInitTailHook) /* for use by auto-update future backwards compat */
659
678
  ret = bundle.postInitTailHook(ret, aggrConfig, bundle, finalBundleLabel, bundleSandbox, injectModule);
679
+ dcpConfig.build = bundleSandbox.dcpConfig.build = require('dcp/build').config.build;
660
680
  return ret;
661
681
  }
662
682
 
@@ -777,16 +797,6 @@ exports.createAggregateConfig = async function dcpClient$$createAggregateConfig(
777
797
  programName = path.basename(programName, '.js');
778
798
  let config = localConfig;
779
799
 
780
- /* This follows spec doc line-by-line */
781
- await addConfigRKey(config, 'HKLM', 'dcp-client/dcp-config');
782
- await addConfigFile(config, etc, 'dcp-client/dcp-config.js');
783
- programName && await addConfigRKey(config, 'HKLM', `dcp-client/${programName}/dcp-config`);
784
- programName && await addConfigFile(config, etc, `dcp-client/${programName}/dcp-config.js`);
785
- await addConfigFile(config, home, '.dcp/dcp-client/dcp-config.js');
786
- programName && await addConfigFile(config, home, `.dcp/dcp-client/${programName}/dcp-config.js`);
787
- await addConfigRKey(config, 'HKCU', `dcp-client/dcp-config`);
788
- programName && await addConfigRKey(config, 'HKCU', `dcp-client/${programName}/dcp-config`);
789
-
790
800
  // Sort out polymorphic arguments: 'passed-in configuration'.
791
801
  if (initArgv[0]) {
792
802
  if (typeof initArgv[0] === 'string' || (typeof initArgv[0] === 'object' && initArgv[0] instanceof global.URL)) {
@@ -806,9 +816,18 @@ exports.createAggregateConfig = async function dcpClient$$createAggregateConfig(
806
816
  if (initArgv[2])
807
817
  addConfig(localConfig.bundle, { location: new URL(initArgv[2])});
808
818
 
809
- await addConfigEnviron(localConfig, 'DCP_CONFIG_');
810
- await addConfigFile(localConfig, etc, `override/dcp-config.js`);
811
- await addConfigRKey(localConfig, 'HKLM', 'override/dcp-config');
819
+ /* This follows spec doc line-by-line */
820
+ await addConfigRKey(config, 'HKLM', 'dcp-client/dcp-config');
821
+ addConfigFile(config, etc, 'dcp/dcp-client/dcp-config.js');
822
+ programName && await addConfigRKey(config, 'HKLM', `dcp-client/${programName}/dcp-config`);
823
+ programName && addConfigFile(config, etc, `dcp/dcp-client/${programName}/dcp-config.js`);
824
+ addConfigFile(config, home, '.dcp/dcp-client/dcp-config.js');
825
+ programName && addConfigFile(config, home, `.dcp/dcp-client/${programName}/dcp-config.js`);
826
+ await addConfigRKey(config, 'HKCU', 'dcp-client/dcp-config');
827
+ programName && await addConfigRKey(config, 'HKCU', `dcp-client/${programName}/dcp-config`);
828
+
829
+ addConfigEnviron(localConfig, 'DCP_CONFIG_');
830
+ addConfigFile(localConfig, etc, 'dcp/override/dcp-config.js');
812
831
  addConfig(aggrConfig, localConfig);
813
832
 
814
833
  /**
@@ -870,6 +889,8 @@ exports.createAggregateConfig = async function dcpClient$$createAggregateConfig(
870
889
  let remoteConfig = {};
871
890
  let newConfig = {};
872
891
  addConfig(remoteConfig, evalStringInSandbox(remoteConfigCode, bundleSandbox, aggrConfig.scheduler.configLocation.href));
892
+ for (let key of protectedDcpConfigKeys)
893
+ delete remoteConfig[key];
873
894
  addConfig(remoteConfig, bundleSandbox.dcpConfig);
874
895
 
875
896
  /* remote config has lower precedence than local modifications, but gets loaded
@@ -366,7 +366,7 @@ function main() {
366
366
  setupErrorHandlers();
367
367
 
368
368
  const argv = require('yargs')
369
- .usage('Node Evaluator - Copyright (c) 2020-2021 Kings Distributed Systems, Ltd. All Rights Reserved.'
369
+ .usage('Node Evaluator - Copyright (c) 2020-2022 Distributive, Ltd. All Rights Reserved.'
370
370
  + 'Usage: dcp-evaluator [options] [<file.js> <file.js> ...]')
371
371
  .options({
372
372
  port: {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @file worker/evaluator-lib/bootstrap.js
3
- * Copyright (c) 2018, Kings Distributed Systems, Ltd. All Rights Reserved.
3
+ * Copyright (c) 2018-2022, Distributive, Ltd. All Rights Reserved.
4
4
  *
5
5
  * Final evaluator bootstrap code for defining functions to be used in the work function.
6
6
  *
@@ -2,7 +2,7 @@
2
2
  * This file extends BravoJS, creating a CommonJS Modules/2.0
3
3
  * environment for WebWorkers and similar environments.
4
4
  *
5
- * Copyright (c) 2018, Kings Distributed Systems, Ltd. All Rights Reserved.
5
+ * Copyright (c) 2018-2022, Distributive, Ltd. All Rights Reserved.
6
6
  * Wes Garland, wes@kingsds.network
7
7
  */
8
8
 
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * @file worker/evaluator-lib/bravojs-init.js
3
- * Copyright (c) 2018, Kings Distributed Systems, Ltd. All Rights Reserved.
3
+ * Copyright (c) 2020-2022, Distributive, Ltd. All Rights Reserved.
4
4
  *
5
- * This file sets up the environment for bravojs to load properly.
5
+ * This file sets up the environment for BravoJS to load properly.
6
6
  *
7
7
  * @author Ryan Rossiter, ryan@kingsds.network
8
8
  * @date Sept 2020
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @file worker/evaluator-lib/calculate-capabilities.js
3
- * Copyright (c) 2018, Kings Distributed Systems, Ltd. All Rights Reserved.
3
+ * Copyright (c) 2020-2022, Distributive. All Rights Reserved.
4
4
  *
5
5
  * This file provides a message handler for handling capabilities requests.
6
6
  *
@@ -20,6 +20,7 @@ self.wrapScriptLoading({ scriptName: 'event-loop-virtualization' }, function eve
20
20
  {
21
21
  (function privateScope(realSetTimeout, realSetInterval, realSetImmediate, realClearTimeout, realClearInterval, realClearImmediate) {
22
22
  let totalCPUTime = 0;
23
+ let startTime;
23
24
  const events = [];
24
25
  events.serial = 0;
25
26
 
@@ -34,7 +35,7 @@ self.wrapScriptLoading({ scriptName: 'event-loop-virtualization' }, function eve
34
35
  serviceEvents.servicing = true;
35
36
  serviceEvents.sliceIsFinished = false;
36
37
 
37
- const startTime = performance.now();
38
+ startTime = performance.now();
38
39
  let now = Date.now();
39
40
 
40
41
  sortEvents();
@@ -72,18 +73,17 @@ self.wrapScriptLoading({ scriptName: 'event-loop-virtualization' }, function eve
72
73
  }
73
74
  }
74
75
  }
76
+ }
77
+ protectedStorage.markCPUTimeAsDone = function markCPUTimeAsDone()
78
+ {
79
+ const endTime = performance.now();
80
+ totalCPUTime += endTime - startTime;
81
+ serviceEvents.sliceIsFinished = true;
82
+ }
75
83
 
76
- protectedStorage.markCPUTimeAsDone = function markCPUTimeAsDone()
77
- {
78
- const endTime = performance.now();
79
- totalCPUTime += endTime - startTime;
80
- serviceEvents.sliceIsFinished = true;
81
- }
82
-
83
- protectedStorage.subtractWebGLTimeFromCPUTime = function subtractCPUTime(time)
84
- {
85
- totalCPUTime -= time;
86
- }
84
+ protectedStorage.subtractWebGLTimeFromCPUTime = function subtractCPUTime(time)
85
+ {
86
+ totalCPUTime -= time;
87
87
  }
88
88
 
89
89
  /** Execute callback after at least timeout ms.
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @file gpu-timers.js
3
- * Copyright (c) 2018, Kings Distributed Systems, Ltd. All Rights Reserved. @todo: is this correct lol?
3
+ * Copyright (c) 2022, Distributive, Ltd.
4
+ * All Rights Reserved. Licensed under the terms of the MIT License.
4
5
  *
5
6
  * This file adds wrappers for webGL and webGPU functions so we can measure their GPU time
6
7
  *
@@ -51,27 +51,29 @@ self.wrapScriptLoading({ scriptName: 'native-event-loop' }, function nativeEvent
51
51
  function fireTimerCallbacks()
52
52
  {
53
53
  sortTimers();
54
- let timer;
55
- while ((timer = timers.shift()))
54
+ let timer = timers.shift();
55
+ let now = Date.now();
56
+ if (!timer)
57
+ throw new Error('Logic error: trying to run timer when no timer exists') /* should be impossible */
58
+ if (timer.when > now) /* should be impossible, but at least we can handle this */
56
59
  {
57
- let now = Date.now();
58
- if (timer.when > now)
59
- {
60
- timers.push(timer);
61
- break;
62
- }
63
- timer.fn.apply(null, timer.args);
60
+ timers.unshift(timer);
61
+ nextTimer(timers[0].when);
62
+ return;
63
+ }
64
+ timer.fn.apply(null, timer.args);
64
65
 
65
- if (timer.recur)
66
- {
67
- timer.when = Date.now() + timer.recur;
68
- timers.push(timer);
69
- }
70
- sortTimers();
66
+ if (timer.recur)
67
+ {
68
+ timer.when = Date.now() + timer.recur;
69
+ timers.push(timer);
71
70
  }
71
+
72
+ sortTimers();
72
73
  if (timers.length)
73
74
  nextTimer(timers[0].when);
74
75
  }
76
+
75
77
  ontimer(fireTimerCallbacks);
76
78
 
77
79
  /** Execute callback after at least timeout ms.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dcp-client",
3
- "version": "4.2.9",
3
+ "version": "4.2.12",
4
4
  "description": "Core libraries for accessing DCP network",
5
5
  "keywords": [
6
6
  "dcp"
@@ -14,9 +14,9 @@
14
14
  "url": "git+ssh://git@github.com/Distributed-Compute-Labs/dcp-client.git"
15
15
  },
16
16
  "license": "MIT",
17
- "author": "Kings Distributed Systems",
17
+ "author": "Distributive",
18
18
  "engines": {
19
- "node": ">=14.0.0"
19
+ "node": ">=14.15.0"
20
20
  },
21
21
  "main": "index.js",
22
22
  "directories": {
@@ -53,7 +53,7 @@
53
53
  "@kingsds/eslint-config": "1.0.1",
54
54
  "eslint": "7.30.0",
55
55
  "express": "^4.17.1",
56
- "peter": "^2.3.2"
56
+ "peter": "^2.3.3"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "dcp-worker": "^3.0.0"
@@ -19,7 +19,7 @@ const machHive = 'HKLM';
19
19
  const userHive = 'HKCU';
20
20
  const regedit = require('regedit');
21
21
 
22
- exports.baseKey = process.env.DCP_REGISTRY_BASEKEY || 'Software\\Kings Distributed Systems\\DCP';
22
+ exports.baseKey = process.env.DCP_REGISTRY_BASEKEY || 'Software\\Distributive\\DCP';
23
23
 
24
24
  /** Join multiple registry keys fragments together into a full path.
25
25
  * @param {string|Array} ...