chore: bundle vendor code (#9016)
This PR removes the manual vendoring process. Third party code can now be updated using the typical NPM pipeline with types/code bundling done through Rollup.
This commit is contained in:
parent
d06a905540
commit
f8de7b1273
@ -103,7 +103,7 @@ module.exports = {
|
||||
{
|
||||
name: 'mitt',
|
||||
message:
|
||||
'Import Mitt from the vendored location: vendor/mitt/src/index.js',
|
||||
'Import Mitt from the vendored location: vendor/mitt/index.js',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -42,6 +42,5 @@ CHANGELOG.md
|
||||
package-lock.json
|
||||
package.json
|
||||
test/assets/
|
||||
vendor/
|
||||
docs/
|
||||
versioned_*/
|
||||
|
@ -7,5 +7,5 @@ sidebar_label: EventType
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
export declare type EventType = string | symbol;
|
||||
declare type EventType = string | symbol;
|
||||
```
|
||||
|
@ -7,5 +7,5 @@ sidebar_label: Handler
|
||||
**Signature:**
|
||||
|
||||
```typescript
|
||||
export declare type Handler<T = any> = (event?: T) => void;
|
||||
declare type Handler<T = any> = (event?: T) => void;
|
||||
```
|
||||
|
213
package-lock.json
generated
213
package-lock.json
generated
@ -68,12 +68,16 @@
|
||||
"jpeg-js": "0.4.4",
|
||||
"mime": "3.0.0",
|
||||
"minimist": "1.2.6",
|
||||
"mitt": "^2.1.0",
|
||||
"mocha": "10.0.0",
|
||||
"ncp": "2.0.0",
|
||||
"npm-run-all": "4.1.5",
|
||||
"pixelmatch": "5.3.0",
|
||||
"pngjs": "6.0.0",
|
||||
"prettier": "2.7.1",
|
||||
"rollup": "^2.79.1",
|
||||
"rollup-plugin-dts": "^4.2.2",
|
||||
"rollup-plugin-node-resolve": "^5.2.0",
|
||||
"semver": "7.3.7",
|
||||
"sinon": "14.0.0",
|
||||
"source-map-support": "0.5.21",
|
||||
@ -1133,6 +1137,15 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/resolve": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-0.0.8.tgz",
|
||||
"integrity": "sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/rimraf": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/rimraf/-/rimraf-3.0.2.tgz",
|
||||
@ -1743,6 +1756,18 @@
|
||||
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/builtin-modules": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz",
|
||||
"integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/c8": {
|
||||
"version": "7.12.0",
|
||||
"resolved": "https://registry.npmjs.org/c8/-/c8-7.12.0.tgz",
|
||||
@ -3413,6 +3438,12 @@
|
||||
"node": ">=4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/estree-walker": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz",
|
||||
"integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/esutils": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
|
||||
@ -4429,6 +4460,12 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/is-module": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz",
|
||||
"integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/is-negative-zero": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz",
|
||||
@ -4982,6 +5019,18 @@
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/magic-string": {
|
||||
"version": "0.26.4",
|
||||
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.26.4.tgz",
|
||||
"integrity": "sha512-e5uXtVJ22aEpK9u1+eQf0fSxHeqwyV19K+uGnlROCxUhzwRip9tBsaMViK/0vC3viyPd5Gtucp3UmEp/Q2cPTQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"sourcemap-codec": "^1.4.8"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/make-dir": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz",
|
||||
@ -5165,6 +5214,12 @@
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/mitt": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/mitt/-/mitt-2.1.0.tgz",
|
||||
"integrity": "sha512-ILj2TpLiysu2wkBbWjAmww7TkZb65aiQO+DkVdUTBpBXq+MHYiETENkKFMtsJZX1Lf4pe4QOrTSjIfUwN5lRdg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/mkdirp-classic": {
|
||||
"version": "0.5.3",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz",
|
||||
@ -6436,6 +6491,69 @@
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/rollup": {
|
||||
"version": "2.79.1",
|
||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.1.tgz",
|
||||
"integrity": "sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"rollup": "dist/bin/rollup"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "~2.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/rollup-plugin-dts": {
|
||||
"version": "4.2.2",
|
||||
"resolved": "https://registry.npmjs.org/rollup-plugin-dts/-/rollup-plugin-dts-4.2.2.tgz",
|
||||
"integrity": "sha512-A3g6Rogyko/PXeKoUlkjxkP++8UDVpgA7C+Tdl77Xj4fgEaIjPSnxRmR53EzvoYy97VMVwLAOcWJudaVAuxneQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"magic-string": "^0.26.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=v12.22.11"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/Swatinem"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@babel/code-frame": "^7.16.7"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"rollup": "^2.55",
|
||||
"typescript": "^4.1"
|
||||
}
|
||||
},
|
||||
"node_modules/rollup-plugin-node-resolve": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-5.2.0.tgz",
|
||||
"integrity": "sha512-jUlyaDXts7TW2CqQ4GaO5VJ4PwwaV8VUGA7+km3n6k6xtOEacf61u0VXwN80phY/evMcaS+9eIeJ9MOyDxt5Zw==",
|
||||
"deprecated": "This package has been deprecated and is no longer maintained. Please use @rollup/plugin-node-resolve.",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/resolve": "0.0.8",
|
||||
"builtin-modules": "^3.1.0",
|
||||
"is-module": "^1.0.0",
|
||||
"resolve": "^1.11.1",
|
||||
"rollup-pluginutils": "^2.8.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"rollup": ">=1.11.0"
|
||||
}
|
||||
},
|
||||
"node_modules/rollup-pluginutils": {
|
||||
"version": "2.8.2",
|
||||
"resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz",
|
||||
"integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"estree-walker": "^0.6.1"
|
||||
}
|
||||
},
|
||||
"node_modules/run-async": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz",
|
||||
@ -6609,6 +6727,12 @@
|
||||
"source-map": "^0.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/sourcemap-codec": {
|
||||
"version": "1.4.8",
|
||||
"resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz",
|
||||
"integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/spdx-correct": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz",
|
||||
@ -8440,6 +8564,15 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/resolve": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-0.0.8.tgz",
|
||||
"integrity": "sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/rimraf": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/rimraf/-/rimraf-3.0.2.tgz",
|
||||
@ -8863,6 +8996,12 @@
|
||||
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
|
||||
"dev": true
|
||||
},
|
||||
"builtin-modules": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz",
|
||||
"integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==",
|
||||
"dev": true
|
||||
},
|
||||
"c8": {
|
||||
"version": "7.12.0",
|
||||
"resolved": "https://registry.npmjs.org/c8/-/c8-7.12.0.tgz",
|
||||
@ -10022,6 +10161,12 @@
|
||||
"integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==",
|
||||
"dev": true
|
||||
},
|
||||
"estree-walker": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz",
|
||||
"integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==",
|
||||
"dev": true
|
||||
},
|
||||
"esutils": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
|
||||
@ -10755,6 +10900,12 @@
|
||||
"is-extglob": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"is-module": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz",
|
||||
"integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==",
|
||||
"dev": true
|
||||
},
|
||||
"is-negative-zero": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz",
|
||||
@ -11179,6 +11330,15 @@
|
||||
"yallist": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"magic-string": {
|
||||
"version": "0.26.4",
|
||||
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.26.4.tgz",
|
||||
"integrity": "sha512-e5uXtVJ22aEpK9u1+eQf0fSxHeqwyV19K+uGnlROCxUhzwRip9tBsaMViK/0vC3viyPd5Gtucp3UmEp/Q2cPTQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"sourcemap-codec": "^1.4.8"
|
||||
}
|
||||
},
|
||||
"make-dir": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz",
|
||||
@ -11312,6 +11472,12 @@
|
||||
"kind-of": "^6.0.3"
|
||||
}
|
||||
},
|
||||
"mitt": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/mitt/-/mitt-2.1.0.tgz",
|
||||
"integrity": "sha512-ILj2TpLiysu2wkBbWjAmww7TkZb65aiQO+DkVdUTBpBXq+MHYiETENkKFMtsJZX1Lf4pe4QOrTSjIfUwN5lRdg==",
|
||||
"dev": true
|
||||
},
|
||||
"mkdirp-classic": {
|
||||
"version": "0.5.3",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz",
|
||||
@ -12251,6 +12417,47 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"rollup": {
|
||||
"version": "2.79.1",
|
||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.1.tgz",
|
||||
"integrity": "sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"fsevents": "~2.3.2"
|
||||
}
|
||||
},
|
||||
"rollup-plugin-dts": {
|
||||
"version": "4.2.2",
|
||||
"resolved": "https://registry.npmjs.org/rollup-plugin-dts/-/rollup-plugin-dts-4.2.2.tgz",
|
||||
"integrity": "sha512-A3g6Rogyko/PXeKoUlkjxkP++8UDVpgA7C+Tdl77Xj4fgEaIjPSnxRmR53EzvoYy97VMVwLAOcWJudaVAuxneQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/code-frame": "^7.16.7",
|
||||
"magic-string": "^0.26.1"
|
||||
}
|
||||
},
|
||||
"rollup-plugin-node-resolve": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-5.2.0.tgz",
|
||||
"integrity": "sha512-jUlyaDXts7TW2CqQ4GaO5VJ4PwwaV8VUGA7+km3n6k6xtOEacf61u0VXwN80phY/evMcaS+9eIeJ9MOyDxt5Zw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/resolve": "0.0.8",
|
||||
"builtin-modules": "^3.1.0",
|
||||
"is-module": "^1.0.0",
|
||||
"resolve": "^1.11.1",
|
||||
"rollup-pluginutils": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"rollup-pluginutils": {
|
||||
"version": "2.8.2",
|
||||
"resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz",
|
||||
"integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"estree-walker": "^0.6.1"
|
||||
}
|
||||
},
|
||||
"run-async": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz",
|
||||
@ -12379,6 +12586,12 @@
|
||||
"source-map": "^0.6.0"
|
||||
}
|
||||
},
|
||||
"sourcemap-codec": {
|
||||
"version": "1.4.8",
|
||||
"resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz",
|
||||
"integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==",
|
||||
"dev": true
|
||||
},
|
||||
"spdx-correct": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz",
|
||||
|
11
package.json
11
package.json
@ -57,10 +57,11 @@
|
||||
"check:protocol-revision": "tsx scripts/ensure-correct-devtools-protocol-package",
|
||||
"check:pinned-deps": "tsx scripts/ensure-pinned-deps",
|
||||
"build": "npm run build:prod",
|
||||
"build:dev": "run-s generate:sources build:tsc:dev generate:artifacts",
|
||||
"build:prod": "run-s generate:sources build:tsc:prod generate:artifacts",
|
||||
"build:dev": "run-s generate:sources build:tsc:dev && run-p bundle:vendor generate:artifacts",
|
||||
"build:prod": "run-s generate:sources build:tsc:prod && run-p bundle:vendor generate:artifacts",
|
||||
"build:tsc:dev": "tsc -b test",
|
||||
"build:tsc:prod": "tsc -b tsconfig.lib.json"
|
||||
"build:tsc:prod": "tsc -b tsconfig.lib.json",
|
||||
"bundle:vendor": "rollup --config rollup.vendor.config.js"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
@ -129,12 +130,16 @@
|
||||
"jpeg-js": "0.4.4",
|
||||
"mime": "3.0.0",
|
||||
"minimist": "1.2.6",
|
||||
"mitt": "2.1.0",
|
||||
"mocha": "10.0.0",
|
||||
"ncp": "2.0.0",
|
||||
"npm-run-all": "4.1.5",
|
||||
"pixelmatch": "5.3.0",
|
||||
"pngjs": "6.0.0",
|
||||
"prettier": "2.7.1",
|
||||
"rollup": "2.79.1",
|
||||
"rollup-plugin-dts": "4.2.2",
|
||||
"rollup-plugin-node-resolve": "5.2.0",
|
||||
"semver": "7.3.7",
|
||||
"sinon": "14.0.0",
|
||||
"source-map-support": "0.5.21",
|
||||
|
39
rollup.vendor.config.js
Normal file
39
rollup.vendor.config.js
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Copyright 2022 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import path from 'path';
|
||||
import dts from 'rollup-plugin-dts';
|
||||
import resolve from 'rollup-plugin-node-resolve';
|
||||
import glob from 'glob';
|
||||
|
||||
export default ['cjs', 'esm'].flatMap(outputType => {
|
||||
const configs = [];
|
||||
const vendorPath = path.resolve(__dirname, `lib/${outputType}/vendor`);
|
||||
for (const jsFile of glob.sync(path.join(vendorPath, '**/*.js'))) {
|
||||
configs.push({
|
||||
input: jsFile,
|
||||
output: {file: jsFile, exports: 'auto', format: outputType},
|
||||
plugins: [resolve()],
|
||||
});
|
||||
}
|
||||
for (const typesFile of glob.sync(path.join(vendorPath, '**/*.d.ts'))) {
|
||||
configs.push({
|
||||
input: typesFile,
|
||||
output: {file: typesFile, format: outputType},
|
||||
plugins: [dts({respectExternal: true})],
|
||||
});
|
||||
}
|
||||
return configs;
|
||||
});
|
@ -14,11 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import mitt, {
|
||||
Emitter,
|
||||
EventType,
|
||||
Handler,
|
||||
} from '../../vendor/mitt/src/index.js';
|
||||
import mitt, {Emitter, EventType, Handler} from '../../vendor/mitt/index.js';
|
||||
|
||||
/**
|
||||
* @public
|
||||
|
@ -6,7 +6,7 @@
|
||||
"module": "CommonJS"
|
||||
},
|
||||
"references": [
|
||||
{"path": "../vendor/tsconfig.cjs.json"},
|
||||
{"path": "../compat/cjs/tsconfig.json"}
|
||||
{"path": "../compat/cjs/tsconfig.json"},
|
||||
{"path": "../vendor/tsconfig.json"}
|
||||
]
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
"module": "esnext"
|
||||
},
|
||||
"references": [
|
||||
{"path": "../vendor/tsconfig.esm.json"},
|
||||
{"path": "../compat/esm/tsconfig.json"}
|
||||
{"path": "../compat/esm/tsconfig.json"},
|
||||
{"path": "../vendor/tsconfig.cjs.json"}
|
||||
]
|
||||
}
|
||||
|
33
vendor/README.md
vendored
33
vendor/README.md
vendored
@ -1,13 +1,28 @@
|
||||
# Vendoring third party dependencies
|
||||
# `vendor`
|
||||
|
||||
Because we are working towards an agnostic Puppeteer that can run in any environment (see [#6125](https://github.com/puppeteer/puppeteer/issues/6125)) we cannot import common dependencies in a way that relies on Node's resolution to find them. For example, `import mitt from 'mitt'` works fine in Node, but in an ESM build running in the browser, the browser has no idea where to find `'mitt'`.
|
||||
This folder contains code that interacts with third party node modules that will
|
||||
be vendored with puppeteer during publishing.
|
||||
|
||||
Therefore we put all common dependencies into this directory, `vendor`. This means there are extra criteria for these dependencies; ideally they will not depend on any other modules. If they do, we should consider an alternative way of managing our dependencies.
|
||||
## Why not `node_modules`?
|
||||
|
||||
The process for updating a vendored dependency is:
|
||||
Because we are working towards an agnostic Puppeteer that can run in any
|
||||
environment (see [#6125](https://github.com/puppeteer/puppeteer/issues/6125)) we
|
||||
cannot import common dependencies in a way that relies on Node's resolution to
|
||||
find them. For example, `import mitt from 'mitt'` works fine in Node, but in an
|
||||
ESM build running in an environment without module resolution such as the
|
||||
browser, `'mitt'` would not make sense.
|
||||
|
||||
1. `npm install {DEP NAME HERE}`
|
||||
2. `cp -r node_modules/DEP vendor`
|
||||
3. Update `eslintrc.js` to forbid importing DEP directly (see the `Mitt` rule already defined in there).
|
||||
4. Use the new DEP, and run `npm run build && npm run build:dev` to check everything compiles successfully.
|
||||
5. If the dep ships as compiled JS, you may need to disable TypeScript checking the file. Add an entry to the `excludes` property of the TSConfig files in `vendor`. (again, see the entry that's already there for Mitt as an example). Don't forget to update both the ESM and CJS config files.
|
||||
The process for installing/using a vendored dependency is a two-step process:
|
||||
|
||||
1. Create a folder named after the package. See the `node_modules` folder for
|
||||
inspiration.
|
||||
2. Create an entrypoint that exports needed imports from the package. For
|
||||
example, `index.ts` may contain
|
||||
|
||||
```ts
|
||||
export * from 'your-package';
|
||||
export {default as default} from 'your-package';
|
||||
```
|
||||
|
||||
Now if you need to import from the dependency, you need to import relative to
|
||||
this directory rather than the package name itself.
|
||||
|
179
vendor/mitt/README.md
vendored
179
vendor/mitt/README.md
vendored
@ -1,179 +0,0 @@
|
||||
<p align="center">
|
||||
<img src="https://i.imgur.com/BqsX9NT.png" width="300" height="300" alt="mitt">
|
||||
<br>
|
||||
<a href="https://www.npmjs.org/package/mitt"><img src="https://img.shields.io/npm/v/mitt.svg" alt="npm"></a>
|
||||
<img src="https://github.com/developit/mitt/workflows/CI/badge.svg" alt="build status">
|
||||
<a href="https://unpkg.com/mitt/dist/mitt.js"><img src="https://img.badgesize.io/https://unpkg.com/mitt/dist/mitt.js?compression=gzip" alt="gzip size"></a>
|
||||
</p>
|
||||
|
||||
# Mitt
|
||||
|
||||
> Tiny 200b functional event emitter / pubsub.
|
||||
|
||||
- **Microscopic:** weighs less than 200 bytes gzipped
|
||||
- **Useful:** a wildcard `"*"` event type listens to all events
|
||||
- **Familiar:** same names & ideas as [Node's EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter)
|
||||
- **Functional:** methods don't rely on `this`
|
||||
- **Great Name:** somehow [mitt](https://npm.im/mitt) wasn't taken
|
||||
|
||||
Mitt was made for the browser, but works in any JavaScript runtime. It has no dependencies and supports IE9+.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Install](#install)
|
||||
- [Usage](#usage)
|
||||
- [Examples & Demos](#examples--demos)
|
||||
- [API](#api)
|
||||
- [Contribute](#contribute)
|
||||
- [License](#license)
|
||||
|
||||
## Install
|
||||
|
||||
This project uses [node](http://nodejs.org) and [npm](https://npmjs.com). Go check them out if you don't have them locally installed.
|
||||
|
||||
```sh
|
||||
$ npm install --save mitt
|
||||
```
|
||||
|
||||
Then with a module bundler like [rollup](http://rollupjs.org/) or [webpack](https://webpack.js.org/), use as you would anything else:
|
||||
|
||||
```javascript
|
||||
// using ES6 modules
|
||||
import mitt from 'mitt'
|
||||
|
||||
// using CommonJS modules
|
||||
var mitt = require('mitt')
|
||||
```
|
||||
|
||||
The [UMD](https://github.com/umdjs/umd) build is also available on [unpkg](https://unpkg.com):
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/mitt/dist/mitt.umd.js"></script>
|
||||
```
|
||||
|
||||
You can find the library on `window.mitt`.
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import mitt from 'mitt'
|
||||
|
||||
const emitter = mitt()
|
||||
|
||||
// listen to an event
|
||||
emitter.on('foo', e => console.log('foo', e) )
|
||||
|
||||
// listen to all events
|
||||
emitter.on('*', (type, e) => console.log(type, e) )
|
||||
|
||||
// fire an event
|
||||
emitter.emit('foo', { a: 'b' })
|
||||
|
||||
// clearing all events
|
||||
emitter.all.clear()
|
||||
|
||||
// working with handler references:
|
||||
function onFoo() {}
|
||||
emitter.on('foo', onFoo) // listen
|
||||
emitter.off('foo', onFoo) // unlisten
|
||||
```
|
||||
|
||||
### Typescript
|
||||
|
||||
```ts
|
||||
import mitt from 'mitt';
|
||||
const emitter: mitt.Emitter = mitt();
|
||||
```
|
||||
|
||||
## Examples & Demos
|
||||
|
||||
<a href="http://codepen.io/developit/pen/rjMEwW?editors=0110">
|
||||
<b>Preact + Mitt Codepen Demo</b>
|
||||
<br>
|
||||
<img src="https://i.imgur.com/CjBgOfJ.png" width="278" alt="preact + mitt preview">
|
||||
</a>
|
||||
|
||||
* * *
|
||||
|
||||
## API
|
||||
|
||||
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
||||
|
||||
#### Table of Contents
|
||||
|
||||
- [mitt](#mitt)
|
||||
- [all](#all)
|
||||
- [on](#on)
|
||||
- [Parameters](#parameters)
|
||||
- [off](#off)
|
||||
- [Parameters](#parameters-1)
|
||||
- [emit](#emit)
|
||||
- [Parameters](#parameters-2)
|
||||
|
||||
### mitt
|
||||
|
||||
Mitt: Tiny (~200b) functional event emitter / pubsub.
|
||||
|
||||
Returns **Mitt**
|
||||
|
||||
### all
|
||||
|
||||
A Map of event names to registered handler functions.
|
||||
|
||||
### on
|
||||
|
||||
Register an event handler for the given type.
|
||||
|
||||
#### Parameters
|
||||
|
||||
- `type` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [symbol](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol))** Type of event to listen for, or `"*"` for all events
|
||||
- `handler` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Function to call in response to given event
|
||||
|
||||
### off
|
||||
|
||||
Remove an event handler for the given type.
|
||||
|
||||
#### Parameters
|
||||
|
||||
- `type` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [symbol](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol))** Type of event to unregister `handler` from, or `"*"`
|
||||
- `handler` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Handler function to remove
|
||||
|
||||
### emit
|
||||
|
||||
Invoke all handlers for the given type.
|
||||
If present, `"*"` handlers are invoked after type-matched handlers.
|
||||
|
||||
Note: Manually firing "\*" handlers is not supported.
|
||||
|
||||
#### Parameters
|
||||
|
||||
- `type` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [symbol](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol))** The event type to invoke
|
||||
- `evt` **Any?** Any value (object is recommended and powerful), passed to each handler
|
||||
|
||||
## Contribute
|
||||
|
||||
First off, thanks for taking the time to contribute!
|
||||
Now, take a moment to be sure your contributions make sense to everyone else.
|
||||
|
||||
### Reporting Issues
|
||||
|
||||
Found a problem? Want a new feature? First of all see if your issue or idea has [already been reported](../../issues).
|
||||
If don't, just open a [new clear and descriptive issue](../../issues/new).
|
||||
|
||||
### Submitting pull requests
|
||||
|
||||
Pull requests are the greatest contributions, so be sure they are focused in scope, and do avoid unrelated commits.
|
||||
|
||||
- Fork it!
|
||||
- Clone your fork: `git clone https://github.com/<your-username>/mitt`
|
||||
- Navigate to the newly cloned directory: `cd mitt`
|
||||
- Create a new branch for the new feature: `git checkout -b my-new-feature`
|
||||
- Install the tools necessary for development: `npm install`
|
||||
- Make your changes.
|
||||
- Commit your changes: `git commit -am 'Add some feature'`
|
||||
- Push to the branch: `git push origin my-new-feature`
|
||||
- Submit a pull request with full remarks documenting your changes.
|
||||
|
||||
## License
|
||||
|
||||
[MIT License](https://opensource.org/licenses/MIT) © [Jason Miller](https://jasonformat.com/)
|
2
vendor/mitt/dist/mitt.es.js
vendored
2
vendor/mitt/dist/mitt.es.js
vendored
@ -1,2 +0,0 @@
|
||||
export default function(n){return{all:n=n||new Map,on:function(t,e){var i=n.get(t);i&&i.push(e)||n.set(t,[e])},off:function(t,e){var i=n.get(t);i&&i.splice(i.indexOf(e)>>>0,1)},emit:function(t,e){(n.get(t)||[]).slice().map(function(n){n(e)}),(n.get("*")||[]).slice().map(function(n){n(t,e)})}}}
|
||||
//# sourceMappingURL=mitt.es.js.map
|
1
vendor/mitt/dist/mitt.es.js.map
vendored
1
vendor/mitt/dist/mitt.es.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"mitt.es.js","sources":["../src/index.ts"],"sourcesContent":["export type EventType = string | symbol;\n\n// An event handler can take an optional event argument\n// and should not return a value\nexport type Handler<T = any> = (event?: T) => void;\nexport type WildcardHandler = (type: EventType, event?: any) => void;\n\n// An array of all currently registered event handlers for a type\nexport type EventHandlerList = Array<Handler>;\nexport type WildCardEventHandlerList = Array<WildcardHandler>;\n\n// A map of event types and their corresponding event handlers.\nexport type EventHandlerMap = Map<EventType, EventHandlerList | WildCardEventHandlerList>;\n\nexport interface Emitter {\n\tall: EventHandlerMap;\n\n\ton<T = any>(type: EventType, handler: Handler<T>): void;\n\ton(type: '*', handler: WildcardHandler): void;\n\n\toff<T = any>(type: EventType, handler: Handler<T>): void;\n\toff(type: '*', handler: WildcardHandler): void;\n\n\temit<T = any>(type: EventType, event?: T): void;\n\temit(type: '*', event?: any): void;\n}\n\n/**\n * Mitt: Tiny (~200b) functional event emitter / pubsub.\n * @name mitt\n * @returns {Mitt}\n */\nexport default function mitt(all?: EventHandlerMap): Emitter {\n\tall = all || new Map();\n\n\treturn {\n\n\t\t/**\n\t\t * A Map of event names to registered handler functions.\n\t\t */\n\t\tall,\n\n\t\t/**\n\t\t * Register an event handler for the given type.\n\t\t * @param {string|symbol} type Type of event to listen for, or `\"*\"` for all events\n\t\t * @param {Function} handler Function to call in response to given event\n\t\t * @memberOf mitt\n\t\t */\n\t\ton<T = any>(type: EventType, handler: Handler<T>) {\n\t\t\tconst handlers = all.get(type);\n\t\t\tconst added = handlers && handlers.push(handler);\n\t\t\tif (!added) {\n\t\t\t\tall.set(type, [handler]);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Remove an event handler for the given type.\n\t\t * @param {string|symbol} type Type of event to unregister `handler` from, or `\"*\"`\n\t\t * @param {Function} handler Handler function to remove\n\t\t * @memberOf mitt\n\t\t */\n\t\toff<T = any>(type: EventType, handler: Handler<T>) {\n\t\t\tconst handlers = all.get(type);\n\t\t\tif (handlers) {\n\t\t\t\thandlers.splice(handlers.indexOf(handler) >>> 0, 1);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Invoke all handlers for the given type.\n\t\t * If present, `\"*\"` handlers are invoked after type-matched handlers.\n\t\t *\n\t\t * Note: Manually firing \"*\" handlers is not supported.\n\t\t *\n\t\t * @param {string|symbol} type The event type to invoke\n\t\t * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler\n\t\t * @memberOf mitt\n\t\t */\n\t\temit<T = any>(type: EventType, evt: T) {\n\t\t\t((all.get(type) || []) as EventHandlerList).slice().map((handler) => { handler(evt); });\n\t\t\t((all.get('*') || []) as WildCardEventHandlerList).slice().map((handler) => { handler(type, evt); });\n\t\t}\n\t};\n}\n"],"names":["all","Map","on","type","handler","handlers","get","push","set","off","splice","indexOf","emit","evt","slice","map"],"mappings":"wBAgC6BA,GAG5B,MAAO,CAKNA,IAPDA,EAAMA,GAAO,IAAIC,IAehBC,YAAYC,EAAiBC,GAC5B,IAAMC,EAAWL,EAAIM,IAAIH,GACXE,GAAYA,EAASE,KAAKH,IAEvCJ,EAAIQ,IAAIL,EAAM,CAACC,KAUjBK,aAAaN,EAAiBC,GAC7B,IAAMC,EAAWL,EAAIM,IAAIH,GACrBE,GACHA,EAASK,OAAOL,EAASM,QAAQP,KAAa,EAAG,IAcnDQ,cAAcT,EAAiBU,IAC5Bb,EAAIM,IAAIH,IAAS,IAAyBW,QAAQC,IAAI,SAACX,GAAcA,EAAQS,MAC7Eb,EAAIM,IAAI,MAAQ,IAAiCQ,QAAQC,IAAI,SAACX,GAAcA,EAAQD,EAAMU"}
|
2
vendor/mitt/dist/mitt.js
vendored
2
vendor/mitt/dist/mitt.js
vendored
@ -1,2 +0,0 @@
|
||||
module.exports=function(n){return{all:n=n||new Map,on:function(e,t){var i=n.get(e);i&&i.push(t)||n.set(e,[t])},off:function(e,t){var i=n.get(e);i&&i.splice(i.indexOf(t)>>>0,1)},emit:function(e,t){(n.get(e)||[]).slice().map(function(n){n(t)}),(n.get("*")||[]).slice().map(function(n){n(e,t)})}}};
|
||||
//# sourceMappingURL=mitt.js.map
|
1
vendor/mitt/dist/mitt.js.map
vendored
1
vendor/mitt/dist/mitt.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"mitt.js","sources":["../src/index.ts"],"sourcesContent":["export type EventType = string | symbol;\n\n// An event handler can take an optional event argument\n// and should not return a value\nexport type Handler<T = any> = (event?: T) => void;\nexport type WildcardHandler = (type: EventType, event?: any) => void;\n\n// An array of all currently registered event handlers for a type\nexport type EventHandlerList = Array<Handler>;\nexport type WildCardEventHandlerList = Array<WildcardHandler>;\n\n// A map of event types and their corresponding event handlers.\nexport type EventHandlerMap = Map<EventType, EventHandlerList | WildCardEventHandlerList>;\n\nexport interface Emitter {\n\tall: EventHandlerMap;\n\n\ton<T = any>(type: EventType, handler: Handler<T>): void;\n\ton(type: '*', handler: WildcardHandler): void;\n\n\toff<T = any>(type: EventType, handler: Handler<T>): void;\n\toff(type: '*', handler: WildcardHandler): void;\n\n\temit<T = any>(type: EventType, event?: T): void;\n\temit(type: '*', event?: any): void;\n}\n\n/**\n * Mitt: Tiny (~200b) functional event emitter / pubsub.\n * @name mitt\n * @returns {Mitt}\n */\nexport default function mitt(all?: EventHandlerMap): Emitter {\n\tall = all || new Map();\n\n\treturn {\n\n\t\t/**\n\t\t * A Map of event names to registered handler functions.\n\t\t */\n\t\tall,\n\n\t\t/**\n\t\t * Register an event handler for the given type.\n\t\t * @param {string|symbol} type Type of event to listen for, or `\"*\"` for all events\n\t\t * @param {Function} handler Function to call in response to given event\n\t\t * @memberOf mitt\n\t\t */\n\t\ton<T = any>(type: EventType, handler: Handler<T>) {\n\t\t\tconst handlers = all.get(type);\n\t\t\tconst added = handlers && handlers.push(handler);\n\t\t\tif (!added) {\n\t\t\t\tall.set(type, [handler]);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Remove an event handler for the given type.\n\t\t * @param {string|symbol} type Type of event to unregister `handler` from, or `\"*\"`\n\t\t * @param {Function} handler Handler function to remove\n\t\t * @memberOf mitt\n\t\t */\n\t\toff<T = any>(type: EventType, handler: Handler<T>) {\n\t\t\tconst handlers = all.get(type);\n\t\t\tif (handlers) {\n\t\t\t\thandlers.splice(handlers.indexOf(handler) >>> 0, 1);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Invoke all handlers for the given type.\n\t\t * If present, `\"*\"` handlers are invoked after type-matched handlers.\n\t\t *\n\t\t * Note: Manually firing \"*\" handlers is not supported.\n\t\t *\n\t\t * @param {string|symbol} type The event type to invoke\n\t\t * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler\n\t\t * @memberOf mitt\n\t\t */\n\t\temit<T = any>(type: EventType, evt: T) {\n\t\t\t((all.get(type) || []) as EventHandlerList).slice().map((handler) => { handler(evt); });\n\t\t\t((all.get('*') || []) as WildCardEventHandlerList).slice().map((handler) => { handler(type, evt); });\n\t\t}\n\t};\n}\n"],"names":["all","Map","on","type","handler","handlers","get","push","set","off","splice","indexOf","emit","evt","slice","map"],"mappings":"wBAgC6BA,GAG5B,MAAO,CAKNA,IAPDA,EAAMA,GAAO,IAAIC,IAehBC,YAAYC,EAAiBC,GAC5B,IAAMC,EAAWL,EAAIM,IAAIH,GACXE,GAAYA,EAASE,KAAKH,IAEvCJ,EAAIQ,IAAIL,EAAM,CAACC,KAUjBK,aAAaN,EAAiBC,GAC7B,IAAMC,EAAWL,EAAIM,IAAIH,GACrBE,GACHA,EAASK,OAAOL,EAASM,QAAQP,KAAa,EAAG,IAcnDQ,cAAcT,EAAiBU,IAC5Bb,EAAIM,IAAIH,IAAS,IAAyBW,QAAQC,IAAI,SAACX,GAAcA,EAAQS,MAC7Eb,EAAIM,IAAI,MAAQ,IAAiCQ,QAAQC,IAAI,SAACX,GAAcA,EAAQD,EAAMU"}
|
2
vendor/mitt/dist/mitt.modern.js
vendored
2
vendor/mitt/dist/mitt.modern.js
vendored
@ -1,2 +0,0 @@
|
||||
export default function(e){return{all:e=e||new Map,on(t,n){const s=e.get(t);s&&s.push(n)||e.set(t,[n])},off(t,n){const s=e.get(t);s&&s.splice(s.indexOf(n)>>>0,1)},emit(t,n){(e.get(t)||[]).slice().map(e=>{e(n)}),(e.get("*")||[]).slice().map(e=>{e(t,n)})}}}
|
||||
//# sourceMappingURL=mitt.modern.js.map
|
1
vendor/mitt/dist/mitt.modern.js.map
vendored
1
vendor/mitt/dist/mitt.modern.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"mitt.modern.js","sources":["../src/index.ts"],"sourcesContent":["export type EventType = string | symbol;\n\n// An event handler can take an optional event argument\n// and should not return a value\nexport type Handler<T = any> = (event?: T) => void;\nexport type WildcardHandler = (type: EventType, event?: any) => void;\n\n// An array of all currently registered event handlers for a type\nexport type EventHandlerList = Array<Handler>;\nexport type WildCardEventHandlerList = Array<WildcardHandler>;\n\n// A map of event types and their corresponding event handlers.\nexport type EventHandlerMap = Map<EventType, EventHandlerList | WildCardEventHandlerList>;\n\nexport interface Emitter {\n\tall: EventHandlerMap;\n\n\ton<T = any>(type: EventType, handler: Handler<T>): void;\n\ton(type: '*', handler: WildcardHandler): void;\n\n\toff<T = any>(type: EventType, handler: Handler<T>): void;\n\toff(type: '*', handler: WildcardHandler): void;\n\n\temit<T = any>(type: EventType, event?: T): void;\n\temit(type: '*', event?: any): void;\n}\n\n/**\n * Mitt: Tiny (~200b) functional event emitter / pubsub.\n * @name mitt\n * @returns {Mitt}\n */\nexport default function mitt(all?: EventHandlerMap): Emitter {\n\tall = all || new Map();\n\n\treturn {\n\n\t\t/**\n\t\t * A Map of event names to registered handler functions.\n\t\t */\n\t\tall,\n\n\t\t/**\n\t\t * Register an event handler for the given type.\n\t\t * @param {string|symbol} type Type of event to listen for, or `\"*\"` for all events\n\t\t * @param {Function} handler Function to call in response to given event\n\t\t * @memberOf mitt\n\t\t */\n\t\ton<T = any>(type: EventType, handler: Handler<T>) {\n\t\t\tconst handlers = all.get(type);\n\t\t\tconst added = handlers && handlers.push(handler);\n\t\t\tif (!added) {\n\t\t\t\tall.set(type, [handler]);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Remove an event handler for the given type.\n\t\t * @param {string|symbol} type Type of event to unregister `handler` from, or `\"*\"`\n\t\t * @param {Function} handler Handler function to remove\n\t\t * @memberOf mitt\n\t\t */\n\t\toff<T = any>(type: EventType, handler: Handler<T>) {\n\t\t\tconst handlers = all.get(type);\n\t\t\tif (handlers) {\n\t\t\t\thandlers.splice(handlers.indexOf(handler) >>> 0, 1);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Invoke all handlers for the given type.\n\t\t * If present, `\"*\"` handlers are invoked after type-matched handlers.\n\t\t *\n\t\t * Note: Manually firing \"*\" handlers is not supported.\n\t\t *\n\t\t * @param {string|symbol} type The event type to invoke\n\t\t * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler\n\t\t * @memberOf mitt\n\t\t */\n\t\temit<T = any>(type: EventType, evt: T) {\n\t\t\t((all.get(type) || []) as EventHandlerList).slice().map((handler) => { handler(evt); });\n\t\t\t((all.get('*') || []) as WildCardEventHandlerList).slice().map((handler) => { handler(type, evt); });\n\t\t}\n\t};\n}\n"],"names":["all","Map","on","type","handler","handlers","get","push","set","off","splice","indexOf","emit","evt","slice","map"],"mappings":"wBAgC6BA,GAG5B,MAAO,CAKNA,IAPDA,EAAMA,GAAO,IAAIC,IAehBC,GAAYC,EAAiBC,GAC5B,MAAMC,EAAWL,EAAIM,IAAIH,GACXE,GAAYA,EAASE,KAAKH,IAEvCJ,EAAIQ,IAAIL,EAAM,CAACC,KAUjBK,IAAaN,EAAiBC,GAC7B,MAAMC,EAAWL,EAAIM,IAAIH,GACrBE,GACHA,EAASK,OAAOL,EAASM,QAAQP,KAAa,EAAG,IAcnDQ,KAAcT,EAAiBU,IAC5Bb,EAAIM,IAAIH,IAAS,IAAyBW,QAAQC,IAAKX,IAAcA,EAAQS,MAC7Eb,EAAIM,IAAI,MAAQ,IAAiCQ,QAAQC,IAAKX,IAAcA,EAAQD,EAAMU"}
|
2
vendor/mitt/dist/mitt.umd.js
vendored
2
vendor/mitt/dist/mitt.umd.js
vendored
@ -1,2 +0,0 @@
|
||||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).mitt=n()}(this,function(){return function(e){return{all:e=e||new Map,on:function(n,t){var f=e.get(n);f&&f.push(t)||e.set(n,[t])},off:function(n,t){var f=e.get(n);f&&f.splice(f.indexOf(t)>>>0,1)},emit:function(n,t){(e.get(n)||[]).slice().map(function(e){e(t)}),(e.get("*")||[]).slice().map(function(e){e(n,t)})}}}});
|
||||
//# sourceMappingURL=mitt.umd.js.map
|
1
vendor/mitt/dist/mitt.umd.js.map
vendored
1
vendor/mitt/dist/mitt.umd.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"mitt.umd.js","sources":["../src/index.ts"],"sourcesContent":["export type EventType = string | symbol;\n\n// An event handler can take an optional event argument\n// and should not return a value\nexport type Handler<T = any> = (event?: T) => void;\nexport type WildcardHandler = (type: EventType, event?: any) => void;\n\n// An array of all currently registered event handlers for a type\nexport type EventHandlerList = Array<Handler>;\nexport type WildCardEventHandlerList = Array<WildcardHandler>;\n\n// A map of event types and their corresponding event handlers.\nexport type EventHandlerMap = Map<EventType, EventHandlerList | WildCardEventHandlerList>;\n\nexport interface Emitter {\n\tall: EventHandlerMap;\n\n\ton<T = any>(type: EventType, handler: Handler<T>): void;\n\ton(type: '*', handler: WildcardHandler): void;\n\n\toff<T = any>(type: EventType, handler: Handler<T>): void;\n\toff(type: '*', handler: WildcardHandler): void;\n\n\temit<T = any>(type: EventType, event?: T): void;\n\temit(type: '*', event?: any): void;\n}\n\n/**\n * Mitt: Tiny (~200b) functional event emitter / pubsub.\n * @name mitt\n * @returns {Mitt}\n */\nexport default function mitt(all?: EventHandlerMap): Emitter {\n\tall = all || new Map();\n\n\treturn {\n\n\t\t/**\n\t\t * A Map of event names to registered handler functions.\n\t\t */\n\t\tall,\n\n\t\t/**\n\t\t * Register an event handler for the given type.\n\t\t * @param {string|symbol} type Type of event to listen for, or `\"*\"` for all events\n\t\t * @param {Function} handler Function to call in response to given event\n\t\t * @memberOf mitt\n\t\t */\n\t\ton<T = any>(type: EventType, handler: Handler<T>) {\n\t\t\tconst handlers = all.get(type);\n\t\t\tconst added = handlers && handlers.push(handler);\n\t\t\tif (!added) {\n\t\t\t\tall.set(type, [handler]);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Remove an event handler for the given type.\n\t\t * @param {string|symbol} type Type of event to unregister `handler` from, or `\"*\"`\n\t\t * @param {Function} handler Handler function to remove\n\t\t * @memberOf mitt\n\t\t */\n\t\toff<T = any>(type: EventType, handler: Handler<T>) {\n\t\t\tconst handlers = all.get(type);\n\t\t\tif (handlers) {\n\t\t\t\thandlers.splice(handlers.indexOf(handler) >>> 0, 1);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Invoke all handlers for the given type.\n\t\t * If present, `\"*\"` handlers are invoked after type-matched handlers.\n\t\t *\n\t\t * Note: Manually firing \"*\" handlers is not supported.\n\t\t *\n\t\t * @param {string|symbol} type The event type to invoke\n\t\t * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler\n\t\t * @memberOf mitt\n\t\t */\n\t\temit<T = any>(type: EventType, evt: T) {\n\t\t\t((all.get(type) || []) as EventHandlerList).slice().map((handler) => { handler(evt); });\n\t\t\t((all.get('*') || []) as WildCardEventHandlerList).slice().map((handler) => { handler(type, evt); });\n\t\t}\n\t};\n}\n"],"names":["all","Map","on","type","handler","handlers","get","push","set","off","splice","indexOf","emit","evt","slice","map"],"mappings":"6LAgC6BA,GAG5B,MAAO,CAKNA,IAPDA,EAAMA,GAAO,IAAIC,IAehBC,YAAYC,EAAiBC,GAC5B,IAAMC,EAAWL,EAAIM,IAAIH,GACXE,GAAYA,EAASE,KAAKH,IAEvCJ,EAAIQ,IAAIL,EAAM,CAACC,KAUjBK,aAAaN,EAAiBC,GAC7B,IAAMC,EAAWL,EAAIM,IAAIH,GACrBE,GACHA,EAASK,OAAOL,EAASM,QAAQP,KAAa,EAAG,IAcnDQ,cAAcT,EAAiBU,IAC5Bb,EAAIM,IAAIH,IAAS,IAAyBW,QAAQC,IAAI,SAACX,GAAcA,EAAQS,MAC7Eb,EAAIM,IAAI,MAAQ,IAAiCQ,QAAQC,IAAI,SAACX,GAAcA,EAAQD,EAAMU"}
|
21
vendor/mitt/index.d.ts
vendored
21
vendor/mitt/index.d.ts
vendored
@ -1,21 +0,0 @@
|
||||
export declare type EventType = string | symbol;
|
||||
export declare type Handler<T = any> = (event?: T) => void;
|
||||
export declare type WildcardHandler = (type: EventType, event?: any) => void;
|
||||
export declare type EventHandlerList = Array<Handler>;
|
||||
export declare type WildCardEventHandlerList = Array<WildcardHandler>;
|
||||
export declare type EventHandlerMap = Map<EventType, EventHandlerList | WildCardEventHandlerList>;
|
||||
export interface Emitter {
|
||||
all: EventHandlerMap;
|
||||
on<T = any>(type: EventType, handler: Handler<T>): void;
|
||||
on(type: '*', handler: WildcardHandler): void;
|
||||
off<T = any>(type: EventType, handler: Handler<T>): void;
|
||||
off(type: '*', handler: WildcardHandler): void;
|
||||
emit<T = any>(type: EventType, event?: T): void;
|
||||
emit(type: '*', event?: any): void;
|
||||
}
|
||||
/**
|
||||
* Mitt: Tiny (~200b) functional event emitter / pubsub.
|
||||
* @name mitt
|
||||
* @returns {Mitt}
|
||||
*/
|
||||
export default function mitt(all?: EventHandlerMap): Emitter;
|
18
vendor/mitt/index.ts
vendored
Normal file
18
vendor/mitt/index.ts
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright 2022 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export * from 'mitt';
|
||||
export {default as default} from 'mitt';
|
141
vendor/mitt/package.json
vendored
141
vendor/mitt/package.json
vendored
@ -1,141 +0,0 @@
|
||||
{
|
||||
"_from": "mitt@latest",
|
||||
"_id": "mitt@2.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-ILj2TpLiysu2wkBbWjAmww7TkZb65aiQO+DkVdUTBpBXq+MHYiETENkKFMtsJZX1Lf4pe4QOrTSjIfUwN5lRdg==",
|
||||
"_location": "/mitt",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "mitt@latest",
|
||||
"name": "mitt",
|
||||
"escapedName": "mitt",
|
||||
"rawSpec": "latest",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/mitt/-/mitt-2.1.0.tgz",
|
||||
"_shasum": "f740577c23176c6205b121b2973514eade1b2230",
|
||||
"_spec": "mitt@latest",
|
||||
"_where": "/Users/jacktfranklin/src/puppeteer",
|
||||
"authors": [
|
||||
"Jason Miller <jason@developit.ca>"
|
||||
],
|
||||
"bugs": {
|
||||
"url": "https://github.com/developit/mitt/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Tiny 200b functional Event Emitter / pubsub.",
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.2.11",
|
||||
"@types/mocha": "^7.0.2",
|
||||
"@types/sinon": "^9.0.4",
|
||||
"@types/sinon-chai": "^3.2.4",
|
||||
"@typescript-eslint/eslint-plugin": "^3.0.1",
|
||||
"@typescript-eslint/parser": "^3.0.1",
|
||||
"chai": "^4.2.0",
|
||||
"documentation": "^13.0.0",
|
||||
"eslint": "^7.1.0",
|
||||
"eslint-config-developit": "^1.2.0",
|
||||
"esm": "^3.2.25",
|
||||
"microbundle": "^0.12.3",
|
||||
"mocha": "^8.0.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"rimraf": "^3.0.2",
|
||||
"sinon": "^9.0.2",
|
||||
"sinon-chai": "^3.5.0",
|
||||
"ts-node": "^8.10.2",
|
||||
"typescript": "^3.9.3"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"developit",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"sourceType": "module"
|
||||
},
|
||||
"env": {
|
||||
"browser": true,
|
||||
"mocha": true,
|
||||
"jest": false,
|
||||
"es6": true
|
||||
},
|
||||
"globals": {
|
||||
"expect": true
|
||||
},
|
||||
"rules": {
|
||||
"semi": [
|
||||
2,
|
||||
"always"
|
||||
],
|
||||
"jest/valid-expect": 0,
|
||||
"@typescript-eslint/no-explicit-any": 0,
|
||||
"@typescript-eslint/explicit-function-return-type": 0,
|
||||
"@typescript-eslint/explicit-module-boundary-types": 0,
|
||||
"@typescript-eslint/no-empty-function": 0
|
||||
}
|
||||
},
|
||||
"eslintIgnore": [
|
||||
"dist",
|
||||
"index.d.ts"
|
||||
],
|
||||
"esmodules": "dist/mitt.modern.js",
|
||||
"files": [
|
||||
"src",
|
||||
"dist",
|
||||
"index.d.ts"
|
||||
],
|
||||
"homepage": "https://github.com/developit/mitt",
|
||||
"jsnext:main": "dist/mitt.es.js",
|
||||
"keywords": [
|
||||
"events",
|
||||
"eventemitter",
|
||||
"emitter",
|
||||
"pubsub"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "dist/mitt.js",
|
||||
"mocha": {
|
||||
"extension": [
|
||||
"ts"
|
||||
],
|
||||
"require": [
|
||||
"ts-node/register",
|
||||
"esm"
|
||||
],
|
||||
"spec": [
|
||||
"test/*_test.ts"
|
||||
]
|
||||
},
|
||||
"module": "dist/mitt.es.js",
|
||||
"name": "mitt",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/developit/mitt.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm-run-all --silent clean -p bundle -s docs",
|
||||
"bundle": "microbundle",
|
||||
"clean": "rimraf dist",
|
||||
"docs": "documentation readme src/index.ts --section API -q --parse-extension ts",
|
||||
"lint": "eslint src test --ext ts --ext js",
|
||||
"mocha": "mocha test",
|
||||
"release": "npm run -s build -s && npm t && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish",
|
||||
"test": "npm-run-all --silent typecheck lint mocha test-types",
|
||||
"test-types": "tsc test/test-types-compilation.ts --noEmit",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"source": "src/index.ts",
|
||||
"typings": "index.d.ts",
|
||||
"umd:main": "dist/mitt.umd.js",
|
||||
"version": "2.1.0"
|
||||
}
|
92
vendor/mitt/src/index.ts
vendored
92
vendor/mitt/src/index.ts
vendored
@ -1,92 +0,0 @@
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type EventType = string | symbol;
|
||||
|
||||
// An event handler can take an optional event argument
|
||||
// and should not return a value
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type Handler<T = any> = (event?: T) => void;
|
||||
export type WildcardHandler = (type: EventType, event?: any) => void;
|
||||
|
||||
// An array of all currently registered event handlers for a type
|
||||
export type EventHandlerList = Array<Handler>;
|
||||
export type WildCardEventHandlerList = Array<WildcardHandler>;
|
||||
|
||||
// A map of event types and their corresponding event handlers.
|
||||
export type EventHandlerMap = Map<EventType, EventHandlerList | WildCardEventHandlerList>;
|
||||
|
||||
export interface Emitter {
|
||||
all: EventHandlerMap;
|
||||
|
||||
on<T = any>(type: EventType, handler: Handler<T>): void;
|
||||
on(type: '*', handler: WildcardHandler): void;
|
||||
|
||||
off<T = any>(type: EventType, handler: Handler<T>): void;
|
||||
off(type: '*', handler: WildcardHandler): void;
|
||||
|
||||
emit<T = any>(type: EventType, event?: T): void;
|
||||
emit(type: '*', event?: any): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mitt: Tiny (~200b) functional event emitter / pubsub.
|
||||
* @name mitt
|
||||
* @returns {Mitt}
|
||||
*/
|
||||
export default function mitt(all?: EventHandlerMap): Emitter {
|
||||
all = all || new Map();
|
||||
|
||||
return {
|
||||
|
||||
/**
|
||||
* A Map of event names to registered handler functions.
|
||||
*/
|
||||
all,
|
||||
|
||||
/**
|
||||
* Register an event handler for the given type.
|
||||
* @param {string|symbol} type Type of event to listen for, or `"*"` for all events
|
||||
* @param {Function} handler Function to call in response to given event
|
||||
* @memberOf mitt
|
||||
*/
|
||||
on<T = any>(type: EventType, handler: Handler<T>) {
|
||||
const handlers = all.get(type);
|
||||
const added = handlers && handlers.push(handler);
|
||||
if (!added) {
|
||||
all.set(type, [handler]);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove an event handler for the given type.
|
||||
* @param {string|symbol} type Type of event to unregister `handler` from, or `"*"`
|
||||
* @param {Function} handler Handler function to remove
|
||||
* @memberOf mitt
|
||||
*/
|
||||
off<T = any>(type: EventType, handler: Handler<T>) {
|
||||
const handlers = all.get(type);
|
||||
if (handlers) {
|
||||
handlers.splice(handlers.indexOf(handler) >>> 0, 1);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Invoke all handlers for the given type.
|
||||
* If present, `"*"` handlers are invoked after type-matched handlers.
|
||||
*
|
||||
* Note: Manually firing "*" handlers is not supported.
|
||||
*
|
||||
* @param {string|symbol} type The event type to invoke
|
||||
* @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler
|
||||
* @memberOf mitt
|
||||
*/
|
||||
emit<T = any>(type: EventType, evt: T) {
|
||||
((all.get(type) || []) as EventHandlerList).slice().map((handler) => { handler(evt); });
|
||||
((all.get('*') || []) as WildCardEventHandlerList).slice().map((handler) => { handler(type, evt); });
|
||||
}
|
||||
};
|
||||
}
|
9
vendor/tsconfig.cjs.json
vendored
9
vendor/tsconfig.cjs.json
vendored
@ -1,12 +1,9 @@
|
||||
{
|
||||
"exclude": [
|
||||
"mitt/dist"
|
||||
],
|
||||
"extends": "../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"declarationMap": false,
|
||||
"outDir": "../lib/cjs/vendor",
|
||||
"module": "CommonJS",
|
||||
"moduleResolution": "node",
|
||||
"strict": false
|
||||
"sourceMap": false
|
||||
}
|
||||
}
|
||||
|
12
vendor/tsconfig.esm.json
vendored
12
vendor/tsconfig.esm.json
vendored
@ -1,12 +0,0 @@
|
||||
{
|
||||
"exclude": [
|
||||
"mitt/dist"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"outDir": "../lib/esm/vendor",
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"strict": false
|
||||
}
|
||||
}
|
9
vendor/tsconfig.json
vendored
Normal file
9
vendor/tsconfig.json
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"declarationMap": false,
|
||||
"outDir": "../lib/esm/vendor",
|
||||
"sourceMap": false
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user