From 1e94d1a8ed5ba406d99060d3d7b19f3fefe3f670 Mon Sep 17 00:00:00 2001 From: ZomoXYZ Date: Mon, 6 Jun 2022 21:00:10 -0500 Subject: [PATCH] init --- .eslintrc.json | 50 ++ .gitignore | 1 + .prettierignore | 1 + .prettierrc | 10 + lib/main.js | 45 ++ lib/main.js.map | 1 + lib/paths.js | 13 + lib/paths.js.map | 1 + lib/readmeta.js | 89 ++++ lib/readmeta.js.map | 1 + lib/types.js | 2 + lib/types.js.map | 1 + meta.schema.json | 103 ++++ package.json | 29 + pnpm-lock.yaml | 1083 ++++++++++++++++++++++++++++++++++++++ readme.md | 25 + src/main.ts | 64 +++ src/paths.ts | 16 + src/readmeta.ts | 93 ++++ src/types.ts | 42 ++ test/test.mjs | 0 tsconfig.json | 17 + types/compiler_vars.d.ts | 6 + 23 files changed, 1693 insertions(+) create mode 100644 .eslintrc.json create mode 100644 .gitignore create mode 100644 .prettierignore create mode 100644 .prettierrc create mode 100644 lib/main.js create mode 100644 lib/main.js.map create mode 100644 lib/paths.js create mode 100644 lib/paths.js.map create mode 100644 lib/readmeta.js create mode 100644 lib/readmeta.js.map create mode 100644 lib/types.js create mode 100644 lib/types.js.map create mode 100644 meta.schema.json create mode 100644 package.json create mode 100644 pnpm-lock.yaml create mode 100644 readme.md create mode 100644 src/main.ts create mode 100644 src/paths.ts create mode 100644 src/readmeta.ts create mode 100644 src/types.ts create mode 100644 test/test.mjs create mode 100644 tsconfig.json create mode 100644 types/compiler_vars.d.ts diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..bd542a5 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,50 @@ +{ + "root": true, + "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"], + "parser": "@typescript-eslint/parser", + "plugins": ["@typescript-eslint"], + "rules": { + "@typescript-eslint/strict-boolean-expressions": [ + 2, + { + "allowString": false, + "allowNumber": false + } + ], + + /* important */ + "prefer-const": "error", + "quotes": ["error", "single"], + + "block-scoped-var": "error", + "camelcase": "error", + "consistent-this": ["error", "that"], + "no-else-return": "error", + "no-eq-null": "error", + "no-floating-decimal": "error", + "no-implicit-coercion": "error", + "no-implied-eval": "error", + "no-invalid-this": "error", + "require-await": "error", + "yoda": "error", + + "semi": ["error", "always"], + "semi-style": ["error", "last"], + + /* less important */ + "no-unreachable-loop": "error", + "no-unused-private-class-members": "error", + "no-use-before-define": "error", + "no-unmodified-loop-condition": "error", + "no-duplicate-imports": "error", + "no-promise-executor-return": "error", + "no-self-compare": "error", + "no-constructor-return": "error", + "no-template-curly-in-string": "error", + "array-callback-return": "error", + "no-eval": "error", + "no-extend-native": "error", + "no-extra-bind": "error" + }, + "ignorePatterns": ["src/**/*.test.ts", "src/frontend/generated/*"] +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..4be6e16 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +dist/* \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..07a8707 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,10 @@ +{ + "printWidth": 80, + "tabWidth": 4, + "useTabs": false, + "semi": false, + "singleQuote": true, + "trailingComma": "es5", + "bracketSpacing": true, + "arrowParens": "avoid" +} diff --git a/lib/main.js b/lib/main.js new file mode 100644 index 0000000..defdb6d --- /dev/null +++ b/lib/main.js @@ -0,0 +1,45 @@ +import { build } from 'esbuild'; +import { lstatSync, readdirSync, readFileSync, unlinkSync, writeFileSync, } from 'fs'; +import { DistBase, DistPath, ScriptBase, ScriptPath } from './paths'; +import readMeta from './readmeta'; +async function compileProject(name) { + //read meta file + let [metaJson, metaString] = readMeta(name); + let outPath = DistPath(name); + await build({ + entryPoints: [ScriptPath(name).main], + outfile: outPath, + target: 'esnext', + platform: 'node', + format: 'esm', + bundle: true, + minify: false, + define: { + UserScriptName: `'${metaJson.name}'`, + UserScriptNamespace: `'${metaJson.namespace}'`, + UserScriptVersion: `'${metaJson.version}'`, + UserScriptDownloadURL: `'${metaJson.downloadURL}'`, + UserScriptSupportURL: `'${metaJson.supportURL}'`, + UserScriptHomepageURL: `'${metaJson.homepageURL}'`, + }, + }); + //add UserScript header + let content = readFileSync(outPath).toString(); + writeFileSync(outPath, metaString + content); +} +if (!lstatSync('package.json').isFile()) { + console.error('package.json not found, unwilling to run'); + process.exit(1); +} +//delete compiled scripts +readdirSync(DistBase).forEach(file => unlinkSync(`${DistBase}/${file}`)); +//compile scripts +readdirSync(ScriptBase).forEach(name => { + let path = ScriptPath(name); + if (!name.endsWith('_') && + lstatSync(path.dir).isDirectory() && + lstatSync(path.main).isFile()) { + compileProject(name); + } +}); +//# sourceMappingURL=main.js.map \ No newline at end of file diff --git a/lib/main.js.map b/lib/main.js.map new file mode 100644 index 0000000..c19dfb4 --- /dev/null +++ b/lib/main.js.map @@ -0,0 +1 @@ +{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EACH,SAAS,EACT,WAAW,EACX,YAAY,EACZ,UAAU,EACV,aAAa,GAChB,MAAM,IAAI,CAAA;AACX,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpE,OAAO,QAAQ,MAAM,YAAY,CAAA;AAEjC,KAAK,UAAU,cAAc,CAAC,IAAY;IACtC,gBAAgB;IAChB,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC3C,IAAI,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAA;IAE5B,MAAM,KAAK,CAAC;QACR,WAAW,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;QACpC,OAAO,EAAE,OAAO;QAEhB,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,KAAK;QAEb,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,KAAK;QAEb,MAAM,EAAE;YACJ,cAAc,EAAE,IAAI,QAAQ,CAAC,IAAI,GAAG;YACpC,mBAAmB,EAAE,IAAI,QAAQ,CAAC,SAAS,GAAG;YAC9C,iBAAiB,EAAE,IAAI,QAAQ,CAAC,OAAO,GAAG;YAE1C,qBAAqB,EAAE,IAAI,QAAQ,CAAC,WAAW,GAAG;YAClD,oBAAoB,EAAE,IAAI,QAAQ,CAAC,UAAU,GAAG;YAChD,qBAAqB,EAAE,IAAI,QAAQ,CAAC,WAAW,GAAG;SACrD;KACJ,CAAC,CAAA;IAEF,uBAAuB;IACvB,IAAI,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAA;IAE9C,aAAa,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,CAAA;AAChD,CAAC;AAED,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,MAAM,EAAE,EAAE;IACrC,OAAO,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAA;IACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;CAClB;AAED,yBAAyB;AACzB,WAAW,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,QAAQ,IAAI,IAAI,EAAE,CAAC,CAAC,CAAA;AAExE,iBAAiB;AACjB,WAAW,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;IACnC,IAAI,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,CAAA;IAE3B,IACI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QACnB,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE;QACjC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAC/B;QACE,cAAc,CAAC,IAAI,CAAC,CAAA;KACvB;AACL,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/lib/paths.js b/lib/paths.js new file mode 100644 index 0000000..e716e50 --- /dev/null +++ b/lib/paths.js @@ -0,0 +1,13 @@ +export const BaseUrl = `https://git.zomo.dev/zomo/browser-scripts`; +export const RemoteBranch = 'main'; +export const ScriptBase = 'scripts'; +export const DistBase = 'dist'; +export const SupportUrl = `${BaseUrl}/issues`; +export const FileUrl = (name) => `${BaseUrl}/raw/branch/${RemoteBranch}/${DistBase}/${name}.user.js`; +export const ScriptPath = (name) => ({ + dir: `${ScriptBase}/${name}`, + main: `${ScriptBase}/${name}/main.ts`, + meta: `${ScriptBase}/${name}/meta.json`, +}); +export const DistPath = (name) => `${DistBase}/${name}.user.js`; +//# sourceMappingURL=paths.js.map \ No newline at end of file diff --git a/lib/paths.js.map b/lib/paths.js.map new file mode 100644 index 0000000..65a927d --- /dev/null +++ b/lib/paths.js.map @@ -0,0 +1 @@ +{"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,2CAA2C,CAAA;AAClE,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAA;AAClC,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAA;AACnC,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAA;AAE9B,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,OAAO,SAAS,CAAA;AAC7C,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE,CACpC,GAAG,OAAO,eAAe,YAAY,IAAI,QAAQ,IAAI,IAAI,UAAU,CAAA;AAEvE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC;IACzC,GAAG,EAAE,GAAG,UAAU,IAAI,IAAI,EAAE;IAC5B,IAAI,EAAE,GAAG,UAAU,IAAI,IAAI,UAAU;IACrC,IAAI,EAAE,GAAG,UAAU,IAAI,IAAI,YAAY;CAC1C,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,GAAG,QAAQ,IAAI,IAAI,UAAU,CAAA"} \ No newline at end of file diff --git a/lib/readmeta.js b/lib/readmeta.js new file mode 100644 index 0000000..0562655 --- /dev/null +++ b/lib/readmeta.js @@ -0,0 +1,89 @@ +import { lstatSync, readFileSync } from 'fs'; +import { BaseUrl, FileUrl, ScriptPath, SupportUrl } from './paths'; +export default function (name) { + var meta = { + name: name, + namespace: 'zomo.dev', + match: '', + excludematch: '', + version: '0.0.0', + description: '', + icon: '', + require: '', + resource: '', + runat: '', + noframes: false, + grant: '', + injectinto: '', + downloadURL: FileUrl(name), + supportURL: SupportUrl, + homepageURL: BaseUrl, + unwrap: false, + }; + let metaPath = ScriptPath(name).meta; + if (lstatSync(metaPath).isFile()) { + try { + let args = JSON.parse(readFileSync(metaPath).toString()); + let key; + for (key in meta) { + let val = args[key]; + //cases where the value is empty + if (val === undefined) + continue; + if (val === false) + continue; + if (val === '') + continue; + meta[key] = val; + } + } + catch (e) { + console.log(e); + } + } + else { + console.log(`${metaPath} not found, using default metadata`); + } + const keyConversion = { + injectinto: 'inject-into', + excludematch: 'exclude-match', + }; + return [ + meta, + `// ==UserScript== +${Object.keys(meta) + .filter(key => { + let val = meta[key]; + if (val === undefined) + return false; + if (val === false) + return false; + if (val === '') + return false; + return true; + }) + .map(key => { + let val = meta[key]; + let key_str = key in keyConversion + ? keyConversion[key] + : key; + key_str = key_str.padStart(12, ' '); + if (typeof val === 'boolean') { + if (val) + return `// @${key_str}`; + } + else if (typeof val === 'string') { + return `// @${key_str} ${val}`; + } + else if (Array.isArray(val)) { + return val.map(v => `// @${key_str} ${v}`).join('\n'); + } + return ''; + }) + .filter(l => l.length) + .join('\n')} +// ==/UserScript== +`, + ]; +} +//# sourceMappingURL=readmeta.js.map \ No newline at end of file diff --git a/lib/readmeta.js.map b/lib/readmeta.js.map new file mode 100644 index 0000000..9cf61b8 --- /dev/null +++ b/lib/readmeta.js.map @@ -0,0 +1 @@ +{"version":3,"file":"readmeta.js","sourceRoot":"","sources":["../src/readmeta.ts"],"names":[],"mappings":"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"} \ No newline at end of file diff --git a/lib/types.js b/lib/types.js new file mode 100644 index 0000000..718fd38 --- /dev/null +++ b/lib/types.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/lib/types.js.map b/lib/types.js.map new file mode 100644 index 0000000..c768b79 --- /dev/null +++ b/lib/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/meta.schema.json b/meta.schema.json new file mode 100644 index 0000000..932b9b5 --- /dev/null +++ b/meta.schema.json @@ -0,0 +1,103 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "UserScriptMeta", + "type": "object", + "properties": { + "name": { + "description": "Script Name", + "type": "string" + }, + "namespace": { + "description": "Author namespace", + "type": "string" + }, + "match": { + "description": "", + "type": ["string", "array"], + "minItems": 1, + "uniqueItems": true, + "items": { + "type": "string" + } + }, + "excludematch": { + "description": "", + "type": ["string", "array"], + "minItems": 1, + "uniqueItems": true, + "items": { + "type": "string" + } + }, + "version": { + "description": "", + "type": "string" + }, + "description": { + "description": "", + "type": "string" + }, + "icon": { + "description": "", + "type": "string" + }, + "require": { + "description": "", + "type": ["string", "array"], + "minItems": 1, + "uniqueItems": true, + "items": { + "type": "string" + } + }, + "resource": { + "description": "", + "type": ["string", "array"], + "minItems": 1, + "uniqueItems": true, + "items": { + "type": "string" + } + }, + "runat": { + "description": "", + "type": "string", + "enum": ["document-start", "document-end", "document-idle"] + }, + "noframes": { + "description": "", + "type": "boolean" + }, + "grant": { + "description": "", + "type": ["string", "array"], + "minItems": 1, + "uniqueItems": true, + "items": { + "type": "string" + } + }, + "injectinto": { + "description": "", + "type": "string", + "enum": ["page", "content", "auto"] + }, + "downloadURL": { + "description": "", + "type": "string" + }, + "supportURL": { + "description": "", + "type": "string" + }, + "homepageURL": { + "description": "", + "type": "string" + }, + "unwrap": { + "description": "", + "type": "boolean" + } + }, + "required": ["name", "namespace", "version"] +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..3edc12f --- /dev/null +++ b/package.json @@ -0,0 +1,29 @@ +{ + "name": "browser-scripts-builder", + "version": "1.0.0", + "description": "", + "main": "./lib/main.mjs", + "module": "./lib/main.mjs", + "bin": { + "bsbuild": "./lib/main.js" + }, + "scripts": { + "prettier": "prettier --write .", + "build": "npm run prettier && tsc", + "test": "node ./test/test.mjs" + }, + "repository": { + "type": "git", + "url": "https://git.zomo.dev/zomo/browser-scripts-builder" + }, + "author": "", + "license": "ISC", + "dependencies": { + "esbuild": "^0.14.42" + }, + "devDependencies": { + "@types/node": "^17.0.40", + "eslint": "^8.17.0", + "prettier": "^2.6.2" + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..c8bbf60 --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,1083 @@ +lockfileVersion: 5.3 + +specifiers: + '@types/node': ^17.0.40 + esbuild: ^0.14.42 + eslint: ^8.17.0 + prettier: ^2.6.2 + +dependencies: + '@types/node': 17.0.40 + esbuild: 0.14.42 + +devDependencies: + eslint: 8.17.0 + prettier: 2.6.2 + +packages: + /@eslint/eslintrc/1.3.0: + resolution: + { + integrity: sha512-UWW0TMTmk2d7hLcWD1/e2g5HDM/HQ3csaLSqXCfqwh4uNDuNqlaKWXmEsL4Cs41Z0KnILNvwbHAah3C2yt06kw==, + } + engines: { node: ^12.22.0 || ^14.17.0 || >=16.0.0 } + dependencies: + ajv: 6.12.6 + debug: 4.3.4 + espree: 9.3.2 + globals: 13.15.0 + ignore: 5.2.0 + import-fresh: 3.3.0 + js-yaml: 4.1.0 + minimatch: 3.1.2 + strip-json-comments: 3.1.1 + transitivePeerDependencies: + - supports-color + dev: true + + /@humanwhocodes/config-array/0.9.5: + resolution: + { + integrity: sha512-ObyMyWxZiCu/yTisA7uzx81s40xR2fD5Cg/2Kq7G02ajkNubJf6BopgDTmDyc3U7sXpNKM8cYOw7s7Tyr+DnCw==, + } + engines: { node: '>=10.10.0' } + dependencies: + '@humanwhocodes/object-schema': 1.2.1 + debug: 4.3.4 + minimatch: 3.1.2 + transitivePeerDependencies: + - supports-color + dev: true + + /@humanwhocodes/object-schema/1.2.1: + resolution: + { + integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==, + } + dev: true + + /@types/node/17.0.40: + resolution: + { + integrity: sha512-UXdBxNGqTMtm7hCwh9HtncFVLrXoqA3oJW30j6XWp5BH/wu3mVeaxo7cq5benFdBw34HB3XDT2TRPI7rXZ+mDg==, + } + dev: false + + /acorn-jsx/5.3.2_acorn@8.7.1: + resolution: + { + integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==, + } + peerDependencies: + acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 + dependencies: + acorn: 8.7.1 + dev: true + + /acorn/8.7.1: + resolution: + { + integrity: sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A==, + } + engines: { node: '>=0.4.0' } + hasBin: true + dev: true + + /ajv/6.12.6: + resolution: + { + integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==, + } + dependencies: + fast-deep-equal: 3.1.3 + fast-json-stable-stringify: 2.1.0 + json-schema-traverse: 0.4.1 + uri-js: 4.4.1 + dev: true + + /ansi-regex/5.0.1: + resolution: + { + integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==, + } + engines: { node: '>=8' } + dev: true + + /ansi-styles/4.3.0: + resolution: + { + integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==, + } + engines: { node: '>=8' } + dependencies: + color-convert: 2.0.1 + dev: true + + /argparse/2.0.1: + resolution: + { + integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==, + } + dev: true + + /balanced-match/1.0.2: + resolution: + { + integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==, + } + dev: true + + /brace-expansion/1.1.11: + resolution: + { + integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==, + } + dependencies: + balanced-match: 1.0.2 + concat-map: 0.0.1 + dev: true + + /callsites/3.1.0: + resolution: + { + integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==, + } + engines: { node: '>=6' } + dev: true + + /chalk/4.1.2: + resolution: + { + integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==, + } + engines: { node: '>=10' } + dependencies: + ansi-styles: 4.3.0 + supports-color: 7.2.0 + dev: true + + /color-convert/2.0.1: + resolution: + { + integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==, + } + engines: { node: '>=7.0.0' } + dependencies: + color-name: 1.1.4 + dev: true + + /color-name/1.1.4: + resolution: + { + integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==, + } + dev: true + + /concat-map/0.0.1: + resolution: { integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= } + dev: true + + /cross-spawn/7.0.3: + resolution: + { + integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==, + } + engines: { node: '>= 8' } + dependencies: + path-key: 3.1.1 + shebang-command: 2.0.0 + which: 2.0.2 + dev: true + + /debug/4.3.4: + resolution: + { + integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==, + } + engines: { node: '>=6.0' } + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + dependencies: + ms: 2.1.2 + dev: true + + /deep-is/0.1.4: + resolution: + { + integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==, + } + dev: true + + /doctrine/3.0.0: + resolution: + { + integrity: sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==, + } + engines: { node: '>=6.0.0' } + dependencies: + esutils: 2.0.3 + dev: true + + /esbuild-android-64/0.14.42: + resolution: + { + integrity: sha512-P4Y36VUtRhK/zivqGVMqhptSrFILAGlYp0Z8r9UQqHJ3iWztRCNWnlBzD9HRx0DbueXikzOiwyOri+ojAFfW6A==, + } + engines: { node: '>=12' } + cpu: [x64] + os: [android] + requiresBuild: true + dev: false + optional: true + + /esbuild-android-arm64/0.14.42: + resolution: + { + integrity: sha512-0cOqCubq+RWScPqvtQdjXG3Czb3AWI2CaKw3HeXry2eoA2rrPr85HF7IpdU26UWdBXgPYtlTN1LUiuXbboROhg==, + } + engines: { node: '>=12' } + cpu: [arm64] + os: [android] + requiresBuild: true + dev: false + optional: true + + /esbuild-darwin-64/0.14.42: + resolution: + { + integrity: sha512-ipiBdCA3ZjYgRfRLdQwP82rTiv/YVMtW36hTvAN5ZKAIfxBOyPXY7Cejp3bMXWgzKD8B6O+zoMzh01GZsCuEIA==, + } + engines: { node: '>=12' } + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: false + optional: true + + /esbuild-darwin-arm64/0.14.42: + resolution: + { + integrity: sha512-bU2tHRqTPOaoH/4m0zYHbFWpiYDmaA0gt90/3BMEFaM0PqVK/a6MA2V/ypV5PO0v8QxN6gH5hBPY4YJ2lopXgA==, + } + engines: { node: '>=12' } + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: false + optional: true + + /esbuild-freebsd-64/0.14.42: + resolution: + { + integrity: sha512-75h1+22Ivy07+QvxHyhVqOdekupiTZVLN1PMwCDonAqyXd8TVNJfIRFrdL8QmSJrOJJ5h8H1I9ETyl2L8LQDaw==, + } + engines: { node: '>=12' } + cpu: [x64] + os: [freebsd] + requiresBuild: true + dev: false + optional: true + + /esbuild-freebsd-arm64/0.14.42: + resolution: + { + integrity: sha512-W6Jebeu5TTDQMJUJVarEzRU9LlKpNkPBbjqSu+GUPTHDCly5zZEQq9uHkmHHl7OKm+mQ2zFySN83nmfCeZCyNA==, + } + engines: { node: '>=12' } + cpu: [arm64] + os: [freebsd] + requiresBuild: true + dev: false + optional: true + + /esbuild-linux-32/0.14.42: + resolution: + { + integrity: sha512-Ooy/Bj+mJ1z4jlWcK5Dl6SlPlCgQB9zg1UrTCeY8XagvuWZ4qGPyYEWGkT94HUsRi2hKsXvcs6ThTOjBaJSMfg==, + } + engines: { node: '>=12' } + cpu: [ia32] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /esbuild-linux-64/0.14.42: + resolution: + { + integrity: sha512-2L0HbzQfbTuemUWfVqNIjOfaTRt9zsvjnme6lnr7/MO9toz/MJ5tZhjqrG6uDWDxhsaHI2/nsDgrv8uEEN2eoA==, + } + engines: { node: '>=12' } + cpu: [x64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /esbuild-linux-arm/0.14.42: + resolution: + { + integrity: sha512-STq69yzCMhdRaWnh29UYrLSr/qaWMm/KqwaRF1pMEK7kDiagaXhSL1zQGXbYv94GuGY/zAwzK98+6idCMUOOCg==, + } + engines: { node: '>=12' } + cpu: [arm] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /esbuild-linux-arm64/0.14.42: + resolution: + { + integrity: sha512-c3Ug3e9JpVr8jAcfbhirtpBauLxzYPpycjWulD71CF6ZSY26tvzmXMJYooQ2YKqDY4e/fPu5K8bm7MiXMnyxuA==, + } + engines: { node: '>=12' } + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /esbuild-linux-mips64le/0.14.42: + resolution: + { + integrity: sha512-QuvpHGbYlkyXWf2cGm51LBCHx6eUakjaSrRpUqhPwjh/uvNUYvLmz2LgPTTPwCqaKt0iwL+OGVL0tXA5aDbAbg==, + } + engines: { node: '>=12' } + cpu: [mips64el] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /esbuild-linux-ppc64le/0.14.42: + resolution: + { + integrity: sha512-8ohIVIWDbDT+i7lCx44YCyIRrOW1MYlks9fxTo0ME2LS/fxxdoJBwHWzaDYhjvf8kNpA+MInZvyOEAGoVDrMHg==, + } + engines: { node: '>=12' } + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /esbuild-linux-riscv64/0.14.42: + resolution: + { + integrity: sha512-DzDqK3TuoXktPyG1Lwx7vhaF49Onv3eR61KwQyxYo4y5UKTpL3NmuarHSIaSVlTFDDpcIajCDwz5/uwKLLgKiQ==, + } + engines: { node: '>=12' } + cpu: [riscv64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /esbuild-linux-s390x/0.14.42: + resolution: + { + integrity: sha512-YFRhPCxl8nb//Wn6SiS5pmtplBi4z9yC2gLrYoYI/tvwuB1jldir9r7JwAGy1Ck4D7sE7wBN9GFtUUX/DLdcEQ==, + } + engines: { node: '>=12' } + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /esbuild-netbsd-64/0.14.42: + resolution: + { + integrity: sha512-QYSD2k+oT9dqB/4eEM9c+7KyNYsIPgzYOSrmfNGDIyJrbT1d+CFVKvnKahDKNJLfOYj8N4MgyFaU9/Ytc6w5Vw==, + } + engines: { node: '>=12' } + cpu: [x64] + os: [netbsd] + requiresBuild: true + dev: false + optional: true + + /esbuild-openbsd-64/0.14.42: + resolution: + { + integrity: sha512-M2meNVIKWsm2HMY7+TU9AxM7ZVwI9havdsw6m/6EzdXysyCFFSoaTQ/Jg03izjCsK17FsVRHqRe26Llj6x0MNA==, + } + engines: { node: '>=12' } + cpu: [x64] + os: [openbsd] + requiresBuild: true + dev: false + optional: true + + /esbuild-sunos-64/0.14.42: + resolution: + { + integrity: sha512-uXV8TAZEw36DkgW8Ak3MpSJs1ofBb3Smkc/6pZ29sCAN1KzCAQzsje4sUwugf+FVicrHvlamCOlFZIXgct+iqQ==, + } + engines: { node: '>=12' } + cpu: [x64] + os: [sunos] + requiresBuild: true + dev: false + optional: true + + /esbuild-windows-32/0.14.42: + resolution: + { + integrity: sha512-4iw/8qWmRICWi9ZOnJJf9sYt6wmtp3hsN4TdI5NqgjfOkBVMxNdM9Vt3626G1Rda9ya2Q0hjQRD9W1o+m6Lz6g==, + } + engines: { node: '>=12' } + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: false + optional: true + + /esbuild-windows-64/0.14.42: + resolution: + { + integrity: sha512-j3cdK+Y3+a5H0wHKmLGTJcq0+/2mMBHPWkItR3vytp/aUGD/ua/t2BLdfBIzbNN9nLCRL9sywCRpOpFMx3CxzA==, + } + engines: { node: '>=12' } + cpu: [x64] + os: [win32] + requiresBuild: true + dev: false + optional: true + + /esbuild-windows-arm64/0.14.42: + resolution: + { + integrity: sha512-+lRAARnF+hf8J0mN27ujO+VbhPbDqJ8rCcJKye4y7YZLV6C4n3pTRThAb388k/zqF5uM0lS5O201u0OqoWSicw==, + } + engines: { node: '>=12' } + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: false + optional: true + + /esbuild/0.14.42: + resolution: + { + integrity: sha512-V0uPZotCEHokJdNqyozH6qsaQXqmZEOiZWrXnds/zaH/0SyrIayRXWRB98CENO73MIZ9T3HBIOsmds5twWtmgw==, + } + engines: { node: '>=12' } + hasBin: true + requiresBuild: true + optionalDependencies: + esbuild-android-64: 0.14.42 + esbuild-android-arm64: 0.14.42 + esbuild-darwin-64: 0.14.42 + esbuild-darwin-arm64: 0.14.42 + esbuild-freebsd-64: 0.14.42 + esbuild-freebsd-arm64: 0.14.42 + esbuild-linux-32: 0.14.42 + esbuild-linux-64: 0.14.42 + esbuild-linux-arm: 0.14.42 + esbuild-linux-arm64: 0.14.42 + esbuild-linux-mips64le: 0.14.42 + esbuild-linux-ppc64le: 0.14.42 + esbuild-linux-riscv64: 0.14.42 + esbuild-linux-s390x: 0.14.42 + esbuild-netbsd-64: 0.14.42 + esbuild-openbsd-64: 0.14.42 + esbuild-sunos-64: 0.14.42 + esbuild-windows-32: 0.14.42 + esbuild-windows-64: 0.14.42 + esbuild-windows-arm64: 0.14.42 + dev: false + + /escape-string-regexp/4.0.0: + resolution: + { + integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==, + } + engines: { node: '>=10' } + dev: true + + /eslint-scope/7.1.1: + resolution: + { + integrity: sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==, + } + engines: { node: ^12.22.0 || ^14.17.0 || >=16.0.0 } + dependencies: + esrecurse: 4.3.0 + estraverse: 5.3.0 + dev: true + + /eslint-utils/3.0.0_eslint@8.17.0: + resolution: + { + integrity: sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==, + } + engines: { node: ^10.0.0 || ^12.0.0 || >= 14.0.0 } + peerDependencies: + eslint: '>=5' + dependencies: + eslint: 8.17.0 + eslint-visitor-keys: 2.1.0 + dev: true + + /eslint-visitor-keys/2.1.0: + resolution: + { + integrity: sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==, + } + engines: { node: '>=10' } + dev: true + + /eslint-visitor-keys/3.3.0: + resolution: + { + integrity: sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==, + } + engines: { node: ^12.22.0 || ^14.17.0 || >=16.0.0 } + dev: true + + /eslint/8.17.0: + resolution: + { + integrity: sha512-gq0m0BTJfci60Fz4nczYxNAlED+sMcihltndR8t9t1evnU/azx53x3t2UHXC/uRjcbvRw/XctpaNygSTcQD+Iw==, + } + engines: { node: ^12.22.0 || ^14.17.0 || >=16.0.0 } + hasBin: true + dependencies: + '@eslint/eslintrc': 1.3.0 + '@humanwhocodes/config-array': 0.9.5 + ajv: 6.12.6 + chalk: 4.1.2 + cross-spawn: 7.0.3 + debug: 4.3.4 + doctrine: 3.0.0 + escape-string-regexp: 4.0.0 + eslint-scope: 7.1.1 + eslint-utils: 3.0.0_eslint@8.17.0 + eslint-visitor-keys: 3.3.0 + espree: 9.3.2 + esquery: 1.4.0 + esutils: 2.0.3 + fast-deep-equal: 3.1.3 + file-entry-cache: 6.0.1 + functional-red-black-tree: 1.0.1 + glob-parent: 6.0.2 + globals: 13.15.0 + ignore: 5.2.0 + import-fresh: 3.3.0 + imurmurhash: 0.1.4 + is-glob: 4.0.3 + js-yaml: 4.1.0 + 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.1 + regexpp: 3.2.0 + strip-ansi: 6.0.1 + strip-json-comments: 3.1.1 + text-table: 0.2.0 + v8-compile-cache: 2.3.0 + transitivePeerDependencies: + - supports-color + dev: true + + /espree/9.3.2: + resolution: + { + integrity: sha512-D211tC7ZwouTIuY5x9XnS0E9sWNChB7IYKX/Xp5eQj3nFXhqmiUDB9q27y76oFl8jTg3pXcQx/bpxMfs3CIZbA==, + } + engines: { node: ^12.22.0 || ^14.17.0 || >=16.0.0 } + dependencies: + acorn: 8.7.1 + acorn-jsx: 5.3.2_acorn@8.7.1 + eslint-visitor-keys: 3.3.0 + dev: true + + /esquery/1.4.0: + resolution: + { + integrity: sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==, + } + engines: { node: '>=0.10' } + dependencies: + estraverse: 5.3.0 + dev: true + + /esrecurse/4.3.0: + resolution: + { + integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==, + } + engines: { node: '>=4.0' } + dependencies: + estraverse: 5.3.0 + dev: true + + /estraverse/5.3.0: + resolution: + { + integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==, + } + engines: { node: '>=4.0' } + dev: true + + /esutils/2.0.3: + resolution: + { + integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==, + } + engines: { node: '>=0.10.0' } + dev: true + + /fast-deep-equal/3.1.3: + resolution: + { + integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==, + } + dev: true + + /fast-json-stable-stringify/2.1.0: + resolution: + { + integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==, + } + dev: true + + /fast-levenshtein/2.0.6: + resolution: + { + integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==, + } + dev: true + + /file-entry-cache/6.0.1: + resolution: + { + integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==, + } + engines: { node: ^10.12.0 || >=12.0.0 } + dependencies: + flat-cache: 3.0.4 + dev: true + + /flat-cache/3.0.4: + resolution: + { + integrity: sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==, + } + engines: { node: ^10.12.0 || >=12.0.0 } + dependencies: + flatted: 3.2.5 + rimraf: 3.0.2 + dev: true + + /flatted/3.2.5: + resolution: + { + integrity: sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==, + } + dev: true + + /fs.realpath/1.0.0: + resolution: + { + integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==, + } + dev: true + + /functional-red-black-tree/1.0.1: + resolution: + { + integrity: sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==, + } + dev: true + + /glob-parent/6.0.2: + resolution: + { + integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==, + } + engines: { node: '>=10.13.0' } + dependencies: + is-glob: 4.0.3 + dev: true + + /glob/7.2.3: + resolution: + { + integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==, + } + dependencies: + fs.realpath: 1.0.0 + inflight: 1.0.6 + inherits: 2.0.4 + minimatch: 3.1.2 + once: 1.4.0 + path-is-absolute: 1.0.1 + dev: true + + /globals/13.15.0: + resolution: + { + integrity: sha512-bpzcOlgDhMG070Av0Vy5Owklpv1I6+j96GhUI7Rh7IzDCKLzboflLrrfqMu8NquDbiR4EOQk7XzJwqVJxicxog==, + } + engines: { node: '>=8' } + dependencies: + type-fest: 0.20.2 + dev: true + + /has-flag/4.0.0: + resolution: + { + integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==, + } + engines: { node: '>=8' } + dev: true + + /ignore/5.2.0: + resolution: + { + integrity: sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==, + } + engines: { node: '>= 4' } + dev: true + + /import-fresh/3.3.0: + resolution: + { + integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==, + } + engines: { node: '>=6' } + dependencies: + parent-module: 1.0.1 + resolve-from: 4.0.0 + dev: true + + /imurmurhash/0.1.4: + resolution: + { + integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==, + } + engines: { node: '>=0.8.19' } + dev: true + + /inflight/1.0.6: + resolution: + { + integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==, + } + dependencies: + once: 1.4.0 + wrappy: 1.0.2 + dev: true + + /inherits/2.0.4: + resolution: + { + integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==, + } + dev: true + + /is-extglob/2.1.1: + resolution: + { + integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==, + } + engines: { node: '>=0.10.0' } + dev: true + + /is-glob/4.0.3: + resolution: + { + integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==, + } + engines: { node: '>=0.10.0' } + dependencies: + is-extglob: 2.1.1 + dev: true + + /isexe/2.0.0: + resolution: + { + integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==, + } + dev: true + + /js-yaml/4.1.0: + resolution: + { + integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==, + } + hasBin: true + dependencies: + argparse: 2.0.1 + dev: true + + /json-schema-traverse/0.4.1: + resolution: + { + integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==, + } + dev: true + + /json-stable-stringify-without-jsonify/1.0.1: + resolution: + { + integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==, + } + dev: true + + /levn/0.4.1: + resolution: + { + integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==, + } + engines: { node: '>= 0.8.0' } + dependencies: + prelude-ls: 1.2.1 + type-check: 0.4.0 + dev: true + + /lodash.merge/4.6.2: + resolution: + { + integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==, + } + dev: true + + /minimatch/3.1.2: + resolution: + { + integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==, + } + dependencies: + brace-expansion: 1.1.11 + dev: true + + /ms/2.1.2: + resolution: + { + integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==, + } + dev: true + + /natural-compare/1.4.0: + resolution: + { + integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==, + } + dev: true + + /once/1.4.0: + resolution: + { + integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==, + } + dependencies: + wrappy: 1.0.2 + dev: true + + /optionator/0.9.1: + resolution: + { + integrity: sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==, + } + engines: { node: '>= 0.8.0' } + dependencies: + deep-is: 0.1.4 + fast-levenshtein: 2.0.6 + levn: 0.4.1 + prelude-ls: 1.2.1 + type-check: 0.4.0 + word-wrap: 1.2.3 + dev: true + + /parent-module/1.0.1: + resolution: + { + integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==, + } + engines: { node: '>=6' } + dependencies: + callsites: 3.1.0 + dev: true + + /path-is-absolute/1.0.1: + resolution: + { + integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==, + } + engines: { node: '>=0.10.0' } + dev: true + + /path-key/3.1.1: + resolution: + { + integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==, + } + engines: { node: '>=8' } + dev: true + + /prelude-ls/1.2.1: + resolution: + { + integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==, + } + engines: { node: '>= 0.8.0' } + dev: true + + /prettier/2.6.2: + resolution: + { + integrity: sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==, + } + engines: { node: '>=10.13.0' } + hasBin: true + dev: true + + /punycode/2.1.1: + resolution: + { + integrity: sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==, + } + engines: { node: '>=6' } + dev: true + + /regexpp/3.2.0: + resolution: + { + integrity: sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==, + } + engines: { node: '>=8' } + dev: true + + /resolve-from/4.0.0: + resolution: + { + integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==, + } + engines: { node: '>=4' } + dev: true + + /rimraf/3.0.2: + resolution: + { + integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==, + } + hasBin: true + dependencies: + glob: 7.2.3 + dev: true + + /shebang-command/2.0.0: + resolution: + { + integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==, + } + engines: { node: '>=8' } + dependencies: + shebang-regex: 3.0.0 + dev: true + + /shebang-regex/3.0.0: + resolution: + { + integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==, + } + engines: { node: '>=8' } + dev: true + + /strip-ansi/6.0.1: + resolution: + { + integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==, + } + engines: { node: '>=8' } + dependencies: + ansi-regex: 5.0.1 + dev: true + + /strip-json-comments/3.1.1: + resolution: + { + integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==, + } + engines: { node: '>=8' } + dev: true + + /supports-color/7.2.0: + resolution: + { + integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==, + } + engines: { node: '>=8' } + dependencies: + has-flag: 4.0.0 + dev: true + + /text-table/0.2.0: + resolution: { integrity: sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= } + dev: true + + /type-check/0.4.0: + resolution: + { + integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==, + } + engines: { node: '>= 0.8.0' } + dependencies: + prelude-ls: 1.2.1 + dev: true + + /type-fest/0.20.2: + resolution: + { + integrity: sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==, + } + engines: { node: '>=10' } + dev: true + + /uri-js/4.4.1: + resolution: + { + integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==, + } + dependencies: + punycode: 2.1.1 + dev: true + + /v8-compile-cache/2.3.0: + resolution: + { + integrity: sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==, + } + dev: true + + /which/2.0.2: + resolution: + { + integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==, + } + engines: { node: '>= 8' } + hasBin: true + dependencies: + isexe: 2.0.0 + dev: true + + /word-wrap/1.2.3: + resolution: + { + integrity: sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==, + } + engines: { node: '>=0.10.0' } + dev: true + + /wrappy/1.0.2: + resolution: { integrity: sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= } + dev: true diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..a49d8d1 --- /dev/null +++ b/readme.md @@ -0,0 +1,25 @@ +# browser-scripts-builder + +builder for [browser-scripts](https://git.zomo.dev/zomo/browser-scripts) + +## Source File Structure + +```text +Root +├─── +└───scripts + └───[each script folder] + ├─── + ├─── + ├───main.ts + └───meta.json (optional) +``` + +## Dist File Structure + +```text +Root +├─── +└───dist + └───[each script folder].user.js +``` diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..c15af1f --- /dev/null +++ b/src/main.ts @@ -0,0 +1,64 @@ +import { build } from 'esbuild' +import { + lstatSync, + readdirSync, + readFileSync, + unlinkSync, + writeFileSync, +} from 'fs' +import { DistBase, DistPath, ScriptBase, ScriptPath } from './paths' +import readMeta from './readmeta' + +async function compileProject(name: string) { + //read meta file + let [metaJson, metaString] = readMeta(name) + let outPath = DistPath(name) + + await build({ + entryPoints: [ScriptPath(name).main], + outfile: outPath, + + target: 'esnext', + platform: 'node', + format: 'esm', + + bundle: true, + minify: false, + + define: { + UserScriptName: `'${metaJson.name}'`, + UserScriptNamespace: `'${metaJson.namespace}'`, + UserScriptVersion: `'${metaJson.version}'`, + + UserScriptDownloadURL: `'${metaJson.downloadURL}'`, + UserScriptSupportURL: `'${metaJson.supportURL}'`, + UserScriptHomepageURL: `'${metaJson.homepageURL}'`, + }, + }) + + //add UserScript header + let content = readFileSync(outPath).toString() + + writeFileSync(outPath, metaString + content) +} + +if (!lstatSync('package.json').isFile()) { + console.error('package.json not found, unwilling to run') + process.exit(1) +} + +//delete compiled scripts +readdirSync(DistBase).forEach(file => unlinkSync(`${DistBase}/${file}`)) + +//compile scripts +readdirSync(ScriptBase).forEach(name => { + let path = ScriptPath(name) + + if ( + !name.endsWith('_') && + lstatSync(path.dir).isDirectory() && + lstatSync(path.main).isFile() + ) { + compileProject(name) + } +}) diff --git a/src/paths.ts b/src/paths.ts new file mode 100644 index 0000000..5a8df67 --- /dev/null +++ b/src/paths.ts @@ -0,0 +1,16 @@ +export const BaseUrl = `https://git.zomo.dev/zomo/browser-scripts` +export const RemoteBranch = 'main' +export const ScriptBase = 'scripts' +export const DistBase = 'dist' + +export const SupportUrl = `${BaseUrl}/issues` +export const FileUrl = (name: string) => + `${BaseUrl}/raw/branch/${RemoteBranch}/${DistBase}/${name}.user.js` + +export const ScriptPath = (name: string) => ({ + dir: `${ScriptBase}/${name}`, + main: `${ScriptBase}/${name}/main.ts`, + meta: `${ScriptBase}/${name}/meta.json`, +}) + +export const DistPath = (name: string) => `${DistBase}/${name}.user.js` diff --git a/src/readmeta.ts b/src/readmeta.ts new file mode 100644 index 0000000..3af1320 --- /dev/null +++ b/src/readmeta.ts @@ -0,0 +1,93 @@ +import { lstatSync, readFileSync } from 'fs' +import { BaseUrl, FileUrl, ScriptPath, SupportUrl } from './paths' +import { UserDataMeta, UserDataMetaFull, UserDataMetaPartial } from './types' + +export default function (name: string): [UserDataMetaFull, string] { + var meta: UserDataMetaFull = { + name: name, + namespace: 'zomo.dev', + match: '', + excludematch: '', + version: '0.0.0', + description: '', + icon: '', + require: '', + resource: '', + runat: '', + noframes: false, + grant: '', + injectinto: '', + downloadURL: FileUrl(name), + supportURL: SupportUrl, + homepageURL: BaseUrl, + unwrap: false, + } + + let metaPath = ScriptPath(name).meta + + if (lstatSync(metaPath).isFile()) { + try { + let args: UserDataMetaPartial = JSON.parse( + readFileSync(metaPath).toString() + ) + + let key: keyof UserDataMeta + for (key in meta) { + let val = args[key] + + //cases where the value is empty + if (val === undefined) continue + if (val === false) continue + if (val === '') + continue + + //:) + ;(meta[key] as any) = val + } + } catch (e) { + console.log(e) + } + } else { + console.log(`${metaPath} not found, using default metadata`) + } + + const keyConversion = { + injectinto: 'inject-into', + excludematch: 'exclude-match', + } + + return [ + meta, + `// ==UserScript== +${(Object.keys(meta) as Array) + .filter(key => { + let val = meta[key] + if (val === undefined) return false + if (val === false) return false + if (val === '') return false + return true + }) + .map(key => { + let val = meta[key] + let key_str = + key in keyConversion + ? keyConversion[key as keyof typeof keyConversion] + : key + key_str = key_str.padStart(12, ' ') + + if (typeof val === 'boolean') { + if (val) return `// @${key_str}` + } else if (typeof val === 'string') { + return `// @${key_str} ${val}` + } else if (Array.isArray(val)) { + return val.map(v => `// @${key_str} ${v}`).join('\n') + } + + return '' + }) + .filter(l => l.length) + .join('\n')} +// ==/UserScript== +`, + ] +} diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 0000000..0e71c58 --- /dev/null +++ b/src/types.ts @@ -0,0 +1,42 @@ +export interface UserDataMetaPartial { + name?: string + namespace?: string + match?: string | string[] + excludematch?: string | string[] + version?: string + description?: string + icon?: string + require?: string | string[] + resource?: string | string[] + runat?: 'document-start' | 'document-end' | 'document-idle' | '' + noframes?: boolean + grant?: string | string[] + injectinto?: 'page' | 'content' | 'auto' | '' + downloadURL?: string + supportURL?: string + homepageURL?: string + unwrap?: boolean +} + +export interface UserDataMeta extends UserDataMetaPartial { + name: string + namespace: string + version: string + downloadURL: string + supportURL: string + homepageURL: string +} + +export interface UserDataMetaFull extends UserDataMeta { + match: string | string[] + excludematch: string | string[] + description: string + icon: string + require: string | string[] + resource: string | string[] + runat: 'document-start' | 'document-end' | 'document-idle' | '' + noframes: boolean + grant: string | string[] + injectinto: 'page' | 'content' | 'auto' | '' + unwrap: boolean +} diff --git a/test/test.mjs b/test/test.mjs new file mode 100644 index 0000000..e69de29 diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..1d5d0c4 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "es2020", + "module": "es2020", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "skipLibCheck": true, + "strict": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "sourceMap": true, + "rootDir": "./src", + "outDir": "./lib", + "moduleResolution": "node" + } +} diff --git a/types/compiler_vars.d.ts b/types/compiler_vars.d.ts new file mode 100644 index 0000000..162462b --- /dev/null +++ b/types/compiler_vars.d.ts @@ -0,0 +1,6 @@ +declare const UserScriptName: string +declare const UserScriptNamespace: string +declare const UserScriptVersion: string +declare const UserScriptDownloadURL: string +declare const UserScriptSupportURL: string +declare const UserScriptHomepageURL: string