This commit is contained in:
21
node_modules/@wry/context/LICENSE
generated
vendored
Normal file
21
node_modules/@wry/context/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Ben Newman
|
||||
|
||||
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.
|
||||
4
node_modules/@wry/context/README.md
generated
vendored
Normal file
4
node_modules/@wry/context/README.md
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
# @wry/context
|
||||
|
||||
Manage contextual information needed by synchronous or asynchronous
|
||||
tasks without explicitly passing objects around.
|
||||
8
node_modules/@wry/context/lib/context.d.ts
generated
vendored
Normal file
8
node_modules/@wry/context/lib/context.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/// <reference types="node" />
|
||||
import { Slot } from "./slot";
|
||||
export { Slot };
|
||||
export declare const bind: <TArgs extends any[], TResult>(callback: (...args: TArgs) => TResult) => (...args: TArgs) => TResult, noContext: <TResult, TArgs extends any[], TThis = any>(callback: (this: TThis, ...args: TArgs) => TResult, args?: TArgs | undefined, thisArg?: TThis | undefined) => TResult;
|
||||
export { setTimeoutWithContext as setTimeout };
|
||||
declare function setTimeoutWithContext(callback: () => any, delay: number): NodeJS.Timer;
|
||||
export declare function asyncFromGen<TArgs extends any[], TResult>(genFn: (...args: TArgs) => IterableIterator<TResult>): (...args: TArgs) => Promise<TResult>;
|
||||
export declare function wrapYieldingFiberMethods<F extends Function>(Fiber: F): F;
|
||||
199
node_modules/@wry/context/lib/context.esm.js
generated
vendored
Normal file
199
node_modules/@wry/context/lib/context.esm.js
generated
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
// This currentContext variable will only be used if the makeSlotClass
|
||||
// function is called, which happens only if this is the first copy of the
|
||||
// @wry/context package to be imported.
|
||||
var currentContext = null;
|
||||
// This unique internal object is used to denote the absence of a value
|
||||
// for a given Slot, and is never exposed to outside code.
|
||||
var MISSING_VALUE = {};
|
||||
var idCounter = 1;
|
||||
// Although we can't do anything about the cost of duplicated code from
|
||||
// accidentally bundling multiple copies of the @wry/context package, we can
|
||||
// avoid creating the Slot class more than once using makeSlotClass.
|
||||
var makeSlotClass = function () { return /** @class */ (function () {
|
||||
function Slot() {
|
||||
// If you have a Slot object, you can find out its slot.id, but you cannot
|
||||
// guess the slot.id of a Slot you don't have access to, thanks to the
|
||||
// randomized suffix.
|
||||
this.id = [
|
||||
"slot",
|
||||
idCounter++,
|
||||
Date.now(),
|
||||
Math.random().toString(36).slice(2),
|
||||
].join(":");
|
||||
}
|
||||
Slot.prototype.hasValue = function () {
|
||||
for (var context_1 = currentContext; context_1; context_1 = context_1.parent) {
|
||||
// We use the Slot object iself as a key to its value, which means the
|
||||
// value cannot be obtained without a reference to the Slot object.
|
||||
if (this.id in context_1.slots) {
|
||||
var value = context_1.slots[this.id];
|
||||
if (value === MISSING_VALUE)
|
||||
break;
|
||||
if (context_1 !== currentContext) {
|
||||
// Cache the value in currentContext.slots so the next lookup will
|
||||
// be faster. This caching is safe because the tree of contexts and
|
||||
// the values of the slots are logically immutable.
|
||||
currentContext.slots[this.id] = value;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (currentContext) {
|
||||
// If a value was not found for this Slot, it's never going to be found
|
||||
// no matter how many times we look it up, so we might as well cache
|
||||
// the absence of the value, too.
|
||||
currentContext.slots[this.id] = MISSING_VALUE;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
Slot.prototype.getValue = function () {
|
||||
if (this.hasValue()) {
|
||||
return currentContext.slots[this.id];
|
||||
}
|
||||
};
|
||||
Slot.prototype.withValue = function (value, callback,
|
||||
// Given the prevalence of arrow functions, specifying arguments is likely
|
||||
// to be much more common than specifying `this`, hence this ordering:
|
||||
args, thisArg) {
|
||||
var _a;
|
||||
var slots = (_a = {
|
||||
__proto__: null
|
||||
},
|
||||
_a[this.id] = value,
|
||||
_a);
|
||||
var parent = currentContext;
|
||||
currentContext = { parent: parent, slots: slots };
|
||||
try {
|
||||
// Function.prototype.apply allows the arguments array argument to be
|
||||
// omitted or undefined, so args! is fine here.
|
||||
return callback.apply(thisArg, args);
|
||||
}
|
||||
finally {
|
||||
currentContext = parent;
|
||||
}
|
||||
};
|
||||
// Capture the current context and wrap a callback function so that it
|
||||
// reestablishes the captured context when called.
|
||||
Slot.bind = function (callback) {
|
||||
var context = currentContext;
|
||||
return function () {
|
||||
var saved = currentContext;
|
||||
try {
|
||||
currentContext = context;
|
||||
return callback.apply(this, arguments);
|
||||
}
|
||||
finally {
|
||||
currentContext = saved;
|
||||
}
|
||||
};
|
||||
};
|
||||
// Immediately run a callback function without any captured context.
|
||||
Slot.noContext = function (callback,
|
||||
// Given the prevalence of arrow functions, specifying arguments is likely
|
||||
// to be much more common than specifying `this`, hence this ordering:
|
||||
args, thisArg) {
|
||||
if (currentContext) {
|
||||
var saved = currentContext;
|
||||
try {
|
||||
currentContext = null;
|
||||
// Function.prototype.apply allows the arguments array argument to be
|
||||
// omitted or undefined, so args! is fine here.
|
||||
return callback.apply(thisArg, args);
|
||||
}
|
||||
finally {
|
||||
currentContext = saved;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return callback.apply(thisArg, args);
|
||||
}
|
||||
};
|
||||
return Slot;
|
||||
}()); };
|
||||
// We store a single global implementation of the Slot class as a permanent
|
||||
// non-enumerable symbol property of the Array constructor. This obfuscation
|
||||
// does nothing to prevent access to the Slot class, but at least it ensures
|
||||
// the implementation (i.e. currentContext) cannot be tampered with, and all
|
||||
// copies of the @wry/context package (hopefully just one) will share the
|
||||
// same Slot implementation. Since the first copy of the @wry/context package
|
||||
// to be imported wins, this technique imposes a very high cost for any
|
||||
// future breaking changes to the Slot class.
|
||||
var globalKey = "@wry/context:Slot";
|
||||
var host = Array;
|
||||
var Slot = host[globalKey] || function () {
|
||||
var Slot = makeSlotClass();
|
||||
try {
|
||||
Object.defineProperty(host, globalKey, {
|
||||
value: host[globalKey] = Slot,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
configurable: false,
|
||||
});
|
||||
}
|
||||
finally {
|
||||
return Slot;
|
||||
}
|
||||
}();
|
||||
|
||||
var bind = Slot.bind, noContext = Slot.noContext;
|
||||
function setTimeoutWithContext(callback, delay) {
|
||||
return setTimeout(bind(callback), delay);
|
||||
}
|
||||
// Turn any generator function into an async function (using yield instead
|
||||
// of await), with context automatically preserved across yields.
|
||||
function asyncFromGen(genFn) {
|
||||
return function () {
|
||||
var gen = genFn.apply(this, arguments);
|
||||
var boundNext = bind(gen.next);
|
||||
var boundThrow = bind(gen.throw);
|
||||
return new Promise(function (resolve, reject) {
|
||||
function invoke(method, argument) {
|
||||
try {
|
||||
var result = method.call(gen, argument);
|
||||
}
|
||||
catch (error) {
|
||||
return reject(error);
|
||||
}
|
||||
var next = result.done ? resolve : invokeNext;
|
||||
if (isPromiseLike(result.value)) {
|
||||
result.value.then(next, result.done ? reject : invokeThrow);
|
||||
}
|
||||
else {
|
||||
next(result.value);
|
||||
}
|
||||
}
|
||||
var invokeNext = function (value) { return invoke(boundNext, value); };
|
||||
var invokeThrow = function (error) { return invoke(boundThrow, error); };
|
||||
invokeNext();
|
||||
});
|
||||
};
|
||||
}
|
||||
function isPromiseLike(value) {
|
||||
return value && typeof value.then === "function";
|
||||
}
|
||||
// If you use the fibers npm package to implement coroutines in Node.js,
|
||||
// you should call this function at least once to ensure context management
|
||||
// remains coherent across any yields.
|
||||
var wrappedFibers = [];
|
||||
function wrapYieldingFiberMethods(Fiber) {
|
||||
// There can be only one implementation of Fiber per process, so this array
|
||||
// should never grow longer than one element.
|
||||
if (wrappedFibers.indexOf(Fiber) < 0) {
|
||||
var wrap = function (obj, method) {
|
||||
var fn = obj[method];
|
||||
obj[method] = function () {
|
||||
return noContext(fn, arguments, this);
|
||||
};
|
||||
};
|
||||
// These methods can yield, according to
|
||||
// https://github.com/laverdet/node-fibers/blob/ddebed9b8ae3883e57f822e2108e6943e5c8d2a8/fibers.js#L97-L100
|
||||
wrap(Fiber, "yield");
|
||||
wrap(Fiber.prototype, "run");
|
||||
wrap(Fiber.prototype, "throwInto");
|
||||
wrappedFibers.push(Fiber);
|
||||
}
|
||||
return Fiber;
|
||||
}
|
||||
|
||||
export { Slot, asyncFromGen, bind, noContext, setTimeoutWithContext as setTimeout, wrapYieldingFiberMethods };
|
||||
//# sourceMappingURL=context.esm.js.map
|
||||
1
node_modules/@wry/context/lib/context.esm.js.map
generated
vendored
Normal file
1
node_modules/@wry/context/lib/context.esm.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
207
node_modules/@wry/context/lib/context.js
generated
vendored
Normal file
207
node_modules/@wry/context/lib/context.js
generated
vendored
Normal file
@@ -0,0 +1,207 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
// This currentContext variable will only be used if the makeSlotClass
|
||||
// function is called, which happens only if this is the first copy of the
|
||||
// @wry/context package to be imported.
|
||||
var currentContext = null;
|
||||
// This unique internal object is used to denote the absence of a value
|
||||
// for a given Slot, and is never exposed to outside code.
|
||||
var MISSING_VALUE = {};
|
||||
var idCounter = 1;
|
||||
// Although we can't do anything about the cost of duplicated code from
|
||||
// accidentally bundling multiple copies of the @wry/context package, we can
|
||||
// avoid creating the Slot class more than once using makeSlotClass.
|
||||
var makeSlotClass = function () { return /** @class */ (function () {
|
||||
function Slot() {
|
||||
// If you have a Slot object, you can find out its slot.id, but you cannot
|
||||
// guess the slot.id of a Slot you don't have access to, thanks to the
|
||||
// randomized suffix.
|
||||
this.id = [
|
||||
"slot",
|
||||
idCounter++,
|
||||
Date.now(),
|
||||
Math.random().toString(36).slice(2),
|
||||
].join(":");
|
||||
}
|
||||
Slot.prototype.hasValue = function () {
|
||||
for (var context_1 = currentContext; context_1; context_1 = context_1.parent) {
|
||||
// We use the Slot object iself as a key to its value, which means the
|
||||
// value cannot be obtained without a reference to the Slot object.
|
||||
if (this.id in context_1.slots) {
|
||||
var value = context_1.slots[this.id];
|
||||
if (value === MISSING_VALUE)
|
||||
break;
|
||||
if (context_1 !== currentContext) {
|
||||
// Cache the value in currentContext.slots so the next lookup will
|
||||
// be faster. This caching is safe because the tree of contexts and
|
||||
// the values of the slots are logically immutable.
|
||||
currentContext.slots[this.id] = value;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (currentContext) {
|
||||
// If a value was not found for this Slot, it's never going to be found
|
||||
// no matter how many times we look it up, so we might as well cache
|
||||
// the absence of the value, too.
|
||||
currentContext.slots[this.id] = MISSING_VALUE;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
Slot.prototype.getValue = function () {
|
||||
if (this.hasValue()) {
|
||||
return currentContext.slots[this.id];
|
||||
}
|
||||
};
|
||||
Slot.prototype.withValue = function (value, callback,
|
||||
// Given the prevalence of arrow functions, specifying arguments is likely
|
||||
// to be much more common than specifying `this`, hence this ordering:
|
||||
args, thisArg) {
|
||||
var _a;
|
||||
var slots = (_a = {
|
||||
__proto__: null
|
||||
},
|
||||
_a[this.id] = value,
|
||||
_a);
|
||||
var parent = currentContext;
|
||||
currentContext = { parent: parent, slots: slots };
|
||||
try {
|
||||
// Function.prototype.apply allows the arguments array argument to be
|
||||
// omitted or undefined, so args! is fine here.
|
||||
return callback.apply(thisArg, args);
|
||||
}
|
||||
finally {
|
||||
currentContext = parent;
|
||||
}
|
||||
};
|
||||
// Capture the current context and wrap a callback function so that it
|
||||
// reestablishes the captured context when called.
|
||||
Slot.bind = function (callback) {
|
||||
var context = currentContext;
|
||||
return function () {
|
||||
var saved = currentContext;
|
||||
try {
|
||||
currentContext = context;
|
||||
return callback.apply(this, arguments);
|
||||
}
|
||||
finally {
|
||||
currentContext = saved;
|
||||
}
|
||||
};
|
||||
};
|
||||
// Immediately run a callback function without any captured context.
|
||||
Slot.noContext = function (callback,
|
||||
// Given the prevalence of arrow functions, specifying arguments is likely
|
||||
// to be much more common than specifying `this`, hence this ordering:
|
||||
args, thisArg) {
|
||||
if (currentContext) {
|
||||
var saved = currentContext;
|
||||
try {
|
||||
currentContext = null;
|
||||
// Function.prototype.apply allows the arguments array argument to be
|
||||
// omitted or undefined, so args! is fine here.
|
||||
return callback.apply(thisArg, args);
|
||||
}
|
||||
finally {
|
||||
currentContext = saved;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return callback.apply(thisArg, args);
|
||||
}
|
||||
};
|
||||
return Slot;
|
||||
}()); };
|
||||
// We store a single global implementation of the Slot class as a permanent
|
||||
// non-enumerable symbol property of the Array constructor. This obfuscation
|
||||
// does nothing to prevent access to the Slot class, but at least it ensures
|
||||
// the implementation (i.e. currentContext) cannot be tampered with, and all
|
||||
// copies of the @wry/context package (hopefully just one) will share the
|
||||
// same Slot implementation. Since the first copy of the @wry/context package
|
||||
// to be imported wins, this technique imposes a very high cost for any
|
||||
// future breaking changes to the Slot class.
|
||||
var globalKey = "@wry/context:Slot";
|
||||
var host = Array;
|
||||
var Slot = host[globalKey] || function () {
|
||||
var Slot = makeSlotClass();
|
||||
try {
|
||||
Object.defineProperty(host, globalKey, {
|
||||
value: host[globalKey] = Slot,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
configurable: false,
|
||||
});
|
||||
}
|
||||
finally {
|
||||
return Slot;
|
||||
}
|
||||
}();
|
||||
|
||||
var bind = Slot.bind, noContext = Slot.noContext;
|
||||
function setTimeoutWithContext(callback, delay) {
|
||||
return setTimeout(bind(callback), delay);
|
||||
}
|
||||
// Turn any generator function into an async function (using yield instead
|
||||
// of await), with context automatically preserved across yields.
|
||||
function asyncFromGen(genFn) {
|
||||
return function () {
|
||||
var gen = genFn.apply(this, arguments);
|
||||
var boundNext = bind(gen.next);
|
||||
var boundThrow = bind(gen.throw);
|
||||
return new Promise(function (resolve, reject) {
|
||||
function invoke(method, argument) {
|
||||
try {
|
||||
var result = method.call(gen, argument);
|
||||
}
|
||||
catch (error) {
|
||||
return reject(error);
|
||||
}
|
||||
var next = result.done ? resolve : invokeNext;
|
||||
if (isPromiseLike(result.value)) {
|
||||
result.value.then(next, result.done ? reject : invokeThrow);
|
||||
}
|
||||
else {
|
||||
next(result.value);
|
||||
}
|
||||
}
|
||||
var invokeNext = function (value) { return invoke(boundNext, value); };
|
||||
var invokeThrow = function (error) { return invoke(boundThrow, error); };
|
||||
invokeNext();
|
||||
});
|
||||
};
|
||||
}
|
||||
function isPromiseLike(value) {
|
||||
return value && typeof value.then === "function";
|
||||
}
|
||||
// If you use the fibers npm package to implement coroutines in Node.js,
|
||||
// you should call this function at least once to ensure context management
|
||||
// remains coherent across any yields.
|
||||
var wrappedFibers = [];
|
||||
function wrapYieldingFiberMethods(Fiber) {
|
||||
// There can be only one implementation of Fiber per process, so this array
|
||||
// should never grow longer than one element.
|
||||
if (wrappedFibers.indexOf(Fiber) < 0) {
|
||||
var wrap = function (obj, method) {
|
||||
var fn = obj[method];
|
||||
obj[method] = function () {
|
||||
return noContext(fn, arguments, this);
|
||||
};
|
||||
};
|
||||
// These methods can yield, according to
|
||||
// https://github.com/laverdet/node-fibers/blob/ddebed9b8ae3883e57f822e2108e6943e5c8d2a8/fibers.js#L97-L100
|
||||
wrap(Fiber, "yield");
|
||||
wrap(Fiber.prototype, "run");
|
||||
wrap(Fiber.prototype, "throwInto");
|
||||
wrappedFibers.push(Fiber);
|
||||
}
|
||||
return Fiber;
|
||||
}
|
||||
|
||||
exports.Slot = Slot;
|
||||
exports.asyncFromGen = asyncFromGen;
|
||||
exports.bind = bind;
|
||||
exports.noContext = noContext;
|
||||
exports.setTimeout = setTimeoutWithContext;
|
||||
exports.wrapYieldingFiberMethods = wrapYieldingFiberMethods;
|
||||
1
node_modules/@wry/context/lib/context.js.map
generated
vendored
Normal file
1
node_modules/@wry/context/lib/context.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AACrB,eADA,WAAI,CACA;AACE,QAAA,IAAI,GAAgB,WAAI,OAAlB,QAAA,SAAS,GAAK,WAAI,WAAC;AAIxC,SAAS,qBAAqB,CAAC,QAAmB,EAAE,KAAa;IAC/D,OAAO,UAAU,CAAC,YAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC;AAC3C,CAAC;AAHiC,2CAAU;AAK5C,0EAA0E;AAC1E,iEAAiE;AACjE,SAAgB,YAAY,CAC1B,KAAoD;IAEpD,OAAO;QACL,IAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,SAAgB,CAAC,CAAC;QAChD,IAAM,SAAS,GAAG,YAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACjC,IAAM,UAAU,GAAG,YAAI,CAAC,GAAG,CAAC,KAAM,CAAC,CAAC;QAGpC,OAAO,IAAI,OAAO,CAAU,UAAC,OAAO,EAAE,MAAM;YAC1C,SAAS,MAAM,CAAC,MAAc,EAAE,QAAa;gBAC3C,IAAI;oBACF,IAAI,MAAM,GAAG,MAAM,CAAC,I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,CAAC,MAAM,CAAC,GAAG;gBACZ,OAAO,iBAAS,CAAC,EAAE,EAAE,SAAgB,EAAE,IAAI,CAAC,CAAC;YAC/C,CAAC,CAAC;QACJ,CAAC,CAAA;QACD,wCAAwC;QACxC,2GAA2G;QAC3G,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACrB,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAC7B,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QACnC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KAC3B;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAlBD,4DAkBC"}
|
||||
12
node_modules/@wry/context/lib/slot.d.ts
generated
vendored
Normal file
12
node_modules/@wry/context/lib/slot.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
declare const makeSlotClass: () => {
|
||||
new <TValue>(): {
|
||||
readonly id: string;
|
||||
hasValue(): boolean;
|
||||
getValue(): TValue | undefined;
|
||||
withValue<TResult, TArgs extends any[], TThis = any>(value: TValue, callback: (this: TThis, ...args: TArgs) => TResult, args?: TArgs | undefined, thisArg?: TThis | undefined): TResult;
|
||||
};
|
||||
bind<TArgs extends any[], TResult>(callback: (...args: TArgs) => TResult): (...args: TArgs) => TResult;
|
||||
noContext<TResult, TArgs extends any[], TThis = any>(callback: (this: TThis, ...args: TArgs) => TResult, args?: TArgs | undefined, thisArg?: TThis | undefined): TResult;
|
||||
};
|
||||
export declare const Slot: ReturnType<typeof makeSlotClass>;
|
||||
export {};
|
||||
139
node_modules/@wry/context/lib/slot.js
generated
vendored
Normal file
139
node_modules/@wry/context/lib/slot.js
generated
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// This currentContext variable will only be used if the makeSlotClass
|
||||
// function is called, which happens only if this is the first copy of the
|
||||
// @wry/context package to be imported.
|
||||
var currentContext = null;
|
||||
// This unique internal object is used to denote the absence of a value
|
||||
// for a given Slot, and is never exposed to outside code.
|
||||
var MISSING_VALUE = {};
|
||||
var idCounter = 1;
|
||||
// Although we can't do anything about the cost of duplicated code from
|
||||
// accidentally bundling multiple copies of the @wry/context package, we can
|
||||
// avoid creating the Slot class more than once using makeSlotClass.
|
||||
var makeSlotClass = function () { return /** @class */ (function () {
|
||||
function Slot() {
|
||||
// If you have a Slot object, you can find out its slot.id, but you cannot
|
||||
// guess the slot.id of a Slot you don't have access to, thanks to the
|
||||
// randomized suffix.
|
||||
this.id = [
|
||||
"slot",
|
||||
idCounter++,
|
||||
Date.now(),
|
||||
Math.random().toString(36).slice(2),
|
||||
].join(":");
|
||||
}
|
||||
Slot.prototype.hasValue = function () {
|
||||
for (var context_1 = currentContext; context_1; context_1 = context_1.parent) {
|
||||
// We use the Slot object iself as a key to its value, which means the
|
||||
// value cannot be obtained without a reference to the Slot object.
|
||||
if (this.id in context_1.slots) {
|
||||
var value = context_1.slots[this.id];
|
||||
if (value === MISSING_VALUE)
|
||||
break;
|
||||
if (context_1 !== currentContext) {
|
||||
// Cache the value in currentContext.slots so the next lookup will
|
||||
// be faster. This caching is safe because the tree of contexts and
|
||||
// the values of the slots are logically immutable.
|
||||
currentContext.slots[this.id] = value;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (currentContext) {
|
||||
// If a value was not found for this Slot, it's never going to be found
|
||||
// no matter how many times we look it up, so we might as well cache
|
||||
// the absence of the value, too.
|
||||
currentContext.slots[this.id] = MISSING_VALUE;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
Slot.prototype.getValue = function () {
|
||||
if (this.hasValue()) {
|
||||
return currentContext.slots[this.id];
|
||||
}
|
||||
};
|
||||
Slot.prototype.withValue = function (value, callback,
|
||||
// Given the prevalence of arrow functions, specifying arguments is likely
|
||||
// to be much more common than specifying `this`, hence this ordering:
|
||||
args, thisArg) {
|
||||
var _a;
|
||||
var slots = (_a = {
|
||||
__proto__: null
|
||||
},
|
||||
_a[this.id] = value,
|
||||
_a);
|
||||
var parent = currentContext;
|
||||
currentContext = { parent: parent, slots: slots };
|
||||
try {
|
||||
// Function.prototype.apply allows the arguments array argument to be
|
||||
// omitted or undefined, so args! is fine here.
|
||||
return callback.apply(thisArg, args);
|
||||
}
|
||||
finally {
|
||||
currentContext = parent;
|
||||
}
|
||||
};
|
||||
// Capture the current context and wrap a callback function so that it
|
||||
// reestablishes the captured context when called.
|
||||
Slot.bind = function (callback) {
|
||||
var context = currentContext;
|
||||
return function () {
|
||||
var saved = currentContext;
|
||||
try {
|
||||
currentContext = context;
|
||||
return callback.apply(this, arguments);
|
||||
}
|
||||
finally {
|
||||
currentContext = saved;
|
||||
}
|
||||
};
|
||||
};
|
||||
// Immediately run a callback function without any captured context.
|
||||
Slot.noContext = function (callback,
|
||||
// Given the prevalence of arrow functions, specifying arguments is likely
|
||||
// to be much more common than specifying `this`, hence this ordering:
|
||||
args, thisArg) {
|
||||
if (currentContext) {
|
||||
var saved = currentContext;
|
||||
try {
|
||||
currentContext = null;
|
||||
// Function.prototype.apply allows the arguments array argument to be
|
||||
// omitted or undefined, so args! is fine here.
|
||||
return callback.apply(thisArg, args);
|
||||
}
|
||||
finally {
|
||||
currentContext = saved;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return callback.apply(thisArg, args);
|
||||
}
|
||||
};
|
||||
return Slot;
|
||||
}()); };
|
||||
// We store a single global implementation of the Slot class as a permanent
|
||||
// non-enumerable symbol property of the Array constructor. This obfuscation
|
||||
// does nothing to prevent access to the Slot class, but at least it ensures
|
||||
// the implementation (i.e. currentContext) cannot be tampered with, and all
|
||||
// copies of the @wry/context package (hopefully just one) will share the
|
||||
// same Slot implementation. Since the first copy of the @wry/context package
|
||||
// to be imported wins, this technique imposes a very high cost for any
|
||||
// future breaking changes to the Slot class.
|
||||
var globalKey = "@wry/context:Slot";
|
||||
var host = Array;
|
||||
exports.Slot = host[globalKey] || function () {
|
||||
var Slot = makeSlotClass();
|
||||
try {
|
||||
Object.defineProperty(host, globalKey, {
|
||||
value: host[globalKey] = Slot,
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
configurable: false,
|
||||
});
|
||||
}
|
||||
finally {
|
||||
return Slot;
|
||||
}
|
||||
}();
|
||||
//# sourceMappingURL=slot.js.map
|
||||
1
node_modules/@wry/context/lib/slot.js.map
generated
vendored
Normal file
1
node_modules/@wry/context/lib/slot.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"slot.js","sourceRoot":"","sources":["../src/slot.ts"],"names":[],"mappings":";;AAKA,sEAAsE;AACtE,0EAA0E;AAC1E,uCAAuC;AACvC,IAAI,cAAc,GAAmB,IAAI,CAAC;AAE1C,uEAAuE;AACvE,0DAA0D;AAC1D,IAAM,aAAa,GAAQ,EAAE,CAAC;AAE9B,IAAI,SAAS,GAAG,CAAC,CAAC;AAElB,uEAAuE;AACvE,4EAA4E;AAC5E,oEAAoE;AACpE,IAAM,aAAa,GAAG,cAAM;IAAA;QAC1B,0EAA0E;QAC1E,sEAAsE;QACtE,qBAAqB;QACL,OAAE,GAAG;YACnB,MAAM;YACN,SAAS,EAAE;YACX,IAAI,CAAC,GAAG,EAAE;YACV,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;SACpC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IA+Fd,CAAC;IA7FQ,uBAAQ,GAAf;QACE,KAAK,IAAI,SAAO,GAAG,cAAc,EAAE,SAAO,EAAE,SAAO,GAAG,SAAO,CAAC,MAAM,EAAE;YACpE,sEAAsE;YACtE,mEAAmE;YACnE,IAAI,IAAI,CAAC,EAAE,IAAI,SAAO,CAAC,KAAK,EAAE;gBAC5B,IAAM,KAAK,GAAG,SAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACrC,IAAI,KAAK,KAAK,aAAa;oB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/context/package.json
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "@wry/context",
|
||||
"version": "0.4.4",
|
||||
"author": "Ben Newman <ben@eloper.dev>",
|
||||
"description": "Manage contextual information needed by (a)synchronous tasks without explicitly passing objects around",
|
||||
"license": "MIT",
|
||||
"main": "lib/context.js",
|
||||
"module": "lib/context.esm.js",
|
||||
"types": "lib/context.d.ts",
|
||||
"keywords": [],
|
||||
"homepage": "https://github.com/benjamn/wryware",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/benjamn/wryware.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/benjamn/wryware/issues"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "../../node_modules/.bin/rimraf lib",
|
||||
"tsc": "../../node_modules/.bin/tsc",
|
||||
"rollup": "../../node_modules/.bin/rollup -c",
|
||||
"build": "npm run clean && npm run tsc && npm run rollup",
|
||||
"mocha": "../../scripts/test.sh lib/tests.js",
|
||||
"prepublish": "npm run build",
|
||||
"test": "npm run build && npm run mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/node": ">=6",
|
||||
"tslib": "^1.9.3"
|
||||
},
|
||||
"gitHead": "50e7d6181b0b937ad54b543118e823ad98e2bca9"
|
||||
}
|
||||
40
node_modules/@wry/context/rollup.config.js
generated
vendored
Normal file
40
node_modules/@wry/context/rollup.config.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
import typescriptPlugin from 'rollup-plugin-typescript2';
|
||||
import typescript from 'typescript';
|
||||
|
||||
const globals = {
|
||||
__proto__: null,
|
||||
tslib: "tslib",
|
||||
};
|
||||
|
||||
function external(id) {
|
||||
return id in globals;
|
||||
}
|
||||
|
||||
export default [{
|
||||
input: "src/context.ts",
|
||||
external,
|
||||
output: {
|
||||
file: "lib/context.esm.js",
|
||||
format: "esm",
|
||||
sourcemap: true,
|
||||
globals,
|
||||
},
|
||||
plugins: [
|
||||
typescriptPlugin({
|
||||
typescript,
|
||||
tsconfig: "./tsconfig.rollup.json",
|
||||
}),
|
||||
],
|
||||
}, {
|
||||
input: "lib/context.esm.js",
|
||||
external,
|
||||
output: {
|
||||
// Intentionally overwrite the context.js file written by tsc:
|
||||
file: "lib/context.js",
|
||||
format: "cjs",
|
||||
exports: "named",
|
||||
sourceMap: true,
|
||||
name: "context",
|
||||
globals,
|
||||
},
|
||||
}];
|
||||
7
node_modules/@wry/context/tsconfig.json
generated
vendored
Normal file
7
node_modules/@wry/context/tsconfig.json
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "./src",
|
||||
"outDir": "./lib"
|
||||
}
|
||||
}
|
||||
6
node_modules/@wry/context/tsconfig.rollup.json
generated
vendored
Normal file
6
node_modules/@wry/context/tsconfig.rollup.json
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"module": "es2015",
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user