decentrand 3.21.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +201 -0
- package/README.md +56 -0
- package/abi/EstateRegistry.json +1226 -0
- package/abi/LANDRegistry.json +1372 -0
- package/abi/MANAToken.json +410 -0
- package/dist/commands/build.d.ts +3 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +108 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/coords.d.ts +3 -0
- package/dist/commands/coords.d.ts.map +1 -0
- package/dist/commands/coords.js +122 -0
- package/dist/commands/coords.js.map +1 -0
- package/dist/commands/deploy.d.ts +4 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +280 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/export.d.ts +3 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +20 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +19 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/info.d.ts +3 -0
- package/dist/commands/info.d.ts.map +1 -0
- package/dist/commands/info.js +186 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/init/help.d.ts +12 -0
- package/dist/commands/init/help.d.ts.map +1 -0
- package/dist/commands/init/help.js +41 -0
- package/dist/commands/init/help.js.map +1 -0
- package/dist/commands/init/index.d.ts +3 -0
- package/dist/commands/init/index.d.ts.map +1 -0
- package/dist/commands/init/index.js +96 -0
- package/dist/commands/init/index.js.map +1 -0
- package/dist/commands/init/library.d.ts +1 -0
- package/dist/commands/init/library.d.ts.map +1 -0
- package/dist/commands/init/library.js +2 -0
- package/dist/commands/init/library.js.map +1 -0
- package/dist/commands/init/repositories.d.ts +11 -0
- package/dist/commands/init/repositories.d.ts.map +1 -0
- package/dist/commands/init/repositories.js +40 -0
- package/dist/commands/init/repositories.js.map +1 -0
- package/dist/commands/init/scene.d.ts +3 -0
- package/dist/commands/init/scene.d.ts.map +1 -0
- package/dist/commands/init/scene.js +56 -0
- package/dist/commands/init/scene.js.map +1 -0
- package/dist/commands/init/types.d.ts +22 -0
- package/dist/commands/init/types.d.ts.map +1 -0
- package/dist/commands/init/types.js +3 -0
- package/dist/commands/init/types.js.map +1 -0
- package/dist/commands/init/utils.d.ts +6 -0
- package/dist/commands/init/utils.d.ts.map +1 -0
- package/dist/commands/init/utils.js +76 -0
- package/dist/commands/init/utils.js.map +1 -0
- package/dist/commands/install.d.ts +3 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +92 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/pack.d.ts +3 -0
- package/dist/commands/pack.d.ts.map +1 -0
- package/dist/commands/pack.js +102 -0
- package/dist/commands/pack.js.map +1 -0
- package/dist/commands/start.d.ts +3 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +235 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +80 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/workspace.d.ts +3 -0
- package/dist/commands/workspace.d.ts.map +1 -0
- package/dist/commands/workspace.js +81 -0
- package/dist/commands/workspace.js.map +1 -0
- package/dist/commands/world-acl.d.ts +22 -0
- package/dist/commands/world-acl.d.ts.map +1 -0
- package/dist/commands/world-acl.js +262 -0
- package/dist/commands/world-acl.js.map +1 -0
- package/dist/config.d.ts +31 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +128 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/API.d.ts +23 -0
- package/dist/lib/API.d.ts.map +1 -0
- package/dist/lib/API.js +175 -0
- package/dist/lib/API.js.map +1 -0
- package/dist/lib/Decentraland.d.ts +75 -0
- package/dist/lib/Decentraland.d.ts.map +1 -0
- package/dist/lib/Decentraland.js +227 -0
- package/dist/lib/Decentraland.js.map +1 -0
- package/dist/lib/Ethereum.d.ts +52 -0
- package/dist/lib/Ethereum.d.ts.map +1 -0
- package/dist/lib/Ethereum.js +245 -0
- package/dist/lib/Ethereum.js.map +1 -0
- package/dist/lib/IEthereumDataProvider.d.ts +17 -0
- package/dist/lib/IEthereumDataProvider.d.ts.map +1 -0
- package/dist/lib/IEthereumDataProvider.js +3 -0
- package/dist/lib/IEthereumDataProvider.js.map +1 -0
- package/dist/lib/LinkerAPI.d.ts +28 -0
- package/dist/lib/LinkerAPI.d.ts.map +1 -0
- package/dist/lib/LinkerAPI.js +151 -0
- package/dist/lib/LinkerAPI.js.map +1 -0
- package/dist/lib/Preview.d.ts +17 -0
- package/dist/lib/Preview.d.ts.map +1 -0
- package/dist/lib/Preview.js +113 -0
- package/dist/lib/Preview.js.map +1 -0
- package/dist/lib/Project.d.ts +152 -0
- package/dist/lib/Project.d.ts.map +1 -0
- package/dist/lib/Project.js +446 -0
- package/dist/lib/Project.js.map +1 -0
- package/dist/lib/Workspace.d.ts +21 -0
- package/dist/lib/Workspace.d.ts.map +1 -0
- package/dist/lib/Workspace.js +140 -0
- package/dist/lib/Workspace.js.map +1 -0
- package/dist/lib/WorldsContentServer.d.ts +27 -0
- package/dist/lib/WorldsContentServer.d.ts.map +1 -0
- package/dist/lib/WorldsContentServer.js +79 -0
- package/dist/lib/WorldsContentServer.js.map +1 -0
- package/dist/lib/WorldsContentServerLinkerAPI.d.ts +21 -0
- package/dist/lib/WorldsContentServerLinkerAPI.d.ts.map +1 -0
- package/dist/lib/WorldsContentServerLinkerAPI.js +105 -0
- package/dist/lib/WorldsContentServerLinkerAPI.js.map +1 -0
- package/dist/lib/adapters/proto/broker.d.ts +2 -0
- package/dist/lib/adapters/proto/broker.d.ts.map +1 -0
- package/dist/lib/adapters/proto/broker.js +2189 -0
- package/dist/lib/adapters/proto/broker.js.map +1 -0
- package/dist/lib/adapters/proto/comms.d.ts +2 -0
- package/dist/lib/adapters/proto/comms.d.ts.map +1 -0
- package/dist/lib/adapters/proto/comms.js +965 -0
- package/dist/lib/adapters/proto/comms.js.map +1 -0
- package/dist/lib/adapters/ws.d.ts +12 -0
- package/dist/lib/adapters/ws.d.ts.map +1 -0
- package/dist/lib/adapters/ws.js +20 -0
- package/dist/lib/adapters/ws.js.map +1 -0
- package/dist/lib/content/ContentService.d.ts +27 -0
- package/dist/lib/content/ContentService.d.ts.map +1 -0
- package/dist/lib/content/ContentService.js +60 -0
- package/dist/lib/content/ContentService.js.map +1 -0
- package/dist/lib/content/types.d.ts +12 -0
- package/dist/lib/content/types.d.ts.map +1 -0
- package/dist/lib/content/types.js +3 -0
- package/dist/lib/content/types.js.map +1 -0
- package/dist/lib/controllers/bff.d.ts +8 -0
- package/dist/lib/controllers/bff.d.ts.map +1 -0
- package/dist/lib/controllers/bff.js +58 -0
- package/dist/lib/controllers/bff.js.map +1 -0
- package/dist/lib/controllers/debugger.d.ts +4 -0
- package/dist/lib/controllers/debugger.d.ts.map +1 -0
- package/dist/lib/controllers/debugger.js +42 -0
- package/dist/lib/controllers/debugger.js.map +1 -0
- package/dist/lib/controllers/ecs6-endpoints.d.ts +11 -0
- package/dist/lib/controllers/ecs6-endpoints.d.ts.map +1 -0
- package/dist/lib/controllers/ecs6-endpoints.js +543 -0
- package/dist/lib/controllers/ecs6-endpoints.js.map +1 -0
- package/dist/lib/controllers/legacy-comms-v1.d.ts +7 -0
- package/dist/lib/controllers/legacy-comms-v1.d.ts.map +1 -0
- package/dist/lib/controllers/legacy-comms-v1.js +98 -0
- package/dist/lib/controllers/legacy-comms-v1.js.map +1 -0
- package/dist/lib/smartItems/buildSmartItem.d.ts +2 -0
- package/dist/lib/smartItems/buildSmartItem.d.ts.map +1 -0
- package/dist/lib/smartItems/buildSmartItem.js +18 -0
- package/dist/lib/smartItems/buildSmartItem.js.map +1 -0
- package/dist/lib/smartItems/packProject.d.ts +2 -0
- package/dist/lib/smartItems/packProject.d.ts.map +1 -0
- package/dist/lib/smartItems/packProject.js +31 -0
- package/dist/lib/smartItems/packProject.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +151 -0
- package/dist/main.js.map +1 -0
- package/dist/project/installDependencies.d.ts +2 -0
- package/dist/project/installDependencies.d.ts.map +1 -0
- package/dist/project/installDependencies.js +57 -0
- package/dist/project/installDependencies.js.map +1 -0
- package/dist/project/isTypescriptProject.d.ts +2 -0
- package/dist/project/isTypescriptProject.d.ts.map +1 -0
- package/dist/project/isTypescriptProject.js +14 -0
- package/dist/project/isTypescriptProject.js.map +1 -0
- package/dist/project/projectInfo.d.ts +8 -0
- package/dist/project/projectInfo.d.ts.map +1 -0
- package/dist/project/projectInfo.js +89 -0
- package/dist/project/projectInfo.js.map +1 -0
- package/dist/project/updateBundleDependenciesField.d.ts +4 -0
- package/dist/project/updateBundleDependenciesField.d.ts.map +1 -0
- package/dist/project/updateBundleDependenciesField.js +67 -0
- package/dist/project/updateBundleDependenciesField.js.map +1 -0
- package/dist/sceneJson/index.d.ts +4 -0
- package/dist/sceneJson/index.d.ts.map +1 -0
- package/dist/sceneJson/index.js +24 -0
- package/dist/sceneJson/index.js.map +1 -0
- package/dist/sceneJson/lintSceneFile.d.ts +2 -0
- package/dist/sceneJson/lintSceneFile.d.ts.map +1 -0
- package/dist/sceneJson/lintSceneFile.js +13 -0
- package/dist/sceneJson/lintSceneFile.js.map +1 -0
- package/dist/sceneJson/utils.d.ts +3 -0
- package/dist/sceneJson/utils.d.ts.map +1 -0
- package/dist/sceneJson/utils.js +66 -0
- package/dist/sceneJson/utils.js.map +1 -0
- package/dist/utils/analytics.d.ts +42 -0
- package/dist/utils/analytics.d.ts.map +1 -0
- package/dist/utils/analytics.js +111 -0
- package/dist/utils/analytics.js.map +1 -0
- package/dist/utils/buildProject.d.ts +2 -0
- package/dist/utils/buildProject.d.ts.map +1 -0
- package/dist/utils/buildProject.js +26 -0
- package/dist/utils/buildProject.js.map +1 -0
- package/dist/utils/catalystPointers.d.ts +20 -0
- package/dist/utils/catalystPointers.d.ts.map +1 -0
- package/dist/utils/catalystPointers.js +51 -0
- package/dist/utils/catalystPointers.js.map +1 -0
- package/dist/utils/coordinateHelpers.d.ts +65 -0
- package/dist/utils/coordinateHelpers.d.ts.map +1 -0
- package/dist/utils/coordinateHelpers.js +126 -0
- package/dist/utils/coordinateHelpers.js.map +1 -0
- package/dist/utils/download.d.ts +3 -0
- package/dist/utils/download.d.ts.map +1 -0
- package/dist/utils/download.js +42 -0
- package/dist/utils/download.js.map +1 -0
- package/dist/utils/env.d.ts +6 -0
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/utils/env.js +31 -0
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/errors.d.ts +18 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +27 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/filesystem.d.ts +41 -0
- package/dist/utils/filesystem.d.ts.map +1 -0
- package/dist/utils/filesystem.js +84 -0
- package/dist/utils/filesystem.js.map +1 -0
- package/dist/utils/getDummyMappings.d.ts +3 -0
- package/dist/utils/getDummyMappings.d.ts.map +1 -0
- package/dist/utils/getDummyMappings.js +19 -0
- package/dist/utils/getDummyMappings.js.map +1 -0
- package/dist/utils/getProjectFilePaths.d.ts +2 -0
- package/dist/utils/getProjectFilePaths.d.ts.map +1 -0
- package/dist/utils/getProjectFilePaths.js +40 -0
- package/dist/utils/getProjectFilePaths.js.map +1 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +33 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/installedDependencies.d.ts +6 -0
- package/dist/utils/installedDependencies.d.ts.map +1 -0
- package/dist/utils/installedDependencies.js +44 -0
- package/dist/utils/installedDependencies.js.map +1 -0
- package/dist/utils/land.d.ts +4 -0
- package/dist/utils/land.d.ts.map +1 -0
- package/dist/utils/land.js +35 -0
- package/dist/utils/land.js.map +1 -0
- package/dist/utils/logging.d.ts +19 -0
- package/dist/utils/logging.d.ts.map +1 -0
- package/dist/utils/logging.js +97 -0
- package/dist/utils/logging.js.map +1 -0
- package/dist/utils/moduleHelpers.d.ts +22 -0
- package/dist/utils/moduleHelpers.d.ts.map +1 -0
- package/dist/utils/moduleHelpers.js +163 -0
- package/dist/utils/moduleHelpers.js.map +1 -0
- package/dist/utils/nodeAndNpmVersion.d.ts +5 -0
- package/dist/utils/nodeAndNpmVersion.d.ts.map +1 -0
- package/dist/utils/nodeAndNpmVersion.js +64 -0
- package/dist/utils/nodeAndNpmVersion.js.map +1 -0
- package/dist/utils/pathsExistOnDir.d.ts +2 -0
- package/dist/utils/pathsExistOnDir.d.ts.map +1 -0
- package/dist/utils/pathsExistOnDir.js +12 -0
- package/dist/utils/pathsExistOnDir.js.map +1 -0
- package/dist/utils/project.d.ts +29 -0
- package/dist/utils/project.d.ts.map +1 -0
- package/dist/utils/project.js +48 -0
- package/dist/utils/project.js.map +1 -0
- package/dist/utils/shellCommands.d.ts +19 -0
- package/dist/utils/shellCommands.d.ts.map +1 -0
- package/dist/utils/shellCommands.js +73 -0
- package/dist/utils/shellCommands.js.map +1 -0
- package/dist/utils/spinner.d.ts +6 -0
- package/dist/utils/spinner.d.ts.map +1 -0
- package/dist/utils/spinner.js +58 -0
- package/dist/utils/spinner.js.map +1 -0
- package/package.json +115 -0
- package/samples/workspace/Dockerfile +21 -0
- package/samples/workspace/package.json +16 -0
- package/sbzkmrj2.cjs +1 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"updateBundleDependenciesField.js","sourceRoot":"","sources":["../../src/project/updateBundleDependenciesField.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAuB;AACvB,wDAAyB;AAEzB,oDAA2D;AAC3D,0EAA6F;AAC7F,0DAA2C;AAE5B,K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,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sceneJson/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAMpC,wBAAsB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,GAAE,OAAc,GAAG,OAAO,CAAC,KAAK,CAAC,CAO5F;AAED,wBAAsB,YAAY,CAAC,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAItF"}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.setSceneFile = exports.getSceneFile = void 0;
|
7
|
+
const path_1 = __importDefault(require("path"));
|
8
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
9
|
+
let sceneFile;
|
10
|
+
async function getSceneFile(workingDir, cache = true) {
|
11
|
+
if (cache && sceneFile) {
|
12
|
+
return sceneFile;
|
13
|
+
}
|
14
|
+
sceneFile = await fs_extra_1.default.readJSON(path_1.default.resolve(workingDir, 'scene.json'));
|
15
|
+
return sceneFile;
|
16
|
+
}
|
17
|
+
exports.getSceneFile = getSceneFile;
|
18
|
+
async function setSceneFile(sceneFile, workingDir) {
|
19
|
+
return fs_extra_1.default.writeJSON(path_1.default.resolve(workingDir, 'scene.json'), sceneFile, {
|
20
|
+
spaces: 2
|
21
|
+
});
|
22
|
+
}
|
23
|
+
exports.setSceneFile = setSceneFile;
|
24
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sceneJson/index.ts"],"names":[],"mappings":";;;;;;AACA,gDAAuB;AACvB,wDAAyB;AAEzB,IAAI,SAAgB,CAAA;AAEb,KAAK,UAAU,YAAY,CAAC,UAAkB,EAAE,QAAiB,IAAI;IAC1E,IAAI,KAAK,IAAI,SAAS,EAAE;QACtB,OAAO,SAAS,CAAA;KACjB;IAED,SAAS,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,cAAI,CAAC,OAAO,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,CAAA;IACrE,OAAO,SAAS,CAAA;AAClB,CAAC;AAPD,oCAOC;AAEM,KAAK,UAAU,YAAY,CAAC,SAAgB,EAAE,UAAkB;IACrE,OAAO,kBAAE,CAAC,SAAS,CAAC,cAAI,CAAC,OAAO,CAAC,UAAU,EAAE,YAAY,CAAC,EAAE,SAAS,EAAE;QACrE,MAAM,EAAE,CAAC;KACV,CAAC,CAAA;AACJ,CAAC;AAJD,oCAIC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"lintSceneFile.d.ts","sourceRoot":"","sources":["../../src/sceneJson/lintSceneFile.ts"],"names":[],"mappings":"AAIA,wBAAsB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAcrE"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.lintSceneFile = void 0;
|
4
|
+
const _1 = require(".");
|
5
|
+
async function lintSceneFile(workingDir) {
|
6
|
+
const sceneFile = await (0, _1.getSceneFile)(workingDir);
|
7
|
+
const finalScene = Object.assign(Object.assign({}, sceneFile), { scene: Object.assign(Object.assign({}, sceneFile.scene), { base: sceneFile.scene.base.replace(/\ /g, ''), parcels: sceneFile.scene.parcels.map((coords) => coords.replace(/\ /g, '')) }) });
|
8
|
+
if (JSON.stringify(sceneFile) !== JSON.stringify(finalScene)) {
|
9
|
+
return (0, _1.setSceneFile)(finalScene, workingDir);
|
10
|
+
}
|
11
|
+
}
|
12
|
+
exports.lintSceneFile = lintSceneFile;
|
13
|
+
//# sourceMappingURL=lintSceneFile.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"lintSceneFile.js","sourceRoot":"","sources":["../../src/sceneJson/lintSceneFile.ts"],"names":[],"mappings":";;;AAEA,wBAA8C;AAEvC,KAAK,UAAU,aAAa,CAAC,UAAkB;IACpD,MAAM,SAAS,GAAG,MAAM,IAAA,eAAY,EAAC,UAAU,CAAC,CAAA;IAChD,MAAM,UAAU,mCACX,SAAS,KACZ,KAAK,kCACA,SAAS,CAAC,KAAK,KAClB,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAC7C,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,MAE9E,CAAA;IAED,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE;QAC5D,OAAO,IAAA,eAAY,EAAC,UAAU,EAAE,UAAU,CAAC,CAAA;KAC5C;AACH,CAAC;AAdD,sCAcC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/sceneJson/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAWpC,wBAAgB,aAAa,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,GAAE,OAAe,GAAG,OAAO,CA8B7E"}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
|
+
};
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
+
exports.validateScene = void 0;
|
30
|
+
const chalk_1 = __importDefault(require("chalk"));
|
31
|
+
const schemas_1 = require("@dcl/schemas");
|
32
|
+
const spinner = __importStar(require("../utils/spinner"));
|
33
|
+
function checkMissingOrDefault(obj, defaults) {
|
34
|
+
const missingKeys = Object.entries(defaults).reduce((acc, [key, value]) => {
|
35
|
+
return obj[key] && obj[key] !== value ? acc : acc.concat(key);
|
36
|
+
}, []);
|
37
|
+
return missingKeys;
|
38
|
+
}
|
39
|
+
function validateScene(sceneJson, log = false) {
|
40
|
+
log && spinner.create('Validating scene.json');
|
41
|
+
const validScene = schemas_1.Scene.validate(sceneJson);
|
42
|
+
if (!validScene) {
|
43
|
+
const error = (schemas_1.Scene.validate.errors || []).map((a) => `${a.data} ${a.message}`).join('');
|
44
|
+
log && spinner.fail(`Invalid scene.json: ${error}`);
|
45
|
+
return false;
|
46
|
+
}
|
47
|
+
const defaults = {
|
48
|
+
title: 'DCL Scene',
|
49
|
+
description: 'My new Decentraland project',
|
50
|
+
navmapThumbnail: 'images/scene-thumbnail.png'
|
51
|
+
};
|
52
|
+
const sceneDisplay = sceneJson.display || {};
|
53
|
+
const missingKeys = checkMissingOrDefault(sceneDisplay, defaults);
|
54
|
+
if (log) {
|
55
|
+
if (missingKeys.length) {
|
56
|
+
spinner.warn(`Don't forget to update your scene.json metadata: [${missingKeys.join(', ')}]
|
57
|
+
${chalk_1.default.underline.bold('https://docs.decentraland.org/development-guide/scene-metadata/')}`);
|
58
|
+
}
|
59
|
+
else {
|
60
|
+
spinner.succeed();
|
61
|
+
}
|
62
|
+
}
|
63
|
+
return !missingKeys.length;
|
64
|
+
}
|
65
|
+
exports.validateScene = validateScene;
|
66
|
+
//# sourceMappingURL=utils.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/sceneJson/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAyB;AACzB,0CAAoC;AAEpC,0DAA2C;AAE3C,SAAS,qBAAqB,CAAoC,GAAM,EAAE,QAAW;IACnF,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,GAAa,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAClF,OAAO,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAC/D,CAAC,EAAE,EAAE,CAAC,CAAA;IACN,OAAO,WAAW,CAAA;AACpB,CAAC;AAED,SAAgB,aAAa,CAAC,SAAgB,EAAE,MAAe,KAAK;IAClE,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAA;IAE9C,MAAM,UAAU,GAAG,eAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;IAC5C,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,KAAK,GAAG,CAAC,eAAK,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAEzF,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,uBAAuB,KAAK,EAAE,CAAC,CAAA;QACnD,OAAO,KAAK,CAAA;KACb;IAED,MAAM,QAAQ,GAAqB;QACjC,KAAK,EAAE,WAAW;QAClB,WAAW,EAAE,6BAA6B;QAC1C,eAAe,EAAE,4BAA4B;KAC9C,CAAA;IACD,MAAM,YAAY,GAAG,SAAS,CAAC,OAAO,IAAI,EAAE,CAAA;IAE5C,MAAM,WAAW,GAAG,qBAAqB,CAAgC,YAAY,EAAE,QAAQ,CAAC,CAAA;IAEhG,IAAI,GAAG,EAAE;QACP,IAAI,WAAW,CAAC,MAAM,EAAE;YACtB,OAAO,CAAC,IAAI,CAAC,qDAAqD,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;UACpF,eAAK,CAAC,SAAS,CAAC,IAAI,CAAC,iEAAiE,CAAC,EAAE,CAAC,CAAA;SAC/F;aAAM;YACL,OAAO,CAAC,OAAO,EAAE,CAAA;SAClB;KACF;IAED,OAAO,CAAC,WAAW,CAAC,MAAM,CAAA;AAC5B,CAAC;AA9BD,sCA8BC"}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import AnalyticsNode from 'analytics-node';
|
2
|
+
import { IPFSv2 } from '@dcl/schemas';
|
3
|
+
export declare let analytics: AnalyticsNode;
|
4
|
+
export declare type AnalyticsProject = {
|
5
|
+
projectHash?: string;
|
6
|
+
ecs?: {
|
7
|
+
ecsVersion: string;
|
8
|
+
packageVersion: string;
|
9
|
+
};
|
10
|
+
coords?: {
|
11
|
+
x: number;
|
12
|
+
y: number;
|
13
|
+
};
|
14
|
+
parcelCount?: number;
|
15
|
+
isWorkspace: boolean;
|
16
|
+
};
|
17
|
+
export declare type SceneDeploySuccess = Omit<AnalyticsProject, 'isWorkspace'> & {
|
18
|
+
isWorld: boolean;
|
19
|
+
sceneId: IPFSv2;
|
20
|
+
targetContentServer: string;
|
21
|
+
worldName: string | undefined;
|
22
|
+
};
|
23
|
+
export declare namespace Analytics {
|
24
|
+
const sceneCreated: (properties?: {
|
25
|
+
projectType: string;
|
26
|
+
url?: string | undefined;
|
27
|
+
} | undefined) => void;
|
28
|
+
const startPreview: (properties: AnalyticsProject) => void;
|
29
|
+
const sceneStartDeploy: (properties?: any) => void;
|
30
|
+
const sceneDeploySuccess: (properties: SceneDeploySuccess) => void;
|
31
|
+
const worldAcl: (properties: any) => void;
|
32
|
+
const buildScene: (properties: AnalyticsProject) => void;
|
33
|
+
const infoCmd: (properties?: any) => void;
|
34
|
+
const statusCmd: (properties?: any) => void;
|
35
|
+
const sendData: (shareData: boolean) => void;
|
36
|
+
const tryToUseDeprecated: (properties?: any) => void;
|
37
|
+
function identify(devId: string): Promise<void>;
|
38
|
+
function reportError(type: string, message: string, stackTrace: string): Promise<void | null>;
|
39
|
+
function requestPermission(): Promise<void>;
|
40
|
+
}
|
41
|
+
export declare function finishPendingTracking(): Promise<any[]>;
|
42
|
+
//# sourceMappingURL=analytics.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../src/utils/analytics.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,gBAAgB,CAAA;AAK1C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAKrC,eAAO,IAAI,SAAS,EAAE,aAAa,CAAA;AAYnC,oBAAY,gBAAgB,GAAG;IAC7B,WAAW,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C"}
|
@@ -0,0 +1,111 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.finishPendingTracking = exports.Analytics = exports.analytics = void 0;
|
7
|
+
const uuid_1 = require("uuid");
|
8
|
+
const analytics_node_1 = __importDefault(require("analytics-node"));
|
9
|
+
const config_1 = require("../config");
|
10
|
+
const moduleHelpers_1 = require("./moduleHelpers");
|
11
|
+
const logging_1 = require("./logging");
|
12
|
+
const chalk_1 = __importDefault(require("chalk"));
|
13
|
+
// Setup segment.io
|
14
|
+
const SINGLEUSER = 'cli-user';
|
15
|
+
const ANONYMOUS_DATA_QUESTION = 'Send Anonymous data';
|
16
|
+
function isCI() {
|
17
|
+
return process.env.CI === 'true' || process.argv.includes('--ci') || process.argv.includes('--c');
|
18
|
+
}
|
19
|
+
function isEditor() {
|
20
|
+
return process.env.EDITOR === 'true';
|
21
|
+
}
|
22
|
+
var Analytics;
|
23
|
+
(function (Analytics) {
|
24
|
+
Analytics.sceneCreated = (properties) => trackAsync('Scene created', properties);
|
25
|
+
Analytics.startPreview = (properties) => trackAsync('Preview started', properties);
|
26
|
+
Analytics.sceneStartDeploy = (properties) => trackAsync('Scene deploy started', properties);
|
27
|
+
Analytics.sceneDeploySuccess = (properties) => trackAsync('Scene deploy success', properties);
|
28
|
+
Analytics.worldAcl = (properties) => trackAsync('World ACL', properties);
|
29
|
+
Analytics.buildScene = (properties) => trackAsync('Build scene', properties);
|
30
|
+
Analytics.infoCmd = (properties) => trackAsync('Info command', properties);
|
31
|
+
Analytics.statusCmd = (properties) => trackAsync('Status command', properties);
|
32
|
+
Analytics.sendData = (shareData) => trackAsync(ANONYMOUS_DATA_QUESTION, { shareData });
|
33
|
+
Analytics.tryToUseDeprecated = (properties) => trackAsync('Try to use depacreated feature', properties);
|
34
|
+
async function identify(devId) {
|
35
|
+
exports.analytics.identify({
|
36
|
+
userId: SINGLEUSER,
|
37
|
+
traits: {
|
38
|
+
os: process.platform,
|
39
|
+
createdAt: new Date().getTime(),
|
40
|
+
isCI: isCI(),
|
41
|
+
isEditor: isEditor(),
|
42
|
+
devId
|
43
|
+
}
|
44
|
+
});
|
45
|
+
}
|
46
|
+
Analytics.identify = identify;
|
47
|
+
async function reportError(type, message, stackTrace) {
|
48
|
+
return track('Error', {
|
49
|
+
errorType: type,
|
50
|
+
message,
|
51
|
+
stackTrace
|
52
|
+
});
|
53
|
+
}
|
54
|
+
Analytics.reportError = reportError;
|
55
|
+
async function requestPermission() {
|
56
|
+
const { fileExists, segmentKey } = (0, config_1.getConfig)();
|
57
|
+
if (!segmentKey)
|
58
|
+
return;
|
59
|
+
exports.analytics = new analytics_node_1.default(segmentKey);
|
60
|
+
if (!fileExists) {
|
61
|
+
console.log(chalk_1.default.dim(`Decentraland CLI sends anonymous usage stats to improve their products, if you want to disable it change the configuration at ${chalk_1.default.bold('~/.dclinfo')}\n`));
|
62
|
+
const newUserId = (0, uuid_1.v4)();
|
63
|
+
await (0, config_1.createDCLInfo)({ userId: newUserId, trackStats: true });
|
64
|
+
(0, logging_1.debug)(`${chalk_1.default.bold('.dclinfo')} file created`);
|
65
|
+
await identify(newUserId);
|
66
|
+
Analytics.sendData(true);
|
67
|
+
}
|
68
|
+
}
|
69
|
+
Analytics.requestPermission = requestPermission;
|
70
|
+
})(Analytics = exports.Analytics || (exports.Analytics = {}));
|
71
|
+
/**
|
72
|
+
* Tracks an specific event using the Segment API
|
73
|
+
* @param eventName The name of the event to be tracked
|
74
|
+
* @param properties Any object containing serializable data
|
75
|
+
*/
|
76
|
+
async function track(eventName, properties = {}) {
|
77
|
+
const { userId, trackStats } = (0, config_1.getConfig)();
|
78
|
+
if (!(await (0, moduleHelpers_1.isOnline)())) {
|
79
|
+
return null;
|
80
|
+
}
|
81
|
+
return new Promise(async (resolve) => {
|
82
|
+
const newProperties = Object.assign(Object.assign({}, properties), { os: process.platform, nodeVersion: process.version, cliVersion: (0, moduleHelpers_1.getInstalledCLIVersion)(), isCI: isCI(), isEditor: isEditor(), devId: userId });
|
83
|
+
const shouldTrack = trackStats || eventName === ANONYMOUS_DATA_QUESTION;
|
84
|
+
if (!shouldTrack) {
|
85
|
+
resolve();
|
86
|
+
}
|
87
|
+
const event = {
|
88
|
+
userId: SINGLEUSER,
|
89
|
+
event: eventName,
|
90
|
+
properties: newProperties
|
91
|
+
};
|
92
|
+
try {
|
93
|
+
exports.analytics.track(event, () => {
|
94
|
+
resolve();
|
95
|
+
});
|
96
|
+
}
|
97
|
+
catch (e) {
|
98
|
+
resolve();
|
99
|
+
}
|
100
|
+
});
|
101
|
+
}
|
102
|
+
const pendingTracking = [];
|
103
|
+
function trackAsync(eventName, properties = {}) {
|
104
|
+
const pTracking = track(eventName, properties).then().catch(logging_1.debug);
|
105
|
+
pendingTracking.push(pTracking);
|
106
|
+
}
|
107
|
+
async function finishPendingTracking() {
|
108
|
+
return Promise.all(pendingTracking);
|
109
|
+
}
|
110
|
+
exports.finishPendingTracking = finishPendingTracking;
|
111
|
+
//# sourceMappingURL=analytics.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../src/utils/analytics.ts"],"names":[],"mappings":";;;;;;AAAA,+BAAmC;AACnC,oEAA0C;AAC1C,sCAAoD;AACpD,mDAAkE;AAClE,uCAAiC;AACjC,kDAAyB;AAGzB,mBAAmB;AACnB,MAAM,UAAU,GAAG,UAAU,CAAA;AAI7B,MAAM,uBAAuB,GAAG,qBAAqB,CAAA;AAErD,SAAS,IAAI;IACX,OAAO,OAAO,CAAC,GAAG,CAAC,EAAE,KAAK,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AACnG,CAAC;AAED,SAA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G,CAAC,eAAe,CAAC,CAAA;AACrC,CAAC;AAFD,sDAEC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"buildProject.d.ts","sourceRoot":"","sources":["../../src/utils/buildProject.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBtE"}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const child_process_1 = require("child_process");
|
4
|
+
const npm = /^win/.test(process.platform) ? 'npm.cmd' : 'npm';
|
5
|
+
function buildProject(workingDir) {
|
6
|
+
console.log(`Building project using "npm run build"`);
|
7
|
+
return new Promise((resolve, reject) => {
|
8
|
+
const child = (0, child_process_1.spawn)(npm, ['run', 'build'], {
|
9
|
+
shell: true,
|
10
|
+
cwd: workingDir,
|
11
|
+
env: Object.assign(Object.assign({}, process.env), { NODE_ENV: '' })
|
12
|
+
});
|
13
|
+
child.stdout.pipe(process.stdout);
|
14
|
+
child.stderr.pipe(process.stderr);
|
15
|
+
child.on('close', (code) => {
|
16
|
+
if (code !== 0) {
|
17
|
+
reject(new Error('Error while building the project'));
|
18
|
+
}
|
19
|
+
else {
|
20
|
+
resolve();
|
21
|
+
}
|
22
|
+
});
|
23
|
+
});
|
24
|
+
}
|
25
|
+
exports.default = buildProject;
|
26
|
+
//# sourceMappingURL=buildProject.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"buildProject.js","sourceRoot":"","sources":["../../src/utils/buildProject.ts"],"names":[],"mappings":";;AAAA,iDAAqC;AAErC,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAA;AAE7D,SAAwB,YAAY,CAAC,UAAkB;IACrD,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAA;IACrD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,KAAK,GAAG,IAAA,qBAAK,EAAC,GAAG,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE;YACzC,KAAK,EAAE,IAAI;YACX,GAAG,EAAE,UAAU;YACf,GAAG,kCAAO,OAAO,CAAC,GAAG,KAAE,QAAQ,EAAE,EAAE,GAAE;SACtC,CAAC,CAAA;QAEF,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QACjC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAEjC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YACzB,IAAI,IAAI,KAAK,CAAC,EAAE;gBACd,MAAM,CAAC,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC,CAAA;aACtD;iBAAM;gBACL,OAAO,EAAE,CAAA;aACV;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC;AApBD,+BAoBC"}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { Entity } from '@dcl/schemas';
|
2
|
+
export declare type DAOCatalyst = {
|
3
|
+
baseUrl: string;
|
4
|
+
owner: string;
|
5
|
+
id: string;
|
6
|
+
};
|
7
|
+
declare type CatalystInfo = {
|
8
|
+
url: string;
|
9
|
+
timestamp: number;
|
10
|
+
entityId: string;
|
11
|
+
};
|
12
|
+
export declare type Network = 'mainnet' | 'sepolia';
|
13
|
+
export declare function daoCatalysts(network?: Network): Promise<Array<DAOCatalyst>>;
|
14
|
+
export declare function fetchEntityByPointer(baseUrl: string, pointers: string[]): Promise<{
|
15
|
+
baseUrl: string;
|
16
|
+
deployments: Entity[];
|
17
|
+
}>;
|
18
|
+
export declare function getPointers(pointer: string, network?: Network): Promise<CatalystInfo[]>;
|
19
|
+
export {};
|
20
|
+
//# sourceMappingURL=catalystPointers.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"catalystPointers.d.ts","sourceRoot":"","sources":["../../src/utils/catalystPointers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAGrC,oBAAY,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,EAAE,EAAE,MAAM,CAAA;CACX,CAAA;AAED,aAAK,YAAY,GAAG;IAClB,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,oBAAY,OAAO,GAAG,SAAS,GAAG,SAAS,CAAA;AAE3C,wBAAsB,YAAY,CAAC,OAAO,GAAE,OAAmB,GAAG,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAI5F;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC;IACT,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,EAAE,CAAA;CACtB,CAAC,CAqBD;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,OAAmB,2BAiB9E"}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.getPointers = exports.fetchEntityByPointer = exports.daoCatalysts = void 0;
|
7
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
8
|
+
async function daoCatalysts(network = 'mainnet') {
|
9
|
+
const tld = network === 'mainnet' ? 'org' : 'zone';
|
10
|
+
const resp = await (await (0, node_fetch_1.default)(`https://peer.decentraland.${tld}/lambdas/contracts/servers`)).json();
|
11
|
+
return resp;
|
12
|
+
}
|
13
|
+
exports.daoCatalysts = daoCatalysts;
|
14
|
+
async function fetchEntityByPointer(baseUrl, pointers) {
|
15
|
+
if (pointers.length === 0)
|
16
|
+
return {
|
17
|
+
baseUrl,
|
18
|
+
deployments: []
|
19
|
+
};
|
20
|
+
const activeEntities = baseUrl + '/content/entities/active';
|
21
|
+
const response = await (0, node_fetch_1.default)(activeEntities, {
|
22
|
+
method: 'post',
|
23
|
+
headers: { 'content-type': 'application/json', connection: 'close' },
|
24
|
+
body: JSON.stringify({ pointers })
|
25
|
+
});
|
26
|
+
const deployments = response.ok ? (await response.json()) : [];
|
27
|
+
return {
|
28
|
+
baseUrl,
|
29
|
+
deployments
|
30
|
+
};
|
31
|
+
}
|
32
|
+
exports.fetchEntityByPointer = fetchEntityByPointer;
|
33
|
+
async function getPointers(pointer, network = 'mainnet') {
|
34
|
+
var _a, _b;
|
35
|
+
const catalysts = await daoCatalysts(network);
|
36
|
+
const catalystInfo = [];
|
37
|
+
for (const { baseUrl } of catalysts) {
|
38
|
+
try {
|
39
|
+
const result = await fetchEntityByPointer(baseUrl, [pointer]);
|
40
|
+
const timestamp = (_a = result.deployments[0]) === null || _a === void 0 ? void 0 : _a.timestamp;
|
41
|
+
const entityId = ((_b = result.deployments[0]) === null || _b === void 0 ? void 0 : _b.id) || '';
|
42
|
+
catalystInfo.push({ timestamp, entityId, url: baseUrl });
|
43
|
+
}
|
44
|
+
catch (err) {
|
45
|
+
console.log('Error fetching catalyst pointers', err);
|
46
|
+
}
|
47
|
+
}
|
48
|
+
return catalystInfo;
|
49
|
+
}
|
50
|
+
exports.getPointers = getPointers;
|
51
|
+
//# sourceMappingURL=catalystPointers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"catalystPointers.js","sourceRoot":"","sources":["../../src/utils/catalystPointers.ts"],"names":[],"mappings":";;;;;;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G,MAAM,oBAAoB,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;YAC7D,MAAM,SAAS,GAAG,MAAA,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,0CAAE,SAAS,CAAA;YAClD,MAAM,QAAQ,GAAG,CAAA,MAAA,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,0CAAE,EAAE,KAAI,EAAE,CAAA;YAEhD,YAAY,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAA;SACzD;QAAC,OAAO,GAAQ,EAAE;YACjB,OAAO,CAAC,GAAG,CAAC,kCAAkC,EAAE,GAAG,CAAC,CAAA;SACrD;KACF;IAED,OAAO,YAAY,CAAA;AACrB,CAAC;AAjBD,kCAiBC"}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
export interface IBounds {
|
2
|
+
minX: number;
|
3
|
+
minY: number;
|
4
|
+
maxX: number;
|
5
|
+
maxY: number;
|
6
|
+
}
|
7
|
+
export declare type Coords = {
|
8
|
+
x: number;
|
9
|
+
y: number;
|
10
|
+
};
|
11
|
+
/**
|
12
|
+
* Returns metaverse coordinates bounds.
|
13
|
+
*/
|
14
|
+
export declare function getBounds(): IBounds;
|
15
|
+
/**
|
16
|
+
* Parses a string-based set of coordinates.
|
17
|
+
* - All spaces are removed
|
18
|
+
* - Leading zeroes are removed
|
19
|
+
* - `-0` is converted to `0`
|
20
|
+
* @param coordinates An string containing coordinates in the `x,y; x,y; ...` format
|
21
|
+
*/
|
22
|
+
export declare function parse(coordinates: string): string[];
|
23
|
+
/**
|
24
|
+
* Returns a promise that resolves `true` if the given set of coordinates is valid.
|
25
|
+
* For invalid coordinates, the promise will reject with an error message.
|
26
|
+
* *This is meant to be used as an inquirer validator.*
|
27
|
+
*
|
28
|
+
* Empty inputs will resolve `true`
|
29
|
+
* @param answers An string containing coordinates in the `x,y; x,y; ...` format
|
30
|
+
*/
|
31
|
+
export declare function validate(answers: string): Promise<boolean>;
|
32
|
+
/**
|
33
|
+
* Returns true if the given coordinate's format is valid
|
34
|
+
*
|
35
|
+
* ```
|
36
|
+
* isValid('0,0') // returns true
|
37
|
+
* isValid(', 0') // returns false
|
38
|
+
* ```
|
39
|
+
* @param val The coodinate string
|
40
|
+
*/
|
41
|
+
export declare function isValid(val: string): boolean;
|
42
|
+
/**
|
43
|
+
* Converts a string-based set of coordinates to an object
|
44
|
+
* @param coords A string containing a set of coordinates
|
45
|
+
*/
|
46
|
+
export declare function getObject(coords: string): Coords;
|
47
|
+
/**
|
48
|
+
* Converts a array-based set of coordinates to an object
|
49
|
+
* @param coords An array containing a set of coordinates
|
50
|
+
*/
|
51
|
+
export declare function getObject(coords: number[]): Coords;
|
52
|
+
/**
|
53
|
+
* Converts a Coords object to a string-based set of coordinates
|
54
|
+
*/
|
55
|
+
export declare function getString({ x, y }: Coords): string;
|
56
|
+
/**
|
57
|
+
* Returns true if the given coordinates are in metaverse bounds
|
58
|
+
*/
|
59
|
+
export declare function inBounds(x: number, y: number): boolean;
|
60
|
+
/**
|
61
|
+
* Returns true if the given parcels array are connected
|
62
|
+
*/
|
63
|
+
export declare function areConnected(parcels: Coords[]): boolean;
|
64
|
+
export declare function isEqual(p1: Coords, p2: Coords): boolean;
|
65
|
+
//# sourceMappingURL=coordinateHelpers.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"coordinateHelpers.d.ts","sourceRoot":"","sources":["../../src/utils/coordinateHelpers.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED,oBAAY,MAAM,GAAG;IACnB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV,CAAA;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAOnC;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAUnD;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAa1D;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAK5C;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;AACjD;;;GAGG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;AAMnD;;GAEG;AACH,wBAAgB,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAGtD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAMvD;AAsBD,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAEvD"}
|
@@ -0,0 +1,126 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.isEqual = exports.areConnected = exports.inBounds = exports.getString = exports.getObject = exports.isValid = exports.validate = exports.parse = exports.getBounds = void 0;
|
4
|
+
/**
|
5
|
+
* Returns metaverse coordinates bounds.
|
6
|
+
*/
|
7
|
+
function getBounds() {
|
8
|
+
return {
|
9
|
+
minX: -150,
|
10
|
+
minY: -150,
|
11
|
+
maxX: 165,
|
12
|
+
maxY: 165
|
13
|
+
};
|
14
|
+
}
|
15
|
+
exports.getBounds = getBounds;
|
16
|
+
/**
|
17
|
+
* Parses a string-based set of coordinates.
|
18
|
+
* - All spaces are removed
|
19
|
+
* - Leading zeroes are removed
|
20
|
+
* - `-0` is converted to `0`
|
21
|
+
* @param coordinates An string containing coordinates in the `x,y; x,y; ...` format
|
22
|
+
*/
|
23
|
+
function parse(coordinates) {
|
24
|
+
return coordinates.split(';').map((coord) => {
|
25
|
+
const [x = 0, y = 0] = coord.split(',').map(($) => {
|
26
|
+
return parseInt($, 10)
|
27
|
+
.toString() // removes spaces :)
|
28
|
+
.replace('-0', '0')
|
29
|
+
.replace(/undefined|NaN/g, '0');
|
30
|
+
});
|
31
|
+
return `${x},${y}`;
|
32
|
+
});
|
33
|
+
}
|
34
|
+
exports.parse = parse;
|
35
|
+
/**
|
36
|
+
* Returns a promise that resolves `true` if the given set of coordinates is valid.
|
37
|
+
* For invalid coordinates, the promise will reject with an error message.
|
38
|
+
* *This is meant to be used as an inquirer validator.*
|
39
|
+
*
|
40
|
+
* Empty inputs will resolve `true`
|
41
|
+
* @param answers An string containing coordinates in the `x,y; x,y; ...` format
|
42
|
+
*/
|
43
|
+
function validate(answers) {
|
44
|
+
return new Promise((resolve, reject) => {
|
45
|
+
if (answers.trim().length === 0) {
|
46
|
+
resolve(true);
|
47
|
+
}
|
48
|
+
else {
|
49
|
+
answers.split(/;\s/g).forEach((answer) => {
|
50
|
+
if (!isValid(answer)) {
|
51
|
+
reject(new Error(`Invalid coordinate ${answer}`));
|
52
|
+
}
|
53
|
+
});
|
54
|
+
resolve(true);
|
55
|
+
}
|
56
|
+
});
|
57
|
+
}
|
58
|
+
exports.validate = validate;
|
59
|
+
/**
|
60
|
+
* Returns true if the given coordinate's format is valid
|
61
|
+
*
|
62
|
+
* ```
|
63
|
+
* isValid('0,0') // returns true
|
64
|
+
* isValid(', 0') // returns false
|
65
|
+
* ```
|
66
|
+
* @param val The coodinate string
|
67
|
+
*/
|
68
|
+
function isValid(val) {
|
69
|
+
if (!val.match(/^(-?\d)+\,(-?\d)+$/g)) {
|
70
|
+
return false;
|
71
|
+
}
|
72
|
+
return true;
|
73
|
+
}
|
74
|
+
exports.isValid = isValid;
|
75
|
+
function getObject(coords) {
|
76
|
+
const [x, y] = typeof coords === 'string' ? parse(coords)[0].split(',') : coords;
|
77
|
+
return { x: parseInt(x.toString(), 10), y: parseInt(y.toString(), 10) };
|
78
|
+
}
|
79
|
+
exports.getObject = getObject;
|
80
|
+
/**
|
81
|
+
* Converts a Coords object to a string-based set of coordinates
|
82
|
+
*/
|
83
|
+
function getString({ x, y }) {
|
84
|
+
return `${x},${y}`;
|
85
|
+
}
|
86
|
+
exports.getString = getString;
|
87
|
+
/**
|
88
|
+
* Returns true if the given coordinates are in metaverse bounds
|
89
|
+
*/
|
90
|
+
function inBounds(x, y) {
|
91
|
+
const { minX, minY, maxX, maxY } = getBounds();
|
92
|
+
return x >= minX && x <= maxX && y >= minY && y <= maxY;
|
93
|
+
}
|
94
|
+
exports.inBounds = inBounds;
|
95
|
+
/**
|
96
|
+
* Returns true if the given parcels array are connected
|
97
|
+
*/
|
98
|
+
function areConnected(parcels) {
|
99
|
+
if (parcels.length === 0) {
|
100
|
+
return false;
|
101
|
+
}
|
102
|
+
const visited = visitParcel(parcels[0], parcels);
|
103
|
+
return visited.length === parcels.length;
|
104
|
+
}
|
105
|
+
exports.areConnected = areConnected;
|
106
|
+
function visitParcel(parcel, allParcels = [parcel], visited = []) {
|
107
|
+
const isVisited = visited.some((visitedParcel) => isEqual(visitedParcel, parcel));
|
108
|
+
if (!isVisited) {
|
109
|
+
visited.push(parcel);
|
110
|
+
const neighbours = getNeighbours(parcel.x, parcel.y, allParcels);
|
111
|
+
neighbours.forEach((neighbours) => visitParcel(neighbours, allParcels, visited));
|
112
|
+
}
|
113
|
+
return visited;
|
114
|
+
}
|
115
|
+
function getIsNeighbourMatcher(x, y) {
|
116
|
+
return (coords) => (coords.x === x && (coords.y + 1 === y || coords.y - 1 === y)) ||
|
117
|
+
(coords.y === y && (coords.x + 1 === x || coords.x - 1 === x));
|
118
|
+
}
|
119
|
+
function getNeighbours(x, y, parcels) {
|
120
|
+
return parcels.filter(getIsNeighbourMatcher(x, y));
|
121
|
+
}
|
122
|
+
function isEqual(p1, p2) {
|
123
|
+
return p1.x === p2.x && p1.y === p2.y;
|
124
|
+
}
|
125
|
+
exports.isEqual = isEqual;
|
126
|
+
//# sourceMappingURL=coordinateHelpers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"coordinateHelpers.js","sourceRoot":"","sources":["../../src/utils/coordinateHelpers.ts"],"names":[],"mappings":";;;AAYA;;GAEG;AACH,SAAgB,SAAS;IACvB,OAAO;QACL,IAAI,EAAE,CAAC,GAAG;QACV,IAAI,EAAE,CAAC,GAAG;QACV,IAAI,EAAE,GAAG;QACT,IAAI,EAAE,GAAG;KACV,CAAA;AACH,CAAC;AAPD,8BAOC;AAED;;;;;;GAMG;AACH,SAAgB,KAAK,CAAC,WAAmB;IACvC,OAAO,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAa,EAAE,EAAE;QAClD,MAAM,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YAChD,OAAO,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC;iBACnB,QAAQ,EAAE,CAAC,oBAAoB;iBAC/B,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;iBAClB,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAA;QACnC,CAAC,CAAC,CAAA;QACF,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,CAAA;IACpB,CAAC,CAAC,CAAA;AACJ,CAAC;AAVD,sBAUC;AAED;;;;;;;GAOG;AACH,SAAgB,QAAQ,CAAC,OAAe;IACtC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,OAA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