diff --git a/src/electron/electron_api.js b/src/electron/electron_api.js index 2387188..9aec8e9 100644 --- a/src/electron/electron_api.js +++ b/src/electron/electron_api.js @@ -409,7 +409,7 @@ class ElectronApi { return {}; } - const result = {}; + const result = Object.create(null); result.opDocs = []; const opDoc = doc.getDocForOp(opName); @@ -813,7 +813,7 @@ class ElectronApi getChangelog(data) { - const obj = {}; + const obj = Object.create(null); obj.items = []; obj.ts = Date.now(); return this.success("OK", obj, true); @@ -1143,7 +1143,7 @@ class ElectronApi } const results = []; - let projectPackages = {}; + let projectPackages = Object.create(null); currentProject.ops.forEach((op) => { const opName = opsUtil.getOpNameById(op.opId); @@ -1372,7 +1372,7 @@ class ElectronApi const currentProject = settings.getCurrentProject(); const dirInfos = projectsUtil.getOpDirs(currentProject, false); - const opDirs = {}; + const opDirs = Object.create(null); if (currentProject && currentProject.ops) { currentProject.ops.forEach((op) => @@ -1463,7 +1463,7 @@ class ElectronApi const currentProject = settings.getCurrentProject(); const assetPorts = projectsUtil.getProjectAssetPorts(currentProject, true); - const oldNew = {}; + const oldNew = Object.create(null); let projectAssetPath = cables.getAssetPath(); projectAssetPath = path.join(projectAssetPath, "assets"); if (!fs.existsSync(projectAssetPath)) mkdirp.sync(projectAssetPath); @@ -1487,7 +1487,7 @@ class ElectronApi collectOps() { const currentProject = settings.getCurrentProject(); - const movedOps = {}; + const movedOps = Object.create(null); const allOpNames = []; if (currentProject && currentProject.ops) { @@ -1745,7 +1745,7 @@ class ElectronApi if (fromRename) targetDir = opsUtil.getOpSourceDir(oldName); const problems = opsUtil.getOpRenameProblems(newName, oldName, currentUser, [], null, null, [], true, targetDir); - const hints = {}; + const hints = Object.create(null); const consequences = opsUtil.getOpRenameConsequences(newName, oldName, targetDir); let newOpDocs = opDocs; diff --git a/src/electron/electron_settings.js b/src/electron/electron_settings.js index 1e6c3c5..926ef8a 100644 --- a/src/electron/electron_settings.js +++ b/src/electron/electron_settings.js @@ -32,15 +32,15 @@ class ElectronSettings this.WINDOW_BOUNDS = "windowBounds"; this.DOWNLOAD_PATH = "downloadPath"; - this.opts = {}; - this.opts.defaults = {}; + this.opts = Object.create(null); + this.opts.defaults = Object.create(null); this.opts.configName = this.MAIN_CONFIG_NAME; - this.opts.defaults[this.USER_SETTINGS_FIELD] = {}; + this.opts.defaults[this.USER_SETTINGS_FIELD] = Object.create(null); this.opts.defaults[this.PATCHID_FIELD] = null; this.opts.defaults[this.PROJECTFILE_FIELD] = null; this.opts.defaults[this.CURRENTPROJECTDIR_FIELD] = null; this.opts.defaults[this.STORAGEDIR_FIELD] = storageDir; - this.opts.defaults[this.RECENT_PROJECTS_FIELD] = {}; + this.opts.defaults[this.RECENT_PROJECTS_FIELD] = Object.create(null); this.opts.defaults[this.OPEN_DEV_TOOLS_FIELD] = false; this.opts.defaults[this.DOWNLOAD_PATH] = app.getPath("downloads"); @@ -178,7 +178,7 @@ class ElectronSettings const coreFile = path.join(cables.getUiDistPath(), "js", "buildinfo.json"); const uiFile = path.join(cables.getUiDistPath(), "buildinfo.json"); const standaloneFile = path.join(cables.getStandaloneDistPath(), "public", "js", "buildinfo.json"); - let core = {}; + let core = Object.create(null); if (fs.existsSync(coreFile)) { try @@ -191,7 +191,7 @@ class ElectronSettings } } - let ui = {}; + let ui = Object.create(null); if (fs.existsSync(uiFile)) { try @@ -204,7 +204,7 @@ class ElectronSettings } } - let api = {}; + let api = Object.create(null); if (fs.existsSync(standaloneFile)) { try @@ -262,7 +262,7 @@ class ElectronSettings setRecentProjects(recents) { - if (!recents) recents = {}; + if (!recents) recents = Object.create(null); return this.set(this.RECENT_PROJECTS_FIELD, recents); } @@ -291,7 +291,7 @@ class ElectronSettings return p2.updated - p1.updated; }); files = helper.uniqueArray(files); - const newRecents = {}; + const newRecents = Object.create(null); for (let i = 0; i < 10; i++) { if (i > files.length) break; diff --git a/src/export/export_zip_standalone.js b/src/export/export_zip_standalone.js index 4340e17..8efc57a 100644 --- a/src/export/export_zip_standalone.js +++ b/src/export/export_zip_standalone.js @@ -67,7 +67,7 @@ export default class StandaloneZipExport extends SharedExportService { this._log.info("exported file " + finalZipFileName + " / " + this.archive.pointer() / 1000000.0 + " mb"); - const result = {}; + const result = Object.create(null); result.size = this.archive.pointer() / 1000000.0; result.path = finalZipFileName; result.log = this.exportLog; diff --git a/src/utils/files_util.js b/src/utils/files_util.js index 6224a17..bfd58a3 100644 --- a/src/utils/files_util.js +++ b/src/utils/files_util.js @@ -243,7 +243,7 @@ class FilesUtil extends SharedFilesUtil getPatchFiles() { const arr = []; - const fileHierarchy = {}; + const fileHierarchy = Object.create(null); const project = settings.getCurrentProject(); if (!project) return arr; diff --git a/src/utils/projects_util.js b/src/utils/projects_util.js index d50f467..e1298f3 100644 --- a/src/utils/projects_util.js +++ b/src/utils/projects_util.js @@ -188,7 +188,7 @@ class ProjectsUtil extends SharedProjectsUtil addOpDir(project, opDir, atTop = false) { - if (!project.dirs) project.dirs = {}; + if (!project.dirs) project.dirs = Object.create(null); if (!project.dirs.ops) project.dirs.ops = []; if (atTop) { @@ -205,7 +205,7 @@ class ProjectsUtil extends SharedProjectsUtil removeOpDir(project, opDir) { - if (!project.dirs) project.dirs = {}; + if (!project.dirs) project.dirs = Object.create(null); if (!project.dirs.ops) project.dirs.ops = []; project.dirs.ops = project.dirs.ops.filter((dirName) => { @@ -238,7 +238,7 @@ class ProjectsUtil extends SharedProjectsUtil dirs.forEach((dir) => { const opJsons = helper.getFileNamesRecursive(dir, ".json"); - const opLocations = {}; + const opLocations = Object.create(null); opJsons.forEach((jsonLocation) => { const jsonName = path.basename(jsonLocation, ".json"); @@ -267,7 +267,7 @@ class ProjectsUtil extends SharedProjectsUtil { if (fs.existsSync(opDir)) newOrder.push(opDir); }); - if (!currentProject.dirs) currentProject.dirs = {}; + if (!currentProject.dirs) currentProject.dirs = Object.create(null); if (!currentProject.dirs.ops) currentProject.dirs.ops = []; currentProject.dirs.ops = newOrder.filter((dir) => { return !this.isFixedPositionOpDir(dir); }); currentProject.dirs.ops = helper.uniqueArray(currentProject.dirs.ops); @@ -308,7 +308,7 @@ class ProjectsUtil extends SharedProjectsUtil { if (this._projectOpDocs && !rebuildCache) return this._projectOpDocs; - const opDocs = {}; + const opDocs = Object.create(null); const opDirs = this.getProjectOpDirs(project, true, false, false); opDirs.forEach((opDir) => diff --git a/src_client/cmd_electron.js b/src_client/cmd_electron.js index cc18271..0cd3ede 100644 --- a/src_client/cmd_electron.js +++ b/src_client/cmd_electron.js @@ -1,13 +1,13 @@ import standalone from "./renderer.js"; -const CABLES_CMD_STANDALONE = {}; -const CABLES_CMD_STANDALONE_OVERRIDES = {}; +const CABLES_CMD_STANDALONE = Object.create(null); +const CABLES_CMD_STANDALONE_OVERRIDES = Object.create(null); const CMD_STANDALONE_COMMANDS = []; CABLES_CMD_STANDALONE.runNpm = () => { const loadingModal = standalone.gui.startModalLoading("Installing packages..."); - const options = {}; + const options = Object.create(null); standalone.editor.api("installProjectDependencies", options, (_err, result) => { if (result.data) @@ -274,7 +274,7 @@ CABLES_CMD_STANDALONE.openOpDirectory = () => } }; -CABLES_CMD_STANDALONE_OVERRIDES.PATCH = {}; +CABLES_CMD_STANDALONE_OVERRIDES.PATCH = Object.create(null); CABLES_CMD_STANDALONE_OVERRIDES.PATCH.saveAs = () => { let patchName = standalone.gui.project() ? standalone.gui.project().name : null; @@ -314,7 +314,7 @@ CABLES_CMD_STANDALONE_OVERRIDES.PATCH.renameOp = (opName) => } }; -CABLES_CMD_STANDALONE_OVERRIDES.RENDERER = {}; +CABLES_CMD_STANDALONE_OVERRIDES.RENDERER = Object.create(null); CABLES_CMD_STANDALONE_OVERRIDES.RENDERER.fullscreen = () => { standalone.editor.api("cycleFullscreen", { }, (_err, r) => {}); diff --git a/src_client/standalone.js b/src_client/standalone.js index 82abc41..31e3a38 100644 --- a/src_client/standalone.js +++ b/src_client/standalone.js @@ -24,7 +24,7 @@ export default class CablesStandalone if (!this._config.isPackaged) window.ELECTRON_DISABLE_SECURITY_WARNINGS = true; - this._loadedModules = {}; + this._loadedModules = Object.create(null); } /** diff --git a/webpack.electron.config.js b/webpack.electron.config.js index ed95b39..b604adb 100644 --- a/webpack.electron.config.js +++ b/webpack.electron.config.js @@ -25,7 +25,7 @@ export default (isLiveBuild, buildInfo, minify = false, analyze = false) => { if (!buildInfo.platform) { - buildInfo.platform = {}; + buildInfo.platform = Object.create(null); } if (process.env.BUILD_VERSION) {