@dcl/sdk 7.0.0-2536021667.commit-17c845c

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.
Files changed (45) hide show
  1. package/LICENSE +201 -0
  2. package/dist/ecs7/index.d.ts +1721 -0
  3. package/dist/ecs7/index.js +6173 -0
  4. package/dist/ecs7/index.min.js +1 -0
  5. package/dist/ecs7/index.min.js.map +1 -0
  6. package/dist/ecs7/proto-definitions/AudioSource.proto +13 -0
  7. package/dist/ecs7/proto-definitions/AudioStream.proto +10 -0
  8. package/dist/ecs7/proto-definitions/BoxShape.proto +11 -0
  9. package/dist/ecs7/proto-definitions/CylinderShape.proto +12 -0
  10. package/dist/ecs7/proto-definitions/NFTShape.proto +16 -0
  11. package/dist/ecs7/proto-definitions/PlaneShape.proto +11 -0
  12. package/dist/ecs7/proto-definitions/README.md +32 -0
  13. package/dist/ecs7/proto-definitions/SphereShape.proto +10 -0
  14. package/dist/ecs7/proto-definitions/TextShape.proto +33 -0
  15. package/dist/ecs7/proto-definitions/Transform.md +25 -0
  16. package/dist/ecs7/proto-definitions/common/Color3.proto +8 -0
  17. package/dist/ecs7/proto-definitions/common/id.md +2 -0
  18. package/dist/ecs7/proto-definitions/common/id.proto +7 -0
  19. package/package.json +42 -0
  20. package/src/cli/mock-catalyst/index.js +170 -0
  21. package/src/cli/setupUtils.js +345 -0
  22. package/src/cli/wearables.js +145 -0
  23. package/src/setupExport.js +43 -0
  24. package/src/setupProxy.js +165 -0
  25. package/types/@decentraland/CommunicationsController/index.d.ts +7 -0
  26. package/types/@decentraland/EnvironmentAPI/index.d.ts +45 -0
  27. package/types/@decentraland/EthereumController/index.d.ts +47 -0
  28. package/types/@decentraland/Identity/index.d.ts +42 -0
  29. package/types/@decentraland/ParcelIdentity/index.d.ts +49 -0
  30. package/types/@decentraland/Players/index.d.ts +47 -0
  31. package/types/@decentraland/PortableExperiences/index.d.ts +39 -0
  32. package/types/@decentraland/RestrictedActions/index.d.ts +41 -0
  33. package/types/@decentraland/SignedFetch/index.d.ts +16 -0
  34. package/types/@decentraland/SocialController/index.d.ts +1 -0
  35. package/types/@decentraland/web3-provider/index.d.ts +7 -0
  36. package/types/dcl/decentraland-ecs.api.json +61732 -0
  37. package/types/dcl/decentraland-ecs.api.md +2717 -0
  38. package/types/ecs7/index.d.ts +1721 -0
  39. package/types/ecs7-env/es2015.iterable.d.ts +486 -0
  40. package/types/ecs7-env/es2015.symbol.d.ts +46 -0
  41. package/types/ecs7-env/index.d.ts +19 -0
  42. package/types/env/es5.d.ts +4565 -0
  43. package/types/env/index.d.ts +411 -0
  44. package/types/tsconfig.ecs7.json +27 -0
  45. package/types/tsconfig.ecs7.strict.json +13 -0
@@ -0,0 +1,13 @@
1
+ syntax = "proto3";
2
+
3
+ import "common/id.proto";
4
+ option (ecs_component_id) = 1020;
5
+
6
+ message PBAudioSource {
7
+ bool playing = 1;
8
+ float volume = 2;
9
+ bool loop = 3;
10
+ float pitch = 4;
11
+ int32 played_at_timestamp = 5;
12
+ string audio_clip_url = 6;
13
+ }
@@ -0,0 +1,10 @@
1
+ syntax = "proto3";
2
+
3
+ import "common/id.proto";
4
+ option (ecs_component_id) = 1021;
5
+
6
+ message PBAudioStream {
7
+ bool playing = 1;
8
+ float volume = 2;
9
+ string url = 3;
10
+ }
@@ -0,0 +1,11 @@
1
+ syntax = "proto3";
2
+
3
+ import "common/id.proto";
4
+ option (ecs_component_id) = 1013;
5
+
6
+ message PBBoxShape {
7
+ bool with_collisions = 1;
8
+ bool is_pointer_blocker = 2;
9
+ bool visible = 3;
10
+ repeated float uvs = 4;
11
+ }
@@ -0,0 +1,12 @@
1
+ syntax = "proto3";
2
+
3
+ import "common/id.proto";
4
+ option (ecs_component_id) = 1016;
5
+
6
+ message PBCylinderShape {
7
+ bool with_collisions = 1;
8
+ bool is_pointer_blocker = 2;
9
+ bool visible = 3;
10
+ float radius_top = 4;
11
+ float radius_bottom = 5;
12
+ }
@@ -0,0 +1,16 @@
1
+ syntax = "proto3";
2
+
3
+ import "common/id.proto";
4
+ option (ecs_component_id) = 1040;
5
+
6
+ import "common/Color3.proto";
7
+
8
+ message PBNFTShape {
9
+ bool with_collisions = 1;
10
+ bool is_pointer_blocker = 2;
11
+ bool visible = 3;
12
+ string src = 4;
13
+ string asset_id = 5;
14
+ int32 style = 6;
15
+ Color3 color = 7;
16
+ }
@@ -0,0 +1,11 @@
1
+ syntax = "proto3";
2
+
3
+ import "common/id.proto";
4
+ option (ecs_component_id) = 1014;
5
+
6
+ message PBPlaneShape {
7
+ bool with_collisions = 1;
8
+ bool is_pointer_blocker = 2;
9
+ bool visible = 3;
10
+ repeated float uvs = 4;
11
+ }
@@ -0,0 +1,32 @@
1
+ # How to add a new ECS Component with Protocol-Buffers
2
+
3
+ In this directory, we have all the components with the schema `ComponentName.proto`. `ComponentName` has to be PascalCase, and the `.proto` is the extension that is recognized as protocol-buffer schema.
4
+
5
+ Inside each proto, we need to have at least this template:
6
+ ```proto
7
+ syntax = "proto3";
8
+
9
+ import "common/id.proto";
10
+ option (ecs_component_id) = XXXX;
11
+
12
+ message PBComponentName {
13
+ float one_parameter = 1;
14
+ }
15
+
16
+ ```
17
+
18
+ Some points that must be well-defined:
19
+ - `XXXX` the component ID is a super important property of the component, and it has to be unique at least between proto, otherwise, the code generation will fail.
20
+ - `PBComponentName` the root message has to be the same as the file name with the prefix `PB`
21
+ - `one_parameter` each parameter name has to be snake_case.
22
+
23
+
24
+ ## Common directory
25
+ The common directory only has to have unambiguous structures like Vector3, Color3, Quaternion, etc. These messages will never change.
26
+
27
+ ## About specific options with other languages
28
+ The definition must be the minimal proto code, and it shouldn't have a specific option to compile on some platform. So if you have to add additional information to the proto, you will be able to run a post-process after the protocol schemas acquisition.
29
+ For example, in the unity-renderer repo, it'll be necessary to add the `csharp_namespace` option but it's the responsibility of this particular implementation. This code option doesn't define how the component is.
30
+
31
+ # Test component
32
+ If you write a proto and then push, CI will fail because the tests will fail. All the components need to be tested. `@dcl/ecs/test/components` has some examples!
@@ -0,0 +1,10 @@
1
+ syntax = "proto3";
2
+
3
+ import "common/id.proto";
4
+ option (ecs_component_id) = 1015;
5
+
6
+ message PBSphereShape {
7
+ bool with_collisions = 1;
8
+ bool is_pointer_blocker = 2;
9
+ bool visible = 3;
10
+ }
@@ -0,0 +1,33 @@
1
+ syntax = "proto3";
2
+
3
+ import "common/id.proto";
4
+ option (ecs_component_id) = 1030;
5
+
6
+ import "common/Color3.proto";
7
+
8
+ message PBTextShape {
9
+ string text = 1;
10
+ bool visible = 2;
11
+ string font = 3;
12
+ float opacity = 4;
13
+ float font_Size = 5;
14
+ bool font_autoSize = 6;
15
+ string h_text_align = 7;
16
+ string v_text_align = 8;
17
+ float width = 9;
18
+ float height = 10;
19
+ float padding_top = 11;
20
+ float padding_right = 12;
21
+ float padding_bottom = 13;
22
+ float padding_left = 14;
23
+ float line_spacing = 15;
24
+ int32 line_count = 16;
25
+ bool text_wrapping = 17;
26
+ float shadow_blur = 18;
27
+ float shadow_offsetX = 19;
28
+ float shadow_offsetY = 20;
29
+ float outline_width = 21;
30
+ Color3 shadow_color = 22;
31
+ Color3 outline_color = 23;
32
+ Color3 text_color = 24;
33
+ }
@@ -0,0 +1,25 @@
1
+
2
+ # Transform
3
+
4
+ Transform is not a protocol-buffer definition, because it uses the native byte-buffer to write directly on the wire. This allows the consumer to copy the message directly on memory and the component be serialized a little bit faster.
5
+
6
+ ```cpp
7
+ // Transform length = 44
8
+ struct Transform {
9
+ float positionX;
10
+ float positionY;
11
+ float positionZ;
12
+
13
+ float rotationX;
14
+ float rotationY;
15
+ float rotationZ;
16
+ float rotationW;
17
+
18
+ float scaleX;
19
+ float scaleY;
20
+ float scaleZ;
21
+
22
+ uint32_t parentEntity;
23
+ };
24
+ ```
25
+ - Serialized in big-endian
@@ -0,0 +1,8 @@
1
+ syntax = "proto3";
2
+
3
+ message Color3 {
4
+ float r = 1;
5
+ float g = 2;
6
+ float b = 3;
7
+ }
8
+
@@ -0,0 +1,2 @@
1
+ # Why id as file option?
2
+ Extending this option in the component definition allows having the data of its ID in the protocol buffer code generator.
@@ -0,0 +1,7 @@
1
+ syntax = "proto3";
2
+
3
+ import "google/protobuf/descriptor.proto";
4
+
5
+ extend google.protobuf.FileOptions {
6
+ optional int32 ecs_component_id = 50000;
7
+ }
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@dcl/sdk",
3
+ "version": "7.0.0-2536021667.commit-17c845c",
4
+ "description": "",
5
+ "main": "dist/src/index.js",
6
+ "typings": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc -p tsconfig.json",
9
+ "start": "npm run build && tsc -p tsconfig.json --watch"
10
+ },
11
+ "keywords": [],
12
+ "tsdoc": {
13
+ "tsdocFlavor": "AEDoc"
14
+ },
15
+ "author": "Decentraland",
16
+ "license": "Apache-2.0",
17
+ "files": [
18
+ "dist",
19
+ "types",
20
+ "docs",
21
+ "LICENSE",
22
+ "docs-yaml",
23
+ "artifacts",
24
+ "src/setupProxy.js",
25
+ "src/setupExport.js",
26
+ "src/cli/*.js",
27
+ "src/cli/**/*.js"
28
+ ],
29
+ "dependencies": {
30
+ "@dcl/amd": "6.11.2-2536021667.commit-17c845c",
31
+ "@dcl/build-ecs": "6.11.2-2536021667.commit-17c845c",
32
+ "@dcl/kernel": "^1.0.0-2392404250.commit-1b886c4",
33
+ "@dcl/posix": "^1.0.4",
34
+ "@dcl/schemas": "4.8.0",
35
+ "@dcl/unity-renderer": "^1.0.35874-20220512094007.commit-bfb5052",
36
+ "glob": "^7.1.7",
37
+ "http-proxy-middleware": "^2.0.3",
38
+ "ignore": "^5.1.8"
39
+ },
40
+ "minCliVersion": "3.10.2",
41
+ "commit": "17c845c30f5afb411ddc1a12e16f4fad1c94d29e"
42
+ }
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ exports.__esModule = true;
39
+ exports.mockCatalyst = void 0;
40
+ var path = require("path");
41
+ var http_proxy_middleware_1 = require("http-proxy-middleware");
42
+ var setupUtils_1 = require("../setupUtils");
43
+ var wearables_1 = require("../wearables");
44
+ var mockCatalyst = function (app, baseFolders) {
45
+ serveFolders(app, baseFolders);
46
+ app.get('/lambdas/explore/realms', function (req, res) {
47
+ res.json([
48
+ {
49
+ serverName: 'localhost',
50
+ url: "http://" + req.get('host'),
51
+ layer: 'stub',
52
+ usersCount: 0,
53
+ maxUsers: 100,
54
+ userParcels: []
55
+ }
56
+ ]);
57
+ });
58
+ app.get('/lambdas/contracts/servers', function (req, res) {
59
+ res.json([
60
+ {
61
+ address: "http://" + req.get('host'),
62
+ owner: '0x0000000000000000000000000000000000000000',
63
+ id: '0x0000000000000000000000000000000000000000000000000000000000000000'
64
+ }
65
+ ]);
66
+ });
67
+ app.get('/lambdas/profiles', function (req, res, next) { return __awaiter(void 0, void 0, void 0, function () {
68
+ var baseUrl, previewWearables, deployedProfile, err_1;
69
+ var _a;
70
+ return __generator(this, function (_b) {
71
+ switch (_b.label) {
72
+ case 0:
73
+ baseUrl = req.protocol + "://" + req.get('host') + "/content/contents";
74
+ _b.label = 1;
75
+ case 1:
76
+ _b.trys.push([1, 6, , 7]);
77
+ return [4 /*yield*/, (0, wearables_1.getAllPreviewWearables)({
78
+ baseFolders: baseFolders,
79
+ baseUrl: baseUrl
80
+ }).map(function (wearable) { return wearable.id; })];
81
+ case 2:
82
+ previewWearables = _b.sent();
83
+ if (!(previewWearables.length === 1)) return [3 /*break*/, 5];
84
+ return [4 /*yield*/, fetch("https://peer.decentraland.org" + req.originalUrl)];
85
+ case 3: return [4 /*yield*/, (_b.sent()).json()];
86
+ case 4:
87
+ deployedProfile = _b.sent();
88
+ if ((deployedProfile === null || deployedProfile === void 0 ? void 0 : deployedProfile.length) === 1) {
89
+ (_a = deployedProfile[0].avatars[0].avatar.wearables).push.apply(_a, previewWearables);
90
+ return [2 /*return*/, res.json(deployedProfile)];
91
+ }
92
+ _b.label = 5;
93
+ case 5: return [3 /*break*/, 7];
94
+ case 6:
95
+ err_1 = _b.sent();
96
+ console.warn("Failed to catch profile and fill with preview wearables.", err_1);
97
+ return [3 /*break*/, 7];
98
+ case 7: return [2 /*return*/, next()];
99
+ }
100
+ });
101
+ }); });
102
+ // fallback all lambdas to a real catalyst
103
+ app.use('/lambdas', (0, http_proxy_middleware_1.createProxyMiddleware)({
104
+ target: 'https://peer.decentraland.org/',
105
+ changeOrigin: true,
106
+ timeout: 25 * 1000,
107
+ proxyTimeout: 25 * 1000,
108
+ onError: function (err, req_, res) {
109
+ console.warn("Oops, it seems the catalyst isn't working well.");
110
+ res.writeHead(500);
111
+ res.end('');
112
+ }
113
+ }));
114
+ // fallback all lambdas to a real catalyst
115
+ app.use('/content', (0, http_proxy_middleware_1.createProxyMiddleware)({
116
+ target: 'https://peer.decentraland.org/',
117
+ changeOrigin: true,
118
+ timeout: 25 * 1000,
119
+ proxyTimeout: 25 * 1000,
120
+ onError: function (err, req_, res) {
121
+ console.warn("Oops, it seems the content server isn't working well.");
122
+ res.writeHead(500);
123
+ res.end('');
124
+ }
125
+ }));
126
+ };
127
+ exports.mockCatalyst = mockCatalyst;
128
+ var serveFolders = function (app, baseFolders) {
129
+ app.get('/content/contents/:hash', function (req, res, next) {
130
+ if (req.params.hash && req.params.hash.startsWith('b64-')) {
131
+ var fullPath_1 = path.resolve(Buffer.from(req.params.hash.replace(/^b64-/, ''), 'base64').toString('utf8'));
132
+ // only return files IF the file is within a baseFolder
133
+ if (!baseFolders.find(function (folder) { return fullPath_1.startsWith(folder); })) {
134
+ next();
135
+ return;
136
+ }
137
+ var options = {
138
+ dotfiles: 'deny',
139
+ maxAge: 1,
140
+ cacheControl: false,
141
+ lastModified: true,
142
+ headers: {
143
+ 'x-timestamp': Date.now(),
144
+ 'x-sent': true,
145
+ etag: JSON.stringify(Date.now().toString()),
146
+ 'cache-control': 'no-cache,private,max-age=1'
147
+ }
148
+ };
149
+ res.sendFile(fullPath_1, options, function (err) {
150
+ if (err) {
151
+ next(err);
152
+ }
153
+ });
154
+ }
155
+ });
156
+ app.get('/content/entities/scene', function (req, res) {
157
+ if (!req.query.pointer) {
158
+ res.json([]);
159
+ return;
160
+ }
161
+ var requestedPointers = new Set(req.query.pointer && typeof req.query.pointer === 'string'
162
+ ? [req.query.pointer]
163
+ : req.query.pointer);
164
+ var resultEntities = (0, setupUtils_1.getSceneJson)({
165
+ baseFolders: baseFolders,
166
+ pointers: Array.from(requestedPointers)
167
+ });
168
+ res.json(resultEntities).end();
169
+ });
170
+ };