@agoric/internal 0.3.3-dev-f561d5d.0.f561d5d → 0.3.3-dev-433c8e8.0.433c8e8
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.
- package/package.json +6 -6
- package/src/node/shutdown.js +1 -1
- package/vendor/anylogger.d.ts +98 -0
- package/vendor/anylogger.d.ts.map +1 -0
- package/vendor/anylogger.js +60 -0
- package/vendor/anylogger.ts +160 -0
- package/vendor/tsconfig.anylogger.json +15 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/internal",
|
|
3
|
-
"version": "0.3.3-dev-
|
|
3
|
+
"version": "0.3.3-dev-433c8e8.0.433c8e8",
|
|
4
4
|
"description": "Externally unsupported utilities internal to agoric-sdk",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"lint:types": "yarn run -T tsc"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@agoric/base-zone": "0.1.1-dev-
|
|
23
|
+
"@agoric/base-zone": "0.1.1-dev-433c8e8.0.433c8e8",
|
|
24
24
|
"@endo/cache-map": "^1.1.0",
|
|
25
25
|
"@endo/common": "^1.2.13",
|
|
26
26
|
"@endo/compartment-mapper": "^1.6.3",
|
|
@@ -34,12 +34,11 @@
|
|
|
34
34
|
"@endo/patterns": "^1.7.0",
|
|
35
35
|
"@endo/promise-kit": "^1.1.13",
|
|
36
36
|
"@endo/stream": "^1.2.13",
|
|
37
|
-
"anylogger": "^0.21.0",
|
|
38
37
|
"import-meta-resolve": "^4.1.0",
|
|
39
38
|
"jessie.js": "^0.3.4"
|
|
40
39
|
},
|
|
41
40
|
"devDependencies": {
|
|
42
|
-
"@agoric/cosmic-proto": "0.4.1-dev-
|
|
41
|
+
"@agoric/cosmic-proto": "0.4.1-dev-433c8e8.0.433c8e8",
|
|
43
42
|
"@endo/exo": "^1.5.12",
|
|
44
43
|
"@endo/init": "^1.1.12",
|
|
45
44
|
"@endo/ses-ava": "^1.3.2",
|
|
@@ -58,7 +57,8 @@
|
|
|
58
57
|
"author": "Agoric",
|
|
59
58
|
"license": "Apache-2.0",
|
|
60
59
|
"files": [
|
|
61
|
-
"src"
|
|
60
|
+
"src",
|
|
61
|
+
"vendor"
|
|
62
62
|
],
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"typeCoverage": {
|
|
67
67
|
"atLeast": 92.84
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "433c8e8aa635325e306429914607df40e7812ee6"
|
|
70
70
|
}
|
package/src/node/shutdown.js
CHANGED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VENDORED SOURCE - DO NOT EDIT DIRECTLY
|
|
3
|
+
*
|
|
4
|
+
* Source of truth for the anylogger vendored module.
|
|
5
|
+
*
|
|
6
|
+
* This vendoring flow intentionally keeps three files:
|
|
7
|
+
* - `vendor/anylogger.ts`: upstream TypeScript source (kept close to upstream).
|
|
8
|
+
* - `vendor/anylogger.js`: generated runtime for consumers that import JS directly.
|
|
9
|
+
* - `vendor/anylogger.d.ts`: generated declarations for type imports from that same JS path.
|
|
10
|
+
*
|
|
11
|
+
* To regenerate generated artifacts after editing the TypeScript source file (vendor/anylogger.ts):
|
|
12
|
+
* `cd packages/internal && yarn run -T tsc --project vendor/tsconfig.anylogger.json`
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* A log function is a function that takes a variable amount of
|
|
16
|
+
* arguments and returns void.
|
|
17
|
+
*/
|
|
18
|
+
export type LogFunction = (...args: any) => void;
|
|
19
|
+
/**
|
|
20
|
+
* The default base log levels for anylogger.
|
|
21
|
+
*/
|
|
22
|
+
export type LogLevels = {
|
|
23
|
+
error: 1;
|
|
24
|
+
warn: 2;
|
|
25
|
+
info: 3;
|
|
26
|
+
log: 4;
|
|
27
|
+
debug: 5;
|
|
28
|
+
trace: 6;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* A log level is a string that is a key of `LogLevels`.
|
|
32
|
+
*/
|
|
33
|
+
export type LogLevel = keyof LogLevels;
|
|
34
|
+
/**
|
|
35
|
+
* All loggers, keyed by name.
|
|
36
|
+
*/
|
|
37
|
+
export type AllLoggers = {
|
|
38
|
+
[name: string]: Logger;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* An alias for the much used concept of a LoggerName.
|
|
42
|
+
*/
|
|
43
|
+
export type LoggerName = string;
|
|
44
|
+
/**
|
|
45
|
+
* An adapter accepts a LogFunction and returns a Logger.
|
|
46
|
+
*/
|
|
47
|
+
export type Adapter = (logfn: LogFunction) => Logger;
|
|
48
|
+
/**
|
|
49
|
+
* A logger is a log function that has a `name` that corresponds to the logger
|
|
50
|
+
* name, a method `enabledFor(level: LogLevel)` to check whether the logger is
|
|
51
|
+
* enabled for a certain log level, and log methods for each of the log levels
|
|
52
|
+
* supported by AnyLogger: `error`, `warn`, `info`, `log`, `debug` and `trace`.
|
|
53
|
+
*/
|
|
54
|
+
export type Logger = LogFunction & {
|
|
55
|
+
readonly name: LoggerName;
|
|
56
|
+
enabledFor: (level?: LogLevel) => boolean | void;
|
|
57
|
+
} & {
|
|
58
|
+
[P in keyof LogLevels as `${P}`]: LogFunction;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Gets or creates a logger by name.
|
|
62
|
+
*/
|
|
63
|
+
export type AnyLogger = ((name: LoggerName) => Logger) & {
|
|
64
|
+
/**
|
|
65
|
+
* Stores all loggers created so far.
|
|
66
|
+
*/
|
|
67
|
+
all: AllLoggers;
|
|
68
|
+
/**
|
|
69
|
+
* An object containing a mapping of level names to level values.
|
|
70
|
+
*/
|
|
71
|
+
levels: {
|
|
72
|
+
[level: string]: number;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Called when a new logger needs to be created.
|
|
76
|
+
*/
|
|
77
|
+
new: (name: LoggerName) => LogFunction;
|
|
78
|
+
/**
|
|
79
|
+
* Called by the log function that the default implementation of
|
|
80
|
+
* `anylogger.new` creates.
|
|
81
|
+
*/
|
|
82
|
+
log: (name: LoggerName, ...args: any) => void;
|
|
83
|
+
/**
|
|
84
|
+
* Called when a log function needs to be extended.
|
|
85
|
+
*/
|
|
86
|
+
ext: Adapter;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Back-compat alias used by callers in this repository.
|
|
90
|
+
*/
|
|
91
|
+
export type BaseLevels = LogLevels;
|
|
92
|
+
/**
|
|
93
|
+
* A N Y L O G G E R
|
|
94
|
+
* Get a logger. Any logger.
|
|
95
|
+
*/
|
|
96
|
+
declare const anylogger: AnyLogger;
|
|
97
|
+
export default anylogger;
|
|
98
|
+
//# sourceMappingURL=anylogger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anylogger.d.ts","sourceRoot":"","sources":["anylogger.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AAGH;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,CAAC,CAAC;IACT,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,EAAE,CAAC,CAAC;IACR,GAAG,EAAE,CAAC,CAAC;IACP,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC;AAEvC;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,WAAW,KAAK,MAAM,CAAC;AAErD;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG,WAAW,GAAG;IACjC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,UAAU,EAAE,CAAC,KAAK,CAAC,EAAE,QAAQ,KAAK,OAAO,GAAG,IAAI,CAAC;CAClD,GAAG;KACD,CAAC,IAAI,MAAM,SAAS,IAAI,GAAG,CAAC,EAAE,GAAG,WAAW;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,IAAI,EAAE,UAAU,KAAK,MAAM,CAAC,GAAG;IACvD;;OAEG;IACH,GAAG,EAAE,UAAU,CAAC;IAEhB;;OAEG;IACH,MAAM,EAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAEpC;;OAEG;IACH,GAAG,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,WAAW,CAAC;IAEvC;;;OAGG;IACH,GAAG,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IAE9C;;OAEG;IACH,GAAG,EAAE,OAAO,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,CAAC;AAEnC;;;GAGG;AAGH,QAAA,MAAM,SAAS,EAIkD,SAAS,CAAC;AAyC3E,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* VENDORED SOURCE - DO NOT EDIT DIRECTLY
|
|
4
|
+
*
|
|
5
|
+
* Source of truth for the anylogger vendored module.
|
|
6
|
+
*
|
|
7
|
+
* This vendoring flow intentionally keeps three files:
|
|
8
|
+
* - `vendor/anylogger.ts`: upstream TypeScript source (kept close to upstream).
|
|
9
|
+
* - `vendor/anylogger.js`: generated runtime for consumers that import JS directly.
|
|
10
|
+
* - `vendor/anylogger.d.ts`: generated declarations for type imports from that same JS path.
|
|
11
|
+
*
|
|
12
|
+
* To regenerate generated artifacts after editing the TypeScript source file (vendor/anylogger.ts):
|
|
13
|
+
* `cd packages/internal && yarn run -T tsc --project vendor/tsconfig.anylogger.json`
|
|
14
|
+
*/
|
|
15
|
+
// prettier-ignore-start
|
|
16
|
+
/**
|
|
17
|
+
* A N Y L O G G E R
|
|
18
|
+
* Get a logger. Any logger.
|
|
19
|
+
*/
|
|
20
|
+
// the main `anylogger` function
|
|
21
|
+
const anylogger = ((name) =>
|
|
22
|
+
// return the existing logger, or
|
|
23
|
+
anylogger.all[name] ||
|
|
24
|
+
// create and store a new logger with that name
|
|
25
|
+
(anylogger.all[name] = anylogger.ext(anylogger.new(name))));
|
|
26
|
+
// all loggers created so far
|
|
27
|
+
anylogger.all = Object.create(null);
|
|
28
|
+
// the supported levels
|
|
29
|
+
anylogger.levels = { error: 1, warn: 2, info: 3, log: 4, debug: 5, trace: 6 };
|
|
30
|
+
// creates a new named log function
|
|
31
|
+
anylogger.new = name => ({
|
|
32
|
+
// to assign the function `name`, set it to a named key in an object.
|
|
33
|
+
// the default implementation calls `anylogger.log`, which should be a
|
|
34
|
+
// good choice in many cases.
|
|
35
|
+
[name]: (...args) => anylogger.log(name, ...args),
|
|
36
|
+
})[name]; // return only the function, not the encapsulating object
|
|
37
|
+
// logs with the logger with the given `name`
|
|
38
|
+
anylogger.log = (name, ...args) => {
|
|
39
|
+
// select the logger to use
|
|
40
|
+
anylogger.all[name][
|
|
41
|
+
// select the level to use
|
|
42
|
+
// if multiple args and first matches a level name
|
|
43
|
+
args.length > 1 && anylogger.levels[args[0]]
|
|
44
|
+
? args.shift() // use the level from the args
|
|
45
|
+
: 'log' // else use default level `'log'`
|
|
46
|
+
](...args); // call method matching level with remaining args
|
|
47
|
+
};
|
|
48
|
+
// extends the given `logger` function
|
|
49
|
+
// the implementation here only adds no-ops
|
|
50
|
+
// adapters should change this behavior
|
|
51
|
+
anylogger.ext = (logger) => {
|
|
52
|
+
logger.enabledFor = () => { };
|
|
53
|
+
for (const method in anylogger.levels) {
|
|
54
|
+
logger[method] = () => { };
|
|
55
|
+
}
|
|
56
|
+
return logger;
|
|
57
|
+
};
|
|
58
|
+
// this is a real ESM module
|
|
59
|
+
export default anylogger;
|
|
60
|
+
// prettier-ignore-end
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/* eslint-disable -- vendored upstream source */
|
|
3
|
+
/**
|
|
4
|
+
* VENDORED SOURCE - DO NOT EDIT DIRECTLY
|
|
5
|
+
*
|
|
6
|
+
* Source of truth for the anylogger vendored module.
|
|
7
|
+
*
|
|
8
|
+
* This vendoring flow intentionally keeps three files:
|
|
9
|
+
* - `vendor/anylogger.ts`: upstream TypeScript source (kept close to upstream).
|
|
10
|
+
* - `vendor/anylogger.js`: generated runtime for consumers that import JS directly.
|
|
11
|
+
* - `vendor/anylogger.d.ts`: generated declarations for type imports from that same JS path.
|
|
12
|
+
*
|
|
13
|
+
* To regenerate generated artifacts after editing the TypeScript source file (vendor/anylogger.ts):
|
|
14
|
+
* `cd packages/internal && yarn run -T tsc --project vendor/tsconfig.anylogger.json`
|
|
15
|
+
*/
|
|
16
|
+
// prettier-ignore-start
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A log function is a function that takes a variable amount of
|
|
20
|
+
* arguments and returns void.
|
|
21
|
+
*/
|
|
22
|
+
export type LogFunction = (...args: any) => void;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The default base log levels for anylogger.
|
|
26
|
+
*/
|
|
27
|
+
export type LogLevels = {
|
|
28
|
+
error: 1;
|
|
29
|
+
warn: 2;
|
|
30
|
+
info: 3;
|
|
31
|
+
log: 4;
|
|
32
|
+
debug: 5;
|
|
33
|
+
trace: 6;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A log level is a string that is a key of `LogLevels`.
|
|
38
|
+
*/
|
|
39
|
+
export type LogLevel = keyof LogLevels;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* All loggers, keyed by name.
|
|
43
|
+
*/
|
|
44
|
+
export type AllLoggers = {
|
|
45
|
+
[name: string]: Logger;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* An alias for the much used concept of a LoggerName.
|
|
50
|
+
*/
|
|
51
|
+
export type LoggerName = string;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* An adapter accepts a LogFunction and returns a Logger.
|
|
55
|
+
*/
|
|
56
|
+
export type Adapter = (logfn: LogFunction) => Logger;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* A logger is a log function that has a `name` that corresponds to the logger
|
|
60
|
+
* name, a method `enabledFor(level: LogLevel)` to check whether the logger is
|
|
61
|
+
* enabled for a certain log level, and log methods for each of the log levels
|
|
62
|
+
* supported by AnyLogger: `error`, `warn`, `info`, `log`, `debug` and `trace`.
|
|
63
|
+
*/
|
|
64
|
+
export type Logger = LogFunction & {
|
|
65
|
+
readonly name: LoggerName;
|
|
66
|
+
enabledFor: (level?: LogLevel) => boolean | void;
|
|
67
|
+
} & {
|
|
68
|
+
[P in keyof LogLevels as `${P}`]: LogFunction;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Gets or creates a logger by name.
|
|
73
|
+
*/
|
|
74
|
+
export type AnyLogger = ((name: LoggerName) => Logger) & {
|
|
75
|
+
/**
|
|
76
|
+
* Stores all loggers created so far.
|
|
77
|
+
*/
|
|
78
|
+
all: AllLoggers;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* An object containing a mapping of level names to level values.
|
|
82
|
+
*/
|
|
83
|
+
levels: { [level: string]: number };
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Called when a new logger needs to be created.
|
|
87
|
+
*/
|
|
88
|
+
new: (name: LoggerName) => LogFunction;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Called by the log function that the default implementation of
|
|
92
|
+
* `anylogger.new` creates.
|
|
93
|
+
*/
|
|
94
|
+
log: (name: LoggerName, ...args: any) => void;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Called when a log function needs to be extended.
|
|
98
|
+
*/
|
|
99
|
+
ext: Adapter;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Back-compat alias used by callers in this repository.
|
|
104
|
+
*/
|
|
105
|
+
export type BaseLevels = LogLevels;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* A N Y L O G G E R
|
|
109
|
+
* Get a logger. Any logger.
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
// the main `anylogger` function
|
|
113
|
+
const anylogger = ((name: LoggerName) =>
|
|
114
|
+
// return the existing logger, or
|
|
115
|
+
anylogger.all[name] ||
|
|
116
|
+
// create and store a new logger with that name
|
|
117
|
+
(anylogger.all[name] = anylogger.ext(anylogger.new(name)))) as AnyLogger;
|
|
118
|
+
|
|
119
|
+
// all loggers created so far
|
|
120
|
+
anylogger.all = Object.create(null);
|
|
121
|
+
|
|
122
|
+
// the supported levels
|
|
123
|
+
anylogger.levels = { error: 1, warn: 2, info: 3, log: 4, debug: 5, trace: 6 };
|
|
124
|
+
|
|
125
|
+
// creates a new named log function
|
|
126
|
+
anylogger.new = name =>
|
|
127
|
+
({
|
|
128
|
+
// to assign the function `name`, set it to a named key in an object.
|
|
129
|
+
// the default implementation calls `anylogger.log`, which should be a
|
|
130
|
+
// good choice in many cases.
|
|
131
|
+
[name]: (...args: any[]) => anylogger.log(name, ...args),
|
|
132
|
+
})[name]; // return only the function, not the encapsulating object
|
|
133
|
+
|
|
134
|
+
// logs with the logger with the given `name`
|
|
135
|
+
anylogger.log = (name, ...args: any[]) => {
|
|
136
|
+
// select the logger to use
|
|
137
|
+
anylogger.all[name][
|
|
138
|
+
// select the level to use
|
|
139
|
+
// if multiple args and first matches a level name
|
|
140
|
+
args.length > 1 && anylogger.levels[args[0] as string]
|
|
141
|
+
? (args.shift() as string) // use the level from the args
|
|
142
|
+
: 'log' // else use default level `'log'`
|
|
143
|
+
](...args); // call method matching level with remaining args
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// extends the given `logger` function
|
|
147
|
+
// the implementation here only adds no-ops
|
|
148
|
+
// adapters should change this behavior
|
|
149
|
+
anylogger.ext = (logger: LogFunction) => {
|
|
150
|
+
(logger as Logger).enabledFor = () => {};
|
|
151
|
+
for (const method in anylogger.levels) {
|
|
152
|
+
(logger as Logger)[method as LogLevel] = () => {};
|
|
153
|
+
}
|
|
154
|
+
return logger as Logger;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// this is a real ESM module
|
|
158
|
+
export default anylogger;
|
|
159
|
+
|
|
160
|
+
// prettier-ignore-end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"rootDir": ".",
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"declarationMap": false,
|
|
9
|
+
"emitDeclarationOnly": false,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"strict": false,
|
|
12
|
+
"removeComments": false
|
|
13
|
+
},
|
|
14
|
+
"include": ["./anylogger.ts"]
|
|
15
|
+
}
|