Project files
This commit is contained in:
21
receipeServer/frontend_old/node_modules/tapable/LICENSE
generated
vendored
Normal file
21
receipeServer/frontend_old/node_modules/tapable/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
|
||||
Copyright JS Foundation 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.
|
||||
296
receipeServer/frontend_old/node_modules/tapable/README.md
generated
vendored
Normal file
296
receipeServer/frontend_old/node_modules/tapable/README.md
generated
vendored
Normal file
@@ -0,0 +1,296 @@
|
||||
# Tapable
|
||||
|
||||
The tapable package expose many Hook classes, which can be used to create hooks for plugins.
|
||||
|
||||
``` javascript
|
||||
const {
|
||||
SyncHook,
|
||||
SyncBailHook,
|
||||
SyncWaterfallHook,
|
||||
SyncLoopHook,
|
||||
AsyncParallelHook,
|
||||
AsyncParallelBailHook,
|
||||
AsyncSeriesHook,
|
||||
AsyncSeriesBailHook,
|
||||
AsyncSeriesWaterfallHook
|
||||
} = require("tapable");
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
``` shell
|
||||
npm install --save tapable
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
All Hook constructors take one optional argument, which is a list of argument names as strings.
|
||||
|
||||
``` js
|
||||
const hook = new SyncHook(["arg1", "arg2", "arg3"]);
|
||||
```
|
||||
|
||||
The best practice is to expose all hooks of a class in a `hooks` property:
|
||||
|
||||
``` js
|
||||
class Car {
|
||||
constructor() {
|
||||
this.hooks = {
|
||||
accelerate: new SyncHook(["newSpeed"]),
|
||||
brake: new SyncHook(),
|
||||
calculateRoutes: new AsyncParallelHook(["source", "target", "routesList"])
|
||||
};
|
||||
}
|
||||
|
||||
/* ... */
|
||||
}
|
||||
```
|
||||
|
||||
Other people can now use these hooks:
|
||||
|
||||
``` js
|
||||
const myCar = new Car();
|
||||
|
||||
// Use the tap method to add a consument
|
||||
myCar.hooks.brake.tap("WarningLampPlugin", () => warningLamp.on());
|
||||
```
|
||||
|
||||
It's required to pass a name to identify the plugin/reason.
|
||||
|
||||
You may receive arguments:
|
||||
|
||||
``` js
|
||||
myCar.hooks.accelerate.tap("LoggerPlugin", newSpeed => console.log(`Accelerating to ${newSpeed}`));
|
||||
```
|
||||
|
||||
For sync hooks, `tap` is the only valid method to add a plugin. Async hooks also support async plugins:
|
||||
|
||||
``` js
|
||||
myCar.hooks.calculateRoutes.tapPromise("GoogleMapsPlugin", (source, target, routesList) => {
|
||||
// return a promise
|
||||
return google.maps.findRoute(source, target).then(route => {
|
||||
routesList.add(route);
|
||||
});
|
||||
});
|
||||
myCar.hooks.calculateRoutes.tapAsync("BingMapsPlugin", (source, target, routesList, callback) => {
|
||||
bing.findRoute(source, target, (err, route) => {
|
||||
if(err) return callback(err);
|
||||
routesList.add(route);
|
||||
// call the callback
|
||||
callback();
|
||||
});
|
||||
});
|
||||
|
||||
// You can still use sync plugins
|
||||
myCar.hooks.calculateRoutes.tap("CachedRoutesPlugin", (source, target, routesList) => {
|
||||
const cachedRoute = cache.get(source, target);
|
||||
if(cachedRoute)
|
||||
routesList.add(cachedRoute);
|
||||
})
|
||||
```
|
||||
The class declaring these hooks need to call them:
|
||||
|
||||
``` js
|
||||
class Car {
|
||||
/**
|
||||
* You won't get returned value from SyncHook or AsyncParallelHook,
|
||||
* to do that, use SyncWaterfallHook and AsyncSeriesWaterfallHook respectively
|
||||
**/
|
||||
|
||||
setSpeed(newSpeed) {
|
||||
// following call returns undefined even when you returned values
|
||||
this.hooks.accelerate.call(newSpeed);
|
||||
}
|
||||
|
||||
useNavigationSystemPromise(source, target) {
|
||||
const routesList = new List();
|
||||
return this.hooks.calculateRoutes.promise(source, target, routesList).then((res) => {
|
||||
// res is undefined for AsyncParallelHook
|
||||
return routesList.getRoutes();
|
||||
});
|
||||
}
|
||||
|
||||
useNavigationSystemAsync(source, target, callback) {
|
||||
const routesList = new List();
|
||||
this.hooks.calculateRoutes.callAsync(source, target, routesList, err => {
|
||||
if(err) return callback(err);
|
||||
callback(null, routesList.getRoutes());
|
||||
});
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The Hook will compile a method with the most efficient way of running your plugins. It generates code depending on:
|
||||
* The number of registered plugins (none, one, many)
|
||||
* The kind of registered plugins (sync, async, promise)
|
||||
* The used call method (sync, async, promise)
|
||||
* The number of arguments
|
||||
* Whether interception is used
|
||||
|
||||
This ensures fastest possible execution.
|
||||
|
||||
## Hook types
|
||||
|
||||
Each hook can be tapped with one or several functions. How they are executed depends on the hook type:
|
||||
|
||||
* Basic hook (without “Waterfall”, “Bail” or “Loop” in its name). This hook simply calls every function it tapped in a row.
|
||||
|
||||
* __Waterfall__. A waterfall hook also calls each tapped function in a row. Unlike the basic hook, it passes a return value from each function to the next function.
|
||||
|
||||
* __Bail__. A bail hook allows exiting early. When any of the tapped function returns anything, the bail hook will stop executing the remaining ones.
|
||||
|
||||
* __Loop__. When a plugin in a loop hook returns a non-undefined value the hook will restart from the first plugin. It will loop until all plugins return undefined.
|
||||
|
||||
Additionally, hooks can be synchronous or asynchronous. To reflect this, there’re “Sync”, “AsyncSeries”, and “AsyncParallel” hook classes:
|
||||
|
||||
* __Sync__. A sync hook can only be tapped with synchronous functions (using `myHook.tap()`).
|
||||
|
||||
* __AsyncSeries__. An async-series hook can be tapped with synchronous, callback-based and promise-based functions (using `myHook.tap()`, `myHook.tapAsync()` and `myHook.tapPromise()`). They call each async method in a row.
|
||||
|
||||
* __AsyncParallel__. An async-parallel hook can also be tapped with synchronous, callback-based and promise-based functions (using `myHook.tap()`, `myHook.tapAsync()` and `myHook.tapPromise()`). However, they run each async method in parallel.
|
||||
|
||||
The hook type is reflected in its class name. E.g., `AsyncSeriesWaterfallHook` allows asynchronous functions and runs them in series, passing each function’s return value into the next function.
|
||||
|
||||
|
||||
## Interception
|
||||
|
||||
All Hooks offer an additional interception API:
|
||||
|
||||
``` js
|
||||
myCar.hooks.calculateRoutes.intercept({
|
||||
call: (source, target, routesList) => {
|
||||
console.log("Starting to calculate routes");
|
||||
},
|
||||
register: (tapInfo) => {
|
||||
// tapInfo = { type: "promise", name: "GoogleMapsPlugin", fn: ... }
|
||||
console.log(`${tapInfo.name} is doing its job`);
|
||||
return tapInfo; // may return a new tapInfo object
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
**call**: `(...args) => void` Adding `call` to your interceptor will trigger when hooks are triggered. You have access to the hooks arguments.
|
||||
|
||||
**tap**: `(tap: Tap) => void` Adding `tap` to your interceptor will trigger when a plugin taps into a hook. Provided is the `Tap` object. `Tap` object can't be changed.
|
||||
|
||||
**loop**: `(...args) => void` Adding `loop` to your interceptor will trigger for each loop of a looping hook.
|
||||
|
||||
**register**: `(tap: Tap) => Tap | undefined` Adding `register` to your interceptor will trigger for each added `Tap` and allows to modify it.
|
||||
|
||||
## Context
|
||||
|
||||
Plugins and interceptors can opt-in to access an optional `context` object, which can be used to pass arbitrary values to subsequent plugins and interceptors.
|
||||
|
||||
``` js
|
||||
myCar.hooks.accelerate.intercept({
|
||||
context: true,
|
||||
tap: (context, tapInfo) => {
|
||||
// tapInfo = { type: "sync", name: "NoisePlugin", fn: ... }
|
||||
console.log(`${tapInfo.name} is doing it's job`);
|
||||
|
||||
// `context` starts as an empty object if at least one plugin uses `context: true`.
|
||||
// If no plugins use `context: true`, then `context` is undefined.
|
||||
if (context) {
|
||||
// Arbitrary properties can be added to `context`, which plugins can then access.
|
||||
context.hasMuffler = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
myCar.hooks.accelerate.tap({
|
||||
name: "NoisePlugin",
|
||||
context: true
|
||||
}, (context, newSpeed) => {
|
||||
if (context && context.hasMuffler) {
|
||||
console.log("Silence...");
|
||||
} else {
|
||||
console.log("Vroom!");
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## HookMap
|
||||
|
||||
A HookMap is a helper class for a Map with Hooks
|
||||
|
||||
``` js
|
||||
const keyedHook = new HookMap(key => new SyncHook(["arg"]))
|
||||
```
|
||||
|
||||
``` js
|
||||
keyedHook.for("some-key").tap("MyPlugin", (arg) => { /* ... */ });
|
||||
keyedHook.for("some-key").tapAsync("MyPlugin", (arg, callback) => { /* ... */ });
|
||||
keyedHook.for("some-key").tapPromise("MyPlugin", (arg) => { /* ... */ });
|
||||
```
|
||||
|
||||
``` js
|
||||
const hook = keyedHook.get("some-key");
|
||||
if(hook !== undefined) {
|
||||
hook.callAsync("arg", err => { /* ... */ });
|
||||
}
|
||||
```
|
||||
|
||||
## Hook/HookMap interface
|
||||
|
||||
Public:
|
||||
|
||||
``` ts
|
||||
interface Hook {
|
||||
tap: (name: string | Tap, fn: (context?, ...args) => Result) => void,
|
||||
tapAsync: (name: string | Tap, fn: (context?, ...args, callback: (err, result: Result) => void) => void) => void,
|
||||
tapPromise: (name: string | Tap, fn: (context?, ...args) => Promise<Result>) => void,
|
||||
intercept: (interceptor: HookInterceptor) => void
|
||||
}
|
||||
|
||||
interface HookInterceptor {
|
||||
call: (context?, ...args) => void,
|
||||
loop: (context?, ...args) => void,
|
||||
tap: (context?, tap: Tap) => void,
|
||||
register: (tap: Tap) => Tap,
|
||||
context: boolean
|
||||
}
|
||||
|
||||
interface HookMap {
|
||||
for: (key: any) => Hook,
|
||||
intercept: (interceptor: HookMapInterceptor) => void
|
||||
}
|
||||
|
||||
interface HookMapInterceptor {
|
||||
factory: (key: any, hook: Hook) => Hook
|
||||
}
|
||||
|
||||
interface Tap {
|
||||
name: string,
|
||||
type: string
|
||||
fn: Function,
|
||||
stage: number,
|
||||
context: boolean,
|
||||
before?: string | Array
|
||||
}
|
||||
```
|
||||
|
||||
Protected (only for the class containing the hook):
|
||||
|
||||
``` ts
|
||||
interface Hook {
|
||||
isUsed: () => boolean,
|
||||
call: (...args) => Result,
|
||||
promise: (...args) => Promise<Result>,
|
||||
callAsync: (...args, callback: (err, result: Result) => void) => void,
|
||||
}
|
||||
|
||||
interface HookMap {
|
||||
get: (key: any) => Hook | undefined,
|
||||
for: (key: any) => Hook
|
||||
}
|
||||
```
|
||||
|
||||
## MultiHook
|
||||
|
||||
A helper Hook-like class to redirect taps to multiple other hooks:
|
||||
|
||||
``` js
|
||||
const { MultiHook } = require("tapable");
|
||||
|
||||
this.hooks.allHooks = new MultiHook([this.hooks.hookA, this.hooks.hookB]);
|
||||
```
|
||||
44
receipeServer/frontend_old/node_modules/tapable/package.json
generated
vendored
Normal file
44
receipeServer/frontend_old/node_modules/tapable/package.json
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "tapable",
|
||||
"version": "2.2.1",
|
||||
"author": "Tobias Koppers @sokra",
|
||||
"description": "Just a little module for plugins.",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/webpack/tapable",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://github.com/webpack/tapable.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.4.4",
|
||||
"@babel/preset-env": "^7.4.4",
|
||||
"babel-jest": "^24.8.0",
|
||||
"codecov": "^3.5.0",
|
||||
"jest": "^24.8.0",
|
||||
"prettier": "^1.17.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
"!lib/__tests__",
|
||||
"tapable.d.ts"
|
||||
],
|
||||
"main": "lib/index.js",
|
||||
"types": "./tapable.d.ts",
|
||||
"browser": {
|
||||
"util": "./lib/util-browser.js"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
"travis": "yarn pretty-lint && jest --coverage && codecov",
|
||||
"pretty-lint": "prettier --check lib/*.js lib/__tests__/*.js",
|
||||
"pretty": "prettier --loglevel warn --write lib/*.js lib/__tests__/*.js"
|
||||
},
|
||||
"jest": {
|
||||
"transform": {
|
||||
"__tests__[\\\\/].+\\.js$": "babel-jest"
|
||||
}
|
||||
}
|
||||
}
|
||||
116
receipeServer/frontend_old/node_modules/tapable/tapable.d.ts
generated
vendored
Normal file
116
receipeServer/frontend_old/node_modules/tapable/tapable.d.ts
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
type FixedSizeArray<T extends number, U> = T extends 0
|
||||
? void[]
|
||||
: ReadonlyArray<U> & {
|
||||
0: U;
|
||||
length: T;
|
||||
};
|
||||
type Measure<T extends number> = T extends 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
|
||||
? T
|
||||
: never;
|
||||
type Append<T extends any[], U> = {
|
||||
0: [U];
|
||||
1: [T[0], U];
|
||||
2: [T[0], T[1], U];
|
||||
3: [T[0], T[1], T[2], U];
|
||||
4: [T[0], T[1], T[2], T[3], U];
|
||||
5: [T[0], T[1], T[2], T[3], T[4], U];
|
||||
6: [T[0], T[1], T[2], T[3], T[4], T[5], U];
|
||||
7: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], U];
|
||||
8: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], U];
|
||||
}[Measure<T["length"]>];
|
||||
type AsArray<T> = T extends any[] ? T : [T];
|
||||
|
||||
declare class UnsetAdditionalOptions {
|
||||
_UnsetAdditionalOptions: true
|
||||
}
|
||||
type IfSet<X> = X extends UnsetAdditionalOptions ? {} : X;
|
||||
|
||||
type Callback<E, T> = (error: E | null, result?: T) => void;
|
||||
type InnerCallback<E, T> = (error?: E | null | false, result?: T) => void;
|
||||
|
||||
type FullTap = Tap & {
|
||||
type: "sync" | "async" | "promise",
|
||||
fn: Function
|
||||
}
|
||||
|
||||
type Tap = TapOptions & {
|
||||
name: string;
|
||||
};
|
||||
|
||||
type TapOptions = {
|
||||
before?: string;
|
||||
stage?: number;
|
||||
};
|
||||
|
||||
interface HookInterceptor<T, R, AdditionalOptions = UnsetAdditionalOptions> {
|
||||
name?: string;
|
||||
tap?: (tap: FullTap & IfSet<AdditionalOptions>) => void;
|
||||
call?: (...args: any[]) => void;
|
||||
loop?: (...args: any[]) => void;
|
||||
error?: (err: Error) => void;
|
||||
result?: (result: R) => void;
|
||||
done?: () => void;
|
||||
register?: (tap: FullTap & IfSet<AdditionalOptions>) => FullTap & IfSet<AdditionalOptions>;
|
||||
}
|
||||
|
||||
type ArgumentNames<T extends any[]> = FixedSizeArray<T["length"], string>;
|
||||
|
||||
declare class Hook<T, R, AdditionalOptions = UnsetAdditionalOptions> {
|
||||
constructor(args?: ArgumentNames<AsArray<T>>, name?: string);
|
||||
name: string | undefined;
|
||||
taps: FullTap[];
|
||||
intercept(interceptor: HookInterceptor<T, R, AdditionalOptions>): void;
|
||||
isUsed(): boolean;
|
||||
callAsync(...args: Append<AsArray<T>, Callback<Error, R>>): void;
|
||||
promise(...args: AsArray<T>): Promise<R>;
|
||||
tap(options: string | Tap & IfSet<AdditionalOptions>, fn: (...args: AsArray<T>) => R): void;
|
||||
withOptions(options: TapOptions & IfSet<AdditionalOptions>): Omit<this, "call" | "callAsync" | "promise">;
|
||||
}
|
||||
|
||||
export class SyncHook<T, R = void, AdditionalOptions = UnsetAdditionalOptions> extends Hook<T, R, AdditionalOptions> {
|
||||
call(...args: AsArray<T>): R;
|
||||
}
|
||||
|
||||
export class SyncBailHook<T, R, AdditionalOptions = UnsetAdditionalOptions> extends SyncHook<T, R, AdditionalOptions> {}
|
||||
export class SyncLoopHook<T, AdditionalOptions = UnsetAdditionalOptions> extends SyncHook<T, void, AdditionalOptions> {}
|
||||
export class SyncWaterfallHook<T, AdditionalOptions = UnsetAdditionalOptions> extends SyncHook<T, AsArray<T>[0], AdditionalOptions> {}
|
||||
|
||||
declare class AsyncHook<T, R, AdditionalOptions = UnsetAdditionalOptions> extends Hook<T, R, AdditionalOptions> {
|
||||
tapAsync(
|
||||
options: string | Tap & IfSet<AdditionalOptions>,
|
||||
fn: (...args: Append<AsArray<T>, InnerCallback<Error, R>>) => void
|
||||
): void;
|
||||
tapPromise(
|
||||
options: string | Tap & IfSet<AdditionalOptions>,
|
||||
fn: (...args: AsArray<T>) => Promise<R>
|
||||
): void;
|
||||
}
|
||||
|
||||
export class AsyncParallelHook<T, AdditionalOptions = UnsetAdditionalOptions> extends AsyncHook<T, void, AdditionalOptions> {}
|
||||
export class AsyncParallelBailHook<T, R, AdditionalOptions = UnsetAdditionalOptions> extends AsyncHook<T, R, AdditionalOptions> {}
|
||||
export class AsyncSeriesHook<T, AdditionalOptions = UnsetAdditionalOptions> extends AsyncHook<T, void, AdditionalOptions> {}
|
||||
export class AsyncSeriesBailHook<T, R, AdditionalOptions = UnsetAdditionalOptions> extends AsyncHook<T, R, AdditionalOptions> {}
|
||||
export class AsyncSeriesLoopHook<T, AdditionalOptions = UnsetAdditionalOptions> extends AsyncHook<T, void, AdditionalOptions> {}
|
||||
export class AsyncSeriesWaterfallHook<T, AdditionalOptions = UnsetAdditionalOptions> extends AsyncHook<T, AsArray<T>[0], AdditionalOptions> {}
|
||||
|
||||
type HookFactory<H> = (key: any, hook?: H) => H;
|
||||
|
||||
interface HookMapInterceptor<H> {
|
||||
factory?: HookFactory<H>;
|
||||
}
|
||||
|
||||
export class HookMap<H> {
|
||||
constructor(factory: HookFactory<H>, name?: string);
|
||||
name: string | undefined;
|
||||
get(key: any): H | undefined;
|
||||
for(key: any): H;
|
||||
intercept(interceptor: HookMapInterceptor<H>): void;
|
||||
}
|
||||
|
||||
export class MultiHook<H> {
|
||||
constructor(hooks: H[], name?: string);
|
||||
name: string | undefined;
|
||||
tap(options: string | Tap, fn?: Function): void;
|
||||
tapAsync(options: string | Tap, fn?: Function): void;
|
||||
tapPromise(options: string | Tap, fn?: Function): void;
|
||||
}
|
||||
Reference in New Issue
Block a user