@dcl/sdk-commands 7.23.4-26770223094.commit-52b9415 → 7.24.0
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.
package/dist/logic/composite.js
CHANGED
|
@@ -9,15 +9,26 @@ const path_1 = __importDefault(require("path"));
|
|
|
9
9
|
const dist_cjs_1 = require("@dcl/ecs/dist-cjs");
|
|
10
10
|
const inspector_1 = require("@dcl/inspector");
|
|
11
11
|
const beautiful_logs_1 = require("./beautiful-logs");
|
|
12
|
+
const COMPOSITE_FILE_MAX_BYTES = 16 * 1024 * 1024; // 16 MB — sanity cap on hand-authored composites; rejects DoS-shaped inputs without bothering legitimate ones.
|
|
12
13
|
async function getAllComposites(components, workingDirectory) {
|
|
13
14
|
let withErrors = false;
|
|
14
15
|
const composites = {};
|
|
16
|
+
// Discover every composite so build-time recursion (`instanceComposite` →
|
|
17
|
+
// `getCompositeOrNull(childCompositePath)`) can resolve nested references
|
|
18
|
+
// embedded in `main.composite`. Only `main.composite` is later inlined into
|
|
19
|
+
// the JS bundle (`compositeLines` below); secondary composites lazy-load at
|
|
20
|
+
// runtime via `~system/Runtime.readFile`.
|
|
15
21
|
const watchFiles = (0, glob_1.globSync)('**/*.composite', { cwd: workingDirectory });
|
|
22
|
+
if (watchFiles.length > 0)
|
|
23
|
+
components.logger.debug(`[composite] .composite: ${watchFiles.join(', ')}`);
|
|
16
24
|
const scripts = new Map();
|
|
17
25
|
const textDecoder = new TextDecoder();
|
|
18
26
|
for (const file of watchFiles) {
|
|
19
27
|
try {
|
|
20
28
|
const fileBuffer = await components.fs.readFile(path_1.default.join(workingDirectory, file));
|
|
29
|
+
if (fileBuffer.length > COMPOSITE_FILE_MAX_BYTES) {
|
|
30
|
+
throw new Error(`Composite file '${file}' is ${fileBuffer.length} bytes (cap ${COMPOSITE_FILE_MAX_BYTES}); refusing to parse.`);
|
|
31
|
+
}
|
|
21
32
|
const json = JSON.parse(textDecoder.decode(fileBuffer));
|
|
22
33
|
composites[file] = dist_cjs_1.Composite.fromJson(json);
|
|
23
34
|
}
|
|
@@ -55,7 +66,12 @@ async function getAllComposites(components, workingDirectory) {
|
|
|
55
66
|
}
|
|
56
67
|
}
|
|
57
68
|
}
|
|
58
|
-
|
|
69
|
+
// Only inline `main.composite` into `~sdk/all-composites`. Secondary
|
|
70
|
+
// composites stay on disk and are fetched at runtime via the provider's
|
|
71
|
+
// `loadComposite` (see packages/@dcl/sdk/src/composite-provider.ts).
|
|
72
|
+
if (compositeSource === 'main.composite') {
|
|
73
|
+
compositeLines.push(`'${composite.src}':${JSON.stringify(dist_cjs_1.Composite.toJson(composite.composite))}`);
|
|
74
|
+
}
|
|
59
75
|
}
|
|
60
76
|
catch (err) {
|
|
61
77
|
(0, beautiful_logs_1.printError)(components.logger, `Composite '${compositeSource}' can't be instanced.`, err);
|
|
@@ -78,6 +94,12 @@ async function getAllComposites(components, workingDirectory) {
|
|
|
78
94
|
const crdtFilePath = path_1.default.join(workingDirectory, 'main.crdt');
|
|
79
95
|
const crdtData = (0, inspector_1.dumpEngineToCrdtCommands)(engine);
|
|
80
96
|
await components.fs.writeFile(crdtFilePath, crdtData);
|
|
81
|
-
return {
|
|
97
|
+
return {
|
|
98
|
+
compositeLines,
|
|
99
|
+
watchFiles,
|
|
100
|
+
scripts,
|
|
101
|
+
withErrors,
|
|
102
|
+
maxCompositeEntity
|
|
103
|
+
};
|
|
82
104
|
}
|
|
83
105
|
//# sourceMappingURL=composite.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composite.js","sourceRoot":"","sources":["../../src/logic/composite.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"composite.js","sourceRoot":"","sources":["../../src/logic/composite.ts"],"names":[],"mappings":";;;;;AAuBA,4CAgHC;AAvID,+BAA+B;AAC/B,gDAAuB;AACvB,gDAM0B;AAC1B,8CAAsG;AAGtG,qDAA6C;AAS7C,MAAM,wBAAwB,GAAG,EAAE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S,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;IAErD,OAAO;QACL,cAAc;QACd,UAAU;QACV,OAAO;QACP,UAAU;QACV,kBAAkB;KACnB,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcl/sdk-commands",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.24.0",
|
|
5
5
|
"author": "Decentraland",
|
|
6
6
|
"bin": {
|
|
7
7
|
"sdk-commands": "./dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@dcl/crypto": "^3.4.4",
|
|
11
|
-
"@dcl/ecs": "7.
|
|
11
|
+
"@dcl/ecs": "7.24.0",
|
|
12
12
|
"@dcl/gltf-validator-ts": "1.0.14",
|
|
13
13
|
"@dcl/hashing": "1.1.3",
|
|
14
14
|
"@dcl/inspector": "7.34.3",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"displayName": "SDK",
|
|
81
81
|
"tsconfig": "./tsconfig.json"
|
|
82
82
|
},
|
|
83
|
-
"commit": "
|
|
83
|
+
"commit": "5d040fd6fe9e018eb005a5c2a85e3419e1ea87a4"
|
|
84
84
|
}
|