Vom Anderen PC aus hoch gespielt
This commit is contained in:
710
node_modules/config/History.md
generated
vendored
Normal file
710
node_modules/config/History.md
generated
vendored
Normal file
@@ -0,0 +1,710 @@
|
||||
Beyond 3.3.7
|
||||
============
|
||||
We've moved this content to [Github Releases](https://github.com/node-config/node-config/releases).
|
||||
|
||||
Future release notes are managed there.
|
||||
|
||||
3.3.7 / 2022-01-11
|
||||
==================
|
||||
|
||||
* No new changes. 3.3.6 was not published to NPM in versioning mix-up.
|
||||
* Release notes are moving to Github Releases page going forward.
|
||||
|
||||
3.3.6 / 2021-03-08
|
||||
==================
|
||||
|
||||
* Added publishConfig element to package.json to prevent publishing to the wrong repository - @lorenwest
|
||||
|
||||
3.3.5 / 2021-03-05
|
||||
==================
|
||||
|
||||
* FIX [#628](https://github.com/node-config/node-config/issues/628) Uncaught ReferenceError: node_env_var_name is not defined @prnake
|
||||
|
||||
3.3.4 / 2021-02-26
|
||||
==================
|
||||
|
||||
* FIX #517 0 loadFileConfigs incorrectly adds to getConfigSources @NguyenMatthieu
|
||||
|
||||
3.3.3 / 2020-11-26
|
||||
==================
|
||||
|
||||
* FIX #460 - Strict mode warning refer to appropriate env variable @iCodeOkay
|
||||
* Use Buffer.alloc and Buffer.from instead of contrsuctor @Fcmam5
|
||||
* Add support for experimental .cjs modules @lenkan
|
||||
|
||||
|
||||
3.3.2 / 2020-09-24
|
||||
==================
|
||||
|
||||
* Fixed issue with Buffers in config throwing error in util.makeImmutable (#608) - Michal Wadas
|
||||
* Added boolean and numeric types to custom environment variables - Ankur Narkhede @ankurnarkhede
|
||||
|
||||
3.3.1 / 2020-03-25
|
||||
==================
|
||||
|
||||
* Fix security vulnerability in json5 dependency - @twkel
|
||||
|
||||
3.3.0 / 2020-02-26
|
||||
==================
|
||||
|
||||
* Allow all defined values in `substituteDeep` - @fostyfost
|
||||
|
||||
3.2.6 / 2020-02-21
|
||||
==================
|
||||
|
||||
* Updated copyright date ranges
|
||||
|
||||
3.2.5 / 2020-01-16
|
||||
==================
|
||||
|
||||
* Fixed issue with getCustomEnvVars and multiple config dirs #585 - @dekelev
|
||||
|
||||
3.2.4 / 2019-10-25
|
||||
==================
|
||||
|
||||
* Improved error handling of env variables value parse - @leonardovillela
|
||||
|
||||
3.2.3 / 2019-10-03
|
||||
==================
|
||||
|
||||
* Fixed strict mode warning #460 - @fedulovivan
|
||||
|
||||
3.2.2 / 2019-07-20
|
||||
==================
|
||||
|
||||
* Fixed delimiter bug in configDirs to match O/S delimiter - @iMoses
|
||||
|
||||
3.2.1 / 2019-07-18
|
||||
==================
|
||||
|
||||
* Fixed TypeError: obj.toString is not a function - @leosuncin
|
||||
|
||||
3.2.0 / 2019-07-11
|
||||
==================
|
||||
|
||||
* Asynchronous configs - @iMoses
|
||||
* Multiple config directories - @iMoses
|
||||
* Improved parser support - @iMoses
|
||||
|
||||
3.1.0 / 2019-04-07
|
||||
==================
|
||||
|
||||
* Support of module.exports syntax for TS config files @keenondrums
|
||||
|
||||
3.0.1 / 2018-12-16
|
||||
==================
|
||||
|
||||
* Fixed bug where dot notation extended own key @exogen
|
||||
|
||||
3.0.0 / 2018-11-20
|
||||
==================
|
||||
|
||||
* Ensure config array items and objects are sealed @fgheorghe
|
||||
- This required a major version bump in case someone
|
||||
- relied on the ability to mutate non-sealed data.
|
||||
|
||||
|
||||
2.0.2 / 2018-08-28
|
||||
==================
|
||||
|
||||
* Added dot notation to setModuleDefaults - bertho-zero
|
||||
* Updated copyright year - JemiloII
|
||||
|
||||
2.0.1 / 2018-07-26
|
||||
==================
|
||||
|
||||
* Removed deprecated code - jpwilliams
|
||||
|
||||
2.0.0 / 2018-07-26
|
||||
==================
|
||||
|
||||
Potential for backward incompatibility requiring a major version bump.
|
||||
|
||||
Safe to upgrade to major version 2 if you're using a recent NodeJS version
|
||||
and you're not trying to mutate config arrays.
|
||||
|
||||
* Added array immutability - jacobemerick
|
||||
* Removed Node V.4 support
|
||||
|
||||
1.31.0 / 2018-05-22
|
||||
===================
|
||||
|
||||
* Load new coffeescript module instead of coffee-script - bastbijl
|
||||
|
||||
1.30.0 / 2018-02-26
|
||||
===================
|
||||
|
||||
* Support for nested raw() in javascript configurations - patrickpilch
|
||||
|
||||
1.29.4 / 2018-02-03
|
||||
===================
|
||||
|
||||
* Re-publish - last changes didn't make it to npm
|
||||
|
||||
1.29.3 / 2018-02-03
|
||||
===================
|
||||
|
||||
* Added soft dependencies so transpilers don't include everything - gewentao
|
||||
|
||||
1.29.2 / 2018-01-12
|
||||
===================
|
||||
|
||||
* Patch, and added a test to ts-node - electroma
|
||||
|
||||
1.29.1 / 2018-01-07
|
||||
===================
|
||||
|
||||
* Prevent re-registration of ts-node - electroma
|
||||
* Fixed bug in contributor table tool - lorenwest
|
||||
|
||||
1.29.0 / 2017-12-26
|
||||
===================
|
||||
|
||||
* Update docs for JavaScript-formatted config files and link them from the README - markstos
|
||||
* Fixed 'hostname' value selection when there is no environment variable for that - wmangelardo
|
||||
|
||||
|
||||
1.28.1 / 2017-11-09
|
||||
===================
|
||||
|
||||
* add nodejs9 to travisci - jfelege
|
||||
|
||||
1.28.0 / 2017-11-07
|
||||
===================
|
||||
|
||||
* allow overrides of `NODE_ENV` with `NODE_CONFIG_ENV` - jfelege
|
||||
|
||||
1.27.0 / 2017-10-17
|
||||
===================
|
||||
|
||||
* Add method to output plain JS object - willsoto
|
||||
* Updated Node versions in Travis CI - lorenwest
|
||||
|
||||
1.26.2 / 2017-08-11
|
||||
===================
|
||||
|
||||
* Update supported nodejs platforms - jfelege
|
||||
|
||||
1.26.1 / 2017-05-03
|
||||
===================
|
||||
|
||||
* Fix: failed while merging from RegExp @XadillaX
|
||||
* Chore: reduce package size. @evilebottnawi
|
||||
|
||||
1.26.0 / 2017-03-30
|
||||
===================
|
||||
|
||||
* Added tests for extendDeep @IvanVergiliev
|
||||
* Added TypeScript support @cypherq
|
||||
* Update config.js with correctly cased type def @ScionOfBytes
|
||||
|
||||
1.25.1 / 2017-02-01
|
||||
===================
|
||||
|
||||
* Fixed undefined CONFIG_SKIP_GITCRYPT variable @lorenwest
|
||||
|
||||
1.25.0 / 2017-01-31
|
||||
===================
|
||||
|
||||
* Add support for configuration files stored with git-crypt @cunneen
|
||||
|
||||
1.24.0 / 2016-11-02
|
||||
===================
|
||||
|
||||
* Prevent accidental publish to private repository
|
||||
|
||||
1.23.0 / 2016-11-02
|
||||
===================
|
||||
|
||||
* Re-publishing because npmjs didn't see 1.22
|
||||
|
||||
1.22.0 / 2016-10-25
|
||||
===================
|
||||
|
||||
* original/previous value for deferredConfig @simon-scherzinger
|
||||
* util.loadFileConfigs: support optional source dir @wmertens
|
||||
* Adding raw wrapper to prevent object modification in config @patrickpilch
|
||||
|
||||
1.21.0 / 2016-06-01
|
||||
===================
|
||||
|
||||
* Added XML configuration @tusharmath
|
||||
|
||||
1.20.4 / 2016-05-23
|
||||
===================
|
||||
|
||||
* Fixed a regression with extending prototype methods @tahoemph
|
||||
|
||||
1.20.3 / 2016-05-18
|
||||
===================
|
||||
|
||||
* Fixed a regression with 1.20.2 @kgoerlitz
|
||||
* Added test to prevent this in the future @kgoerlitz
|
||||
|
||||
1.20.2 / 2016-05-17
|
||||
===================
|
||||
|
||||
* node v6 compatiblity: remove deprecated __lookupGetter__ use - @thetalecrafter
|
||||
* node v6 compatiblity: handle different SyntaxError format - @pwwolf
|
||||
|
||||
1.20.1 / 2016-04-08
|
||||
===================
|
||||
|
||||
* Simplify truthiness check - @markstos
|
||||
* Remove errant console.log - @markstos
|
||||
|
||||
1.20.0 / 2016-04-06
|
||||
===================
|
||||
|
||||
* Typo fix @jchip
|
||||
* Handle null sub-object @wmertens
|
||||
* Bug fix for NODE_CONFIG_STRICT_MODE check @markstos
|
||||
* Ran node security check on 4/6/2016 with the following output
|
||||
|
||||
$ nsp check
|
||||
(+) No known vulnerabilities found
|
||||
|
||||
1.19.0 / 2016-01-08
|
||||
===================
|
||||
|
||||
* Resolve defered values in predictable order for consistent results.
|
||||
Fixes #265 @elliotttf @markstos
|
||||
|
||||
1.18.0 / 2015-11-17
|
||||
===================
|
||||
|
||||
* More robust handling of JSON @elliotttf
|
||||
|
||||
1.17.1 / 2015-11-17
|
||||
===================
|
||||
|
||||
* Patch release for regex bugfix
|
||||
|
||||
1.17.0 / 2015-11-17
|
||||
===================
|
||||
|
||||
* Update warning about missing configuration files to mention how to disable the warning #245 @markstos
|
||||
* Upgrade to run CI with travis containers @lorenwest
|
||||
* Fixed bug with comments and inline json @elliotttf
|
||||
|
||||
1.16.0 / 2015-09-03
|
||||
===================
|
||||
|
||||
* Change == to === to tighten equality tests #242 @wgpsutherland
|
||||
* Fix attachProtoDeep for setModuleDefaults #243 @benkroeger
|
||||
|
||||
1.15.0 / 2015-07-30
|
||||
===================
|
||||
|
||||
* Added full hostname in addition to first segment @vicary
|
||||
|
||||
1.14.0 / 2015-06-02
|
||||
===================
|
||||
|
||||
* Added JSON parsing to custom environment variables @leachiM2k
|
||||
* Handle unicode BOM characters @johndkane
|
||||
|
||||
1.13.0 / 2015-05-05
|
||||
===================
|
||||
|
||||
* Updated CSON library @dsimidzija
|
||||
|
||||
1.12.0 / 2015-02-19
|
||||
===================
|
||||
|
||||
* Better date merging @axelhzf
|
||||
|
||||
1.11.0 / 2015-01-14
|
||||
===================
|
||||
|
||||
* Added Hjson support @laktak
|
||||
|
||||
1.10.0 / 2015-01-06
|
||||
===================
|
||||
|
||||
* Added TOML support (@jasonhansel)
|
||||
* Another year - changed copyright messages for 2015
|
||||
* Updated contributors list
|
||||
* New Strict Mode added in 1.9.0 is now documented. (@markstos)
|
||||
* has() now returns false when given an undefined or null key to look up. Previously it threw an exception. (@markstos)
|
||||
* When get() is given an undefined or null key to look up, it now throws a more helpful diagnostic (@robludwig, @markstos)
|
||||
|
||||
1.9.0 / 2014-12-08
|
||||
==================
|
||||
|
||||
* New strictness checks have been added to ensure the expected configuration has been loaded. Warnings are now thrown in these cases. If NODE_CONFIG_STRICT_MODE is set, exceptions are thrown instead. (@markstos)
|
||||
* There must be an explicit config file matching `NODE_ENV` if `NODE_ENV` is set.
|
||||
* There must be an explicit config file matching `NODE_APP_INSTANCE` if `NODE_APP_INSTANCE` is set
|
||||
* `NODE_ENV` must not match 'default' or 'local' to avoid ambiguity.
|
||||
|
||||
* Added .iced extension support (@arthanzel)
|
||||
|
||||
* Highlight `config.has()` in the README. Use it to check to if a value exists, since `config.get()`
|
||||
throws exceptions on undefined values. (@markstos)
|
||||
|
||||
* API Change: getConfigSources() now starts to return data on config files that are valid-but-empty. (@markstos)
|
||||
|
||||
1.8.1 / 2014-11-14
|
||||
==================
|
||||
|
||||
* Simplify syntax for defer() functions. The 'this' value in the functions is now bound
|
||||
to the main configuration object, so it doesn't have to be passed into the function. (@markstos)
|
||||
* new defer sub-module introduced in 1.8.0 can now be accessed by require('config/defer')
|
||||
For usage, see: https://github.com/node-config/node-config/wiki/Configuration-Files#javascript-module---js
|
||||
* Add test coverage for array merging cases. (@markstos)
|
||||
* Bump dependency on cson package to 1.6.1 (@markstos)
|
||||
|
||||
1.8.0 / 2014-11-13
|
||||
==================
|
||||
|
||||
* Added deferred function for evaluating configs after load (@markstos)
|
||||
For details, see: https://github.com/node-config/node-config/wiki/Configuration-Files#javascript-module---js
|
||||
* Bumped js-yaml dependency (@markstos)
|
||||
|
||||
1.7.0 / 2014-10-30
|
||||
==================
|
||||
|
||||
* Added variable substitution in .properties files (@ncuillery)
|
||||
|
||||
1.6.0 / 2014-10-22
|
||||
==================
|
||||
|
||||
* Added support for property accessors in configs (@jaylynch)
|
||||
|
||||
1.5.0 / 2014-10-20
|
||||
==================
|
||||
|
||||
* Added support for .json5 config files (@bertrandom)
|
||||
|
||||
1.4.0 / 2014-10-16
|
||||
==================
|
||||
|
||||
* Added support for .properties config files (@superoven)
|
||||
|
||||
1.3.0 / 2014-10-15
|
||||
==================
|
||||
|
||||
* Added support for CSON configuration files (@superoven)
|
||||
|
||||
1.2.4 / 2014-10-10
|
||||
==================
|
||||
|
||||
* Repaired the 1.2.3 fix to work both before and after the first get()
|
||||
|
||||
1.2.3 / 2014-10-03
|
||||
==================
|
||||
|
||||
* Changed test suite to verify a bug in util.setModuleDefaults()
|
||||
* Fixed util.setModuleDefaults() to work after a get() (and pass the new test)
|
||||
|
||||
1.2.2 / 2014-10-03
|
||||
==================
|
||||
|
||||
* Added support for regexp and date configurations (@diversario)
|
||||
|
||||
1.2.1 / 2014-09-23
|
||||
==================
|
||||
|
||||
* Wrote test to prove setModuleDefaults() was broken in 1.2.0
|
||||
* Fixed setModuleDefaults() to not rely on immutable configs
|
||||
|
||||
1.2.0 / 2014-09-15
|
||||
==================
|
||||
|
||||
* Feature release
|
||||
* Delaying immutability until after first get() - for external configs
|
||||
* Allowing immutability override with $ALLOW_CONFIG_MUTATIONS=Y
|
||||
|
||||
|
||||
1.1.1 / 2014-09-03
|
||||
==================
|
||||
|
||||
* @th507 - Update support for Coffee-script >=1.7.0
|
||||
|
||||
1.1.0 / 2014-09-03
|
||||
==================
|
||||
|
||||
* Feature release
|
||||
* @bradboro - Custom environment variables
|
||||
* @supersheep - Catch error when requiring visionmedia yaml module
|
||||
|
||||
1.0.2 / 2014-07-30
|
||||
===================
|
||||
|
||||
* @bradobro - Fixed a variable from leaking into global
|
||||
* @tilfin - Removed un-necessary YAML comment filtering for js-yaml
|
||||
|
||||
1.0.1 / 2014-07-25
|
||||
===================
|
||||
|
||||
* Removed test directory from npm install
|
||||
|
||||
1.0.0 / 2014-07-23
|
||||
===================
|
||||
|
||||
* Major revision. Upgrade notes:
|
||||
https://github.com/node-config/node-config/wiki/Upgrading-From-Config-0.x
|
||||
* Update to semver versioning
|
||||
* Change load ordering
|
||||
from hostname.EXT --> deployment.EXT
|
||||
to deployment.EXT --> hostname.EXT
|
||||
* Allow makeImmutable to accept an array of attributes
|
||||
* Allow makeImmutable to accept no attrs, making all attributes immutable
|
||||
* Allow recursion in makeImmutable, if an attribute is an object
|
||||
* Change node-config behavior to make all configurations immutable
|
||||
* Removed getOriginalConfig as no longer necessary post-immutable
|
||||
* Removed runtime.json file writing and monitoring
|
||||
* Removed previously deprecated $CONFIG_* environment configurations
|
||||
* Deprecated the attribute watch functionality
|
||||
* Added error output if no configurations found
|
||||
* Exposed config loading for alternate configurations
|
||||
* Added config.get() and config.has() methods & tests
|
||||
* Removed reliance on global.NODE_CONFIG so older versions can work with 1.x
|
||||
* Fix empty YAML file causing crash with latest js-yaml
|
||||
* Added SUPPRESS_NO_CONFIG_WARNING for better sub-module support
|
||||
* Moved all documentation [to the wiki](https://github.com/node-config/node-config/wiki).
|
||||
|
||||
0.4.37 / 2014-07-22
|
||||
===================
|
||||
|
||||
* Fix empty YAML file causing crash with latest js-yaml
|
||||
|
||||
0.4.36 / 2014-05-27
|
||||
===================
|
||||
|
||||
* Not writing runtime.json if not used
|
||||
|
||||
0.4.35 / 2014-01-16
|
||||
===================
|
||||
|
||||
* NODE_CONFIG_DIR can now contain a relative path for .js and .coffee configurations
|
||||
|
||||
0.4.34 / 2014-01-06
|
||||
===================
|
||||
|
||||
* Updated copyright year
|
||||
|
||||
0.4.33 / 2013-10-25
|
||||
===================
|
||||
|
||||
* Assure writes to runtime.json are atomic
|
||||
|
||||
0.4.32 / 2013-10-24
|
||||
===================
|
||||
|
||||
* Don't freak out if running without a config directory
|
||||
* Don't be so chatty if runtime.json doesn't exist
|
||||
|
||||
0.4.31 / 2013-10-18
|
||||
===================
|
||||
|
||||
* Changed getConfigSources to copy array vs. object
|
||||
|
||||
0.4.30 / 2013-09-12
|
||||
===================
|
||||
|
||||
* More consistent array extension
|
||||
* No longer requiring a config directory
|
||||
* Not erroneously writing runtime.json
|
||||
* Exposing the original configuration sources
|
||||
* Added --NODE_CONFIG={json} command line overrides
|
||||
* Added $NODE_CONFIG={json} environment variable overrides
|
||||
* Consistent handling of environment variables and command line parameters
|
||||
* Reached 100 regression tests
|
||||
|
||||
0.4.29 / 2013-08-07
|
||||
===================
|
||||
|
||||
* Added flag for disabling the write of runtime.json
|
||||
|
||||
0.4.28 / 2013-07-31
|
||||
===================
|
||||
|
||||
* Eliminated a totally annoying install warning in newer versions of NPM
|
||||
|
||||
0.4.27 / 2013-06-18
|
||||
===================
|
||||
|
||||
* Fixed a bug preventing double underscores in config environment variables
|
||||
|
||||
0.4.26 / 2013-06-10
|
||||
===================
|
||||
|
||||
* Re-watch file on rename (allows editing runtime.json with vi)
|
||||
* Allow runtime.json file watch disable via NODE_CONFIG_DISABLE_FILE_WATCH=Y
|
||||
* Change no yaml parser error message to suggest using js-yaml
|
||||
* Changed default clone depth from 6 to 20 to allow for deeper configurations
|
||||
|
||||
0.4.25 / 2013-05-24
|
||||
===================
|
||||
|
||||
* Dont fail if config directory doesnt exist
|
||||
|
||||
0.4.24 / 2013-04-13
|
||||
===================
|
||||
|
||||
* Added resetRuntime() to reset the runtime.json file
|
||||
* Updated docs to reflect the new public method
|
||||
|
||||
0.4.23 / 2013-04-13
|
||||
===================
|
||||
|
||||
* Multiple application instance support via $NODE_APP_INSTANCE
|
||||
* Multi-app testing & documentation
|
||||
|
||||
0.4.22 / 2013-03-29
|
||||
===================
|
||||
|
||||
* Added configuration $CONFIG_* environment variables
|
||||
* Added $CONFIG_* documentation and tests
|
||||
* Added NodeJS 0.10 integration test
|
||||
|
||||
0.4.21 / 2013-03-06
|
||||
===================
|
||||
|
||||
* Triggering file.watch when an editor saves a file - rename vs. change
|
||||
* Installed Travis-CI continuous integration testing framework
|
||||
|
||||
0.4.20 / 2013-02-21
|
||||
===================
|
||||
|
||||
* Merged _diffDeep fix
|
||||
|
||||
0.4.19 / 2013-02-21
|
||||
===================
|
||||
|
||||
* Added discovery of .yml in addition to .yaml for YAML configs (w/doc)
|
||||
* Added testing of .yml file discovery
|
||||
* Removed licensing inconsistencies
|
||||
|
||||
0.4.18 / 2012-10-30
|
||||
===================
|
||||
|
||||
* Moved coffee-script and js-yaml from optionalDependencies back to
|
||||
devDependencies to trim the install size for those not needing
|
||||
these packages.
|
||||
* Promoted $HOSTNAME and $HOST above OS.hostname()
|
||||
|
||||
0.4.17 / 2012-09-26
|
||||
===================
|
||||
|
||||
* Allow the location of runtime.json to be picked up from the environment
|
||||
* Added documentation for the NODE_CONFIG_RUNTIME_JSON environment variable
|
||||
* package.json cleanup - created optionalDependencies and devDependencies
|
||||
|
||||
0.4.16 / 2012-08-09
|
||||
===================
|
||||
|
||||
* Allowing a zero interval in watchForConfigFileChanges() to disable file watching.
|
||||
* Fixed a comparator bug in _equalsDeep()
|
||||
* Added a test to confirm deep extending array functionality
|
||||
|
||||
0.4.15 / 2012-06-04
|
||||
===================
|
||||
|
||||
* Placed YAML and Coffee-Script libraries back into the download. Still lazy loading into memory.
|
||||
|
||||
0.4.14 / 2012-06-01
|
||||
===================
|
||||
|
||||
* Added the local.EXT and local-deployment.EXT configs.
|
||||
* Removed unnecessary debug output
|
||||
* Added retry logic on file parse to reduce read/write collisions
|
||||
* Added support for a better YAML parser
|
||||
* Fixed problems with null configuration values
|
||||
|
||||
0.4.13 / 2012-04-25
|
||||
===================
|
||||
|
||||
* Assuring the runtime.json file exists. Undocumented fs.watch() requirement.
|
||||
|
||||
0.4.12 / 2012-04-25
|
||||
===================
|
||||
|
||||
* Removed all external dependencies
|
||||
* Lazy loading of yaml and coffee-script only if these file types are used
|
||||
* Added new style file watching if available (retaining pre 6.0 compatibility)
|
||||
* Windows compatibility - file watching changes were required
|
||||
|
||||
0.4.11 / 2012-02-15
|
||||
===================
|
||||
|
||||
* Automatically watching runtime.json for changes
|
||||
* Fixed a date comparison bug during file watching
|
||||
* Changed require('sys') to require('util')
|
||||
|
||||
0.4.10 / 2012-01-18
|
||||
===================
|
||||
|
||||
* Made sure the CONFIG object is a shared singleton
|
||||
* Added NODE_CONFIG_DIR environment variable to point to a different directory
|
||||
* Added tests and documentation for the above
|
||||
|
||||
0.4.9 / 2012-01-06
|
||||
==================
|
||||
|
||||
* Added coffee-script file type support with extension .coffee
|
||||
* Added an example coffee-script configuration file
|
||||
* Added coffee-script module dependency
|
||||
* Added a test for coffee-script configuration files
|
||||
* Documented coffee-script support, regenerated documentation
|
||||
|
||||
0.4.8 / 2011-12-20
|
||||
==================
|
||||
|
||||
* Fixed a bug where changes to module default configs weren't persisted
|
||||
* Added a test to validate the bugfix
|
||||
|
||||
0.4.7 / 2011-12-16
|
||||
==================
|
||||
|
||||
* Created the makeHidden method to hide a property of an object
|
||||
* Added a value argument to makeImmutable for creating new properties
|
||||
* Fixed setModuleDefaults to hide injected prototype methods
|
||||
* Added documentation and unit tests
|
||||
|
||||
0.4.6 / 2011-11-29
|
||||
==================
|
||||
|
||||
* Updated vows from 0.5.8 to 0.5.13
|
||||
|
||||
0.4.5 / 2011-11-16
|
||||
==================
|
||||
|
||||
* Updated YAML dependency from "0.1.x" to ">=0.2.2"
|
||||
* Added stripping of comment-only and whitespace-only lines in YAML files for backward compatibility
|
||||
* Added more tests for YAML edge cases
|
||||
* Added a homepage link in package.json to the online documentation
|
||||
* Added History.md
|
||||
|
||||
0.4.4 / 2011-11-08
|
||||
==================
|
||||
|
||||
* Removed deprecated modules from package.json
|
||||
|
||||
0.4.3 / 2011-08-02
|
||||
==================
|
||||
|
||||
* Made watchForConfigFileChanges public
|
||||
|
||||
0.4.2 / 2011-07-11
|
||||
==================
|
||||
|
||||
* Added comment stripping from JSON configuration files
|
||||
|
||||
0.4.1 / 2011-07-07
|
||||
==================
|
||||
|
||||
* Added more tests
|
||||
* Return the module config in setModuleDefaults
|
||||
|
||||
0.4.0 / 2011-07-06
|
||||
==================
|
||||
|
||||
* Update to version 0.4.0
|
||||
|
||||
* Online documentation
|
||||
* Runtime configuration changes
|
||||
* Configuration value watching
|
||||
* Multi-instance node deployments
|
||||
* Better module developer support
|
||||
19
node_modules/config/LICENSE
generated
vendored
Normal file
19
node_modules/config/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// Copyright 2010-2022, Loren West and other contributors
|
||||
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
176
node_modules/config/README.md
generated
vendored
Normal file
176
node_modules/config/README.md
generated
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
Configure your Node.js Applications
|
||||
===================================
|
||||
|
||||
[](https://nodei.co/npm/config/)
|
||||
[](https://travis-ci.org/lorenwest/node-config)
|
||||
[release notes](https://github.com/node-config/node-config/blob/master/History.md)
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
Node-config organizes hierarchical configurations for your app deployments.
|
||||
|
||||
It lets you define a set of default parameters,
|
||||
and extend them for different deployment environments (development, qa,
|
||||
staging, production, etc.).
|
||||
|
||||
Configurations are stored in [configuration files](https://github.com/node-config/node-config/wiki/Configuration-Files) within your application, and can be overridden and extended by [environment variables](https://github.com/lorenwest/node-config/wiki/Environment-Variables),
|
||||
[command line parameters](https://github.com/node-config/node-config/wiki/Command-Line-Overrides), or [external sources](https://github.com/lorenwest/node-config/wiki/Configuring-from-an-External-Source).
|
||||
|
||||
This gives your application a consistent configuration interface shared among a
|
||||
[growing list of npm modules](https://www.npmjs.org/browse/depended/config) also using node-config.
|
||||
|
||||
Project Guidelines
|
||||
------------------
|
||||
|
||||
* *Simple* - Get started fast
|
||||
* *Powerful* - For multi-node enterprise deployment
|
||||
* *Flexible* - Supporting multiple config file formats
|
||||
* *Lightweight* - Small file and memory footprint
|
||||
* *Predictable* - Well tested foundation for module and app developers
|
||||
|
||||
Quick Start
|
||||
---------------
|
||||
The following examples are in JSON format, but configurations can be in other [file formats](https://github.com/node-config/node-config/wiki/Configuration-Files#file-formats).
|
||||
|
||||
**Install in your app directory, and edit the default config file.**
|
||||
|
||||
```shell
|
||||
$ npm install config
|
||||
$ mkdir config
|
||||
$ vi config/default.json
|
||||
```
|
||||
```js
|
||||
{
|
||||
// Customer module configs
|
||||
"Customer": {
|
||||
"dbConfig": {
|
||||
"host": "localhost",
|
||||
"port": 5984,
|
||||
"dbName": "customers"
|
||||
},
|
||||
"credit": {
|
||||
"initialLimit": 100,
|
||||
// Set low for development
|
||||
"initialDays": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Edit config overrides for production deployment:**
|
||||
|
||||
```shell
|
||||
$ vi config/production.json
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"Customer": {
|
||||
"dbConfig": {
|
||||
"host": "prod-db-server"
|
||||
},
|
||||
"credit": {
|
||||
"initialDays": 30
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Use configs in your code:**
|
||||
|
||||
```js
|
||||
const config = require('config');
|
||||
//...
|
||||
const dbConfig = config.get('Customer.dbConfig');
|
||||
db.connect(dbConfig, ...);
|
||||
|
||||
if (config.has('optionalFeature.detail')) {
|
||||
const detail = config.get('optionalFeature.detail');
|
||||
//...
|
||||
}
|
||||
```
|
||||
|
||||
`config.get()` will throw an exception for undefined keys to help catch typos and missing values.
|
||||
Use `config.has()` to test if a configuration value is defined.
|
||||
|
||||
**Start your app server:**
|
||||
|
||||
```shell
|
||||
$ export NODE_ENV=production
|
||||
$ node my-app.js
|
||||
```
|
||||
|
||||
Running in this configuration, the `port` and `dbName` elements of `dbConfig`
|
||||
will come from the `default.json` file, and the `host` element will
|
||||
come from the `production.json` override file.
|
||||
|
||||
Articles
|
||||
--------
|
||||
|
||||
* [Configuration Files](https://github.com/node-config/node-config/wiki/Configuration-Files)
|
||||
* [Special features for JavaScript configuration files](https://github.com/node-config/node-config/wiki/Special-features-for-JavaScript-configuration-files)
|
||||
* [Common Usage](https://github.com/node-config/node-config/wiki/Common-Usage)
|
||||
* [Environment Variables](https://github.com/node-config/node-config/wiki/Environment-Variables)
|
||||
* [Reserved Words](https://github.com/node-config/node-config/wiki/Reserved-Words)
|
||||
* [Command Line Overrides](https://github.com/node-config/node-config/wiki/Command-Line-Overrides)
|
||||
* [Multiple Node Instances](https://github.com/node-config/node-config/wiki/Multiple-Node-Instances)
|
||||
* [Sub-Module Configuration](https://github.com/node-config/node-config/wiki/Sub-Module-Configuration)
|
||||
* [Configuring from a DB / External Source](https://github.com/node-config/node-config/wiki/Configuring-from-an-External-Source)
|
||||
* [Securing Production Config Files](https://github.com/node-config/node-config/wiki/Securing-Production-Config-Files)
|
||||
* [External Configuration Management Tools](https://github.com/node-config/node-config/wiki/External-Configuration-Management-Tools)
|
||||
* [Examining Configuration Sources](https://github.com/node-config/node-config/wiki/Examining-Configuration-Sources)
|
||||
* [Using Config Utilities](https://github.com/node-config/node-config/wiki/Using-Config-Utilities)
|
||||
* [Upgrading from Config 0.x](https://github.com/node-config/node-config/wiki/Upgrading-From-Config-0.x)
|
||||
* [Webpack usage](https://github.com/node-config/node-config/wiki/Webpack-Usage)
|
||||
|
||||
Further Information
|
||||
---------------------
|
||||
If you still don't see what you are looking for, here are some more resources to check:
|
||||
|
||||
* The [wiki may have more pages](https://github.com/node-config/node-config/wiki) which are not directly linked from here.
|
||||
* Review [questions tagged with node-config](https://stackexchange.com/filters/207096/node-config) on StackExchange. These are monitored by `node-config` contributors.
|
||||
* [Search the issue tracker](https://github.com/node-config/node-config/issues). Hundreds of issues have already been discussed and resolved there.
|
||||
|
||||
Contributors
|
||||
------------
|
||||
<table id="contributors"><tr><td><img src=https://avatars.githubusercontent.com/u/373538?v=4><a href="https://github.com/lorenwest">lorenwest</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/25829?v=4><a href="https://github.com/markstos">markstos</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/1083065?v=4><a href="https://github.com/iMoses">iMoses</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/447151?v=4><a href="https://github.com/elliotttf">elliotttf</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/8839447?v=4><a href="https://github.com/jfelege">jfelege</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/66902?v=4><a href="https://github.com/leachiM2k">leachiM2k</a></td>
|
||||
</tr><tr><td><img src=https://avatars.githubusercontent.com/u/791137?v=4><a href="https://github.com/josx">josx</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/133277?v=4><a href="https://github.com/enyo">enyo</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/4307697?v=4><a href="https://github.com/leosuncin">leosuncin</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/1077378?v=4><a href="https://github.com/arthanzel">arthanzel</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/1656140?v=4><a href="https://github.com/eheikes">eheikes</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/138707?v=4><a href="https://github.com/th507">th507</a></td>
|
||||
</tr><tr><td><img src=https://avatars.githubusercontent.com/u/506460?v=4><a href="https://github.com/Osterjour">Osterjour</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/1751645?v=4><a href="https://github.com/cunneen">cunneen</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/842998?v=4><a href="https://github.com/nsabovic">nsabovic</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/5138570?v=4><a href="https://github.com/BadgerBadgerBadgerBadger">BadgerBadgerBadgerBadger</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/2529835?v=4><a href="https://github.com/simon-scherzinger">simon-scherzinger</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/8650543?v=4><a href="https://github.com/leonardovillela">leonardovillela</a></td>
|
||||
</tr><tr><td><img src=https://avatars.githubusercontent.com/u/175627?v=4><a href="https://github.com/axelhzf">axelhzf</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/7782055?v=4><a href="https://github.com/benkroeger">benkroeger</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/1872824?v=4><a href="https://github.com/fgheorghe">fgheorghe</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/1443067?v=4><a href="https://github.com/IvanVergiliev">IvanVergiliev</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/1736957?v=4><a href="https://github.com/jpwilliams">jpwilliams</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/1246875?v=4><a href="https://github.com/jaylynch">jaylynch</a></td>
|
||||
</tr><tr><td><img src=https://avatars.githubusercontent.com/u/145742?v=4><a href="https://github.com/jberrisch">jberrisch</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/9355665?v=4><a href="https://github.com/kgoerlitz">kgoerlitz</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/8525267?v=4><a href="https://github.com/bertho-zero">bertho-zero</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/6686044?v=4><a href="https://github.com/NguyenMatthieu">NguyenMatthieu</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/1918551?v=4><a href="https://github.com/nitzan-shaked">nitzan-shaked</a></td>
|
||||
<td><img src=https://avatars.githubusercontent.com/u/3058150?v=4><a href="https://github.com/robertrossmann">robertrossmann</a></td>
|
||||
</tr></table>
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
May be freely distributed under the [MIT license](https://raw.githubusercontent.com/node-config/node-config/master/LICENSE).
|
||||
|
||||
Copyright (c) 2010-2022 Loren West
|
||||
[and other contributors](https://github.com/node-config/node-config/graphs/contributors)
|
||||
|
||||
70
node_modules/config/async.js
generated
vendored
Normal file
70
node_modules/config/async.js
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
var asyncSymbol = Symbol('asyncSymbol');
|
||||
var deferConfig = require('./defer').deferConfig;
|
||||
|
||||
/**
|
||||
* @param promiseOrFunc the promise will determine a property's value once resolved
|
||||
* can also be a function to defer which resolves to a promise
|
||||
* @returns {Promise} a marked promise to be resolve later using `resolveAsyncConfigs`
|
||||
*/
|
||||
function asyncConfig(promiseOrFunc) {
|
||||
if (typeof promiseOrFunc === 'function') { // also acts as deferConfig
|
||||
return deferConfig(function (config, original) {
|
||||
var release;
|
||||
function registerRelease(resolve) { release = resolve; }
|
||||
function callFunc() { return promiseOrFunc.call(config, config, original); }
|
||||
var promise = asyncConfig(new Promise(registerRelease).then(callFunc));
|
||||
promise.release = release;
|
||||
return promise;
|
||||
});
|
||||
}
|
||||
var promise = promiseOrFunc;
|
||||
promise.async = asyncSymbol;
|
||||
promise.prepare = function(config, prop, property) {
|
||||
if (promise.release) {
|
||||
promise.release();
|
||||
}
|
||||
return function() {
|
||||
return promise.then(function(value) {
|
||||
Object.defineProperty(prop, property, {value: value});
|
||||
});
|
||||
};
|
||||
};
|
||||
return promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not use `config.get` before executing this method, it will freeze the config object
|
||||
* @param config the main config object, returned from require('config')
|
||||
* @returns {Promise<config>} once all promises are resolved, return the original config object
|
||||
*/
|
||||
function resolveAsyncConfigs(config) {
|
||||
var promises = [];
|
||||
var resolvers = [];
|
||||
(function iterate(prop) {
|
||||
var propsToSort = [];
|
||||
for (var property in prop) {
|
||||
if (Object.hasOwnProperty.call(prop, property) && prop[property] != null) {
|
||||
propsToSort.push(property);
|
||||
}
|
||||
}
|
||||
propsToSort.sort().forEach(function(property) {
|
||||
if (prop[property].constructor === Object) {
|
||||
iterate(prop[property]);
|
||||
}
|
||||
else if (prop[property].constructor === Array) {
|
||||
prop[property].forEach(iterate);
|
||||
}
|
||||
else if (prop[property] && prop[property].async === asyncSymbol) {
|
||||
resolvers.push(prop[property].prepare(config, prop, property));
|
||||
promises.push(prop[property]);
|
||||
}
|
||||
});
|
||||
})(config);
|
||||
return Promise.all(promises).then(function() {
|
||||
resolvers.forEach(function(resolve) { resolve(); });
|
||||
return config;
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.asyncConfig = asyncConfig;
|
||||
module.exports.resolveAsyncConfigs = resolveAsyncConfigs;
|
||||
23
node_modules/config/defer.js
generated
vendored
Normal file
23
node_modules/config/defer.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
// Create a deferredConfig prototype so that we can check for it when reviewing the configs later.
|
||||
function DeferredConfig() {}
|
||||
DeferredConfig.prototype.prepare = function() {};
|
||||
DeferredConfig.prototype.resolve = function() {};
|
||||
|
||||
// Accept a function that we'll use to resolve this value later and return a 'deferred' configuration value to resolve it later.
|
||||
function deferConfig(func) {
|
||||
var obj = Object.create(DeferredConfig.prototype);
|
||||
obj.prepare = function(config, prop, property) {
|
||||
var original = prop[property]._original;
|
||||
obj.resolve = function() {
|
||||
var value = func.call(config, config, original);
|
||||
Object.defineProperty(prop, property, {value: value});
|
||||
return value;
|
||||
};
|
||||
Object.defineProperty(prop, property, {get: function() { return obj.resolve(); }});
|
||||
return obj;
|
||||
};
|
||||
return obj;
|
||||
}
|
||||
|
||||
module.exports.deferConfig = deferConfig;
|
||||
module.exports.DeferredConfig = DeferredConfig;
|
||||
1521
node_modules/config/lib/config.js
generated
vendored
Normal file
1521
node_modules/config/lib/config.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
52
node_modules/config/package.json
generated
vendored
Normal file
52
node_modules/config/package.json
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"name": "config",
|
||||
"version": "3.3.9",
|
||||
"main": "./lib/config.js",
|
||||
"description": "Configuration control for production node deployments",
|
||||
"author": "Loren West <open_source@lorenwest.com>",
|
||||
"homepage": "http://github.com/node-config/node-config.git",
|
||||
"publishConfig": {
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"keywords": [
|
||||
"conf",
|
||||
"config",
|
||||
"configuration",
|
||||
"node-config",
|
||||
"config-node",
|
||||
"env",
|
||||
"environment"
|
||||
],
|
||||
"directories": {
|
||||
"lib": "./lib"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"json5": "^2.2.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^7.0.8",
|
||||
"coffeescript": "2.2.4",
|
||||
"cson": "^3.0.1",
|
||||
"hjson": "^1.2.0",
|
||||
"js-yaml": "^3.2.2",
|
||||
"properties": "~1.2.1",
|
||||
"semver": "5.3.0",
|
||||
"toml": "^2.0.6",
|
||||
"ts-node": "^3.3.0",
|
||||
"typescript": "^2.4.2",
|
||||
"underscore": "^1.8.3",
|
||||
"vows": ">=0.8.1",
|
||||
"x2js": "^2.0.1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://github.com/node-config/node-config.git"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "./node_modules/vows/bin/vows test/*.js --spec"
|
||||
}
|
||||
}
|
||||
368
node_modules/config/parser.js
generated
vendored
Normal file
368
node_modules/config/parser.js
generated
vendored
Normal file
@@ -0,0 +1,368 @@
|
||||
// External libraries are lazy-loaded only if these file types exist.
|
||||
const util = require("util");
|
||||
var Yaml = null,
|
||||
VisionmediaYaml = null,
|
||||
Coffee = null,
|
||||
Iced = null,
|
||||
CSON = null,
|
||||
PPARSER = null,
|
||||
JSON5 = null,
|
||||
TOML = null,
|
||||
HJSON = null,
|
||||
XML = null;
|
||||
|
||||
// Define soft dependencies so transpilers don't include everything
|
||||
var COFFEE_2_DEP = 'coffeescript',
|
||||
COFFEE_DEP = 'coffee-script',
|
||||
ICED_DEP = 'iced-coffee-script',
|
||||
JS_YAML_DEP = 'js-yaml',
|
||||
YAML_DEP = 'yaml',
|
||||
JSON5_DEP = 'json5',
|
||||
HJSON_DEP = 'hjson',
|
||||
TOML_DEP = 'toml',
|
||||
CSON_DEP = 'cson',
|
||||
PPARSER_DEP = 'properties',
|
||||
XML_DEP = 'x2js',
|
||||
TS_DEP = 'ts-node';
|
||||
|
||||
var Parser = module.exports;
|
||||
|
||||
Parser.parse = function(filename, content) {
|
||||
var parserName = filename.substr(filename.lastIndexOf('.') +1); // file extension
|
||||
if (typeof definitions[parserName] === 'function') {
|
||||
return definitions[parserName](filename, content);
|
||||
}
|
||||
// TODO: decide what to do in case of a missing parser
|
||||
};
|
||||
|
||||
Parser.xmlParser = function(filename, content) {
|
||||
if (!XML) {
|
||||
XML = require(XML_DEP);
|
||||
}
|
||||
var x2js = new XML();
|
||||
var configObject = x2js.xml2js(content);
|
||||
var rootKeys = Object.keys(configObject);
|
||||
if(rootKeys.length === 1) {
|
||||
return configObject[rootKeys[0]];
|
||||
}
|
||||
return configObject;
|
||||
};
|
||||
|
||||
Parser.jsParser = function(filename, content) {
|
||||
var configObject = require(filename);
|
||||
|
||||
if (configObject.__esModule && util.isObject(configObject.default)) {
|
||||
return configObject.default
|
||||
}
|
||||
return configObject;
|
||||
};
|
||||
|
||||
Parser.tsParser = function(filename, content) {
|
||||
if (!require.extensions['.ts']) {
|
||||
require(TS_DEP).register({
|
||||
lazy: true,
|
||||
transpileOnly: true,
|
||||
compilerOptions: {
|
||||
allowJs: true,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Imports config if it is exported via module.exports = ...
|
||||
// See https://github.com/node-config/node-config/issues/524
|
||||
var configObject = require(filename);
|
||||
|
||||
// Because of ES6 modules usage, `default` is treated as named export (like any other)
|
||||
// Therefore config is a value of `default` key.
|
||||
if (configObject.default) {
|
||||
return configObject.default
|
||||
}
|
||||
return configObject;
|
||||
};
|
||||
|
||||
Parser.coffeeParser = function(filename, content) {
|
||||
// .coffee files can be loaded with either coffee-script or iced-coffee-script.
|
||||
// Prefer iced-coffee-script, if it exists.
|
||||
// Lazy load the appropriate extension
|
||||
if (!Coffee) {
|
||||
Coffee = {};
|
||||
|
||||
// The following enables iced-coffee-script on .coffee files, if iced-coffee-script is available.
|
||||
// This is commented as per a decision on a pull request.
|
||||
//try {
|
||||
// Coffee = require('iced-coffee-script');
|
||||
//}
|
||||
//catch (e) {
|
||||
// Coffee = require('coffee-script');
|
||||
//}
|
||||
try {
|
||||
// Try to load coffeescript
|
||||
Coffee = require(COFFEE_2_DEP);
|
||||
}
|
||||
catch (e) {
|
||||
// If it doesn't exist, try to load it using the deprecated module name
|
||||
Coffee = require(COFFEE_DEP);
|
||||
}
|
||||
// coffee-script >= 1.7.0 requires explicit registration for require() to work
|
||||
if (Coffee.register) {
|
||||
Coffee.register();
|
||||
}
|
||||
}
|
||||
// Use the built-in parser for .coffee files with coffee-script
|
||||
return require(filename);
|
||||
};
|
||||
|
||||
Parser.icedParser = function(filename, content) {
|
||||
Iced = require(ICED_DEP);
|
||||
|
||||
// coffee-script >= 1.7.0 requires explicit registration for require() to work
|
||||
if (Iced.register) {
|
||||
Iced.register();
|
||||
}
|
||||
};
|
||||
|
||||
Parser.yamlParser = function(filename, content) {
|
||||
if (!Yaml && !VisionmediaYaml) {
|
||||
// Lazy loading
|
||||
try {
|
||||
// Try to load the better js-yaml module
|
||||
Yaml = require(JS_YAML_DEP);
|
||||
}
|
||||
catch (e) {
|
||||
try {
|
||||
// If it doesn't exist, load the fallback visionmedia yaml module.
|
||||
VisionmediaYaml = require(YAML_DEP);
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
}
|
||||
if (Yaml) {
|
||||
return Yaml.load(content);
|
||||
}
|
||||
else if (VisionmediaYaml) {
|
||||
// The yaml library doesn't like strings that have newlines but don't
|
||||
// end in a newline: https://github.com/visionmedia/js-yaml/issues/issue/13
|
||||
content += '\n';
|
||||
if (typeof VisionmediaYaml.eval === 'function') {
|
||||
return VisionmediaYaml.eval(Parser.stripYamlComments(content));
|
||||
}
|
||||
return VisionmediaYaml.parse(Parser.stripYamlComments(content));
|
||||
}
|
||||
else {
|
||||
console.error('No YAML parser loaded. Suggest adding js-yaml dependency to your package.json file.')
|
||||
}
|
||||
};
|
||||
|
||||
Parser.jsonParser = function(filename, content) {
|
||||
try {
|
||||
return JSON.parse(content);
|
||||
}
|
||||
catch (e) {
|
||||
// All JS Style comments will begin with /, so all JSON parse errors that
|
||||
// encountered a syntax error will complain about this character.
|
||||
if (e.name !== 'SyntaxError' || e.message.indexOf('Unexpected token /') !== 0) {
|
||||
throw e;
|
||||
}
|
||||
if (!JSON5) {
|
||||
JSON5 = require(JSON5_DEP);
|
||||
}
|
||||
return JSON5.parse(content);
|
||||
}
|
||||
};
|
||||
|
||||
Parser.json5Parser = function(filename, content) {
|
||||
if (!JSON5) {
|
||||
JSON5 = require(JSON5_DEP);
|
||||
}
|
||||
return JSON5.parse(content);
|
||||
};
|
||||
|
||||
Parser.hjsonParser = function(filename, content) {
|
||||
if (!HJSON) {
|
||||
HJSON = require(HJSON_DEP);
|
||||
}
|
||||
return HJSON.parse(content);
|
||||
};
|
||||
|
||||
Parser.tomlParser = function(filename, content) {
|
||||
if(!TOML) {
|
||||
TOML = require(TOML_DEP);
|
||||
}
|
||||
return TOML.parse(content);
|
||||
};
|
||||
|
||||
Parser.csonParser = function(filename, content) {
|
||||
if (!CSON) {
|
||||
CSON = require(CSON_DEP);
|
||||
}
|
||||
// Allow comments in CSON files
|
||||
if (typeof CSON.parseSync === 'function') {
|
||||
return CSON.parseSync(Parser.stripComments(content));
|
||||
}
|
||||
return CSON.parse(Parser.stripComments(content));
|
||||
};
|
||||
|
||||
Parser.propertiesParser = function(filename, content) {
|
||||
if (!PPARSER) {
|
||||
PPARSER = require(PPARSER_DEP);
|
||||
}
|
||||
return PPARSER.parse(content, { namespaces: true, variables: true, sections: true });
|
||||
};
|
||||
|
||||
/**
|
||||
* Strip all Javascript type comments from the string.
|
||||
*
|
||||
* The string is usually a file loaded from the O/S, containing
|
||||
* newlines and javascript type comments.
|
||||
*
|
||||
* Thanks to James Padolsey, and all who contributed to this implementation.
|
||||
* http://james.padolsey.com/javascript/javascript-comment-removal-revisted/
|
||||
*
|
||||
* @protected
|
||||
* @method stripComments
|
||||
* @param fileStr {string} The string to strip comments from
|
||||
* @param stringRegex {RegExp} Optional regular expression to match strings that
|
||||
* make up the config file
|
||||
* @return {string} The string with comments stripped.
|
||||
*/
|
||||
Parser.stripComments = function(fileStr, stringRegex) {
|
||||
stringRegex = stringRegex || /(['"])(\\\1|.)+?\1/g;
|
||||
|
||||
var uid = '_' + +new Date(),
|
||||
primitives = [],
|
||||
primIndex = 0;
|
||||
|
||||
return (
|
||||
fileStr
|
||||
|
||||
/* Remove strings */
|
||||
.replace(stringRegex, function(match){
|
||||
primitives[primIndex] = match;
|
||||
return (uid + '') + primIndex++;
|
||||
})
|
||||
|
||||
/* Remove Regexes */
|
||||
.replace(/([^\/])(\/(?!\*|\/)(\\\/|.)+?\/[gim]{0,3})/g, function(match, $1, $2){
|
||||
primitives[primIndex] = $2;
|
||||
return $1 + (uid + '') + primIndex++;
|
||||
})
|
||||
|
||||
/*
|
||||
- Remove single-line comments that contain would-be multi-line delimiters
|
||||
E.g. // Comment /* <--
|
||||
- Remove multi-line comments that contain would be single-line delimiters
|
||||
E.g. /* // <--
|
||||
*/
|
||||
.replace(/\/\/.*?\/?\*.+?(?=\n|\r|$)|\/\*[\s\S]*?\/\/[\s\S]*?\*\//g, '')
|
||||
|
||||
/*
|
||||
Remove single and multi-line comments,
|
||||
no consideration of inner-contents
|
||||
*/
|
||||
.replace(/\/\/.+?(?=\n|\r|$)|\/\*[\s\S]+?\*\//g, '')
|
||||
|
||||
/*
|
||||
Remove multi-line comments that have a replaced ending (string/regex)
|
||||
Greedy, so no inner strings/regexes will stop it.
|
||||
*/
|
||||
.replace(RegExp('\\/\\*[\\s\\S]+' + uid + '\\d+', 'g'), '')
|
||||
|
||||
/* Bring back strings & regexes */
|
||||
.replace(RegExp(uid + '(\\d+)', 'g'), function(match, n){
|
||||
return primitives[n];
|
||||
})
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Strip YAML comments from the string
|
||||
*
|
||||
* The 2.0 yaml parser doesn't allow comment-only or blank lines. Strip them.
|
||||
*
|
||||
* @protected
|
||||
* @method stripYamlComments
|
||||
* @param fileStr {string} The string to strip comments from
|
||||
* @return {string} The string with comments stripped.
|
||||
*/
|
||||
Parser.stripYamlComments = function(fileStr) {
|
||||
// First replace removes comment-only lines
|
||||
// Second replace removes blank lines
|
||||
return fileStr.replace(/^\s*#.*/mg,'').replace(/^\s*[\n|\r]+/mg,'');
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses the environment variable to the boolean equivalent.
|
||||
* Defaults to false
|
||||
*
|
||||
* @param {String} content - Environment variable value
|
||||
* @return {boolean} - Boolean value fo the passed variable value
|
||||
*/
|
||||
Parser.booleanParser = function(filename, content) {
|
||||
return content === 'true';
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses the environment variable to the number equivalent.
|
||||
* Defaults to undefined
|
||||
*
|
||||
* @param {String} content - Environment variable value
|
||||
* @return {Number} - Number value fo the passed variable value
|
||||
*/
|
||||
Parser.numberParser = function(filename, content) {
|
||||
const numberValue = Number(content);
|
||||
return Number.isNaN(numberValue) ? undefined : numberValue;
|
||||
};
|
||||
|
||||
var order = ['js', 'cjs', 'ts', 'json', 'json5', 'hjson', 'toml', 'coffee', 'iced', 'yaml', 'yml', 'cson', 'properties', 'xml',
|
||||
'boolean', 'number'];
|
||||
var definitions = {
|
||||
cjs: Parser.jsParser,
|
||||
coffee: Parser.coffeeParser,
|
||||
cson: Parser.csonParser,
|
||||
hjson: Parser.hjsonParser,
|
||||
iced: Parser.icedParser,
|
||||
js: Parser.jsParser,
|
||||
json: Parser.jsonParser,
|
||||
json5: Parser.json5Parser,
|
||||
properties: Parser.propertiesParser,
|
||||
toml: Parser.tomlParser,
|
||||
ts: Parser.tsParser,
|
||||
xml: Parser.xmlParser,
|
||||
yaml: Parser.yamlParser,
|
||||
yml: Parser.yamlParser,
|
||||
boolean: Parser.booleanParser,
|
||||
number: Parser.numberParser
|
||||
};
|
||||
|
||||
Parser.getParser = function(name) {
|
||||
return definitions[name];
|
||||
};
|
||||
|
||||
Parser.setParser = function(name, parser) {
|
||||
definitions[name] = parser;
|
||||
if (order.indexOf(name) === -1) {
|
||||
order.push(name);
|
||||
}
|
||||
};
|
||||
|
||||
Parser.getFilesOrder = function(name) {
|
||||
if (name) {
|
||||
return order.indexOf(name);
|
||||
}
|
||||
return order;
|
||||
};
|
||||
|
||||
Parser.setFilesOrder = function(name, newIndex) {
|
||||
if (Array.isArray(name)) {
|
||||
return order = name;
|
||||
}
|
||||
if (typeof newIndex === 'number') {
|
||||
var index = order.indexOf(name);
|
||||
order.splice(newIndex, 0, name);
|
||||
if (index > -1) {
|
||||
order.splice(index >= newIndex ? index +1 : index, 1);
|
||||
}
|
||||
}
|
||||
return order;
|
||||
};
|
||||
15
node_modules/config/raw.js
generated
vendored
Normal file
15
node_modules/config/raw.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* This is meant to wrap configuration objects that should be left as is,
|
||||
* meaning that the object or its prototype will not be modified in any way
|
||||
*/
|
||||
function RawConfig () {
|
||||
}
|
||||
|
||||
function raw(rawObj) {
|
||||
var obj = Object.create(RawConfig.prototype);
|
||||
obj.resolve = function () { return rawObj; }
|
||||
return obj;
|
||||
}
|
||||
|
||||
module.exports.RawConfig = RawConfig;
|
||||
module.exports.raw = raw;
|
||||
23
node_modules/json5/LICENSE.md
generated
vendored
Normal file
23
node_modules/json5/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2012-2018 Aseem Kishore, and [others].
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
[others]: https://github.com/json5/json5/contributors
|
||||
282
node_modules/json5/README.md
generated
vendored
Normal file
282
node_modules/json5/README.md
generated
vendored
Normal file
@@ -0,0 +1,282 @@
|
||||
# JSON5 – JSON for Humans
|
||||
|
||||
[][Build
|
||||
Status] [][Coverage
|
||||
Status]
|
||||
|
||||
JSON5 is an extension to the popular [JSON] file format that aims to be
|
||||
easier to **write and maintain _by hand_ (e.g. for config files)**.
|
||||
It is _not intended_ to be used for machine-to-machine communication.
|
||||
(Keep using JSON or other file formats for that. 🙂)
|
||||
|
||||
JSON5 was started in 2012, and as of 2022, now gets **[>65M downloads/week](https://www.npmjs.com/package/json5)**,
|
||||
ranks in the **[top 0.1%](https://gist.github.com/anvaka/8e8fa57c7ee1350e3491)** of the most depended-upon packages on npm,
|
||||
and has been adopted by major projects like
|
||||
**[Chromium](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/runtime_enabled_features.json5;drc=5de823b36e68fd99009a29281b17bc3a1d6b329c),
|
||||
[Next.js](https://github.com/vercel/next.js/blob/b88f20c90bf4659b8ad5cb2a27956005eac2c7e8/packages/next/lib/find-config.ts#L43-L46),
|
||||
[Babel](https://babeljs.io/docs/en/config-files#supported-file-extensions),
|
||||
[Retool](https://community.retool.com/t/i-am-attempting-to-append-several-text-fields-to-a-google-sheet-but-receiving-a-json5-invalid-character-error/7626),
|
||||
[WebStorm](https://www.jetbrains.com/help/webstorm/json.html),
|
||||
and [more](https://github.com/json5/json5/wiki/In-the-Wild)**.
|
||||
It's also natively supported on **[Apple platforms](https://developer.apple.com/documentation/foundation/jsondecoder/3766916-allowsjson5)**
|
||||
like **MacOS** and **iOS**.
|
||||
|
||||
Formally, the **[JSON5 Data Interchange Format](https://spec.json5.org/)** is a superset of JSON
|
||||
(so valid JSON files will always be valid JSON5 files)
|
||||
that expands its syntax to include some productions from [ECMAScript 5.1] (ES5).
|
||||
It's also a strict _subset_ of ES5, so valid JSON5 files will always be valid ES5.
|
||||
|
||||
This JavaScript library is a reference implementation for JSON5 parsing and serialization,
|
||||
and is directly used in many of the popular projects mentioned above
|
||||
(where e.g. extreme performance isn't necessary),
|
||||
but others have created [many other libraries](https://github.com/json5/json5/wiki/In-the-Wild)
|
||||
across many other platforms.
|
||||
|
||||
[Build Status]: https://app.travis-ci.com/json5/json5
|
||||
|
||||
[Coverage Status]: https://coveralls.io/github/json5/json5
|
||||
|
||||
[JSON]: https://tools.ietf.org/html/rfc7159
|
||||
|
||||
[ECMAScript 5.1]: https://www.ecma-international.org/ecma-262/5.1/
|
||||
|
||||
## Summary of Features
|
||||
The following ECMAScript 5.1 features, which are not supported in JSON, have
|
||||
been extended to JSON5.
|
||||
|
||||
### Objects
|
||||
- Object keys may be an ECMAScript 5.1 _[IdentifierName]_.
|
||||
- Objects may have a single trailing comma.
|
||||
|
||||
### Arrays
|
||||
- Arrays may have a single trailing comma.
|
||||
|
||||
### Strings
|
||||
- Strings may be single quoted.
|
||||
- Strings may span multiple lines by escaping new line characters.
|
||||
- Strings may include character escapes.
|
||||
|
||||
### Numbers
|
||||
- Numbers may be hexadecimal.
|
||||
- Numbers may have a leading or trailing decimal point.
|
||||
- Numbers may be [IEEE 754] positive infinity, negative infinity, and NaN.
|
||||
- Numbers may begin with an explicit plus sign.
|
||||
|
||||
### Comments
|
||||
- Single and multi-line comments are allowed.
|
||||
|
||||
### White Space
|
||||
- Additional white space characters are allowed.
|
||||
|
||||
[IdentifierName]: https://www.ecma-international.org/ecma-262/5.1/#sec-7.6
|
||||
|
||||
[IEEE 754]: http://ieeexplore.ieee.org/servlet/opac?punumber=4610933
|
||||
|
||||
## Example
|
||||
Kitchen-sink example:
|
||||
|
||||
```js
|
||||
{
|
||||
// comments
|
||||
unquoted: 'and you can quote me on that',
|
||||
singleQuotes: 'I can use "double quotes" here',
|
||||
lineBreaks: "Look, Mom! \
|
||||
No \\n's!",
|
||||
hexadecimal: 0xdecaf,
|
||||
leadingDecimalPoint: .8675309, andTrailing: 8675309.,
|
||||
positiveSign: +1,
|
||||
trailingComma: 'in objects', andIn: ['arrays',],
|
||||
"backwardsCompatible": "with JSON",
|
||||
}
|
||||
```
|
||||
|
||||
A more real-world example is [this config file](https://github.com/chromium/chromium/blob/feb3c9f670515edf9a88f185301cbd7794ee3e52/third_party/blink/renderer/platform/runtime_enabled_features.json5)
|
||||
from the Chromium/Blink project.
|
||||
|
||||
## Specification
|
||||
For a detailed explanation of the JSON5 format, please read the [official
|
||||
specification](https://json5.github.io/json5-spec/).
|
||||
|
||||
## Installation and Usage
|
||||
### Node.js
|
||||
```sh
|
||||
npm install json5
|
||||
```
|
||||
|
||||
#### CommonJS
|
||||
```js
|
||||
const JSON5 = require('json5')
|
||||
```
|
||||
|
||||
#### Modules
|
||||
```js
|
||||
import JSON5 from 'json5'
|
||||
```
|
||||
|
||||
### Browsers
|
||||
#### UMD
|
||||
```html
|
||||
<!-- This will create a global `JSON5` variable. -->
|
||||
<script src="https://unpkg.com/json5@2/dist/index.min.js"></script>
|
||||
```
|
||||
|
||||
#### Modules
|
||||
```html
|
||||
<script type="module">
|
||||
import JSON5 from 'https://unpkg.com/json5@2/dist/index.min.mjs'
|
||||
</script>
|
||||
```
|
||||
|
||||
## API
|
||||
The JSON5 API is compatible with the [JSON API].
|
||||
|
||||
[JSON API]:
|
||||
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON
|
||||
|
||||
### JSON5.parse()
|
||||
Parses a JSON5 string, constructing the JavaScript value or object described by
|
||||
the string. An optional reviver function can be provided to perform a
|
||||
transformation on the resulting object before it is returned.
|
||||
|
||||
#### Syntax
|
||||
JSON5.parse(text[, reviver])
|
||||
|
||||
#### Parameters
|
||||
- `text`: The string to parse as JSON5.
|
||||
- `reviver`: If a function, this prescribes how the value originally produced by
|
||||
parsing is transformed, before being returned.
|
||||
|
||||
#### Return value
|
||||
The object corresponding to the given JSON5 text.
|
||||
|
||||
### JSON5.stringify()
|
||||
Converts a JavaScript value to a JSON5 string, optionally replacing values if a
|
||||
replacer function is specified, or optionally including only the specified
|
||||
properties if a replacer array is specified.
|
||||
|
||||
#### Syntax
|
||||
JSON5.stringify(value[, replacer[, space]])
|
||||
JSON5.stringify(value[, options])
|
||||
|
||||
#### Parameters
|
||||
- `value`: The value to convert to a JSON5 string.
|
||||
- `replacer`: A function that alters the behavior of the stringification
|
||||
process, or an array of String and Number objects that serve as a whitelist
|
||||
for selecting/filtering the properties of the value object to be included in
|
||||
the JSON5 string. If this value is null or not provided, all properties of the
|
||||
object are included in the resulting JSON5 string.
|
||||
- `space`: A String or Number object that's used to insert white space into the
|
||||
output JSON5 string for readability purposes. If this is a Number, it
|
||||
indicates the number of space characters to use as white space; this number is
|
||||
capped at 10 (if it is greater, the value is just 10). Values less than 1
|
||||
indicate that no space should be used. If this is a String, the string (or the
|
||||
first 10 characters of the string, if it's longer than that) is used as white
|
||||
space. If this parameter is not provided (or is null), no white space is used.
|
||||
If white space is used, trailing commas will be used in objects and arrays.
|
||||
- `options`: An object with the following properties:
|
||||
- `replacer`: Same as the `replacer` parameter.
|
||||
- `space`: Same as the `space` parameter.
|
||||
- `quote`: A String representing the quote character to use when serializing
|
||||
strings.
|
||||
|
||||
#### Return value
|
||||
A JSON5 string representing the value.
|
||||
|
||||
### Node.js `require()` JSON5 files
|
||||
When using Node.js, you can `require()` JSON5 files by adding the following
|
||||
statement.
|
||||
|
||||
```js
|
||||
require('json5/lib/register')
|
||||
```
|
||||
|
||||
Then you can load a JSON5 file with a Node.js `require()` statement. For
|
||||
example:
|
||||
|
||||
```js
|
||||
const config = require('./config.json5')
|
||||
```
|
||||
|
||||
## CLI
|
||||
Since JSON is more widely used than JSON5, this package includes a CLI for
|
||||
converting JSON5 to JSON and for validating the syntax of JSON5 documents.
|
||||
|
||||
### Installation
|
||||
```sh
|
||||
npm install --global json5
|
||||
```
|
||||
|
||||
### Usage
|
||||
```sh
|
||||
json5 [options] <file>
|
||||
```
|
||||
|
||||
If `<file>` is not provided, then STDIN is used.
|
||||
|
||||
#### Options:
|
||||
- `-s`, `--space`: The number of spaces to indent or `t` for tabs
|
||||
- `-o`, `--out-file [file]`: Output to the specified file, otherwise STDOUT
|
||||
- `-v`, `--validate`: Validate JSON5 but do not output JSON
|
||||
- `-V`, `--version`: Output the version number
|
||||
- `-h`, `--help`: Output usage information
|
||||
|
||||
## Contributing
|
||||
### Development
|
||||
```sh
|
||||
git clone https://github.com/json5/json5
|
||||
cd json5
|
||||
npm install
|
||||
```
|
||||
|
||||
When contributing code, please write relevant tests and run `npm test` and `npm
|
||||
run lint` before submitting pull requests. Please use an editor that supports
|
||||
[EditorConfig](http://editorconfig.org/).
|
||||
|
||||
### Issues
|
||||
To report bugs or request features regarding the JSON5 **data format**,
|
||||
please submit an issue to the official
|
||||
**[_specification_ repository](https://github.com/json5/json5-spec)**.
|
||||
|
||||
Note that we will never add any features that make JSON5 incompatible with ES5;
|
||||
that compatibility is a fundamental premise of JSON5.
|
||||
|
||||
To report bugs or request features regarding this **JavaScript implementation**
|
||||
of JSON5, please submit an issue to **_this_ repository**.
|
||||
|
||||
### Security Vulnerabilities and Disclosures
|
||||
To report a security vulnerability, please follow the follow the guidelines
|
||||
described in our [security policy](./SECURITY.md).
|
||||
|
||||
## License
|
||||
MIT. See [LICENSE.md](./LICENSE.md) for details.
|
||||
|
||||
## Credits
|
||||
[Aseem Kishore](https://github.com/aseemk) founded this project.
|
||||
He wrote a [blog post](https://aseemk.substack.com/p/ignore-the-f-ing-haters-json5)
|
||||
about the journey and lessons learned 10 years in.
|
||||
|
||||
[Michael Bolin](http://bolinfest.com/) independently arrived at and published
|
||||
some of these same ideas with awesome explanations and detail. Recommended
|
||||
reading: [Suggested Improvements to JSON](http://bolinfest.com/essays/json.html)
|
||||
|
||||
[Douglas Crockford](http://www.crockford.com/) of course designed and built
|
||||
JSON, but his state machine diagrams on the [JSON website](http://json.org/), as
|
||||
cheesy as it may sound, gave us motivation and confidence that building a new
|
||||
parser to implement these ideas was within reach! The original
|
||||
implementation of JSON5 was also modeled directly off of Doug’s open-source
|
||||
[json_parse.js] parser. We’re grateful for that clean and well-documented
|
||||
code.
|
||||
|
||||
[json_parse.js]:
|
||||
https://github.com/douglascrockford/JSON-js/blob/03157639c7a7cddd2e9f032537f346f1a87c0f6d/json_parse.js
|
||||
|
||||
[Max Nanasy](https://github.com/MaxNanasy) has been an early and prolific
|
||||
supporter, contributing multiple patches and ideas.
|
||||
|
||||
[Andrew Eisenberg](https://github.com/aeisenberg) contributed the original
|
||||
`stringify` method.
|
||||
|
||||
[Jordan Tucker](https://github.com/jordanbtucker) has aligned JSON5 more closely
|
||||
with ES5, wrote the official JSON5 specification, completely rewrote the
|
||||
codebase from the ground up, and is actively maintaining this project.
|
||||
1737
node_modules/json5/dist/index.js
generated
vendored
Normal file
1737
node_modules/json5/dist/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/json5/dist/index.min.js
generated
vendored
Normal file
1
node_modules/json5/dist/index.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/json5/dist/index.min.mjs
generated
vendored
Normal file
1
node_modules/json5/dist/index.min.mjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1426
node_modules/json5/dist/index.mjs
generated
vendored
Normal file
1426
node_modules/json5/dist/index.mjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
152
node_modules/json5/lib/cli.js
generated
vendored
Normal file
152
node_modules/json5/lib/cli.js
generated
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const pkg = require('../package.json')
|
||||
const JSON5 = require('./')
|
||||
|
||||
const argv = parseArgs()
|
||||
|
||||
if (argv.version) {
|
||||
version()
|
||||
} else if (argv.help) {
|
||||
usage()
|
||||
} else {
|
||||
const inFilename = argv.defaults[0]
|
||||
|
||||
let readStream
|
||||
if (inFilename) {
|
||||
readStream = fs.createReadStream(inFilename)
|
||||
} else {
|
||||
readStream = process.stdin
|
||||
}
|
||||
|
||||
let json5 = ''
|
||||
readStream.on('data', data => {
|
||||
json5 += data
|
||||
})
|
||||
|
||||
readStream.on('end', () => {
|
||||
let space
|
||||
if (argv.space === 't' || argv.space === 'tab') {
|
||||
space = '\t'
|
||||
} else {
|
||||
space = Number(argv.space)
|
||||
}
|
||||
|
||||
let value
|
||||
try {
|
||||
value = JSON5.parse(json5)
|
||||
if (!argv.validate) {
|
||||
const json = JSON.stringify(value, null, space)
|
||||
|
||||
let writeStream
|
||||
|
||||
// --convert is for backward compatibility with v0.5.1. If
|
||||
// specified with <file> and not --out-file, then a file with
|
||||
// the same name but with a .json extension will be written.
|
||||
if (argv.convert && inFilename && !argv.outFile) {
|
||||
const parsedFilename = path.parse(inFilename)
|
||||
const outFilename = path.format(
|
||||
Object.assign(
|
||||
parsedFilename,
|
||||
{base: path.basename(parsedFilename.base, parsedFilename.ext) + '.json'}
|
||||
)
|
||||
)
|
||||
|
||||
writeStream = fs.createWriteStream(outFilename)
|
||||
} else if (argv.outFile) {
|
||||
writeStream = fs.createWriteStream(argv.outFile)
|
||||
} else {
|
||||
writeStream = process.stdout
|
||||
}
|
||||
|
||||
writeStream.write(json)
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err.message)
|
||||
process.exit(1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function parseArgs () {
|
||||
let convert
|
||||
let space
|
||||
let validate
|
||||
let outFile
|
||||
let version
|
||||
let help
|
||||
const defaults = []
|
||||
|
||||
const args = process.argv.slice(2)
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
const arg = args[i]
|
||||
switch (arg) {
|
||||
case '--convert':
|
||||
case '-c':
|
||||
convert = true
|
||||
break
|
||||
|
||||
case '--space':
|
||||
case '-s':
|
||||
space = args[++i]
|
||||
break
|
||||
|
||||
case '--validate':
|
||||
case '-v':
|
||||
validate = true
|
||||
break
|
||||
|
||||
case '--out-file':
|
||||
case '-o':
|
||||
outFile = args[++i]
|
||||
break
|
||||
|
||||
case '--version':
|
||||
case '-V':
|
||||
version = true
|
||||
break
|
||||
|
||||
case '--help':
|
||||
case '-h':
|
||||
help = true
|
||||
break
|
||||
|
||||
default:
|
||||
defaults.push(arg)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
convert,
|
||||
space,
|
||||
validate,
|
||||
outFile,
|
||||
version,
|
||||
help,
|
||||
defaults,
|
||||
}
|
||||
}
|
||||
|
||||
function version () {
|
||||
console.log(pkg.version)
|
||||
}
|
||||
|
||||
function usage () {
|
||||
console.log(
|
||||
`
|
||||
Usage: json5 [options] <file>
|
||||
|
||||
If <file> is not provided, then STDIN is used.
|
||||
|
||||
Options:
|
||||
|
||||
-s, --space The number of spaces to indent or 't' for tabs
|
||||
-o, --out-file [file] Output to the specified file, otherwise STDOUT
|
||||
-v, --validate Validate JSON5 but do not output JSON
|
||||
-V, --version Output the version number
|
||||
-h, --help Output usage information`
|
||||
)
|
||||
}
|
||||
4
node_modules/json5/lib/index.d.ts
generated
vendored
Normal file
4
node_modules/json5/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import parse = require('./parse')
|
||||
import stringify = require('./stringify')
|
||||
|
||||
export {parse, stringify}
|
||||
9
node_modules/json5/lib/index.js
generated
vendored
Normal file
9
node_modules/json5/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
const parse = require('./parse')
|
||||
const stringify = require('./stringify')
|
||||
|
||||
const JSON5 = {
|
||||
parse,
|
||||
stringify,
|
||||
}
|
||||
|
||||
module.exports = JSON5
|
||||
15
node_modules/json5/lib/parse.d.ts
generated
vendored
Normal file
15
node_modules/json5/lib/parse.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Parses a JSON5 string, constructing the JavaScript value or object described
|
||||
* by the string.
|
||||
* @template T The type of the return value.
|
||||
* @param text The string to parse as JSON5.
|
||||
* @param reviver A function that prescribes how the value originally produced
|
||||
* by parsing is transformed before being returned.
|
||||
* @returns The JavaScript value converted from the JSON5 string.
|
||||
*/
|
||||
declare function parse<T = any>(
|
||||
text: string,
|
||||
reviver?: ((this: any, key: string, value: any) => any) | null,
|
||||
): T
|
||||
|
||||
export = parse
|
||||
1114
node_modules/json5/lib/parse.js
generated
vendored
Normal file
1114
node_modules/json5/lib/parse.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
13
node_modules/json5/lib/register.js
generated
vendored
Normal file
13
node_modules/json5/lib/register.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
const fs = require('fs')
|
||||
const JSON5 = require('./')
|
||||
|
||||
// eslint-disable-next-line node/no-deprecated-api
|
||||
require.extensions['.json5'] = function (module, filename) {
|
||||
const content = fs.readFileSync(filename, 'utf8')
|
||||
try {
|
||||
module.exports = JSON5.parse(content)
|
||||
} catch (err) {
|
||||
err.message = filename + ': ' + err.message
|
||||
throw err
|
||||
}
|
||||
}
|
||||
4
node_modules/json5/lib/require.js
generated
vendored
Normal file
4
node_modules/json5/lib/require.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
// This file is for backward compatibility with v0.5.1.
|
||||
require('./register')
|
||||
|
||||
console.warn("'json5/require' is deprecated. Please use 'json5/register' instead.")
|
||||
89
node_modules/json5/lib/stringify.d.ts
generated
vendored
Normal file
89
node_modules/json5/lib/stringify.d.ts
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
declare type StringifyOptions = {
|
||||
/**
|
||||
* A function that alters the behavior of the stringification process, or an
|
||||
* array of String and Number objects that serve as a allowlist for
|
||||
* selecting/filtering the properties of the value object to be included in
|
||||
* the JSON5 string. If this value is null or not provided, all properties
|
||||
* of the object are included in the resulting JSON5 string.
|
||||
*/
|
||||
replacer?:
|
||||
| ((this: any, key: string, value: any) => any)
|
||||
| (string | number)[]
|
||||
| null
|
||||
|
||||
/**
|
||||
* A String or Number object that's used to insert white space into the
|
||||
* output JSON5 string for readability purposes. If this is a Number, it
|
||||
* indicates the number of space characters to use as white space; this
|
||||
* number is capped at 10 (if it is greater, the value is just 10). Values
|
||||
* less than 1 indicate that no space should be used. If this is a String,
|
||||
* the string (or the first 10 characters of the string, if it's longer than
|
||||
* that) is used as white space. If this parameter is not provided (or is
|
||||
* null), no white space is used. If white space is used, trailing commas
|
||||
* will be used in objects and arrays.
|
||||
*/
|
||||
space?: string | number | null
|
||||
|
||||
/**
|
||||
* A String representing the quote character to use when serializing
|
||||
* strings.
|
||||
*/
|
||||
quote?: string | null
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a JavaScript value to a JSON5 string.
|
||||
* @param value The value to convert to a JSON5 string.
|
||||
* @param replacer A function that alters the behavior of the stringification
|
||||
* process. If this value is null or not provided, all properties of the object
|
||||
* are included in the resulting JSON5 string.
|
||||
* @param space A String or Number object that's used to insert white space into
|
||||
* the output JSON5 string for readability purposes. If this is a Number, it
|
||||
* indicates the number of space characters to use as white space; this number
|
||||
* is capped at 10 (if it is greater, the value is just 10). Values less than 1
|
||||
* indicate that no space should be used. If this is a String, the string (or
|
||||
* the first 10 characters of the string, if it's longer than that) is used as
|
||||
* white space. If this parameter is not provided (or is null), no white space
|
||||
* is used. If white space is used, trailing commas will be used in objects and
|
||||
* arrays.
|
||||
* @returns The JSON5 string converted from the JavaScript value.
|
||||
*/
|
||||
declare function stringify(
|
||||
value: any,
|
||||
replacer?: ((this: any, key: string, value: any) => any) | null,
|
||||
space?: string | number | null,
|
||||
): string
|
||||
|
||||
/**
|
||||
* Converts a JavaScript value to a JSON5 string.
|
||||
* @param value The value to convert to a JSON5 string.
|
||||
* @param replacer An array of String and Number objects that serve as a
|
||||
* allowlist for selecting/filtering the properties of the value object to be
|
||||
* included in the JSON5 string. If this value is null or not provided, all
|
||||
* properties of the object are included in the resulting JSON5 string.
|
||||
* @param space A String or Number object that's used to insert white space into
|
||||
* the output JSON5 string for readability purposes. If this is a Number, it
|
||||
* indicates the number of space characters to use as white space; this number
|
||||
* is capped at 10 (if it is greater, the value is just 10). Values less than 1
|
||||
* indicate that no space should be used. If this is a String, the string (or
|
||||
* the first 10 characters of the string, if it's longer than that) is used as
|
||||
* white space. If this parameter is not provided (or is null), no white space
|
||||
* is used. If white space is used, trailing commas will be used in objects and
|
||||
* arrays.
|
||||
* @returns The JSON5 string converted from the JavaScript value.
|
||||
*/
|
||||
declare function stringify(
|
||||
value: any,
|
||||
replacer: (string | number)[],
|
||||
space?: string | number | null,
|
||||
): string
|
||||
|
||||
/**
|
||||
* Converts a JavaScript value to a JSON5 string.
|
||||
* @param value The value to convert to a JSON5 string.
|
||||
* @param options An object specifying options.
|
||||
* @returns The JSON5 string converted from the JavaScript value.
|
||||
*/
|
||||
declare function stringify(value: any, options: StringifyOptions): string
|
||||
|
||||
export = stringify
|
||||
261
node_modules/json5/lib/stringify.js
generated
vendored
Normal file
261
node_modules/json5/lib/stringify.js
generated
vendored
Normal file
@@ -0,0 +1,261 @@
|
||||
const util = require('./util')
|
||||
|
||||
module.exports = function stringify (value, replacer, space) {
|
||||
const stack = []
|
||||
let indent = ''
|
||||
let propertyList
|
||||
let replacerFunc
|
||||
let gap = ''
|
||||
let quote
|
||||
|
||||
if (
|
||||
replacer != null &&
|
||||
typeof replacer === 'object' &&
|
||||
!Array.isArray(replacer)
|
||||
) {
|
||||
space = replacer.space
|
||||
quote = replacer.quote
|
||||
replacer = replacer.replacer
|
||||
}
|
||||
|
||||
if (typeof replacer === 'function') {
|
||||
replacerFunc = replacer
|
||||
} else if (Array.isArray(replacer)) {
|
||||
propertyList = []
|
||||
for (const v of replacer) {
|
||||
let item
|
||||
|
||||
if (typeof v === 'string') {
|
||||
item = v
|
||||
} else if (
|
||||
typeof v === 'number' ||
|
||||
v instanceof String ||
|
||||
v instanceof Number
|
||||
) {
|
||||
item = String(v)
|
||||
}
|
||||
|
||||
if (item !== undefined && propertyList.indexOf(item) < 0) {
|
||||
propertyList.push(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (space instanceof Number) {
|
||||
space = Number(space)
|
||||
} else if (space instanceof String) {
|
||||
space = String(space)
|
||||
}
|
||||
|
||||
if (typeof space === 'number') {
|
||||
if (space > 0) {
|
||||
space = Math.min(10, Math.floor(space))
|
||||
gap = ' '.substr(0, space)
|
||||
}
|
||||
} else if (typeof space === 'string') {
|
||||
gap = space.substr(0, 10)
|
||||
}
|
||||
|
||||
return serializeProperty('', {'': value})
|
||||
|
||||
function serializeProperty (key, holder) {
|
||||
let value = holder[key]
|
||||
if (value != null) {
|
||||
if (typeof value.toJSON5 === 'function') {
|
||||
value = value.toJSON5(key)
|
||||
} else if (typeof value.toJSON === 'function') {
|
||||
value = value.toJSON(key)
|
||||
}
|
||||
}
|
||||
|
||||
if (replacerFunc) {
|
||||
value = replacerFunc.call(holder, key, value)
|
||||
}
|
||||
|
||||
if (value instanceof Number) {
|
||||
value = Number(value)
|
||||
} else if (value instanceof String) {
|
||||
value = String(value)
|
||||
} else if (value instanceof Boolean) {
|
||||
value = value.valueOf()
|
||||
}
|
||||
|
||||
switch (value) {
|
||||
case null: return 'null'
|
||||
case true: return 'true'
|
||||
case false: return 'false'
|
||||
}
|
||||
|
||||
if (typeof value === 'string') {
|
||||
return quoteString(value, false)
|
||||
}
|
||||
|
||||
if (typeof value === 'number') {
|
||||
return String(value)
|
||||
}
|
||||
|
||||
if (typeof value === 'object') {
|
||||
return Array.isArray(value) ? serializeArray(value) : serializeObject(value)
|
||||
}
|
||||
|
||||
return undefined
|
||||
}
|
||||
|
||||
function quoteString (value) {
|
||||
const quotes = {
|
||||
"'": 0.1,
|
||||
'"': 0.2,
|
||||
}
|
||||
|
||||
const replacements = {
|
||||
"'": "\\'",
|
||||
'"': '\\"',
|
||||
'\\': '\\\\',
|
||||
'\b': '\\b',
|
||||
'\f': '\\f',
|
||||
'\n': '\\n',
|
||||
'\r': '\\r',
|
||||
'\t': '\\t',
|
||||
'\v': '\\v',
|
||||
'\0': '\\0',
|
||||
'\u2028': '\\u2028',
|
||||
'\u2029': '\\u2029',
|
||||
}
|
||||
|
||||
let product = ''
|
||||
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
const c = value[i]
|
||||
switch (c) {
|
||||
case "'":
|
||||
case '"':
|
||||
quotes[c]++
|
||||
product += c
|
||||
continue
|
||||
|
||||
case '\0':
|
||||
if (util.isDigit(value[i + 1])) {
|
||||
product += '\\x00'
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if (replacements[c]) {
|
||||
product += replacements[c]
|
||||
continue
|
||||
}
|
||||
|
||||
if (c < ' ') {
|
||||
let hexString = c.charCodeAt(0).toString(16)
|
||||
product += '\\x' + ('00' + hexString).substring(hexString.length)
|
||||
continue
|
||||
}
|
||||
|
||||
product += c
|
||||
}
|
||||
|
||||
const quoteChar = quote || Object.keys(quotes).reduce((a, b) => (quotes[a] < quotes[b]) ? a : b)
|
||||
|
||||
product = product.replace(new RegExp(quoteChar, 'g'), replacements[quoteChar])
|
||||
|
||||
return quoteChar + product + quoteChar
|
||||
}
|
||||
|
||||
function serializeObject (value) {
|
||||
if (stack.indexOf(value) >= 0) {
|
||||
throw TypeError('Converting circular structure to JSON5')
|
||||
}
|
||||
|
||||
stack.push(value)
|
||||
|
||||
let stepback = indent
|
||||
indent = indent + gap
|
||||
|
||||
let keys = propertyList || Object.keys(value)
|
||||
let partial = []
|
||||
for (const key of keys) {
|
||||
const propertyString = serializeProperty(key, value)
|
||||
if (propertyString !== undefined) {
|
||||
let member = serializeKey(key) + ':'
|
||||
if (gap !== '') {
|
||||
member += ' '
|
||||
}
|
||||
member += propertyString
|
||||
partial.push(member)
|
||||
}
|
||||
}
|
||||
|
||||
let final
|
||||
if (partial.length === 0) {
|
||||
final = '{}'
|
||||
} else {
|
||||
let properties
|
||||
if (gap === '') {
|
||||
properties = partial.join(',')
|
||||
final = '{' + properties + '}'
|
||||
} else {
|
||||
let separator = ',\n' + indent
|
||||
properties = partial.join(separator)
|
||||
final = '{\n' + indent + properties + ',\n' + stepback + '}'
|
||||
}
|
||||
}
|
||||
|
||||
stack.pop()
|
||||
indent = stepback
|
||||
return final
|
||||
}
|
||||
|
||||
function serializeKey (key) {
|
||||
if (key.length === 0) {
|
||||
return quoteString(key, true)
|
||||
}
|
||||
|
||||
const firstChar = String.fromCodePoint(key.codePointAt(0))
|
||||
if (!util.isIdStartChar(firstChar)) {
|
||||
return quoteString(key, true)
|
||||
}
|
||||
|
||||
for (let i = firstChar.length; i < key.length; i++) {
|
||||
if (!util.isIdContinueChar(String.fromCodePoint(key.codePointAt(i)))) {
|
||||
return quoteString(key, true)
|
||||
}
|
||||
}
|
||||
|
||||
return key
|
||||
}
|
||||
|
||||
function serializeArray (value) {
|
||||
if (stack.indexOf(value) >= 0) {
|
||||
throw TypeError('Converting circular structure to JSON5')
|
||||
}
|
||||
|
||||
stack.push(value)
|
||||
|
||||
let stepback = indent
|
||||
indent = indent + gap
|
||||
|
||||
let partial = []
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
const propertyString = serializeProperty(String(i), value)
|
||||
partial.push((propertyString !== undefined) ? propertyString : 'null')
|
||||
}
|
||||
|
||||
let final
|
||||
if (partial.length === 0) {
|
||||
final = '[]'
|
||||
} else {
|
||||
if (gap === '') {
|
||||
let properties = partial.join(',')
|
||||
final = '[' + properties + ']'
|
||||
} else {
|
||||
let separator = ',\n' + indent
|
||||
let properties = partial.join(separator)
|
||||
final = '[\n' + indent + properties + ',\n' + stepback + ']'
|
||||
}
|
||||
}
|
||||
|
||||
stack.pop()
|
||||
indent = stepback
|
||||
return final
|
||||
}
|
||||
}
|
||||
3
node_modules/json5/lib/unicode.d.ts
generated
vendored
Normal file
3
node_modules/json5/lib/unicode.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare const Space_Separator: RegExp
|
||||
export declare const ID_Start: RegExp
|
||||
export declare const ID_Continue: RegExp
|
||||
4
node_modules/json5/lib/unicode.js
generated
vendored
Normal file
4
node_modules/json5/lib/unicode.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
5
node_modules/json5/lib/util.d.ts
generated
vendored
Normal file
5
node_modules/json5/lib/util.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export declare function isSpaceSeparator(c?: string): boolean
|
||||
export declare function isIdStartChar(c?: string): boolean
|
||||
export declare function isIdContinueChar(c?: string): boolean
|
||||
export declare function isDigit(c?: string): boolean
|
||||
export declare function isHexDigit(c?: string): boolean
|
||||
35
node_modules/json5/lib/util.js
generated
vendored
Normal file
35
node_modules/json5/lib/util.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
const unicode = require('../lib/unicode')
|
||||
|
||||
module.exports = {
|
||||
isSpaceSeparator (c) {
|
||||
return typeof c === 'string' && unicode.Space_Separator.test(c)
|
||||
},
|
||||
|
||||
isIdStartChar (c) {
|
||||
return typeof c === 'string' && (
|
||||
(c >= 'a' && c <= 'z') ||
|
||||
(c >= 'A' && c <= 'Z') ||
|
||||
(c === '$') || (c === '_') ||
|
||||
unicode.ID_Start.test(c)
|
||||
)
|
||||
},
|
||||
|
||||
isIdContinueChar (c) {
|
||||
return typeof c === 'string' && (
|
||||
(c >= 'a' && c <= 'z') ||
|
||||
(c >= 'A' && c <= 'Z') ||
|
||||
(c >= '0' && c <= '9') ||
|
||||
(c === '$') || (c === '_') ||
|
||||
(c === '\u200C') || (c === '\u200D') ||
|
||||
unicode.ID_Continue.test(c)
|
||||
)
|
||||
},
|
||||
|
||||
isDigit (c) {
|
||||
return typeof c === 'string' && /[0-9]/.test(c)
|
||||
},
|
||||
|
||||
isHexDigit (c) {
|
||||
return typeof c === 'string' && /[0-9A-Fa-f]/.test(c)
|
||||
},
|
||||
}
|
||||
72
node_modules/json5/package.json
generated
vendored
Normal file
72
node_modules/json5/package.json
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"name": "json5",
|
||||
"version": "2.2.3",
|
||||
"description": "JSON for Humans",
|
||||
"main": "lib/index.js",
|
||||
"module": "dist/index.mjs",
|
||||
"bin": "lib/cli.js",
|
||||
"browser": "dist/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"files": [
|
||||
"lib/",
|
||||
"dist/"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rollup -c",
|
||||
"build-package": "node build/package.js",
|
||||
"build-unicode": "node build/unicode.js",
|
||||
"coverage": "tap --coverage-report html test",
|
||||
"lint": "eslint --fix .",
|
||||
"lint-report": "eslint .",
|
||||
"prepublishOnly": "npm run production",
|
||||
"preversion": "npm run production",
|
||||
"production": "run-s test build",
|
||||
"tap": "tap -Rspec --100 test",
|
||||
"test": "run-s lint-report tap",
|
||||
"version": "npm run build-package && git add package.json5"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/json5/json5.git"
|
||||
},
|
||||
"keywords": [
|
||||
"json",
|
||||
"json5",
|
||||
"es5",
|
||||
"es2015",
|
||||
"ecmascript"
|
||||
],
|
||||
"author": "Aseem Kishore <aseem.kishore@gmail.com>",
|
||||
"contributors": [
|
||||
"Max Nanasy <max.nanasy@gmail.com>",
|
||||
"Andrew Eisenberg <andrew@eisenberg.as>",
|
||||
"Jordan Tucker <jordanbtucker@gmail.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/json5/json5/issues"
|
||||
},
|
||||
"homepage": "http://json5.org/",
|
||||
"devDependencies": {
|
||||
"core-js": "^2.6.5",
|
||||
"eslint": "^5.15.3",
|
||||
"eslint-config-standard": "^12.0.0",
|
||||
"eslint-plugin-import": "^2.16.0",
|
||||
"eslint-plugin-node": "^8.0.1",
|
||||
"eslint-plugin-promise": "^4.0.1",
|
||||
"eslint-plugin-standard": "^4.0.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"regenerate": "^1.4.0",
|
||||
"rollup": "^0.64.1",
|
||||
"rollup-plugin-buble": "^0.19.6",
|
||||
"rollup-plugin-commonjs": "^9.2.1",
|
||||
"rollup-plugin-node-resolve": "^3.4.0",
|
||||
"rollup-plugin-terser": "^1.0.1",
|
||||
"sinon": "^6.3.5",
|
||||
"tap": "^12.6.0",
|
||||
"unicode-10.0.0": "^0.7.5"
|
||||
}
|
||||
}
|
||||
507
node_modules/mime-db/HISTORY.md
generated
vendored
Normal file
507
node_modules/mime-db/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,507 @@
|
||||
1.52.0 / 2022-02-21
|
||||
===================
|
||||
|
||||
* Add extensions from IANA for more `image/*` types
|
||||
* Add extension `.asc` to `application/pgp-keys`
|
||||
* Add extensions to various XML types
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.51.0 / 2021-11-08
|
||||
===================
|
||||
|
||||
* Add new upstream MIME types
|
||||
* Mark `image/vnd.microsoft.icon` as compressible
|
||||
* Mark `image/vnd.ms-dds` as compressible
|
||||
|
||||
1.50.0 / 2021-09-15
|
||||
===================
|
||||
|
||||
* Add deprecated iWorks mime types and extensions
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.49.0 / 2021-07-26
|
||||
===================
|
||||
|
||||
* Add extension `.trig` to `application/trig`
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.48.0 / 2021-05-30
|
||||
===================
|
||||
|
||||
* Add extension `.mvt` to `application/vnd.mapbox-vector-tile`
|
||||
* Add new upstream MIME types
|
||||
* Mark `text/yaml` as compressible
|
||||
|
||||
1.47.0 / 2021-04-01
|
||||
===================
|
||||
|
||||
* Add new upstream MIME types
|
||||
* Remove ambigious extensions from IANA for `application/*+xml` types
|
||||
* Update primary extension to `.es` for `application/ecmascript`
|
||||
|
||||
1.46.0 / 2021-02-13
|
||||
===================
|
||||
|
||||
* Add extension `.amr` to `audio/amr`
|
||||
* Add extension `.m4s` to `video/iso.segment`
|
||||
* Add extension `.opus` to `audio/ogg`
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.45.0 / 2020-09-22
|
||||
===================
|
||||
|
||||
* Add `application/ubjson` with extension `.ubj`
|
||||
* Add `image/avif` with extension `.avif`
|
||||
* Add `image/ktx2` with extension `.ktx2`
|
||||
* Add extension `.dbf` to `application/vnd.dbf`
|
||||
* Add extension `.rar` to `application/vnd.rar`
|
||||
* Add extension `.td` to `application/urc-targetdesc+xml`
|
||||
* Add new upstream MIME types
|
||||
* Fix extension of `application/vnd.apple.keynote` to be `.key`
|
||||
|
||||
1.44.0 / 2020-04-22
|
||||
===================
|
||||
|
||||
* Add charsets from IANA
|
||||
* Add extension `.cjs` to `application/node`
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.43.0 / 2020-01-05
|
||||
===================
|
||||
|
||||
* Add `application/x-keepass2` with extension `.kdbx`
|
||||
* Add extension `.mxmf` to `audio/mobile-xmf`
|
||||
* Add extensions from IANA for `application/*+xml` types
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.42.0 / 2019-09-25
|
||||
===================
|
||||
|
||||
* Add `image/vnd.ms-dds` with extension `.dds`
|
||||
* Add new upstream MIME types
|
||||
* Remove compressible from `multipart/mixed`
|
||||
|
||||
1.41.0 / 2019-08-30
|
||||
===================
|
||||
|
||||
* Add new upstream MIME types
|
||||
* Add `application/toml` with extension `.toml`
|
||||
* Mark `font/ttf` as compressible
|
||||
|
||||
1.40.0 / 2019-04-20
|
||||
===================
|
||||
|
||||
* Add extensions from IANA for `model/*` types
|
||||
* Add `text/mdx` with extension `.mdx`
|
||||
|
||||
1.39.0 / 2019-04-04
|
||||
===================
|
||||
|
||||
* Add extensions `.siv` and `.sieve` to `application/sieve`
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.38.0 / 2019-02-04
|
||||
===================
|
||||
|
||||
* Add extension `.nq` to `application/n-quads`
|
||||
* Add extension `.nt` to `application/n-triples`
|
||||
* Add new upstream MIME types
|
||||
* Mark `text/less` as compressible
|
||||
|
||||
1.37.0 / 2018-10-19
|
||||
===================
|
||||
|
||||
* Add extensions to HEIC image types
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.36.0 / 2018-08-20
|
||||
===================
|
||||
|
||||
* Add Apple file extensions from IANA
|
||||
* Add extensions from IANA for `image/*` types
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.35.0 / 2018-07-15
|
||||
===================
|
||||
|
||||
* Add extension `.owl` to `application/rdf+xml`
|
||||
* Add new upstream MIME types
|
||||
- Removes extension `.woff` from `application/font-woff`
|
||||
|
||||
1.34.0 / 2018-06-03
|
||||
===================
|
||||
|
||||
* Add extension `.csl` to `application/vnd.citationstyles.style+xml`
|
||||
* Add extension `.es` to `application/ecmascript`
|
||||
* Add new upstream MIME types
|
||||
* Add `UTF-8` as default charset for `text/turtle`
|
||||
* Mark all XML-derived types as compressible
|
||||
|
||||
1.33.0 / 2018-02-15
|
||||
===================
|
||||
|
||||
* Add extensions from IANA for `message/*` types
|
||||
* Add new upstream MIME types
|
||||
* Fix some incorrect OOXML types
|
||||
* Remove `application/font-woff2`
|
||||
|
||||
1.32.0 / 2017-11-29
|
||||
===================
|
||||
|
||||
* Add new upstream MIME types
|
||||
* Update `text/hjson` to registered `application/hjson`
|
||||
* Add `text/shex` with extension `.shex`
|
||||
|
||||
1.31.0 / 2017-10-25
|
||||
===================
|
||||
|
||||
* Add `application/raml+yaml` with extension `.raml`
|
||||
* Add `application/wasm` with extension `.wasm`
|
||||
* Add new `font` type from IANA
|
||||
* Add new upstream font extensions
|
||||
* Add new upstream MIME types
|
||||
* Add extensions for JPEG-2000 images
|
||||
|
||||
1.30.0 / 2017-08-27
|
||||
===================
|
||||
|
||||
* Add `application/vnd.ms-outlook`
|
||||
* Add `application/x-arj`
|
||||
* Add extension `.mjs` to `application/javascript`
|
||||
* Add glTF types and extensions
|
||||
* Add new upstream MIME types
|
||||
* Add `text/x-org`
|
||||
* Add VirtualBox MIME types
|
||||
* Fix `source` records for `video/*` types that are IANA
|
||||
* Update `font/opentype` to registered `font/otf`
|
||||
|
||||
1.29.0 / 2017-07-10
|
||||
===================
|
||||
|
||||
* Add `application/fido.trusted-apps+json`
|
||||
* Add extension `.wadl` to `application/vnd.sun.wadl+xml`
|
||||
* Add new upstream MIME types
|
||||
* Add `UTF-8` as default charset for `text/css`
|
||||
|
||||
1.28.0 / 2017-05-14
|
||||
===================
|
||||
|
||||
* Add new upstream MIME types
|
||||
* Add extension `.gz` to `application/gzip`
|
||||
* Update extensions `.md` and `.markdown` to be `text/markdown`
|
||||
|
||||
1.27.0 / 2017-03-16
|
||||
===================
|
||||
|
||||
* Add new upstream MIME types
|
||||
* Add `image/apng` with extension `.apng`
|
||||
|
||||
1.26.0 / 2017-01-14
|
||||
===================
|
||||
|
||||
* Add new upstream MIME types
|
||||
* Add extension `.geojson` to `application/geo+json`
|
||||
|
||||
1.25.0 / 2016-11-11
|
||||
===================
|
||||
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.24.0 / 2016-09-18
|
||||
===================
|
||||
|
||||
* Add `audio/mp3`
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.23.0 / 2016-05-01
|
||||
===================
|
||||
|
||||
* Add new upstream MIME types
|
||||
* Add extension `.3gpp` to `audio/3gpp`
|
||||
|
||||
1.22.0 / 2016-02-15
|
||||
===================
|
||||
|
||||
* Add `text/slim`
|
||||
* Add extension `.rng` to `application/xml`
|
||||
* Add new upstream MIME types
|
||||
* Fix extension of `application/dash+xml` to be `.mpd`
|
||||
* Update primary extension to `.m4a` for `audio/mp4`
|
||||
|
||||
1.21.0 / 2016-01-06
|
||||
===================
|
||||
|
||||
* Add Google document types
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.20.0 / 2015-11-10
|
||||
===================
|
||||
|
||||
* Add `text/x-suse-ymp`
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.19.0 / 2015-09-17
|
||||
===================
|
||||
|
||||
* Add `application/vnd.apple.pkpass`
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.18.0 / 2015-09-03
|
||||
===================
|
||||
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.17.0 / 2015-08-13
|
||||
===================
|
||||
|
||||
* Add `application/x-msdos-program`
|
||||
* Add `audio/g711-0`
|
||||
* Add `image/vnd.mozilla.apng`
|
||||
* Add extension `.exe` to `application/x-msdos-program`
|
||||
|
||||
1.16.0 / 2015-07-29
|
||||
===================
|
||||
|
||||
* Add `application/vnd.uri-map`
|
||||
|
||||
1.15.0 / 2015-07-13
|
||||
===================
|
||||
|
||||
* Add `application/x-httpd-php`
|
||||
|
||||
1.14.0 / 2015-06-25
|
||||
===================
|
||||
|
||||
* Add `application/scim+json`
|
||||
* Add `application/vnd.3gpp.ussd+xml`
|
||||
* Add `application/vnd.biopax.rdf+xml`
|
||||
* Add `text/x-processing`
|
||||
|
||||
1.13.0 / 2015-06-07
|
||||
===================
|
||||
|
||||
* Add nginx as a source
|
||||
* Add `application/x-cocoa`
|
||||
* Add `application/x-java-archive-diff`
|
||||
* Add `application/x-makeself`
|
||||
* Add `application/x-perl`
|
||||
* Add `application/x-pilot`
|
||||
* Add `application/x-redhat-package-manager`
|
||||
* Add `application/x-sea`
|
||||
* Add `audio/x-m4a`
|
||||
* Add `audio/x-realaudio`
|
||||
* Add `image/x-jng`
|
||||
* Add `text/mathml`
|
||||
|
||||
1.12.0 / 2015-06-05
|
||||
===================
|
||||
|
||||
* Add `application/bdoc`
|
||||
* Add `application/vnd.hyperdrive+json`
|
||||
* Add `application/x-bdoc`
|
||||
* Add extension `.rtf` to `text/rtf`
|
||||
|
||||
1.11.0 / 2015-05-31
|
||||
===================
|
||||
|
||||
* Add `audio/wav`
|
||||
* Add `audio/wave`
|
||||
* Add extension `.litcoffee` to `text/coffeescript`
|
||||
* Add extension `.sfd-hdstx` to `application/vnd.hydrostatix.sof-data`
|
||||
* Add extension `.n-gage` to `application/vnd.nokia.n-gage.symbian.install`
|
||||
|
||||
1.10.0 / 2015-05-19
|
||||
===================
|
||||
|
||||
* Add `application/vnd.balsamiq.bmpr`
|
||||
* Add `application/vnd.microsoft.portable-executable`
|
||||
* Add `application/x-ns-proxy-autoconfig`
|
||||
|
||||
1.9.1 / 2015-04-19
|
||||
==================
|
||||
|
||||
* Remove `.json` extension from `application/manifest+json`
|
||||
- This is causing bugs downstream
|
||||
|
||||
1.9.0 / 2015-04-19
|
||||
==================
|
||||
|
||||
* Add `application/manifest+json`
|
||||
* Add `application/vnd.micro+json`
|
||||
* Add `image/vnd.zbrush.pcx`
|
||||
* Add `image/x-ms-bmp`
|
||||
|
||||
1.8.0 / 2015-03-13
|
||||
==================
|
||||
|
||||
* Add `application/vnd.citationstyles.style+xml`
|
||||
* Add `application/vnd.fastcopy-disk-image`
|
||||
* Add `application/vnd.gov.sk.xmldatacontainer+xml`
|
||||
* Add extension `.jsonld` to `application/ld+json`
|
||||
|
||||
1.7.0 / 2015-02-08
|
||||
==================
|
||||
|
||||
* Add `application/vnd.gerber`
|
||||
* Add `application/vnd.msa-disk-image`
|
||||
|
||||
1.6.1 / 2015-02-05
|
||||
==================
|
||||
|
||||
* Community extensions ownership transferred from `node-mime`
|
||||
|
||||
1.6.0 / 2015-01-29
|
||||
==================
|
||||
|
||||
* Add `application/jose`
|
||||
* Add `application/jose+json`
|
||||
* Add `application/json-seq`
|
||||
* Add `application/jwk+json`
|
||||
* Add `application/jwk-set+json`
|
||||
* Add `application/jwt`
|
||||
* Add `application/rdap+json`
|
||||
* Add `application/vnd.gov.sk.e-form+xml`
|
||||
* Add `application/vnd.ims.imsccv1p3`
|
||||
|
||||
1.5.0 / 2014-12-30
|
||||
==================
|
||||
|
||||
* Add `application/vnd.oracle.resource+json`
|
||||
* Fix various invalid MIME type entries
|
||||
- `application/mbox+xml`
|
||||
- `application/oscp-response`
|
||||
- `application/vwg-multiplexed`
|
||||
- `audio/g721`
|
||||
|
||||
1.4.0 / 2014-12-21
|
||||
==================
|
||||
|
||||
* Add `application/vnd.ims.imsccv1p2`
|
||||
* Fix various invalid MIME type entries
|
||||
- `application/vnd-acucobol`
|
||||
- `application/vnd-curl`
|
||||
- `application/vnd-dart`
|
||||
- `application/vnd-dxr`
|
||||
- `application/vnd-fdf`
|
||||
- `application/vnd-mif`
|
||||
- `application/vnd-sema`
|
||||
- `application/vnd-wap-wmlc`
|
||||
- `application/vnd.adobe.flash-movie`
|
||||
- `application/vnd.dece-zip`
|
||||
- `application/vnd.dvb_service`
|
||||
- `application/vnd.micrografx-igx`
|
||||
- `application/vnd.sealed-doc`
|
||||
- `application/vnd.sealed-eml`
|
||||
- `application/vnd.sealed-mht`
|
||||
- `application/vnd.sealed-ppt`
|
||||
- `application/vnd.sealed-tiff`
|
||||
- `application/vnd.sealed-xls`
|
||||
- `application/vnd.sealedmedia.softseal-html`
|
||||
- `application/vnd.sealedmedia.softseal-pdf`
|
||||
- `application/vnd.wap-slc`
|
||||
- `application/vnd.wap-wbxml`
|
||||
- `audio/vnd.sealedmedia.softseal-mpeg`
|
||||
- `image/vnd-djvu`
|
||||
- `image/vnd-svf`
|
||||
- `image/vnd-wap-wbmp`
|
||||
- `image/vnd.sealed-png`
|
||||
- `image/vnd.sealedmedia.softseal-gif`
|
||||
- `image/vnd.sealedmedia.softseal-jpg`
|
||||
- `model/vnd-dwf`
|
||||
- `model/vnd.parasolid.transmit-binary`
|
||||
- `model/vnd.parasolid.transmit-text`
|
||||
- `text/vnd-a`
|
||||
- `text/vnd-curl`
|
||||
- `text/vnd.wap-wml`
|
||||
* Remove example template MIME types
|
||||
- `application/example`
|
||||
- `audio/example`
|
||||
- `image/example`
|
||||
- `message/example`
|
||||
- `model/example`
|
||||
- `multipart/example`
|
||||
- `text/example`
|
||||
- `video/example`
|
||||
|
||||
1.3.1 / 2014-12-16
|
||||
==================
|
||||
|
||||
* Fix missing extensions
|
||||
- `application/json5`
|
||||
- `text/hjson`
|
||||
|
||||
1.3.0 / 2014-12-07
|
||||
==================
|
||||
|
||||
* Add `application/a2l`
|
||||
* Add `application/aml`
|
||||
* Add `application/atfx`
|
||||
* Add `application/atxml`
|
||||
* Add `application/cdfx+xml`
|
||||
* Add `application/dii`
|
||||
* Add `application/json5`
|
||||
* Add `application/lxf`
|
||||
* Add `application/mf4`
|
||||
* Add `application/vnd.apache.thrift.compact`
|
||||
* Add `application/vnd.apache.thrift.json`
|
||||
* Add `application/vnd.coffeescript`
|
||||
* Add `application/vnd.enphase.envoy`
|
||||
* Add `application/vnd.ims.imsccv1p1`
|
||||
* Add `text/csv-schema`
|
||||
* Add `text/hjson`
|
||||
* Add `text/markdown`
|
||||
* Add `text/yaml`
|
||||
|
||||
1.2.0 / 2014-11-09
|
||||
==================
|
||||
|
||||
* Add `application/cea`
|
||||
* Add `application/dit`
|
||||
* Add `application/vnd.gov.sk.e-form+zip`
|
||||
* Add `application/vnd.tmd.mediaflex.api+xml`
|
||||
* Type `application/epub+zip` is now IANA-registered
|
||||
|
||||
1.1.2 / 2014-10-23
|
||||
==================
|
||||
|
||||
* Rebuild database for `application/x-www-form-urlencoded` change
|
||||
|
||||
1.1.1 / 2014-10-20
|
||||
==================
|
||||
|
||||
* Mark `application/x-www-form-urlencoded` as compressible.
|
||||
|
||||
1.1.0 / 2014-09-28
|
||||
==================
|
||||
|
||||
* Add `application/font-woff2`
|
||||
|
||||
1.0.3 / 2014-09-25
|
||||
==================
|
||||
|
||||
* Fix engine requirement in package
|
||||
|
||||
1.0.2 / 2014-09-25
|
||||
==================
|
||||
|
||||
* Add `application/coap-group+json`
|
||||
* Add `application/dcd`
|
||||
* Add `application/vnd.apache.thrift.binary`
|
||||
* Add `image/vnd.tencent.tap`
|
||||
* Mark all JSON-derived types as compressible
|
||||
* Update `text/vtt` data
|
||||
|
||||
1.0.1 / 2014-08-30
|
||||
==================
|
||||
|
||||
* Fix extension ordering
|
||||
|
||||
1.0.0 / 2014-08-30
|
||||
==================
|
||||
|
||||
* Add `application/atf`
|
||||
* Add `application/merge-patch+json`
|
||||
* Add `multipart/x-mixed-replace`
|
||||
* Add `source: 'apache'` metadata
|
||||
* Add `source: 'iana'` metadata
|
||||
* Remove badly-assumed charset data
|
||||
23
node_modules/mime-db/LICENSE
generated
vendored
Normal file
23
node_modules/mime-db/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
|
||||
Copyright (c) 2015-2022 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
100
node_modules/mime-db/README.md
generated
vendored
Normal file
100
node_modules/mime-db/README.md
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
# mime-db
|
||||
|
||||
[![NPM Version][npm-version-image]][npm-url]
|
||||
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||
[![Node.js Version][node-image]][node-url]
|
||||
[![Build Status][ci-image]][ci-url]
|
||||
[![Coverage Status][coveralls-image]][coveralls-url]
|
||||
|
||||
This is a large database of mime types and information about them.
|
||||
It consists of a single, public JSON file and does not include any logic,
|
||||
allowing it to remain as un-opinionated as possible with an API.
|
||||
It aggregates data from the following sources:
|
||||
|
||||
- http://www.iana.org/assignments/media-types/media-types.xhtml
|
||||
- http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
|
||||
- http://hg.nginx.org/nginx/raw-file/default/conf/mime.types
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install mime-db
|
||||
```
|
||||
|
||||
### Database Download
|
||||
|
||||
If you're crazy enough to use this in the browser, you can just grab the
|
||||
JSON file using [jsDelivr](https://www.jsdelivr.com/). It is recommended to
|
||||
replace `master` with [a release tag](https://github.com/jshttp/mime-db/tags)
|
||||
as the JSON format may change in the future.
|
||||
|
||||
```
|
||||
https://cdn.jsdelivr.net/gh/jshttp/mime-db@master/db.json
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var db = require('mime-db')
|
||||
|
||||
// grab data on .js files
|
||||
var data = db['application/javascript']
|
||||
```
|
||||
|
||||
## Data Structure
|
||||
|
||||
The JSON file is a map lookup for lowercased mime types.
|
||||
Each mime type has the following properties:
|
||||
|
||||
- `.source` - where the mime type is defined.
|
||||
If not set, it's probably a custom media type.
|
||||
- `apache` - [Apache common media types](http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types)
|
||||
- `iana` - [IANA-defined media types](http://www.iana.org/assignments/media-types/media-types.xhtml)
|
||||
- `nginx` - [nginx media types](http://hg.nginx.org/nginx/raw-file/default/conf/mime.types)
|
||||
- `.extensions[]` - known extensions associated with this mime type.
|
||||
- `.compressible` - whether a file of this type can be gzipped.
|
||||
- `.charset` - the default charset associated with this type, if any.
|
||||
|
||||
If unknown, every property could be `undefined`.
|
||||
|
||||
## Contributing
|
||||
|
||||
To edit the database, only make PRs against `src/custom-types.json` or
|
||||
`src/custom-suffix.json`.
|
||||
|
||||
The `src/custom-types.json` file is a JSON object with the MIME type as the
|
||||
keys and the values being an object with the following keys:
|
||||
|
||||
- `compressible` - leave out if you don't know, otherwise `true`/`false` to
|
||||
indicate whether the data represented by the type is typically compressible.
|
||||
- `extensions` - include an array of file extensions that are associated with
|
||||
the type.
|
||||
- `notes` - human-readable notes about the type, typically what the type is.
|
||||
- `sources` - include an array of URLs of where the MIME type and the associated
|
||||
extensions are sourced from. This needs to be a [primary source](https://en.wikipedia.org/wiki/Primary_source);
|
||||
links to type aggregating sites and Wikipedia are _not acceptable_.
|
||||
|
||||
To update the build, run `npm run build`.
|
||||
|
||||
### Adding Custom Media Types
|
||||
|
||||
The best way to get new media types included in this library is to register
|
||||
them with the IANA. The community registration procedure is outlined in
|
||||
[RFC 6838 section 5](http://tools.ietf.org/html/rfc6838#section-5). Types
|
||||
registered with the IANA are automatically pulled into this library.
|
||||
|
||||
If that is not possible / feasible, they can be added directly here as a
|
||||
"custom" type. To do this, it is required to have a primary source that
|
||||
definitively lists the media type. If an extension is going to be listed as
|
||||
associateed with this media type, the source must definitively link the
|
||||
media type and extension as well.
|
||||
|
||||
[ci-image]: https://badgen.net/github/checks/jshttp/mime-db/master?label=ci
|
||||
[ci-url]: https://github.com/jshttp/mime-db/actions?query=workflow%3Aci
|
||||
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/mime-db/master
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/mime-db?branch=master
|
||||
[node-image]: https://badgen.net/npm/node/mime-db
|
||||
[node-url]: https://nodejs.org/en/download
|
||||
[npm-downloads-image]: https://badgen.net/npm/dm/mime-db
|
||||
[npm-url]: https://npmjs.org/package/mime-db
|
||||
[npm-version-image]: https://badgen.net/npm/v/mime-db
|
||||
8519
node_modules/mime-db/db.json
generated
vendored
Normal file
8519
node_modules/mime-db/db.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
12
node_modules/mime-db/index.js
generated
vendored
Normal file
12
node_modules/mime-db/index.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/*!
|
||||
* mime-db
|
||||
* Copyright(c) 2014 Jonathan Ong
|
||||
* Copyright(c) 2015-2022 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = require('./db.json')
|
||||
60
node_modules/mime-db/package.json
generated
vendored
Normal file
60
node_modules/mime-db/package.json
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"name": "mime-db",
|
||||
"description": "Media Type Database",
|
||||
"version": "1.52.0",
|
||||
"contributors": [
|
||||
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)",
|
||||
"Robert Kieffer <robert@broofa.com> (http://github.com/broofa)"
|
||||
],
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"mime",
|
||||
"db",
|
||||
"type",
|
||||
"types",
|
||||
"database",
|
||||
"charset",
|
||||
"charsets"
|
||||
],
|
||||
"repository": "jshttp/mime-db",
|
||||
"devDependencies": {
|
||||
"bluebird": "3.7.2",
|
||||
"co": "4.6.0",
|
||||
"cogent": "1.0.1",
|
||||
"csv-parse": "4.16.3",
|
||||
"eslint": "7.32.0",
|
||||
"eslint-config-standard": "15.0.1",
|
||||
"eslint-plugin-import": "2.25.4",
|
||||
"eslint-plugin-markdown": "2.2.1",
|
||||
"eslint-plugin-node": "11.1.0",
|
||||
"eslint-plugin-promise": "5.1.1",
|
||||
"eslint-plugin-standard": "4.1.0",
|
||||
"gnode": "0.1.2",
|
||||
"media-typer": "1.1.0",
|
||||
"mocha": "9.2.1",
|
||||
"nyc": "15.1.0",
|
||||
"raw-body": "2.5.0",
|
||||
"stream-to-array": "2.3.0"
|
||||
},
|
||||
"files": [
|
||||
"HISTORY.md",
|
||||
"LICENSE",
|
||||
"README.md",
|
||||
"db.json",
|
||||
"index.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "node scripts/build",
|
||||
"fetch": "node scripts/fetch-apache && gnode scripts/fetch-iana && node scripts/fetch-nginx",
|
||||
"lint": "eslint .",
|
||||
"test": "mocha --reporter spec --bail --check-leaks test/",
|
||||
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
||||
"test-cov": "nyc --reporter=html --reporter=text npm test",
|
||||
"update": "npm run fetch && npm run build",
|
||||
"version": "node scripts/version-history.js && git add HISTORY.md"
|
||||
}
|
||||
}
|
||||
397
node_modules/mime-types/HISTORY.md
generated
vendored
Normal file
397
node_modules/mime-types/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,397 @@
|
||||
2.1.35 / 2022-03-12
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.52.0
|
||||
- Add extensions from IANA for more `image/*` types
|
||||
- Add extension `.asc` to `application/pgp-keys`
|
||||
- Add extensions to various XML types
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.34 / 2021-11-08
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.51.0
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.33 / 2021-10-01
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.50.0
|
||||
- Add deprecated iWorks mime types and extensions
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.32 / 2021-07-27
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.49.0
|
||||
- Add extension `.trig` to `application/trig`
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.31 / 2021-06-01
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.48.0
|
||||
- Add extension `.mvt` to `application/vnd.mapbox-vector-tile`
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.30 / 2021-04-02
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.47.0
|
||||
- Add extension `.amr` to `audio/amr`
|
||||
- Remove ambigious extensions from IANA for `application/*+xml` types
|
||||
- Update primary extension to `.es` for `application/ecmascript`
|
||||
|
||||
2.1.29 / 2021-02-17
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.46.0
|
||||
- Add extension `.amr` to `audio/amr`
|
||||
- Add extension `.m4s` to `video/iso.segment`
|
||||
- Add extension `.opus` to `audio/ogg`
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.28 / 2021-01-01
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.45.0
|
||||
- Add `application/ubjson` with extension `.ubj`
|
||||
- Add `image/avif` with extension `.avif`
|
||||
- Add `image/ktx2` with extension `.ktx2`
|
||||
- Add extension `.dbf` to `application/vnd.dbf`
|
||||
- Add extension `.rar` to `application/vnd.rar`
|
||||
- Add extension `.td` to `application/urc-targetdesc+xml`
|
||||
- Add new upstream MIME types
|
||||
- Fix extension of `application/vnd.apple.keynote` to be `.key`
|
||||
|
||||
2.1.27 / 2020-04-23
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.44.0
|
||||
- Add charsets from IANA
|
||||
- Add extension `.cjs` to `application/node`
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.26 / 2020-01-05
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.43.0
|
||||
- Add `application/x-keepass2` with extension `.kdbx`
|
||||
- Add extension `.mxmf` to `audio/mobile-xmf`
|
||||
- Add extensions from IANA for `application/*+xml` types
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.25 / 2019-11-12
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.42.0
|
||||
- Add new upstream MIME types
|
||||
- Add `application/toml` with extension `.toml`
|
||||
- Add `image/vnd.ms-dds` with extension `.dds`
|
||||
|
||||
2.1.24 / 2019-04-20
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.40.0
|
||||
- Add extensions from IANA for `model/*` types
|
||||
- Add `text/mdx` with extension `.mdx`
|
||||
|
||||
2.1.23 / 2019-04-17
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.39.0
|
||||
- Add extensions `.siv` and `.sieve` to `application/sieve`
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.22 / 2019-02-14
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.38.0
|
||||
- Add extension `.nq` to `application/n-quads`
|
||||
- Add extension `.nt` to `application/n-triples`
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.21 / 2018-10-19
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.37.0
|
||||
- Add extensions to HEIC image types
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.20 / 2018-08-26
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.36.0
|
||||
- Add Apple file extensions from IANA
|
||||
- Add extensions from IANA for `image/*` types
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.19 / 2018-07-17
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.35.0
|
||||
- Add extension `.csl` to `application/vnd.citationstyles.style+xml`
|
||||
- Add extension `.es` to `application/ecmascript`
|
||||
- Add extension `.owl` to `application/rdf+xml`
|
||||
- Add new upstream MIME types
|
||||
- Add UTF-8 as default charset for `text/turtle`
|
||||
|
||||
2.1.18 / 2018-02-16
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.33.0
|
||||
- Add `application/raml+yaml` with extension `.raml`
|
||||
- Add `application/wasm` with extension `.wasm`
|
||||
- Add `text/shex` with extension `.shex`
|
||||
- Add extensions for JPEG-2000 images
|
||||
- Add extensions from IANA for `message/*` types
|
||||
- Add new upstream MIME types
|
||||
- Update font MIME types
|
||||
- Update `text/hjson` to registered `application/hjson`
|
||||
|
||||
2.1.17 / 2017-09-01
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.30.0
|
||||
- Add `application/vnd.ms-outlook`
|
||||
- Add `application/x-arj`
|
||||
- Add extension `.mjs` to `application/javascript`
|
||||
- Add glTF types and extensions
|
||||
- Add new upstream MIME types
|
||||
- Add `text/x-org`
|
||||
- Add VirtualBox MIME types
|
||||
- Fix `source` records for `video/*` types that are IANA
|
||||
- Update `font/opentype` to registered `font/otf`
|
||||
|
||||
2.1.16 / 2017-07-24
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.29.0
|
||||
- Add `application/fido.trusted-apps+json`
|
||||
- Add extension `.wadl` to `application/vnd.sun.wadl+xml`
|
||||
- Add extension `.gz` to `application/gzip`
|
||||
- Add new upstream MIME types
|
||||
- Update extensions `.md` and `.markdown` to be `text/markdown`
|
||||
|
||||
2.1.15 / 2017-03-23
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.27.0
|
||||
- Add new mime types
|
||||
- Add `image/apng`
|
||||
|
||||
2.1.14 / 2017-01-14
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.26.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.13 / 2016-11-18
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.25.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.12 / 2016-09-18
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.24.0
|
||||
- Add new mime types
|
||||
- Add `audio/mp3`
|
||||
|
||||
2.1.11 / 2016-05-01
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.23.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.10 / 2016-02-15
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.22.0
|
||||
- Add new mime types
|
||||
- Fix extension of `application/dash+xml`
|
||||
- Update primary extension for `audio/mp4`
|
||||
|
||||
2.1.9 / 2016-01-06
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.21.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.8 / 2015-11-30
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.20.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.7 / 2015-09-20
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.19.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.6 / 2015-09-03
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.18.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.5 / 2015-08-20
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.17.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.4 / 2015-07-30
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.16.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.3 / 2015-07-13
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.15.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.2 / 2015-06-25
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.14.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.1 / 2015-06-08
|
||||
==================
|
||||
|
||||
* perf: fix deopt during mapping
|
||||
|
||||
2.1.0 / 2015-06-07
|
||||
==================
|
||||
|
||||
* Fix incorrectly treating extension-less file name as extension
|
||||
- i.e. `'path/to/json'` will no longer return `application/json`
|
||||
* Fix `.charset(type)` to accept parameters
|
||||
* Fix `.charset(type)` to match case-insensitive
|
||||
* Improve generation of extension to MIME mapping
|
||||
* Refactor internals for readability and no argument reassignment
|
||||
* Prefer `application/*` MIME types from the same source
|
||||
* Prefer any type over `application/octet-stream`
|
||||
* deps: mime-db@~1.13.0
|
||||
- Add nginx as a source
|
||||
- Add new mime types
|
||||
|
||||
2.0.14 / 2015-06-06
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.12.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.13 / 2015-05-31
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.11.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.12 / 2015-05-19
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.10.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.11 / 2015-05-05
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.9.1
|
||||
- Add new mime types
|
||||
|
||||
2.0.10 / 2015-03-13
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.8.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.9 / 2015-02-09
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.7.0
|
||||
- Add new mime types
|
||||
- Community extensions ownership transferred from `node-mime`
|
||||
|
||||
2.0.8 / 2015-01-29
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.6.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.7 / 2014-12-30
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.5.0
|
||||
- Add new mime types
|
||||
- Fix various invalid MIME type entries
|
||||
|
||||
2.0.6 / 2014-12-30
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.4.0
|
||||
- Add new mime types
|
||||
- Fix various invalid MIME type entries
|
||||
- Remove example template MIME types
|
||||
|
||||
2.0.5 / 2014-12-29
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.3.1
|
||||
- Fix missing extensions
|
||||
|
||||
2.0.4 / 2014-12-10
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.3.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.3 / 2014-11-09
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.2.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.2 / 2014-09-28
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.1.0
|
||||
- Add new mime types
|
||||
- Update charsets
|
||||
|
||||
2.0.1 / 2014-09-07
|
||||
==================
|
||||
|
||||
* Support Node.js 0.6
|
||||
|
||||
2.0.0 / 2014-09-02
|
||||
==================
|
||||
|
||||
* Use `mime-db`
|
||||
* Remove `.define()`
|
||||
|
||||
1.0.2 / 2014-08-04
|
||||
==================
|
||||
|
||||
* Set charset=utf-8 for `text/javascript`
|
||||
|
||||
1.0.1 / 2014-06-24
|
||||
==================
|
||||
|
||||
* Add `text/jsx` type
|
||||
|
||||
1.0.0 / 2014-05-12
|
||||
==================
|
||||
|
||||
* Return `false` for unknown types
|
||||
* Set charset=utf-8 for `application/json`
|
||||
|
||||
0.1.0 / 2014-05-02
|
||||
==================
|
||||
|
||||
* Initial release
|
||||
23
node_modules/mime-types/LICENSE
generated
vendored
Normal file
23
node_modules/mime-types/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
|
||||
Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
113
node_modules/mime-types/README.md
generated
vendored
Normal file
113
node_modules/mime-types/README.md
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
# mime-types
|
||||
|
||||
[![NPM Version][npm-version-image]][npm-url]
|
||||
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][ci-image]][ci-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
The ultimate javascript content-type utility.
|
||||
|
||||
Similar to [the `mime@1.x` module](https://www.npmjs.com/package/mime), except:
|
||||
|
||||
- __No fallbacks.__ Instead of naively returning the first available type,
|
||||
`mime-types` simply returns `false`, so do
|
||||
`var type = mime.lookup('unrecognized') || 'application/octet-stream'`.
|
||||
- No `new Mime()` business, so you could do `var lookup = require('mime-types').lookup`.
|
||||
- No `.define()` functionality
|
||||
- Bug fixes for `.lookup(path)`
|
||||
|
||||
Otherwise, the API is compatible with `mime` 1.x.
|
||||
|
||||
## Install
|
||||
|
||||
This is a [Node.js](https://nodejs.org/en/) module available through the
|
||||
[npm registry](https://www.npmjs.com/). Installation is done using the
|
||||
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
||||
|
||||
```sh
|
||||
$ npm install mime-types
|
||||
```
|
||||
|
||||
## Adding Types
|
||||
|
||||
All mime types are based on [mime-db](https://www.npmjs.com/package/mime-db),
|
||||
so open a PR there if you'd like to add mime types.
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var mime = require('mime-types')
|
||||
```
|
||||
|
||||
All functions return `false` if input is invalid or not found.
|
||||
|
||||
### mime.lookup(path)
|
||||
|
||||
Lookup the content-type associated with a file.
|
||||
|
||||
```js
|
||||
mime.lookup('json') // 'application/json'
|
||||
mime.lookup('.md') // 'text/markdown'
|
||||
mime.lookup('file.html') // 'text/html'
|
||||
mime.lookup('folder/file.js') // 'application/javascript'
|
||||
mime.lookup('folder/.htaccess') // false
|
||||
|
||||
mime.lookup('cats') // false
|
||||
```
|
||||
|
||||
### mime.contentType(type)
|
||||
|
||||
Create a full content-type header given a content-type or extension.
|
||||
When given an extension, `mime.lookup` is used to get the matching
|
||||
content-type, otherwise the given content-type is used. Then if the
|
||||
content-type does not already have a `charset` parameter, `mime.charset`
|
||||
is used to get the default charset and add to the returned content-type.
|
||||
|
||||
```js
|
||||
mime.contentType('markdown') // 'text/x-markdown; charset=utf-8'
|
||||
mime.contentType('file.json') // 'application/json; charset=utf-8'
|
||||
mime.contentType('text/html') // 'text/html; charset=utf-8'
|
||||
mime.contentType('text/html; charset=iso-8859-1') // 'text/html; charset=iso-8859-1'
|
||||
|
||||
// from a full path
|
||||
mime.contentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8'
|
||||
```
|
||||
|
||||
### mime.extension(type)
|
||||
|
||||
Get the default extension for a content-type.
|
||||
|
||||
```js
|
||||
mime.extension('application/octet-stream') // 'bin'
|
||||
```
|
||||
|
||||
### mime.charset(type)
|
||||
|
||||
Lookup the implied default charset of a content-type.
|
||||
|
||||
```js
|
||||
mime.charset('text/markdown') // 'UTF-8'
|
||||
```
|
||||
|
||||
### var type = mime.types[extension]
|
||||
|
||||
A map of content-types by extension.
|
||||
|
||||
### [extensions...] = mime.extensions[type]
|
||||
|
||||
A map of extensions by content-type.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[ci-image]: https://badgen.net/github/checks/jshttp/mime-types/master?label=ci
|
||||
[ci-url]: https://github.com/jshttp/mime-types/actions/workflows/ci.yml
|
||||
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/mime-types/master
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/mime-types?branch=master
|
||||
[node-version-image]: https://badgen.net/npm/node/mime-types
|
||||
[node-version-url]: https://nodejs.org/en/download
|
||||
[npm-downloads-image]: https://badgen.net/npm/dm/mime-types
|
||||
[npm-url]: https://npmjs.org/package/mime-types
|
||||
[npm-version-image]: https://badgen.net/npm/v/mime-types
|
||||
188
node_modules/mime-types/index.js
generated
vendored
Normal file
188
node_modules/mime-types/index.js
generated
vendored
Normal file
@@ -0,0 +1,188 @@
|
||||
/*!
|
||||
* mime-types
|
||||
* Copyright(c) 2014 Jonathan Ong
|
||||
* Copyright(c) 2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var db = require('mime-db')
|
||||
var extname = require('path').extname
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/
|
||||
var TEXT_TYPE_REGEXP = /^text\//i
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
exports.charset = charset
|
||||
exports.charsets = { lookup: charset }
|
||||
exports.contentType = contentType
|
||||
exports.extension = extension
|
||||
exports.extensions = Object.create(null)
|
||||
exports.lookup = lookup
|
||||
exports.types = Object.create(null)
|
||||
|
||||
// Populate the extensions/types maps
|
||||
populateMaps(exports.extensions, exports.types)
|
||||
|
||||
/**
|
||||
* Get the default charset for a MIME type.
|
||||
*
|
||||
* @param {string} type
|
||||
* @return {boolean|string}
|
||||
*/
|
||||
|
||||
function charset (type) {
|
||||
if (!type || typeof type !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
// TODO: use media-typer
|
||||
var match = EXTRACT_TYPE_REGEXP.exec(type)
|
||||
var mime = match && db[match[1].toLowerCase()]
|
||||
|
||||
if (mime && mime.charset) {
|
||||
return mime.charset
|
||||
}
|
||||
|
||||
// default text/* to utf-8
|
||||
if (match && TEXT_TYPE_REGEXP.test(match[1])) {
|
||||
return 'UTF-8'
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a full Content-Type header given a MIME type or extension.
|
||||
*
|
||||
* @param {string} str
|
||||
* @return {boolean|string}
|
||||
*/
|
||||
|
||||
function contentType (str) {
|
||||
// TODO: should this even be in this module?
|
||||
if (!str || typeof str !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
var mime = str.indexOf('/') === -1
|
||||
? exports.lookup(str)
|
||||
: str
|
||||
|
||||
if (!mime) {
|
||||
return false
|
||||
}
|
||||
|
||||
// TODO: use content-type or other module
|
||||
if (mime.indexOf('charset') === -1) {
|
||||
var charset = exports.charset(mime)
|
||||
if (charset) mime += '; charset=' + charset.toLowerCase()
|
||||
}
|
||||
|
||||
return mime
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default extension for a MIME type.
|
||||
*
|
||||
* @param {string} type
|
||||
* @return {boolean|string}
|
||||
*/
|
||||
|
||||
function extension (type) {
|
||||
if (!type || typeof type !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
// TODO: use media-typer
|
||||
var match = EXTRACT_TYPE_REGEXP.exec(type)
|
||||
|
||||
// get extensions
|
||||
var exts = match && exports.extensions[match[1].toLowerCase()]
|
||||
|
||||
if (!exts || !exts.length) {
|
||||
return false
|
||||
}
|
||||
|
||||
return exts[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup the MIME type for a file path/extension.
|
||||
*
|
||||
* @param {string} path
|
||||
* @return {boolean|string}
|
||||
*/
|
||||
|
||||
function lookup (path) {
|
||||
if (!path || typeof path !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
// get the extension ("ext" or ".ext" or full path)
|
||||
var extension = extname('x.' + path)
|
||||
.toLowerCase()
|
||||
.substr(1)
|
||||
|
||||
if (!extension) {
|
||||
return false
|
||||
}
|
||||
|
||||
return exports.types[extension] || false
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the extensions and types maps.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function populateMaps (extensions, types) {
|
||||
// source preference (least -> most)
|
||||
var preference = ['nginx', 'apache', undefined, 'iana']
|
||||
|
||||
Object.keys(db).forEach(function forEachMimeType (type) {
|
||||
var mime = db[type]
|
||||
var exts = mime.extensions
|
||||
|
||||
if (!exts || !exts.length) {
|
||||
return
|
||||
}
|
||||
|
||||
// mime -> extensions
|
||||
extensions[type] = exts
|
||||
|
||||
// extension -> mime
|
||||
for (var i = 0; i < exts.length; i++) {
|
||||
var extension = exts[i]
|
||||
|
||||
if (types[extension]) {
|
||||
var from = preference.indexOf(db[types[extension]].source)
|
||||
var to = preference.indexOf(mime.source)
|
||||
|
||||
if (types[extension] !== 'application/octet-stream' &&
|
||||
(from > to || (from === to && types[extension].substr(0, 12) === 'application/'))) {
|
||||
// skip the remapping
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// set the extension -> mime
|
||||
types[extension] = type
|
||||
}
|
||||
})
|
||||
}
|
||||
44
node_modules/mime-types/package.json
generated
vendored
Normal file
44
node_modules/mime-types/package.json
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "mime-types",
|
||||
"description": "The ultimate javascript content-type utility.",
|
||||
"version": "2.1.35",
|
||||
"contributors": [
|
||||
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||
"Jeremiah Senkpiel <fishrock123@rocketmail.com> (https://searchbeam.jit.su)",
|
||||
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
|
||||
],
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"mime",
|
||||
"types"
|
||||
],
|
||||
"repository": "jshttp/mime-types",
|
||||
"dependencies": {
|
||||
"mime-db": "1.52.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "7.32.0",
|
||||
"eslint-config-standard": "14.1.1",
|
||||
"eslint-plugin-import": "2.25.4",
|
||||
"eslint-plugin-markdown": "2.2.1",
|
||||
"eslint-plugin-node": "11.1.0",
|
||||
"eslint-plugin-promise": "5.2.0",
|
||||
"eslint-plugin-standard": "4.1.0",
|
||||
"mocha": "9.2.2",
|
||||
"nyc": "15.1.0"
|
||||
},
|
||||
"files": [
|
||||
"HISTORY.md",
|
||||
"LICENSE",
|
||||
"index.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"test": "mocha --reporter spec test/test.js",
|
||||
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
||||
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
||||
}
|
||||
}
|
||||
312
node_modules/mime/CHANGELOG.md
generated
vendored
Normal file
312
node_modules/mime/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,312 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
## [3.0.0](https://github.com/broofa/mime/compare/v2.6.0...v3.0.0) (2021-11-03)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* drop support for node < 10.x
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* skypack.dev for direct browser import, fixes [#263](https://github.com/broofa/mime/issues/263) ([41db4c0](https://github.com/broofa/mime/commit/41db4c042ccf50ea7baf3d2160ea37dcca37998d))
|
||||
|
||||
|
||||
### update
|
||||
|
||||
* drop support for node < 10.x ([8857363](https://github.com/broofa/mime/commit/8857363ae0446ed0229b17291cf4483cf801f0d0))
|
||||
|
||||
## [2.6.0](https://github.com/broofa/mime/compare/v2.5.2...v2.6.0) (2021-11-02)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* mime-db@1.50.0 ([cef0cc4](https://github.com/broofa/mime/commit/cef0cc484ff6d05ff1e12b54ca3e8b856fbc14d8))
|
||||
|
||||
### [2.5.2](https://github.com/broofa/mime/compare/v2.5.0...v2.5.2) (2021-02-17)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* update to mime-db@1.46.0, fixes [#253](https://github.com/broofa/mime/issues/253) ([f10e6aa](https://github.com/broofa/mime/commit/f10e6aa62e1356de7e2491d7fb4374c8dac65800))
|
||||
|
||||
## [2.5.0](https://github.com/broofa/mime/compare/v2.4.7...v2.5.0) (2021-01-16)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* improved CLI ([#244](https://github.com/broofa/mime/issues/244)) ([c8a8356](https://github.com/broofa/mime/commit/c8a8356e3b27f3ef46b64b89b428fdb547b14d5f))
|
||||
|
||||
### [2.4.7](https://github.com/broofa/mime/compare/v2.4.6...v2.4.7) (2020-12-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* update to latest mime-db ([43b09ef](https://github.com/broofa/mime/commit/43b09eff0233eacc449af2b1f99a19ba9e104a44))
|
||||
|
||||
### [2.4.6](https://github.com/broofa/mime/compare/v2.4.5...v2.4.6) (2020-05-27)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add cli.js to package.json files ([#237](https://github.com/broofa/mime/issues/237)) ([6c070bc](https://github.com/broofa/mime/commit/6c070bc298fa12a48e2ed126fbb9de641a1e7ebc))
|
||||
|
||||
### [2.4.5](https://github.com/broofa/mime/compare/v2.4.4...v2.4.5) (2020-05-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix [#236](https://github.com/broofa/mime/issues/236) ([7f4ecd0](https://github.com/broofa/mime/commit/7f4ecd0d850ed22c9e3bfda2c11fc74e4dde12a7))
|
||||
* update to latest mime-db ([c5cb3f2](https://github.com/broofa/mime/commit/c5cb3f2ab8b07642a066efbde1142af1b90c927b))
|
||||
|
||||
### [2.4.4](https://github.com/broofa/mime/compare/v2.4.3...v2.4.4) (2019-06-07)
|
||||
|
||||
|
||||
|
||||
### [2.4.3](https://github.com/broofa/mime/compare/v2.4.2...v2.4.3) (2019-05-15)
|
||||
|
||||
|
||||
|
||||
### [2.4.2](https://github.com/broofa/mime/compare/v2.4.1...v2.4.2) (2019-04-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* don't use arrow function introduced in 2.4.1 ([2e00b5c](https://github.com/broofa/mime/commit/2e00b5c))
|
||||
|
||||
|
||||
|
||||
### [2.4.1](https://github.com/broofa/mime/compare/v2.4.0...v2.4.1) (2019-04-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* update MDN and mime-db types ([3e567a9](https://github.com/broofa/mime/commit/3e567a9))
|
||||
|
||||
|
||||
|
||||
# [2.4.0](https://github.com/broofa/mime/compare/v2.3.1...v2.4.0) (2018-11-26)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Bind exported methods ([9d2a7b8](https://github.com/broofa/mime/commit/9d2a7b8))
|
||||
* update to mime-db@1.37.0 ([49e6e41](https://github.com/broofa/mime/commit/49e6e41))
|
||||
|
||||
|
||||
|
||||
### [2.3.1](https://github.com/broofa/mime/compare/v2.3.0...v2.3.1) (2018-04-11)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix [#198](https://github.com/broofa/mime/issues/198) ([25ca180](https://github.com/broofa/mime/commit/25ca180))
|
||||
|
||||
|
||||
|
||||
# [2.3.0](https://github.com/broofa/mime/compare/v2.2.2...v2.3.0) (2018-04-11)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix [#192](https://github.com/broofa/mime/issues/192) ([5c35df6](https://github.com/broofa/mime/commit/5c35df6))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add travis-ci testing ([d64160f](https://github.com/broofa/mime/commit/d64160f))
|
||||
|
||||
|
||||
|
||||
### [2.2.2](https://github.com/broofa/mime/compare/v2.2.1...v2.2.2) (2018-03-30)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* update types files to mime-db@1.32.0 ([85aac16](https://github.com/broofa/mime/commit/85aac16))
|
||||
|
||||
|
||||
### [2.2.1](https://github.com/broofa/mime/compare/v2.2.0...v2.2.1) (2018-03-30)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Retain type->extension mappings for non-default types. Fixes [#180](https://github.com/broofa/mime/issues/180) ([b5c83fb](https://github.com/broofa/mime/commit/b5c83fb))
|
||||
|
||||
|
||||
|
||||
# [2.2.0](https://github.com/broofa/mime/compare/v2.1.0...v2.2.0) (2018-01-04)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Retain type->extension mappings for non-default types. Fixes [#180](https://github.com/broofa/mime/issues/180) ([10f82ac](https://github.com/broofa/mime/commit/10f82ac))
|
||||
|
||||
|
||||
|
||||
# [2.1.0](https://github.com/broofa/mime/compare/v2.0.5...v2.1.0) (2017-12-22)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Upgrade to mime-db@1.32.0. Fixes [#185](https://github.com/broofa/mime/issues/185) ([3f775ba](https://github.com/broofa/mime/commit/3f775ba))
|
||||
|
||||
|
||||
|
||||
### [2.0.5](https://github.com/broofa/mime/compare/v2.0.1...v2.0.5) (2017-12-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* ES5 support (back to node v0.4) ([f14ccb6](https://github.com/broofa/mime/commit/f14ccb6))
|
||||
|
||||
|
||||
|
||||
# Changelog
|
||||
|
||||
### v2.0.4 (24/11/2017)
|
||||
- [**closed**] Switch to mime-score module for resolving extension contention issues. [#182](https://github.com/broofa/mime/issues/182)
|
||||
- [**closed**] Update mime-db to 1.31.0 in v1.x branch [#181](https://github.com/broofa/mime/issues/181)
|
||||
|
||||
---
|
||||
|
||||
## v1.5.0 (22/11/2017)
|
||||
- [**closed**] need ES5 version ready in npm package [#179](https://github.com/broofa/mime/issues/179)
|
||||
- [**closed**] mime-db no trace of iWork - pages / numbers / etc. [#178](https://github.com/broofa/mime/issues/178)
|
||||
- [**closed**] How it works in brownser ? [#176](https://github.com/broofa/mime/issues/176)
|
||||
- [**closed**] Missing `./Mime` [#175](https://github.com/broofa/mime/issues/175)
|
||||
- [**closed**] Vulnerable Regular Expression [#167](https://github.com/broofa/mime/issues/167)
|
||||
|
||||
---
|
||||
|
||||
### v2.0.3 (25/09/2017)
|
||||
*No changelog for this release.*
|
||||
|
||||
---
|
||||
|
||||
### v1.4.1 (25/09/2017)
|
||||
- [**closed**] Issue when bundling with webpack [#172](https://github.com/broofa/mime/issues/172)
|
||||
|
||||
---
|
||||
|
||||
### v2.0.2 (15/09/2017)
|
||||
- [**V2**] fs.readFileSync is not a function [#165](https://github.com/broofa/mime/issues/165)
|
||||
- [**closed**] The extension for video/quicktime should map to .mov, not .qt [#164](https://github.com/broofa/mime/issues/164)
|
||||
- [**V2**] [v2 Feedback request] Mime class API [#163](https://github.com/broofa/mime/issues/163)
|
||||
- [**V2**] [v2 Feedback request] Resolving conflicts over extensions [#162](https://github.com/broofa/mime/issues/162)
|
||||
- [**V2**] Allow callers to load module with official, full, or no defined types. [#161](https://github.com/broofa/mime/issues/161)
|
||||
- [**V2**] Use "facets" to resolve extension conflicts [#160](https://github.com/broofa/mime/issues/160)
|
||||
- [**V2**] Remove fs and path dependencies [#152](https://github.com/broofa/mime/issues/152)
|
||||
- [**V2**] Default content-type should not be application/octet-stream [#139](https://github.com/broofa/mime/issues/139)
|
||||
- [**V2**] reset mime-types [#124](https://github.com/broofa/mime/issues/124)
|
||||
- [**V2**] Extensionless paths should return null or false [#113](https://github.com/broofa/mime/issues/113)
|
||||
|
||||
---
|
||||
|
||||
### v2.0.1 (14/09/2017)
|
||||
- [**closed**] Changelog for v2.0 does not mention breaking changes [#171](https://github.com/broofa/mime/issues/171)
|
||||
- [**closed**] MIME breaking with 'class' declaration as it is without 'use strict mode' [#170](https://github.com/broofa/mime/issues/170)
|
||||
|
||||
---
|
||||
|
||||
## v2.0.0 (12/09/2017)
|
||||
- [**closed**] woff and woff2 [#168](https://github.com/broofa/mime/issues/168)
|
||||
|
||||
---
|
||||
|
||||
## v1.4.0 (28/08/2017)
|
||||
- [**closed**] support for ac3 voc files [#159](https://github.com/broofa/mime/issues/159)
|
||||
- [**closed**] Help understanding change from application/xml to text/xml [#158](https://github.com/broofa/mime/issues/158)
|
||||
- [**closed**] no longer able to override mimetype [#157](https://github.com/broofa/mime/issues/157)
|
||||
- [**closed**] application/vnd.adobe.photoshop [#147](https://github.com/broofa/mime/issues/147)
|
||||
- [**closed**] Directories should appear as something other than application/octet-stream [#135](https://github.com/broofa/mime/issues/135)
|
||||
- [**closed**] requested features [#131](https://github.com/broofa/mime/issues/131)
|
||||
- [**closed**] Make types.json loading optional? [#129](https://github.com/broofa/mime/issues/129)
|
||||
- [**closed**] Cannot find module './types.json' [#120](https://github.com/broofa/mime/issues/120)
|
||||
- [**V2**] .wav files show up as "audio/x-wav" instead of "audio/x-wave" [#118](https://github.com/broofa/mime/issues/118)
|
||||
- [**closed**] Don't be a pain in the ass for node community [#108](https://github.com/broofa/mime/issues/108)
|
||||
- [**closed**] don't make default_type global [#78](https://github.com/broofa/mime/issues/78)
|
||||
- [**closed**] mime.extension() fails if the content-type is parameterized [#74](https://github.com/broofa/mime/issues/74)
|
||||
|
||||
---
|
||||
|
||||
### v1.3.6 (11/05/2017)
|
||||
- [**closed**] .md should be text/markdown as of March 2016 [#154](https://github.com/broofa/mime/issues/154)
|
||||
- [**closed**] Error while installing mime [#153](https://github.com/broofa/mime/issues/153)
|
||||
- [**closed**] application/manifest+json [#149](https://github.com/broofa/mime/issues/149)
|
||||
- [**closed**] Dynamic adaptive streaming over HTTP (DASH) file extension typo [#141](https://github.com/broofa/mime/issues/141)
|
||||
- [**closed**] charsets image/png undefined [#140](https://github.com/broofa/mime/issues/140)
|
||||
- [**closed**] Mime-db dependency out of date [#130](https://github.com/broofa/mime/issues/130)
|
||||
- [**closed**] how to support plist? [#126](https://github.com/broofa/mime/issues/126)
|
||||
- [**closed**] how does .types file format look like? [#123](https://github.com/broofa/mime/issues/123)
|
||||
- [**closed**] Feature: support for expanding MIME patterns [#121](https://github.com/broofa/mime/issues/121)
|
||||
- [**closed**] DEBUG_MIME doesn't work [#117](https://github.com/broofa/mime/issues/117)
|
||||
|
||||
---
|
||||
|
||||
### v1.3.4 (06/02/2015)
|
||||
*No changelog for this release.*
|
||||
|
||||
---
|
||||
|
||||
### v1.3.3 (06/02/2015)
|
||||
*No changelog for this release.*
|
||||
|
||||
---
|
||||
|
||||
### v1.3.1 (05/02/2015)
|
||||
- [**closed**] Consider adding support for Handlebars .hbs file ending [#111](https://github.com/broofa/mime/issues/111)
|
||||
- [**closed**] Consider adding support for hjson. [#110](https://github.com/broofa/mime/issues/110)
|
||||
- [**closed**] Add mime type for Opus audio files [#94](https://github.com/broofa/mime/issues/94)
|
||||
- [**closed**] Consider making the `Requesting New Types` information more visible [#77](https://github.com/broofa/mime/issues/77)
|
||||
|
||||
---
|
||||
|
||||
## v1.3.0 (05/02/2015)
|
||||
- [**closed**] Add common name? [#114](https://github.com/broofa/mime/issues/114)
|
||||
- [**closed**] application/x-yaml [#104](https://github.com/broofa/mime/issues/104)
|
||||
- [**closed**] Add mime type for WOFF file format 2.0 [#102](https://github.com/broofa/mime/issues/102)
|
||||
- [**closed**] application/x-msi for .msi [#99](https://github.com/broofa/mime/issues/99)
|
||||
- [**closed**] Add mimetype for gettext translation files [#98](https://github.com/broofa/mime/issues/98)
|
||||
- [**closed**] collaborators [#88](https://github.com/broofa/mime/issues/88)
|
||||
- [**closed**] getting errot in installation of mime module...any1 can help? [#87](https://github.com/broofa/mime/issues/87)
|
||||
- [**closed**] should application/json's charset be utf8? [#86](https://github.com/broofa/mime/issues/86)
|
||||
- [**closed**] Add "license" and "licenses" to package.json [#81](https://github.com/broofa/mime/issues/81)
|
||||
- [**closed**] lookup with extension-less file on Windows returns wrong type [#68](https://github.com/broofa/mime/issues/68)
|
||||
|
||||
---
|
||||
|
||||
### v1.2.11 (15/08/2013)
|
||||
- [**closed**] Update mime.types [#65](https://github.com/broofa/mime/issues/65)
|
||||
- [**closed**] Publish a new version [#63](https://github.com/broofa/mime/issues/63)
|
||||
- [**closed**] README should state upfront that "application/octet-stream" is default for unknown extension [#55](https://github.com/broofa/mime/issues/55)
|
||||
- [**closed**] Suggested improvement to the charset API [#52](https://github.com/broofa/mime/issues/52)
|
||||
|
||||
---
|
||||
|
||||
### v1.2.10 (25/07/2013)
|
||||
- [**closed**] Mime type for woff files should be application/font-woff and not application/x-font-woff [#62](https://github.com/broofa/mime/issues/62)
|
||||
- [**closed**] node.types in conflict with mime.types [#51](https://github.com/broofa/mime/issues/51)
|
||||
|
||||
---
|
||||
|
||||
### v1.2.9 (17/01/2013)
|
||||
- [**closed**] Please update "mime" NPM [#49](https://github.com/broofa/mime/issues/49)
|
||||
- [**closed**] Please add semicolon [#46](https://github.com/broofa/mime/issues/46)
|
||||
- [**closed**] parse full mime types [#43](https://github.com/broofa/mime/issues/43)
|
||||
|
||||
---
|
||||
|
||||
### v1.2.8 (10/01/2013)
|
||||
- [**closed**] /js directory mime is application/javascript. Is it correct? [#47](https://github.com/broofa/mime/issues/47)
|
||||
- [**closed**] Add mime types for lua code. [#45](https://github.com/broofa/mime/issues/45)
|
||||
|
||||
---
|
||||
|
||||
### v1.2.7 (19/10/2012)
|
||||
- [**closed**] cannot install 1.2.7 via npm [#41](https://github.com/broofa/mime/issues/41)
|
||||
- [**closed**] Transfer ownership to @broofa [#36](https://github.com/broofa/mime/issues/36)
|
||||
- [**closed**] it's wrong to set charset to UTF-8 for text [#30](https://github.com/broofa/mime/issues/30)
|
||||
- [**closed**] Allow multiple instances of MIME types container [#27](https://github.com/broofa/mime/issues/27)
|
||||
21
node_modules/mime/LICENSE
generated
vendored
Normal file
21
node_modules/mime/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2010 Benjamin Thomas, Robert Kieffer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
97
node_modules/mime/Mime.js
generated
vendored
Normal file
97
node_modules/mime/Mime.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @param typeMap [Object] Map of MIME type -> Array[extensions]
|
||||
* @param ...
|
||||
*/
|
||||
function Mime() {
|
||||
this._types = Object.create(null);
|
||||
this._extensions = Object.create(null);
|
||||
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
this.define(arguments[i]);
|
||||
}
|
||||
|
||||
this.define = this.define.bind(this);
|
||||
this.getType = this.getType.bind(this);
|
||||
this.getExtension = this.getExtension.bind(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define mimetype -> extension mappings. Each key is a mime-type that maps
|
||||
* to an array of extensions associated with the type. The first extension is
|
||||
* used as the default extension for the type.
|
||||
*
|
||||
* e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
|
||||
*
|
||||
* If a type declares an extension that has already been defined, an error will
|
||||
* be thrown. To suppress this error and force the extension to be associated
|
||||
* with the new type, pass `force`=true. Alternatively, you may prefix the
|
||||
* extension with "*" to map the type to extension, without mapping the
|
||||
* extension to the type.
|
||||
*
|
||||
* e.g. mime.define({'audio/wav', ['wav']}, {'audio/x-wav', ['*wav']});
|
||||
*
|
||||
*
|
||||
* @param map (Object) type definitions
|
||||
* @param force (Boolean) if true, force overriding of existing definitions
|
||||
*/
|
||||
Mime.prototype.define = function(typeMap, force) {
|
||||
for (let type in typeMap) {
|
||||
let extensions = typeMap[type].map(function(t) {
|
||||
return t.toLowerCase();
|
||||
});
|
||||
type = type.toLowerCase();
|
||||
|
||||
for (let i = 0; i < extensions.length; i++) {
|
||||
const ext = extensions[i];
|
||||
|
||||
// '*' prefix = not the preferred type for this extension. So fixup the
|
||||
// extension, and skip it.
|
||||
if (ext[0] === '*') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!force && (ext in this._types)) {
|
||||
throw new Error(
|
||||
'Attempt to change mapping for "' + ext +
|
||||
'" extension from "' + this._types[ext] + '" to "' + type +
|
||||
'". Pass `force=true` to allow this, otherwise remove "' + ext +
|
||||
'" from the list of extensions for "' + type + '".'
|
||||
);
|
||||
}
|
||||
|
||||
this._types[ext] = type;
|
||||
}
|
||||
|
||||
// Use first extension as default
|
||||
if (force || !this._extensions[type]) {
|
||||
const ext = extensions[0];
|
||||
this._extensions[type] = (ext[0] !== '*') ? ext : ext.substr(1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Lookup a mime type based on extension
|
||||
*/
|
||||
Mime.prototype.getType = function(path) {
|
||||
path = String(path);
|
||||
let last = path.replace(/^.*[/\\]/, '').toLowerCase();
|
||||
let ext = last.replace(/^.*\./, '').toLowerCase();
|
||||
|
||||
let hasPath = last.length < path.length;
|
||||
let hasDot = ext.length < last.length - 1;
|
||||
|
||||
return (hasDot || !hasPath) && this._types[ext] || null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return file extension associated with a mime type
|
||||
*/
|
||||
Mime.prototype.getExtension = function(type) {
|
||||
type = /^\s*([^;\s]*)/.test(type) && RegExp.$1;
|
||||
return type && this._extensions[type.toLowerCase()] || null;
|
||||
};
|
||||
|
||||
module.exports = Mime;
|
||||
178
node_modules/mime/README.md
generated
vendored
Normal file
178
node_modules/mime/README.md
generated
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
<!--
|
||||
-- This file is auto-generated from src/README_js.md. Changes should be made there.
|
||||
-->
|
||||
# Mime
|
||||
|
||||
A comprehensive, compact MIME type module.
|
||||
|
||||
[](https://travis-ci.org/broofa/mime)
|
||||
|
||||
## Install
|
||||
|
||||
### NPM
|
||||
```
|
||||
npm install mime
|
||||
```
|
||||
|
||||
### Browser
|
||||
|
||||
It is recommended that you use a bundler such as
|
||||
[webpack](https://webpack.github.io/) or [browserify](http://browserify.org/) to
|
||||
package your code. However, browser-ready versions are available via
|
||||
skypack.dev as follows:
|
||||
```
|
||||
// Full version
|
||||
<script type="module">
|
||||
import mime from "https://cdn.skypack.dev/mime";
|
||||
</script>
|
||||
```
|
||||
|
||||
```
|
||||
// "lite" version
|
||||
<script type="module">
|
||||
import mime from "https://cdn.skypack.dev/mime/lite";
|
||||
</script>
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
For the full version (800+ MIME types, 1,000+ extensions):
|
||||
|
||||
```javascript
|
||||
const mime = require('mime');
|
||||
|
||||
mime.getType('txt'); // ⇨ 'text/plain'
|
||||
mime.getExtension('text/plain'); // ⇨ 'txt'
|
||||
```
|
||||
|
||||
See [Mime API](#mime-api) below for API details.
|
||||
|
||||
## Lite Version
|
||||
|
||||
The "lite" version of this module omits vendor-specific (`*/vnd.*`) and
|
||||
experimental (`*/x-*`) types. It weighs in at ~2.5KB, compared to 8KB for the
|
||||
full version. To load the lite version:
|
||||
|
||||
```javascript
|
||||
const mime = require('mime/lite');
|
||||
```
|
||||
|
||||
## Mime .vs. mime-types .vs. mime-db modules
|
||||
|
||||
For those of you wondering about the difference between these [popular] NPM modules,
|
||||
here's a brief rundown ...
|
||||
|
||||
[`mime-db`](https://github.com/jshttp/mime-db) is "the source of
|
||||
truth" for MIME type information. It is not an API. Rather, it is a canonical
|
||||
dataset of mime type definitions pulled from IANA, Apache, NGINX, and custom mappings
|
||||
submitted by the Node.js community.
|
||||
|
||||
[`mime-types`](https://github.com/jshttp/mime-types) is a thin
|
||||
wrapper around mime-db that provides an API drop-in compatible(ish) with `mime @ < v1.3.6` API.
|
||||
|
||||
`mime` is, as of v2, a self-contained module bundled with a pre-optimized version
|
||||
of the `mime-db` dataset. It provides a simplified API with the following characteristics:
|
||||
|
||||
* Intelligently resolved type conflicts (See [mime-score](https://github.com/broofa/mime-score) for details)
|
||||
* Method naming consistent with industry best-practices
|
||||
* Compact footprint. E.g. The minified+compressed sizes of the various modules:
|
||||
|
||||
Module | Size
|
||||
--- | ---
|
||||
`mime-db` | 18 KB
|
||||
`mime-types` | same as mime-db
|
||||
`mime` | 8 KB
|
||||
`mime/lite` | 2 KB
|
||||
|
||||
## Mime API
|
||||
|
||||
Both `require('mime')` and `require('mime/lite')` return instances of the MIME
|
||||
class, documented below.
|
||||
|
||||
Note: Inputs to this API are case-insensitive. Outputs (returned values) will
|
||||
be lowercase.
|
||||
|
||||
### new Mime(typeMap, ... more maps)
|
||||
|
||||
Most users of this module will not need to create Mime instances directly.
|
||||
However if you would like to create custom mappings, you may do so as follows
|
||||
...
|
||||
|
||||
```javascript
|
||||
// Require Mime class
|
||||
const Mime = require('mime/Mime');
|
||||
|
||||
// Define mime type -> extensions map
|
||||
const typeMap = {
|
||||
'text/abc': ['abc', 'alpha', 'bet'],
|
||||
'text/def': ['leppard']
|
||||
};
|
||||
|
||||
// Create and use Mime instance
|
||||
const myMime = new Mime(typeMap);
|
||||
myMime.getType('abc'); // ⇨ 'text/abc'
|
||||
myMime.getExtension('text/def'); // ⇨ 'leppard'
|
||||
```
|
||||
|
||||
If more than one map argument is provided, each map is `define()`ed (see below), in order.
|
||||
|
||||
### mime.getType(pathOrExtension)
|
||||
|
||||
Get mime type for the given path or extension. E.g.
|
||||
|
||||
```javascript
|
||||
mime.getType('js'); // ⇨ 'application/javascript'
|
||||
mime.getType('json'); // ⇨ 'application/json'
|
||||
|
||||
mime.getType('txt'); // ⇨ 'text/plain'
|
||||
mime.getType('dir/text.txt'); // ⇨ 'text/plain'
|
||||
mime.getType('dir\\text.txt'); // ⇨ 'text/plain'
|
||||
mime.getType('.text.txt'); // ⇨ 'text/plain'
|
||||
mime.getType('.txt'); // ⇨ 'text/plain'
|
||||
```
|
||||
|
||||
`null` is returned in cases where an extension is not detected or recognized
|
||||
|
||||
```javascript
|
||||
mime.getType('foo/txt'); // ⇨ null
|
||||
mime.getType('bogus_type'); // ⇨ null
|
||||
```
|
||||
|
||||
### mime.getExtension(type)
|
||||
Get extension for the given mime type. Charset options (often included in
|
||||
Content-Type headers) are ignored.
|
||||
|
||||
```javascript
|
||||
mime.getExtension('text/plain'); // ⇨ 'txt'
|
||||
mime.getExtension('application/json'); // ⇨ 'json'
|
||||
mime.getExtension('text/html; charset=utf8'); // ⇨ 'html'
|
||||
```
|
||||
|
||||
### mime.define(typeMap[, force = false])
|
||||
|
||||
Define [more] type mappings.
|
||||
|
||||
`typeMap` is a map of type -> extensions, as documented in `new Mime`, above.
|
||||
|
||||
By default this method will throw an error if you try to map a type to an
|
||||
extension that is already assigned to another type. Passing `true` for the
|
||||
`force` argument will suppress this behavior (overriding any previous mapping).
|
||||
|
||||
```javascript
|
||||
mime.define({'text/x-abc': ['abc', 'abcd']});
|
||||
|
||||
mime.getType('abcd'); // ⇨ 'text/x-abc'
|
||||
mime.getExtension('text/x-abc') // ⇨ 'abc'
|
||||
```
|
||||
|
||||
## Command Line
|
||||
|
||||
mime [path_or_extension]
|
||||
|
||||
E.g.
|
||||
|
||||
> mime scripts/jquery.js
|
||||
application/javascript
|
||||
|
||||
----
|
||||
Markdown generated from [src/README_js.md](src/README_js.md) by [](https://github.com/broofa/runmd)
|
||||
46
node_modules/mime/cli.js
generated
vendored
Normal file
46
node_modules/mime/cli.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
process.title = 'mime';
|
||||
let mime = require('.');
|
||||
let pkg = require('./package.json');
|
||||
let args = process.argv.splice(2);
|
||||
|
||||
if (args.includes('--version') || args.includes('-v') || args.includes('--v')) {
|
||||
console.log(pkg.version);
|
||||
process.exit(0);
|
||||
} else if (args.includes('--name') || args.includes('-n') || args.includes('--n')) {
|
||||
console.log(pkg.name);
|
||||
process.exit(0);
|
||||
} else if (args.includes('--help') || args.includes('-h') || args.includes('--h')) {
|
||||
console.log(pkg.name + ' - ' + pkg.description + '\n');
|
||||
console.log(`Usage:
|
||||
|
||||
mime [flags] [path_or_extension]
|
||||
|
||||
Flags:
|
||||
--help, -h Show this message
|
||||
--version, -v Display the version
|
||||
--name, -n Print the name of the program
|
||||
|
||||
Note: the command will exit after it executes if a command is specified
|
||||
The path_or_extension is the path to the file or the extension of the file.
|
||||
|
||||
Examples:
|
||||
mime --help
|
||||
mime --version
|
||||
mime --name
|
||||
mime -v
|
||||
mime src/log.js
|
||||
mime new.py
|
||||
mime foo.sh
|
||||
`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
let file = args[0];
|
||||
let type = mime.getType(file);
|
||||
|
||||
process.stdout.write(type + '\n');
|
||||
|
||||
4
node_modules/mime/index.js
generated
vendored
Normal file
4
node_modules/mime/index.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
let Mime = require('./Mime');
|
||||
module.exports = new Mime(require('./types/standard'), require('./types/other'));
|
||||
4
node_modules/mime/lite.js
generated
vendored
Normal file
4
node_modules/mime/lite.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
let Mime = require('./Mime');
|
||||
module.exports = new Mime(require('./types/standard'));
|
||||
52
node_modules/mime/package.json
generated
vendored
Normal file
52
node_modules/mime/package.json
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"author": {
|
||||
"name": "Robert Kieffer",
|
||||
"url": "http://github.com/broofa",
|
||||
"email": "robert@broofa.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"mime": "cli.js"
|
||||
},
|
||||
"contributors": [],
|
||||
"description": "A comprehensive library for mime-type mapping",
|
||||
"license": "MIT",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"benchmark": "*",
|
||||
"chalk": "4.1.2",
|
||||
"eslint": "8.1.0",
|
||||
"mime-db": "1.50.0",
|
||||
"mime-score": "1.2.0",
|
||||
"mime-types": "2.1.33",
|
||||
"mocha": "9.1.3",
|
||||
"runmd": "*",
|
||||
"standard-version": "9.3.2"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"lite.js",
|
||||
"Mime.js",
|
||||
"cli.js",
|
||||
"/types"
|
||||
],
|
||||
"scripts": {
|
||||
"prepare": "node src/build.js && runmd --output README.md src/README_js.md",
|
||||
"release": "standard-version",
|
||||
"benchmark": "node src/benchmark.js",
|
||||
"md": "runmd --watch --output README.md src/README_js.md",
|
||||
"test": "mocha src/test.js"
|
||||
},
|
||||
"keywords": [
|
||||
"util",
|
||||
"mime"
|
||||
],
|
||||
"name": "mime",
|
||||
"repository": {
|
||||
"url": "https://github.com/broofa/mime",
|
||||
"type": "git"
|
||||
},
|
||||
"version": "3.0.0"
|
||||
}
|
||||
1
node_modules/mime/types/other.js
generated
vendored
Normal file
1
node_modules/mime/types/other.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/mime/types/standard.js
generated
vendored
Normal file
1
node_modules/mime/types/standard.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
11
node_modules/os/README.md
generated
vendored
Normal file
11
node_modules/os/README.md
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# os
|
||||
|
||||
This is a Node.js Core Module
|
||||
|
||||
# There's no need to install through npm
|
||||
|
||||
**Really, there's no need, just require/import it :)**
|
||||
|
||||
## API
|
||||
|
||||
https://nodejs.org/api/os.html
|
||||
1
node_modules/os/index.js
generated
vendored
Normal file
1
node_modules/os/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('os')
|
||||
25
node_modules/os/package.json
generated
vendored
Normal file
25
node_modules/os/package.json
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "os",
|
||||
"version": "0.1.2",
|
||||
"description": "NodeJS Core Module Extended",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/DiegoRBaquero/node-os.git"
|
||||
},
|
||||
"keywords": [
|
||||
"node",
|
||||
"os",
|
||||
"core",
|
||||
"module"
|
||||
],
|
||||
"author": "Diego Rodríguez Baquero <diegorbaquero@gmail.com> (https://diegorbaquero.com)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/DiegoRBaquero/node-os/issues"
|
||||
},
|
||||
"homepage": "https://github.com/DiegoRBaquero/node-os#readme"
|
||||
}
|
||||
21
node_modules/three-orbitcontrols/LICENSE
generated
vendored
Normal file
21
node_modules/three-orbitcontrols/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
|
||||
Copyright © 2010-2018 three.js authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
1182
node_modules/three-orbitcontrols/OrbitControls.js
generated
vendored
Normal file
1182
node_modules/three-orbitcontrols/OrbitControls.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
84
node_modules/three-orbitcontrols/README.md
generated
vendored
Normal file
84
node_modules/three-orbitcontrols/README.md
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
**DEPRECATED**
|
||||
|
||||
[three-js] exposes real modules now via three/examples/jsm/...
|
||||
For example to import the Orbit, do
|
||||
|
||||
```js
|
||||
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls"
|
||||
```
|
||||
|
||||
# three-orbitcontrols
|
||||
|
||||
> is the [three.js] OrbitControls from official repo examples
|
||||
|
||||
## Installation
|
||||
|
||||
To install with npm do
|
||||
|
||||
```bash
|
||||
npm install three
|
||||
npm install three-orbitcontrols
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
All credit goes to [OrbitControls.js][original_orbitcontrols] contributors.
|
||||
See also [official OrbitControls documentation][orbitcontrols_documentation].
|
||||
|
||||
I have just **stolen** the code and modified to export it as a module so you can do something like
|
||||
|
||||
```javascript
|
||||
const THREE = require('three')
|
||||
const OrbitControls = require('three-orbitcontrols')
|
||||
// ES6 also works, i.e.
|
||||
// import OrbitControls from 'three-orbitcontrols'
|
||||
|
||||
// Init THREE scene (add your code)
|
||||
|
||||
const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000)
|
||||
camera.position.z = 5
|
||||
|
||||
const renderer = new THREE.WebGLRenderer({ canvas })
|
||||
|
||||
const controls = new OrbitControls(camera, renderer.domElement)
|
||||
controls.enableDamping = true
|
||||
controls.dampingFactor = 0.25
|
||||
controls.enableZoom = false
|
||||
```
|
||||
|
||||
Please note that:
|
||||
|
||||
1. You call `OrbitControls` directly instead of `THREE.OrbitControls`.
|
||||
2. This package does not depend directly on [three.js], which is declared as a peer dependency.
|
||||
|
||||
See also examples:
|
||||
|
||||
- [CommonJS example](https://github.com/fibo/three-orbitcontrols/tree/master/example.js): clone this repo, install deps and launch `npm run example_commonjs`.
|
||||
- [TypeScript example](https://github.com/fibo/three-orbitcontrols/tree/master/example.ts): clone this repo, install deps and launch `npm run example_typescript`.
|
||||
|
||||
## Changelog
|
||||
|
||||
See [OrbiControls.js history here](https://github.com/mrdoob/three.js/commits/master/examples/js/controls/OrbitControls.js).
|
||||
|
||||
Please also note that this repo's minor version equals [three.js] release number.
|
||||
|
||||
## Motivation
|
||||
|
||||
There is another package similar to this one: [three-orbit-controls].
|
||||
I decided to create another package with a different approach, see [this issue for the rationale](https://github.com/mattdesl/three-orbit-controls/issues/17).
|
||||
|
||||
I am using this package for my [3d tic tac toe canvas](https://github.com/fibo/tris3d-canvas): see also online [demo](http://g14n.info/tris3d-canvas/example/).
|
||||
|
||||
<!--
|
||||
I am using this package for my [3d tic tac toe](http://tris3d.net) online game.
|
||||
-->
|
||||
|
||||
## License
|
||||
|
||||
License is the same as [three.js], i.e. [MIT].
|
||||
|
||||
[original_orbitcontrols]: https://github.com/mrdoob/three.js/tree/master/examples/js/controls/OrbitControls.js "OrbitControls.js"
|
||||
[orbitcontrols_documentation]: https://threejs.org/docs/#examples/controls/OrbitControls "OrbitControls documentation"
|
||||
[three.js]: http://threejs.org/ "three.js"
|
||||
[MIT]: https://github.com/mrdoob/three.js/blob/master/LICENSE "three.js license"
|
||||
[three-orbit-controls]: https://www.npmjs.com/package/three-orbit-controls "three-orbit-controls"
|
||||
36
node_modules/three-orbitcontrols/example.js
generated
vendored
Normal file
36
node_modules/three-orbitcontrols/example.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
// To import package in your code use the following:
|
||||
//
|
||||
// const OrbitControls = require('three-orbitcontrols')
|
||||
//
|
||||
const OrbitControls = require('./OrbitControls.js')
|
||||
const THREE = require('three')
|
||||
|
||||
const width = window.innerWidth
|
||||
const height = window.innerHeight
|
||||
|
||||
const scene = new THREE.Scene()
|
||||
const camera = new THREE.PerspectiveCamera(75, width/height, 0.1, 1000)
|
||||
|
||||
const renderer = new THREE.WebGLRenderer()
|
||||
renderer.setSize(width, height)
|
||||
document.body.appendChild(renderer.domElement)
|
||||
|
||||
const geometry = new THREE.BoxGeometry(1, 1, 1)
|
||||
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 })
|
||||
const cube = new THREE.Mesh(geometry, material)
|
||||
scene.add(cube)
|
||||
|
||||
camera.position.z = 5
|
||||
|
||||
const controls = new OrbitControls(camera, renderer.domElement)
|
||||
|
||||
function animate() {
|
||||
requestAnimationFrame(animate)
|
||||
|
||||
cube.rotation.x += 0.01
|
||||
cube.rotation.y += 0.01
|
||||
|
||||
renderer.render(scene, camera)
|
||||
}
|
||||
|
||||
animate()
|
||||
36
node_modules/three-orbitcontrols/example.ts
generated
vendored
Normal file
36
node_modules/three-orbitcontrols/example.ts
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
// To import package in your code use the following:
|
||||
//
|
||||
// import * as OrbitControls from 'three-orbitcontrols';
|
||||
//
|
||||
import * as OrbitControls from './OrbitControls.js';
|
||||
import * as THREE from 'three';
|
||||
|
||||
const width = window.innerWidth;
|
||||
const height = window.innerHeight;
|
||||
|
||||
const scene = new THREE.Scene();
|
||||
const camera = new THREE.PerspectiveCamera(75, width/height, 0.1, 1000);
|
||||
|
||||
const renderer = new THREE.WebGLRenderer();
|
||||
renderer.setSize(width, height);
|
||||
document.body.appendChild(renderer.domElement);
|
||||
|
||||
const geometry = new THREE.BoxGeometry(1, 1, 1);
|
||||
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
|
||||
const cube = new THREE.Mesh(geometry, material);
|
||||
scene.add(cube);
|
||||
|
||||
camera.position.z = 5;
|
||||
|
||||
const controls = new OrbitControls(camera, renderer.domElement);
|
||||
|
||||
function animate() {
|
||||
requestAnimationFrame(animate);
|
||||
|
||||
cube.rotation.x += 0.01;
|
||||
cube.rotation.y += 0.01;
|
||||
|
||||
renderer.render(scene, camera);
|
||||
}
|
||||
|
||||
animate();
|
||||
44
node_modules/three-orbitcontrols/package.json
generated
vendored
Normal file
44
node_modules/three-orbitcontrols/package.json
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "three-orbitcontrols",
|
||||
"version": "2.110.3",
|
||||
"description": "is the three.js OrbitControls from official repo examples",
|
||||
"main": "OrbitControls.js",
|
||||
"scripts": {
|
||||
"example_commonjs": "budo example.js --open",
|
||||
"example_typescript": "budo example.ts --open -- -p [tsify]",
|
||||
"deploy": "npm version patch",
|
||||
"predeploy": "npm test",
|
||||
"postversion": "git push origin v${npm_package_version}; npm publish; git push origin master",
|
||||
"test": "node test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/fibo/three-orbitcontrols.git"
|
||||
},
|
||||
"keywords": [
|
||||
"three",
|
||||
"three.js",
|
||||
"3d",
|
||||
"camera",
|
||||
"controls"
|
||||
],
|
||||
"author": {
|
||||
"name": "Gianluca Casati",
|
||||
"url": "http://g14n.info"
|
||||
},
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/fibo/three-orbitcontrols/issues"
|
||||
},
|
||||
"homepage": "http://g14n.info/three-orbitcontrols",
|
||||
"peerDependencies": {
|
||||
"three": ">= 0.110.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^12.12.5",
|
||||
"budo": "^11.6.3",
|
||||
"three": "^0.110.0",
|
||||
"tsify": "^4.0.1",
|
||||
"typescript": "^3.6.4"
|
||||
}
|
||||
}
|
||||
8
node_modules/three-orbitcontrols/test.js
generated
vendored
Normal file
8
node_modules/three-orbitcontrols/test.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
const assert = require('assert')
|
||||
|
||||
const { version, peerDependencies } = require('./package.json')
|
||||
|
||||
const orbitControlsMinorVersion = version.split('.')[1]
|
||||
const threeMinorVersion = peerDependencies.three.split('.')[1]
|
||||
|
||||
assert.equal(orbitControlsMinorVersion, threeMinorVersion, 'minor version is the same as threejs release')
|
||||
21
node_modules/three/LICENSE
generated
vendored
Normal file
21
node_modules/three/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
|
||||
Copyright © 2010-2023 three.js authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
86
node_modules/three/README.md
generated
vendored
Normal file
86
node_modules/three/README.md
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
# three.js
|
||||
|
||||
[![NPM Package][npm]][npm-url]
|
||||
[![Build Size][build-size]][build-size-url]
|
||||
[![NPM Downloads][npm-downloads]][npmtrends-url]
|
||||
[![DeepScan][deepscan]][deepscan-url]
|
||||
[![Discord][discord]][discord-url]
|
||||
|
||||
#### JavaScript 3D library
|
||||
|
||||
The aim of the project is to create an easy-to-use, lightweight, cross-browser, general-purpose 3D library. The current builds only include a WebGL renderer but WebGPU (experimental), SVG and CSS3D renderers are also available as addons.
|
||||
|
||||
[Examples](https://threejs.org/examples/) —
|
||||
[Docs](https://threejs.org/docs/) —
|
||||
[Manual](https://threejs.org/manual/) —
|
||||
[Wiki](https://github.com/mrdoob/three.js/wiki) —
|
||||
[Migrating](https://github.com/mrdoob/three.js/wiki/Migration-Guide) —
|
||||
[Questions](https://stackoverflow.com/questions/tagged/three.js) —
|
||||
[Forum](https://discourse.threejs.org/) —
|
||||
[Discord](https://discord.gg/56GBJwAnUS)
|
||||
|
||||
### Usage
|
||||
|
||||
This code creates a scene, a camera, and a geometric cube, and it adds the cube to the scene. It then creates a `WebGL` renderer for the scene and camera, and it adds that viewport to the `document.body` element. Finally, it animates the cube within the scene for the camera.
|
||||
|
||||
```javascript
|
||||
import * as THREE from 'three';
|
||||
|
||||
const width = window.innerWidth, height = window.innerHeight;
|
||||
|
||||
// init
|
||||
|
||||
const camera = new THREE.PerspectiveCamera( 70, width / height, 0.01, 10 );
|
||||
camera.position.z = 1;
|
||||
|
||||
const scene = new THREE.Scene();
|
||||
|
||||
const geometry = new THREE.BoxGeometry( 0.2, 0.2, 0.2 );
|
||||
const material = new THREE.MeshNormalMaterial();
|
||||
|
||||
const mesh = new THREE.Mesh( geometry, material );
|
||||
scene.add( mesh );
|
||||
|
||||
const renderer = new THREE.WebGLRenderer( { antialias: true } );
|
||||
renderer.setSize( width, height );
|
||||
renderer.setAnimationLoop( animation );
|
||||
document.body.appendChild( renderer.domElement );
|
||||
|
||||
// animation
|
||||
|
||||
function animation( time ) {
|
||||
|
||||
mesh.rotation.x = time / 2000;
|
||||
mesh.rotation.y = time / 1000;
|
||||
|
||||
renderer.render( scene, camera );
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
If everything goes well, you should see [this](https://jsfiddle.net/2nyxkmco/).
|
||||
|
||||
### Cloning this repository
|
||||
|
||||
Cloning the repo with all its history results in a ~2 GB download. If you don't need the whole history you can use the `depth` parameter to significantly reduce download size.
|
||||
|
||||
```sh
|
||||
git clone --depth=1 https://github.com/mrdoob/three.js.git
|
||||
```
|
||||
|
||||
### Change log
|
||||
|
||||
[Releases](https://github.com/mrdoob/three.js/releases)
|
||||
|
||||
|
||||
[npm]: https://img.shields.io/npm/v/three
|
||||
[npm-url]: https://www.npmjs.com/package/three
|
||||
[build-size]: https://badgen.net/bundlephobia/minzip/three
|
||||
[build-size-url]: https://bundlephobia.com/result?p=three
|
||||
[npm-downloads]: https://img.shields.io/npm/dw/three
|
||||
[npmtrends-url]: https://www.npmtrends.com/three
|
||||
[deepscan]: https://deepscan.io/api/teams/16600/projects/19901/branches/525701/badge/grade.svg
|
||||
[deepscan-url]: https://deepscan.io/dashboard#view=project&tid=16600&pid=19901&bid=525701
|
||||
[discord]: https://img.shields.io/discord/685241246557667386
|
||||
[discord-url]: https://discord.gg/56GBJwAnUS
|
||||
|
||||
52121
node_modules/three/build/three.cjs
generated
vendored
Normal file
52121
node_modules/three/build/three.cjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
52128
node_modules/three/build/three.js
generated
vendored
Normal file
52128
node_modules/three/build/three.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
7
node_modules/three/build/three.min.js
generated
vendored
Normal file
7
node_modules/three/build/three.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
51706
node_modules/three/build/three.module.js
generated
vendored
Normal file
51706
node_modules/three/build/three.module.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
6
node_modules/three/build/three.module.min.js
generated
vendored
Normal file
6
node_modules/three/build/three.module.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
13
node_modules/three/examples/fonts/LICENSE
generated
vendored
Normal file
13
node_modules/three/examples/fonts/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
Copyright @ 2004 by MAGENTA Ltd. All Rights Reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright and this permission notice shall be included in all copies of one or more of the Font Software typefaces.
|
||||
|
||||
The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing the word "MgOpen", or if the modifications are accepted for inclusion in the Font Software itself by the each appointed Administrator.
|
||||
|
||||
This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "MgOpen" name.
|
||||
|
||||
The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself.
|
||||
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL MAGENTA OR PERSONS OR BODIES IN CHARGE OF ADMINISTRATION AND MAINTENANCE OF THE FONT SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
11
node_modules/three/examples/fonts/README.md
generated
vendored
Normal file
11
node_modules/three/examples/fonts/README.md
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
## MgOpen typefaces
|
||||
|
||||
# Source and License
|
||||
|
||||
https://web.archive.org/web/20050528114140/https://ellak.gr/fonts/mgopen/index.en
|
||||
|
||||
# Usage
|
||||
|
||||
Use Facetype.js to generate typeface.json fonts: https://gero3.github.io/facetype.js/
|
||||
|
||||
Collection of Google fonts as typeface data for usage with three.js: https://github.com/components-ai/typefaces
|
||||
190
node_modules/three/examples/fonts/droid/NOTICE
generated
vendored
Normal file
190
node_modules/three/examples/fonts/droid/NOTICE
generated
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
|
||||
Copyright (c) 2005-2008, The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
18
node_modules/three/examples/fonts/droid/README.txt
generated
vendored
Normal file
18
node_modules/three/examples/fonts/droid/README.txt
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
Copyright (C) 2008 The Android Open Source Project
|
||||
|
||||
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.
|
||||
|
||||
##########
|
||||
|
||||
This directory contains the fonts for the platform. They are licensed
|
||||
under the Apache 2 license.
|
||||
1
node_modules/three/examples/fonts/droid/droid_sans_bold.typeface.json
generated
vendored
Normal file
1
node_modules/three/examples/fonts/droid/droid_sans_bold.typeface.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/three/examples/fonts/droid/droid_sans_mono_regular.typeface.json
generated
vendored
Normal file
1
node_modules/three/examples/fonts/droid/droid_sans_mono_regular.typeface.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/three/examples/fonts/droid/droid_sans_regular.typeface.json
generated
vendored
Normal file
1
node_modules/three/examples/fonts/droid/droid_sans_regular.typeface.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/three/examples/fonts/droid/droid_serif_bold.typeface.json
generated
vendored
Normal file
1
node_modules/three/examples/fonts/droid/droid_serif_bold.typeface.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/three/examples/fonts/droid/droid_serif_regular.typeface.json
generated
vendored
Normal file
1
node_modules/three/examples/fonts/droid/droid_serif_regular.typeface.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/three/examples/fonts/gentilis_bold.typeface.json
generated
vendored
Normal file
1
node_modules/three/examples/fonts/gentilis_bold.typeface.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/three/examples/fonts/gentilis_regular.typeface.json
generated
vendored
Normal file
1
node_modules/three/examples/fonts/gentilis_regular.typeface.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/three/examples/fonts/helvetiker_bold.typeface.json
generated
vendored
Normal file
1
node_modules/three/examples/fonts/helvetiker_bold.typeface.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/three/examples/fonts/helvetiker_regular.typeface.json
generated
vendored
Normal file
1
node_modules/three/examples/fonts/helvetiker_regular.typeface.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/three/examples/fonts/optimer_bold.typeface.json
generated
vendored
Normal file
1
node_modules/three/examples/fonts/optimer_bold.typeface.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/three/examples/fonts/optimer_regular.typeface.json
generated
vendored
Normal file
1
node_modules/three/examples/fonts/optimer_regular.typeface.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
9
node_modules/three/examples/fonts/ttf/README.md
generated
vendored
Normal file
9
node_modules/three/examples/fonts/ttf/README.md
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# Kenney Fonts
|
||||
|
||||
## Source
|
||||
|
||||
https://www.kenney.nl/assets/kenney-fonts
|
||||
|
||||
## License
|
||||
|
||||
CC0 1.0 Universal (CC0 1.0) Public Domain Dedication (https://creativecommons.org/publicdomain/zero/1.0/)
|
||||
BIN
node_modules/three/examples/fonts/ttf/kenpixel.ttf
generated
vendored
Normal file
BIN
node_modules/three/examples/fonts/ttf/kenpixel.ttf
generated
vendored
Normal file
Binary file not shown.
290
node_modules/three/examples/jsm/Addons.js
generated
vendored
Normal file
290
node_modules/three/examples/jsm/Addons.js
generated
vendored
Normal file
@@ -0,0 +1,290 @@
|
||||
export * from './animation/AnimationClipCreator.js';
|
||||
export * from './animation/CCDIKSolver.js';
|
||||
export * from './animation/MMDAnimationHelper.js';
|
||||
export * from './animation/MMDPhysics.js';
|
||||
|
||||
export * from './cameras/CinematicCamera.js';
|
||||
|
||||
export { default as WebGL } from './capabilities/WebGL.js';
|
||||
|
||||
export * from './controls/ArcballControls.js';
|
||||
export * from './controls/DragControls.js';
|
||||
export * from './controls/FirstPersonControls.js';
|
||||
export * from './controls/FlyControls.js';
|
||||
export * from './controls/MapControls.js';
|
||||
export * from './controls/OrbitControls.js';
|
||||
export * from './controls/PointerLockControls.js';
|
||||
export * from './controls/TrackballControls.js';
|
||||
export * from './controls/TransformControls.js';
|
||||
|
||||
export * from './csm/CSM.js';
|
||||
export * from './csm/CSMFrustum.js';
|
||||
export * from './csm/CSMHelper.js';
|
||||
export * from './csm/CSMShader.js';
|
||||
|
||||
export * as Curves from './curves/CurveExtras.js';
|
||||
export * from './curves/NURBSCurve.js';
|
||||
export * from './curves/NURBSSurface.js';
|
||||
export * as NURBSUtils from './curves/NURBSUtils.js';
|
||||
|
||||
export * from './effects/AnaglyphEffect.js';
|
||||
export * from './effects/AsciiEffect.js';
|
||||
export * from './effects/OutlineEffect.js';
|
||||
export * from './effects/ParallaxBarrierEffect.js';
|
||||
export * from './effects/PeppersGhostEffect.js';
|
||||
export * from './effects/StereoEffect.js';
|
||||
|
||||
export * from './environments/DebugEnvironment.js';
|
||||
export * from './environments/RoomEnvironment.js';
|
||||
|
||||
export * from './exporters/DRACOExporter.js';
|
||||
export * from './exporters/EXRExporter.js';
|
||||
export * from './exporters/GLTFExporter.js';
|
||||
export * from './exporters/KTX2Exporter.js';
|
||||
export * from './exporters/MMDExporter.js';
|
||||
export * from './exporters/OBJExporter.js';
|
||||
export * from './exporters/PLYExporter.js';
|
||||
export * from './exporters/STLExporter.js';
|
||||
export * from './exporters/USDZExporter.js';
|
||||
|
||||
export * from './geometries/BoxLineGeometry.js';
|
||||
export * from './geometries/ConvexGeometry.js';
|
||||
export * from './geometries/DecalGeometry.js';
|
||||
export * from './geometries/ParametricGeometries.js';
|
||||
export * from './geometries/ParametricGeometry.js';
|
||||
export * from './geometries/RoundedBoxGeometry.js';
|
||||
export * from './geometries/TeapotGeometry.js';
|
||||
export * from './geometries/TextGeometry.js';
|
||||
|
||||
export * from './helpers/LightProbeHelper.js';
|
||||
export * from './helpers/OctreeHelper.js';
|
||||
export * from './helpers/PositionalAudioHelper.js';
|
||||
export * from './helpers/RectAreaLightHelper.js';
|
||||
export * from './helpers/VertexNormalsHelper.js';
|
||||
export * from './helpers/VertexTangentsHelper.js';
|
||||
export * from './helpers/ViewHelper.js';
|
||||
|
||||
export * from './interactive/HTMLMesh.js';
|
||||
export * from './interactive/InteractiveGroup.js';
|
||||
export * from './interactive/SelectionBox.js';
|
||||
export * from './interactive/SelectionHelper.js';
|
||||
|
||||
export { default as IESSpotLight } from './lights/IESSpotLight.js';
|
||||
export * from './lights/LightProbeGenerator.js';
|
||||
export * from './lights/RectAreaLightUniformsLib.js';
|
||||
|
||||
export * from './lines/Line2.js';
|
||||
export * from './lines/LineGeometry.js';
|
||||
export * from './lines/LineMaterial.js';
|
||||
export * from './lines/LineSegments2.js';
|
||||
export * from './lines/LineSegmentsGeometry.js';
|
||||
export * from './lines/Wireframe.js';
|
||||
export * from './lines/WireframeGeometry2.js';
|
||||
|
||||
export * from './loaders/3DMLoader.js';
|
||||
export * from './loaders/3MFLoader.js';
|
||||
export * from './loaders/AMFLoader.js';
|
||||
export * from './loaders/BVHLoader.js';
|
||||
export * from './loaders/ColladaLoader.js';
|
||||
export * from './loaders/DDSLoader.js';
|
||||
export * from './loaders/DRACOLoader.js';
|
||||
export * from './loaders/EXRLoader.js';
|
||||
export * from './loaders/FBXLoader.js';
|
||||
export * from './loaders/FontLoader.js';
|
||||
export * from './loaders/GCodeLoader.js';
|
||||
export * from './loaders/GLTFLoader.js';
|
||||
export * from './loaders/HDRCubeTextureLoader.js';
|
||||
export * from './loaders/IESLoader.js';
|
||||
export * from './loaders/KMZLoader.js';
|
||||
export * from './loaders/KTX2Loader.js';
|
||||
export * from './loaders/KTXLoader.js';
|
||||
export * from './loaders/LDrawLoader.js';
|
||||
export * from './loaders/LUT3dlLoader.js';
|
||||
export * from './loaders/LUTCubeLoader.js';
|
||||
export * from './loaders/LWOLoader.js';
|
||||
export * from './loaders/LogLuvLoader.js';
|
||||
export * from './loaders/LottieLoader.js';
|
||||
export * from './loaders/MD2Loader.js';
|
||||
export * from './loaders/MDDLoader.js';
|
||||
export * from './loaders/MMDLoader.js';
|
||||
export * from './loaders/MTLLoader.js';
|
||||
export * from './loaders/NRRDLoader.js';
|
||||
export * from './loaders/OBJLoader.js';
|
||||
export * from './loaders/PCDLoader.js';
|
||||
export * from './loaders/PDBLoader.js';
|
||||
export * from './loaders/PLYLoader.js';
|
||||
export * from './loaders/PVRLoader.js';
|
||||
export * from './loaders/RGBELoader.js';
|
||||
export * from './loaders/RGBMLoader.js';
|
||||
export * from './loaders/STLLoader.js';
|
||||
export * from './loaders/SVGLoader.js';
|
||||
export * from './loaders/TDSLoader.js';
|
||||
export * from './loaders/TGALoader.js';
|
||||
export * from './loaders/TIFFLoader.js';
|
||||
export * from './loaders/TTFLoader.js';
|
||||
export * from './loaders/TiltLoader.js';
|
||||
export * from './loaders/USDZLoader.js';
|
||||
export * from './loaders/VOXLoader.js';
|
||||
export * from './loaders/VRMLLoader.js';
|
||||
export * from './loaders/VTKLoader.js';
|
||||
export * from './loaders/XYZLoader.js';
|
||||
|
||||
export * from './materials/MeshGouraudMaterial.js';
|
||||
|
||||
export * from './math/Capsule.js';
|
||||
export * from './math/ColorConverter.js';
|
||||
export * from './math/ConvexHull.js';
|
||||
export * from './math/ImprovedNoise.js';
|
||||
export * from './math/Lut.js';
|
||||
export * from './math/MeshSurfaceSampler.js';
|
||||
export * from './math/OBB.js';
|
||||
export * from './math/Octree.js';
|
||||
export * from './math/SimplexNoise.js';
|
||||
|
||||
export * from './misc/ConvexObjectBreaker.js';
|
||||
export * from './misc/GPUComputationRenderer.js';
|
||||
export * from './misc/Gyroscope.js';
|
||||
export * from './misc/MD2Character.js';
|
||||
export * from './misc/MD2CharacterComplex.js';
|
||||
export * from './misc/MorphAnimMesh.js';
|
||||
export * from './misc/MorphBlendMesh.js';
|
||||
export * from './misc/ProgressiveLightMap.js';
|
||||
export * from './misc/RollerCoaster.js';
|
||||
export * from './misc/TubePainter.js';
|
||||
export * from './misc/Volume.js';
|
||||
export * from './misc/VolumeSlice.js';
|
||||
|
||||
export * from './modifiers/CurveModifier.js';
|
||||
export * from './modifiers/EdgeSplitModifier.js';
|
||||
export * from './modifiers/SimplifyModifier.js';
|
||||
export * from './modifiers/TessellateModifier.js';
|
||||
|
||||
export * from './objects/BatchedMesh.js';
|
||||
export * from './objects/GroundProjectedSkybox.js';
|
||||
export * from './objects/Lensflare.js';
|
||||
export * from './objects/MarchingCubes.js';
|
||||
export * from './objects/Reflector.js';
|
||||
export * from './objects/ReflectorForSSRPass.js';
|
||||
export * from './objects/Refractor.js';
|
||||
export * from './objects/ShadowMesh.js';
|
||||
export * from './objects/Sky.js';
|
||||
export * from './objects/Water.js';
|
||||
export { Water as Water2 } from './objects/Water2.js';
|
||||
|
||||
export * from './physics/AmmoPhysics.js';
|
||||
export * from './physics/RapierPhysics.js';
|
||||
|
||||
export * from './postprocessing/AfterimagePass.js';
|
||||
export * from './postprocessing/BloomPass.js';
|
||||
export * from './postprocessing/BokehPass.js';
|
||||
export * from './postprocessing/ClearPass.js';
|
||||
export * from './postprocessing/CubeTexturePass.js';
|
||||
export * from './postprocessing/DotScreenPass.js';
|
||||
export * from './postprocessing/EffectComposer.js';
|
||||
export * from './postprocessing/FilmPass.js';
|
||||
export * from './postprocessing/GlitchPass.js';
|
||||
export * from './postprocessing/HalftonePass.js';
|
||||
export * from './postprocessing/LUTPass.js';
|
||||
export * from './postprocessing/MaskPass.js';
|
||||
export * from './postprocessing/OutlinePass.js';
|
||||
export * from './postprocessing/OutputPass.js';
|
||||
export * from './postprocessing/Pass.js';
|
||||
export * from './postprocessing/RenderPass.js';
|
||||
export * from './postprocessing/RenderPixelatedPass.js';
|
||||
export * from './postprocessing/SAOPass.js';
|
||||
export * from './postprocessing/SMAAPass.js';
|
||||
export * from './postprocessing/SSAARenderPass.js';
|
||||
export * from './postprocessing/SSAOPass.js';
|
||||
export * from './postprocessing/SSRPass.js';
|
||||
export * from './postprocessing/SavePass.js';
|
||||
export * from './postprocessing/ShaderPass.js';
|
||||
export * from './postprocessing/TAARenderPass.js';
|
||||
export * from './postprocessing/TexturePass.js';
|
||||
export * from './postprocessing/UnrealBloomPass.js';
|
||||
|
||||
export * from './renderers/CSS2DRenderer.js';
|
||||
export * from './renderers/CSS3DRenderer.js';
|
||||
export * from './renderers/Projector.js';
|
||||
export * from './renderers/SVGRenderer.js';
|
||||
|
||||
export * from './shaders/ACESFilmicToneMappingShader.js';
|
||||
export * from './shaders/AfterimageShader.js';
|
||||
export * from './shaders/BasicShader.js';
|
||||
export * from './shaders/BleachBypassShader.js';
|
||||
export * from './shaders/BlendShader.js';
|
||||
export * from './shaders/BokehShader.js';
|
||||
export { BokehShader as BokehShader2 } from './shaders/BokehShader2.js';
|
||||
export * from './shaders/BrightnessContrastShader.js';
|
||||
export * from './shaders/ColorCorrectionShader.js';
|
||||
export * from './shaders/ColorifyShader.js';
|
||||
export * from './shaders/ConvolutionShader.js';
|
||||
export * from './shaders/CopyShader.js';
|
||||
export * from './shaders/DOFMipMapShader.js';
|
||||
export * from './shaders/DepthLimitedBlurShader.js';
|
||||
export * from './shaders/DigitalGlitch.js';
|
||||
export * from './shaders/DotScreenShader.js';
|
||||
export * from './shaders/ExposureShader.js';
|
||||
export * from './shaders/FXAAShader.js';
|
||||
export * from './shaders/FilmShader.js';
|
||||
export * from './shaders/FocusShader.js';
|
||||
export * from './shaders/FreiChenShader.js';
|
||||
export * from './shaders/GammaCorrectionShader.js';
|
||||
export * from './shaders/GodRaysShader.js';
|
||||
export * from './shaders/HalftoneShader.js';
|
||||
export * from './shaders/HorizontalBlurShader.js';
|
||||
export * from './shaders/HorizontalTiltShiftShader.js';
|
||||
export * from './shaders/HueSaturationShader.js';
|
||||
export * from './shaders/KaleidoShader.js';
|
||||
export * from './shaders/LuminosityHighPassShader.js';
|
||||
export * from './shaders/LuminosityShader.js';
|
||||
export * from './shaders/MMDToonShader.js';
|
||||
export * from './shaders/MirrorShader.js';
|
||||
export * from './shaders/NormalMapShader.js';
|
||||
export * from './shaders/OutputShader.js';
|
||||
export * from './shaders/RGBShiftShader.js';
|
||||
export * from './shaders/SAOShader.js';
|
||||
export * from './shaders/SMAAShader.js';
|
||||
export * from './shaders/SSAOShader.js';
|
||||
export * from './shaders/SSRShader.js';
|
||||
export * from './shaders/SepiaShader.js';
|
||||
export * from './shaders/SobelOperatorShader.js';
|
||||
export * from './shaders/SubsurfaceScatteringShader.js';
|
||||
export * from './shaders/TechnicolorShader.js';
|
||||
export * from './shaders/ToonShader.js';
|
||||
export * from './shaders/TriangleBlurShader.js';
|
||||
export * from './shaders/UnpackDepthRGBAShader.js';
|
||||
export * from './shaders/VelocityShader.js';
|
||||
export * from './shaders/VerticalBlurShader.js';
|
||||
export * from './shaders/VerticalTiltShiftShader.js';
|
||||
export * from './shaders/VignetteShader.js';
|
||||
export * from './shaders/VolumeShader.js';
|
||||
export * from './shaders/WaterRefractionShader.js';
|
||||
|
||||
export * from './textures/FlakesTexture.js';
|
||||
|
||||
export * as BufferGeometryUtils from './utils/BufferGeometryUtils.js';
|
||||
export * as CameraUtils from './utils/CameraUtils.js';
|
||||
export * from './utils/GPUStatsPanel.js';
|
||||
export * as GeometryCompressionUtils from './utils/GeometryCompressionUtils.js';
|
||||
export * as GeometryUtils from './utils/GeometryUtils.js';
|
||||
export * from './utils/LDrawUtils.js';
|
||||
export * from './utils/PackedPhongMaterial.js';
|
||||
export * as SceneUtils from './utils/SceneUtils.js';
|
||||
export * from './utils/ShadowMapViewer.js';
|
||||
export * as SkeletonUtils from './utils/SkeletonUtils.js';
|
||||
export * from './utils/TextureUtils.js';
|
||||
export * from './utils/UVsDebug.js';
|
||||
export * from './utils/WorkerPool.js';
|
||||
|
||||
export * from './webxr/ARButton.js';
|
||||
export * from './webxr/OculusHandModel.js';
|
||||
export * from './webxr/OculusHandPointerModel.js';
|
||||
export * from './webxr/Text2D.js';
|
||||
export * from './webxr/VRButton.js';
|
||||
export * from './webxr/XRButton.js';
|
||||
export * from './webxr/XRControllerModelFactory.js';
|
||||
export * from './webxr/XREstimatedLight.js';
|
||||
export * from './webxr/XRHandMeshModel.js';
|
||||
export * from './webxr/XRHandModelFactory.js';
|
||||
export * from './webxr/XRHandPrimitiveModel.js';
|
||||
export * from './webxr/XRPlanes.js';
|
||||
116
node_modules/three/examples/jsm/animation/AnimationClipCreator.js
generated
vendored
Normal file
116
node_modules/three/examples/jsm/animation/AnimationClipCreator.js
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
import {
|
||||
AnimationClip,
|
||||
BooleanKeyframeTrack,
|
||||
ColorKeyframeTrack,
|
||||
NumberKeyframeTrack,
|
||||
Vector3,
|
||||
VectorKeyframeTrack
|
||||
} from 'three';
|
||||
|
||||
class AnimationClipCreator {
|
||||
|
||||
static CreateRotationAnimation( period, axis = 'x' ) {
|
||||
|
||||
const times = [ 0, period ], values = [ 0, 360 ];
|
||||
|
||||
const trackName = '.rotation[' + axis + ']';
|
||||
|
||||
const track = new NumberKeyframeTrack( trackName, times, values );
|
||||
|
||||
return new AnimationClip( null, period, [ track ] );
|
||||
|
||||
}
|
||||
|
||||
static CreateScaleAxisAnimation( period, axis = 'x' ) {
|
||||
|
||||
const times = [ 0, period ], values = [ 0, 1 ];
|
||||
|
||||
const trackName = '.scale[' + axis + ']';
|
||||
|
||||
const track = new NumberKeyframeTrack( trackName, times, values );
|
||||
|
||||
return new AnimationClip( null, period, [ track ] );
|
||||
|
||||
}
|
||||
|
||||
static CreateShakeAnimation( duration, shakeScale ) {
|
||||
|
||||
const times = [], values = [], tmp = new Vector3();
|
||||
|
||||
for ( let i = 0; i < duration * 10; i ++ ) {
|
||||
|
||||
times.push( i / 10 );
|
||||
|
||||
tmp.set( Math.random() * 2.0 - 1.0, Math.random() * 2.0 - 1.0, Math.random() * 2.0 - 1.0 ).
|
||||
multiply( shakeScale ).
|
||||
toArray( values, values.length );
|
||||
|
||||
}
|
||||
|
||||
const trackName = '.position';
|
||||
|
||||
const track = new VectorKeyframeTrack( trackName, times, values );
|
||||
|
||||
return new AnimationClip( null, duration, [ track ] );
|
||||
|
||||
}
|
||||
|
||||
static CreatePulsationAnimation( duration, pulseScale ) {
|
||||
|
||||
const times = [], values = [], tmp = new Vector3();
|
||||
|
||||
for ( let i = 0; i < duration * 10; i ++ ) {
|
||||
|
||||
times.push( i / 10 );
|
||||
|
||||
const scaleFactor = Math.random() * pulseScale;
|
||||
tmp.set( scaleFactor, scaleFactor, scaleFactor ).
|
||||
toArray( values, values.length );
|
||||
|
||||
}
|
||||
|
||||
const trackName = '.scale';
|
||||
|
||||
const track = new VectorKeyframeTrack( trackName, times, values );
|
||||
|
||||
return new AnimationClip( null, duration, [ track ] );
|
||||
|
||||
}
|
||||
|
||||
static CreateVisibilityAnimation( duration ) {
|
||||
|
||||
const times = [ 0, duration / 2, duration ], values = [ true, false, true ];
|
||||
|
||||
const trackName = '.visible';
|
||||
|
||||
const track = new BooleanKeyframeTrack( trackName, times, values );
|
||||
|
||||
return new AnimationClip( null, duration, [ track ] );
|
||||
|
||||
}
|
||||
|
||||
static CreateMaterialColorAnimation( duration, colors ) {
|
||||
|
||||
const times = [], values = [],
|
||||
timeStep = duration / colors.length;
|
||||
|
||||
for ( let i = 0; i < colors.length; i ++ ) {
|
||||
|
||||
times.push( i * timeStep );
|
||||
|
||||
const color = colors[ i ];
|
||||
values.push( color.r, color.g, color.b );
|
||||
|
||||
}
|
||||
|
||||
const trackName = '.material.color';
|
||||
|
||||
const track = new ColorKeyframeTrack( trackName, times, values );
|
||||
|
||||
return new AnimationClip( null, duration, [ track ] );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { AnimationClipCreator };
|
||||
482
node_modules/three/examples/jsm/animation/CCDIKSolver.js
generated
vendored
Normal file
482
node_modules/three/examples/jsm/animation/CCDIKSolver.js
generated
vendored
Normal file
@@ -0,0 +1,482 @@
|
||||
import {
|
||||
BufferAttribute,
|
||||
BufferGeometry,
|
||||
Color,
|
||||
Line,
|
||||
LineBasicMaterial,
|
||||
Matrix4,
|
||||
Mesh,
|
||||
MeshBasicMaterial,
|
||||
Object3D,
|
||||
Quaternion,
|
||||
SphereGeometry,
|
||||
Vector3
|
||||
} from 'three';
|
||||
|
||||
const _q = new Quaternion();
|
||||
const _targetPos = new Vector3();
|
||||
const _targetVec = new Vector3();
|
||||
const _effectorPos = new Vector3();
|
||||
const _effectorVec = new Vector3();
|
||||
const _linkPos = new Vector3();
|
||||
const _invLinkQ = new Quaternion();
|
||||
const _linkScale = new Vector3();
|
||||
const _axis = new Vector3();
|
||||
const _vector = new Vector3();
|
||||
const _matrix = new Matrix4();
|
||||
|
||||
|
||||
/**
|
||||
* CCD Algorithm
|
||||
* - https://sites.google.com/site/auraliusproject/ccd-algorithm
|
||||
*
|
||||
* // ik parameter example
|
||||
* //
|
||||
* // target, effector, index in links are bone index in skeleton.bones.
|
||||
* // the bones relation should be
|
||||
* // <-- parent child -->
|
||||
* // links[ n ], links[ n - 1 ], ..., links[ 0 ], effector
|
||||
* iks = [ {
|
||||
* target: 1,
|
||||
* effector: 2,
|
||||
* links: [ { index: 5, limitation: new Vector3( 1, 0, 0 ) }, { index: 4, enabled: false }, { index : 3 } ],
|
||||
* iteration: 10,
|
||||
* minAngle: 0.0,
|
||||
* maxAngle: 1.0,
|
||||
* } ];
|
||||
*/
|
||||
|
||||
class CCDIKSolver {
|
||||
|
||||
/**
|
||||
* @param {THREE.SkinnedMesh} mesh
|
||||
* @param {Array<Object>} iks
|
||||
*/
|
||||
constructor( mesh, iks = [] ) {
|
||||
|
||||
this.mesh = mesh;
|
||||
this.iks = iks;
|
||||
|
||||
this._valid();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update all IK bones.
|
||||
*
|
||||
* @return {CCDIKSolver}
|
||||
*/
|
||||
update() {
|
||||
|
||||
const iks = this.iks;
|
||||
|
||||
for ( let i = 0, il = iks.length; i < il; i ++ ) {
|
||||
|
||||
this.updateOne( iks[ i ] );
|
||||
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update one IK bone
|
||||
*
|
||||
* @param {Object} ik parameter
|
||||
* @return {CCDIKSolver}
|
||||
*/
|
||||
updateOne( ik ) {
|
||||
|
||||
const bones = this.mesh.skeleton.bones;
|
||||
|
||||
// for reference overhead reduction in loop
|
||||
const math = Math;
|
||||
|
||||
const effector = bones[ ik.effector ];
|
||||
const target = bones[ ik.target ];
|
||||
|
||||
// don't use getWorldPosition() here for the performance
|
||||
// because it calls updateMatrixWorld( true ) inside.
|
||||
_targetPos.setFromMatrixPosition( target.matrixWorld );
|
||||
|
||||
const links = ik.links;
|
||||
const iteration = ik.iteration !== undefined ? ik.iteration : 1;
|
||||
|
||||
for ( let i = 0; i < iteration; i ++ ) {
|
||||
|
||||
let rotated = false;
|
||||
|
||||
for ( let j = 0, jl = links.length; j < jl; j ++ ) {
|
||||
|
||||
const link = bones[ links[ j ].index ];
|
||||
|
||||
// skip this link and following links.
|
||||
// this skip is used for MMD performance optimization.
|
||||
if ( links[ j ].enabled === false ) break;
|
||||
|
||||
const limitation = links[ j ].limitation;
|
||||
const rotationMin = links[ j ].rotationMin;
|
||||
const rotationMax = links[ j ].rotationMax;
|
||||
|
||||
// don't use getWorldPosition/Quaternion() here for the performance
|
||||
// because they call updateMatrixWorld( true ) inside.
|
||||
link.matrixWorld.decompose( _linkPos, _invLinkQ, _linkScale );
|
||||
_invLinkQ.invert();
|
||||
_effectorPos.setFromMatrixPosition( effector.matrixWorld );
|
||||
|
||||
// work in link world
|
||||
_effectorVec.subVectors( _effectorPos, _linkPos );
|
||||
_effectorVec.applyQuaternion( _invLinkQ );
|
||||
_effectorVec.normalize();
|
||||
|
||||
_targetVec.subVectors( _targetPos, _linkPos );
|
||||
_targetVec.applyQuaternion( _invLinkQ );
|
||||
_targetVec.normalize();
|
||||
|
||||
let angle = _targetVec.dot( _effectorVec );
|
||||
|
||||
if ( angle > 1.0 ) {
|
||||
|
||||
angle = 1.0;
|
||||
|
||||
} else if ( angle < - 1.0 ) {
|
||||
|
||||
angle = - 1.0;
|
||||
|
||||
}
|
||||
|
||||
angle = math.acos( angle );
|
||||
|
||||
// skip if changing angle is too small to prevent vibration of bone
|
||||
if ( angle < 1e-5 ) continue;
|
||||
|
||||
if ( ik.minAngle !== undefined && angle < ik.minAngle ) {
|
||||
|
||||
angle = ik.minAngle;
|
||||
|
||||
}
|
||||
|
||||
if ( ik.maxAngle !== undefined && angle > ik.maxAngle ) {
|
||||
|
||||
angle = ik.maxAngle;
|
||||
|
||||
}
|
||||
|
||||
_axis.crossVectors( _effectorVec, _targetVec );
|
||||
_axis.normalize();
|
||||
|
||||
_q.setFromAxisAngle( _axis, angle );
|
||||
link.quaternion.multiply( _q );
|
||||
|
||||
// TODO: re-consider the limitation specification
|
||||
if ( limitation !== undefined ) {
|
||||
|
||||
let c = link.quaternion.w;
|
||||
|
||||
if ( c > 1.0 ) c = 1.0;
|
||||
|
||||
const c2 = math.sqrt( 1 - c * c );
|
||||
link.quaternion.set( limitation.x * c2,
|
||||
limitation.y * c2,
|
||||
limitation.z * c2,
|
||||
c );
|
||||
|
||||
}
|
||||
|
||||
if ( rotationMin !== undefined ) {
|
||||
|
||||
link.rotation.setFromVector3( _vector.setFromEuler( link.rotation ).max( rotationMin ) );
|
||||
|
||||
}
|
||||
|
||||
if ( rotationMax !== undefined ) {
|
||||
|
||||
link.rotation.setFromVector3( _vector.setFromEuler( link.rotation ).min( rotationMax ) );
|
||||
|
||||
}
|
||||
|
||||
link.updateMatrixWorld( true );
|
||||
|
||||
rotated = true;
|
||||
|
||||
}
|
||||
|
||||
if ( ! rotated ) break;
|
||||
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates Helper
|
||||
*
|
||||
* @return {CCDIKHelper}
|
||||
*/
|
||||
createHelper() {
|
||||
|
||||
return new CCDIKHelper( this.mesh, this.iks );
|
||||
|
||||
}
|
||||
|
||||
// private methods
|
||||
|
||||
_valid() {
|
||||
|
||||
const iks = this.iks;
|
||||
const bones = this.mesh.skeleton.bones;
|
||||
|
||||
for ( let i = 0, il = iks.length; i < il; i ++ ) {
|
||||
|
||||
const ik = iks[ i ];
|
||||
const effector = bones[ ik.effector ];
|
||||
const links = ik.links;
|
||||
let link0, link1;
|
||||
|
||||
link0 = effector;
|
||||
|
||||
for ( let j = 0, jl = links.length; j < jl; j ++ ) {
|
||||
|
||||
link1 = bones[ links[ j ].index ];
|
||||
|
||||
if ( link0.parent !== link1 ) {
|
||||
|
||||
console.warn( 'THREE.CCDIKSolver: bone ' + link0.name + ' is not the child of bone ' + link1.name );
|
||||
|
||||
}
|
||||
|
||||
link0 = link1;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getPosition( bone, matrixWorldInv ) {
|
||||
|
||||
return _vector
|
||||
.setFromMatrixPosition( bone.matrixWorld )
|
||||
.applyMatrix4( matrixWorldInv );
|
||||
|
||||
}
|
||||
|
||||
function setPositionOfBoneToAttributeArray( array, index, bone, matrixWorldInv ) {
|
||||
|
||||
const v = getPosition( bone, matrixWorldInv );
|
||||
|
||||
array[ index * 3 + 0 ] = v.x;
|
||||
array[ index * 3 + 1 ] = v.y;
|
||||
array[ index * 3 + 2 ] = v.z;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Visualize IK bones
|
||||
*
|
||||
* @param {SkinnedMesh} mesh
|
||||
* @param {Array<Object>} iks
|
||||
*/
|
||||
class CCDIKHelper extends Object3D {
|
||||
|
||||
constructor( mesh, iks = [], sphereSize = 0.25 ) {
|
||||
|
||||
super();
|
||||
|
||||
this.root = mesh;
|
||||
this.iks = iks;
|
||||
|
||||
this.matrix.copy( mesh.matrixWorld );
|
||||
this.matrixAutoUpdate = false;
|
||||
|
||||
this.sphereGeometry = new SphereGeometry( sphereSize, 16, 8 );
|
||||
|
||||
this.targetSphereMaterial = new MeshBasicMaterial( {
|
||||
color: new Color( 0xff8888 ),
|
||||
depthTest: false,
|
||||
depthWrite: false,
|
||||
transparent: true
|
||||
} );
|
||||
|
||||
this.effectorSphereMaterial = new MeshBasicMaterial( {
|
||||
color: new Color( 0x88ff88 ),
|
||||
depthTest: false,
|
||||
depthWrite: false,
|
||||
transparent: true
|
||||
} );
|
||||
|
||||
this.linkSphereMaterial = new MeshBasicMaterial( {
|
||||
color: new Color( 0x8888ff ),
|
||||
depthTest: false,
|
||||
depthWrite: false,
|
||||
transparent: true
|
||||
} );
|
||||
|
||||
this.lineMaterial = new LineBasicMaterial( {
|
||||
color: new Color( 0xff0000 ),
|
||||
depthTest: false,
|
||||
depthWrite: false,
|
||||
transparent: true
|
||||
} );
|
||||
|
||||
this._init();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates IK bones visualization.
|
||||
*/
|
||||
updateMatrixWorld( force ) {
|
||||
|
||||
const mesh = this.root;
|
||||
|
||||
if ( this.visible ) {
|
||||
|
||||
let offset = 0;
|
||||
|
||||
const iks = this.iks;
|
||||
const bones = mesh.skeleton.bones;
|
||||
|
||||
_matrix.copy( mesh.matrixWorld ).invert();
|
||||
|
||||
for ( let i = 0, il = iks.length; i < il; i ++ ) {
|
||||
|
||||
const ik = iks[ i ];
|
||||
|
||||
const targetBone = bones[ ik.target ];
|
||||
const effectorBone = bones[ ik.effector ];
|
||||
|
||||
const targetMesh = this.children[ offset ++ ];
|
||||
const effectorMesh = this.children[ offset ++ ];
|
||||
|
||||
targetMesh.position.copy( getPosition( targetBone, _matrix ) );
|
||||
effectorMesh.position.copy( getPosition( effectorBone, _matrix ) );
|
||||
|
||||
for ( let j = 0, jl = ik.links.length; j < jl; j ++ ) {
|
||||
|
||||
const link = ik.links[ j ];
|
||||
const linkBone = bones[ link.index ];
|
||||
|
||||
const linkMesh = this.children[ offset ++ ];
|
||||
|
||||
linkMesh.position.copy( getPosition( linkBone, _matrix ) );
|
||||
|
||||
}
|
||||
|
||||
const line = this.children[ offset ++ ];
|
||||
const array = line.geometry.attributes.position.array;
|
||||
|
||||
setPositionOfBoneToAttributeArray( array, 0, targetBone, _matrix );
|
||||
setPositionOfBoneToAttributeArray( array, 1, effectorBone, _matrix );
|
||||
|
||||
for ( let j = 0, jl = ik.links.length; j < jl; j ++ ) {
|
||||
|
||||
const link = ik.links[ j ];
|
||||
const linkBone = bones[ link.index ];
|
||||
setPositionOfBoneToAttributeArray( array, j + 2, linkBone, _matrix );
|
||||
|
||||
}
|
||||
|
||||
line.geometry.attributes.position.needsUpdate = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.matrix.copy( mesh.matrixWorld );
|
||||
|
||||
super.updateMatrixWorld( force );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees the GPU-related resources allocated by this instance. Call this method whenever this instance is no longer used in your app.
|
||||
*/
|
||||
dispose() {
|
||||
|
||||
this.sphereGeometry.dispose();
|
||||
|
||||
this.targetSphereMaterial.dispose();
|
||||
this.effectorSphereMaterial.dispose();
|
||||
this.linkSphereMaterial.dispose();
|
||||
this.lineMaterial.dispose();
|
||||
|
||||
const children = this.children;
|
||||
|
||||
for ( let i = 0; i < children.length; i ++ ) {
|
||||
|
||||
const child = children[ i ];
|
||||
|
||||
if ( child.isLine ) child.geometry.dispose();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// private method
|
||||
|
||||
_init() {
|
||||
|
||||
const scope = this;
|
||||
const iks = this.iks;
|
||||
|
||||
function createLineGeometry( ik ) {
|
||||
|
||||
const geometry = new BufferGeometry();
|
||||
const vertices = new Float32Array( ( 2 + ik.links.length ) * 3 );
|
||||
geometry.setAttribute( 'position', new BufferAttribute( vertices, 3 ) );
|
||||
|
||||
return geometry;
|
||||
|
||||
}
|
||||
|
||||
function createTargetMesh() {
|
||||
|
||||
return new Mesh( scope.sphereGeometry, scope.targetSphereMaterial );
|
||||
|
||||
}
|
||||
|
||||
function createEffectorMesh() {
|
||||
|
||||
return new Mesh( scope.sphereGeometry, scope.effectorSphereMaterial );
|
||||
|
||||
}
|
||||
|
||||
function createLinkMesh() {
|
||||
|
||||
return new Mesh( scope.sphereGeometry, scope.linkSphereMaterial );
|
||||
|
||||
}
|
||||
|
||||
function createLine( ik ) {
|
||||
|
||||
return new Line( createLineGeometry( ik ), scope.lineMaterial );
|
||||
|
||||
}
|
||||
|
||||
for ( let i = 0, il = iks.length; i < il; i ++ ) {
|
||||
|
||||
const ik = iks[ i ];
|
||||
|
||||
this.add( createTargetMesh() );
|
||||
this.add( createEffectorMesh() );
|
||||
|
||||
for ( let j = 0, jl = ik.links.length; j < jl; j ++ ) {
|
||||
|
||||
this.add( createLinkMesh() );
|
||||
|
||||
}
|
||||
|
||||
this.add( createLine( ik ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { CCDIKSolver, CCDIKHelper };
|
||||
1207
node_modules/three/examples/jsm/animation/MMDAnimationHelper.js
generated
vendored
Normal file
1207
node_modules/three/examples/jsm/animation/MMDAnimationHelper.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1406
node_modules/three/examples/jsm/animation/MMDPhysics.js
generated
vendored
Normal file
1406
node_modules/three/examples/jsm/animation/MMDPhysics.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
208
node_modules/three/examples/jsm/cameras/CinematicCamera.js
generated
vendored
Normal file
208
node_modules/three/examples/jsm/cameras/CinematicCamera.js
generated
vendored
Normal file
@@ -0,0 +1,208 @@
|
||||
import {
|
||||
Mesh,
|
||||
OrthographicCamera,
|
||||
PerspectiveCamera,
|
||||
PlaneGeometry,
|
||||
Scene,
|
||||
ShaderMaterial,
|
||||
UniformsUtils,
|
||||
WebGLRenderTarget
|
||||
} from 'three';
|
||||
|
||||
import { BokehShader, BokehDepthShader } from '../shaders/BokehShader2.js';
|
||||
|
||||
class CinematicCamera extends PerspectiveCamera {
|
||||
|
||||
constructor( fov, aspect, near, far ) {
|
||||
|
||||
super( fov, aspect, near, far );
|
||||
|
||||
this.type = 'CinematicCamera';
|
||||
|
||||
this.postprocessing = { enabled: true };
|
||||
this.shaderSettings = {
|
||||
rings: 3,
|
||||
samples: 4
|
||||
};
|
||||
|
||||
const depthShader = BokehDepthShader;
|
||||
|
||||
this.materialDepth = new ShaderMaterial( {
|
||||
uniforms: depthShader.uniforms,
|
||||
vertexShader: depthShader.vertexShader,
|
||||
fragmentShader: depthShader.fragmentShader
|
||||
} );
|
||||
|
||||
this.materialDepth.uniforms[ 'mNear' ].value = near;
|
||||
this.materialDepth.uniforms[ 'mFar' ].value = far;
|
||||
|
||||
// In case of cinematicCamera, having a default lens set is important
|
||||
this.setLens();
|
||||
|
||||
this.initPostProcessing();
|
||||
|
||||
}
|
||||
|
||||
// providing fnumber and coc(Circle of Confusion) as extra arguments
|
||||
// In case of cinematicCamera, having a default lens set is important
|
||||
// if fnumber and coc are not provided, cinematicCamera tries to act as a basic PerspectiveCamera
|
||||
setLens( focalLength = 35, filmGauge = 35, fNumber = 8, coc = 0.019 ) {
|
||||
|
||||
this.filmGauge = filmGauge;
|
||||
|
||||
this.setFocalLength( focalLength );
|
||||
|
||||
this.fNumber = fNumber;
|
||||
this.coc = coc;
|
||||
|
||||
// fNumber is focalLength by aperture
|
||||
this.aperture = focalLength / this.fNumber;
|
||||
|
||||
// hyperFocal is required to calculate depthOfField when a lens tries to focus at a distance with given fNumber and focalLength
|
||||
this.hyperFocal = ( focalLength * focalLength ) / ( this.aperture * this.coc );
|
||||
|
||||
}
|
||||
|
||||
linearize( depth ) {
|
||||
|
||||
const zfar = this.far;
|
||||
const znear = this.near;
|
||||
return - zfar * znear / ( depth * ( zfar - znear ) - zfar );
|
||||
|
||||
}
|
||||
|
||||
smoothstep( near, far, depth ) {
|
||||
|
||||
const x = this.saturate( ( depth - near ) / ( far - near ) );
|
||||
return x * x * ( 3 - 2 * x );
|
||||
|
||||
}
|
||||
|
||||
saturate( x ) {
|
||||
|
||||
return Math.max( 0, Math.min( 1, x ) );
|
||||
|
||||
}
|
||||
|
||||
// function for focusing at a distance from the camera
|
||||
focusAt( focusDistance = 20 ) {
|
||||
|
||||
const focalLength = this.getFocalLength();
|
||||
|
||||
// distance from the camera (normal to frustrum) to focus on
|
||||
this.focus = focusDistance;
|
||||
|
||||
// the nearest point from the camera which is in focus (unused)
|
||||
this.nearPoint = ( this.hyperFocal * this.focus ) / ( this.hyperFocal + ( this.focus - focalLength ) );
|
||||
|
||||
// the farthest point from the camera which is in focus (unused)
|
||||
this.farPoint = ( this.hyperFocal * this.focus ) / ( this.hyperFocal - ( this.focus - focalLength ) );
|
||||
|
||||
// the gap or width of the space in which is everything is in focus (unused)
|
||||
this.depthOfField = this.farPoint - this.nearPoint;
|
||||
|
||||
// Considering minimum distance of focus for a standard lens (unused)
|
||||
if ( this.depthOfField < 0 ) this.depthOfField = 0;
|
||||
|
||||
this.sdistance = this.smoothstep( this.near, this.far, this.focus );
|
||||
|
||||
this.ldistance = this.linearize( 1 - this.sdistance );
|
||||
|
||||
this.postprocessing.bokeh_uniforms[ 'focalDepth' ].value = this.ldistance;
|
||||
|
||||
}
|
||||
|
||||
initPostProcessing() {
|
||||
|
||||
if ( this.postprocessing.enabled ) {
|
||||
|
||||
this.postprocessing.scene = new Scene();
|
||||
|
||||
this.postprocessing.camera = new OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, - 10000, 10000 );
|
||||
|
||||
this.postprocessing.scene.add( this.postprocessing.camera );
|
||||
|
||||
this.postprocessing.rtTextureDepth = new WebGLRenderTarget( window.innerWidth, window.innerHeight );
|
||||
this.postprocessing.rtTextureColor = new WebGLRenderTarget( window.innerWidth, window.innerHeight );
|
||||
|
||||
const bokeh_shader = BokehShader;
|
||||
|
||||
this.postprocessing.bokeh_uniforms = UniformsUtils.clone( bokeh_shader.uniforms );
|
||||
|
||||
this.postprocessing.bokeh_uniforms[ 'tColor' ].value = this.postprocessing.rtTextureColor.texture;
|
||||
this.postprocessing.bokeh_uniforms[ 'tDepth' ].value = this.postprocessing.rtTextureDepth.texture;
|
||||
|
||||
this.postprocessing.bokeh_uniforms[ 'manualdof' ].value = 0;
|
||||
this.postprocessing.bokeh_uniforms[ 'shaderFocus' ].value = 0;
|
||||
|
||||
this.postprocessing.bokeh_uniforms[ 'fstop' ].value = 2.8;
|
||||
|
||||
this.postprocessing.bokeh_uniforms[ 'showFocus' ].value = 1;
|
||||
|
||||
this.postprocessing.bokeh_uniforms[ 'focalDepth' ].value = 0.1;
|
||||
|
||||
//console.log( this.postprocessing.bokeh_uniforms[ "focalDepth" ].value );
|
||||
|
||||
this.postprocessing.bokeh_uniforms[ 'znear' ].value = this.near;
|
||||
this.postprocessing.bokeh_uniforms[ 'zfar' ].value = this.near;
|
||||
|
||||
|
||||
this.postprocessing.bokeh_uniforms[ 'textureWidth' ].value = window.innerWidth;
|
||||
|
||||
this.postprocessing.bokeh_uniforms[ 'textureHeight' ].value = window.innerHeight;
|
||||
|
||||
this.postprocessing.materialBokeh = new ShaderMaterial( {
|
||||
uniforms: this.postprocessing.bokeh_uniforms,
|
||||
vertexShader: bokeh_shader.vertexShader,
|
||||
fragmentShader: bokeh_shader.fragmentShader,
|
||||
defines: {
|
||||
RINGS: this.shaderSettings.rings,
|
||||
SAMPLES: this.shaderSettings.samples,
|
||||
DEPTH_PACKING: 1
|
||||
}
|
||||
} );
|
||||
|
||||
this.postprocessing.quad = new Mesh( new PlaneGeometry( window.innerWidth, window.innerHeight ), this.postprocessing.materialBokeh );
|
||||
this.postprocessing.quad.position.z = - 500;
|
||||
this.postprocessing.scene.add( this.postprocessing.quad );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
renderCinematic( scene, renderer ) {
|
||||
|
||||
if ( this.postprocessing.enabled ) {
|
||||
|
||||
const currentRenderTarget = renderer.getRenderTarget();
|
||||
|
||||
renderer.clear();
|
||||
|
||||
// Render scene into texture
|
||||
|
||||
scene.overrideMaterial = null;
|
||||
renderer.setRenderTarget( this.postprocessing.rtTextureColor );
|
||||
renderer.clear();
|
||||
renderer.render( scene, this );
|
||||
|
||||
// Render depth into texture
|
||||
|
||||
scene.overrideMaterial = this.materialDepth;
|
||||
renderer.setRenderTarget( this.postprocessing.rtTextureDepth );
|
||||
renderer.clear();
|
||||
renderer.render( scene, this );
|
||||
|
||||
// Render bokeh composite
|
||||
|
||||
renderer.setRenderTarget( null );
|
||||
renderer.render( this.postprocessing.scene, this.postprocessing.camera );
|
||||
|
||||
renderer.setRenderTarget( currentRenderTarget );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { CinematicCamera };
|
||||
108
node_modules/three/examples/jsm/capabilities/WebGL.js
generated
vendored
Normal file
108
node_modules/three/examples/jsm/capabilities/WebGL.js
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
class WebGL {
|
||||
|
||||
static isWebGLAvailable() {
|
||||
|
||||
try {
|
||||
|
||||
const canvas = document.createElement( 'canvas' );
|
||||
return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) );
|
||||
|
||||
} catch ( e ) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static isWebGL2Available() {
|
||||
|
||||
try {
|
||||
|
||||
const canvas = document.createElement( 'canvas' );
|
||||
return !! ( window.WebGL2RenderingContext && canvas.getContext( 'webgl2' ) );
|
||||
|
||||
} catch ( e ) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static isColorSpaceAvailable( colorSpace ) {
|
||||
|
||||
try {
|
||||
|
||||
const canvas = document.createElement( 'canvas' );
|
||||
const ctx = window.WebGL2RenderingContext && canvas.getContext( 'webgl2' );
|
||||
ctx.drawingBufferColorSpace = colorSpace;
|
||||
return ctx.drawingBufferColorSpace === colorSpace; // deepscan-disable-line SAME_OPERAND_VALUE
|
||||
|
||||
} catch ( e ) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static getWebGLErrorMessage() {
|
||||
|
||||
return this.getErrorMessage( 1 );
|
||||
|
||||
}
|
||||
|
||||
static getWebGL2ErrorMessage() {
|
||||
|
||||
return this.getErrorMessage( 2 );
|
||||
|
||||
}
|
||||
|
||||
static getErrorMessage( version ) {
|
||||
|
||||
const names = {
|
||||
1: 'WebGL',
|
||||
2: 'WebGL 2'
|
||||
};
|
||||
|
||||
const contexts = {
|
||||
1: window.WebGLRenderingContext,
|
||||
2: window.WebGL2RenderingContext
|
||||
};
|
||||
|
||||
let message = 'Your $0 does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">$1</a>';
|
||||
|
||||
const element = document.createElement( 'div' );
|
||||
element.id = 'webglmessage';
|
||||
element.style.fontFamily = 'monospace';
|
||||
element.style.fontSize = '13px';
|
||||
element.style.fontWeight = 'normal';
|
||||
element.style.textAlign = 'center';
|
||||
element.style.background = '#fff';
|
||||
element.style.color = '#000';
|
||||
element.style.padding = '1.5em';
|
||||
element.style.width = '400px';
|
||||
element.style.margin = '5em auto 0';
|
||||
|
||||
if ( contexts[ version ] ) {
|
||||
|
||||
message = message.replace( '$0', 'graphics card' );
|
||||
|
||||
} else {
|
||||
|
||||
message = message.replace( '$0', 'browser' );
|
||||
|
||||
}
|
||||
|
||||
message = message.replace( '$1', names[ version ] );
|
||||
|
||||
element.innerHTML = message;
|
||||
|
||||
return element;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default WebGL;
|
||||
53
node_modules/three/examples/jsm/capabilities/WebGPU.js
generated
vendored
Normal file
53
node_modules/three/examples/jsm/capabilities/WebGPU.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
if ( window.GPUShaderStage === undefined ) {
|
||||
|
||||
window.GPUShaderStage = { VERTEX: 1, FRAGMENT: 2, COMPUTE: 4 };
|
||||
|
||||
}
|
||||
|
||||
let isAvailable = false;
|
||||
|
||||
if ( navigator.gpu !== undefined ) {
|
||||
|
||||
const adapter = await navigator.gpu.requestAdapter();
|
||||
|
||||
if ( adapter !== null ) {
|
||||
|
||||
isAvailable = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class WebGPU {
|
||||
|
||||
static isAvailable() {
|
||||
|
||||
return isAvailable;
|
||||
|
||||
}
|
||||
|
||||
static getErrorMessage() {
|
||||
|
||||
const message = 'Your browser does not support <a href="https://gpuweb.github.io/gpuweb/" style="color:blue">WebGPU</a> yet';
|
||||
|
||||
const element = document.createElement( 'div' );
|
||||
element.id = 'webgpumessage';
|
||||
element.style.fontFamily = 'monospace';
|
||||
element.style.fontSize = '13px';
|
||||
element.style.fontWeight = 'normal';
|
||||
element.style.textAlign = 'center';
|
||||
element.style.background = '#fff';
|
||||
element.style.color = '#000';
|
||||
element.style.padding = '1.5em';
|
||||
element.style.maxWidth = '400px';
|
||||
element.style.margin = '5em auto 0';
|
||||
|
||||
element.innerHTML = message;
|
||||
|
||||
return element;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default WebGPU;
|
||||
3224
node_modules/three/examples/jsm/controls/ArcballControls.js
generated
vendored
Normal file
3224
node_modules/three/examples/jsm/controls/ArcballControls.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
221
node_modules/three/examples/jsm/controls/DragControls.js
generated
vendored
Normal file
221
node_modules/three/examples/jsm/controls/DragControls.js
generated
vendored
Normal file
@@ -0,0 +1,221 @@
|
||||
import {
|
||||
EventDispatcher,
|
||||
Matrix4,
|
||||
Plane,
|
||||
Raycaster,
|
||||
Vector2,
|
||||
Vector3
|
||||
} from 'three';
|
||||
|
||||
const _plane = new Plane();
|
||||
const _raycaster = new Raycaster();
|
||||
|
||||
const _pointer = new Vector2();
|
||||
const _offset = new Vector3();
|
||||
const _intersection = new Vector3();
|
||||
const _worldPosition = new Vector3();
|
||||
const _inverseMatrix = new Matrix4();
|
||||
|
||||
class DragControls extends EventDispatcher {
|
||||
|
||||
constructor( _objects, _camera, _domElement ) {
|
||||
|
||||
super();
|
||||
|
||||
_domElement.style.touchAction = 'none'; // disable touch scroll
|
||||
|
||||
let _selected = null, _hovered = null;
|
||||
|
||||
const _intersections = [];
|
||||
|
||||
//
|
||||
|
||||
const scope = this;
|
||||
|
||||
function activate() {
|
||||
|
||||
_domElement.addEventListener( 'pointermove', onPointerMove );
|
||||
_domElement.addEventListener( 'pointerdown', onPointerDown );
|
||||
_domElement.addEventListener( 'pointerup', onPointerCancel );
|
||||
_domElement.addEventListener( 'pointerleave', onPointerCancel );
|
||||
|
||||
}
|
||||
|
||||
function deactivate() {
|
||||
|
||||
_domElement.removeEventListener( 'pointermove', onPointerMove );
|
||||
_domElement.removeEventListener( 'pointerdown', onPointerDown );
|
||||
_domElement.removeEventListener( 'pointerup', onPointerCancel );
|
||||
_domElement.removeEventListener( 'pointerleave', onPointerCancel );
|
||||
|
||||
_domElement.style.cursor = '';
|
||||
|
||||
}
|
||||
|
||||
function dispose() {
|
||||
|
||||
deactivate();
|
||||
|
||||
}
|
||||
|
||||
function getObjects() {
|
||||
|
||||
return _objects;
|
||||
|
||||
}
|
||||
|
||||
function getRaycaster() {
|
||||
|
||||
return _raycaster;
|
||||
|
||||
}
|
||||
|
||||
function onPointerMove( event ) {
|
||||
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
updatePointer( event );
|
||||
|
||||
_raycaster.setFromCamera( _pointer, _camera );
|
||||
|
||||
if ( _selected ) {
|
||||
|
||||
if ( _raycaster.ray.intersectPlane( _plane, _intersection ) ) {
|
||||
|
||||
_selected.position.copy( _intersection.sub( _offset ).applyMatrix4( _inverseMatrix ) );
|
||||
|
||||
}
|
||||
|
||||
scope.dispatchEvent( { type: 'drag', object: _selected } );
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// hover support
|
||||
|
||||
if ( event.pointerType === 'mouse' || event.pointerType === 'pen' ) {
|
||||
|
||||
_intersections.length = 0;
|
||||
|
||||
_raycaster.setFromCamera( _pointer, _camera );
|
||||
_raycaster.intersectObjects( _objects, scope.recursive, _intersections );
|
||||
|
||||
if ( _intersections.length > 0 ) {
|
||||
|
||||
const object = _intersections[ 0 ].object;
|
||||
|
||||
_plane.setFromNormalAndCoplanarPoint( _camera.getWorldDirection( _plane.normal ), _worldPosition.setFromMatrixPosition( object.matrixWorld ) );
|
||||
|
||||
if ( _hovered !== object && _hovered !== null ) {
|
||||
|
||||
scope.dispatchEvent( { type: 'hoveroff', object: _hovered } );
|
||||
|
||||
_domElement.style.cursor = 'auto';
|
||||
_hovered = null;
|
||||
|
||||
}
|
||||
|
||||
if ( _hovered !== object ) {
|
||||
|
||||
scope.dispatchEvent( { type: 'hoveron', object: object } );
|
||||
|
||||
_domElement.style.cursor = 'pointer';
|
||||
_hovered = object;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if ( _hovered !== null ) {
|
||||
|
||||
scope.dispatchEvent( { type: 'hoveroff', object: _hovered } );
|
||||
|
||||
_domElement.style.cursor = 'auto';
|
||||
_hovered = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onPointerDown( event ) {
|
||||
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
updatePointer( event );
|
||||
|
||||
_intersections.length = 0;
|
||||
|
||||
_raycaster.setFromCamera( _pointer, _camera );
|
||||
_raycaster.intersectObjects( _objects, scope.recursive, _intersections );
|
||||
|
||||
if ( _intersections.length > 0 ) {
|
||||
|
||||
_selected = ( scope.transformGroup === true ) ? _objects[ 0 ] : _intersections[ 0 ].object;
|
||||
|
||||
_plane.setFromNormalAndCoplanarPoint( _camera.getWorldDirection( _plane.normal ), _worldPosition.setFromMatrixPosition( _selected.matrixWorld ) );
|
||||
|
||||
if ( _raycaster.ray.intersectPlane( _plane, _intersection ) ) {
|
||||
|
||||
_inverseMatrix.copy( _selected.parent.matrixWorld ).invert();
|
||||
_offset.copy( _intersection ).sub( _worldPosition.setFromMatrixPosition( _selected.matrixWorld ) );
|
||||
|
||||
}
|
||||
|
||||
_domElement.style.cursor = 'move';
|
||||
|
||||
scope.dispatchEvent( { type: 'dragstart', object: _selected } );
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function onPointerCancel() {
|
||||
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
if ( _selected ) {
|
||||
|
||||
scope.dispatchEvent( { type: 'dragend', object: _selected } );
|
||||
|
||||
_selected = null;
|
||||
|
||||
}
|
||||
|
||||
_domElement.style.cursor = _hovered ? 'pointer' : 'auto';
|
||||
|
||||
}
|
||||
|
||||
function updatePointer( event ) {
|
||||
|
||||
const rect = _domElement.getBoundingClientRect();
|
||||
|
||||
_pointer.x = ( event.clientX - rect.left ) / rect.width * 2 - 1;
|
||||
_pointer.y = - ( event.clientY - rect.top ) / rect.height * 2 + 1;
|
||||
|
||||
}
|
||||
|
||||
activate();
|
||||
|
||||
// API
|
||||
|
||||
this.enabled = true;
|
||||
this.recursive = true;
|
||||
this.transformGroup = false;
|
||||
|
||||
this.activate = activate;
|
||||
this.deactivate = deactivate;
|
||||
this.dispose = dispose;
|
||||
this.getObjects = getObjects;
|
||||
this.getRaycaster = getRaycaster;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { DragControls };
|
||||
325
node_modules/three/examples/jsm/controls/FirstPersonControls.js
generated
vendored
Normal file
325
node_modules/three/examples/jsm/controls/FirstPersonControls.js
generated
vendored
Normal file
@@ -0,0 +1,325 @@
|
||||
import {
|
||||
MathUtils,
|
||||
Spherical,
|
||||
Vector3
|
||||
} from 'three';
|
||||
|
||||
const _lookDirection = new Vector3();
|
||||
const _spherical = new Spherical();
|
||||
const _target = new Vector3();
|
||||
|
||||
class FirstPersonControls {
|
||||
|
||||
constructor( object, domElement ) {
|
||||
|
||||
this.object = object;
|
||||
this.domElement = domElement;
|
||||
|
||||
// API
|
||||
|
||||
this.enabled = true;
|
||||
|
||||
this.movementSpeed = 1.0;
|
||||
this.lookSpeed = 0.005;
|
||||
|
||||
this.lookVertical = true;
|
||||
this.autoForward = false;
|
||||
|
||||
this.activeLook = true;
|
||||
|
||||
this.heightSpeed = false;
|
||||
this.heightCoef = 1.0;
|
||||
this.heightMin = 0.0;
|
||||
this.heightMax = 1.0;
|
||||
|
||||
this.constrainVertical = false;
|
||||
this.verticalMin = 0;
|
||||
this.verticalMax = Math.PI;
|
||||
|
||||
this.mouseDragOn = false;
|
||||
|
||||
// internals
|
||||
|
||||
this.autoSpeedFactor = 0.0;
|
||||
|
||||
this.pointerX = 0;
|
||||
this.pointerY = 0;
|
||||
|
||||
this.moveForward = false;
|
||||
this.moveBackward = false;
|
||||
this.moveLeft = false;
|
||||
this.moveRight = false;
|
||||
|
||||
this.viewHalfX = 0;
|
||||
this.viewHalfY = 0;
|
||||
|
||||
// private variables
|
||||
|
||||
let lat = 0;
|
||||
let lon = 0;
|
||||
|
||||
//
|
||||
|
||||
this.handleResize = function () {
|
||||
|
||||
if ( this.domElement === document ) {
|
||||
|
||||
this.viewHalfX = window.innerWidth / 2;
|
||||
this.viewHalfY = window.innerHeight / 2;
|
||||
|
||||
} else {
|
||||
|
||||
this.viewHalfX = this.domElement.offsetWidth / 2;
|
||||
this.viewHalfY = this.domElement.offsetHeight / 2;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.onPointerDown = function ( event ) {
|
||||
|
||||
if ( this.domElement !== document ) {
|
||||
|
||||
this.domElement.focus();
|
||||
|
||||
}
|
||||
|
||||
if ( this.activeLook ) {
|
||||
|
||||
switch ( event.button ) {
|
||||
|
||||
case 0: this.moveForward = true; break;
|
||||
case 2: this.moveBackward = true; break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.mouseDragOn = true;
|
||||
|
||||
};
|
||||
|
||||
this.onPointerUp = function ( event ) {
|
||||
|
||||
if ( this.activeLook ) {
|
||||
|
||||
switch ( event.button ) {
|
||||
|
||||
case 0: this.moveForward = false; break;
|
||||
case 2: this.moveBackward = false; break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.mouseDragOn = false;
|
||||
|
||||
};
|
||||
|
||||
this.onPointerMove = function ( event ) {
|
||||
|
||||
if ( this.domElement === document ) {
|
||||
|
||||
this.pointerX = event.pageX - this.viewHalfX;
|
||||
this.pointerY = event.pageY - this.viewHalfY;
|
||||
|
||||
} else {
|
||||
|
||||
this.pointerX = event.pageX - this.domElement.offsetLeft - this.viewHalfX;
|
||||
this.pointerY = event.pageY - this.domElement.offsetTop - this.viewHalfY;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.onKeyDown = function ( event ) {
|
||||
|
||||
switch ( event.code ) {
|
||||
|
||||
case 'ArrowUp':
|
||||
case 'KeyW': this.moveForward = true; break;
|
||||
|
||||
case 'ArrowLeft':
|
||||
case 'KeyA': this.moveLeft = true; break;
|
||||
|
||||
case 'ArrowDown':
|
||||
case 'KeyS': this.moveBackward = true; break;
|
||||
|
||||
case 'ArrowRight':
|
||||
case 'KeyD': this.moveRight = true; break;
|
||||
|
||||
case 'KeyR': this.moveUp = true; break;
|
||||
case 'KeyF': this.moveDown = true; break;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.onKeyUp = function ( event ) {
|
||||
|
||||
switch ( event.code ) {
|
||||
|
||||
case 'ArrowUp':
|
||||
case 'KeyW': this.moveForward = false; break;
|
||||
|
||||
case 'ArrowLeft':
|
||||
case 'KeyA': this.moveLeft = false; break;
|
||||
|
||||
case 'ArrowDown':
|
||||
case 'KeyS': this.moveBackward = false; break;
|
||||
|
||||
case 'ArrowRight':
|
||||
case 'KeyD': this.moveRight = false; break;
|
||||
|
||||
case 'KeyR': this.moveUp = false; break;
|
||||
case 'KeyF': this.moveDown = false; break;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.lookAt = function ( x, y, z ) {
|
||||
|
||||
if ( x.isVector3 ) {
|
||||
|
||||
_target.copy( x );
|
||||
|
||||
} else {
|
||||
|
||||
_target.set( x, y, z );
|
||||
|
||||
}
|
||||
|
||||
this.object.lookAt( _target );
|
||||
|
||||
setOrientation( this );
|
||||
|
||||
return this;
|
||||
|
||||
};
|
||||
|
||||
this.update = function () {
|
||||
|
||||
const targetPosition = new Vector3();
|
||||
|
||||
return function update( delta ) {
|
||||
|
||||
if ( this.enabled === false ) return;
|
||||
|
||||
if ( this.heightSpeed ) {
|
||||
|
||||
const y = MathUtils.clamp( this.object.position.y, this.heightMin, this.heightMax );
|
||||
const heightDelta = y - this.heightMin;
|
||||
|
||||
this.autoSpeedFactor = delta * ( heightDelta * this.heightCoef );
|
||||
|
||||
} else {
|
||||
|
||||
this.autoSpeedFactor = 0.0;
|
||||
|
||||
}
|
||||
|
||||
const actualMoveSpeed = delta * this.movementSpeed;
|
||||
|
||||
if ( this.moveForward || ( this.autoForward && ! this.moveBackward ) ) this.object.translateZ( - ( actualMoveSpeed + this.autoSpeedFactor ) );
|
||||
if ( this.moveBackward ) this.object.translateZ( actualMoveSpeed );
|
||||
|
||||
if ( this.moveLeft ) this.object.translateX( - actualMoveSpeed );
|
||||
if ( this.moveRight ) this.object.translateX( actualMoveSpeed );
|
||||
|
||||
if ( this.moveUp ) this.object.translateY( actualMoveSpeed );
|
||||
if ( this.moveDown ) this.object.translateY( - actualMoveSpeed );
|
||||
|
||||
let actualLookSpeed = delta * this.lookSpeed;
|
||||
|
||||
if ( ! this.activeLook ) {
|
||||
|
||||
actualLookSpeed = 0;
|
||||
|
||||
}
|
||||
|
||||
let verticalLookRatio = 1;
|
||||
|
||||
if ( this.constrainVertical ) {
|
||||
|
||||
verticalLookRatio = Math.PI / ( this.verticalMax - this.verticalMin );
|
||||
|
||||
}
|
||||
|
||||
lon -= this.pointerX * actualLookSpeed;
|
||||
if ( this.lookVertical ) lat -= this.pointerY * actualLookSpeed * verticalLookRatio;
|
||||
|
||||
lat = Math.max( - 85, Math.min( 85, lat ) );
|
||||
|
||||
let phi = MathUtils.degToRad( 90 - lat );
|
||||
const theta = MathUtils.degToRad( lon );
|
||||
|
||||
if ( this.constrainVertical ) {
|
||||
|
||||
phi = MathUtils.mapLinear( phi, 0, Math.PI, this.verticalMin, this.verticalMax );
|
||||
|
||||
}
|
||||
|
||||
const position = this.object.position;
|
||||
|
||||
targetPosition.setFromSphericalCoords( 1, phi, theta ).add( position );
|
||||
|
||||
this.object.lookAt( targetPosition );
|
||||
|
||||
};
|
||||
|
||||
}();
|
||||
|
||||
this.dispose = function () {
|
||||
|
||||
this.domElement.removeEventListener( 'contextmenu', contextmenu );
|
||||
this.domElement.removeEventListener( 'pointerdown', _onPointerDown );
|
||||
this.domElement.removeEventListener( 'pointermove', _onPointerMove );
|
||||
this.domElement.removeEventListener( 'pointerup', _onPointerUp );
|
||||
|
||||
window.removeEventListener( 'keydown', _onKeyDown );
|
||||
window.removeEventListener( 'keyup', _onKeyUp );
|
||||
|
||||
};
|
||||
|
||||
const _onPointerMove = this.onPointerMove.bind( this );
|
||||
const _onPointerDown = this.onPointerDown.bind( this );
|
||||
const _onPointerUp = this.onPointerUp.bind( this );
|
||||
const _onKeyDown = this.onKeyDown.bind( this );
|
||||
const _onKeyUp = this.onKeyUp.bind( this );
|
||||
|
||||
this.domElement.addEventListener( 'contextmenu', contextmenu );
|
||||
this.domElement.addEventListener( 'pointerdown', _onPointerDown );
|
||||
this.domElement.addEventListener( 'pointermove', _onPointerMove );
|
||||
this.domElement.addEventListener( 'pointerup', _onPointerUp );
|
||||
|
||||
window.addEventListener( 'keydown', _onKeyDown );
|
||||
window.addEventListener( 'keyup', _onKeyUp );
|
||||
|
||||
function setOrientation( controls ) {
|
||||
|
||||
const quaternion = controls.object.quaternion;
|
||||
|
||||
_lookDirection.set( 0, 0, - 1 ).applyQuaternion( quaternion );
|
||||
_spherical.setFromVector3( _lookDirection );
|
||||
|
||||
lat = 90 - MathUtils.radToDeg( _spherical.phi );
|
||||
lon = MathUtils.radToDeg( _spherical.theta );
|
||||
|
||||
}
|
||||
|
||||
this.handleResize();
|
||||
|
||||
setOrientation( this );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function contextmenu( event ) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
}
|
||||
|
||||
export { FirstPersonControls };
|
||||
326
node_modules/three/examples/jsm/controls/FlyControls.js
generated
vendored
Normal file
326
node_modules/three/examples/jsm/controls/FlyControls.js
generated
vendored
Normal file
@@ -0,0 +1,326 @@
|
||||
import {
|
||||
EventDispatcher,
|
||||
Quaternion,
|
||||
Vector3
|
||||
} from 'three';
|
||||
|
||||
const _changeEvent = { type: 'change' };
|
||||
|
||||
class FlyControls extends EventDispatcher {
|
||||
|
||||
constructor( object, domElement ) {
|
||||
|
||||
super();
|
||||
|
||||
this.object = object;
|
||||
this.domElement = domElement;
|
||||
|
||||
// API
|
||||
|
||||
// Set to false to disable this control
|
||||
this.enabled = true;
|
||||
|
||||
this.movementSpeed = 1.0;
|
||||
this.rollSpeed = 0.005;
|
||||
|
||||
this.dragToLook = false;
|
||||
this.autoForward = false;
|
||||
|
||||
// disable default target object behavior
|
||||
|
||||
// internals
|
||||
|
||||
const scope = this;
|
||||
|
||||
const EPS = 0.000001;
|
||||
|
||||
const lastQuaternion = new Quaternion();
|
||||
const lastPosition = new Vector3();
|
||||
|
||||
this.tmpQuaternion = new Quaternion();
|
||||
|
||||
this.status = 0;
|
||||
|
||||
this.moveState = { up: 0, down: 0, left: 0, right: 0, forward: 0, back: 0, pitchUp: 0, pitchDown: 0, yawLeft: 0, yawRight: 0, rollLeft: 0, rollRight: 0 };
|
||||
this.moveVector = new Vector3( 0, 0, 0 );
|
||||
this.rotationVector = new Vector3( 0, 0, 0 );
|
||||
|
||||
this.keydown = function ( event ) {
|
||||
|
||||
if ( event.altKey || this.enabled === false ) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
switch ( event.code ) {
|
||||
|
||||
case 'ShiftLeft':
|
||||
case 'ShiftRight': this.movementSpeedMultiplier = .1; break;
|
||||
|
||||
case 'KeyW': this.moveState.forward = 1; break;
|
||||
case 'KeyS': this.moveState.back = 1; break;
|
||||
|
||||
case 'KeyA': this.moveState.left = 1; break;
|
||||
case 'KeyD': this.moveState.right = 1; break;
|
||||
|
||||
case 'KeyR': this.moveState.up = 1; break;
|
||||
case 'KeyF': this.moveState.down = 1; break;
|
||||
|
||||
case 'ArrowUp': this.moveState.pitchUp = 1; break;
|
||||
case 'ArrowDown': this.moveState.pitchDown = 1; break;
|
||||
|
||||
case 'ArrowLeft': this.moveState.yawLeft = 1; break;
|
||||
case 'ArrowRight': this.moveState.yawRight = 1; break;
|
||||
|
||||
case 'KeyQ': this.moveState.rollLeft = 1; break;
|
||||
case 'KeyE': this.moveState.rollRight = 1; break;
|
||||
|
||||
}
|
||||
|
||||
this.updateMovementVector();
|
||||
this.updateRotationVector();
|
||||
|
||||
};
|
||||
|
||||
this.keyup = function ( event ) {
|
||||
|
||||
if ( this.enabled === false ) return;
|
||||
|
||||
switch ( event.code ) {
|
||||
|
||||
case 'ShiftLeft':
|
||||
case 'ShiftRight': this.movementSpeedMultiplier = 1; break;
|
||||
|
||||
case 'KeyW': this.moveState.forward = 0; break;
|
||||
case 'KeyS': this.moveState.back = 0; break;
|
||||
|
||||
case 'KeyA': this.moveState.left = 0; break;
|
||||
case 'KeyD': this.moveState.right = 0; break;
|
||||
|
||||
case 'KeyR': this.moveState.up = 0; break;
|
||||
case 'KeyF': this.moveState.down = 0; break;
|
||||
|
||||
case 'ArrowUp': this.moveState.pitchUp = 0; break;
|
||||
case 'ArrowDown': this.moveState.pitchDown = 0; break;
|
||||
|
||||
case 'ArrowLeft': this.moveState.yawLeft = 0; break;
|
||||
case 'ArrowRight': this.moveState.yawRight = 0; break;
|
||||
|
||||
case 'KeyQ': this.moveState.rollLeft = 0; break;
|
||||
case 'KeyE': this.moveState.rollRight = 0; break;
|
||||
|
||||
}
|
||||
|
||||
this.updateMovementVector();
|
||||
this.updateRotationVector();
|
||||
|
||||
};
|
||||
|
||||
this.pointerdown = function ( event ) {
|
||||
|
||||
if ( this.enabled === false ) return;
|
||||
|
||||
if ( this.dragToLook ) {
|
||||
|
||||
this.status ++;
|
||||
|
||||
} else {
|
||||
|
||||
switch ( event.button ) {
|
||||
|
||||
case 0: this.moveState.forward = 1; break;
|
||||
case 2: this.moveState.back = 1; break;
|
||||
|
||||
}
|
||||
|
||||
this.updateMovementVector();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.pointermove = function ( event ) {
|
||||
|
||||
if ( this.enabled === false ) return;
|
||||
|
||||
if ( ! this.dragToLook || this.status > 0 ) {
|
||||
|
||||
const container = this.getContainerDimensions();
|
||||
const halfWidth = container.size[ 0 ] / 2;
|
||||
const halfHeight = container.size[ 1 ] / 2;
|
||||
|
||||
this.moveState.yawLeft = - ( ( event.pageX - container.offset[ 0 ] ) - halfWidth ) / halfWidth;
|
||||
this.moveState.pitchDown = ( ( event.pageY - container.offset[ 1 ] ) - halfHeight ) / halfHeight;
|
||||
|
||||
this.updateRotationVector();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.pointerup = function ( event ) {
|
||||
|
||||
if ( this.enabled === false ) return;
|
||||
|
||||
if ( this.dragToLook ) {
|
||||
|
||||
this.status --;
|
||||
|
||||
this.moveState.yawLeft = this.moveState.pitchDown = 0;
|
||||
|
||||
} else {
|
||||
|
||||
switch ( event.button ) {
|
||||
|
||||
case 0: this.moveState.forward = 0; break;
|
||||
case 2: this.moveState.back = 0; break;
|
||||
|
||||
}
|
||||
|
||||
this.updateMovementVector();
|
||||
|
||||
}
|
||||
|
||||
this.updateRotationVector();
|
||||
|
||||
};
|
||||
|
||||
this.pointercancel = function () {
|
||||
|
||||
if ( this.enabled === false ) return;
|
||||
|
||||
if ( this.dragToLook ) {
|
||||
|
||||
this.status = 0;
|
||||
|
||||
this.moveState.yawLeft = this.moveState.pitchDown = 0;
|
||||
|
||||
} else {
|
||||
|
||||
this.moveState.forward = 0;
|
||||
this.moveState.back = 0;
|
||||
|
||||
this.updateMovementVector();
|
||||
|
||||
}
|
||||
|
||||
this.updateRotationVector();
|
||||
|
||||
};
|
||||
|
||||
this.contextMenu = function ( event ) {
|
||||
|
||||
if ( this.enabled === false ) return;
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
};
|
||||
|
||||
this.update = function ( delta ) {
|
||||
|
||||
if ( this.enabled === false ) return;
|
||||
|
||||
const moveMult = delta * scope.movementSpeed;
|
||||
const rotMult = delta * scope.rollSpeed;
|
||||
|
||||
scope.object.translateX( scope.moveVector.x * moveMult );
|
||||
scope.object.translateY( scope.moveVector.y * moveMult );
|
||||
scope.object.translateZ( scope.moveVector.z * moveMult );
|
||||
|
||||
scope.tmpQuaternion.set( scope.rotationVector.x * rotMult, scope.rotationVector.y * rotMult, scope.rotationVector.z * rotMult, 1 ).normalize();
|
||||
scope.object.quaternion.multiply( scope.tmpQuaternion );
|
||||
|
||||
if (
|
||||
lastPosition.distanceToSquared( scope.object.position ) > EPS ||
|
||||
8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS
|
||||
) {
|
||||
|
||||
scope.dispatchEvent( _changeEvent );
|
||||
lastQuaternion.copy( scope.object.quaternion );
|
||||
lastPosition.copy( scope.object.position );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.updateMovementVector = function () {
|
||||
|
||||
const forward = ( this.moveState.forward || ( this.autoForward && ! this.moveState.back ) ) ? 1 : 0;
|
||||
|
||||
this.moveVector.x = ( - this.moveState.left + this.moveState.right );
|
||||
this.moveVector.y = ( - this.moveState.down + this.moveState.up );
|
||||
this.moveVector.z = ( - forward + this.moveState.back );
|
||||
|
||||
//console.log( 'move:', [ this.moveVector.x, this.moveVector.y, this.moveVector.z ] );
|
||||
|
||||
};
|
||||
|
||||
this.updateRotationVector = function () {
|
||||
|
||||
this.rotationVector.x = ( - this.moveState.pitchDown + this.moveState.pitchUp );
|
||||
this.rotationVector.y = ( - this.moveState.yawRight + this.moveState.yawLeft );
|
||||
this.rotationVector.z = ( - this.moveState.rollRight + this.moveState.rollLeft );
|
||||
|
||||
//console.log( 'rotate:', [ this.rotationVector.x, this.rotationVector.y, this.rotationVector.z ] );
|
||||
|
||||
};
|
||||
|
||||
this.getContainerDimensions = function () {
|
||||
|
||||
if ( this.domElement != document ) {
|
||||
|
||||
return {
|
||||
size: [ this.domElement.offsetWidth, this.domElement.offsetHeight ],
|
||||
offset: [ this.domElement.offsetLeft, this.domElement.offsetTop ]
|
||||
};
|
||||
|
||||
} else {
|
||||
|
||||
return {
|
||||
size: [ window.innerWidth, window.innerHeight ],
|
||||
offset: [ 0, 0 ]
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.dispose = function () {
|
||||
|
||||
this.domElement.removeEventListener( 'contextmenu', _contextmenu );
|
||||
this.domElement.removeEventListener( 'pointerdown', _pointerdown );
|
||||
this.domElement.removeEventListener( 'pointermove', _pointermove );
|
||||
this.domElement.removeEventListener( 'pointerup', _pointerup );
|
||||
this.domElement.removeEventListener( 'pointercancel', _pointercancel );
|
||||
|
||||
window.removeEventListener( 'keydown', _keydown );
|
||||
window.removeEventListener( 'keyup', _keyup );
|
||||
|
||||
};
|
||||
|
||||
const _contextmenu = this.contextMenu.bind( this );
|
||||
const _pointermove = this.pointermove.bind( this );
|
||||
const _pointerdown = this.pointerdown.bind( this );
|
||||
const _pointerup = this.pointerup.bind( this );
|
||||
const _pointercancel = this.pointercancel.bind( this );
|
||||
const _keydown = this.keydown.bind( this );
|
||||
const _keyup = this.keyup.bind( this );
|
||||
|
||||
this.domElement.addEventListener( 'contextmenu', _contextmenu );
|
||||
this.domElement.addEventListener( 'pointerdown', _pointerdown );
|
||||
this.domElement.addEventListener( 'pointermove', _pointermove );
|
||||
this.domElement.addEventListener( 'pointerup', _pointerup );
|
||||
this.domElement.addEventListener( 'pointercancel', _pointercancel );
|
||||
|
||||
window.addEventListener( 'keydown', _keydown );
|
||||
window.addEventListener( 'keyup', _keyup );
|
||||
|
||||
this.updateMovementVector();
|
||||
this.updateRotationVector();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { FlyControls };
|
||||
28
node_modules/three/examples/jsm/controls/MapControls.js
generated
vendored
Normal file
28
node_modules/three/examples/jsm/controls/MapControls.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import { MOUSE, TOUCH } from 'three';
|
||||
|
||||
import { OrbitControls } from './OrbitControls.js';
|
||||
|
||||
// MapControls performs orbiting, dollying (zooming), and panning.
|
||||
// Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default).
|
||||
//
|
||||
// Orbit - right mouse, or left mouse + ctrl/meta/shiftKey / touch: two-finger rotate
|
||||
// Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish
|
||||
// Pan - left mouse, or arrow keys / touch: one-finger move
|
||||
|
||||
class MapControls extends OrbitControls {
|
||||
|
||||
constructor( object, domElement ) {
|
||||
|
||||
super( object, domElement );
|
||||
|
||||
this.screenSpacePanning = false; // pan orthogonal to world-space direction camera.up
|
||||
|
||||
this.mouseButtons = { LEFT: MOUSE.PAN, MIDDLE: MOUSE.DOLLY, RIGHT: MOUSE.ROTATE };
|
||||
|
||||
this.touches = { ONE: TOUCH.PAN, TWO: TOUCH.DOLLY_ROTATE };
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { MapControls };
|
||||
1407
node_modules/three/examples/jsm/controls/OrbitControls.js
generated
vendored
Normal file
1407
node_modules/three/examples/jsm/controls/OrbitControls.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
162
node_modules/three/examples/jsm/controls/PointerLockControls.js
generated
vendored
Normal file
162
node_modules/three/examples/jsm/controls/PointerLockControls.js
generated
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
import {
|
||||
Euler,
|
||||
EventDispatcher,
|
||||
Vector3
|
||||
} from 'three';
|
||||
|
||||
const _euler = new Euler( 0, 0, 0, 'YXZ' );
|
||||
const _vector = new Vector3();
|
||||
|
||||
const _changeEvent = { type: 'change' };
|
||||
const _lockEvent = { type: 'lock' };
|
||||
const _unlockEvent = { type: 'unlock' };
|
||||
|
||||
const _PI_2 = Math.PI / 2;
|
||||
|
||||
class PointerLockControls extends EventDispatcher {
|
||||
|
||||
constructor( camera, domElement ) {
|
||||
|
||||
super();
|
||||
|
||||
this.camera = camera;
|
||||
this.domElement = domElement;
|
||||
|
||||
this.isLocked = false;
|
||||
|
||||
// Set to constrain the pitch of the camera
|
||||
// Range is 0 to Math.PI radians
|
||||
this.minPolarAngle = 0; // radians
|
||||
this.maxPolarAngle = Math.PI; // radians
|
||||
|
||||
this.pointerSpeed = 1.0;
|
||||
|
||||
this._onMouseMove = onMouseMove.bind( this );
|
||||
this._onPointerlockChange = onPointerlockChange.bind( this );
|
||||
this._onPointerlockError = onPointerlockError.bind( this );
|
||||
|
||||
this.connect();
|
||||
|
||||
}
|
||||
|
||||
connect() {
|
||||
|
||||
this.domElement.ownerDocument.addEventListener( 'mousemove', this._onMouseMove );
|
||||
this.domElement.ownerDocument.addEventListener( 'pointerlockchange', this._onPointerlockChange );
|
||||
this.domElement.ownerDocument.addEventListener( 'pointerlockerror', this._onPointerlockError );
|
||||
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
|
||||
this.domElement.ownerDocument.removeEventListener( 'mousemove', this._onMouseMove );
|
||||
this.domElement.ownerDocument.removeEventListener( 'pointerlockchange', this._onPointerlockChange );
|
||||
this.domElement.ownerDocument.removeEventListener( 'pointerlockerror', this._onPointerlockError );
|
||||
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
this.disconnect();
|
||||
|
||||
}
|
||||
|
||||
getObject() { // retaining this method for backward compatibility
|
||||
|
||||
return this.camera;
|
||||
|
||||
}
|
||||
|
||||
getDirection( v ) {
|
||||
|
||||
return v.set( 0, 0, - 1 ).applyQuaternion( this.camera.quaternion );
|
||||
|
||||
}
|
||||
|
||||
moveForward( distance ) {
|
||||
|
||||
// move forward parallel to the xz-plane
|
||||
// assumes camera.up is y-up
|
||||
|
||||
const camera = this.camera;
|
||||
|
||||
_vector.setFromMatrixColumn( camera.matrix, 0 );
|
||||
|
||||
_vector.crossVectors( camera.up, _vector );
|
||||
|
||||
camera.position.addScaledVector( _vector, distance );
|
||||
|
||||
}
|
||||
|
||||
moveRight( distance ) {
|
||||
|
||||
const camera = this.camera;
|
||||
|
||||
_vector.setFromMatrixColumn( camera.matrix, 0 );
|
||||
|
||||
camera.position.addScaledVector( _vector, distance );
|
||||
|
||||
}
|
||||
|
||||
lock() {
|
||||
|
||||
this.domElement.requestPointerLock();
|
||||
|
||||
}
|
||||
|
||||
unlock() {
|
||||
|
||||
this.domElement.ownerDocument.exitPointerLock();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// event listeners
|
||||
|
||||
function onMouseMove( event ) {
|
||||
|
||||
if ( this.isLocked === false ) return;
|
||||
|
||||
const movementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
|
||||
const movementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;
|
||||
|
||||
const camera = this.camera;
|
||||
_euler.setFromQuaternion( camera.quaternion );
|
||||
|
||||
_euler.y -= movementX * 0.002 * this.pointerSpeed;
|
||||
_euler.x -= movementY * 0.002 * this.pointerSpeed;
|
||||
|
||||
_euler.x = Math.max( _PI_2 - this.maxPolarAngle, Math.min( _PI_2 - this.minPolarAngle, _euler.x ) );
|
||||
|
||||
camera.quaternion.setFromEuler( _euler );
|
||||
|
||||
this.dispatchEvent( _changeEvent );
|
||||
|
||||
}
|
||||
|
||||
function onPointerlockChange() {
|
||||
|
||||
if ( this.domElement.ownerDocument.pointerLockElement === this.domElement ) {
|
||||
|
||||
this.dispatchEvent( _lockEvent );
|
||||
|
||||
this.isLocked = true;
|
||||
|
||||
} else {
|
||||
|
||||
this.dispatchEvent( _unlockEvent );
|
||||
|
||||
this.isLocked = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onPointerlockError() {
|
||||
|
||||
console.error( 'THREE.PointerLockControls: Unable to use Pointer Lock API' );
|
||||
|
||||
}
|
||||
|
||||
export { PointerLockControls };
|
||||
828
node_modules/three/examples/jsm/controls/TrackballControls.js
generated
vendored
Normal file
828
node_modules/three/examples/jsm/controls/TrackballControls.js
generated
vendored
Normal file
@@ -0,0 +1,828 @@
|
||||
import {
|
||||
EventDispatcher,
|
||||
MathUtils,
|
||||
MOUSE,
|
||||
Quaternion,
|
||||
Vector2,
|
||||
Vector3
|
||||
} from 'three';
|
||||
|
||||
const _changeEvent = { type: 'change' };
|
||||
const _startEvent = { type: 'start' };
|
||||
const _endEvent = { type: 'end' };
|
||||
|
||||
class TrackballControls extends EventDispatcher {
|
||||
|
||||
constructor( object, domElement ) {
|
||||
|
||||
super();
|
||||
|
||||
const scope = this;
|
||||
const STATE = { NONE: - 1, ROTATE: 0, ZOOM: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_ZOOM_PAN: 4 };
|
||||
|
||||
this.object = object;
|
||||
this.domElement = domElement;
|
||||
this.domElement.style.touchAction = 'none'; // disable touch scroll
|
||||
|
||||
// API
|
||||
|
||||
this.enabled = true;
|
||||
|
||||
this.screen = { left: 0, top: 0, width: 0, height: 0 };
|
||||
|
||||
this.rotateSpeed = 1.0;
|
||||
this.zoomSpeed = 1.2;
|
||||
this.panSpeed = 0.3;
|
||||
|
||||
this.noRotate = false;
|
||||
this.noZoom = false;
|
||||
this.noPan = false;
|
||||
|
||||
this.staticMoving = false;
|
||||
this.dynamicDampingFactor = 0.2;
|
||||
|
||||
this.minDistance = 0;
|
||||
this.maxDistance = Infinity;
|
||||
|
||||
this.minZoom = 0;
|
||||
this.maxZoom = Infinity;
|
||||
|
||||
this.keys = [ 'KeyA' /*A*/, 'KeyS' /*S*/, 'KeyD' /*D*/ ];
|
||||
|
||||
this.mouseButtons = { LEFT: MOUSE.ROTATE, MIDDLE: MOUSE.DOLLY, RIGHT: MOUSE.PAN };
|
||||
|
||||
// internals
|
||||
|
||||
this.target = new Vector3();
|
||||
|
||||
const EPS = 0.000001;
|
||||
|
||||
const lastPosition = new Vector3();
|
||||
let lastZoom = 1;
|
||||
|
||||
let _state = STATE.NONE,
|
||||
_keyState = STATE.NONE,
|
||||
|
||||
_touchZoomDistanceStart = 0,
|
||||
_touchZoomDistanceEnd = 0,
|
||||
|
||||
_lastAngle = 0;
|
||||
|
||||
const _eye = new Vector3(),
|
||||
|
||||
_movePrev = new Vector2(),
|
||||
_moveCurr = new Vector2(),
|
||||
|
||||
_lastAxis = new Vector3(),
|
||||
|
||||
_zoomStart = new Vector2(),
|
||||
_zoomEnd = new Vector2(),
|
||||
|
||||
_panStart = new Vector2(),
|
||||
_panEnd = new Vector2(),
|
||||
|
||||
_pointers = [],
|
||||
_pointerPositions = {};
|
||||
|
||||
// for reset
|
||||
|
||||
this.target0 = this.target.clone();
|
||||
this.position0 = this.object.position.clone();
|
||||
this.up0 = this.object.up.clone();
|
||||
this.zoom0 = this.object.zoom;
|
||||
|
||||
// methods
|
||||
|
||||
this.handleResize = function () {
|
||||
|
||||
const box = scope.domElement.getBoundingClientRect();
|
||||
// adjustments come from similar code in the jquery offset() function
|
||||
const d = scope.domElement.ownerDocument.documentElement;
|
||||
scope.screen.left = box.left + window.pageXOffset - d.clientLeft;
|
||||
scope.screen.top = box.top + window.pageYOffset - d.clientTop;
|
||||
scope.screen.width = box.width;
|
||||
scope.screen.height = box.height;
|
||||
|
||||
};
|
||||
|
||||
const getMouseOnScreen = ( function () {
|
||||
|
||||
const vector = new Vector2();
|
||||
|
||||
return function getMouseOnScreen( pageX, pageY ) {
|
||||
|
||||
vector.set(
|
||||
( pageX - scope.screen.left ) / scope.screen.width,
|
||||
( pageY - scope.screen.top ) / scope.screen.height
|
||||
);
|
||||
|
||||
return vector;
|
||||
|
||||
};
|
||||
|
||||
}() );
|
||||
|
||||
const getMouseOnCircle = ( function () {
|
||||
|
||||
const vector = new Vector2();
|
||||
|
||||
return function getMouseOnCircle( pageX, pageY ) {
|
||||
|
||||
vector.set(
|
||||
( ( pageX - scope.screen.width * 0.5 - scope.screen.left ) / ( scope.screen.width * 0.5 ) ),
|
||||
( ( scope.screen.height + 2 * ( scope.screen.top - pageY ) ) / scope.screen.width ) // screen.width intentional
|
||||
);
|
||||
|
||||
return vector;
|
||||
|
||||
};
|
||||
|
||||
}() );
|
||||
|
||||
this.rotateCamera = ( function () {
|
||||
|
||||
const axis = new Vector3(),
|
||||
quaternion = new Quaternion(),
|
||||
eyeDirection = new Vector3(),
|
||||
objectUpDirection = new Vector3(),
|
||||
objectSidewaysDirection = new Vector3(),
|
||||
moveDirection = new Vector3();
|
||||
|
||||
return function rotateCamera() {
|
||||
|
||||
moveDirection.set( _moveCurr.x - _movePrev.x, _moveCurr.y - _movePrev.y, 0 );
|
||||
let angle = moveDirection.length();
|
||||
|
||||
if ( angle ) {
|
||||
|
||||
_eye.copy( scope.object.position ).sub( scope.target );
|
||||
|
||||
eyeDirection.copy( _eye ).normalize();
|
||||
objectUpDirection.copy( scope.object.up ).normalize();
|
||||
objectSidewaysDirection.crossVectors( objectUpDirection, eyeDirection ).normalize();
|
||||
|
||||
objectUpDirection.setLength( _moveCurr.y - _movePrev.y );
|
||||
objectSidewaysDirection.setLength( _moveCurr.x - _movePrev.x );
|
||||
|
||||
moveDirection.copy( objectUpDirection.add( objectSidewaysDirection ) );
|
||||
|
||||
axis.crossVectors( moveDirection, _eye ).normalize();
|
||||
|
||||
angle *= scope.rotateSpeed;
|
||||
quaternion.setFromAxisAngle( axis, angle );
|
||||
|
||||
_eye.applyQuaternion( quaternion );
|
||||
scope.object.up.applyQuaternion( quaternion );
|
||||
|
||||
_lastAxis.copy( axis );
|
||||
_lastAngle = angle;
|
||||
|
||||
} else if ( ! scope.staticMoving && _lastAngle ) {
|
||||
|
||||
_lastAngle *= Math.sqrt( 1.0 - scope.dynamicDampingFactor );
|
||||
_eye.copy( scope.object.position ).sub( scope.target );
|
||||
quaternion.setFromAxisAngle( _lastAxis, _lastAngle );
|
||||
_eye.applyQuaternion( quaternion );
|
||||
scope.object.up.applyQuaternion( quaternion );
|
||||
|
||||
}
|
||||
|
||||
_movePrev.copy( _moveCurr );
|
||||
|
||||
};
|
||||
|
||||
}() );
|
||||
|
||||
|
||||
this.zoomCamera = function () {
|
||||
|
||||
let factor;
|
||||
|
||||
if ( _state === STATE.TOUCH_ZOOM_PAN ) {
|
||||
|
||||
factor = _touchZoomDistanceStart / _touchZoomDistanceEnd;
|
||||
_touchZoomDistanceStart = _touchZoomDistanceEnd;
|
||||
|
||||
if ( scope.object.isPerspectiveCamera ) {
|
||||
|
||||
_eye.multiplyScalar( factor );
|
||||
|
||||
} else if ( scope.object.isOrthographicCamera ) {
|
||||
|
||||
scope.object.zoom = MathUtils.clamp( scope.object.zoom / factor, scope.minZoom, scope.maxZoom );
|
||||
|
||||
if ( lastZoom !== scope.object.zoom ) {
|
||||
|
||||
scope.object.updateProjectionMatrix();
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
console.warn( 'THREE.TrackballControls: Unsupported camera type' );
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
factor = 1.0 + ( _zoomEnd.y - _zoomStart.y ) * scope.zoomSpeed;
|
||||
|
||||
if ( factor !== 1.0 && factor > 0.0 ) {
|
||||
|
||||
if ( scope.object.isPerspectiveCamera ) {
|
||||
|
||||
_eye.multiplyScalar( factor );
|
||||
|
||||
} else if ( scope.object.isOrthographicCamera ) {
|
||||
|
||||
scope.object.zoom = MathUtils.clamp( scope.object.zoom / factor, scope.minZoom, scope.maxZoom );
|
||||
|
||||
if ( lastZoom !== scope.object.zoom ) {
|
||||
|
||||
scope.object.updateProjectionMatrix();
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
console.warn( 'THREE.TrackballControls: Unsupported camera type' );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( scope.staticMoving ) {
|
||||
|
||||
_zoomStart.copy( _zoomEnd );
|
||||
|
||||
} else {
|
||||
|
||||
_zoomStart.y += ( _zoomEnd.y - _zoomStart.y ) * this.dynamicDampingFactor;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.panCamera = ( function () {
|
||||
|
||||
const mouseChange = new Vector2(),
|
||||
objectUp = new Vector3(),
|
||||
pan = new Vector3();
|
||||
|
||||
return function panCamera() {
|
||||
|
||||
mouseChange.copy( _panEnd ).sub( _panStart );
|
||||
|
||||
if ( mouseChange.lengthSq() ) {
|
||||
|
||||
if ( scope.object.isOrthographicCamera ) {
|
||||
|
||||
const scale_x = ( scope.object.right - scope.object.left ) / scope.object.zoom / scope.domElement.clientWidth;
|
||||
const scale_y = ( scope.object.top - scope.object.bottom ) / scope.object.zoom / scope.domElement.clientWidth;
|
||||
|
||||
mouseChange.x *= scale_x;
|
||||
mouseChange.y *= scale_y;
|
||||
|
||||
}
|
||||
|
||||
mouseChange.multiplyScalar( _eye.length() * scope.panSpeed );
|
||||
|
||||
pan.copy( _eye ).cross( scope.object.up ).setLength( mouseChange.x );
|
||||
pan.add( objectUp.copy( scope.object.up ).setLength( mouseChange.y ) );
|
||||
|
||||
scope.object.position.add( pan );
|
||||
scope.target.add( pan );
|
||||
|
||||
if ( scope.staticMoving ) {
|
||||
|
||||
_panStart.copy( _panEnd );
|
||||
|
||||
} else {
|
||||
|
||||
_panStart.add( mouseChange.subVectors( _panEnd, _panStart ).multiplyScalar( scope.dynamicDampingFactor ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}() );
|
||||
|
||||
this.checkDistances = function () {
|
||||
|
||||
if ( ! scope.noZoom || ! scope.noPan ) {
|
||||
|
||||
if ( _eye.lengthSq() > scope.maxDistance * scope.maxDistance ) {
|
||||
|
||||
scope.object.position.addVectors( scope.target, _eye.setLength( scope.maxDistance ) );
|
||||
_zoomStart.copy( _zoomEnd );
|
||||
|
||||
}
|
||||
|
||||
if ( _eye.lengthSq() < scope.minDistance * scope.minDistance ) {
|
||||
|
||||
scope.object.position.addVectors( scope.target, _eye.setLength( scope.minDistance ) );
|
||||
_zoomStart.copy( _zoomEnd );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.update = function () {
|
||||
|
||||
_eye.subVectors( scope.object.position, scope.target );
|
||||
|
||||
if ( ! scope.noRotate ) {
|
||||
|
||||
scope.rotateCamera();
|
||||
|
||||
}
|
||||
|
||||
if ( ! scope.noZoom ) {
|
||||
|
||||
scope.zoomCamera();
|
||||
|
||||
}
|
||||
|
||||
if ( ! scope.noPan ) {
|
||||
|
||||
scope.panCamera();
|
||||
|
||||
}
|
||||
|
||||
scope.object.position.addVectors( scope.target, _eye );
|
||||
|
||||
if ( scope.object.isPerspectiveCamera ) {
|
||||
|
||||
scope.checkDistances();
|
||||
|
||||
scope.object.lookAt( scope.target );
|
||||
|
||||
if ( lastPosition.distanceToSquared( scope.object.position ) > EPS ) {
|
||||
|
||||
scope.dispatchEvent( _changeEvent );
|
||||
|
||||
lastPosition.copy( scope.object.position );
|
||||
|
||||
}
|
||||
|
||||
} else if ( scope.object.isOrthographicCamera ) {
|
||||
|
||||
scope.object.lookAt( scope.target );
|
||||
|
||||
if ( lastPosition.distanceToSquared( scope.object.position ) > EPS || lastZoom !== scope.object.zoom ) {
|
||||
|
||||
scope.dispatchEvent( _changeEvent );
|
||||
|
||||
lastPosition.copy( scope.object.position );
|
||||
lastZoom = scope.object.zoom;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
console.warn( 'THREE.TrackballControls: Unsupported camera type' );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.reset = function () {
|
||||
|
||||
_state = STATE.NONE;
|
||||
_keyState = STATE.NONE;
|
||||
|
||||
scope.target.copy( scope.target0 );
|
||||
scope.object.position.copy( scope.position0 );
|
||||
scope.object.up.copy( scope.up0 );
|
||||
scope.object.zoom = scope.zoom0;
|
||||
|
||||
scope.object.updateProjectionMatrix();
|
||||
|
||||
_eye.subVectors( scope.object.position, scope.target );
|
||||
|
||||
scope.object.lookAt( scope.target );
|
||||
|
||||
scope.dispatchEvent( _changeEvent );
|
||||
|
||||
lastPosition.copy( scope.object.position );
|
||||
lastZoom = scope.object.zoom;
|
||||
|
||||
};
|
||||
|
||||
// listeners
|
||||
|
||||
function onPointerDown( event ) {
|
||||
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
if ( _pointers.length === 0 ) {
|
||||
|
||||
scope.domElement.setPointerCapture( event.pointerId );
|
||||
|
||||
scope.domElement.addEventListener( 'pointermove', onPointerMove );
|
||||
scope.domElement.addEventListener( 'pointerup', onPointerUp );
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
addPointer( event );
|
||||
|
||||
if ( event.pointerType === 'touch' ) {
|
||||
|
||||
onTouchStart( event );
|
||||
|
||||
} else {
|
||||
|
||||
onMouseDown( event );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onPointerMove( event ) {
|
||||
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
if ( event.pointerType === 'touch' ) {
|
||||
|
||||
onTouchMove( event );
|
||||
|
||||
} else {
|
||||
|
||||
onMouseMove( event );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onPointerUp( event ) {
|
||||
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
if ( event.pointerType === 'touch' ) {
|
||||
|
||||
onTouchEnd( event );
|
||||
|
||||
} else {
|
||||
|
||||
onMouseUp();
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
removePointer( event );
|
||||
|
||||
if ( _pointers.length === 0 ) {
|
||||
|
||||
scope.domElement.releasePointerCapture( event.pointerId );
|
||||
|
||||
scope.domElement.removeEventListener( 'pointermove', onPointerMove );
|
||||
scope.domElement.removeEventListener( 'pointerup', onPointerUp );
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function onPointerCancel( event ) {
|
||||
|
||||
removePointer( event );
|
||||
|
||||
}
|
||||
|
||||
function keydown( event ) {
|
||||
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
window.removeEventListener( 'keydown', keydown );
|
||||
|
||||
if ( _keyState !== STATE.NONE ) {
|
||||
|
||||
return;
|
||||
|
||||
} else if ( event.code === scope.keys[ STATE.ROTATE ] && ! scope.noRotate ) {
|
||||
|
||||
_keyState = STATE.ROTATE;
|
||||
|
||||
} else if ( event.code === scope.keys[ STATE.ZOOM ] && ! scope.noZoom ) {
|
||||
|
||||
_keyState = STATE.ZOOM;
|
||||
|
||||
} else if ( event.code === scope.keys[ STATE.PAN ] && ! scope.noPan ) {
|
||||
|
||||
_keyState = STATE.PAN;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function keyup() {
|
||||
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
_keyState = STATE.NONE;
|
||||
|
||||
window.addEventListener( 'keydown', keydown );
|
||||
|
||||
}
|
||||
|
||||
function onMouseDown( event ) {
|
||||
|
||||
if ( _state === STATE.NONE ) {
|
||||
|
||||
switch ( event.button ) {
|
||||
|
||||
case scope.mouseButtons.LEFT:
|
||||
_state = STATE.ROTATE;
|
||||
break;
|
||||
|
||||
case scope.mouseButtons.MIDDLE:
|
||||
_state = STATE.ZOOM;
|
||||
break;
|
||||
|
||||
case scope.mouseButtons.RIGHT:
|
||||
_state = STATE.PAN;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const state = ( _keyState !== STATE.NONE ) ? _keyState : _state;
|
||||
|
||||
if ( state === STATE.ROTATE && ! scope.noRotate ) {
|
||||
|
||||
_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );
|
||||
_movePrev.copy( _moveCurr );
|
||||
|
||||
} else if ( state === STATE.ZOOM && ! scope.noZoom ) {
|
||||
|
||||
_zoomStart.copy( getMouseOnScreen( event.pageX, event.pageY ) );
|
||||
_zoomEnd.copy( _zoomStart );
|
||||
|
||||
} else if ( state === STATE.PAN && ! scope.noPan ) {
|
||||
|
||||
_panStart.copy( getMouseOnScreen( event.pageX, event.pageY ) );
|
||||
_panEnd.copy( _panStart );
|
||||
|
||||
}
|
||||
|
||||
scope.dispatchEvent( _startEvent );
|
||||
|
||||
}
|
||||
|
||||
function onMouseMove( event ) {
|
||||
|
||||
const state = ( _keyState !== STATE.NONE ) ? _keyState : _state;
|
||||
|
||||
if ( state === STATE.ROTATE && ! scope.noRotate ) {
|
||||
|
||||
_movePrev.copy( _moveCurr );
|
||||
_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );
|
||||
|
||||
} else if ( state === STATE.ZOOM && ! scope.noZoom ) {
|
||||
|
||||
_zoomEnd.copy( getMouseOnScreen( event.pageX, event.pageY ) );
|
||||
|
||||
} else if ( state === STATE.PAN && ! scope.noPan ) {
|
||||
|
||||
_panEnd.copy( getMouseOnScreen( event.pageX, event.pageY ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onMouseUp() {
|
||||
|
||||
_state = STATE.NONE;
|
||||
|
||||
scope.dispatchEvent( _endEvent );
|
||||
|
||||
}
|
||||
|
||||
function onMouseWheel( event ) {
|
||||
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
if ( scope.noZoom === true ) return;
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
switch ( event.deltaMode ) {
|
||||
|
||||
case 2:
|
||||
// Zoom in pages
|
||||
_zoomStart.y -= event.deltaY * 0.025;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
// Zoom in lines
|
||||
_zoomStart.y -= event.deltaY * 0.01;
|
||||
break;
|
||||
|
||||
default:
|
||||
// undefined, 0, assume pixels
|
||||
_zoomStart.y -= event.deltaY * 0.00025;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
scope.dispatchEvent( _startEvent );
|
||||
scope.dispatchEvent( _endEvent );
|
||||
|
||||
}
|
||||
|
||||
function onTouchStart( event ) {
|
||||
|
||||
trackPointer( event );
|
||||
|
||||
switch ( _pointers.length ) {
|
||||
|
||||
case 1:
|
||||
_state = STATE.TOUCH_ROTATE;
|
||||
_moveCurr.copy( getMouseOnCircle( _pointers[ 0 ].pageX, _pointers[ 0 ].pageY ) );
|
||||
_movePrev.copy( _moveCurr );
|
||||
break;
|
||||
|
||||
default: // 2 or more
|
||||
_state = STATE.TOUCH_ZOOM_PAN;
|
||||
const dx = _pointers[ 0 ].pageX - _pointers[ 1 ].pageX;
|
||||
const dy = _pointers[ 0 ].pageY - _pointers[ 1 ].pageY;
|
||||
_touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt( dx * dx + dy * dy );
|
||||
|
||||
const x = ( _pointers[ 0 ].pageX + _pointers[ 1 ].pageX ) / 2;
|
||||
const y = ( _pointers[ 0 ].pageY + _pointers[ 1 ].pageY ) / 2;
|
||||
_panStart.copy( getMouseOnScreen( x, y ) );
|
||||
_panEnd.copy( _panStart );
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
scope.dispatchEvent( _startEvent );
|
||||
|
||||
}
|
||||
|
||||
function onTouchMove( event ) {
|
||||
|
||||
trackPointer( event );
|
||||
|
||||
switch ( _pointers.length ) {
|
||||
|
||||
case 1:
|
||||
_movePrev.copy( _moveCurr );
|
||||
_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );
|
||||
break;
|
||||
|
||||
default: // 2 or more
|
||||
|
||||
const position = getSecondPointerPosition( event );
|
||||
|
||||
const dx = event.pageX - position.x;
|
||||
const dy = event.pageY - position.y;
|
||||
_touchZoomDistanceEnd = Math.sqrt( dx * dx + dy * dy );
|
||||
|
||||
const x = ( event.pageX + position.x ) / 2;
|
||||
const y = ( event.pageY + position.y ) / 2;
|
||||
_panEnd.copy( getMouseOnScreen( x, y ) );
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onTouchEnd( event ) {
|
||||
|
||||
switch ( _pointers.length ) {
|
||||
|
||||
case 0:
|
||||
_state = STATE.NONE;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
_state = STATE.TOUCH_ROTATE;
|
||||
_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );
|
||||
_movePrev.copy( _moveCurr );
|
||||
break;
|
||||
|
||||
case 2:
|
||||
_state = STATE.TOUCH_ZOOM_PAN;
|
||||
|
||||
for ( let i = 0; i < _pointers.length; i ++ ) {
|
||||
|
||||
if ( _pointers[ i ].pointerId !== event.pointerId ) {
|
||||
|
||||
const position = _pointerPositions[ _pointers[ i ].pointerId ];
|
||||
_moveCurr.copy( getMouseOnCircle( position.x, position.y ) );
|
||||
_movePrev.copy( _moveCurr );
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
scope.dispatchEvent( _endEvent );
|
||||
|
||||
}
|
||||
|
||||
function contextmenu( event ) {
|
||||
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
}
|
||||
|
||||
function addPointer( event ) {
|
||||
|
||||
_pointers.push( event );
|
||||
|
||||
}
|
||||
|
||||
function removePointer( event ) {
|
||||
|
||||
delete _pointerPositions[ event.pointerId ];
|
||||
|
||||
for ( let i = 0; i < _pointers.length; i ++ ) {
|
||||
|
||||
if ( _pointers[ i ].pointerId == event.pointerId ) {
|
||||
|
||||
_pointers.splice( i, 1 );
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function trackPointer( event ) {
|
||||
|
||||
let position = _pointerPositions[ event.pointerId ];
|
||||
|
||||
if ( position === undefined ) {
|
||||
|
||||
position = new Vector2();
|
||||
_pointerPositions[ event.pointerId ] = position;
|
||||
|
||||
}
|
||||
|
||||
position.set( event.pageX, event.pageY );
|
||||
|
||||
}
|
||||
|
||||
function getSecondPointerPosition( event ) {
|
||||
|
||||
const pointer = ( event.pointerId === _pointers[ 0 ].pointerId ) ? _pointers[ 1 ] : _pointers[ 0 ];
|
||||
|
||||
return _pointerPositions[ pointer.pointerId ];
|
||||
|
||||
}
|
||||
|
||||
this.dispose = function () {
|
||||
|
||||
scope.domElement.removeEventListener( 'contextmenu', contextmenu );
|
||||
|
||||
scope.domElement.removeEventListener( 'pointerdown', onPointerDown );
|
||||
scope.domElement.removeEventListener( 'pointercancel', onPointerCancel );
|
||||
scope.domElement.removeEventListener( 'wheel', onMouseWheel );
|
||||
|
||||
scope.domElement.removeEventListener( 'pointermove', onPointerMove );
|
||||
scope.domElement.removeEventListener( 'pointerup', onPointerUp );
|
||||
|
||||
window.removeEventListener( 'keydown', keydown );
|
||||
window.removeEventListener( 'keyup', keyup );
|
||||
|
||||
};
|
||||
|
||||
this.domElement.addEventListener( 'contextmenu', contextmenu );
|
||||
|
||||
this.domElement.addEventListener( 'pointerdown', onPointerDown );
|
||||
this.domElement.addEventListener( 'pointercancel', onPointerCancel );
|
||||
this.domElement.addEventListener( 'wheel', onMouseWheel, { passive: false } );
|
||||
|
||||
|
||||
window.addEventListener( 'keydown', keydown );
|
||||
window.addEventListener( 'keyup', keyup );
|
||||
|
||||
this.handleResize();
|
||||
|
||||
// force an update at start
|
||||
this.update();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { TrackballControls };
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user