diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 000000000..4bae3fb27 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,106 @@ +import js from "@eslint/js"; +import globals from "globals"; + +export default [ + js.configs.recommended, + + { + // Global ignores + ignores: [ + "**/*.min.js", + "**/src/lib/**", + "**/dist/", + "packages/backend/src/public/assets/**", + ], + }, + { + // Top-level and tools use Node + files: [ + "tools/**/*.js", + ], + languageOptions: { + globals: { + ...globals.node, + } + } + }, + { + // Back end + files: [ + "packages/backend/**/*.js", + "dev-server.js", + "utils.js", + ], + languageOptions: { + globals: { + ...globals.node, + "kv": true, + } + } + }, + { + // Front end + files: [ + "index.js", + "initgui.js", + "src/**/*.js", + "packages/**/*.js", + ], + ignores: [ + "packages/backend/**/*.js", + ], + languageOptions: { + globals: { + ...globals.browser, + ...globals.commonjs, + "puter": true, + "i18n": true, + "html_encode": true, + "html_decode": true, + "isMobile": true, + // Libraries + "saveAs": true, // FileSaver + "iro": true, // iro.js color picker + "$": true, // jQuery + "jQuery": true, // jQuery + "JSZip": true, // JSZip + "_": true, // lodash + "QRCode": true, // qrcode + "io": true, // socket.io + "timeago": true, // timeago + "SelectionArea": true, // viselect + } + } + }, + { + // Tests + files: [ + "**/test/**/*.js", + ], + languageOptions: { + globals: { + ...globals.mocha, + } + } + }, + { + // Phoenix + files: [ + "packages/phoenix/**/*.js", + ], + languageOptions: { + globals: { + ...globals.node, + } + } + }, + { + // Global rule settings + rules: { + "no-prototype-builtins": "off", // Complains about any use of hasOwnProperty() + "no-unused-vars": "off", // Temporary, we just have a lot of these + "no-debugger": "warn", + "no-async-promise-executor": "off", // We do this quite often and it's fine + } + }, +]; diff --git a/package-lock.json b/package-lock.json index ba610ac6d..ae585914a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,10 +16,13 @@ "uuid": "^9.0.1" }, "devDependencies": { + "@eslint/js": "^9.1.1", "chalk": "^4.1.0", "clean-css": "^5.3.2", "dotenv": "^16.4.5", + "eslint": "^9.1.1", "express": "^4.18.2", + "globals": "^15.0.0", "html-entities": "^2.3.3", "nodemon": "^3.1.0", "uglify-js": "^3.17.4", @@ -27,6 +30,15 @@ "webpack-cli": "^5.1.1" } }, + "node_modules/@aashutoshrathi/word-wrap": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", + "integrity": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/@ampproject/remapping": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", @@ -407,6 +419,15 @@ "node": ">=6.9.0" } }, + "node_modules/@babel/traverse/node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/@babel/types": { "version": "7.24.0", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.24.0.tgz", @@ -448,6 +469,86 @@ "node": ">=10.0.0" } }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz", + "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==", + "dev": true, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.0.2.tgz", + "integrity": "sha512-wV19ZEGEMAC1eHgrS7UQPqsdEiCIbTKTasEfcXAigzoXICcqZSjBZEHlZwNVvKg6UBCjSlos84XiLqsRJnIcIg==", + "dev": true, + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^10.0.1", + "globals": "^14.0.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@eslint/js": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.1.1.tgz", + "integrity": "sha512-5WoDz3Y19Bg2BnErkZTp0en+c/i9PvgFS7MBe1+m60HjFr0hrphlAGp4yzI7pxpt4xShln4ZyYp4neJm8hmOkQ==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, "node_modules/@grpc/grpc-js": { "version": "1.10.6", "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.10.6.tgz", @@ -621,6 +722,52 @@ "resolved": "packages/terminal", "link": true }, + "node_modules/@humanwhocodes/config-array": { + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz", + "integrity": "sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==", + "dev": true, + "dependencies": { + "@humanwhocodes/object-schema": "^2.0.3", + "debug": "^4.3.1", + "minimatch": "^3.0.5" + }, + "engines": { + "node": ">=10.10.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/object-schema": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", + "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", + "dev": true + }, + "node_modules/@humanwhocodes/retry": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.2.3.tgz", + "integrity": "sha512-X38nUbachlb01YMlvPFojKoiXq+LzZvuSce70KPMPdeM1Rj03k4dR7lDslhbqXn3Ang4EU3+EAmwEAsbrjHW3g==", + "dev": true, + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", @@ -1305,6 +1452,41 @@ "node-pre-gyp": "bin/node-pre-gyp" } }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/@opentelemetry/api": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.4.1.tgz", @@ -3948,6 +4130,15 @@ "acorn": "^8" } }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, "node_modules/agent-base": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", @@ -4612,6 +4803,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/camelcase": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.0.0.tgz", @@ -5308,6 +5508,12 @@ "node": ">=4.0.0" } }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true + }, "node_modules/default-require-extensions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-3.0.1.tgz", @@ -5618,6 +5824,57 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/eslint": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.1.1.tgz", + "integrity": "sha512-b4cRQ0BeZcSEzPpY2PjFY70VbO32K7BStTGtBsnIGdTSEEQzBi8hPBcGQmTG2zUvFr9uLe0TK42bw8YszuHEqg==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^3.0.2", + "@eslint/js": "9.1.1", + "@humanwhocodes/config-array": "^0.13.0", + "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.2.3", + "@nodelib/fs.walk": "^1.2.8", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^8.0.1", + "eslint-visitor-keys": "^4.0.0", + "espree": "^10.0.1", + "esquery": "^1.4.2", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^8.0.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3", + "strip-ansi": "^6.0.1", + "text-table": "^0.2.0" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, "node_modules/eslint-scope": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", @@ -5631,6 +5888,55 @@ "node": ">=8.0.0" } }, + "node_modules/eslint-visitor-keys": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", + "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/eslint-scope": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.0.1.tgz", + "integrity": "sha512-pL8XjgP4ZOmmwfFE8mEhSxA7ZY4C+LWyqjQ3o4yWkkmD0qcMT9kkW3zWHOczhWcjTSgqycYAgwSlXvZltv65og==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/eslint/node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/esm": { "version": "3.2.25", "resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz", @@ -5639,6 +5945,23 @@ "node": ">=6" } }, + "node_modules/espree": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.0.1.tgz", + "integrity": "sha512-MWkrWZbJsL2UwnjxTX3gG8FneachS/Mwg7tdGXce011sJd5b0JG54vat5KHnfSBODZ3Wvzd2WnjxyzsRoVv+ww==", + "dev": true, + "dependencies": { + "acorn": "^8.11.3", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, "node_modules/esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", @@ -5652,6 +5975,27 @@ "node": ">=4" } }, + "node_modules/esquery": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", + "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", + "dev": true, + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esquery/node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, "node_modules/esrecurse": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", @@ -5682,6 +6026,15 @@ "node": ">=4.0" } }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", @@ -5817,6 +6170,12 @@ "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", "dev": true }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true + }, "node_modules/fastest-levenshtein": { "version": "1.0.16", "resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz", @@ -5826,11 +6185,32 @@ "node": ">= 4.9.1" } }, + "node_modules/fastq": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", + "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", + "dev": true, + "dependencies": { + "reusify": "^1.0.4" + } + }, "node_modules/fecha": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/fecha/-/fecha-4.2.3.tgz", "integrity": "sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw==" }, + "node_modules/file-entry-cache": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "dev": true, + "dependencies": { + "flat-cache": "^4.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, "node_modules/file-stream-rotator": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/file-stream-rotator/-/file-stream-rotator-0.6.1.tgz", @@ -5943,6 +6323,25 @@ "flat": "cli.js" } }, + "node_modules/flat-cache": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", + "dev": true, + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.4" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/flatted": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz", + "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", + "dev": true + }, "node_modules/fn.name": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz", @@ -6328,12 +6727,15 @@ } }, "node_modules/globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.0.0.tgz", + "integrity": "sha512-m/C/yR4mjO6pXDTm9/R/SpYTAIyaUB4EOzcaaMEl7mds7Mshct9GfejiJNQGjHHbdMPey13Kpu4TMbYi9ex1pw==", "dev": true, "engines": { - "node": ">=4" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/gopd": { @@ -6548,6 +6950,15 @@ "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" }, + "node_modules/ignore": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", + "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, "node_modules/ignore-by-default": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", @@ -6567,6 +6978,31 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.1.tgz", "integrity": "sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g==" }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/import-fresh/node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/import-in-the-middle": { "version": "1.7.1", "resolved": "https://registry.npmjs.org/import-in-the-middle/-/import-in-the-middle-1.7.1.tgz", @@ -6758,6 +7194,15 @@ "node": ">=0.12.0" } }, + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/is-plain-obj": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", @@ -7133,6 +7578,12 @@ "bignumber.js": "^9.0.0" } }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true + }, "node_modules/json-parse-even-better-errors": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", @@ -7145,6 +7596,12 @@ "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true + }, "node_modules/json5": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", @@ -7201,6 +7658,15 @@ "safe-buffer": "^5.0.1" } }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "dependencies": { + "json-buffer": "3.0.1" + } + }, "node_modules/kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", @@ -7273,6 +7739,19 @@ "node": ">=0.10.0" } }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/load-bmfont": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/load-bmfont/-/load-bmfont-1.4.1.tgz", @@ -7855,6 +8334,12 @@ "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==" }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true + }, "node_modules/negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", @@ -8323,6 +8808,23 @@ "undici-types": "~5.26.4" } }, + "node_modules/optionator": { + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", + "integrity": "sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==", + "dev": true, + "dependencies": { + "@aashutoshrathi/word-wrap": "^1.2.3", + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -8394,6 +8896,18 @@ "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==" }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/parse-bmfont-ascii": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/parse-bmfont-ascii/-/parse-bmfont-ascii-1.0.6.tgz", @@ -8708,6 +9222,15 @@ "node": ">=10" } }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", @@ -8852,6 +9375,26 @@ "node": ">=0.4.x" } }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", @@ -9089,6 +9632,16 @@ "node": ">= 0.6" } }, + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true, + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, "node_modules/rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -9122,6 +9675,29 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, "node_modules/rxjs": { "version": "7.8.1", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", @@ -9976,6 +10552,12 @@ "resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz", "integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==" }, + "node_modules/text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", + "dev": true + }, "node_modules/tiktoken": { "version": "1.0.14", "resolved": "https://registry.npmjs.org/tiktoken/-/tiktoken-1.0.14.tgz", @@ -10132,6 +10714,18 @@ "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", "integrity": "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==" }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", @@ -10957,38 +11551,6 @@ "node-pty": "^1.0.0" } }, - "packages/phoenix/node_modules/@nodelib/fs.scandir": { - "version": "2.1.5", - "dev": true, - "license": "MIT", - "dependencies": { - "@nodelib/fs.stat": "2.0.5", - "run-parallel": "^1.1.9" - }, - "engines": { - "node": ">= 8" - } - }, - "packages/phoenix/node_modules/@nodelib/fs.stat": { - "version": "2.0.5", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 8" - } - }, - "packages/phoenix/node_modules/@nodelib/fs.walk": { - "version": "1.2.8", - "dev": true, - "license": "MIT", - "dependencies": { - "@nodelib/fs.scandir": "2.1.5", - "fastq": "^1.6.0" - }, - "engines": { - "node": ">= 8" - } - }, "packages/phoenix/node_modules/@pkgjs/parseargs": { "version": "0.11.0", "license": "MIT", @@ -11284,14 +11846,6 @@ "node": ">=8.6.0" } }, - "packages/phoenix/node_modules/fastq": { - "version": "1.15.0", - "dev": true, - "license": "ISC", - "dependencies": { - "reusify": "^1.0.4" - } - }, "packages/phoenix/node_modules/fs-extra": { "version": "8.1.0", "dev": true, @@ -11353,14 +11907,6 @@ "node": ">=8" } }, - "packages/phoenix/node_modules/ignore": { - "version": "5.2.4", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 4" - } - }, "packages/phoenix/node_modules/is-builtin-module": { "version": "3.2.1", "dev": true, @@ -11456,25 +12002,6 @@ "node": ">=8" } }, - "packages/phoenix/node_modules/queue-microtask": { - "version": "1.2.3", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, "packages/phoenix/node_modules/randomstring": { "version": "1.3.0", "license": "MIT", @@ -11492,15 +12019,6 @@ "version": "2.0.3", "license": "MIT" }, - "packages/phoenix/node_modules/reusify": { - "version": "1.0.4", - "dev": true, - "license": "MIT", - "engines": { - "iojs": ">=1.0.0", - "node": ">=0.10.0" - } - }, "packages/phoenix/node_modules/rollup": { "version": "3.21.4", "dev": true, @@ -11531,28 +12049,6 @@ "node": ">=8.3" } }, - "packages/phoenix/node_modules/run-parallel": { - "version": "1.2.0", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT", - "dependencies": { - "queue-microtask": "^1.2.2" - } - }, "packages/phoenix/node_modules/sinon": { "version": "17.0.1", "license": "BSD-3-Clause", @@ -11671,38 +12167,6 @@ "rollup-plugin-copy": "^3.4.0" } }, - "packages/terminal/node_modules/@nodelib/fs.scandir": { - "version": "2.1.5", - "dev": true, - "license": "MIT", - "dependencies": { - "@nodelib/fs.stat": "2.0.5", - "run-parallel": "^1.1.9" - }, - "engines": { - "node": ">= 8" - } - }, - "packages/terminal/node_modules/@nodelib/fs.stat": { - "version": "2.0.5", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 8" - } - }, - "packages/terminal/node_modules/@nodelib/fs.walk": { - "version": "1.2.8", - "dev": true, - "license": "MIT", - "dependencies": { - "@nodelib/fs.scandir": "2.1.5", - "fastq": "^1.6.0" - }, - "engines": { - "node": ">= 8" - } - }, "packages/terminal/node_modules/@rollup/plugin-commonjs": { "version": "24.1.0", "dev": true, @@ -11903,14 +12367,6 @@ "node": ">=8.6.0" } }, - "packages/terminal/node_modules/fastq": { - "version": "1.15.0", - "dev": true, - "license": "ISC", - "dependencies": { - "reusify": "^1.0.4" - } - }, "packages/terminal/node_modules/fs-extra": { "version": "8.1.0", "dev": true, @@ -12042,14 +12498,6 @@ "node": ">=0.10.0" } }, - "packages/terminal/node_modules/ignore": { - "version": "5.2.4", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 4" - } - }, "packages/terminal/node_modules/is-builtin-module": { "version": "3.2.1", "dev": true, @@ -12168,39 +12616,11 @@ "url": "https://github.com/sponsors/ljharb" } }, - "packages/terminal/node_modules/queue-microtask": { - "version": "1.2.3", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, "packages/terminal/node_modules/requires-port": { "version": "1.0.0", "dev": true, "license": "MIT" }, - "packages/terminal/node_modules/reusify": { - "version": "1.0.4", - "dev": true, - "license": "MIT", - "engines": { - "iojs": ">=1.0.0", - "node": ">=0.10.0" - } - }, "packages/terminal/node_modules/rollup": { "version": "3.23.0", "dev": true, @@ -12231,28 +12651,6 @@ "node": ">=8.3" } }, - "packages/terminal/node_modules/run-parallel": { - "version": "1.2.0", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT", - "dependencies": { - "queue-microtask": "^1.2.2" - } - }, "packages/terminal/node_modules/secure-compare": { "version": "3.0.1", "dev": true, diff --git a/package.json b/package.json index 339b62aa9..203820aa9 100644 --- a/package.json +++ b/package.json @@ -11,10 +11,13 @@ "lib": "lib" }, "devDependencies": { + "@eslint/js": "^9.1.1", "chalk": "^4.1.0", "clean-css": "^5.3.2", "dotenv": "^16.4.5", + "eslint": "^9.1.1", "express": "^4.18.2", + "globals": "^15.0.0", "html-entities": "^2.3.3", "nodemon": "^3.1.0", "uglify-js": "^3.17.4", diff --git a/packages/backend/src/api/filesystem/FlagParam.js b/packages/backend/src/api/filesystem/FlagParam.js index 1a688e113..3ba1b2b1c 100644 --- a/packages/backend/src/api/filesystem/FlagParam.js +++ b/packages/backend/src/api/filesystem/FlagParam.js @@ -16,6 +16,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ +const { APIError } = require('../../api/APIError'); + module.exports = class FlagParam { constructor (srckey, options) { this.srckey = srckey; diff --git a/packages/backend/src/api/filesystem/StringParam.js b/packages/backend/src/api/filesystem/StringParam.js index 674f21803..17e46231e 100644 --- a/packages/backend/src/api/filesystem/StringParam.js +++ b/packages/backend/src/api/filesystem/StringParam.js @@ -16,6 +16,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ +const { APIError } = require('../../api/APIError'); + module.exports = class StringParam { constructor (srckey, options) { this.srckey = srckey; diff --git a/packages/backend/src/connective/data_model.js b/packages/backend/src/connective/data_model.js deleted file mode 100644 index eaa8e55bc..000000000 --- a/packages/backend/src/connective/data_model.js +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2024 Puter Technologies Inc. - * - * This file is part of Puter. - * - * Puter is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -{ - registries: { - type: { - description: 'high-level types' - } - } -} diff --git a/packages/backend/src/connective/registry.js b/packages/backend/src/connective/registry.js deleted file mode 100644 index 1e45aa3a9..000000000 --- a/packages/backend/src/connective/registry.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2024 Puter Technologies Inc. - * - * This file is part of Puter. - * - * Puter is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -class Registry { - constructor() { - this._registry = {}; - } - - put(name, value) { - this._registry[name] = value; - } - - get(name) { - return this._registry[name]; - } -} diff --git a/packages/backend/src/filesystem/FilesystemService.js b/packages/backend/src/filesystem/FilesystemService.js index 3322e07fc..959264d88 100644 --- a/packages/backend/src/filesystem/FilesystemService.js +++ b/packages/backend/src/filesystem/FilesystemService.js @@ -138,7 +138,6 @@ class FilesystemService extends AdvancedBase { return permission.startsWith('fs:'); }, checker: async (actor, permission) => { - debugger; if ( !(actor.type instanceof UserActorType) ) { return undefined; } @@ -363,7 +362,7 @@ class FilesystemService extends AdvancedBase { [new_path, old_path.length + 1, old_path + '%', user_id] ); - const log = services.get('log-service').create('update_child_paths'); + const log = this.services.get('log-service').create('update_child_paths'); log.info(`updated ${old_path} -> ${new_path}`); monitor.end(); diff --git a/packages/backend/src/filesystem/batch/BatchExecutor.js b/packages/backend/src/filesystem/batch/BatchExecutor.js index bf4e6562c..6da8e00bc 100644 --- a/packages/backend/src/filesystem/batch/BatchExecutor.js +++ b/packages/backend/src/filesystem/batch/BatchExecutor.js @@ -118,7 +118,7 @@ class BatchExecutor extends AdvancedBase { alarm: true, }); - e = APIError.adapt(e); + e = APIError.adapt(e); // eslint-disable-line no-ex-assign } // Consume stream if there's a file diff --git a/packages/backend/src/filesystem/hl_operations/hl_data_read.js b/packages/backend/src/filesystem/hl_operations/hl_data_read.js index a942fa346..e19e9530a 100644 --- a/packages/backend/src/filesystem/hl_operations/hl_data_read.js +++ b/packages/backend/src/filesystem/hl_operations/hl_data_read.js @@ -18,6 +18,9 @@ */ const { stream_to_buffer } = require("../../util/streamutil"); const { HLFilesystemOperation } = require("./definitions"); +const { chkperm } = require('../../helpers'); +const { LLRead } = require('../ll_operations/ll_read'); +const { APIError } = require('../../api/APIError'); /** * HLDataRead reads a stream of objects from a file containing structured data. @@ -38,6 +41,7 @@ class HLDataRead extends HLFilesystemOperation { const { fsNode, + version_id, } = this.values; if ( ! await fsNode.exists() ) { @@ -85,6 +89,7 @@ class HLDataRead extends HLFilesystemOperation { } _stream_jsonl_lines_to_objects (stream) { + const { PassThrough } = this.modules.stream; const output_stream = new PassThrough(); (async () => { for await (const line of stream) { diff --git a/packages/backend/src/filesystem/hl_operations/hl_mkdir.js b/packages/backend/src/filesystem/hl_operations/hl_mkdir.js index 86f84ca77..7a3692443 100644 --- a/packages/backend/src/filesystem/hl_operations/hl_mkdir.js +++ b/packages/backend/src/filesystem/hl_operations/hl_mkdir.js @@ -63,6 +63,7 @@ class MkTree extends HLFilesystemOperation { async _run () { const { values, context } = this; + const fs = context.get('services').get('filesystem'); await this.create_branch_({ parent_node: values.parent || await fs.node(new RootNodeSelector()), diff --git a/packages/backend/src/filesystem/hl_operations/hl_move.js b/packages/backend/src/filesystem/hl_operations/hl_move.js index a545f517d..1fd4b801c 100644 --- a/packages/backend/src/filesystem/hl_operations/hl_move.js +++ b/packages/backend/src/filesystem/hl_operations/hl_move.js @@ -17,7 +17,7 @@ * along with this program. If not, see . */ const APIError = require("../../api/APIError"); -const { chkperm, validate_fsentry_name, is_ancestor_of } = require("../../helpers"); +const { chkperm, validate_fsentry_name, is_ancestor_of, df, get_user } = require("../../helpers"); const { LLMove } = require("../ll_operations/ll_move"); const { RootNodeSelector } = require("../node/selectors"); const { HLFilesystemOperation } = require("./definitions"); diff --git a/packages/backend/src/filesystem/hl_operations/hl_read.js b/packages/backend/src/filesystem/hl_operations/hl_read.js index 130b974dd..56de932a8 100644 --- a/packages/backend/src/filesystem/hl_operations/hl_read.js +++ b/packages/backend/src/filesystem/hl_operations/hl_read.js @@ -41,7 +41,7 @@ class HLRead extends HLFilesystemOperation { } const ll_read = new LLRead(); - const stream = await ll_read.run({ + let stream = await ll_read.run({ fsNode, actor, version_id, ...(byte_count !== undefined ? { diff --git a/packages/backend/src/filesystem/hl_operations/hl_stat.js b/packages/backend/src/filesystem/hl_operations/hl_stat.js index ed5d21f1e..a8ea07a3d 100644 --- a/packages/backend/src/filesystem/hl_operations/hl_stat.js +++ b/packages/backend/src/filesystem/hl_operations/hl_stat.js @@ -19,6 +19,7 @@ const { chkperm } = require("../../helpers"); const { Context } = require("../../util/context"); const { HLFilesystemOperation } = require("./definitions"); +const { APIError } = require('../../api/APIError'); class HLStat extends HLFilesystemOperation { static MODULES = { diff --git a/packages/backend/src/filesystem/lib/PuterPath.js b/packages/backend/src/filesystem/lib/PuterPath.js index db12145b2..2d2d676ca 100644 --- a/packages/backend/src/filesystem/lib/PuterPath.js +++ b/packages/backend/src/filesystem/lib/PuterPath.js @@ -64,10 +64,6 @@ class PuterPath { return ! this.isAbsolute(); } - get hasRelativePortion () { - - } - get reference () { if ( this.isAbsolute ) return this.constructor.NULL_UUID; diff --git a/packages/backend/src/filesystem/ll_operations/ll_copy_idea.js b/packages/backend/src/filesystem/ll_operations/ll_copy_idea.js index 3ee21ac92..e3909defe 100644 --- a/packages/backend/src/filesystem/ll_operations/ll_copy_idea.js +++ b/packages/backend/src/filesystem/ll_operations/ll_copy_idea.js @@ -30,6 +30,7 @@ - easier to diagnose stuck operations */ +/* eslint-disable */ const STEPS_COPY_CONTENTS = [ { diff --git a/packages/backend/src/filesystem/ll_operations/ll_read.js b/packages/backend/src/filesystem/ll_operations/ll_read.js index c2279e9c6..a133c74b3 100644 --- a/packages/backend/src/filesystem/ll_operations/ll_read.js +++ b/packages/backend/src/filesystem/ll_operations/ll_read.js @@ -91,7 +91,7 @@ class LLRead extends LLFilesystemOperation { const context = a.iget('context'); const svc_fileCache = context.get('services').get('file-cache'); - const { fsNode } = a.values(); + const { fsNode, offset, length } = a.values(); const maybe_buffer = await svc_fileCache.try_get(fsNode, a.log); if ( maybe_buffer ) { diff --git a/packages/backend/src/filesystem/ll_operations/ll_rmnode.js b/packages/backend/src/filesystem/ll_operations/ll_rmnode.js index cb4d24692..0fa6c11fc 100644 --- a/packages/backend/src/filesystem/ll_operations/ll_rmnode.js +++ b/packages/backend/src/filesystem/ll_operations/ll_rmnode.js @@ -19,6 +19,7 @@ const { Context } = require("../../util/context"); const { ParallelTasks } = require("../../util/otelutil"); const { LLFilesystemOperation } = require("./definitions"); +const { APIError } = require("../../api/APIError"); class LLRmNode extends LLFilesystemOperation { async _run () { diff --git a/packages/backend/src/filesystem/storage/SystemFSEntryService.js b/packages/backend/src/filesystem/storage/SystemFSEntryService.js index e9abb9bae..6cc8ef4b6 100644 --- a/packages/backend/src/filesystem/storage/SystemFSEntryService.js +++ b/packages/backend/src/filesystem/storage/SystemFSEntryService.js @@ -17,6 +17,7 @@ * along with this program. If not, see . */ const { PuterPath } = require("../lib/PuterPath"); +const _path = require('path'); // Redis keys: // ::::: diff --git a/packages/backend/src/filesystem/validation.js b/packages/backend/src/filesystem/validation.js index bec9875a6..a9cf934eb 100644 --- a/packages/backend/src/filesystem/validation.js +++ b/packages/backend/src/filesystem/validation.js @@ -22,10 +22,12 @@ This module contains functions that validate filesystem operations. */ +/* eslint-disable no-control-regex */ + const config = require("../config"); const path_excludes = () => /[\x00-\x1F]/g; -const node_excludes = () => /[\/\x00-\x1F]/g; +const node_excludes = () => /[/\x00-\x1F]/g; // this characters are not allowed in path names because // they might be used to trick the user into thinking diff --git a/packages/backend/src/helpers.js b/packages/backend/src/helpers.js index 2c951ae42..06cabf757 100644 --- a/packages/backend/src/helpers.js +++ b/packages/backend/src/helpers.js @@ -681,7 +681,7 @@ const get_descendants_0 = async (path, user, depth, return_thumbnail = false) => [user.id] ); // users that have shared files/dirs with this user - sharing_users = await db.read( + const sharing_users = await db.read( `SELECT DISTINCT(owner_user_id), user.username FROM share INNER JOIN user ON user.id = share.owner_user_id @@ -719,7 +719,7 @@ const get_descendants_0 = async (path, user, depth, return_thumbnail = false) => return []; // shared files/dirs with this user - shared_fsentries = await db.read( + const shared_fsentries = await db.read( `SELECT fsentries.id, fsentries.user_id, fsentries.uuid, fsentries.parent_uid, fsentries.bucket, fsentries.bucket_region, fsentries.name, fsentries.shortcut_to, fsentries.is_shortcut, fsentries.metadata, fsentries.is_dir, fsentries.modified, @@ -899,7 +899,7 @@ const get_descendants = async (...args) => { if ( ! result || ! result[0] ) { errors.report('id2path.select', { alarm: true, - message: `no result for ${entry_uid}: ${e.message}`, + message: `no result for ${entry_uid}`, extra: { entry_uid, } @@ -953,12 +953,12 @@ function cp(source_path, dest_path, user, overwrite, change_name, check_perms = throw new Error(`legacy copy function called`); } -isString = function (variable) { +function isString(variable) { return typeof variable === 'string' || variable instanceof String; } // checks to see if given variable is an object -isObject = function (variable) { +function isObject(variable) { return variable !== null && typeof variable === 'object'; } @@ -1809,7 +1809,7 @@ async function get_taskbar_items(user) { try { taskbar_items_from_db = JSON.parse(user.taskbar_items); }catch(e){ - + // ignore errors } } diff --git a/packages/backend/src/om/entitystorage/ValidationES.js b/packages/backend/src/om/entitystorage/ValidationES.js index a624ac6ee..affe7e446 100644 --- a/packages/backend/src/om/entitystorage/ValidationES.js +++ b/packages/backend/src/om/entitystorage/ValidationES.js @@ -86,6 +86,7 @@ class ValidationES extends BaseES { } catch ( e ) { if ( ! (e instanceof APIError) ) { console.log('THIS IS HAPPENING', e); + // eslint-disable-next-line no-ex-assign e = APIError.create('field_invalid', null, { key: prop.name, converted_from_another_error: true, diff --git a/packages/backend/src/om/proptypes/__all__.js b/packages/backend/src/om/proptypes/__all__.js index e57b66edb..231d75000 100644 --- a/packages/backend/src/om/proptypes/__all__.js +++ b/packages/backend/src/om/proptypes/__all__.js @@ -163,7 +163,7 @@ module.exports = { }, async adapt (value, { descriptor }) { if ( descriptor.debug ) { - debugger; + debugger; // eslint-disable-line no-debugger } if ( ! descriptor.service ) return value; if ( ! value ) return null; diff --git a/packages/backend/src/routers/_default.js b/packages/backend/src/routers/_default.js index d8ef7ec49..ff95a02aa 100644 --- a/packages/backend/src/routers/_default.js +++ b/packages/backend/src/routers/_default.js @@ -402,7 +402,7 @@ router.all('*', async function(req, res, next) { }); } catch (e) { console.error('error from sendFile', e); - return res.status(err.statusCode).send('Error /apps/') + return res.status(e.statusCode).send('Error /apps/') } } // -------------------------------------- diff --git a/packages/backend/src/routers/auth/list-permissions.js b/packages/backend/src/routers/auth/list-permissions.js index 486b509a6..096ba23c0 100644 --- a/packages/backend/src/routers/auth/list-permissions.js +++ b/packages/backend/src/routers/auth/list-permissions.js @@ -21,6 +21,7 @@ const { get_app, get_user } = require("../../helpers"); const { UserActorType } = require("../../services/auth/Actor"); const { DB_READ } = require("../../services/database/consts"); const { Context } = require("../../util/context"); +const { APIError } = require('../../api/APIError'); module.exports = eggspress('/auth/list-permissions', { subdomain: 'api', diff --git a/packages/backend/src/routers/auth/list-sessions.js b/packages/backend/src/routers/auth/list-sessions.js index a163c78c7..9d4992c08 100644 --- a/packages/backend/src/routers/auth/list-sessions.js +++ b/packages/backend/src/routers/auth/list-sessions.js @@ -1,6 +1,7 @@ const eggspress = require("../../api/eggspress"); const { UserActorType } = require("../../services/auth/Actor"); const { Context } = require("../../util/context"); +const { APIError } = require('../../api/APIError'); module.exports = eggspress('/auth/list-sessions', { subdomain: 'api', diff --git a/packages/backend/src/routers/auth/revoke-user-app.js b/packages/backend/src/routers/auth/revoke-user-app.js index 00d81b38c..7087b9766 100644 --- a/packages/backend/src/routers/auth/revoke-user-app.js +++ b/packages/backend/src/routers/auth/revoke-user-app.js @@ -19,6 +19,7 @@ const eggspress = require("../../api/eggspress"); const { UserActorType } = require("../../services/auth/Actor"); const { Context } = require("../../util/context"); +const { APIError } = require('../../api/APIError'); module.exports = eggspress('/auth/revoke-user-app', { subdomain: 'api', diff --git a/packages/backend/src/routers/delete-site.js b/packages/backend/src/routers/delete-site.js index 66ce2f297..fc152e1f6 100644 --- a/packages/backend/src/routers/delete-site.js +++ b/packages/backend/src/routers/delete-site.js @@ -40,7 +40,6 @@ router.post('/delete-site', auth, express.json(), async (req, res, next)=>{ return res.status(400).send('site_uuid is required') // modules - const {} = require('../helpers'); const db = req.services.get('database').get(DB_WRITE, 'subdomains:legacy'); await db.write( diff --git a/packages/backend/src/routers/drivers/usage.js b/packages/backend/src/routers/drivers/usage.js index 67fab56b2..5d53f7bbd 100644 --- a/packages/backend/src/routers/drivers/usage.js +++ b/packages/backend/src/routers/drivers/usage.js @@ -143,7 +143,7 @@ module.exports = eggspress('/drivers/usage', { // usages.apps.push(usage); } - for ( k in usages.apps ) { + for ( const k in usages.apps ) { usages.apps[k] = Object.values(usages.apps[k]); } diff --git a/packages/backend/src/routers/drivers/xd.js b/packages/backend/src/routers/drivers/xd.js index e413fefb1..cf08d44a1 100644 --- a/packages/backend/src/routers/drivers/xd.js +++ b/packages/backend/src/routers/drivers/xd.js @@ -65,8 +65,9 @@ const script = async function script () { return await response.json(); }; + /* global window */ window.addEventListener('message', async event => { - const { id, interface, method, params } = event.data; + const { id, interface: interface_, method, params } = event.data; let has_file = false; for ( const k in params ) { if ( params[k] instanceof File ) { @@ -75,11 +76,11 @@ const script = async function script () { } } const result = has_file ? await fcall({ - interface_name: interface, + interface_name: interface_, method_name: method, params, }) : await call({ - interface_name: interface, + interface_name: interface_, method_name: method, params, }); diff --git a/packages/backend/src/routers/filesystem_api/batch/all.js b/packages/backend/src/routers/filesystem_api/batch/all.js index ed4c6b584..f09b6d45f 100644 --- a/packages/backend/src/routers/filesystem_api/batch/all.js +++ b/packages/backend/src/routers/filesystem_api/batch/all.js @@ -26,6 +26,7 @@ const Busboy = require('busboy'); const { BatchExecutor } = require("../../../filesystem/batch/BatchExecutor"); const { TeePromise } = require("../../../util/promise"); const { EWMA, MovingMode } = require("../../../util/opmath"); +const { get_app } = require('../../../helpers'); const commands = require('../../../filesystem/batch/commands.js').commands; @@ -221,28 +222,6 @@ module.exports = eggspress('/batch', { let ps = []; busboy.on('file', async (fieldname, stream, detais) => { - if (false) { - ended[i] = false; - ps[i] = new TeePromise(); - const this_i = i; - stream.on('end', () => { - ps[this_i].resolve(); - ended[this_i] = true; - batch_widget.ec++; - }); - if ( i > 0 ) { - if ( ! ended[i-1] ) { - batch_widget.sc++; - // stream.pause(); - batch_widget.wc++; - await Promise.all(Array(i).fill(0).map((_, j) => ps[j])); - batch_widget.wc--; - // stream.resume(); - } - } - i++; - } - if ( batch_exe.total_tbd ) { batch_exe.total_tbd = false; batch_widget.ic = pending_operations.length; diff --git a/packages/backend/src/routers/filesystem_api/copy.js b/packages/backend/src/routers/filesystem_api/copy.js index bc070cc6a..9860c0f1d 100644 --- a/packages/backend/src/routers/filesystem_api/copy.js +++ b/packages/backend/src/routers/filesystem_api/copy.js @@ -66,18 +66,6 @@ module.exports = eggspress('/copy', { x.set(operationTraceSvc.ckey('frame'), frame); } - // TEMP: Testing copy with its own sql queue - if ( false ) { - const x = Context.get(); - const svc = new ProxyContainer(x.get('services')); - const s = new DatabaseFSEntryService({ - services: x.get('services'), - label: 'Copy-DatabaseFSEntryService', - }); - svc.set('systemFSEntryService', s); - x.set('services', svc); - } - const log = req.services.get('log-service').create('copy'); const filesystem = req.services.get('filesystem'); @@ -103,7 +91,6 @@ module.exports = eggspress('/copy', { source: req.values.source, new_name: req.body.new_name, - new_name: req.body.new_name, overwrite: req.body.overwrite ?? false, dedupe_name, diff --git a/packages/backend/src/routers/filesystem_api/read.js b/packages/backend/src/routers/filesystem_api/read.js index 8536f5520..320d2026c 100644 --- a/packages/backend/src/routers/filesystem_api/read.js +++ b/packages/backend/src/routers/filesystem_api/read.js @@ -74,15 +74,4 @@ module.exports = eggspress('/read', { res.set('Content-Type', 'application/octet-stream'); stream.pipe(res); - - return; - - const filesystem = req.services.get('filesystem'); - await filesystem.read(req.fs, res, { - ...req.values, - user: req.user, - version_id: req.query.version_id, - line_count, - byte_count, - }); }); diff --git a/packages/backend/src/routers/filesystem_api/token-read.js b/packages/backend/src/routers/filesystem_api/token-read.js index 2da57f73b..d00be92e4 100644 --- a/packages/backend/src/routers/filesystem_api/token-read.js +++ b/packages/backend/src/routers/filesystem_api/token-read.js @@ -49,12 +49,10 @@ module.exports = eggspress('/token-read', { const actor = await svc_auth.authenticate_from_token(access_jwt); if ( ! actor ) { - throw new Error('A'); throw APIError.create('token_auth_failed'); } if ( ! (actor.type instanceof AccessTokenActorType) ) { - throw new Error('B'); throw APIError.create('token_auth_failed'); } @@ -98,16 +96,5 @@ module.exports = eggspress('/token-read', { res.setHeader('Content-Type', mime_type); stream.pipe(res); - - return; - - const filesystem = req.services.get('filesystem'); - await filesystem.read(req.fs, res, { - ...req.values, - user: req.user, - version_id: req.query.version_id, - line_count, - byte_count, - }); }); diff --git a/packages/backend/src/routers/hosting/puter-site.js b/packages/backend/src/routers/hosting/puter-site.js index 1a59e645e..fab6ba458 100644 --- a/packages/backend/src/routers/hosting/puter-site.js +++ b/packages/backend/src/routers/hosting/puter-site.js @@ -62,7 +62,7 @@ class PuterSiteMiddleware extends AdvancedBase { req.subdomains[0] === 'devtest' ? 'devtest' : req.hostname.slice(0, -1 * (config.static_hosting_domain.length + 1)); - let path = (req.baseUrl + req.path) ?? 'index.html'; + let path = (req.baseUrl + req.path) || 'index.html'; const context = Context.get(); const services = context.get('services'); diff --git a/packages/backend/src/routers/open_item.js b/packages/backend/src/routers/open_item.js index b4d0599d0..cdd94f863 100644 --- a/packages/backend/src/routers/open_item.js +++ b/packages/backend/src/routers/open_item.js @@ -45,7 +45,7 @@ module.exports = eggspress('/open_item', { const subject = req.values.subject; const actor = Context.get('actor'); - if ( ! actor.type instanceof UserActorType ) { + if ( ! (actor.type instanceof UserActorType) ) { throw APIError.create('forbidden'); } diff --git a/packages/backend/src/routers/save_account.js b/packages/backend/src/routers/save_account.js index 67876fbfb..d28c52f1e 100644 --- a/packages/backend/src/routers/save_account.js +++ b/packages/backend/src/routers/save_account.js @@ -19,7 +19,7 @@ "use strict" const express = require('express'); const router = new express.Router(); -const {get_taskbar_items, username_exists, send_email_verification_code, send_email_verification_token, invalidate_cached_user} = require('../helpers'); +const {get_taskbar_items, username_exists, send_email_verification_code, send_email_verification_token, invalidate_cached_user, get_user } = require('../helpers'); const auth = require('../middleware/auth.js'); const config = require('../config'); const { Context } = require('../util/context'); @@ -85,11 +85,6 @@ router.post('/save_account', auth, express.json(), async (req, res, next)=>{ // get pseudo user, if exists let pseudo_user = await db.read(`SELECT * FROM user WHERE email = ? AND password IS NULL`, [req.body.email]); pseudo_user = pseudo_user[0]; - // get uuid user, if exists - if(req.body.uuid){ - uuid_user = await db.read(`SELECT * FROM user WHERE uuid = ? LIMIT 1`, [req.body.uuid]); - uuid_user = uuid_user[0]; - } // send_confirmation_code req.body.send_confirmation_code = req.body.send_confirmation_code ?? true; diff --git a/packages/backend/src/routers/sign.js b/packages/backend/src/routers/sign.js index 9a8d6aa58..df91c9bff 100644 --- a/packages/backend/src/routers/sign.js +++ b/packages/backend/src/routers/sign.js @@ -34,7 +34,7 @@ module.exports = eggspress('/sign', { allowedMethods: ['POST'], }, async (req, res, next)=>{ const actor = Context.get('actor'); - if ( ! actor.type instanceof UserActorType ) { + if ( ! (actor.type instanceof UserActorType) ) { throw APIError.create('forbidden'); } @@ -62,7 +62,8 @@ module.exports = eggspress('/sign', { app = await get_app({ uid: req.body.app_uid }); if ( ! app ) { - throw APIError.create('no_suitable_app', null, { entry_name: subject.entry.name }); + // FIXME: subject.entry.name isn't available here + throw APIError.create('no_suitable_app', null); //, { entry_name: subject.entry.name }); } // Generate user-app token const svc_auth = Context.get('services').get('auth'); @@ -111,7 +112,7 @@ module.exports = eggspress('/sign', { const svc_acl = Context.get('services').get('acl'); if ( ! await svc_acl.check(actor, node, 'see') ) { - throw await svc_acl.get_safe_acl_error(actor, subject, 'see'); + throw await svc_acl.get_safe_acl_error(actor, node, 'see'); } if ( app !== null ) { diff --git a/packages/backend/src/services/ComplainAboutVersionsService.js b/packages/backend/src/services/ComplainAboutVersionsService.js index 4a65ba492..61d084b87 100644 --- a/packages/backend/src/services/ComplainAboutVersionsService.js +++ b/packages/backend/src/services/ComplainAboutVersionsService.js @@ -27,7 +27,7 @@ class ComplainAboutVersionsService extends BaseService { if ( ! current_version_data ) { this.log.warn( - `failed to check ${current_version} in the EOL database` + `failed to check ${major} in the EOL database` ); return; } diff --git a/packages/backend/src/services/ContextInitService.js b/packages/backend/src/services/ContextInitService.js index ac30cfb3b..3267d8819 100644 --- a/packages/backend/src/services/ContextInitService.js +++ b/packages/backend/src/services/ContextInitService.js @@ -52,7 +52,7 @@ class ContextInitService extends BaseService { key, value, }); } - register_async_factory (key, factory) { + register_async_factory (key, async_factory) { this.mw.register_initializer({ key, async_factory, }); diff --git a/packages/backend/src/services/StorageService.js b/packages/backend/src/services/StorageService.js index 8e67d3e48..c10f98125 100644 --- a/packages/backend/src/services/StorageService.js +++ b/packages/backend/src/services/StorageService.js @@ -20,6 +20,7 @@ const { AdvancedBase } = require("@heyputer/puter-js-common"); class StorageService extends AdvancedBase { constructor ({ services }) { + super(services); // } } \ No newline at end of file diff --git a/packages/backend/src/services/WebServerService.js b/packages/backend/src/services/WebServerService.js index 76db5cd1a..597c3fa73 100644 --- a/packages/backend/src/services/WebServerService.js +++ b/packages/backend/src/services/WebServerService.js @@ -255,7 +255,7 @@ class WebServerService extends BaseService { onFinished(res, () => { if ( res.statusCode !== 500 ) return; if ( req.__error_handled ) return; - const alarm = services.get('alarm'); + const alarm = this.services.get('alarm'); alarm.create('responded-500', 'server sent a 500 response', { error: req.__error_source, url: req.url, diff --git a/packages/backend/src/services/auth/AuthService.js b/packages/backend/src/services/auth/AuthService.js index 5df6fd187..b6d282317 100644 --- a/packages/backend/src/services/auth/AuthService.js +++ b/packages/backend/src/services/auth/AuthService.js @@ -55,27 +55,6 @@ class AuthService extends BaseService { if ( ! decoded.hasOwnProperty('type') ) { throw new LegacyTokenError(); - const user = await this.db.requireRead( - "SELECT * FROM `user` WHERE `uuid` = ? LIMIT 1", - [decoded.uuid], - ); - - if ( ! user[0] ) { - throw APIError.create('token_auth_failed'); - } - - if ( user[0].suspended ) { - throw APIError.create('account_suspended'); - } - - const actor_type = new UserActorType({ - user: user[0], - }); - - return new Actor({ - user_uid: decoded.uuid, - type: actor_type, - }); } if ( decoded.type === 'session' ) { diff --git a/packages/backend/src/services/auth/TokenService.js b/packages/backend/src/services/auth/TokenService.js index 1dda5ff1b..f3febad10 100644 --- a/packages/backend/src/services/auth/TokenService.js +++ b/packages/backend/src/services/auth/TokenService.js @@ -1,6 +1,6 @@ const BaseService = require("../BaseService"); -def = o => { +const def = o => { for ( let k in o ) { if ( typeof o[k] === 'string' ) { o[k] = { short: o[k] }; @@ -15,7 +15,7 @@ def = o => { }; } -defv = o => { +const defv = o => { return { to_short: o, to_long: Object.keys(o).reduce((acc, key) => { diff --git a/packages/backend/src/services/drivers/implementations/BaseImplementation.js b/packages/backend/src/services/drivers/implementations/BaseImplementation.js index a7797f942..af1a5ac94 100644 --- a/packages/backend/src/services/drivers/implementations/BaseImplementation.js +++ b/packages/backend/src/services/drivers/implementations/BaseImplementation.js @@ -60,6 +60,7 @@ class BaseImplementation extends AdvancedBase { async _sla_enforcement (method) { const context = Context.get(); + const services = context.get('services'); const method_key = `${this.constructor.ID}:${method}`; const svc_sla = services.get('sla'); diff --git a/packages/backend/src/services/drivers/implementations/PuterDriverProxy.js b/packages/backend/src/services/drivers/implementations/PuterDriverProxy.js index a3f72920a..422bdc9d7 100644 --- a/packages/backend/src/services/drivers/implementations/PuterDriverProxy.js +++ b/packages/backend/src/services/drivers/implementations/PuterDriverProxy.js @@ -41,6 +41,7 @@ class PuterDriverProxy extends AdvancedBase { } constructor ({ target }) { + super(); this.target = target; } diff --git a/packages/backend/src/services/drivers/meta/Construct.js b/packages/backend/src/services/drivers/meta/Construct.js index b073745e5..57f8cf93d 100644 --- a/packages/backend/src/services/drivers/meta/Construct.js +++ b/packages/backend/src/services/drivers/meta/Construct.js @@ -119,10 +119,6 @@ class TypeSpec extends BasicBase { equals (other) { return this.raw.$ === other.raw.$; - // for ( k in this.raw ) { - // if ( this.raw[k] !== other.raw[k] ) return false; - // } - return true; } toString () { diff --git a/packages/backend/src/services/runtime-analysis/ExpectationService.js b/packages/backend/src/services/runtime-analysis/ExpectationService.js index df24dc2d3..fc1070e09 100644 --- a/packages/backend/src/services/runtime-analysis/ExpectationService.js +++ b/packages/backend/src/services/runtime-analysis/ExpectationService.js @@ -91,12 +91,13 @@ class ExpectationService extends BaseService { purgeExpectations_ () { return; - for ( let i=0 ; i < this.expectations_.length ; i++ ) { - if ( this.expectations_[i].check() ) { - this.expectations_[i] = null; - } - } - this.expectations_ = this.expectations_.filter(v => v !== null); + // TODO: Re-enable this + // for ( let i=0 ; i < this.expectations_.length ; i++ ) { + // if ( this.expectations_[i].check() ) { + // this.expectations_[i] = null; + // } + // } + // this.expectations_ = this.expectations_.filter(v => v !== null); } expect_eventually ({ workUnit, checkpoint }) { diff --git a/packages/backend/src/services/runtime-analysis/PagerService.js b/packages/backend/src/services/runtime-analysis/PagerService.js index ccdc304f3..82d98a37b 100644 --- a/packages/backend/src/services/runtime-analysis/PagerService.js +++ b/packages/backend/src/services/runtime-analysis/PagerService.js @@ -18,6 +18,7 @@ */ const pdjs = require('@pagerduty/pdjs'); const BaseService = require('../BaseService'); +const util = require('util'); class PagerService extends BaseService { async _construct () { diff --git a/packages/backend/src/util/stdioutil.js b/packages/backend/src/util/stdioutil.js index 1cfd99db0..c8abb4b45 100644 --- a/packages/backend/src/util/stdioutil.js +++ b/packages/backend/src/util/stdioutil.js @@ -23,6 +23,7 @@ * @param {*} str */ const visible_length = (str) => { + // eslint-disable-next-line no-control-regex return str.replace(/\x1b\[[0-9;]*m/g, '').length; }; diff --git a/packages/backend/src/util/streamutil.js b/packages/backend/src/util/streamutil.js index d6b2596a7..bd0e92dcb 100644 --- a/packages/backend/src/util/streamutil.js +++ b/packages/backend/src/util/streamutil.js @@ -365,7 +365,7 @@ const stuck_detector_stream = (source, { return stream; } -string_to_stream = (str, chunk_size) => { +const string_to_stream = (str, chunk_size) => { const s = new Readable(); s._read = () => {}; // redundant? see update below // split string into chunks diff --git a/packages/backend/src/util/strutil.js b/packages/backend/src/util/strutil.js index c520836e6..4701fc475 100644 --- a/packages/backend/src/util/strutil.js +++ b/packages/backend/src/util/strutil.js @@ -39,7 +39,7 @@ const osclink = (url, text) => { return `\x1B]8;;${url}\x1B\\${text}\x1B]8;;\x1B\\`; } -format_as_usd = (amount) => { +const format_as_usd = (amount) => { if ( amount < 0.01 ) { if ( amount < 0.00001 ) { // scientific notation diff --git a/packages/phoenix/rollup.config.js b/packages/phoenix/rollup.config.js index 27c803247..fd090bbb8 100644 --- a/packages/phoenix/rollup.config.js +++ b/packages/phoenix/rollup.config.js @@ -19,6 +19,7 @@ import { nodeResolve } from '@rollup/plugin-node-resolve' import commonjs from '@rollup/plugin-commonjs'; import copy from 'rollup-plugin-copy'; +import process from 'node:process'; const configFile = process.env.CONFIG_FILE ?? 'config/dev.js'; await import(`./${configFile}`); diff --git a/packages/phoenix/src/ansi-shell/ANSIShell.js b/packages/phoenix/src/ansi-shell/ANSIShell.js index 0eb151e8c..68f260a48 100644 --- a/packages/phoenix/src/ansi-shell/ANSIShell.js +++ b/packages/phoenix/src/ansi-shell/ANSIShell.js @@ -83,7 +83,7 @@ export class ANSIShell extends EventTarget { Object.defineProperty(this.env, 'PWD', { enumerable: true, get: () => this.variables.pwd, - set: v => this.variables.pwd = v + set: v => { this.variables.pwd = v } }) Object.defineProperty(this.env, 'ROWS', { enumerable: true, diff --git a/packages/phoenix/src/ansi-shell/arg-parsers/simple-parser.js b/packages/phoenix/src/ansi-shell/arg-parsers/simple-parser.js index a0fc8ff4d..2d806b00b 100644 --- a/packages/phoenix/src/ansi-shell/arg-parsers/simple-parser.js +++ b/packages/phoenix/src/ansi-shell/arg-parsers/simple-parser.js @@ -27,7 +27,6 @@ export default { let result; try { - if ( ! ctx.locals.args ) debugger; result = parseArgs({ ...spec, args: ctx.locals.args }); } catch (e) { await ctx.externs.out.write( diff --git a/packages/phoenix/src/ansi-shell/ioutil/SignalReader.js b/packages/phoenix/src/ansi-shell/ioutil/SignalReader.js index b7eafc86e..17ea234b5 100644 --- a/packages/phoenix/src/ansi-shell/ioutil/SignalReader.js +++ b/packages/phoenix/src/ansi-shell/ioutil/SignalReader.js @@ -40,9 +40,9 @@ export class SignalReader extends ProxyReader { return { value, done }; } - const tmp_value = value; + let tmp_value = value; - if ( ! tmp_value instanceof Uint8Array ) { + if ( ! (tmp_value instanceof Uint8Array) ) { tmp_value = encoder.encode(value); } diff --git a/packages/phoenix/src/ansi-shell/parsing/PuterShellParser.js b/packages/phoenix/src/ansi-shell/parsing/PuterShellParser.js index 8dc2626c9..3c87dbf89 100644 --- a/packages/phoenix/src/ansi-shell/parsing/PuterShellParser.js +++ b/packages/phoenix/src/ansi-shell/parsing/PuterShellParser.js @@ -21,10 +21,7 @@ import { buildParserFirstHalf } from "./buildParserFirstHalf.js"; import { buildParserSecondHalf } from "./buildParserSecondHalf.js"; export class PuterShellParser { - constructor () { - { - } - } + constructor () {} parseLineForSyntax () {} parseLineForProcessing (input) { const sp = new StrataParser(); diff --git a/packages/phoenix/src/ansi-shell/pipeline/Coupler.js b/packages/phoenix/src/ansi-shell/pipeline/Coupler.js index 7ad454a74..ad40b9c08 100644 --- a/packages/phoenix/src/ansi-shell/pipeline/Coupler.js +++ b/packages/phoenix/src/ansi-shell/pipeline/Coupler.js @@ -68,7 +68,6 @@ export class Coupler { break; } if ( this.on_ ) { - if ( ! value ) debugger; await this.target.write(value); } } diff --git a/packages/phoenix/src/ansi-shell/readline/readline.js b/packages/phoenix/src/ansi-shell/readline/readline.js index 0a9c04901..0d1b83268 100644 --- a/packages/phoenix/src/ansi-shell/readline/readline.js +++ b/packages/phoenix/src/ansi-shell/readline/readline.js @@ -151,11 +151,7 @@ const ReadlineProcessorBuilder = builder => builder if ( completions.length > 1 ) { let inCommon = ''; - for ( let i=0 ; true ; i++ ) { - if ( ! completions.every(completion => { - return completion.length > i; - }) ) break; - + for ( let i=0 ; completions.every(completion => completion.length > i) ; i++ ) { let matches = true; const chrFirst = completions[0][i]; diff --git a/packages/phoenix/src/puter-shell/coreutils/coreutil_lib/echo_escapes.js b/packages/phoenix/src/puter-shell/coreutils/coreutil_lib/echo_escapes.js index c084d7230..8bcc0be1b 100644 --- a/packages/phoenix/src/puter-shell/coreutils/coreutil_lib/echo_escapes.js +++ b/packages/phoenix/src/puter-shell/coreutils/coreutil_lib/echo_escapes.js @@ -104,7 +104,7 @@ const echo_escapes = { caller.output(NUL); return; } - caller.output(String.fromCharCode(Number.parseInt(hexchars, 8))); + caller.output(String.fromCharCode(Number.parseInt(octchars, 8))); }, '\\': caller => caller.output('\\'), }; diff --git a/packages/phoenix/src/puter-shell/coreutils/date.js b/packages/phoenix/src/puter-shell/coreutils/date.js index f694544f1..fd3bcc685 100644 --- a/packages/phoenix/src/puter-shell/coreutils/date.js +++ b/packages/phoenix/src/puter-shell/coreutils/date.js @@ -126,9 +126,9 @@ export default { break; } - // "Locale's abbreviated month name." + // b: "Locale's abbreviated month name." + // h: "A synonym for %b." case 'b': - // "A synonym for %b." case 'h': { output += date.toLocaleDateString(locale, { timeZone: timeZone, month: 'short' }); break; diff --git a/packages/phoenix/src/puter-shell/coreutils/grep.js b/packages/phoenix/src/puter-shell/coreutils/grep.js index 29351e1cc..eb1831444 100644 --- a/packages/phoenix/src/puter-shell/coreutils/grep.js +++ b/packages/phoenix/src/puter-shell/coreutils/grep.js @@ -78,7 +78,7 @@ export default { } } - const do_grep_line = async ( line ) => { + const do_grep_line = async ( line, lineNumber ) => { if ( line.endsWith('\n') ) line = line.slice(0, -1); const re = new RegExp( pattern, @@ -97,10 +97,9 @@ export default { ); if ( lxor(values['invert-match'], re.test(line)) ) { - const lineNumber = values['line-number'] ? i + 1 : ''; - const lineToPrint = - lineNumber ? lineNumber + ':' : '' + - line; + const lineToPrint = values['line-number'] + ? `${lineNumber + 1}:${line}` + : line; console.log(`LINE{${lineToPrint}}`); await ctx.externs.out.write(lineToPrint + '\n'); @@ -111,7 +110,7 @@ export default { for ( let i=0 ; i < lines.length ; i++ ) { const line = lines[i]; - await do_grep_line(line); + await do_grep_line(line, i); } } @@ -139,10 +138,10 @@ export default { for ( let file of files ) { if ( file === '-' ) { - for ( ;; ) { + for ( let i = 0; ; i++) { const { value, done } = await ctx.externs.in_.read(); if ( done ) break; - await do_grep_line(value); + await do_grep_line(value, i); } } else { file = resolveRelativePath(ctx.vars, file); diff --git a/packages/phoenix/src/puter-shell/providers/ScriptCommandProvider.js b/packages/phoenix/src/puter-shell/providers/ScriptCommandProvider.js index 66be2041f..1e50a0894 100644 --- a/packages/phoenix/src/puter-shell/providers/ScriptCommandProvider.js +++ b/packages/phoenix/src/puter-shell/providers/ScriptCommandProvider.js @@ -24,7 +24,7 @@ export class ScriptCommandProvider { async lookup (id, { ctx }) { const { filesystem } = ctx.platform; - const is_path = id.match(/^[.\/]/); + const is_path = id.match(/^[./]/); if ( ! is_path ) return undefined; const absPath = resolveRelativePath(ctx.vars, id); diff --git a/packages/phoenix/src/util/wrap-text.js b/packages/phoenix/src/util/wrap-text.js index 478f1e76b..86adfe840 100644 --- a/packages/phoenix/src/util/wrap-text.js +++ b/packages/phoenix/src/util/wrap-text.js @@ -16,6 +16,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ +/* eslint-disable no-control-regex */ + export function lengthIgnoringEscapes(text) { const escape = '\x1b'; // There are a lot of different ones, but we only use graphics-mode ones, so only parse those for now. diff --git a/packages/puter-js/src/modules/FileSystem/operations/upload.js b/packages/puter-js/src/modules/FileSystem/operations/upload.js index 4b7fe525f..90bbff013 100644 --- a/packages/puter-js/src/modules/FileSystem/operations/upload.js +++ b/packages/puter-js/src/modules/FileSystem/operations/upload.js @@ -60,8 +60,6 @@ const upload = async function(items, dirPath, options = {}){ for(let i=0; i { this.readController = controller; diff --git a/run-selfhosted.js b/run-selfhosted.js index a9104bbfc..e8621d02c 100644 --- a/run-selfhosted.js +++ b/run-selfhosted.js @@ -5,6 +5,9 @@ // The implementation of this in packages/backend might not // work in older versions of node, so we instead re-implement // it here. +import console from 'node:console'; +import process from 'node:process'; + const surrounding_box = (col, lines) => { const lengths = lines.map(line => line.length); diff --git a/src/IPC.js b/src/IPC.js index ed96c175a..a566ed510 100644 --- a/src/IPC.js +++ b/src/IPC.js @@ -50,11 +50,11 @@ window.addEventListener('message', async (event) => { // -------------------------------------------------------- // A response to a GUI message received from the app. // -------------------------------------------------------- - if (typeof event.data.original_msg_id !== "undefined" && typeof appCallbackFunctions[event.data.original_msg_id] !== "undefined") { + if (typeof event.data.original_msg_id !== "undefined" && typeof window.appCallbackFunctions[event.data.original_msg_id] !== "undefined") { // Execute callback - appCallbackFunctions[event.data.original_msg_id](event.data); + window.appCallbackFunctions[event.data.original_msg_id](event.data); // Remove this callback function since it won't be needed again - delete appCallbackFunctions[event.data.original_msg_id]; + delete window.appCallbackFunctions[event.data.original_msg_id]; // Done return; @@ -78,10 +78,10 @@ window.addEventListener('message', async (event) => { return; } - const $el_parent_window = $(window_for_app_instance(event.data.appInstanceID)); + const $el_parent_window = $(window.window_for_app_instance(event.data.appInstanceID)); const parent_window_id = $el_parent_window.attr('data-id'); const $el_parent_disable_mask = $el_parent_window.find('.window-disable-mask'); - const target_iframe = iframe_for_app_instance(event.data.appInstanceID); + const target_iframe = window.iframe_for_app_instance(event.data.appInstanceID); const msg_id = event.data.uuid; const app_name = $(target_iframe).attr('data-app'); const app_uuid = $el_parent_window.attr('data-app_uuid'); @@ -103,6 +103,7 @@ window.addEventListener('message', async (event) => { // windowFocused //------------------------------------------------- else if(event.data.msg === 'windowFocused'){ + // TODO: Respond to this } //-------------------------------------------------------- // ALERT @@ -177,7 +178,7 @@ window.addEventListener('message', async (event) => { else if(event.data.msg === 'setItem' && event.data.key && event.data.value){ // todo: validate key and value to avoid unnecessary api calls return await $.ajax({ - url: api_origin + "/setItem", + url: window.api_origin + "/setItem", type: 'POST', data: JSON.stringify({ app: app_uuid, @@ -187,11 +188,11 @@ window.addEventListener('message', async (event) => { async: true, contentType: "application/json", headers: { - "Authorization": "Bearer "+auth_token + "Authorization": "Bearer "+window.auth_token }, statusCode: { 401: function () { - logout(); + window.logout(); }, }, success: function (fsentry){ @@ -204,7 +205,7 @@ window.addEventListener('message', async (event) => { else if(event.data.msg === 'getItem' && event.data.key){ // todo: validate key to avoid unnecessary api calls $.ajax({ - url: api_origin + "/getItem", + url: window.api_origin + "/getItem", type: 'POST', data: JSON.stringify({ key: event.data.key, @@ -213,11 +214,11 @@ window.addEventListener('message', async (event) => { async: true, contentType: "application/json", headers: { - "Authorization": "Bearer "+auth_token + "Authorization": "Bearer "+window.auth_token }, statusCode: { 401: function () { - logout(); + window.logout(); }, }, success: function (result){ @@ -236,7 +237,7 @@ window.addEventListener('message', async (event) => { else if(event.data.msg === 'removeItem' && event.data.key){ // todo: validate key to avoid unnecessary api calls $.ajax({ - url: api_origin + "/removeItem", + url: window.api_origin + "/removeItem", type: 'POST', data: JSON.stringify({ key: event.data.key, @@ -245,11 +246,11 @@ window.addEventListener('message', async (event) => { async: true, contentType: "application/json", headers: { - "Authorization": "Bearer "+auth_token + "Authorization": "Bearer "+window.auth_token }, statusCode: { 401: function () { - logout(); + window.logout(); }, }, success: function (result){ @@ -265,7 +266,7 @@ window.addEventListener('message', async (event) => { //-------------------------------------------------------- else if(event.data.msg === 'showOpenFilePicker'){ // Auth - if(!is_auth() && !(await UIWindowSignup({referrer: app_name}))) + if(!window.is_auth() && !(await UIWindowSignup({referrer: app_name}))) return; // Disable parent window @@ -306,7 +307,7 @@ window.addEventListener('message', async (event) => { //-------------------------------------------------------- else if(event.data.msg === 'showDirectoryPicker'){ // Auth - if(!is_auth() && !(await UIWindowSignup({referrer: app_name}))) + if(!window.is_auth() && !(await UIWindowSignup({referrer: app_name}))) return; // Disable parent window @@ -345,7 +346,7 @@ window.addEventListener('message', async (event) => { // setWindowTitle //-------------------------------------------------------- else if(event.data.msg === 'setWindowTitle' && event.data.new_title !== undefined){ - const el_window = window_for_app_instance(event.data.appInstanceID); + const el_window = window.window_for_app_instance(event.data.appInstanceID); // set window title $(el_window).find(`.window-head-title`).html(html_encode(event.data.new_title)); // send confirmation to requester window @@ -357,7 +358,7 @@ window.addEventListener('message', async (event) => { // setMenubar //-------------------------------------------------------- else if(event.data.msg === 'setMenubar') { - const el_window = window_for_app_instance(event.data.appInstanceID); + const el_window = window.window_for_app_instance(event.data.appInstanceID); console.error(`EXPERIMENTAL: setMenubar is a work-in-progress`); const hydrator = puter.util.rpc.getHydrator({ @@ -573,13 +574,13 @@ window.addEventListener('message', async (event) => { else if(event.data.msg === 'launchApp'){ // TODO: Determine if the app is allowed to launch child apps? We may want to limit this to prevent abuse. // remember app for launch callback later - const child_instance_id = uuidv4(); + const child_instance_id = window.uuidv4(); window.child_launch_callbacks[child_instance_id] = { parent_instance_id: event.data.appInstanceID, launch_msg_id: msg_id, }; // launch child app - launch_app({ + window.launch_app({ name: event.data.app_name ?? app_name, args: event.data.args ?? {}, parent_instance_id: event.data.appInstanceID, @@ -594,7 +595,7 @@ window.addEventListener('message', async (event) => { event.data.path = path.resolve(event.data.path); // join with appdata dir - const file_path = path.join(appdata_path, app_uuid, event.data.path); + const file_path = path.join(window.appdata_path, app_uuid, event.data.path); puter.fs.sign(app_uuid, { path: file_path, @@ -626,16 +627,16 @@ window.addEventListener('message', async (event) => { //-------------------------------------------------------- // todo appdata should be provided from the /open_item api call else if(event.data.msg === 'getAppData'){ - if(appdata_signatures[app_uuid]){ + if(window.appdata_signatures[app_uuid]){ target_iframe.contentWindow.postMessage({ msg: "getAppDataSucceeded", original_msg_id: msg_id, - item: appdata_signatures[app_uuid], + item: window.appdata_signatures[app_uuid], }, '*'); } // make app directory if it doesn't exist puter.fs.mkdir({ - path: path.join( appdata_path, app_uuid), + path: path.join( window.appdata_path, app_uuid), rename: false, overwrite: false, success: function(dir){ @@ -644,7 +645,7 @@ window.addEventListener('message', async (event) => { action: 'write', success: function(signature){ signature = signature.items; - appdata_signatures[app_uuid] = signature; + window.appdata_signatures[app_uuid] = signature; // send confirmation to requester window target_iframe.contentWindow.postMessage({ msg: "getAppDataSucceeded", @@ -661,7 +662,7 @@ window.addEventListener('message', async (event) => { action: 'write', success: function(signature){ signature = signature.items; - appdata_signatures[app_uuid] = signature; + window.appdata_signatures[app_uuid] = signature; // send confirmation to requester window target_iframe.contentWindow.postMessage({ msg: "getAppDataSucceeded", @@ -679,7 +680,7 @@ window.addEventListener('message', async (event) => { //-------------------------------------------------------- else if(event.data.msg === 'requestPermission'){ // auth - if(!is_auth() && !(await UIWindowSignup({referrer: app_name}))) + if(!window.is_auth() && !(await UIWindowSignup({referrer: app_name}))) return; // options must be an object @@ -714,7 +715,7 @@ window.addEventListener('message', async (event) => { //-------------------------------------------------------- else if(event.data.msg === 'showFontPicker'){ // auth - if(!is_auth() && !(await UIWindowSignup({referrer: app_name}))) + if(!window.is_auth() && !(await UIWindowSignup({referrer: app_name}))) return; // set options @@ -742,7 +743,7 @@ window.addEventListener('message', async (event) => { //-------------------------------------------------------- else if(event.data.msg === 'showColorPicker'){ // Auth - if(!is_auth() && !(await UIWindowSignup({referrer: app_name}))) + if(!window.is_auth() && !(await UIWindowSignup({referrer: app_name}))) return; // set options @@ -770,7 +771,7 @@ window.addEventListener('message', async (event) => { //-------------------------------------------------------- else if(event.data.msg === 'setWallpaper'){ // Auth - if(!is_auth() && !(await UIWindowSignup({referrer: app_name}))) + if(!window.is_auth() && !(await UIWindowSignup({referrer: app_name}))) return; // No options? @@ -780,7 +781,7 @@ window.addEventListener('message', async (event) => { // /set-desktop-bg try{ await $.ajax({ - url: api_origin + "/set-desktop-bg", + url: window.api_origin + "/set-desktop-bg", type: 'POST', data: JSON.stringify({ url: event.data.readURL, @@ -790,11 +791,11 @@ window.addEventListener('message', async (event) => { async: true, contentType: "application/json", headers: { - "Authorization": "Bearer "+auth_token + "Authorization": "Bearer "+window.auth_token }, statusCode: { 401: function () { - logout(); + window.logout(); }, }, }); @@ -822,7 +823,7 @@ window.addEventListener('message', async (event) => { //-------------------------------------------------------- else if(event.data.msg === 'showSaveFilePicker'){ //auth - if(!is_auth() && !(await UIWindowSignup({referrer: app_name}))) + if(!window.is_auth() && !(await UIWindowSignup({referrer: app_name}))) return; //disable parent window @@ -854,7 +855,7 @@ window.addEventListener('message', async (event) => { // ------------------------------------- if(event.data.url){ // download progress tracker - let dl_op_id = operation_id++; + let dl_op_id = window.operation_id++; // upload progress tracker defaults window.progress_tracker[dl_op_id] = []; @@ -869,8 +870,8 @@ window.addEventListener('message', async (event) => { url: event.data.url, name: path.basename(target_path), dest_path: path.dirname(target_path), - auth_token: auth_token, - api_origin: api_origin, + auth_token: window.auth_token, + api_origin: window.api_origin, dedupe_name: false, overwrite: false, operation_id: dl_op_id, @@ -936,7 +937,7 @@ window.addEventListener('message', async (event) => { immutable: res.immutable, associated_app_name: res.associated_app?.name, path: target_path, - icon: await item_icon(res), + icon: await window.item_icon(res), name: path.basename(target_path), uid: res.uid, size: res.size, @@ -948,10 +949,10 @@ window.addEventListener('message', async (event) => { }); // sort each window $(`.item-container[data-path="${html_encode(path.dirname(target_path))}" i]`).each(function(){ - sort_items(this, $(this).attr('data-sort_by'), $(this).attr('data-sort_order')) + window.sort_items(this, $(this).attr('data-sort_by'), $(this).attr('data-sort_order')) }); $(el_filedialog_window).close(); - show_save_account_notice_if_needed(); + window.show_save_account_notice_if_needed(); } catch(err){ // item with same name exists @@ -995,13 +996,13 @@ window.addEventListener('message', async (event) => { // done let busy_duration = (Date.now() - busy_init_ts); - if( busy_duration >= busy_indicator_hide_delay){ + if( busy_duration >= window.busy_indicator_hide_delay){ $(el_filedialog_window).close(); }else{ setTimeout(() => { // close this dialog $(el_filedialog_window).close(); - }, Math.abs(busy_indicator_hide_delay - busy_duration)); + }, Math.abs(window.busy_indicator_hide_delay - busy_duration)); } } }); @@ -1015,21 +1016,21 @@ window.addEventListener('message', async (event) => { let create_missing_ancestors = false; if(event.data.msg === 'saveToPictures') - target_path = path.join(pictures_path, event.data.filename); + target_path = path.join(window.pictures_path, event.data.filename); else if(event.data.msg === 'saveToDesktop') - target_path = path.join(desktop_path, event.data.filename); + target_path = path.join(window.desktop_path, event.data.filename); else if(event.data.msg === 'saveToDocuments') - target_path = path.join(documents_path, event.data.filename); + target_path = path.join(window.documents_path, event.data.filename); else if(event.data.msg === 'saveToVideos') - target_path = path.join(videos_path, event.data.filename); + target_path = path.join(window.videos_path, event.data.filename); else if(event.data.msg === 'saveToAudio') - target_path = path.join(audio_path, event.data.filename); + target_path = path.join(window.audio_path, event.data.filename); else if(event.data.msg === 'saveToAppData'){ - target_path = path.join(appdata_path, app_uuid, event.data.filename); + target_path = path.join(window.appdata_path, app_uuid, event.data.filename); create_missing_ancestors = true; } //auth - if(!is_auth() && !(await UIWindowSignup({referrer: app_name}))) + if(!window.is_auth() && !(await UIWindowSignup({referrer: app_name}))) return; let item_with_same_name_already_exists = true; @@ -1041,7 +1042,7 @@ window.addEventListener('message', async (event) => { if(event.data.url){ let overwrite = false; // download progress tracker - let dl_op_id = operation_id++; + let dl_op_id = window.operation_id++; // upload progress tracker defaults window.progress_tracker[dl_op_id] = []; @@ -1056,8 +1057,8 @@ window.addEventListener('message', async (event) => { url: event.data.url, name: path.basename(target_path), dest_path: path.dirname(target_path), - auth_token: auth_token, - api_origin: api_origin, + auth_token: window.auth_token, + api_origin: window.api_origin, dedupe_name: true, overwrite: false, operation_id: dl_op_id, @@ -1142,7 +1143,7 @@ window.addEventListener('message', async (event) => { // TODO: Track message traffic between apps // pass on the message - const target_iframe = iframe_for_app_instance(targetAppInstanceID); + const target_iframe = window.iframe_for_app_instance(targetAppInstanceID); if (!target_iframe) { console.error('Failed to send message to non-existent app', event); return; @@ -1160,7 +1161,7 @@ window.addEventListener('message', async (event) => { else if (event.data.msg === 'closeApp') { const { appInstanceID, targetAppInstanceID } = event.data; - const target_window = window_for_app_instance(targetAppInstanceID); + const target_window = window.window_for_app_instance(targetAppInstanceID); if (!target_window) { console.warn(`Failed to close non-existent app ${targetAppInstanceID}`); return; @@ -1175,7 +1176,7 @@ window.addEventListener('message', async (event) => { } // God-mode apps can close anything - const app_info = await get_apps(app_name); + const app_info = await window.get_apps(app_name); if (app_info.godmode === 1) { console.log(`⚠️ Allowing GODMODE app ${appInstanceID} to close app ${targetAppInstanceID}`); return true; @@ -1196,6 +1197,6 @@ window.addEventListener('message', async (event) => { // exit //-------------------------------------------------------- else if(event.data.msg === 'exit'){ - $(window_for_app_instance(event.data.appInstanceID)).close({bypass_iframe_messaging: true}); + $(window.window_for_app_instance(event.data.appInstanceID)).close({bypass_iframe_messaging: true}); } }); \ No newline at end of file diff --git a/src/UI/Settings/UITabAccount.js b/src/UI/Settings/UITabAccount.js index 4ed08ea00..d05442065 100644 --- a/src/UI/Settings/UITabAccount.js +++ b/src/UI/Settings/UITabAccount.js @@ -31,7 +31,7 @@ export default { let h = `

${i18n('account')}

`; // change password button - if(!user.is_temp){ + if(!window.user.is_temp){ h += `
`; h += `${i18n('password')}`; h += `
`; @@ -44,7 +44,7 @@ export default { h += `
`; h += `
`; h += `${i18n('username')}`; - h += `${html_encode(user.username)}`; + h += `${html_encode(window.user.username)}`; h += `
`; h += `
`; h += ``; @@ -52,11 +52,11 @@ export default { h += `
`; // change email button - if(user.email){ + if(window.user.email){ h += `
`; h += `
`; h += `${i18n('email')}`; - h += `${html_encode(user.email)}`; + h += `${html_encode(window.user.email)}`; h += `
`; h += `
`; h += ``; diff --git a/src/UI/Settings/UITabLanguage.js b/src/UI/Settings/UITabLanguage.js index 5bb09a68b..c65f611be 100644 --- a/src/UI/Settings/UITabLanguage.js +++ b/src/UI/Settings/UITabLanguage.js @@ -32,7 +32,7 @@ export default {
`; // list of languages - const available_languages = listSupportedLanguages(); + const available_languages = window.listSupportedLanguages(); h += `
`; for (let lang of available_languages) { h += `
${html_encode(lang.name)}
`; diff --git a/src/UI/Settings/UITabUsage.js b/src/UI/Settings/UITabUsage.js index 976475cfb..ba72bd618 100644 --- a/src/UI/Settings/UITabUsage.js +++ b/src/UI/Settings/UITabUsage.js @@ -42,16 +42,16 @@ export default { }, init: ($el_window) => { $.ajax({ - url: api_origin + "/drivers/usage", + url: window.api_origin + "/drivers/usage", type: 'GET', async: true, contentType: "application/json", headers: { - "Authorization": "Bearer " + auth_token + "Authorization": "Bearer " + window.auth_token }, statusCode: { 401: function () { - logout(); + window.logout(); }, }, success: function (res) { @@ -93,16 +93,16 @@ export default { // df $.ajax({ - url: api_origin + "/df", + url: window.api_origin + "/df", type: 'GET', async: true, contentType: "application/json", headers: { - "Authorization": "Bearer " + auth_token + "Authorization": "Bearer " + window.auth_token }, statusCode: { 401: function () { - logout(); + window.logout(); }, }, success: function (res) { @@ -113,15 +113,15 @@ export default { let host_usage_percentage = 0; if ( res.host_used ) { - $('#storage-puter-used').html(byte_format(res.used)); + $('#storage-puter-used').html(window.byte_format(res.used)); $('#storage-puter-used-w').show(); general_used = res.host_used; host_usage_percentage = ((res.host_used - res.used) / res.capacity * 100).toFixed(0); } - $('#storage-used').html(byte_format(general_used)); - $('#storage-capacity').html(byte_format(res.capacity)); + $('#storage-used').html(window.byte_format(general_used)); + $('#storage-capacity').html(window.byte_format(res.capacity)); $('#storage-used-percent').html( usage_percentage + '%' + (host_usage_percentage > 0 diff --git a/src/UI/Settings/UIWindowChangeEmail.js b/src/UI/Settings/UIWindowChangeEmail.js index 61f6a2882..1b28c0aee 100644 --- a/src/UI/Settings/UIWindowChangeEmail.js +++ b/src/UI/Settings/UIWindowChangeEmail.js @@ -93,11 +93,11 @@ async function UIWindowChangeEmail(options){ $(el_window).find('.new-email').attr('disabled', true); $.ajax({ - url: api_origin + "/change_email/start", + url: window.api_origin + "/change_email/start", type: 'POST', async: true, headers: { - "Authorization": "Bearer "+auth_token + "Authorization": "Bearer "+window.auth_token }, contentType: "application/json", data: JSON.stringify({ diff --git a/src/UI/Settings/UIWindowFinalizeUserDeletion.js b/src/UI/Settings/UIWindowFinalizeUserDeletion.js index 505a6270f..e4511f4e5 100644 --- a/src/UI/Settings/UIWindowFinalizeUserDeletion.js +++ b/src/UI/Settings/UIWindowFinalizeUserDeletion.js @@ -26,7 +26,7 @@ async function UIWindowFinalizeUserDeletion(options){ let h = ''; // if user is temporary, ask them to type in 'confirm' to delete their account - if(user.is_temp){ + if(window.user.is_temp){ h += `
`; h += `
×
`; h += ``; @@ -94,7 +94,7 @@ async function UIWindowFinalizeUserDeletion(options){ $(el_window).find('.proceed-with-user-deletion').on('click', function(){ $(el_window).find('.error-message').hide(); // if user is temporary, check if they typed 'confirm' - if(user.is_temp){ + if(window.user.is_temp){ if($(el_window).find('.confirm-temporary-user-deletion').val() !== 'confirm'){ $(el_window).find('.error-message').html(i18n('type_confirm_to_delete_account'), false); $(el_window).find('.error-message').show(); @@ -112,19 +112,19 @@ async function UIWindowFinalizeUserDeletion(options){ // delete user $.ajax({ - url: api_origin + "/delete-own-user", + url: window.api_origin + "/delete-own-user", type: 'POST', async: true, contentType: "application/json", headers: { - "Authorization": "Bearer " + auth_token + "Authorization": "Bearer " + window.auth_token }, data: JSON.stringify({ password: $(el_window).find('.confirm-user-deletion-password').val(), }), statusCode: { 401: function () { - logout(); + window.logout(); }, 400: function(){ $(el_window).find('.error-message').html(i18n('incorrect_password')); @@ -136,7 +136,7 @@ async function UIWindowFinalizeUserDeletion(options){ // mark user as deleted window.user.deleted = true; // log user out - logout(); + window.logout(); } else{ $(el_window).find('.error-message').html(html_encode(data.error)); diff --git a/src/UI/Settings/UIWindowSettings.js b/src/UI/Settings/UIWindowSettings.js index 2a720372e..28300f231 100644 --- a/src/UI/Settings/UIWindowSettings.js +++ b/src/UI/Settings/UIWindowSettings.js @@ -45,7 +45,7 @@ async function UIWindowSettings(options){ // side bar h += `
`; tabs.forEach((tab, i) => { - h += `
${i18n(tab.title_i18n_key)}
`; + h += `
${i18n(tab.title_i18n_key)}
`; }); h += `
`; @@ -82,7 +82,6 @@ async function UIWindowSettings(options){ allow_user_select: true, backdrop: false, width: 800, - height: 500, height: 'auto', dominant: true, show_in_taskbar: false, diff --git a/src/UI/UIAlert.js b/src/UI/UIAlert.js index c5763ea0b..dcf46cdda 100644 --- a/src/UI/UIAlert.js +++ b/src/UI/UIAlert.js @@ -23,7 +23,7 @@ function UIAlert(options){ // set sensible defaults if(arguments.length > 0){ // if first argument is a string, then assume it is the message - if(isString(arguments[0])){ + if(window.isString(arguments[0])){ options = {}; options.message = arguments[0]; } diff --git a/src/UI/UIContextMenu.js b/src/UI/UIContextMenu.js index 9f5f65d3c..367bc33cd 100644 --- a/src/UI/UIContextMenu.js +++ b/src/UI/UIContextMenu.js @@ -20,7 +20,7 @@ function UIContextMenu(options){ $('.window-active .window-app-iframe').css('pointer-events', 'none'); - const menu_id = global_element_id++; + const menu_id = window.global_element_id++; let h = ''; h += `
(window.innerHeight - taskbar_height - 10)) - y_pos = window.innerHeight - menu_height - taskbar_height - 10; + if( (start_y + menu_height) > (window.innerHeight - window.taskbar_height - 10)) + y_pos = window.innerHeight - menu_height - window.taskbar_height - 10; else y_pos = start_y; @@ -257,7 +257,7 @@ function UIContextMenu(options){ $(options.parent_element).css('overflow', 'scroll'); $(options.parent_element).removeClass('has-open-contextmenu'); if($(options.parent_element).hasClass('taskbar-item')){ - make_taskbar_sortable() + window.make_taskbar_sortable() } } }) diff --git a/src/UI/UIDesktop.js b/src/UI/UIDesktop.js index be26556e2..92d3bf822 100644 --- a/src/UI/UIDesktop.js +++ b/src/UI/UIDesktop.js @@ -41,9 +41,9 @@ async function UIDesktop(options){ let h = ''; // connect socket. - window.socket = io(gui_origin + '/', { + window.socket = io(window.gui_origin + '/', { query: { - auth_token: auth_token + auth_token: window.auth_token } }); @@ -83,7 +83,7 @@ async function UIDesktop(options){ console.error('GUI Socket Error:', error); }); - socket.on('upload.progress', (msg) => { + window.socket.on('upload.progress', (msg) => { if(window.progress_tracker[msg.operation_id]){ window.progress_tracker[msg.operation_id].cloud_uploaded += msg.loaded_diff if(window.progress_tracker[msg.operation_id][msg.item_upload_id]){ @@ -92,7 +92,7 @@ async function UIDesktop(options){ } }); - socket.on('download.progress', (msg) => { + window.socket.on('download.progress', (msg) => { if(window.progress_tracker[msg.operation_id]){ if(window.progress_tracker[msg.operation_id][msg.item_upload_id]){ window.progress_tracker[msg.operation_id][msg.item_upload_id].downloaded = msg.loaded; @@ -101,30 +101,30 @@ async function UIDesktop(options){ } }); - socket.on('trash.is_empty', async (msg) => { - $(`.item[data-path="${html_encode(trash_path)}" i]`).find('.item-icon > img').attr('src', msg.is_empty ? window.icons['trash.svg'] : window.icons['trash-full.svg']); - $(`.window[data-path="${html_encode(trash_path)}" i]`).find('.window-head-icon').attr('src', msg.is_empty ? window.icons['trash.svg'] : window.icons['trash-full.svg']); + window.socket.on('trash.is_empty', async (msg) => { + $(`.item[data-path="${html_encode(window.trash_path)}" i]`).find('.item-icon > img').attr('src', msg.is_empty ? window.icons['trash.svg'] : window.icons['trash-full.svg']); + $(`.window[data-path="${html_encode(window.trash_path)}" i]`).find('.window-head-icon').attr('src', msg.is_empty ? window.icons['trash.svg'] : window.icons['trash-full.svg']); // empty trash windows if needed if(msg.is_empty) - $(`.window[data-path="${html_encode(trash_path)}" i]`).find('.item-container').empty(); + $(`.window[data-path="${html_encode(window.trash_path)}" i]`).find('.item-container').empty(); }) - socket.on('app.opened', async (app) => { + window.socket.on('app.opened', async (app) => { // don't update if this is the original client that initiated the action if(app.original_client_socket_id === window.socket.id) return; // add the app to the beginning of the array - launch_apps.recent.unshift(app); + window.launch_apps.recent.unshift(app); // dedupe the array by uuid, uid, and id - launch_apps.recent = _.uniqBy(launch_apps.recent, 'name'); + window.launch_apps.recent = _.uniqBy(window.launch_apps.recent, 'name'); // limit to 5 - launch_apps.recent = launch_apps.recent.slice(0, window.launch_recent_apps_count); + window.launch_apps.recent = window.launch_apps.recent.slice(0, window.launch_recent_apps_count); }) - socket.on('item.removed', async (item) => { + window.socket.on('item.removed', async (item) => { // don't update if this is the original client that initiated the action if(item.original_client_socket_id === window.socket.id) return; @@ -143,17 +143,17 @@ async function UIDesktop(options){ }); }) - socket.on('item.updated', async (item) => { + window.socket.on('item.updated', async (item) => { // Don't update if this is the original client that initiated the action if(item.original_client_socket_id === window.socket.id) return; // Update matching items // set new item name - $(`.item[data-uid='${html_encode(item.uid)}'] .item-name`).html(html_encode(truncate_filename(item.name, TRUNCATE_LENGTH)).replaceAll(' ', ' ')); + $(`.item[data-uid='${html_encode(item.uid)}'] .item-name`).html(html_encode(window.truncate_filename(item.name, window.TRUNCATE_LENGTH)).replaceAll(' ', ' ')); // Set new icon - const new_icon = (item.is_dir ? window.icons['folder.svg'] : (await item_icon(item)).image); + const new_icon = (item.is_dir ? window.icons['folder.svg'] : (await window.item_icon(item)).image); $(`.item[data-uid='${item.uid}']`).find('.item-icon-thumb').attr('src', new_icon); $(`.item[data-uid='${item.uid}']`).find('.item-icon-icon').attr('src', new_icon); @@ -189,21 +189,21 @@ async function UIDesktop(options){ // Update all exact-matching windows $(`.window-${item.uid}`).each(function(){ - update_window_path(this, new_path); + window.update_window_path(this, new_path); }) // Set new name for matching open windows $(`.window-${item.uid} .window-head-title`).text(item.name); // Re-sort all matching item containers $(`.item[data-uid='${item.uid}']`).parent('.item-container').each(function(){ - sort_items(this, $(this).closest('.item-container').attr('data-sort_by'), $(this).closest('.item-container').attr('data-sort_order')); + window.sort_items(this, $(this).closest('.item-container').attr('data-sort_by'), $(this).closest('.item-container').attr('data-sort_order')); }) }) - socket.on('item.moved', async (resp) => { + window.socket.on('item.moved', async (resp) => { let fsentry = resp; // Notify all apps that are watching this item - sendItemChangeEventToWatchingApps(fsentry.uid, { + window.sendItemChangeEventToWatchingApps(fsentry.uid, { event: 'moved', uid: fsentry.uid, name: fsentry.name, @@ -216,9 +216,6 @@ async function UIDesktop(options){ let dest_path = path.dirname(fsentry.path); let metadata = fsentry.metadata; - // path must use the real name from DB - fsentry.path = fsentry.path; - // update all shortcut_to_path $(`.item[data-shortcut_to_path="${html_encode(resp.old_path)}" i]`).attr(`data-shortcut_to_path`, html_encode(fsentry.path)); @@ -230,13 +227,13 @@ async function UIDesktop(options){ $(this).removeItems(); // update parent windows' item counts $(parent_windows).each(function(index){ - update_explorer_footer_item_count(this); - update_explorer_footer_selected_items_count(this) + window.update_explorer_footer_item_count(this); + window.update_explorer_footer_selected_items_count(this) }); }) // if trashing, close windows of trashed items and its descendants - if(dest_path === trash_path){ + if(dest_path === window.trash_path){ $(`.window[data-path="${html_encode(resp.old_path)}" i]`).close(); // todo this has to be case-insensitive but the `i` selector doesn't work on ^= $(`.window[data-path^="${html_encode(resp.old_path)}/"]`).close(); @@ -246,11 +243,11 @@ async function UIDesktop(options){ else{ // todo this has to be case-insensitive but the `i` selector doesn't work on ^= $(`.window[data-path^="${html_encode(resp.old_path)}/"], .window[data-path="${html_encode(resp.old_path)}" i]`).each(function(){ - update_window_path(this, $(this).attr('data-path').replace(resp.old_path, fsentry.path)); + window.update_window_path(this, $(this).attr('data-path').replace(resp.old_path, fsentry.path)); }) } - if(dest_path === trash_path){ + if(dest_path === window.trash_path){ $(`.item[data-uid="${fsentry.uid}"]`).find('.item-is-shared').fadeOut(300); // if trashing dir... @@ -277,14 +274,14 @@ async function UIDesktop(options){ immutable: fsentry.immutable, uid: fsentry.uid, path: fsentry.path, - icon: await item_icon(fsentry), - name: (dest_path === trash_path) ? metadata.original_name : fsentry.name, + icon: await window.item_icon(fsentry), + name: (dest_path === window.trash_path) ? metadata.original_name : fsentry.name, is_dir: fsentry.is_dir, size: fsentry.size, type: fsentry.type, modified: fsentry.modified, is_selected: false, - is_shared: (dest_path === trash_path) ? false : fsentry.is_shared, + is_shared: (dest_path === window.trash_path) ? false : fsentry.is_shared, is_shortcut: fsentry.is_shortcut, shortcut_to: fsentry.shortcut_to, shortcut_to_path: fsentry.shortcut_to_path, @@ -305,7 +302,7 @@ async function UIDesktop(options){ immutable: false, uid: dir.uid, path: dir.path, - icon: await item_icon(dir), + icon: await window.item_icon(dir), name: dir.name, size: dir.size, type: dir.type, @@ -316,34 +313,34 @@ async function UIDesktop(options){ has_website: false, }); } - sort_items(item_container, $(item_container).attr('data-sort_by'), $(item_container).attr('data-sort_order')); + window.sort_items(item_container, $(item_container).attr('data-sort_by'), $(item_container).attr('data-sort_order')); }); } //sort each container $(`.item-container[data-path='${html_encode(dest_path)}' i]`).each(function(){ - sort_items(this, $(this).attr('data-sort_by'), $(this).attr('data-sort_order')) + window.sort_items(this, $(this).attr('data-sort_by'), $(this).attr('data-sort_order')) }) }); - socket.on('user.email_confirmed', (msg) => { + window.socket.on('user.email_confirmed', (msg) => { // don't update if this is the original client that initiated the action if(msg.original_client_socket_id === window.socket.id) return; - refresh_user_data(window.auth_token); + window.refresh_user_data(window.auth_token); }); - socket.on('user.email_changed', (msg) => { + window.socket.on('user.email_changed', (msg) => { // don't update if this is the original client that initiated the action if(msg.original_client_socket_id === window.socket.id) return; - refresh_user_data(window.auth_token); + window.refresh_user_data(window.auth_token); }); - socket.on('item.renamed', async (item) => { + window.socket.on('item.renamed', async (item) => { // Notify all apps that are watching this item - sendItemChangeEventToWatchingApps(item.uid, { + window.sendItemChangeEventToWatchingApps(item.uid, { event: 'rename', uid: item.uid, // path: item.path, @@ -357,10 +354,10 @@ async function UIDesktop(options){ // Update matching items // Set new item name - $(`.item[data-uid='${html_encode(item.uid)}'] .item-name`).html(html_encode(truncate_filename(item.name, TRUNCATE_LENGTH)).replaceAll(' ', ' ')); + $(`.item[data-uid='${html_encode(item.uid)}'] .item-name`).html(html_encode(window.truncate_filename(item.name, window.TRUNCATE_LENGTH)).replaceAll(' ', ' ')); // Set new icon - const new_icon = (item.is_dir ? window.icons['folder.svg'] : (await item_icon(item)).image); + const new_icon = (item.is_dir ? window.icons['folder.svg'] : (await window.item_icon(item)).image); $(`.item[data-uid='${item.uid}']`).find('.item-icon-icon').attr('src', new_icon); // Set new data-name @@ -395,24 +392,24 @@ async function UIDesktop(options){ // Update all exact-matching windows $(`.window-${item.uid}`).each(function(){ - update_window_path(this, new_path); + window.update_window_path(this, new_path); }) // Set new name for matching open windows $(`.window-${item.uid} .window-head-title`).text(item.name); // Re-sort all matching item containers $(`.item[data-uid='${item.uid}']`).parent('.item-container').each(function(){ - sort_items(this, $(this).closest('.item-container').attr('data-sort_by'), $(this).closest('.item-container').attr('data-sort_order')); + window.sort_items(this, $(this).closest('.item-container').attr('data-sort_by'), $(this).closest('.item-container').attr('data-sort_order')); }) }); - socket.on('item.added', async (item) => { + window.socket.on('item.added', async (item) => { // if item is empty, don't proceed if(_.isEmpty(item)) return; // Notify all apps that are watching this item - sendItemChangeEventToWatchingApps(item.uid, { + window.sendItemChangeEventToWatchingApps(item.uid, { event: 'write', uid: item.uid, // path: item.path, @@ -437,12 +434,12 @@ async function UIDesktop(options){ 'data-type': item.type, }) // set new icon - const new_icon = (item.is_dir ? window.icons['folder.svg'] : (await item_icon(item)).image); + const new_icon = (item.is_dir ? window.icons['folder.svg'] : (await window.item_icon(item)).image); $(`.item[data-uid="${item.overwritten_uid}"]`).find('.item-icon > img').attr('src', new_icon); //sort each window $(`.item-container[data-path='${html_encode(item.dirpath)}' i]`).each(function(){ - sort_items(this, $(this).attr('data-sort_by'), $(this).attr('data-sort_order')) + window.sort_items(this, $(this).attr('data-sort_by'), $(this).attr('data-sort_order')) }) } else{ @@ -452,7 +449,7 @@ async function UIDesktop(options){ immutable: item.immutable, associated_app_name: item.associated_app?.name, path: item.path, - icon: await item_icon(item), + icon: await window.item_icon(item), name: item.name, size: item.size, type: item.type, @@ -460,14 +457,13 @@ async function UIDesktop(options){ is_dir: item.is_dir, is_shared: item.is_shared, is_shortcut: item.is_shortcut, - associated_app_name: item.associated_app?.name, shortcut_to: item.shortcut_to, shortcut_to_path: item.shortcut_to_path, }); //sort each window $(`.item-container[data-path='${html_encode(item.dirpath)}' i]`).each(function(){ - sort_items(this, $(this).attr('data-sort_by'), $(this).attr('data-sort_order')) + window.sort_items(this, $(this).attr('data-sort_by'), $(this).attr('data-sort_order')) }) } }); @@ -488,12 +484,12 @@ async function UIDesktop(options){ data-uid="${options.desktop_fsentry.uid}" data-sort_by="${!options.desktop_fsentry.sort_by ? 'name' : options.desktop_fsentry.sort_by}" data-sort_order="${!options.desktop_fsentry.sort_order ? 'asc' : options.desktop_fsentry.sort_order}" - data-path="${html_encode(desktop_path)}" + data-path="${html_encode(window.desktop_path)}" >`; h += `
`; // Get window sidebar width - getItem({ + window.getItem({ key: "window_sidebar_width", success: async function(res){ let value = parseInt(res.value); @@ -505,7 +501,7 @@ async function UIDesktop(options){ }) // Remove `?ref=...` from navbar URL - if(url_query_params.has('ref')){ + if(window.url_query_params.has('ref')){ window.history.pushState(null, document.title, '/'); } @@ -522,7 +518,7 @@ async function UIDesktop(options){ user_preferences[default_app_keys[key].substring(17)] = await puter.kv.get(default_app_keys[key]); } - update_user_preferences(user_preferences); + window.update_user_preferences(user_preferences); }); // Append to @@ -557,7 +553,7 @@ async function UIDesktop(options){ return false; // recursively create directories and upload files if(e.dataTransfer?.items?.length>0){ - upload_items(e.dataTransfer.items, desktop_path); + window.upload_items(e.dataTransfer.items, window.desktop_path); } e.stopPropagation(); @@ -574,7 +570,7 @@ async function UIDesktop(options){ tolerance: "intersect", drop: function( event, ui ) { // Check if item was actually dropped on desktop and not a window - if(mouseover_window !== undefined) + if(window.mouseover_window !== undefined) return; // Can't drop anything but UIItems on desktop @@ -582,7 +578,7 @@ async function UIDesktop(options){ return; // Don't move an item to its current directory - if( path.dirname($(ui.draggable).attr('data-path')) === desktop_path && !event.ctrlKey) + if( path.dirname($(ui.draggable).attr('data-path')) === window.desktop_path && !event.ctrlKey) return; // If ctrl is pressed and source is Trashed, cancel whole operation @@ -610,11 +606,11 @@ async function UIDesktop(options){ if(path.dirname($(ui.draggable).attr('data-path')) === window.trash_path) return; - copy_items(items_to_move, desktop_path) + window.copy_items(items_to_move, window.desktop_path) } // otherwise, move items else{ - move_items(items_to_move, desktop_path); + window.move_items(items_to_move, window.desktop_path); } } }); @@ -646,16 +642,16 @@ async function UIDesktop(options){ items: [ { html: i18n('auto_arrange'), - icon: is_auto_arrange_enabled ? '✓' : '', + icon: window.is_auto_arrange_enabled ? '✓' : '', onClick: async function(){ - is_auto_arrange_enabled = !is_auto_arrange_enabled; - store_auto_arrange_preference(is_auto_arrange_enabled); - if(is_auto_arrange_enabled){ - sort_items(el_desktop, $(el_desktop).attr('data-sort_by'), $(el_desktop).attr('data-sort_order')); - set_sort_by(options.desktop_fsentry.uid, $(el_desktop).attr('data-sort_by'), $(el_desktop).attr('data-sort_order')) - clear_desktop_item_positions(el_desktop); + window.is_auto_arrange_enabled = !window.is_auto_arrange_enabled; + window.store_auto_arrange_preference(window.is_auto_arrange_enabled); + if(window.is_auto_arrange_enabled){ + window.sort_items(el_desktop, $(el_desktop).attr('data-sort_by'), $(el_desktop).attr('data-sort_order')); + window.set_sort_by(options.desktop_fsentry.uid, $(el_desktop).attr('data-sort_by'), $(el_desktop).attr('data-sort_order')) + window.clear_desktop_item_positions(el_desktop); }else{ - set_desktop_item_positions(el_desktop) + window.set_desktop_item_positions(el_desktop) } } }, @@ -665,38 +661,38 @@ async function UIDesktop(options){ '-', { html: i18n('name'), - disabled: !is_auto_arrange_enabled, + disabled: !window.is_auto_arrange_enabled, icon: $(el_desktop).attr('data-sort_by') === 'name' ? '✓' : '', onClick: async function(){ - sort_items(el_desktop, 'name', $(el_desktop).attr('data-sort_order')); - set_sort_by(options.desktop_fsentry.uid, 'name', $(el_desktop).attr('data-sort_order')) + window.sort_items(el_desktop, 'name', $(el_desktop).attr('data-sort_order')); + window.set_sort_by(options.desktop_fsentry.uid, 'name', $(el_desktop).attr('data-sort_order')) } }, { html: i18n('date_modified'), - disabled: !is_auto_arrange_enabled, + disabled: !window.is_auto_arrange_enabled, icon: $(el_desktop).attr('data-sort_by') === 'modified' ? '✓' : '', onClick: async function(){ - sort_items(el_desktop, 'modified', $(el_desktop).attr('data-sort_order')); - set_sort_by(options.desktop_fsentry.uid, 'modified', $(el_desktop).attr('data-sort_order')) + window.sort_items(el_desktop, 'modified', $(el_desktop).attr('data-sort_order')); + window.set_sort_by(options.desktop_fsentry.uid, 'modified', $(el_desktop).attr('data-sort_order')) } }, { html: i18n('type'), - disabled: !is_auto_arrange_enabled, + disabled: !window.is_auto_arrange_enabled, icon: $(el_desktop).attr('data-sort_by') === 'type' ? '✓' : '', onClick: async function(){ - sort_items(el_desktop, 'type', $(el_desktop).attr('data-sort_order')); - set_sort_by(options.desktop_fsentry.uid, 'type', $(el_desktop).attr('data-sort_order')) + window.sort_items(el_desktop, 'type', $(el_desktop).attr('data-sort_order')); + window.set_sort_by(options.desktop_fsentry.uid, 'type', $(el_desktop).attr('data-sort_order')) } }, { html: i18n('size'), - disabled: !is_auto_arrange_enabled, + disabled: !window.is_auto_arrange_enabled, icon: $(el_desktop).attr('data-sort_by') === 'size' ? '✓' : '', onClick: async function(){ - sort_items(el_desktop, 'size', $(el_desktop).attr('data-sort_order')); - set_sort_by(options.desktop_fsentry.uid, 'size', $(el_desktop).attr('data-sort_order')) + window.sort_items(el_desktop, 'size', $(el_desktop).attr('data-sort_order')); + window.set_sort_by(options.desktop_fsentry.uid, 'size', $(el_desktop).attr('data-sort_order')) } }, // ------------------------------------------- @@ -705,22 +701,22 @@ async function UIDesktop(options){ '-', { html: i18n('ascending'), - disabled: !is_auto_arrange_enabled, + disabled: !window.is_auto_arrange_enabled, icon: $(el_desktop).attr('data-sort_order') === 'asc' ? '✓' : '', onClick: async function(){ const sort_by = $(el_desktop).attr('data-sort_by') - sort_items(el_desktop, sort_by, 'asc'); - set_sort_by(options.desktop_fsentry.uid, sort_by, 'asc') + window.sort_items(el_desktop, sort_by, 'asc'); + window.set_sort_by(options.desktop_fsentry.uid, sort_by, 'asc') } }, { html: i18n('descending'), - disabled: !is_auto_arrange_enabled, + disabled: !window.is_auto_arrange_enabled, icon: $(el_desktop).attr('data-sort_order') === 'desc' ? '✓' : '', onClick: async function(){ const sort_by = $(el_desktop).attr('data-sort_by') - sort_items(el_desktop, sort_by, 'desc'); - set_sort_by(options.desktop_fsentry.uid, sort_by, 'desc') + window.sort_items(el_desktop, sort_by, 'desc'); + window.set_sort_by(options.desktop_fsentry.uid, sort_by, 'desc') } }, ] @@ -754,7 +750,7 @@ async function UIDesktop(options){ // ------------------------------------------- // New File // ------------------------------------------- - new_context_menu_item(desktop_path, el_desktop), + new_context_menu_item(window.desktop_path, el_desktop), // ------------------------------------------- // - // ------------------------------------------- @@ -764,12 +760,12 @@ async function UIDesktop(options){ // ------------------------------------------- { html: i18n('paste'), - disabled: clipboard.length > 0 ? false : true, + disabled: window.clipboard.length > 0 ? false : true, onClick: function(){ - if(clipboard_op === 'copy') - copy_clipboard_items(desktop_path, el_desktop); - else if(clipboard_op === 'move') - move_clipboard_items(el_desktop) + if(window.clipboard_op === 'copy') + window.copy_clipboard_items(window.desktop_path, el_desktop); + else if(window.clipboard_op === 'move') + window.move_clipboard_items(el_desktop) } }, // ------------------------------------------- @@ -777,9 +773,9 @@ async function UIDesktop(options){ // ------------------------------------------- { html: i18n('undo'), - disabled: actions_history.length > 0 ? false : true, + disabled: window.actions_history.length > 0 ? false : true, onClick: function(){ - undo_last_action(); + window.undo_last_action(); } }, // ------------------------------------------- @@ -788,7 +784,7 @@ async function UIDesktop(options){ { html: i18n('upload_here'), onClick: function(){ - init_upload_using_dialog(el_desktop); + window.init_upload_using_dialog(el_desktop); } }, // ------------------------------------------- @@ -815,7 +811,7 @@ async function UIDesktop(options){ // we don't need to get the desktop items if we're in embedded or fullpage mode // because the items aren't visible anyway and we don't need to waste bandwidth/server resources //------------------------------------------- - if(!is_embedded && !window.is_fullpage_mode){ + if(!window.is_embedded && !window.is_fullpage_mode){ refresh_item_container(el_desktop, {fadeInItems: true}) } @@ -908,7 +904,7 @@ async function UIDesktop(options){ } // refer - if(user.referral_code){ + if(window.user.referral_code){ ht += `
`; } @@ -919,7 +915,7 @@ async function UIDesktop(options){ } // qr code button -- only show if not embedded - if(!is_embedded) + if(!window.is_embedded) ht += `
`; // user options menu @@ -937,17 +933,17 @@ async function UIDesktop(options){ // --------------------------------------------- // Run apps from insta-login URL // --------------------------------------------- - if(url_query_params.has('app')){ - let url_app_name = url_query_params.get('app'); + if(window.url_query_params.has('app')){ + let url_app_name = window.url_query_params.get('app'); if(url_app_name === 'explorer'){ - let predefined_path = home_path; - if(url_query_params.has('path')) - predefined_path =url_query_params.get('path') + let predefined_path = window.home_path; + if(window.url_query_params.has('path')) + predefined_path =window.url_query_params.get('path') // launch explorer UIWindow({ path: predefined_path, title: path.basename(predefined_path), - icon: await item_icon({is_dir: true, path: predefined_path}), + icon: await window.item_icon({is_dir: true, path: predefined_path}), // todo // uid: $(el_item).attr('data-uid'), is_dir: true, @@ -963,11 +959,11 @@ async function UIDesktop(options){ else if(window.app_launched_from_url){ let qparams = new URLSearchParams(window.location.search); if(!qparams.has('c')){ - launch_app({ - name: app_launched_from_url, + window.launch_app({ + name: window.app_launched_from_url, readURL: qparams.get('readURL'), maximized: qparams.get('maximized'), - params: app_query_params ?? [], + params: window.app_query_params ?? [], is_fullpage: window.is_fullpage_mode, window_options: { stay_on_top: false, @@ -1014,21 +1010,21 @@ async function UIDesktop(options){ var x1=month + "/" + dt + "/" + x.getFullYear(); x1 = x1 + " - " + hours + ":" + minutes + ":" + seconds + " " + ampm; $('#clock').html(x1); - $('#clock').css('line-height', taskbar_height + 'px'); + $('#clock').css('line-height', window.taskbar_height + 'px'); } setInterval(display_ct, 1000); // show referral notice window - if(window.show_referral_notice && !user.email_confirmed){ - getItem({ + if(window.show_referral_notice && !window.user.email_confirmed){ + window.getItem({ key: "shown_referral_notice", success: async function(res){ if(!res){ setTimeout(() => { UIWindowClaimReferral(); }, 1000); - setItem({ + window.setItem({ key: "shown_referral_notice", value: true, }) @@ -1122,13 +1118,13 @@ $(document).on('click', '.user-options-menu-btn', async function(e){ items.push( { html: l_user.username, - icon: l_user.username === user.username ? '✓' : '', + icon: l_user.username === window.user.username ? '✓' : '', onClick: async function(val){ // don't reload everything if clicked on already-logged-in user - if(l_user.username === user.username) + if(l_user.username === window.user.username) return; // update auth data - update_auth_data(l_user.auth_token, l_user); + window.update_auth_data(l_user.auth_token, l_user); // refresh location.reload(); } @@ -1167,7 +1163,7 @@ $(document).on('click', '.user-options-menu-btn', async function(e){ // ------------------------------------------- // Load available languages // ------------------------------------------- - const supportedLanguagesItems = listSupportedLanguages().map(lang => { + const supportedLanguagesItems = window.listSupportedLanguages().map(lang => { return { html: lang.name, icon: window.locale === lang.code ? '✓' : '', @@ -1246,11 +1242,11 @@ $(document).on('click', '.user-options-menu-btn', async function(e){ ] }) if(alert_resp === 'close_and_log_out') - logout(); + window.logout(); } // no open windows else - logout(); + window.logout(); } }, ] @@ -1258,7 +1254,7 @@ $(document).on('click', '.user-options-menu-btn', async function(e){ }) $(document).on('click', '.fullscreen-btn', async function (e) { - if(!is_fullscreen()) { + if(!window.is_fullscreen()) { var elem = document.documentElement; if (elem.requestFullscreen) { elem.requestFullscreen(); @@ -1305,7 +1301,7 @@ $(document).on('click', '.refer-btn', async function(e){ }) $(document).on('click', '.start-app', async function(e){ - launch_app({ + window.launch_app({ name: $(this).attr('data-app-name') }) // close popovers @@ -1367,7 +1363,7 @@ $(document).on('focus', '.launch-search', function(e){ }) $(document).on('change keyup keypress keydown paste', '.launch-search', function(e){ - // search launch_apps.recommended for query + // search window.launch_apps.recommended for query const query = $(this).val().toLowerCase(); if(query === ''){ $('.launch-search-clear').hide(); @@ -1378,7 +1374,7 @@ $(document).on('change keyup keypress keydown paste', '.launch-search', function $('.launch-apps-recent').hide(); $('.start-section-heading').hide(); $('.launch-search-clear').show(); - launch_apps.recommended.forEach((app)=>{ + window.launch_apps.recommended.forEach((app)=>{ if(app.title.toLowerCase().includes(query.toLowerCase())){ $(`.start-app-card[data-name="${app.name}"]`).show(); }else{ @@ -1457,7 +1453,7 @@ window.update_taskbar = function(){ // update taskbar in the server-side $.ajax({ - url: api_origin + "/update-taskbar-items", + url: window.api_origin + "/update-taskbar-items", type: 'POST', data: JSON.stringify({ items: items, @@ -1465,7 +1461,7 @@ window.update_taskbar = function(){ async: true, contentType: "application/json", headers: { - "Authorization": "Bearer "+auth_token + "Authorization": "Bearer "+window.auth_token }, }) } @@ -1485,7 +1481,7 @@ window.enter_fullpage_mode = (el_window)=>{ $(el_window).css({ width: '100%', height: '100%', - top: toolbar_height + 'px', + top: window.toolbar_height + 'px', left: 0, 'border-radius': 0, }); @@ -1499,7 +1495,7 @@ window.exit_fullpage_mode = (el_window)=>{ refresh_item_container($('.desktop.item-container'), {fadeInItems: true}); $(el_window).removeAttr('data-is_fullpage'); if(el_window){ - reset_window_size_and_position(el_window) + window.reset_window_size_and_position(el_window) $(el_window).find('.window-head').show(); } @@ -1510,14 +1506,14 @@ window.exit_fullpage_mode = (el_window)=>{ $('.show-desktop-btn').hide(); // refresh desktop background - refresh_desktop_background(); + window.refresh_desktop_background(); } window.reset_window_size_and_position = (el_window)=>{ $(el_window).css({ width: 680, height: 380, - 'border-radius': window_border_radius, + 'border-radius': window.window_border_radius, top: 'calc(50% - 190px)', left: 'calc(50% - 340px)', }); diff --git a/src/UI/UIItem.js b/src/UI/UIItem.js index f2c2c49a4..b601df1c8 100644 --- a/src/UI/UIItem.js +++ b/src/UI/UIItem.js @@ -39,7 +39,7 @@ function UIItem(options){ return; } - const item_id = global_element_id++; + const item_id = window.global_element_id++; let last_mousedown_ts = 999999999999999; let rename_cancelled = false; @@ -59,7 +59,7 @@ function UIItem(options){ options.sort_container_after_append = (options.sort_container_after_append !== undefined ? options.sort_container_after_append : false); const is_shared_with_me = (options.path !== '/'+window.user.username && !options.path.startsWith('/'+window.user.username+'/')); - let website_url = determine_website_url(options.path); + let website_url = window.determine_website_url(options.path); // do a quick check to see if the target parent has any file type restrictions const appendto_allowed_file_types = $(options.appendTo).attr('data-allowed_file_types') @@ -101,7 +101,7 @@ function UIItem(options){ h += `
`; // size h += `
`; - h += `${options.size ? byte_format(options.size) : '-'}`; + h += `${options.size ? window.byte_format(options.size) : '-'}`; h += `
`; // type h += `
`; @@ -158,7 +158,7 @@ function UIItem(options){ h += `
`; // name - h += `${options.is_trash ? i18n('trash') : html_encode(truncate_filename(options.name, TRUNCATE_LENGTH)).replaceAll(' ', ' ')}` + h += `${options.is_trash ? i18n('trash') : html_encode(window.truncate_filename(options.name, window.TRUNCATE_LENGTH)).replaceAll(' ', ' ')}` // name editor h += `` h += `
`; @@ -168,14 +168,14 @@ function UIItem(options){ // updte item_container const item_container = $(options.appendTo).closest('.item-container'); - show_or_hide_empty_folder_message(item_container); + window.show_or_hide_empty_folder_message(item_container); // get all the elements needed const el_item = document.getElementById(`item-${item_id}`); const el_item_name = document.querySelector(`#item-${item_id} > .item-name`); const el_item_icon = document.querySelector(`#item-${item_id} .item-icon`); const el_item_name_editor = document.querySelector(`#item-${item_id} > .item-name-editor`); - const is_trashed = $(el_item).attr('data-path').startsWith(trash_path + '/'); + const is_trashed = $(el_item).attr('data-path').startsWith(window.trash_path + '/'); // update parent window's explorer item count if applicable if(options.appendTo !== undefined){ @@ -183,11 +183,11 @@ function UIItem(options){ if(!$(el_window).hasClass('.window')) el_window = $(el_window).closest('.window'); - update_explorer_footer_item_count(el_window); + window.update_explorer_footer_item_count(el_window); } // manual positioning - if( !is_auto_arrange_enabled && + if( !window.is_auto_arrange_enabled && options.position && // item is on the desktop (must be desktop itself and not a window, hence the '.desktop' class check) $(el_item).closest('.item-container.desktop').attr('data-path') === window.desktop_path @@ -214,7 +214,7 @@ function UIItem(options){ $(el_item).removeClass('item-selected'); // if files were dropped... if(e.dataTransfer?.items?.length > 0){ - upload_items( e.dataTransfer.items, $(el_item).attr('data-path')) + window.upload_items( e.dataTransfer.items, $(el_item).attr('data-path')) } e.stopPropagation(); @@ -333,13 +333,13 @@ function UIItem(options){ } // send drag event to iframe if mouse is inside iframe - if(mouseover_window){ - const $app_iframe = $(mouseover_window).find('.window-app-iframe'); - if(!$(mouseover_window).hasClass('window-disabled') && $app_iframe.length > 0){ + if(window.mouseover_window){ + const $app_iframe = $(window.mouseover_window).find('.window-app-iframe'); + if(!$(window.mouseover_window).hasClass('window-disabled') && $app_iframe.length > 0){ var rect = $app_iframe.get(0).getBoundingClientRect(); // if mouse is inside iframe, send drag message to iframe - if(mouseX > rect.left && mouseX < rect.right && mouseY > rect.top && mouseY < rect.bottom){ - $app_iframe.get(0).contentWindow.postMessage({msg: "drag", x: (mouseX - rect.left), y: (mouseY - rect.top)}, '*'); + if(window.mouseX > rect.left && window.mouseX < rect.right && window.mouseY > rect.top && window.mouseY < rect.bottom){ + $app_iframe.get(0).contentWindow.postMessage({msg: "drag", x: (window.mouseX - rect.left), y: (window.mouseY - rect.top)}, '*'); } } } @@ -347,16 +347,16 @@ function UIItem(options){ stop: function(event, ui){ // Allow rearranging only if item is on desktop, not trash container, auto arrange is disabled and item is not dropped into another item if($(el_item).closest('.item-container').attr('data-path') === window.desktop_path && - !is_auto_arrange_enabled && $(el_item).attr('data-path') !== trash_path && !ui.helper.data('dropped') && + !window.is_auto_arrange_enabled && $(el_item).attr('data-path') !== window.trash_path && !ui.helper.data('dropped') && // Item must be dropped on the Desktop and not on the taskbar - mouseover_window === undefined && ui.position.top <= window.desktop_height - window.taskbar_height - 15){ + window.mouseover_window === undefined && ui.position.top <= window.desktop_height - window.taskbar_height - 15){ el_item.style.position = 'absolute'; el_item.style.left = ui.position.left + 'px'; el_item.style.top = ui.position.top + 'px'; $('.ui-draggable-dragging').remove(); - desktop_item_positions[$(el_item).attr('data-uid')] = ui.position; - save_desktop_item_positions() + window.desktop_item_positions[$(el_item).attr('data-uid')] = ui.position; + window.save_desktop_item_positions() } $('.item-selected-clone').remove(); @@ -380,7 +380,7 @@ function UIItem(options){ tolerance: 'pointer', drop: async function( event, ui ) { // Check if hovering over an item that is VISIBILE - if($(event.target).closest('.window').attr('data-id') !== $(mouseover_window).attr('data-id')) + if($(event.target).closest('.window').attr('data-id') !== $(window.mouseover_window).attr('data-id')) return; // If ctrl is pressed and source is Trashed, cancel whole operation @@ -424,7 +424,7 @@ function UIItem(options){ // open each item for (let i = 0; i < items_to_open.length; i++) { const item = items_to_open[i]; - launch_app({ + window.launch_app({ name: options.associated_app_name, file_path: item.path, // app_obj: open_item_meta.suggested_apps[0], @@ -445,14 +445,14 @@ function UIItem(options){ // If ctrl key is down, copy items. Except if target or source is Trash if(event.ctrlKey){ if(options.is_dir && $(el_item).attr('data-path') !== window.trash_path ) - copy_items(items_to_move, $(el_item).attr('data-path')) + window.copy_items(items_to_move, $(el_item).attr('data-path')) else if(!options.is_dir) - copy_items(items_to_move, path.dirname($(el_item).attr('data-path'))); + window.copy_items(items_to_move, path.dirname($(el_item).attr('data-path'))); } // If alt key is down, create shortcut items else if(event.altKey && window.feature_flags.create_shortcut){ items_to_move.forEach((item_to_move) => { - create_shortcut( + window.create_shortcut( path.basename($(item_to_move).attr('data-path')), $(item_to_move).attr('data-is_dir') === '1', options.is_dir ? $(el_item).attr('data-path') : path.dirname($(el_item).attr('data-path')), @@ -465,10 +465,10 @@ function UIItem(options){ // Otherwise, move items else if(options.is_dir){ if($(el_item).closest('.item-container').attr('data-path') === window.desktop_path){ - delete desktop_item_positions[$(el_item).attr('data-uid')]; - save_desktop_item_positions() + delete window.desktop_item_positions[$(el_item).attr('data-uid')]; + window.save_desktop_item_positions() } - move_items(items_to_move, $(el_item).attr('data-shortcut_to_path') !== '' ? $(el_item).attr('data-shortcut_to_path') : $(el_item).attr('data-path')); + window.move_items(items_to_move, $(el_item).attr('data-shortcut_to_path') !== '' ? $(el_item).attr('data-shortcut_to_path') : $(el_item).attr('data-path')); } } @@ -480,7 +480,7 @@ function UIItem(options){ over: function(event, ui){ // Check hovering over an item that is VISIBILE const $event_parent_win = $(event.target).closest('.window') - if( $event_parent_win.length > 0 && $event_parent_win.attr('data-id') !== $(mouseover_window).attr('data-id')) + if( $event_parent_win.length > 0 && $event_parent_win.attr('data-id') !== $(window.mouseover_window).attr('data-id')) return; // Don't do anything if the dragged item is NOT a UIItem if(!$(ui.draggable).hasClass('item')) @@ -522,7 +522,7 @@ function UIItem(options){ if($(e.target).hasClass('item-name-editor')) return false; - open_item({ + window.open_item({ item: el_item, maximized: true, }); @@ -537,7 +537,7 @@ function UIItem(options){ if($(e.target).hasClass('item-name-editor')) return false; - open_item({ + window.open_item({ item: el_item, new_window: e.metaKey || e.ctrlKey, }); @@ -576,7 +576,7 @@ function UIItem(options){ else{ $(this).addClass('item-selected') } - update_explorer_footer_selected_items_count($el_parent_window) + window.update_explorer_footer_selected_items_count($el_parent_window) }); // -------------------------------------------------------- // Click @@ -593,7 +593,7 @@ function UIItem(options){ // CTRL/Command key is pressed or clicking an item that is already selected if(!e.ctrlKey && !e.metaKey){ $(this).closest('.item-container').find('.item-selected').not(this).removeClass('item-selected'); - update_explorer_footer_selected_items_count($el_parent_window) + window.update_explorer_footer_selected_items_count($el_parent_window) } //---------------------------------------------------------------- // On an OpenFileDialog? @@ -648,7 +648,7 @@ function UIItem(options){ UIAlert(`The name ".." is not allowed, because it is a reserved name. Please choose another name.`) } - $(el_item_name).html(truncate_filename(options.name, TRUNCATE_LENGTH).replaceAll(' ', ' ')); + $(el_item_name).html(window.truncate_filename(options.name, window.TRUNCATE_LENGTH).replaceAll(' ', ' ')); $(el_item_name).show(); $(el_item_name_editor).val($(el_item).attr('data-name')); $(el_item_name_editor).hide(); @@ -658,7 +658,7 @@ function UIItem(options){ $(el_item_name_editor).removeClass('item-name-editor-active'); // Perform rename request - rename_file(options, new_name, old_name, old_path, el_item, el_item_name, el_item_icon, el_item_name_editor, website_url); + window.rename_file(options, new_name, old_name, old_path, el_item, el_item_name, el_item_icon, el_item_name_editor, website_url); } // -------------------------------------------------------- @@ -675,8 +675,8 @@ function UIItem(options){ e.preventDefault(); $(el_item_name_editor).blur(); $(el_item).addClass('item-selected'); - last_enter_pressed_to_rename_ts = Date.now(); - update_explorer_footer_selected_items_count($(el_item).closest('.item-container')); + window.last_enter_pressed_to_rename_ts = Date.now(); + window.update_explorer_footer_selected_items_count($(el_item).closest('.item-container')); return false; } }) @@ -715,7 +715,7 @@ function UIItem(options){ setTimeout(() => { if(!skip_a_rename_click && (Date.now() - last_mousedown_ts) > 400){ if (!e.ctrlKey && !e.metaKey) - activate_item_name_editor(el_item) + window.activate_item_name_editor(el_item) last_mousedown_ts = 0 }else{ last_mousedown_ts = Date.now() + 500; @@ -760,7 +760,7 @@ function UIItem(options){ // Multiple items selected // ------------------------------------------------------- if($selected_items.length > 1){ - const are_trashed = $selected_items.attr('data-path').startsWith(trash_path + '/'); + const are_trashed = $selected_items.attr('data-path').startsWith(window.trash_path + '/'); menu_items = [] // ------------------------------------------- // Restore @@ -772,7 +772,7 @@ function UIItem(options){ $selected_items.each(function() { const ell = this; let metadata = $(ell).attr('data-metadata') === '' ? {} : JSON.parse($(ell).attr('data-metadata')) - move_items([ell], path.dirname(metadata.original_path)); + window.move_items([ell], path.dirname(metadata.original_path)); }) } }); @@ -793,7 +793,7 @@ function UIItem(options){ items.push($selected_items[index]); } - zipItems(items, path.dirname($(el_item).attr('data-path')), true); + window.zipItems(items, path.dirname($(el_item).attr('data-path')), true); } }); // ------------------------------------------- @@ -807,7 +807,7 @@ function UIItem(options){ items.push($selected_items[index]); } - zipItems(items, path.dirname($(el_item).attr('data-path')), false); + window.zipItems(items, path.dirname($(el_item).attr('data-path')), false); } }); // ------------------------------------------- @@ -872,9 +872,9 @@ function UIItem(options){ if((alert_resp) === 'Delete'){ for (let index = 0; index < $selected_items.length; index++) { const element = $selected_items[index]; - await delete_item(element); + await window.delete_item(element); } - const trash = await puter.fs.stat(trash_path); + const trash = await puter.fs.stat(window.trash_path); // update other clients if(window.socket){ @@ -882,8 +882,8 @@ function UIItem(options){ } if(trash.is_empty){ - $(`.item[data-path="${html_encode(trash_path)}" i], .item[data-shortcut_to_path="${trash_path}" i]`).find('.item-icon > img').attr('src', window.icons['trash.svg']); - $(`.window[data-path="${html_encode(trash_path)}"]`).find('.window-head-icon').attr('src', window.icons['trash.svg']); + $(`.item[data-path="${html_encode(window.trash_path)}" i], .item[data-shortcut_to_path="${window.trash_path}" i]`).find('.item-icon > img').attr('src', window.icons['trash.svg']); + $(`.window[data-path="${html_encode(window.trash_path)}"]`).find('.window-head-icon').attr('src', window.icons['trash.svg']); } } } @@ -903,7 +903,7 @@ function UIItem(options){ base_dir = window.desktop_path; } // create shortcut - create_shortcut( + window.create_shortcut( path.basename($(this).attr('data-path')), $(this).attr('data-is_dir') === '1', base_dir, @@ -922,7 +922,7 @@ function UIItem(options){ menu_items.push({ html: i18n('delete'), onClick: async function(){ - move_items($selected_items, trash_path); + window.move_items($selected_items, window.trash_path); } }); } @@ -933,7 +933,7 @@ function UIItem(options){ // One item selected // ------------------------------------------------------- else{ - const is_trash = $(el_item).attr('data-path') === trash_path || $(el_item).attr('data-shortcut_to_path') === trash_path; + const is_trash = $(el_item).attr('data-path') === window.trash_path || $(el_item).attr('data-shortcut_to_path') === window.trash_path; menu_items = []; // ------------------------------------------- // Open @@ -942,7 +942,7 @@ function UIItem(options){ menu_items.push({ html: i18n('open'), onClick: function(){ - open_item({item: el_item}); + window.open_item({item: el_item}); } }); @@ -959,7 +959,7 @@ function UIItem(options){ let items = []; if(!options.suggested_apps || options.suggested_apps.length === 0){ // try to find suitable apps - const suitable_apps = await suggest_apps_for_fsentry({ + const suitable_apps = await window.suggest_apps_for_fsentry({ uid: options.uid, path: options.path, }); @@ -981,12 +981,12 @@ function UIItem(options){ onClick: async function(){ var extension = path.extname($(el_item).attr('data-path')).toLowerCase(); if( - user_preferences[`default_apps${extension}`] !== suggested_app.name + window.user_preferences[`default_apps${extension}`] !== suggested_app.name && ( - (!user_preferences[`default_apps${extension}`] && index > 0) + (!window.user_preferences[`default_apps${extension}`] && index > 0) || - (user_preferences[`default_apps${extension}`]) + (window.user_preferences[`default_apps${extension}`]) ) ){ const alert_resp = await UIAlert({ @@ -1004,11 +1004,11 @@ function UIItem(options){ ] }) if((alert_resp) === 'yes'){ - user_preferences['default_apps' + extension] = suggested_app.name; - window.mutate_user_preferences(user_preferences); + window.user_preferences['default_apps' + extension] = suggested_app.name; + window.mutate_user_preferences(window.user_preferences); } } - launch_app({ + window.launch_app({ name: suggested_app.name, file_path: $(el_item).attr('data-path'), window_title: $(el_item).attr('data-name'), @@ -1044,7 +1044,7 @@ function UIItem(options){ html: i18n('open_in_new_window'), onClick: function(){ if(options.is_dir){ - open_item({item: el_item, new_window: true}) + window.open_item({item: el_item, new_window: true}) } } }); @@ -1090,7 +1090,7 @@ function UIItem(options){ html: i18n('deploy_as_app'), disabled: !options.is_dir, onClick: async function () { - launch_app({ + window.launch_app({ name: 'dev-center', file_path: $(el_item).attr('data-path'), file_uid: $(el_item).attr('data-uid'), @@ -1111,7 +1111,7 @@ function UIItem(options){ menu_items.push({ html: i18n('empty_trash'), onClick: async function(){ - empty_trash(); + window.empty_trash(); } }); } @@ -1124,9 +1124,9 @@ function UIItem(options){ disabled: options.is_dir && !window.feature_flags.download_directory, onClick: async function(){ if(options.is_dir) - zipItems(el_item, path.dirname($(el_item).attr('data-path')), true); + window.zipItems(el_item, path.dirname($(el_item).attr('data-path')), true); else - trigger_download([options.path]); + window.trigger_download([options.path]); } }); } @@ -1137,7 +1137,7 @@ function UIItem(options){ menu_items.push({ html: i18n('zip'), onClick: function(){ - zipItems(el_item, path.dirname($(el_item).attr('data-path')), false); + window.zipItems(el_item, path.dirname($(el_item).attr('data-path')), false); } }) } @@ -1177,7 +1177,7 @@ function UIItem(options){ html: i18n('restore'), onClick: async function(){ let metadata = $(el_item).attr('data-metadata') === '' ? {} : JSON.parse($(el_item).attr('data-metadata')) - move_items([el_item], path.dirname(metadata.original_path)); + window.move_items([el_item], path.dirname(metadata.original_path)); } }); } @@ -1216,12 +1216,12 @@ function UIItem(options){ if($(el_item).attr('data-is_dir') === '1' && !is_trashed && !is_trash){ menu_items.push({ html: i18n('paste_into_folder'), - disabled: clipboard.length > 0 ? false : true, + disabled: window.clipboard.length > 0 ? false : true, onClick: function(){ - if(clipboard_op === 'copy') - copy_clipboard_items($(el_item).attr('data-path'), null); - else if(clipboard_op === 'move') - move_clipboard_items(null, $(el_item).attr('data-path')) + if(window.clipboard_op === 'copy') + window.copy_clipboard_items($(el_item).attr('data-path'), null); + else if(window.clipboard_op === 'move') + window.move_clipboard_items(null, $(el_item).attr('data-path')) } }) } @@ -1244,7 +1244,7 @@ function UIItem(options){ base_dir = window.desktop_path; } - create_shortcut( + window.create_shortcut( path.basename($(el_item).attr('data-path')), options.is_dir, base_dir, @@ -1262,7 +1262,7 @@ function UIItem(options){ menu_items.push({ html: i18n('delete'), onClick: async function(){ - move_items([el_item], trash_path); + window.move_items([el_item], window.trash_path); } }); } @@ -1287,17 +1287,17 @@ function UIItem(options){ }) if((alert_resp) === 'Delete'){ - await delete_item(el_item); + await window.delete_item(el_item); // check if trash is empty - const trash = await puter.fs.stat(trash_path); + const trash = await puter.fs.stat(window.trash_path); // update other clients if(window.socket){ window.socket.emit('trash.is_empty', {is_empty: trash.is_empty}); } // update this client if(trash.is_empty){ - $(`.item[data-path="${html_encode(trash_path)}" i], .item[data-shortcut_to_path="${html_encode(trash_path)}" i]`).find('.item-icon > img').attr('src', window.icons['trash.svg']); - $(`.window[data-path="${trash_path}"]`).find('.window-head-icon').attr('src', window.icons['trash.svg']); + $(`.item[data-path="${html_encode(window.trash_path)}" i], .item[data-shortcut_to_path="${html_encode(window.trash_path)}" i]`).find('.item-icon > img').attr('src', window.icons['trash.svg']); + $(`.window[data-path="${window.trash_path}"]`).find('.window-head-icon').attr('src', window.icons['trash.svg']); } } } @@ -1310,7 +1310,7 @@ function UIItem(options){ menu_items.push({ html: i18n('rename'), onClick: function(){ - activate_item_name_editor(el_item) + window.activate_item_name_editor(el_item) } }); } @@ -1370,10 +1370,10 @@ function UIItem(options){ }) if(options.sort_container_after_append){ - sort_items(options.appendTo, $(el_item).closest('.item-container').attr('data-sort_by'), $(el_item).closest('.item-container').attr('data-sort_order')); + window.sort_items(options.appendTo, $(el_item).closest('.item-container').attr('data-sort_by'), $(el_item).closest('.item-container').attr('data-sort_order')); } if(options.editable){ - activate_item_name_editor(el_item) + window.activate_item_name_editor(el_item) } } @@ -1430,7 +1430,7 @@ $(document).on('contextmenu', '.item-has-website-url-badge', async function(e){ onClick: async function(){ const website_url = $(e.target).closest('.item').attr('data-website_url'); if(website_url){ - await copy_to_clipboard(website_url); + await window.copy_to_clipboard(website_url); } } }, @@ -1514,7 +1514,7 @@ $.fn.removeItems = async function(options) { $(this).each(async function() { const parent_container = $(this).closest('.item-container'); $(this).remove(); - show_or_hide_empty_folder_message(parent_container); + window.show_or_hide_empty_folder_message(parent_container); }); return this; diff --git a/src/UI/UINotification.js b/src/UI/UINotification.js index 697d23e39..e110ea232 100644 --- a/src/UI/UINotification.js +++ b/src/UI/UINotification.js @@ -18,12 +18,12 @@ */ function UINotification(options){ - global_element_id++; + window.global_element_id++; options.content = options.content ?? ''; let h = ''; - h += `
`; + h += `
`; h += ``; h += html_encode(options.content); h += `
`; @@ -31,7 +31,7 @@ function UINotification(options){ $('body').append(h); - const el_notification = document.getElementById(`ui-notification__${global_element_id}`); + const el_notification = document.getElementById(`ui-notification__${window.global_element_id}`); $(el_notification).show(0, function(e){ // options.onAppend() @@ -44,7 +44,7 @@ function UINotification(options){ $(el_notification).delay(100).show(0). // In the right position (the mouse) css({ - top: toolbar_height + 15, + top: window.toolbar_height + 15, }); return el_notification; @@ -52,9 +52,10 @@ function UINotification(options){ $(document).on('click', '.notification', function(e){ if($(e.target).hasClass('notification')){ - if(options.click && typeof options.click === 'function'){ - options.click(e); - } + // TODO: options isn't available here + // if(options.click && typeof options.click === 'function'){ + // options.click(e); + // } window.close_notification(e.target); }else{ window.close_notification($(e.target).closest('.notification')); diff --git a/src/UI/UIPopover.js b/src/UI/UIPopover.js index 69f7ddaaf..23f6f21bb 100644 --- a/src/UI/UIPopover.js +++ b/src/UI/UIPopover.js @@ -25,19 +25,19 @@ function UIPopover(options){ $('.window-active .window-app-iframe').css('pointer-events', 'none'); - global_element_id++; + window.global_element_id++; options.content = options.content ?? ''; let h = ''; - h += `
`; + h += `
`; h += options.content; h += `
`; $('body').append(h); - const el_popover = document.getElementById(`popover-${global_element_id}`); + const el_popover = document.getElementById(`popover-${window.global_element_id}`); $(el_popover).show(0, function(e){ // options.onAppend() @@ -73,7 +73,7 @@ function UIPopover(options){ // Y position const popover_height = options.height ?? $(el_popover).height(); if(options.center_horizontally){ - y_pos = options.top ?? (window.innerHeight - (taskbar_height + popover_height + 10)); + y_pos = options.top ?? (window.innerHeight - (window.taskbar_height + popover_height + 10)); }else{ y_pos = options.top ?? ($(options.snapToElement).offset().top + $(options.snapToElement).height() + 5); } diff --git a/src/UI/UIPrompt.js b/src/UI/UIPrompt.js index 7d48f72c0..56b8f4ea4 100644 --- a/src/UI/UIPrompt.js +++ b/src/UI/UIPrompt.js @@ -23,7 +23,7 @@ function UIPrompt(options){ // set sensible defaults if(arguments.length > 0){ // if first argument is a string, then assume it is the message - if(isString(arguments[0])){ + if(window.isString(arguments[0])){ options = {}; options.message = arguments[0]; } diff --git a/src/UI/UITaskbar.js b/src/UI/UITaskbar.js index 43b7a603e..2184f4c46 100644 --- a/src/UI/UITaskbar.js +++ b/src/UI/UITaskbar.js @@ -21,19 +21,19 @@ import UITaskbarItem from './UITaskbarItem.js' import UIPopover from './UIPopover.js' async function UITaskbar(options){ - global_element_id++; + window.global_element_id++; options = options ?? {}; options.content = options.content ?? ''; // get launch apps $.ajax({ - url: api_origin + "/get-launch-apps", + url: window.api_origin + "/get-launch-apps", type: 'GET', async: true, contentType: "application/json", headers: { - "Authorization": "Bearer "+auth_token + "Authorization": "Bearer "+window.auth_token }, success: function (apps){ window.launch_apps = apps; @@ -41,7 +41,7 @@ async function UITaskbar(options){ }); let h = ''; - h += `
`; + h += `
`; $('.desktop').append(h); @@ -74,15 +74,15 @@ async function UITaskbar(options){ // In the rare case that launch_apps is not populated yet, get it from the server // then populate the popover - if(!launch_apps || !launch_apps.recent || launch_apps.recent.length === 0){ + if(!window.launch_apps || !window.launch_apps.recent || window.launch_apps.recent.length === 0){ // get launch apps - launch_apps = await $.ajax({ - url: api_origin + "/get-launch-apps", + window.launch_apps = await $.ajax({ + url: window.api_origin + "/get-launch-apps", type: 'GET', async: true, contentType: "application/json", headers: { - "Authorization": "Bearer "+auth_token + "Authorization": "Bearer "+window.auth_token }, }); } @@ -96,14 +96,14 @@ async function UITaskbar(options){ // ------------------------------------------- // Recent apps // ------------------------------------------- - if(launch_apps.recent.length > 0){ + if(window.launch_apps.recent.length > 0){ // heading apps_str += `

${i18n('recent')}

`; // apps apps_str += `
`; - for (let index = 0; index < window.launch_recent_apps_count && index < launch_apps.recent.length; index++) { - const app_info = launch_apps.recent[index]; + for (let index = 0; index < window.launch_recent_apps_count && index < window.launch_apps.recent.length; index++) { + const app_info = window.launch_apps.recent[index]; apps_str += `
`; apps_str += `
`; apps_str += ``; @@ -116,14 +116,14 @@ async function UITaskbar(options){ // ------------------------------------------- // Reccomended apps // ------------------------------------------- - if(launch_apps.recommended.length > 0){ + if(window.launch_apps.recommended.length > 0){ // heading - apps_str += `

Recommended

`; + apps_str += `

Recommended

`; // apps apps_str += `