@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,165 @@
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
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
+ if (ar || !(i in from)) {
41
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
+ ar[i] = from[i];
43
+ }
44
+ }
45
+ return to.concat(ar || Array.prototype.slice.call(from));
46
+ };
47
+ var path = require("path");
48
+ var fs = require("fs");
49
+ var setupUtils_1 = require("./cli/setupUtils");
50
+ var mock_catalyst_1 = require("./cli/mock-catalyst");
51
+ var wearables_1 = require("./cli/wearables");
52
+ var schemas_1 = require("@dcl/schemas");
53
+ var setupProxy = function (dcl, app) {
54
+ // first resolve all dependencies in the local current working directory
55
+ // second try to resolve dependencies in @dcl/sdk folder
56
+ /**
57
+ * to test locally with linked packages:
58
+ *
59
+ * 1. go to explorer/kernel/static and run `npm link`
60
+ * 2. in an empty folder create a test scene with `dcl init`
61
+ * 3. in that folder run `npm install folder-to/@dcl/sdk`
62
+ * 4. install whatever version of `@dcl/unity-renderer` you want to test
63
+ * 5. link kernel using `npm link @dcll/kernel` this will use the folder from step 1
64
+ */
65
+ var ecsPath = path.dirname(require.resolve('@dcl/sdk/package.json', {
66
+ paths: [
67
+ dcl.getWorkingDir(),
68
+ __dirname + '/../../',
69
+ __dirname + '/../../../',
70
+ __dirname + '/../'
71
+ ]
72
+ }));
73
+ var dclKernelPath = path.dirname(require.resolve('@dcl/kernel/package.json', {
74
+ paths: [dcl.getWorkingDir(), ecsPath]
75
+ }));
76
+ var dclKernelDefaultProfilePath = path.resolve(dclKernelPath, 'default-profile');
77
+ var dclKernelImagesDecentralandConnect = path.resolve(dclKernelPath, 'images', 'decentraland-connect');
78
+ var dclKernelLoaderPath = path.resolve(dclKernelPath, 'loader');
79
+ var dclUnityRenderer = path.dirname(require.resolve('@dcl/unity-renderer/package.json', {
80
+ paths: [dcl.getWorkingDir(), ecsPath]
81
+ }));
82
+ var baseSceneFolders = [dcl.getWorkingDir()];
83
+ var baseWearableFolders = [dcl.getWorkingDir()];
84
+ // TODO: merge types from github.com/decentraland/cli
85
+ if (dcl.workspace) {
86
+ var projects = dcl.workspace.getAllProjects();
87
+ if (!!(projects === null || projects === void 0 ? void 0 : projects.length)) {
88
+ var _a = projects.reduce(function (acc, project) {
89
+ var projectType = project.getInfo().sceneType;
90
+ var projectDir = project.getProjectWorkingDir();
91
+ if (projectType === schemas_1.sdk.ProjectType.SCENE ||
92
+ projectType === schemas_1.sdk.ProjectType.SMART_ITEM)
93
+ acc.scenes.push(projectDir);
94
+ if (projectType === schemas_1.sdk.ProjectType.PORTABLE_EXPERIENCE)
95
+ acc.wearables.push(projectDir);
96
+ return acc;
97
+ }, { wearables: [], scenes: [] }), wearables = _a.wearables, scenes = _a.scenes;
98
+ baseSceneFolders = scenes;
99
+ baseWearableFolders = wearables;
100
+ }
101
+ }
102
+ try {
103
+ (0, mock_catalyst_1.mockCatalyst)(app, __spreadArray(__spreadArray([], baseSceneFolders, true), baseWearableFolders, true));
104
+ }
105
+ catch (err) {
106
+ console.error("Fatal error, couldn't mock the catalyst", err);
107
+ }
108
+ try {
109
+ (0, wearables_1.mockPreviewWearables)(app, baseWearableFolders);
110
+ }
111
+ catch (err) {
112
+ console.error("Fatal error, couldn't mock the wearables", err);
113
+ }
114
+ var routes = [
115
+ {
116
+ route: '/',
117
+ path: path.resolve(dclKernelPath, 'preview.html'),
118
+ type: 'text/html'
119
+ },
120
+ {
121
+ route: '/favicon.ico',
122
+ path: path.resolve(dclKernelPath, 'favicon.ico'),
123
+ type: 'text/html'
124
+ },
125
+ {
126
+ route: '/@/artifacts/index.js',
127
+ path: path.resolve(dclKernelPath, 'index.js'),
128
+ type: 'text/javascript'
129
+ }
130
+ ];
131
+ var _loop_1 = function (route) {
132
+ app.get(route.route, function (req, res) { return __awaiter(void 0, void 0, void 0, function () {
133
+ var contentFile;
134
+ return __generator(this, function (_a) {
135
+ res.setHeader('Content-Type', route.type);
136
+ contentFile = fs.readFileSync(route.path);
137
+ res.send(contentFile);
138
+ return [2 /*return*/];
139
+ });
140
+ }); });
141
+ };
142
+ for (var _i = 0, routes_1 = routes; _i < routes_1.length; _i++) {
143
+ var route = routes_1[_i];
144
+ _loop_1(route);
145
+ }
146
+ (0, setupUtils_1.createStaticRoutes)(app, '/images/decentraland-connect/*', dclKernelImagesDecentralandConnect);
147
+ (0, setupUtils_1.createStaticRoutes)(app, '/@/artifacts/unity-renderer/*', dclUnityRenderer, function (filePath) { return filePath.replace(/.br+$/, ''); });
148
+ (0, setupUtils_1.createStaticRoutes)(app, '/@/artifacts/loader/*', dclKernelLoaderPath);
149
+ (0, setupUtils_1.createStaticRoutes)(app, '/default-profile/*', dclKernelDefaultProfilePath);
150
+ app.get('/feature-flags/:file', function (req, res) { return __awaiter(void 0, void 0, void 0, function () {
151
+ var featureFlagResponse, featureFlagBody;
152
+ return __generator(this, function (_a) {
153
+ switch (_a.label) {
154
+ case 0: return [4 /*yield*/, fetch("https://feature-flags.decentraland.zone/" + req.params.file)];
155
+ case 1:
156
+ featureFlagResponse = _a.sent();
157
+ return [4 /*yield*/, featureFlagResponse.json()];
158
+ case 2:
159
+ featureFlagBody = _a.sent();
160
+ return [2 /*return*/, res.json(featureFlagBody)];
161
+ }
162
+ });
163
+ }); });
164
+ };
165
+ module.exports = setupProxy;
@@ -0,0 +1,7 @@
1
+ declare module '@decentraland/CommunicationsController' {
2
+ /**
3
+ * Send the comms transmission
4
+ * @param message
5
+ */
6
+ export function send(message: string): Promise<void>
7
+ }
@@ -0,0 +1,45 @@
1
+ declare module '@decentraland/EnvironmentAPI' {
2
+ export type Realm = {
3
+ domain: string
4
+ /** @deprecated use room instead */
5
+ layer: string
6
+ room: string
7
+ serverName: string
8
+ displayName: string
9
+ }
10
+
11
+ export type ExplorerConfiguration = {
12
+ clientUri: string
13
+ configurations: Record<string, string | number | boolean>
14
+ }
15
+
16
+ export const enum Platform {
17
+ DESKTOP = 'desktop',
18
+ BROWSER = 'browser'
19
+ }
20
+
21
+ /**
22
+ * Returns the current connected realm
23
+ */
24
+ export function getCurrentRealm(): Promise<Realm | undefined>
25
+
26
+ /**
27
+ * Returns whether the scene is running in preview mode or not
28
+ */
29
+ export function isPreviewMode(): Promise<boolean>
30
+
31
+ /**
32
+ * Returns explorer configuration and environment information
33
+ */
34
+ export function getExplorerConfiguration(): Promise<ExplorerConfiguration>
35
+
36
+ /**
37
+ * Returns what platform is running the scene
38
+ */
39
+ export function getPlatform(): Promise<Platform>
40
+
41
+ /**
42
+ * Returns Decentraland's time
43
+ */
44
+ export function getDecentralandTime(): Promise<{ seconds: number }>
45
+ }
@@ -0,0 +1,47 @@
1
+ declare module '@decentraland/EthereumController' {
2
+ export type RPCSendableMessage = {
3
+ jsonrpc: '2.0'
4
+ id: number
5
+ method: string
6
+ params: any[]
7
+ }
8
+
9
+ export interface MessageDict {
10
+ [key: string]: string
11
+ }
12
+
13
+ /**
14
+ * Requires a generic payment in ETH or ERC20.
15
+ * @param {string} [toAddress] - NFT asset id.
16
+ * @param {number} [amount] - Exact amount of the order.
17
+ * @param {string} [currency] - ETH or ERC20 supported token symbol
18
+ */
19
+ export function requirePayment(toAddress: string, amount: number, currency: string): Promise<any>
20
+
21
+ /**
22
+ * Takes a dictionary, converts it to string with correct format and signs it.
23
+ * @param {messageToSign} [MessageDict] - Message in an object format.
24
+ * @return {object} - Promise of message and signature in an object.
25
+ */
26
+ export function signMessage(
27
+ message: MessageDict
28
+ ): Promise<{ message: string; hexEncodedMessage: string; signature: string }>
29
+
30
+ /**
31
+ * Takes a message string, parses it and converts to object.
32
+ * @param {message} [string] - Message in a string format.
33
+ * @return {object} - Promise of message as a MessageDict.
34
+ * @internal
35
+ */
36
+ export function convertMessageToObject(message: string): Promise<MessageDict>
37
+
38
+ /**
39
+ * Used to build a Ethereum provider
40
+ */
41
+ export function sendAsync(message: RPCSendableMessage): Promise<any>
42
+
43
+ /**
44
+ * Returns the user's public key (address)
45
+ */
46
+ export function getUserAccount(): Promise<string>
47
+ }
@@ -0,0 +1,42 @@
1
+ declare module '@decentraland/Identity' {
2
+ export type ColorString = string
3
+
4
+ export type Snapshots = {
5
+ // @deprecated
6
+ face: string
7
+ // @deprecated
8
+ face256: string
9
+ // @deprecated
10
+ face128: string
11
+ // @deprecated
12
+ body: string
13
+ }
14
+
15
+ export type AvatarForUserData = {
16
+ bodyShape: WearableId
17
+ skinColor: ColorString
18
+ hairColor: ColorString
19
+ eyeColor: ColorString
20
+ wearables: WearableId[]
21
+ snapshots: Snapshots
22
+ }
23
+
24
+ export type UserData = {
25
+ displayName: string
26
+ publicKey: string | null
27
+ hasConnectedWeb3: boolean
28
+ userId: string
29
+ version: number
30
+ avatar: AvatarForUserData
31
+ }
32
+
33
+ /**
34
+ * Return the Ethereum address of the user
35
+ */
36
+ export function getUserPublicKey(): Promise<string | null>
37
+
38
+ /**
39
+ * Return the user's data
40
+ */
41
+ export function getUserData(): Promise<UserData | null>
42
+ }
@@ -0,0 +1,49 @@
1
+ declare module '@decentraland/ParcelIdentity' {
2
+
3
+ export type ILand = {
4
+ sceneJsonData: SceneJsonData
5
+ }
6
+
7
+ export type SceneJsonData = {
8
+ display?: SceneDisplay
9
+ owner?: string
10
+ contact?: SceneContact
11
+ tags?: string[]
12
+ scene: SceneParcels
13
+ spawnPoints?: SceneSpawnPoint[]
14
+ requiredPermissions?: string[]
15
+ }
16
+
17
+ export type SceneDisplay = {
18
+ title?: string
19
+ favicon?: string
20
+ description?: string
21
+ navmapThumbnail?: string
22
+ }
23
+
24
+ export type SceneContact = {
25
+ name?: string
26
+ email?: string
27
+ url?: string
28
+ }
29
+
30
+ export type SceneParcels = {
31
+ base: string
32
+ parcels: string[]
33
+ }
34
+
35
+ export type SceneSpawnPoint = {
36
+ name?: string
37
+ position: {
38
+ x: number | number[]
39
+ y: number | number[]
40
+ z: number | number[]
41
+ }
42
+ default?: boolean
43
+ }
44
+
45
+ /**
46
+ * Returns the current parcel data
47
+ */
48
+ export function getParcel(): Promise<{ land: ILand; cid: string }>
49
+ }
@@ -0,0 +1,47 @@
1
+ declare module '@decentraland/Players' {
2
+ export type ColorString = string
3
+
4
+ export type Snapshots = {
5
+ // @deprecated
6
+ face: string
7
+ // @deprecated
8
+ face256: string
9
+ // @deprecated
10
+ face128: string
11
+ // @deprecated
12
+ body: string
13
+ }
14
+
15
+ export type AvatarForUserData = {
16
+ bodyShape: WearableId
17
+ skinColor: ColorString
18
+ hairColor: ColorString
19
+ eyeColor: ColorString
20
+ wearables: WearableId[]
21
+ snapshots: Snapshots
22
+ }
23
+
24
+ export type UserData = {
25
+ displayName: string
26
+ publicKey: string | null
27
+ hasConnectedWeb3: boolean
28
+ userId: string
29
+ version: number
30
+ avatar: AvatarForUserData
31
+ }
32
+
33
+ /**
34
+ * Return the players's data
35
+ */
36
+ export function getPlayerData(opt: { userId: string }): Promise<UserData | null>
37
+
38
+ /**
39
+ * Return array of connected players
40
+ */
41
+ export function getConnectedPlayers(): Promise<{ userId: string }[]>
42
+
43
+ /**
44
+ * Return array of players inside the scene
45
+ */
46
+ export function getPlayersInScene(): Promise<{ userId: string }[]>
47
+ }
@@ -0,0 +1,39 @@
1
+ declare module '@decentraland/PortableExperiences' {
2
+ type PortableExperienceUrn = string
3
+ type PortableExperienceHandle = {
4
+ pid: PortableExperienceUrn
5
+ parentCid: string // Identifier of who triggered the PE to allow to kill it only to who created it
6
+ }
7
+ type PortableExperienceLoaded = {
8
+ portableExperiences: PortableExperienceHandle[]
9
+ }
10
+
11
+ /**
12
+ * Starts a portable experience.
13
+ * @param {SpawnPortableExperienceParameters} [pid] - Information to identify the PE
14
+ *
15
+ * Returns the handle of the portable experience.
16
+ */
17
+ export function spawn(pid: PortableExperienceUrn): Promise<PortableExperienceHandle>
18
+
19
+ /**
20
+ * Stops a portable experience. Only the executor that spawned the portable experience has permission to kill it.
21
+ * @param {string} [pid] - The portable experience process id
22
+ *
23
+ * Returns true if was able to kill the portable experience, false if not.
24
+ */
25
+ export function kill(pid: PortableExperienceUrn): Promise<boolean>
26
+
27
+ /**
28
+ * Stops a portable experience from the current running portable scene.
29
+ *
30
+ * Returns true if was able to kill the portable experience, false if not.
31
+ */
32
+ export function exit(): Promise<boolean>
33
+
34
+ /**
35
+ *
36
+ * Returns current portable experiences loaded with ids and parentCid
37
+ */
38
+ export function getPortableExperiencesLoaded(): Promise<PortableExperienceLoaded>
39
+ }
@@ -0,0 +1,41 @@
1
+ declare module '@decentraland/RestrictedActions' {
2
+ /**
3
+ * move player to a position inside the scene
4
+ *
5
+ * @param position PositionType
6
+ * @param cameraTarget PositionType
7
+ */
8
+ export function movePlayerTo(newPosition: PositionType, cameraTarget?: PositionType): Promise<void>
9
+
10
+ export type PositionType = { x: number; y: number; z: number }
11
+
12
+ /**
13
+ * trigger an emote on the current player
14
+ *
15
+ * @param emote the emote to perform
16
+ */
17
+ export function triggerEmote(emote: Emote): Promise<void>
18
+
19
+ export type Emote = {
20
+ predefined: PredefinedEmote
21
+ }
22
+
23
+ export const enum PredefinedEmote {
24
+ WAVE = 'wave',
25
+ FIST_PUMP = 'fistpump',
26
+ ROBOT = 'robot',
27
+ RAISE_HAND = 'raiseHand',
28
+ CLAP = 'clap',
29
+ MONEY = 'money',
30
+ KISS = 'kiss',
31
+ TIK = 'tik',
32
+ HAMMER = 'hammer',
33
+ TEKTONIK = 'tektonik',
34
+ DONT_SEE = 'dontsee',
35
+ HANDS_AIR = 'handsair',
36
+ SHRUG = 'shrug',
37
+ DISCO = 'disco',
38
+ DAB = 'dab',
39
+ HEAD_EXPLODDE = 'headexplode'
40
+ }
41
+ }
@@ -0,0 +1,16 @@
1
+ declare module '@decentraland/SignedFetch' {
2
+ export type FlatFetchResponse = {
3
+ ok: boolean
4
+ status: number
5
+ statusText: string
6
+ headers: Record<string, string>
7
+ json?: any
8
+ text?: string
9
+ }
10
+
11
+ export type BodyType = 'json' | 'text'
12
+
13
+ export type FlatFetchInit = RequestInit & { responseBodyType?: BodyType }
14
+
15
+ export function signedFetch(url: string, init?: FlatFetchInit): Promise<FlatFetchResponse>
16
+ }
@@ -0,0 +1 @@
1
+ declare module '@decentraland/SocialController'
@@ -0,0 +1,7 @@
1
+ declare module '@decentraland/web3-provider' {
2
+ export type Provider = {
3
+ send: Function
4
+ sendAsync: Function
5
+ }
6
+ export function getProvider(): Promise<Provider>
7
+ }