@dxos/invariant 0.3.7 → 0.3.8-main.152ec6f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/common/invariant/src/invariant.ts":{"bytes":
|
|
1
|
+
{"inputs":{"packages/common/invariant/src/invariant.ts":{"bytes":4587,"imports":[],"format":"esm"},"packages/common/invariant/src/index.ts":{"bytes":470,"imports":[{"path":"packages/common/invariant/src/invariant.ts","kind":"import-statement","original":"./invariant"}],"format":"esm"}},"outputs":{"packages/common/invariant/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2355},"packages/common/invariant/dist/lib/browser/index.mjs":{"imports":[],"exports":["InvariantViolation","invariant"],"entryPoint":"packages/common/invariant/src/index.ts","inputs":{"packages/common/invariant/src/invariant.ts":{"bytesInOutput":730},"packages/common/invariant/src/index.ts":{"bytesInOutput":0}},"bytes":857}}}
|
package/dist/lib/node/index.cjs
CHANGED
|
@@ -16,16 +16,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
19
|
+
var node_exports = {};
|
|
20
|
+
__export(node_exports, {
|
|
23
21
|
InvariantViolation: () => InvariantViolation,
|
|
24
22
|
invariant: () => invariant
|
|
25
23
|
});
|
|
26
|
-
module.exports = __toCommonJS(
|
|
27
|
-
|
|
28
|
-
// packages/common/invariant/src/invariant.ts
|
|
24
|
+
module.exports = __toCommonJS(node_exports);
|
|
29
25
|
var invariant = (condition, message, meta) => {
|
|
30
26
|
if (condition) {
|
|
31
27
|
return;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\
|
|
5
|
-
"mappings": "
|
|
3
|
+
"sources": ["../../../src/invariant.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type CallMetadata } from './meta';\n\nexport type InvariantFn = (condition: unknown, message?: string, meta?: CallMetadata) => asserts condition;\n\n/**\n * Asserts that the condition is true.\n *\n * @param message Optional message.\n */\nexport const invariant: InvariantFn = (\n condition: unknown,\n message?: string,\n meta?: CallMetadata,\n): asserts condition => {\n if (condition) {\n return;\n }\n\n let errorMessage = 'invariant violation';\n\n if (message) {\n errorMessage += `: ${message}`;\n }\n\n if (meta?.A) {\n errorMessage += ` [${meta.A[0]}]`;\n }\n\n if (meta?.F) {\n errorMessage += ` at ${getRelativeFilename(meta.F)}:${meta.L}`;\n }\n\n throw new InvariantViolation(errorMessage);\n};\n\nexport class InvariantViolation extends Error {\n constructor(message: string) {\n super(message);\n // NOTE: Restores prototype chain (https://stackoverflow.com/a/48342359).\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nconst getRelativeFilename = (filename: string) => {\n // TODO(burdon): Hack uses \"packages\" as an anchor (pre-parse NX?)\n // Including `packages/` part of the path so that excluded paths (e.g. from dist) are clickable in vscode.\n const match = filename.match(/.+\\/(packages\\/.+\\/.+)/);\n if (match) {\n const [, filePath] = match;\n return filePath;\n }\n\n return filename;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAaO,IAAMA,YAAyB,CACpCC,WACAC,SACAC,SAAAA;AAEA,MAAIF,WAAW;AACb;EACF;AAEA,MAAIG,eAAe;AAEnB,MAAIF,SAAS;AACXE,oBAAgB,KAAKF,OAAAA;EACvB;AAEA,MAAIC,MAAME,GAAG;AACXD,oBAAgB,KAAKD,KAAKE,EAAE,CAAA,CAAE;EAChC;AAEA,MAAIF,MAAMG,GAAG;AACXF,oBAAgB,OAAOG,oBAAoBJ,KAAKG,CAAC,CAAA,IAAKH,KAAKK,CAAC;EAC9D;AAEA,QAAM,IAAIC,mBAAmBL,YAAAA;AAC/B;AAEO,IAAMK,qBAAN,cAAiCC,MAAAA;EACtCC,YAAYT,SAAiB;AAC3B,UAAMA,OAAAA;AAENU,WAAOC,eAAe,MAAM,WAAWC,SAAS;EAClD;AACF;AAEA,IAAMP,sBAAsB,CAACQ,aAAAA;AAG3B,QAAMC,QAAQD,SAASC,MAAM,wBAAA;AAC7B,MAAIA,OAAO;AACT,UAAM,CAAA,EAAGC,QAAAA,IAAYD;AACrB,WAAOC;EACT;AAEA,SAAOF;AACT;",
|
|
6
6
|
"names": ["invariant", "condition", "message", "meta", "errorMessage", "A", "F", "getRelativeFilename", "L", "InvariantViolation", "Error", "constructor", "Object", "setPrototypeOf", "prototype", "filename", "match", "filePath"]
|
|
7
7
|
}
|
package/dist/lib/node/meta.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/common/invariant/src/invariant.ts":{"bytes":
|
|
1
|
+
{"inputs":{"packages/common/invariant/src/invariant.ts":{"bytes":4587,"imports":[],"format":"esm"},"packages/common/invariant/src/index.ts":{"bytes":470,"imports":[{"path":"packages/common/invariant/src/invariant.ts","kind":"import-statement","original":"./invariant"}],"format":"esm"}},"outputs":{"packages/common/invariant/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2355},"packages/common/invariant/dist/lib/node/index.cjs":{"imports":[],"exports":["InvariantViolation","invariant"],"entryPoint":"packages/common/invariant/src/index.ts","inputs":{"packages/common/invariant/src/invariant.ts":{"bytesInOutput":730},"packages/common/invariant/src/index.ts":{"bytesInOutput":0}},"bytes":857}}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/invariant",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8-main.152ec6f",
|
|
4
4
|
"description": "Invariant assertion compatible with DXOS logger.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"src"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@dxos/node-std": "0.3.
|
|
19
|
+
"@dxos/node-std": "0.3.8-main.152ec6f"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@swc/core": "1.3.70",
|