tiny-essentials 1.11.0 → 1.12.0
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/README.md +12 -3
- package/dist/node_modules/firebase-functions/lib/common/trace.cjs +82 -0
- package/dist/node_modules/firebase-functions/lib/logger/common.cjs +57 -0
- package/dist/node_modules/firebase-functions/lib/logger/index.cjs +158 -0
- package/dist/v1/TinyBasicsEs.js +1653 -1
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyDragDropDetector.js +307 -0
- package/dist/v1/TinyDragDropDetector.min.js +1 -0
- package/dist/v1/TinyDragger.js +3563 -0
- package/dist/v1/TinyDragger.min.js +2 -0
- package/dist/v1/TinyDragger.min.js.LICENSE.txt +8 -0
- package/dist/v1/TinyEssentials.js +2783 -2
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyNotifyCenter.js +32 -0
- package/dist/v1/TinyNotifyCenter.min.js +1 -1
- package/dist/v1/TinyToastNotify.js +24 -0
- package/dist/v1/TinyToastNotify.min.js +1 -1
- package/dist/v1/TinyUploadClicker.js +5235 -0
- package/dist/v1/TinyUploadClicker.min.js +2 -0
- package/dist/v1/TinyUploadClicker.min.js.LICENSE.txt +8 -0
- package/dist/v1/basics/fileManager.cjs +524 -0
- package/dist/v1/basics/fileManager.d.mts +209 -0
- package/dist/v1/basics/fileManager.mjs +443 -0
- package/dist/v1/basics/fullScreen.cjs +134 -0
- package/dist/v1/basics/fullScreen.d.mts +8 -0
- package/dist/v1/basics/fullScreen.mjs +121 -0
- package/dist/v1/basics/html.cjs +262 -0
- package/dist/v1/basics/html.d.mts +63 -0
- package/dist/v1/basics/html.mjs +208 -0
- package/dist/v1/basics/index.cjs +40 -0
- package/dist/v1/basics/index.d.mts +38 -1
- package/dist/v1/basics/index.mjs +4 -1
- package/dist/v1/build/TinyDragDropDetector.cjs +7 -0
- package/dist/v1/build/TinyDragDropDetector.d.mts +3 -0
- package/dist/v1/build/TinyDragDropDetector.mjs +2 -0
- package/dist/v1/build/TinyDragger.cjs +7 -0
- package/dist/v1/build/TinyDragger.d.mts +3 -0
- package/dist/v1/build/TinyDragger.mjs +2 -0
- package/dist/v1/build/TinyUploadClicker.cjs +7 -0
- package/dist/v1/build/TinyUploadClicker.d.mts +3 -0
- package/dist/v1/build/TinyUploadClicker.mjs +2 -0
- package/dist/v1/css/TinyDraggerExample.css +21 -0
- package/dist/v1/css/TinyDraggerExample.min.css +1 -0
- package/dist/v1/index.cjs +44 -0
- package/dist/v1/index.d.mts +40 -1
- package/dist/v1/index.mjs +6 -1
- package/dist/v1/libs/TinyDragDropDetector.cjs +268 -0
- package/dist/v1/libs/TinyDragDropDetector.d.mts +123 -0
- package/dist/v1/libs/TinyDragDropDetector.mjs +228 -0
- package/dist/v1/libs/TinyDragger.cjs +801 -0
- package/dist/v1/libs/TinyDragger.d.mts +300 -0
- package/dist/v1/libs/TinyDragger.mjs +689 -0
- package/dist/v1/libs/TinyNotifyCenter.cjs +32 -0
- package/dist/v1/libs/TinyNotifyCenter.d.mts +9 -0
- package/dist/v1/libs/TinyNotifyCenter.mjs +28 -0
- package/dist/v1/libs/TinyToastNotify.cjs +24 -0
- package/dist/v1/libs/TinyToastNotify.d.mts +8 -0
- package/dist/v1/libs/TinyToastNotify.mjs +20 -0
- package/dist/v1/libs/TinyUploadClicker.cjs +223 -0
- package/dist/v1/libs/TinyUploadClicker.d.mts +80 -0
- package/dist/v1/libs/TinyUploadClicker.mjs +182 -0
- package/docs/v1/README.md +8 -2
- package/docs/v1/basics/fileManager.md +222 -0
- package/docs/v1/basics/fullScreen.md +183 -0
- package/docs/v1/basics/html.md +243 -0
- package/docs/v1/libs/TinyDragDropDetector.md +143 -0
- package/docs/v1/libs/TinyDragger.md +415 -0
- package/docs/v1/libs/TinyLevelUp.md +1 -1
- package/docs/v1/libs/TinyNotifyCenter.md +20 -0
- package/docs/v1/libs/TinyToastNotify.md +19 -0
- package/docs/v1/libs/TinyUploadClicker.md +108 -0
- package/package.json +12 -2
package/README.md
CHANGED
|
@@ -21,9 +21,6 @@
|
|
|
21
21
|
- ⏱️ **Time Calculations**: Easily calculate durations, format timers, and more.
|
|
22
22
|
- 🧠 **Object Utilities**: Perform type checks, count object properties, and calculate percentages.
|
|
23
23
|
- 🛠️ **Custom Utilities**: Includes various helper functions like `ruleOfThree` for proportion calculations and `getAge` to calculate the age based on a given birth date.
|
|
24
|
-
- 🔐 **Encryption Tools**:
|
|
25
|
-
This feature has been migrated.
|
|
26
|
-
👉 For the latest version and full functionality, please visit the new [Tiny Crypto Suite repository](https://github.com/JasminDreasond/Tiny-Crypto-Suite).
|
|
27
24
|
|
|
28
25
|
## 📦 Installation
|
|
29
26
|
|
|
@@ -60,6 +57,18 @@ Check out the full documentation here:
|
|
|
60
57
|
|
|
61
58
|
👉 [Go to docs page](./docs/v1/README.md)
|
|
62
59
|
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 📦 More Tiny Essentials Modules
|
|
63
|
+
|
|
64
|
+
- 🤖 [**tiny-ai-api**](https://github.com/JasminDreasond/Tiny-AI-API) — Minimal AI API wrapper.
|
|
65
|
+
- 🎲 [**tiny-dices**](https://github.com/JasminDreasond/Tiny-Dices) — Simple dice and randomness utilities.
|
|
66
|
+
- 🔐 [**tiny-crypto-suite**](https://github.com/JasminDreasond/Tiny-Crypto-Suite) — Lightweight cryptography toolkit.
|
|
67
|
+
- 🖥️ [**tiny-server-essentials**](https://github.com/JasminDreasond/Tiny-Server-Essentials) — Node.js server utilities.
|
|
68
|
+
- 🪟 [**tiny-electron-essentials**](https://github.com/JasminDreasond/Tiny-Electron-Essentials) — Essential tools for Electron apps.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
63
72
|
## 🤝 Contributions
|
|
64
73
|
|
|
65
74
|
Feel free to fork, contribute, and create pull requests for improvements! Whether it's a bug fix or an additional feature, contributions are always welcome.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var trace = require('../../../../_virtual/trace.cjs');
|
|
4
|
+
var require$$0 = require('async_hooks');
|
|
5
|
+
|
|
6
|
+
var hasRequiredTrace;
|
|
7
|
+
|
|
8
|
+
function requireTrace () {
|
|
9
|
+
if (hasRequiredTrace) return trace.__exports;
|
|
10
|
+
hasRequiredTrace = 1;
|
|
11
|
+
Object.defineProperty(trace.__exports, "__esModule", { value: true });
|
|
12
|
+
trace.__exports.extractTraceContext = trace.__exports.traceContext = void 0;
|
|
13
|
+
const async_hooks_1 = require$$0;
|
|
14
|
+
/* @internal */
|
|
15
|
+
trace.__exports.traceContext = new async_hooks_1.AsyncLocalStorage();
|
|
16
|
+
/**
|
|
17
|
+
* A regex to match the Cloud Trace header.
|
|
18
|
+
* - ([A-Fa-f0-9]{32}): The trace id, a 32 character hex value. (e.g. 4bf92f3577b34da6a3ce929d0e0e4736)
|
|
19
|
+
* - ([0-9]+): The parent span id, a 64 bit integer. (e.g. 00f067aa0ba902b7)
|
|
20
|
+
* - (?:;o=([0-3])): The trace mask, 1-3 denote it should be traced.
|
|
21
|
+
*/
|
|
22
|
+
const CLOUD_TRACE_REGEX = new RegExp("^(?<traceId>[A-Fa-f0-9]{32})/" + "(?<parentIdInt>[0-9]+)" + "(?:;o=(?<traceMask>[0-3]))?$");
|
|
23
|
+
const CLOUD_TRACE_HEADER = "X-Cloud-Trace-Context";
|
|
24
|
+
function matchCloudTraceHeader(carrier) {
|
|
25
|
+
let header = carrier === null || carrier === void 0 ? void 0 : carrier[CLOUD_TRACE_HEADER];
|
|
26
|
+
if (!header) {
|
|
27
|
+
// try lowercase header
|
|
28
|
+
header = carrier === null || carrier === void 0 ? void 0 : carrier[CLOUD_TRACE_HEADER.toLowerCase()];
|
|
29
|
+
}
|
|
30
|
+
if (header && typeof header === "string") {
|
|
31
|
+
const matches = CLOUD_TRACE_REGEX.exec(header);
|
|
32
|
+
if (matches && matches.groups) {
|
|
33
|
+
const { traceId, parentIdInt, traceMask } = matches.groups;
|
|
34
|
+
// Convert parentId from unsigned int to hex
|
|
35
|
+
const parentId = parseInt(parentIdInt);
|
|
36
|
+
if (isNaN(parentId)) {
|
|
37
|
+
// Ignore traces with invalid parentIds
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const sample = !!traceMask && traceMask !== "0";
|
|
41
|
+
return { traceId, parentId: parentId.toString(16), sample, version: "00" };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A regex to match the traceparent header.
|
|
47
|
+
* - ^([a-f0-9]{2}): The specification version (e.g. 00)
|
|
48
|
+
* - ([a-f0-9]{32}): The trace id, a 16-byte array. (e.g. 4bf92f3577b34da6a3ce929d0e0e4736)
|
|
49
|
+
* - ([a-f0-9]{16}): The parent span id, an 8-byte array. (e.g. 00f067aa0ba902b7)
|
|
50
|
+
* - ([a-f0-9]{2}: The sampled flag. (e.g. 00)
|
|
51
|
+
*/
|
|
52
|
+
const TRACEPARENT_REGEX = new RegExp("^(?<version>[a-f0-9]{2})-" +
|
|
53
|
+
"(?<traceId>[a-f0-9]{32})-" +
|
|
54
|
+
"(?<parentId>[a-f0-9]{16})-" +
|
|
55
|
+
"(?<flag>[a-f0-9]{2})$");
|
|
56
|
+
const TRACEPARENT_HEADER = "traceparent";
|
|
57
|
+
function matchTraceparentHeader(carrier) {
|
|
58
|
+
const header = carrier === null || carrier === void 0 ? void 0 : carrier[TRACEPARENT_HEADER];
|
|
59
|
+
if (header && typeof header === "string") {
|
|
60
|
+
const matches = TRACEPARENT_REGEX.exec(header);
|
|
61
|
+
if (matches && matches.groups) {
|
|
62
|
+
const { version, traceId, parentId, flag } = matches.groups;
|
|
63
|
+
const sample = flag === "01";
|
|
64
|
+
return { traceId, parentId, sample, version };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Extracts trace context from given carrier object, if any.
|
|
70
|
+
*
|
|
71
|
+
* Supports Cloud Trace and traceparent format.
|
|
72
|
+
*
|
|
73
|
+
* @param carrier
|
|
74
|
+
*/
|
|
75
|
+
function extractTraceContext(carrier) {
|
|
76
|
+
return matchCloudTraceHeader(carrier) || matchTraceparentHeader(carrier);
|
|
77
|
+
}
|
|
78
|
+
trace.__exports.extractTraceContext = extractTraceContext;
|
|
79
|
+
return trace.__exports;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
exports.__require = requireTrace;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var common = require('../../../../_virtual/common.cjs');
|
|
4
|
+
|
|
5
|
+
var hasRequiredCommon;
|
|
6
|
+
|
|
7
|
+
function requireCommon () {
|
|
8
|
+
if (hasRequiredCommon) return common.__exports;
|
|
9
|
+
hasRequiredCommon = 1;
|
|
10
|
+
// The MIT License (MIT)
|
|
11
|
+
//
|
|
12
|
+
// Copyright (c) 2017 Firebase
|
|
13
|
+
//
|
|
14
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
// in the Software without restriction, including without limitation the rights
|
|
17
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
// furnished to do so, subject to the following conditions:
|
|
20
|
+
//
|
|
21
|
+
// The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
// copies or substantial portions of the Software.
|
|
23
|
+
//
|
|
24
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
// SOFTWARE.
|
|
31
|
+
Object.defineProperty(common.__exports, "__esModule", { value: true });
|
|
32
|
+
common.__exports.UNPATCHED_CONSOLE = common.__exports.CONSOLE_SEVERITY = void 0;
|
|
33
|
+
// Map LogSeverity types to their equivalent `console.*` method.
|
|
34
|
+
/** @hidden */
|
|
35
|
+
common.__exports.CONSOLE_SEVERITY = {
|
|
36
|
+
DEBUG: "debug",
|
|
37
|
+
INFO: "info",
|
|
38
|
+
NOTICE: "info",
|
|
39
|
+
WARNING: "warn",
|
|
40
|
+
ERROR: "error",
|
|
41
|
+
CRITICAL: "error",
|
|
42
|
+
ALERT: "error",
|
|
43
|
+
EMERGENCY: "error",
|
|
44
|
+
};
|
|
45
|
+
// safely preserve unpatched console.* methods in case of compat require
|
|
46
|
+
/** @hidden */
|
|
47
|
+
common.__exports.UNPATCHED_CONSOLE = {
|
|
48
|
+
debug: console.debug,
|
|
49
|
+
info: console.info,
|
|
50
|
+
log: console.log,
|
|
51
|
+
warn: console.warn,
|
|
52
|
+
error: console.error,
|
|
53
|
+
};
|
|
54
|
+
return common.__exports;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
exports.__require = requireCommon;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('../../../../_virtual/index2.cjs');
|
|
4
|
+
var require$$0 = require('util');
|
|
5
|
+
var trace = require('../common/trace.cjs');
|
|
6
|
+
var common = require('./common.cjs');
|
|
7
|
+
|
|
8
|
+
var hasRequiredLogger;
|
|
9
|
+
|
|
10
|
+
function requireLogger () {
|
|
11
|
+
if (hasRequiredLogger) return index.__exports;
|
|
12
|
+
hasRequiredLogger = 1;
|
|
13
|
+
// The MIT License (MIT)
|
|
14
|
+
//
|
|
15
|
+
// Copyright (c) 2017 Firebase
|
|
16
|
+
//
|
|
17
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
18
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
19
|
+
// in the Software without restriction, including without limitation the rights
|
|
20
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
21
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
22
|
+
// furnished to do so, subject to the following conditions:
|
|
23
|
+
//
|
|
24
|
+
// The above copyright notice and this permission notice shall be included in all
|
|
25
|
+
// copies or substantial portions of the Software.
|
|
26
|
+
//
|
|
27
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
28
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
29
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
30
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
31
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
32
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
|
+
// SOFTWARE.
|
|
34
|
+
Object.defineProperty(index.__exports, "__esModule", { value: true });
|
|
35
|
+
index.__exports.error = index.__exports.warn = index.__exports.info = index.__exports.log = index.__exports.debug = index.__exports.write = void 0;
|
|
36
|
+
const util_1 = require$$0;
|
|
37
|
+
const trace_1 = trace.__require();
|
|
38
|
+
const common_1 = common.__require();
|
|
39
|
+
/** @internal */
|
|
40
|
+
function removeCircular(obj, refs = []) {
|
|
41
|
+
if (typeof obj !== "object" || !obj) {
|
|
42
|
+
return obj;
|
|
43
|
+
}
|
|
44
|
+
// If the object defines its own toJSON, prefer that.
|
|
45
|
+
if (obj.toJSON) {
|
|
46
|
+
return obj.toJSON();
|
|
47
|
+
}
|
|
48
|
+
if (refs.includes(obj)) {
|
|
49
|
+
return "[Circular]";
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
refs.push(obj);
|
|
53
|
+
}
|
|
54
|
+
let returnObj;
|
|
55
|
+
if (Array.isArray(obj)) {
|
|
56
|
+
returnObj = new Array(obj.length);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
returnObj = {};
|
|
60
|
+
}
|
|
61
|
+
for (const k in obj) {
|
|
62
|
+
if (refs.includes(obj[k])) {
|
|
63
|
+
returnObj[k] = "[Circular]";
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
returnObj[k] = removeCircular(obj[k], refs);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return returnObj;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Writes a `LogEntry` to `stdout`/`stderr` (depending on severity).
|
|
73
|
+
* @param entry - The `LogEntry` including severity, message, and any additional structured metadata.
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
function write(entry) {
|
|
77
|
+
const ctx = trace_1.traceContext.getStore();
|
|
78
|
+
if (ctx === null || ctx === void 0 ? void 0 : ctx.traceId) {
|
|
79
|
+
entry["logging.googleapis.com/trace"] = `projects/${process.env.GCLOUD_PROJECT}/traces/${ctx.traceId}`;
|
|
80
|
+
}
|
|
81
|
+
common_1.UNPATCHED_CONSOLE[common_1.CONSOLE_SEVERITY[entry.severity]](JSON.stringify(removeCircular(entry)));
|
|
82
|
+
}
|
|
83
|
+
index.__exports.write = write;
|
|
84
|
+
/**
|
|
85
|
+
* Writes a `DEBUG` severity log. If the last argument provided is a plain object,
|
|
86
|
+
* it is added to the `jsonPayload` in the Cloud Logging entry.
|
|
87
|
+
* @param args - Arguments, concatenated into the log message with space separators.
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
function debug(...args) {
|
|
91
|
+
write(entryFromArgs("DEBUG", args));
|
|
92
|
+
}
|
|
93
|
+
index.__exports.debug = debug;
|
|
94
|
+
/**
|
|
95
|
+
* Writes an `INFO` severity log. If the last argument provided is a plain object,
|
|
96
|
+
* it is added to the `jsonPayload` in the Cloud Logging entry.
|
|
97
|
+
* @param args - Arguments, concatenated into the log message with space separators.
|
|
98
|
+
* @public
|
|
99
|
+
*/
|
|
100
|
+
function log(...args) {
|
|
101
|
+
write(entryFromArgs("INFO", args));
|
|
102
|
+
}
|
|
103
|
+
index.__exports.log = log;
|
|
104
|
+
/**
|
|
105
|
+
* Writes an `INFO` severity log. If the last argument provided is a plain object,
|
|
106
|
+
* it is added to the `jsonPayload` in the Cloud Logging entry.
|
|
107
|
+
* @param args - Arguments, concatenated into the log message with space separators.
|
|
108
|
+
* @public
|
|
109
|
+
*/
|
|
110
|
+
function info(...args) {
|
|
111
|
+
write(entryFromArgs("INFO", args));
|
|
112
|
+
}
|
|
113
|
+
index.__exports.info = info;
|
|
114
|
+
/**
|
|
115
|
+
* Writes a `WARNING` severity log. If the last argument provided is a plain object,
|
|
116
|
+
* it is added to the `jsonPayload` in the Cloud Logging entry.
|
|
117
|
+
* @param args - Arguments, concatenated into the log message with space separators.
|
|
118
|
+
* @public
|
|
119
|
+
*/
|
|
120
|
+
function warn(...args) {
|
|
121
|
+
write(entryFromArgs("WARNING", args));
|
|
122
|
+
}
|
|
123
|
+
index.__exports.warn = warn;
|
|
124
|
+
/**
|
|
125
|
+
* Writes an `ERROR` severity log. If the last argument provided is a plain object,
|
|
126
|
+
* it is added to the `jsonPayload` in the Cloud Logging entry.
|
|
127
|
+
* @param args - Arguments, concatenated into the log message with space separators.
|
|
128
|
+
* @public
|
|
129
|
+
*/
|
|
130
|
+
function error(...args) {
|
|
131
|
+
write(entryFromArgs("ERROR", args));
|
|
132
|
+
}
|
|
133
|
+
index.__exports.error = error;
|
|
134
|
+
/** @hidden */
|
|
135
|
+
function entryFromArgs(severity, args) {
|
|
136
|
+
let entry = {};
|
|
137
|
+
const lastArg = args[args.length - 1];
|
|
138
|
+
if (lastArg && typeof lastArg === "object" && lastArg.constructor === Object) {
|
|
139
|
+
entry = args.pop();
|
|
140
|
+
}
|
|
141
|
+
// mimic `console.*` behavior, see https://nodejs.org/api/console.html#console_console_log_data_args
|
|
142
|
+
let message = (0, util_1.format)(...args);
|
|
143
|
+
if (severity === "ERROR" && !args.find((arg) => arg instanceof Error)) {
|
|
144
|
+
message = new Error(message).stack || message;
|
|
145
|
+
}
|
|
146
|
+
const out = {
|
|
147
|
+
...entry,
|
|
148
|
+
severity,
|
|
149
|
+
};
|
|
150
|
+
if (message) {
|
|
151
|
+
out.message = message;
|
|
152
|
+
}
|
|
153
|
+
return out;
|
|
154
|
+
}
|
|
155
|
+
return index.__exports;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
exports.__require = requireLogger;
|