Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Config/eslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@
"Table": "writable",
"TerrainMap": "writable",
"UIParent": "writable",
"UUID": "writable",
"UniqueID": "writable",
"validateString": "writable",
"validateNumber": "writable",
"Vector3D": "writable",
Expand Down
9 changes: 9 additions & 0 deletions Core/Aliases.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const BABYLON = require("babylonjs/babylon.max"); // C_WebGL & C_Sound
const BITMAP = require("bmp-js"); // C_Bitmap
const MESSAGEPACK = require("@msgpack/msgpack"); // C_Message
const JOI = require("joi"); // C_Validation
const UUID = require("uuid"); // UniqueID builtin

function dump(...data) {
console.log(data);
Expand All @@ -18,3 +19,11 @@ function printf(message, ...rest) {
// If we don't check the length, it will print an empty array when there are no parameters
rest.length > 0 ? console.log(message, ...rest) : console.log(message);
}

// Explicitly export so that their presence can be tested for more easily
// BABYLON already exports itself globally by default
window.BITMAP = BITMAP;
window.JOI = JOI;
window.MESSAGEPACK = MESSAGEPACK;
window.NODE = NODE;
window.UUID = UUID;
8 changes: 8 additions & 0 deletions Core/Builtins/UniqueID.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class UniqueID {
constructor() {
this.identifier = UUID.v4();
}
toString() {
return this.identifier;
}
}
13 changes: 13 additions & 0 deletions Tests/Builtins/UniqueID.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
describe("UniqueID", () => {
it("should be exported into the global environment", () => {
assertEquals(UniqueID.name, "UniqueID");
});

let exportedApiSurface = ["toString"];

exportedApiSurface.forEach((namedExport) => {
it("should export function " + namedExport, () => {
assertEquals(typeof UniqueID[namedExport], "function");
});
});
});
16 changes: 16 additions & 0 deletions Tests/SharedConstants/Aliases.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
describe("Aliases", () => {
const exportedObjects = ["BABYLON", "BITMAP", "JOI", "MESSAGEPACK", "NODE", "UUID"];
const exportedFunctions = ["dump", "printf"];

exportedObjects.forEach((namedExport) => {
it("should export global object " + namedExport, () => {
assertEquals(typeof window[namedExport], "object");
});
});

exportedFunctions.forEach((namedExport) => {
it("should export global function " + namedExport, () => {
assertEquals(typeof window[namedExport], "function");
});
});
});
4 changes: 2 additions & 2 deletions Tests/run-renderer-tests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const testSuites = {
SharedConstants: ["SharedConstants/Paths.js"],
Builtins: ["Builtins/Assertions.js", "Builtins/LocalCacheTests.js", "Builtins/Validators.js"],
SharedConstants: ["SharedConstants/Aliases.js", "SharedConstants/Paths.js"],
Builtins: ["Builtins/Assertions.js", "Builtins/LocalCacheTests.js", "Builtins/UniqueID.js", "Builtins/Validators.js"],
C_Settings: [
"API/C_Settings/validate.js",
"API/C_Settings/validateDefaultSettings.js",
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,5 @@
</script>
</body>
<script src="Core/Builtins/Validation.js"></script>
<script src="Core/Builtins/UniqueID.js"></script>
</html>
16 changes: 15 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"bmp-js": "^0.1.0",
"joi": "17.4.1",
"maxrects-packer": "2.7.2",
"tippy.js": "6.3.6"
"tippy.js": "6.3.6",
"uuid": "8.3.2"
},
"devDependencies": {
"electron": "13.3.0",
Expand Down