dcp-client 4.3.1 → 4.3.2-webgpu.1

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.
@@ -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 {Set} blockList - An object of property names mapping to booleans to indicate whether access is allowed or not.
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 = {}, polyfills = {}) {
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
- } else {
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
- * this list through the objects entire prototype chain
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 {Set} polyfills - An object of property names to create/polyfill
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; o.__proto__ && (o.__proto__ !== Object); o = o.__proto__) {
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.__proto__, and global.__proto__.__proto__,
752
- // because there's networking-accessing functions inside global.__proto__.__proto__, like fetch.
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: _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
 
@@ -83,9 +83,14 @@
83
83
  result: "success",
84
84
  });
85
85
 
86
- if (options.finalScript)
86
+ if (options.finalScript) {
87
87
  delete self.wrapScriptLoading;
88
88
 
89
+ // The 'sandboxLoaded' event is used by dcp-native; do not remove.
90
+ ring0PostMessage({
91
+ request: 'sandboxLoaded', // SAVE
92
+ })
93
+ }
89
94
  } catch (e) {
90
95
  ring0PostMessage({
91
96
  request: 'scriptLoaded',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dcp-client",
3
- "version": "4.3.1",
3
+ "version": "4.3.2-webgpu.1",
4
4
  "description": "Core libraries for accessing DCP network",
5
5
  "keywords": [
6
6
  "dcp"
@@ -50,7 +50,6 @@
50
50
  },
51
51
  "devDependencies": {
52
52
  "@kingsds/eslint-config": "1.0.1",
53
- "@techdocs/cli": "1.4.6",
54
53
  "eslint": "7.30.0",
55
54
  "express": "^4.18.2",
56
55
  "peter": "^2.3.11"
@@ -1,74 +0,0 @@
1
- #! /usr/bin/env bash
2
- #
3
- # @file publish-docs.sh
4
- # @athor Brandon Christie <brandon@distributive.network>
5
- # @date Aug 2023
6
- #
7
- # @description Publishes the docs for each component
8
- # to backstage.
9
-
10
- set -euo pipefail
11
-
12
- cd "$(dirname "$0")/.."
13
-
14
- ROOT_DIR=$PWD
15
-
16
- echo "TechDocs Bucket Name: $TECHDOCS_S3_BUCKET_NAME"
17
- echo "Namespace: $ENTITY_NAMESPACE"
18
-
19
- ENTITY_KIND=$(yq ".kind" < catalog-info.yaml)
20
- echo "Kind: $ENTITY_KIND"
21
-
22
- ENTITY_NAME=$(yq ".metadata.name" < catalog-info.yaml)
23
- echo "Name: $ENTITY_NAME"
24
-
25
- TECHDOCS_REF=$(yq ".metadata.annotations.\"backstage.io/techdocs-ref\"" < catalog-info.yaml)
26
- echo "TechDocs Ref: $TECHDOCS_REF"
27
-
28
- # An example of the the techdocs-ref in the YAML file:
29
- # dir:./docs/dcp
30
- #
31
- # The Regex below will isolate the directory path giving the
32
- # result 'docs/dcp' for the given example.
33
- if [[ "$TECHDOCS_REF" =~ dir:\.(.*) ]]; then
34
- RELATIVE_DOCS_DIR="${BASH_REMATCH[1]%%[[:space:]]*}"
35
- DOCS_DIR="$ROOT_DIR/$RELATIVE_DOCS_DIR"
36
- fi
37
-
38
- # The techdocs-cli commands must be called in the directory where the
39
- # mkdocs.yml file is present.
40
- cd "$DOCS_DIR"
41
-
42
- # MkDocs requires an index.md or README.md file, if one does not exist it will
43
- # be generated automatically.
44
- if ! [ -f index.md ] && ! [ -f README.md ]; then
45
- if [ -z "$CI" ]; then
46
- AUTHOR="$(git config user.name) <$(git config user.email)>"
47
- else
48
- AUTHOR="$CI_COMMIT_AUTHOR"
49
- fi
50
-
51
- echo "README.md or index.md was not found and will be automatically generated."
52
- cat >> index.md <<EOF
53
- <!--
54
- @author $AUTHOR
55
- @date $(date)
56
- @machine $HOSTNAME
57
- @rev $(git rev-parse HEAD)
58
- -->
59
- > **Warning**: MkDocs requires a top level index.md or README.md (case sensitive)
60
- This index.md file has been generated automatically to ensure MkDocs works correctly
61
- EOF
62
- fi
63
-
64
- npx techdocs-cli generate --no-docker --verbose
65
-
66
- npx techdocs-cli publish \
67
- --publisher-type awsS3 \
68
- --storage-name "$TECHDOCS_S3_BUCKET_NAME" \
69
- --entity "$ENTITY_NAMESPACE"/"$ENTITY_KIND"/"$ENTITY_NAME" \
70
- --directory "$ROOT_DIR"/site
71
-
72
- rm -r "$ROOT_DIR"/site
73
-
74
- echo "View generated component: https://backstage.overwatch.distributive.network/docs/default/component/$ENTITY_NAME"
package/catalog-info.yaml DELETED
@@ -1,21 +0,0 @@
1
- # @file catalog-info.yml
2
- # @author Brandon Christie <brandon@distributive.network>
3
- # @date Mar 2023
4
- #
5
- # @description Lists all of the components and the paths to all
6
- # the documentation that will be published to backstage.
7
-
8
- apiVersion: backstage.io/v1alpha1
9
- kind: Component
10
- metadata:
11
- name: dcp-client
12
- description: Documentation for the dcp-client.
13
- tags:
14
- - documentation
15
- annotations:
16
- gitlab.com/project-id: '9874684'
17
- backstage.io/techdocs-ref: dir:./docs
18
- spec:
19
- type: library
20
- lifecycle: production
21
- owner: core
package/docs/mkdocs.yml DELETED
@@ -1,16 +0,0 @@
1
- # @file mkdocs.yml
2
- # @author Brandon Christie <brandon@distributive.network>
3
- # @date Aug 2023
4
- #
5
- # @description Determines how the component of name: 'dcp-client'
6
- # is formatted on backstage.
7
-
8
- site_name: dcp-client
9
- repo_url: https://gitlab.com/Distributed-Compute-Protocol/dcp-client
10
- edit_uri: edit/develop/docs
11
- docs_dir: .
12
- nav:
13
- - README.md
14
- plugins:
15
- - techdocs-core
16
- - same-dir
package/portal-emails.txt DELETED
File without changes