Initial Sample.

This commit is contained in:
2024-06-03 20:23:50 +05:30
parent ef2b65f673
commit 5269ec3c66
2575 changed files with 282312 additions and 0 deletions

21
graphql-subscription/node_modules/ts-invariant/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Apollo GraphQL
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.

View File

@@ -0,0 +1,19 @@
# ts-invariant
[TypeScript](https://www.typescriptlang.org) implementation of
[`invariant(condition, message)`](https://www.npmjs.com/package/invariant).
Supports `invariant.log`, `invariant.warn`, and `invariant.error`, which
wrap `console` methods of the same name, and may be stripped in production
by [`rollup-plugin-invariant`](../../archived/rollup-plugin-invariant).
The verbosity of these methods can be globally reconfigured using the
`setVerbosity` function:
```ts
import { setVerbosity } from "ts-invariant";
setVerbosity("log"); // display all messages (default)
setVerbosity("warn"); // display only warnings and errors
setVerbosity("error"); // display only errors
setVerbosity("silent"); // display no messages
```

View File

@@ -0,0 +1,60 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var tslib = require('tslib');
var genericMessage = "Invariant Violation";
var _a = Object.setPrototypeOf, setPrototypeOf = _a === void 0 ? function (obj, proto) {
obj.__proto__ = proto;
return obj;
} : _a;
var InvariantError = /** @class */ (function (_super) {
tslib.__extends(InvariantError, _super);
function InvariantError(message) {
if (message === void 0) { message = genericMessage; }
var _this = _super.call(this, typeof message === "number"
? genericMessage + ": " + message + " (see https://github.com/apollographql/invariant-packages)"
: message) || this;
_this.framesToPop = 1;
_this.name = genericMessage;
setPrototypeOf(_this, InvariantError.prototype);
return _this;
}
return InvariantError;
}(Error));
function invariant(condition, message) {
if (!condition) {
throw new InvariantError(message);
}
}
var verbosityLevels = ["debug", "log", "warn", "error", "silent"];
var verbosityLevel = verbosityLevels.indexOf("log");
function wrapConsoleMethod(name) {
return function () {
if (verbosityLevels.indexOf(name) >= verbosityLevel) {
// Default to console.log if this host environment happens not to provide
// all the console.* methods we need.
var method = console[name] || console.log;
return method.apply(console, arguments);
}
};
}
(function (invariant) {
invariant.debug = wrapConsoleMethod("debug");
invariant.log = wrapConsoleMethod("log");
invariant.warn = wrapConsoleMethod("warn");
invariant.error = wrapConsoleMethod("error");
})(invariant || (invariant = {}));
function setVerbosity(level) {
var old = verbosityLevels[verbosityLevel];
verbosityLevel = Math.max(0, verbosityLevels.indexOf(level));
return old;
}
var invariant$1 = invariant;
exports.InvariantError = InvariantError;
exports["default"] = invariant$1;
exports.invariant = invariant;
exports.setVerbosity = setVerbosity;
//# sourceMappingURL=invariant.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"invariant.cjs","sources":["invariant.js"],"sourcesContent":["import { __extends } from \"tslib\";\nvar genericMessage = \"Invariant Violation\";\nvar _a = Object.setPrototypeOf, setPrototypeOf = _a === void 0 ? function (obj, proto) {\n obj.__proto__ = proto;\n return obj;\n} : _a;\nvar InvariantError = /** @class */ (function (_super) {\n __extends(InvariantError, _super);\n function InvariantError(message) {\n if (message === void 0) { message = genericMessage; }\n var _this = _super.call(this, typeof message === \"number\"\n ? genericMessage + \": \" + message + \" (see https://github.com/apollographql/invariant-packages)\"\n : message) || this;\n _this.framesToPop = 1;\n _this.name = genericMessage;\n setPrototypeOf(_this, InvariantError.prototype);\n return _this;\n }\n return InvariantError;\n}(Error));\nexport { InvariantError };\nexport function invariant(condition, message) {\n if (!condition) {\n throw new InvariantError(message);\n }\n}\nvar verbosityLevels = [\"debug\", \"log\", \"warn\", \"error\", \"silent\"];\nvar verbosityLevel = verbosityLevels.indexOf(\"log\");\nfunction wrapConsoleMethod(name) {\n return function () {\n if (verbosityLevels.indexOf(name) >= verbosityLevel) {\n // Default to console.log if this host environment happens not to provide\n // all the console.* methods we need.\n var method = console[name] || console.log;\n return method.apply(console, arguments);\n }\n };\n}\n(function (invariant) {\n invariant.debug = wrapConsoleMethod(\"debug\");\n invariant.log = wrapConsoleMethod(\"log\");\n invariant.warn = wrapConsoleMethod(\"warn\");\n invariant.error = wrapConsoleMethod(\"error\");\n})(invariant || (invariant = {}));\nexport function setVerbosity(level) {\n var old = verbosityLevels[verbosityLevel];\n verbosityLevel = Math.max(0, verbosityLevels.indexOf(level));\n return old;\n}\nexport default invariant;\n//# sourceMappingURL=invariant.js.map"],"names":["__extends"],"mappings":";;;;;;AACA,IAAI,cAAc,GAAG,qBAAqB,CAAC;AAC3C,IAAI,EAAE,GAAG,MAAM,CAAC,cAAc,EAAE,cAAc,GAAG,EAAE,KAAK,KAAK,CAAC,GAAG,UAAU,GAAG,EAAE,KAAK,EAAE;AACvF,IAAI,GAAG,CAAC,SAAS,GAAG,KAAK,CAAC;AAC1B,IAAI,OAAO,GAAG,CAAC;AACf,CAAC,GAAG,EAAE,CAAC;AACJ,IAAC,cAAc,kBAAkB,UAAU,MAAM,EAAE;AACtD,IAAIA,eAAS,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AACtC,IAAI,SAAS,cAAc,CAAC,OAAO,EAAE;AACrC,QAAQ,IAAI,OAAO,KAAK,KAAK,CAAC,EAAE,EAAE,OAAO,GAAG,cAAc,CAAC,EAAE;AAC7D,QAAQ,IAAI,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,OAAO,KAAK,QAAQ;AACjE,cAAc,cAAc,GAAG,IAAI,GAAG,OAAO,GAAG,4DAA4D;AAC5G,cAAc,OAAO,CAAC,IAAI,IAAI,CAAC;AAC/B,QAAQ,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC;AAC9B,QAAQ,KAAK,CAAC,IAAI,GAAG,cAAc,CAAC;AACpC,QAAQ,cAAc,CAAC,KAAK,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;AACxD,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,OAAO,cAAc,CAAC;AAC1B,CAAC,CAAC,KAAK,CAAC,EAAE;AAEH,SAAS,SAAS,CAAC,SAAS,EAAE,OAAO,EAAE;AAC9C,IAAI,IAAI,CAAC,SAAS,EAAE;AACpB,QAAQ,MAAM,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;AAC1C,KAAK;AACL,CAAC;AACD,IAAI,eAAe,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAClE,IAAI,cAAc,GAAG,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACpD,SAAS,iBAAiB,CAAC,IAAI,EAAE;AACjC,IAAI,OAAO,YAAY;AACvB,QAAQ,IAAI,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,cAAc,EAAE;AAC7D;AACA;AACA,YAAY,IAAI,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC;AACtD,YAAY,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AACpD,SAAS;AACT,KAAK,CAAC;AACN,CAAC;AACD,CAAC,UAAU,SAAS,EAAE;AACtB,IAAI,SAAS,CAAC,KAAK,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;AACjD,IAAI,SAAS,CAAC,GAAG,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;AAC7C,IAAI,SAAS,CAAC,IAAI,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAC/C,IAAI,SAAS,CAAC,KAAK,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;AACjD,CAAC,EAAE,SAAS,KAAK,SAAS,GAAG,EAAE,CAAC,CAAC,CAAC;AAC3B,SAAS,YAAY,CAAC,KAAK,EAAE;AACpC,IAAI,IAAI,GAAG,GAAG,eAAe,CAAC,cAAc,CAAC,CAAC;AAC9C,IAAI,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AACjE,IAAI,OAAO,GAAG,CAAC;AACf,CAAC;AACD,kBAAe,SAAS;;;;;;;"}

View File

@@ -0,0 +1,60 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var tslib = require('tslib');
var genericMessage = "Invariant Violation";
var _a = Object.setPrototypeOf, setPrototypeOf = _a === void 0 ? function (obj, proto) {
obj.__proto__ = proto;
return obj;
} : _a;
var InvariantError = /** @class */ (function (_super) {
tslib.__extends(InvariantError, _super);
function InvariantError(message) {
if (message === void 0) { message = genericMessage; }
var _this = _super.call(this, typeof message === "number"
? genericMessage + ": " + message + " (see https://github.com/apollographql/invariant-packages)"
: message) || this;
_this.framesToPop = 1;
_this.name = genericMessage;
setPrototypeOf(_this, InvariantError.prototype);
return _this;
}
return InvariantError;
}(Error));
function invariant(condition, message) {
if (!condition) {
throw new InvariantError(message);
}
}
var verbosityLevels = ["debug", "log", "warn", "error", "silent"];
var verbosityLevel = verbosityLevels.indexOf("log");
function wrapConsoleMethod(name) {
return function () {
if (verbosityLevels.indexOf(name) >= verbosityLevel) {
// Default to console.log if this host environment happens not to provide
// all the console.* methods we need.
var method = console[name] || console.log;
return method.apply(console, arguments);
}
};
}
(function (invariant) {
invariant.debug = wrapConsoleMethod("debug");
invariant.log = wrapConsoleMethod("log");
invariant.warn = wrapConsoleMethod("warn");
invariant.error = wrapConsoleMethod("error");
})(invariant || (invariant = {}));
function setVerbosity(level) {
var old = verbosityLevels[verbosityLevel];
verbosityLevel = Math.max(0, verbosityLevels.indexOf(level));
return old;
}
var invariant$1 = invariant;
exports.InvariantError = InvariantError;
exports["default"] = invariant$1;
exports.invariant = invariant;
exports.setVerbosity = setVerbosity;
//# sourceMappingURL=invariant.cjs.map

View File

@@ -0,0 +1,29 @@
export declare class InvariantError extends Error {
framesToPop: number;
name: string;
constructor(message?: string | number);
}
export declare function invariant(condition: any, message?: string | number): asserts condition;
declare const verbosityLevels: readonly ["debug", "log", "warn", "error", "silent"];
export declare type VerbosityLevel = (typeof verbosityLevels)[number];
export declare type ConsoleMethodName = Exclude<VerbosityLevel, "silent">;
export declare namespace invariant {
const debug: {
(...data: any[]): void;
(message?: any, ...optionalParams: any[]): void;
};
const log: {
(...data: any[]): void;
(message?: any, ...optionalParams: any[]): void;
};
const warn: {
(...data: any[]): void;
(message?: any, ...optionalParams: any[]): void;
};
const error: {
(...data: any[]): void;
(message?: any, ...optionalParams: any[]): void;
};
}
export declare function setVerbosity(level: VerbosityLevel): VerbosityLevel;
export default invariant;

View File

@@ -0,0 +1,51 @@
import { __extends } from "tslib";
var genericMessage = "Invariant Violation";
var _a = Object.setPrototypeOf, setPrototypeOf = _a === void 0 ? function (obj, proto) {
obj.__proto__ = proto;
return obj;
} : _a;
var InvariantError = /** @class */ (function (_super) {
__extends(InvariantError, _super);
function InvariantError(message) {
if (message === void 0) { message = genericMessage; }
var _this = _super.call(this, typeof message === "number"
? genericMessage + ": " + message + " (see https://github.com/apollographql/invariant-packages)"
: message) || this;
_this.framesToPop = 1;
_this.name = genericMessage;
setPrototypeOf(_this, InvariantError.prototype);
return _this;
}
return InvariantError;
}(Error));
export { InvariantError };
export function invariant(condition, message) {
if (!condition) {
throw new InvariantError(message);
}
}
var verbosityLevels = ["debug", "log", "warn", "error", "silent"];
var verbosityLevel = verbosityLevels.indexOf("log");
function wrapConsoleMethod(name) {
return function () {
if (verbosityLevels.indexOf(name) >= verbosityLevel) {
// Default to console.log if this host environment happens not to provide
// all the console.* methods we need.
var method = console[name] || console.log;
return method.apply(console, arguments);
}
};
}
(function (invariant) {
invariant.debug = wrapConsoleMethod("debug");
invariant.log = wrapConsoleMethod("log");
invariant.warn = wrapConsoleMethod("warn");
invariant.error = wrapConsoleMethod("error");
})(invariant || (invariant = {}));
export function setVerbosity(level) {
var old = verbosityLevels[verbosityLevel];
verbosityLevel = Math.max(0, verbosityLevels.indexOf(level));
return old;
}
export default invariant;
//# sourceMappingURL=invariant.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"invariant.js","sourceRoot":"","sources":["../src/invariant.ts"],"names":[],"mappings":";AAAA,IAAM,cAAc,GAAG,qBAAqB,CAAC;AAE3C,IAAA,KAIE,MAAa,eADd,EAHD,cAAc,mBAAG,UAAU,GAAQ,EAAE,KAAU;IAC7C,GAAG,CAAC,SAAS,GAAG,KAAK,CAAC;IACtB,OAAO,GAAG,CAAC;AACb,CAAC,KAAA,CACe;AAElB;IAAoC,kCAAK;IAGvC,wBAAY,OAAyC;QAAzC,wBAAA,EAAA,wBAAyC;QAArD,YACE,kBACE,OAAO,OAAO,KAAK,QAAQ;YACzB,CAAC,CAAI,cAAc,UAAK,OAAO,+DAA4D;YAC3F,CAAC,CAAC,OAAO,CACZ,SAEF;QATD,iBAAW,GAAG,CAAC,CAAC;QAChB,UAAI,GAAG,cAAc,CAAC;QAOpB,cAAc,CAAC,KAAI,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;;IACjD,CAAC;IACH,qBAAC;AAAD,CAAC,AAXD,CAAoC,KAAK,GAWxC;;AAED,MAAM,UAAU,SAAS,CACvB,SAAc,EACd,OAAyB;IAEzB,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;KACnC;AACH,CAAC;AAED,IAAM,eAAe,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC;AAG7E,IAAI,cAAc,GAAG,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAEpD,SAAS,iBAAiB,CAA8B,IAAO;IAC7D,OAAO;QACL,IAAI,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,cAAc,EAAE;YACnD,yEAAyE;YACzE,qCAAqC;YACrC,IAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC;YAC5C,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,SAAgB,CAAC,CAAC;SAChD;IACH,CAAwB,CAAC;AAC3B,CAAC;AAED,WAAiB,SAAS;IACX,eAAK,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACnC,aAAG,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC/B,cAAI,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACjC,eAAK,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;AAClD,CAAC,EALgB,SAAS,KAAT,SAAS,QAKzB;AAED,MAAM,UAAU,YAAY,CAAC,KAAqB;IAChD,IAAM,GAAG,GAAG,eAAe,CAAC,cAAc,CAAC,CAAC;IAC5C,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7D,OAAO,GAAG,CAAC;AACb,CAAC;AAED,eAAe,SAAS,CAAC","sourcesContent":["const genericMessage = \"Invariant Violation\";\nconst {\n setPrototypeOf = function (obj: any, proto: any) {\n obj.__proto__ = proto;\n return obj;\n },\n} = Object as any;\n\nexport class InvariantError extends Error {\n framesToPop = 1;\n name = genericMessage;\n constructor(message: string | number = genericMessage) {\n super(\n typeof message === \"number\"\n ? `${genericMessage}: ${message} (see https://github.com/apollographql/invariant-packages)`\n : message\n );\n setPrototypeOf(this, InvariantError.prototype);\n }\n}\n\nexport function invariant(\n condition: any,\n message?: string | number,\n): asserts condition {\n if (!condition) {\n throw new InvariantError(message);\n }\n}\n\nconst verbosityLevels = [\"debug\", \"log\", \"warn\", \"error\", \"silent\"] as const;\nexport type VerbosityLevel = (typeof verbosityLevels)[number];\nexport type ConsoleMethodName = Exclude<VerbosityLevel, \"silent\">;\nlet verbosityLevel = verbosityLevels.indexOf(\"log\");\n\nfunction wrapConsoleMethod<M extends ConsoleMethodName>(name: M) {\n return function () {\n if (verbosityLevels.indexOf(name) >= verbosityLevel) {\n // Default to console.log if this host environment happens not to provide\n // all the console.* methods we need.\n const method = console[name] || console.log;\n return method.apply(console, arguments as any);\n }\n } as (typeof console)[M];\n}\n\nexport namespace invariant {\n export const debug = wrapConsoleMethod(\"debug\");\n export const log = wrapConsoleMethod(\"log\");\n export const warn = wrapConsoleMethod(\"warn\");\n export const error = wrapConsoleMethod(\"error\");\n}\n\nexport function setVerbosity(level: VerbosityLevel): VerbosityLevel {\n const old = verbosityLevels[verbosityLevel];\n verbosityLevel = Math.max(0, verbosityLevels.indexOf(level));\n return old;\n}\n\nexport default invariant;\n"]}

View File

@@ -0,0 +1,47 @@
{
"name": "ts-invariant",
"version": "0.10.3",
"author": "Ben Newman <ben@apollographql.com>",
"description": "TypeScript implementation of invariant(condition, message)",
"license": "MIT",
"type": "module",
"main": "lib/invariant.cjs",
"module": "lib/invariant.js",
"types": "lib/invariant.d.ts",
"keywords": [
"invariant",
"assertion",
"precondition",
"TypeScript"
],
"homepage": "https://github.com/apollographql/invariant-packages",
"repository": {
"type": "git",
"url": "git+https://github.com/apollographql/invariant-packages.git"
},
"bugs": {
"url": "https://github.com/apollographql/invariant-packages/issues"
},
"scripts": {
"build": "npm run tsc && npm run rollup",
"tsc": "../../node_modules/.bin/tsc",
"rollup": "../../node_modules/.bin/rollup -c",
"prepare": "npm run build",
"mocha": "npm run mocha:esm && npm run mocha:cjs",
"mocha:esm": "../../node_modules/.bin/mocha --reporter spec --full-trace lib/tests.js",
"mocha:cjs": "../../node_modules/.bin/mocha --reporter spec --full-trace lib/tests.bundle.cjs",
"test": "npm run build && npm run mocha && npm run test:no-node",
"test:no-node": "! grep -i node lib/invariant.d.ts"
},
"dependencies": {
"tslib": "^2.1.0"
},
"devDependencies": {
"@types/invariant": "^2.2.29",
"invariant": "^2.2.4"
},
"engines": {
"node": ">=8"
},
"gitHead": "c8a2d6d2e839e9bdc595ae5fd2a50331b2b01014"
}

View File

@@ -0,0 +1,2 @@
export declare function install(): void;
export declare function remove(): void;

View File

@@ -0,0 +1,52 @@
function maybe(thunk) {
try { return thunk() } catch (_) {}
}
var safeGlobal = (
maybe(function() { return globalThis }) ||
maybe(function() { return window }) ||
maybe(function() { return self }) ||
maybe(function() { return global }) ||
// We don't expect the Function constructor ever to be invoked at runtime, as
// long as at least one of globalThis, window, self, or global is defined, so
// we are under no obligation to make it easy for static analysis tools to
// detect syntactic usage of the Function constructor. If you think you can
// improve your static analysis to detect this obfuscation, think again. This
// is an arms race you cannot win, at least not in JavaScript.
maybe(function() { return maybe.constructor("return this")() })
);
var needToRemove = false;
export function install() {
if (safeGlobal &&
!maybe(function() { return process.env.NODE_ENV }) &&
!maybe(function() { return process })) {
Object.defineProperty(safeGlobal, "process", {
value: {
env: {
// This default needs to be "production" instead of "development", to
// avoid the problem https://github.com/graphql/graphql-js/pull/2894
// will eventually solve, once merged and released.
NODE_ENV: "production",
},
},
// Let anyone else change global.process as they see fit, but hide it from
// Object.keys(global) enumeration.
configurable: true,
enumerable: false,
writable: true,
});
needToRemove = true;
}
}
// Call install() at least once, when this module is imported.
install();
export function remove() {
if (needToRemove) {
delete safeGlobal.process;
needToRemove = false;
}
}

View File

@@ -0,0 +1,60 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function maybe(thunk) {
try { return thunk() } catch (_) {}
}
var safeGlobal = (
maybe(function() { return globalThis }) ||
maybe(function() { return window }) ||
maybe(function() { return self }) ||
maybe(function() { return global }) ||
// We don't expect the Function constructor ever to be invoked at runtime, as
// long as at least one of globalThis, window, self, or global is defined, so
// we are under no obligation to make it easy for static analysis tools to
// detect syntactic usage of the Function constructor. If you think you can
// improve your static analysis to detect this obfuscation, think again. This
// is an arms race you cannot win, at least not in JavaScript.
maybe(function() { return maybe.constructor("return this")() })
);
var needToRemove = false;
function install() {
if (safeGlobal &&
!maybe(function() { return process.env.NODE_ENV }) &&
!maybe(function() { return process })) {
Object.defineProperty(safeGlobal, "process", {
value: {
env: {
// This default needs to be "production" instead of "development", to
// avoid the problem https://github.com/graphql/graphql-js/pull/2894
// will eventually solve, once merged and released.
NODE_ENV: "production",
},
},
// Let anyone else change global.process as they see fit, but hide it from
// Object.keys(global) enumeration.
configurable: true,
enumerable: false,
writable: true,
});
needToRemove = true;
}
}
// Call install() at least once, when this module is imported.
install();
function remove() {
if (needToRemove) {
delete safeGlobal.process;
needToRemove = false;
}
}
exports.install = install;
exports.remove = remove;
//# sourceMappingURL=main.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"main.cjs","sources":["index.js"],"sourcesContent":["function maybe(thunk) {\n try { return thunk() } catch (_) {}\n}\n\nvar safeGlobal = (\n maybe(function() { return globalThis }) ||\n maybe(function() { return window }) ||\n maybe(function() { return self }) ||\n maybe(function() { return global }) ||\n // We don't expect the Function constructor ever to be invoked at runtime, as\n // long as at least one of globalThis, window, self, or global is defined, so\n // we are under no obligation to make it easy for static analysis tools to\n // detect syntactic usage of the Function constructor. If you think you can\n // improve your static analysis to detect this obfuscation, think again. This\n // is an arms race you cannot win, at least not in JavaScript.\n maybe(function() { return maybe.constructor(\"return this\")() })\n);\n\nvar needToRemove = false;\n\nexport function install() {\n if (safeGlobal &&\n !maybe(function() { return process.env.NODE_ENV }) &&\n !maybe(function() { return process })) {\n Object.defineProperty(safeGlobal, \"process\", {\n value: {\n env: {\n // This default needs to be \"production\" instead of \"development\", to\n // avoid the problem https://github.com/graphql/graphql-js/pull/2894\n // will eventually solve, once merged and released.\n NODE_ENV: \"production\",\n },\n },\n // Let anyone else change global.process as they see fit, but hide it from\n // Object.keys(global) enumeration.\n configurable: true,\n enumerable: false,\n writable: true,\n });\n needToRemove = true;\n }\n}\n\n// Call install() at least once, when this module is imported.\ninstall();\n\nexport function remove() {\n if (needToRemove) {\n delete safeGlobal.process;\n needToRemove = false;\n }\n}\n"],"names":[],"mappings":";;;;AAAA,SAAS,KAAK,CAAC,KAAK,EAAE;AACtB,EAAE,IAAI,EAAE,OAAO,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE;AACrC,CAAC;AACD;AACA,IAAI,UAAU;AACd,EAAE,KAAK,CAAC,WAAW,EAAE,OAAO,UAAU,EAAE,CAAC;AACzC,EAAE,KAAK,CAAC,WAAW,EAAE,OAAO,MAAM,EAAE,CAAC;AACrC,EAAE,KAAK,CAAC,WAAW,EAAE,OAAO,IAAI,EAAE,CAAC;AACnC,EAAE,KAAK,CAAC,WAAW,EAAE,OAAO,MAAM,EAAE,CAAC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,KAAK,CAAC,WAAW,EAAE,OAAO,KAAK,CAAC,WAAW,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC;AACjE,CAAC,CAAC;AACF;AACA,IAAI,YAAY,GAAG,KAAK,CAAC;AACzB;AACO,SAAS,OAAO,GAAG;AAC1B,EAAE,IAAI,UAAU;AAChB,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxD,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,OAAO,OAAO,EAAE,CAAC,EAAE;AAC7C,IAAI,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,SAAS,EAAE;AACjD,MAAM,KAAK,EAAE;AACb,QAAQ,GAAG,EAAE;AACb;AACA;AACA;AACA,UAAU,QAAQ,EAAE,YAAY;AAChC,SAAS;AACT,OAAO;AACP;AACA;AACA,MAAM,YAAY,EAAE,IAAI;AACxB,MAAM,UAAU,EAAE,KAAK;AACvB,MAAM,QAAQ,EAAE,IAAI;AACpB,KAAK,CAAC,CAAC;AACP,IAAI,YAAY,GAAG,IAAI,CAAC;AACxB,GAAG;AACH,CAAC;AACD;AACA;AACA,OAAO,EAAE,CAAC;AACV;AACO,SAAS,MAAM,GAAG;AACzB,EAAE,IAAI,YAAY,EAAE;AACpB,IAAI,OAAO,UAAU,CAAC,OAAO,CAAC;AAC9B,IAAI,YAAY,GAAG,KAAK,CAAC;AACzB,GAAG;AACH;;;;;"}

View File

@@ -0,0 +1,60 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function maybe(thunk) {
try { return thunk() } catch (_) {}
}
var safeGlobal = (
maybe(function() { return globalThis }) ||
maybe(function() { return window }) ||
maybe(function() { return self }) ||
maybe(function() { return global }) ||
// We don't expect the Function constructor ever to be invoked at runtime, as
// long as at least one of globalThis, window, self, or global is defined, so
// we are under no obligation to make it easy for static analysis tools to
// detect syntactic usage of the Function constructor. If you think you can
// improve your static analysis to detect this obfuscation, think again. This
// is an arms race you cannot win, at least not in JavaScript.
maybe(function() { return maybe.constructor("return this")() })
);
var needToRemove = false;
function install() {
if (safeGlobal &&
!maybe(function() { return process.env.NODE_ENV }) &&
!maybe(function() { return process })) {
Object.defineProperty(safeGlobal, "process", {
value: {
env: {
// This default needs to be "production" instead of "development", to
// avoid the problem https://github.com/graphql/graphql-js/pull/2894
// will eventually solve, once merged and released.
NODE_ENV: "production",
},
},
// Let anyone else change global.process as they see fit, but hide it from
// Object.keys(global) enumeration.
configurable: true,
enumerable: false,
writable: true,
});
needToRemove = true;
}
}
// Call install() at least once, when this module is imported.
install();
function remove() {
if (needToRemove) {
delete safeGlobal.process;
needToRemove = false;
}
}
exports.install = install;
exports.remove = remove;
//# sourceMappingURL=main.cjs.map

View File

@@ -0,0 +1,12 @@
{
"name": "ts-invariant/process",
"type": "module",
"main": "./main.cjs",
"module": "./index.js",
"types": "./index.d.ts",
"sideEffects": [
"./main.cjs",
"./main.cjs.native.js",
"./index.js"
]
}

View File

@@ -0,0 +1,74 @@
import { promises as fs } from "fs";
const globals = {
__proto__: null,
assert: "assert",
invariant: "reactInvariant",
tslib: "tslib",
"@ungap/global-this": "globalThisPolyfill",
};
function external(id) {
return id in globals;
}
function copyPlugin() {
return {
name: "copy *.cjs to *.cjs.native.js",
async writeBundle({ file }) {
const buffer = await fs.readFile(file);
await fs.writeFile(
file + ".native.js",
buffer,
);
},
};
}
const jobs = [];
export default jobs;
jobs.push({
input: "lib/invariant.js",
external,
output: {
file: "lib/invariant.cjs",
format: "cjs",
exports: "named",
sourcemap: true,
name: "ts-invariant",
globals,
},
plugins: [
copyPlugin(),
],
});
jobs.push({
input: "lib/tests.js",
external,
output: {
file: "lib/tests.bundle.cjs",
format: "cjs",
exports: "named",
sourcemap: true,
name: "ts-invariant-tests-cjs-bundle",
globals,
},
});
jobs.push({
input: "process/index.js",
external,
output: {
file: "process/main.cjs",
format: "cjs",
exports: "named",
sourcemap: true,
name: "ts-invariant/process",
globals,
},
plugins: [
copyPlugin(),
],
});

View File

@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./lib"
}
}

View File

@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "es2015",
},
}