@graphql-markdown/logger 1.1.2 → 1.1.4
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 +1 -0
- package/dist/index.d.ts +15 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -5
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# @graphql-markdown/logger
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@graphql-markdown/logger)
|
|
4
|
+
[](https://jsr.io/@graphql-markdown/logger)
|
|
4
5
|
[](https://raw.githubusercontent.com/graphql-markdown/graphql-markdown/main/LICENSE)
|
|
5
6
|
[](https://sonarcloud.io/summary/new_code?id=graphql-markdown_logger)
|
|
6
7
|
[](https://sonarcloud.io/summary/new_code?id=graphql-markdown_logger)
|
package/dist/index.d.ts
CHANGED
|
@@ -4,10 +4,21 @@
|
|
|
4
4
|
* @module Logger
|
|
5
5
|
* @packageDocumentation
|
|
6
6
|
*/
|
|
7
|
-
import type { LoggerType
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import type { LoggerType } from "@graphql-markdown/types";
|
|
8
|
+
/**
|
|
9
|
+
* Resolves a module specifier for dynamic `import()` at runtime.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* Inlined from `runtimeModuleSpecifier` in `@graphql-markdown/utils` (logger must not depend on utils).
|
|
13
|
+
* On Deno, bare specifiers are not resolved from inside a JSR package and need a prefix:
|
|
14
|
+
* `@graphql-markdown/*` names get `jsr:`, other bare names get `npm:`.
|
|
15
|
+
*
|
|
16
|
+
* @param name - the module specifier.
|
|
17
|
+
* @returns the specifier to pass to `import()`.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export declare const runtimeModuleSpecifier: (name: string) => string;
|
|
11
22
|
/**
|
|
12
23
|
* Log levels supported by the logger.
|
|
13
24
|
*
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,sBAAsB,SAAU,MAAM,KAAG,MASrD,CAAC;AAKF;;;;;;;GAOG;AACH,oBAAY,QAAQ;IAClB,KAAK,UAAU;IACf,KAAK,UAAU;IACf,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,OAAO,YAAY;IACnB,IAAI,SAAS;CACd;AAED;;;;;;GAMG;AACH,QAAA,MAAM,YAAY,aACN,OAAO,SACV,QAAQ,GAAG,MAAM,OAAO,QAAQ,KACtC,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAM5D,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,qBAAqB,aACf,OAAO,KAChB,UAAU,CAAC,UAAU,CAAC,GAAG,SA4B3B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,MAAM,gBACJ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,KAC5C,OAAO,CAAC,IAAI,CAwCd,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,GAAG,YACL,MAAM,UACR,QAAQ,GAAG,MAAM,OAAO,QAAQ,KACtC,IAGF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE;IACvB,YAAY,EAAE,OAAO,YAAY,CAAC;IAClC,qBAAqB,EAAE,OAAO,qBAAqB,CAAC;CACX,CAAC;AAE5C;;GAEG;AACH,aAAa;eACE,MAAM"}
|
package/dist/index.js
CHANGED
|
@@ -6,8 +6,39 @@
|
|
|
6
6
|
* @module Logger
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
10
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
11
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
12
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return path;
|
|
16
|
+
};
|
|
9
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.__internal = exports.log = exports.Logger = exports.LogLevel = void 0;
|
|
18
|
+
exports.__internal = exports.log = exports.Logger = exports.LogLevel = exports.runtimeModuleSpecifier = void 0;
|
|
19
|
+
/**
|
|
20
|
+
* Resolves a module specifier for dynamic `import()` at runtime.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* Inlined from `runtimeModuleSpecifier` in `@graphql-markdown/utils` (logger must not depend on utils).
|
|
24
|
+
* On Deno, bare specifiers are not resolved from inside a JSR package and need a prefix:
|
|
25
|
+
* `@graphql-markdown/*` names get `jsr:`, other bare names get `npm:`.
|
|
26
|
+
*
|
|
27
|
+
* @param name - the module specifier.
|
|
28
|
+
* @returns the specifier to pass to `import()`.
|
|
29
|
+
*
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
const runtimeModuleSpecifier = (name) => {
|
|
33
|
+
if (!("Deno" in globalThis) ||
|
|
34
|
+
/^(?:\.{1,2}\/|\/|(?:file|http|https|jsr|npm|node|data):)/.test(name)) {
|
|
35
|
+
return name;
|
|
36
|
+
}
|
|
37
|
+
const prefix = name.startsWith("@graphql-markdown/") ? "jsr:" : "npm:";
|
|
38
|
+
return `${prefix}${name}`;
|
|
39
|
+
};
|
|
40
|
+
exports.runtimeModuleSpecifier = runtimeModuleSpecifier;
|
|
41
|
+
const globalScope = globalThis;
|
|
11
42
|
/**
|
|
12
43
|
* Log levels supported by the logger.
|
|
13
44
|
*
|
|
@@ -92,12 +123,13 @@ const resolveLoggerInstance = (instance) => {
|
|
|
92
123
|
*
|
|
93
124
|
*/
|
|
94
125
|
const Logger = async (moduleName) => {
|
|
95
|
-
if (
|
|
126
|
+
if (globalScope.logger?.instance && moduleName === undefined) {
|
|
96
127
|
return;
|
|
97
128
|
}
|
|
98
129
|
let moduleExports;
|
|
99
130
|
if (typeof moduleName === "string" && moduleName !== "") {
|
|
100
|
-
|
|
131
|
+
const specifier = (0, exports.runtimeModuleSpecifier)(moduleName);
|
|
132
|
+
moduleExports = await import(__rewriteRelativeImportExtension(specifier));
|
|
101
133
|
}
|
|
102
134
|
else if (typeof moduleName === "object") {
|
|
103
135
|
moduleExports = moduleName;
|
|
@@ -118,7 +150,7 @@ const Logger = async (moduleName) => {
|
|
|
118
150
|
const callback = getCallbackForLevel(instance, level);
|
|
119
151
|
callback?.apply(this, [message]);
|
|
120
152
|
};
|
|
121
|
-
|
|
153
|
+
globalScope.logger = { instance, _log };
|
|
122
154
|
};
|
|
123
155
|
exports.Logger = Logger;
|
|
124
156
|
/**
|
|
@@ -140,7 +172,7 @@ exports.Logger = Logger;
|
|
|
140
172
|
*/
|
|
141
173
|
const log = (message, level = LogLevel.info) => {
|
|
142
174
|
Promise.resolve((0, exports.Logger)()).catch(() => { });
|
|
143
|
-
|
|
175
|
+
globalScope.logger?._log(message, level);
|
|
144
176
|
};
|
|
145
177
|
exports.log = log;
|
|
146
178
|
/**
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-markdown/logger",
|
|
3
3
|
"homepage": "https://graphql-markdown.dev",
|
|
4
|
-
"description": "GraphQL-Markdown
|
|
4
|
+
"description": "Logger used by the GraphQL-Markdown packages.",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/graphql-markdown/graphql-markdown/issues"
|
|
7
7
|
},
|
|
8
|
-
"version": "1.1.
|
|
8
|
+
"version": "1.1.4",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"build": "tsgo --build",
|
|
42
42
|
"lint": "eslint --config ../../packages/tooling-config/eslint/config.ts \"{src,tests}/**/*.{ts,js,json,gql}\"",
|
|
43
43
|
"lint:fix": "eslint --config ../../packages/tooling-config/eslint/config.ts \"{src,tests}/**/*.{ts,js,json,gql}\" --fix",
|
|
44
|
-
"prettier": "prettier \"{src,tests,assets}/**/*.{ts,js,json,md,gql}\" --check",
|
|
45
|
-
"prettier:fix": "prettier \"{src,tests,assets}/**/*.{ts,js,json,md,gql}\" --write",
|
|
44
|
+
"prettier": "prettier \"{src,tests,assets}/**/*.{ts,js,json,md,gql}\" README.md --check",
|
|
45
|
+
"prettier:fix": "prettier \"{src,tests,assets}/**/*.{ts,js,json,md,gql}\" README.md --write",
|
|
46
46
|
"ts:check": "tsgo --noEmit",
|
|
47
47
|
"test": "vitest run --passWithNoTests",
|
|
48
48
|
"test:unit": "vitest run --passWithNoTests tests/unit",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"test:watch": "vitest --watch"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@graphql-markdown/types": "^1.
|
|
54
|
+
"@graphql-markdown/types": "^1.17.1"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@docusaurus/logger": "*",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"test": "tests"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|
|
64
|
-
"node": ">=22.
|
|
64
|
+
"node": ">=22.18.0"
|
|
65
65
|
},
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"access": "public"
|