@graphql-markdown/core 1.17.2 → 1.18.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/dist/event-emitter.d.ts +2 -2
- package/dist/event-emitter.d.ts.map +1 -1
- package/dist/event-emitter.js +20 -12
- package/dist/event-handlers.d.ts.map +1 -1
- package/dist/event-handlers.js +9 -3
- package/dist/event-map.d.ts +4 -0
- package/dist/event-map.d.ts.map +1 -1
- package/dist/event-map.js +5 -0
- package/dist/events/base.d.ts +2 -2
- package/dist/events/base.d.ts.map +1 -1
- package/dist/events/index.d.ts +3 -0
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +6 -1
- package/dist/generator.d.ts +12 -0
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js +42 -13
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/printer.d.ts +2 -2
- package/dist/printer.d.ts.map +1 -1
- package/dist/printer.js +2 -2
- package/dist/renderer.js +1 -1
- package/package.json +9 -9
package/dist/event-emitter.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ICancellableEvent, PrinterEvent } from "@graphql-markdown/types";
|
|
3
3
|
/**
|
|
4
4
|
* Result object returned when emitting a cancellable event.
|
|
5
5
|
*
|
|
@@ -61,7 +61,7 @@ declare class CancellableEventEmitter extends EventEmitter {
|
|
|
61
61
|
* }
|
|
62
62
|
* ```
|
|
63
63
|
*/
|
|
64
|
-
emitAsync(eventName: string, event:
|
|
64
|
+
emitAsync(eventName: string, event: ICancellableEvent | PrinterEvent): Promise<EmitResult>;
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Get the singleton event emitter instance.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-emitter.d.ts","sourceRoot":"","sources":["../src/event-emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"event-emitter.d.ts","sourceRoot":"","sources":["../src/event-emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE/E;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,MAAM,EAAE,KAAK,EAAE,CAAC;IAEhB;;;OAGG;IACH,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;GAUG;AACH,cAAM,uBAAwB,SAAQ,YAAY;IAChD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACG,SAAS,CACb,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,iBAAiB,GAAG,YAAY,GACtC,OAAO,CAAC,UAAU,CAAC,CAiDrB;CACF;AAQD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,SAAS,+BAGrB,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,WAAW,YAKvB,CAAC"}
|
package/dist/event-emitter.js
CHANGED
|
@@ -50,15 +50,17 @@ class CancellableEventEmitter extends node_events_1.EventEmitter {
|
|
|
50
50
|
const errors = [];
|
|
51
51
|
// Get all registered listeners for this event
|
|
52
52
|
const listeners = this.listeners(eventName);
|
|
53
|
+
// Check if event is a full cancellable event (has propagationStopped property)
|
|
54
|
+
const isCancellable = "propagationStopped" in event;
|
|
53
55
|
// Execute each handler sequentially
|
|
54
56
|
for (const listener of listeners) {
|
|
55
57
|
try {
|
|
56
58
|
// Call the handler - await to support async handlers
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
});
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
60
|
+
await listener(event);
|
|
60
61
|
// Check if handler stopped propagation to remaining handlers
|
|
61
|
-
if (
|
|
62
|
+
if (isCancellable &&
|
|
63
|
+
event.propagationStopped) {
|
|
62
64
|
break; // Exit the loop, skipping remaining handlers
|
|
63
65
|
}
|
|
64
66
|
}
|
|
@@ -68,15 +70,21 @@ class CancellableEventEmitter extends node_events_1.EventEmitter {
|
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
// Execute default action if not prevented and event has one
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
if ("runDefaultAction" in event) {
|
|
74
|
+
try {
|
|
75
|
+
// Call defaultAction - await to support async
|
|
76
|
+
await event.runDefaultAction();
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
// Collect error from default action
|
|
80
|
+
errors.push(error instanceof Error ? error : new Error(String(error)));
|
|
81
|
+
}
|
|
78
82
|
}
|
|
79
|
-
|
|
83
|
+
// Check defaultPrevented - simple events may have this property
|
|
84
|
+
const defaultPrevented = "defaultPrevented" in event
|
|
85
|
+
? !!event.defaultPrevented
|
|
86
|
+
: false;
|
|
87
|
+
return { errors, defaultPrevented };
|
|
80
88
|
}
|
|
81
89
|
}
|
|
82
90
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-handlers.d.ts","sourceRoot":"","sources":["../src/event-handlers.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,wBAAwB,
|
|
1
|
+
{"version":3,"file":"event-handlers.d.ts","sourceRoot":"","sources":["../src/event-handlers.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,wBAAwB,8BAwCpC,CAAC"}
|
package/dist/event-handlers.js
CHANGED
|
@@ -40,12 +40,18 @@ const registerMDXEventHandlers = (mdxModule) => {
|
|
|
40
40
|
(0, event_emitter_1.resetEvents)(); // reset event to avoid duplicate registrations
|
|
41
41
|
const events = (0, event_emitter_1.getEvents)();
|
|
42
42
|
const registeredHandlers = new Set();
|
|
43
|
+
// Get the actual module object, handling ESM default export wrapping
|
|
44
|
+
// When using dynamic import() on a CommonJS module, exports may be under .default
|
|
45
|
+
const module = mdxModule;
|
|
46
|
+
const effectiveModule = module.default && typeof module.default === "object"
|
|
47
|
+
? module.default
|
|
48
|
+
: module;
|
|
43
49
|
// Iterate through event callback mappings (lifecycle hooks only)
|
|
44
50
|
for (const [eventName, callbackName] of Object.entries(event_map_1.EVENT_CALLBACK_MAP)) {
|
|
45
51
|
// Check if mdxModule has this callback function
|
|
46
|
-
if (callbackName in
|
|
47
|
-
typeof
|
|
48
|
-
const mdxFunction =
|
|
52
|
+
if (callbackName in effectiveModule &&
|
|
53
|
+
typeof effectiveModule[callbackName] === "function") {
|
|
54
|
+
const mdxFunction = effectiveModule[callbackName];
|
|
49
55
|
events.on(eventName, mdxFunction);
|
|
50
56
|
registeredHandlers.add(callbackName);
|
|
51
57
|
}
|
package/dist/event-map.d.ts
CHANGED
|
@@ -18,5 +18,9 @@ export declare const EVENT_CALLBACK_MAP: {
|
|
|
18
18
|
readonly "render:afterRenderTypeEntities": "afterRenderTypeEntitiesHook";
|
|
19
19
|
readonly "render:beforeGenerateIndexMetafile": "beforeGenerateIndexMetafileHook";
|
|
20
20
|
readonly "render:afterGenerateIndexMetafile": "afterGenerateIndexMetafileHook";
|
|
21
|
+
readonly "print:beforePrintCode": "beforePrintCodeHook";
|
|
22
|
+
readonly "print:afterPrintCode": "afterPrintCodeHook";
|
|
23
|
+
readonly "print:beforePrintType": "beforePrintTypeHook";
|
|
24
|
+
readonly "print:afterPrintType": "afterPrintTypeHook";
|
|
21
25
|
};
|
|
22
26
|
//# sourceMappingURL=event-map.d.ts.map
|
package/dist/event-map.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-map.d.ts","sourceRoot":"","sources":["../src/event-map.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"event-map.d.ts","sourceRoot":"","sources":["../src/event-map.ts"],"names":[],"mappings":"AAgBA;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;CAmBrB,CAAC"}
|
package/dist/event-map.js
CHANGED
|
@@ -15,6 +15,7 @@ const render_root_types_events_1 = require("./events/render-root-types-events");
|
|
|
15
15
|
const render_homepage_events_1 = require("./events/render-homepage-events");
|
|
16
16
|
const render_type_entities_events_1 = require("./events/render-type-entities-events");
|
|
17
17
|
const generate_index_metafile_events_1 = require("./events/generate-index-metafile-events");
|
|
18
|
+
const print_type_events_1 = require("./events/print-type-events");
|
|
18
19
|
/**
|
|
19
20
|
* Event callback mapping configuration.
|
|
20
21
|
* Maps event names to their corresponding callback names in mdxModule.
|
|
@@ -35,4 +36,8 @@ exports.EVENT_CALLBACK_MAP = {
|
|
|
35
36
|
[render_type_entities_events_1.RenderTypeEntitiesEvents.AFTER_RENDER]: "afterRenderTypeEntitiesHook",
|
|
36
37
|
[generate_index_metafile_events_1.GenerateIndexMetafileEvents.BEFORE_GENERATE]: "beforeGenerateIndexMetafileHook",
|
|
37
38
|
[generate_index_metafile_events_1.GenerateIndexMetafileEvents.AFTER_GENERATE]: "afterGenerateIndexMetafileHook",
|
|
39
|
+
[print_type_events_1.PrintTypeEvents.BEFORE_PRINT_CODE]: "beforePrintCodeHook",
|
|
40
|
+
[print_type_events_1.PrintTypeEvents.AFTER_PRINT_CODE]: "afterPrintCodeHook",
|
|
41
|
+
[print_type_events_1.PrintTypeEvents.BEFORE_PRINT_TYPE]: "beforePrintTypeHook",
|
|
42
|
+
[print_type_events_1.PrintTypeEvents.AFTER_PRINT_TYPE]: "afterPrintTypeHook",
|
|
38
43
|
};
|
package/dist/events/base.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
|
-
import type { DefaultAction } from "@graphql-markdown/types";
|
|
6
|
+
import type { DefaultAction, ICancellableEvent } from "@graphql-markdown/types";
|
|
7
7
|
/**
|
|
8
8
|
* Deep freezes an object to make it immutable at runtime.
|
|
9
9
|
* Recursively freezes all nested objects and arrays.
|
|
@@ -34,7 +34,7 @@ export interface CancellableEventOptions {
|
|
|
34
34
|
*
|
|
35
35
|
* @category Events
|
|
36
36
|
*/
|
|
37
|
-
export declare abstract class CancellableEvent {
|
|
37
|
+
export declare abstract class CancellableEvent implements ICancellableEvent {
|
|
38
38
|
/**
|
|
39
39
|
* Whether the default action has been prevented.
|
|
40
40
|
* Set to true when preventDefault() is called.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/events/base.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/events/base.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEhF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,+CAc3B,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACtC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;;;GAUG;AACH,8BAAsB,gBAAiB,YAAW,iBAAiB;IACjE;;;OAGG;IACH,OAAO,CAAC,iBAAiB,CAAS;IAElC;;;OAGG;IACH,OAAO,CAAC,mBAAmB,CAAS;IAEpC;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAU;IAEvC;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAgB;IAEhD;;;;;;OAMG;IACH,YAAY,OAAO,CAAC,EAAE,uBAAuB,EAG5C;IAED;;OAEG;IACH,IAAI,gBAAgB,IAAI,OAAO,CAE9B;IAED;;OAEG;IACH,IAAI,kBAAkB,IAAI,OAAO,CAEhC;IAED;;OAEG;IACH,IAAI,aAAa,IAAI,aAAa,GAAG,SAAS,CAE7C;IAED;;;;;;;;;;;;;OAaG;IACH,cAAc,IAAI,IAAI,CAIrB;IAED;;;;;;;;;;;;OAYG;IACH,eAAe,IAAI,IAAI,CAEtB;IAED;;;;;;;;;OASG;IACG,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAKtC;CACF"}
|
package/dist/events/index.d.ts
CHANGED
|
@@ -10,10 +10,13 @@ export { RenderRootTypesEvents } from "./render-root-types-events";
|
|
|
10
10
|
export { RenderHomepageEvents } from "./render-homepage-events";
|
|
11
11
|
export { RenderTypeEntitiesEvents } from "./render-type-entities-events";
|
|
12
12
|
export { GenerateIndexMetafileEvents } from "./generate-index-metafile-events";
|
|
13
|
+
export { PrintTypeEvents } from "./print-type-events";
|
|
13
14
|
export { SchemaEvent } from "./schema-load";
|
|
14
15
|
export { DiffCheckEvent } from "./diff-check";
|
|
15
16
|
export { RenderRootTypesEvent } from "./render-root-types";
|
|
16
17
|
export { RenderHomepageEvent } from "./render-homepage";
|
|
17
18
|
export { RenderTypeEntitiesEvent } from "./render-type-entities";
|
|
18
19
|
export { GenerateIndexMetafileEvent } from "./generate-index-metafile";
|
|
20
|
+
export { PrintCodeEvent, PrintTypeEvent } from "./print-type";
|
|
21
|
+
export type { PrintCodeEventData, PrintTypeEventData } from "./print-type";
|
|
19
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGtD,OAAO,EAAE,YAAY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,MAAM,cAAc,CAAC"}
|
package/dist/events/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @packageDocumentation
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.GenerateIndexMetafileEvent = exports.RenderTypeEntitiesEvent = exports.RenderHomepageEvent = exports.RenderRootTypesEvent = exports.DiffCheckEvent = exports.SchemaEvent = exports.GenerateIndexMetafileEvents = exports.RenderTypeEntitiesEvents = exports.RenderHomepageEvents = exports.RenderRootTypesEvents = exports.DiffEvents = exports.SchemaEvents = exports.deepFreeze = exports.CancellableEvent = void 0;
|
|
8
|
+
exports.PrintTypeEvent = exports.PrintCodeEvent = exports.GenerateIndexMetafileEvent = exports.RenderTypeEntitiesEvent = exports.RenderHomepageEvent = exports.RenderRootTypesEvent = exports.DiffCheckEvent = exports.SchemaEvent = exports.PrintTypeEvents = exports.GenerateIndexMetafileEvents = exports.RenderTypeEntitiesEvents = exports.RenderHomepageEvents = exports.RenderRootTypesEvents = exports.DiffEvents = exports.SchemaEvents = exports.deepFreeze = exports.CancellableEvent = void 0;
|
|
9
9
|
// Base
|
|
10
10
|
const base_1 = require("./base");
|
|
11
11
|
Object.defineProperty(exports, "CancellableEvent", { enumerable: true, get: function () { return base_1.CancellableEvent; } });
|
|
@@ -23,6 +23,8 @@ const render_type_entities_events_1 = require("./render-type-entities-events");
|
|
|
23
23
|
Object.defineProperty(exports, "RenderTypeEntitiesEvents", { enumerable: true, get: function () { return render_type_entities_events_1.RenderTypeEntitiesEvents; } });
|
|
24
24
|
const generate_index_metafile_events_1 = require("./generate-index-metafile-events");
|
|
25
25
|
Object.defineProperty(exports, "GenerateIndexMetafileEvents", { enumerable: true, get: function () { return generate_index_metafile_events_1.GenerateIndexMetafileEvents; } });
|
|
26
|
+
const print_type_events_1 = require("./print-type-events");
|
|
27
|
+
Object.defineProperty(exports, "PrintTypeEvents", { enumerable: true, get: function () { return print_type_events_1.PrintTypeEvents; } });
|
|
26
28
|
// Event classes
|
|
27
29
|
const schema_load_1 = require("./schema-load");
|
|
28
30
|
Object.defineProperty(exports, "SchemaEvent", { enumerable: true, get: function () { return schema_load_1.SchemaEvent; } });
|
|
@@ -36,3 +38,6 @@ const render_type_entities_1 = require("./render-type-entities");
|
|
|
36
38
|
Object.defineProperty(exports, "RenderTypeEntitiesEvent", { enumerable: true, get: function () { return render_type_entities_1.RenderTypeEntitiesEvent; } });
|
|
37
39
|
const generate_index_metafile_1 = require("./generate-index-metafile");
|
|
38
40
|
Object.defineProperty(exports, "GenerateIndexMetafileEvent", { enumerable: true, get: function () { return generate_index_metafile_1.GenerateIndexMetafileEvent; } });
|
|
41
|
+
const print_type_1 = require("./print-type");
|
|
42
|
+
Object.defineProperty(exports, "PrintCodeEvent", { enumerable: true, get: function () { return print_type_1.PrintCodeEvent; } });
|
|
43
|
+
Object.defineProperty(exports, "PrintTypeEvent", { enumerable: true, get: function () { return print_type_1.PrintTypeEvent; } });
|
package/dist/generator.d.ts
CHANGED
|
@@ -30,6 +30,18 @@ export declare const FILE_EXTENSION: {
|
|
|
30
30
|
* @internal
|
|
31
31
|
*/
|
|
32
32
|
export declare const loadMDXModule: (mdxParser: Maybe<string | PackageName>) => Promise<unknown>;
|
|
33
|
+
/**
|
|
34
|
+
* Gets a property from an MDX module, checking both the module directly and `module.default`.
|
|
35
|
+
*
|
|
36
|
+
* This handles the differences between ESM and CommonJS module exports when dynamically importing.
|
|
37
|
+
*
|
|
38
|
+
* @param mdxModule - The loaded MDX module
|
|
39
|
+
* @param propertyName - The name of the property to extract
|
|
40
|
+
* @returns The property value if found, otherwise undefined
|
|
41
|
+
*
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
export declare const getMDXModuleProperty: <T>(mdxModule: unknown, propertyName: string) => T | undefined;
|
|
33
45
|
/**
|
|
34
46
|
* Extracts a formatter from an MDX module.
|
|
35
47
|
*
|
package/dist/generator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAEV,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,WAAW,EAEX,cAAc,EAEf,MAAM,yBAAyB,CAAC;AA+BjC;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;CAGjB,CAAC;AAgBX;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAEV,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,WAAW,EAEX,cAAc,EAEf,MAAM,yBAAyB,CAAC;AA+BjC;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;CAGjB,CAAC;AAgBX;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,8DAczB,CAAC;AAgBF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,4DAsBrC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB,yEAkDrC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,6FAe7B,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB,wHAgBlC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B,qKA0BxC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,qUAuNjC,CAAC"}
|
package/dist/generator.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.generateDocFromSchema = exports.resolveSkipAndOnlyDirectives = exports.checkSchemaDifferences = exports.loadGraphqlSchema = exports.getFormatterFromMDXModule = exports.loadMDXModule = exports.FILE_EXTENSION = void 0;
|
|
36
|
+
exports.generateDocFromSchema = exports.resolveSkipAndOnlyDirectives = exports.checkSchemaDifferences = exports.loadGraphqlSchema = exports.getFormatterFromMDXModule = exports.getMDXModuleProperty = exports.loadMDXModule = exports.FILE_EXTENSION = void 0;
|
|
37
37
|
const logger_1 = __importStar(require("@graphql-markdown/logger"));
|
|
38
38
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
39
39
|
const utils_1 = require("@graphql-markdown/utils");
|
|
@@ -80,8 +80,9 @@ const SEC_DECIMALS = 3;
|
|
|
80
80
|
*/
|
|
81
81
|
const loadMDXModule = async (mdxParser) => {
|
|
82
82
|
return mdxParser !== undefined && mdxParser !== null
|
|
83
|
-
? Promise.resolve(`${mdxParser}`).then(s => __importStar(require(s))).catch(() => {
|
|
84
|
-
|
|
83
|
+
? Promise.resolve(`${mdxParser}`).then(s => __importStar(require(s))).catch((error) => {
|
|
84
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
85
|
+
(0, logger_1.log)(`An error occurred while loading MDX formatter "${mdxParser}": ${errorMessage}`, logger_1.LogLevel.warn);
|
|
85
86
|
return undefined;
|
|
86
87
|
})
|
|
87
88
|
: undefined;
|
|
@@ -100,6 +101,34 @@ const FORMATTER_FUNCTION_NAMES = [
|
|
|
100
101
|
"formatMDXNameEntity",
|
|
101
102
|
"formatMDXSpecifiedByLink",
|
|
102
103
|
];
|
|
104
|
+
/**
|
|
105
|
+
* Gets a property from an MDX module, checking both the module directly and `module.default`.
|
|
106
|
+
*
|
|
107
|
+
* This handles the differences between ESM and CommonJS module exports when dynamically importing.
|
|
108
|
+
*
|
|
109
|
+
* @param mdxModule - The loaded MDX module
|
|
110
|
+
* @param propertyName - The name of the property to extract
|
|
111
|
+
* @returns The property value if found, otherwise undefined
|
|
112
|
+
*
|
|
113
|
+
* @internal
|
|
114
|
+
*/
|
|
115
|
+
const getMDXModuleProperty = (mdxModule, propertyName) => {
|
|
116
|
+
if (!mdxModule || typeof mdxModule !== "object") {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
const module = mdxModule;
|
|
120
|
+
// Check for property directly on the module
|
|
121
|
+
if (propertyName in module) {
|
|
122
|
+
return module[propertyName];
|
|
123
|
+
}
|
|
124
|
+
// Check for property on module.default (ESM default export)
|
|
125
|
+
const defaultExport = module.default;
|
|
126
|
+
if (defaultExport && propertyName in defaultExport) {
|
|
127
|
+
return defaultExport[propertyName];
|
|
128
|
+
}
|
|
129
|
+
return undefined;
|
|
130
|
+
};
|
|
131
|
+
exports.getMDXModuleProperty = getMDXModuleProperty;
|
|
103
132
|
/**
|
|
104
133
|
* Extracts a formatter from an MDX module.
|
|
105
134
|
*
|
|
@@ -246,11 +275,13 @@ exports.resolveSkipAndOnlyDirectives = resolveSkipAndOnlyDirectives;
|
|
|
246
275
|
*/
|
|
247
276
|
const generateDocFromSchema = async ({ baseURL, customDirective, diffMethod, docOptions, force, groupByDirective, homepageLocation, linkRoot, loaders: loadersList, loggerModule, mdxParser, metatags, onlyDocDirective, outputDir, prettify, printer: printerModule, printTypeOptions, schemaLocation, skipDocDirective, tmpDir, }) => {
|
|
248
277
|
const start = process.hrtime.bigint();
|
|
249
|
-
const events = (0, event_emitter_1.getEvents)();
|
|
250
278
|
await (0, logger_1.default)(loggerModule);
|
|
251
279
|
const mdxModule = await (0, exports.loadMDXModule)(mdxParser);
|
|
252
280
|
// Register MDX lifecycle event handlers if mdxModule loaded successfully
|
|
281
|
+
// This must be called BEFORE getEvents() because it resets the singleton
|
|
253
282
|
(0, event_handlers_1.registerMDXEventHandlers)(mdxModule);
|
|
283
|
+
// Get events AFTER registration (registerMDXEventHandlers resets and recreates the singleton)
|
|
284
|
+
const events = (0, event_emitter_1.getEvents)();
|
|
254
285
|
await events.emitAsync(events_1.SchemaEvents.BEFORE_LOAD, new events_1.SchemaEvent({
|
|
255
286
|
schemaLocation: schemaLocation,
|
|
256
287
|
}));
|
|
@@ -278,9 +309,7 @@ const generateDocFromSchema = async ({ baseURL, customDirective, diffMethod, doc
|
|
|
278
309
|
// Extract formatter from the MDX module (for direct function calls)
|
|
279
310
|
const formatter = (0, exports.getFormatterFromMDXModule)(mdxModule, docOptions);
|
|
280
311
|
// Extract mdxDeclaration from the MDX module (if available)
|
|
281
|
-
const mdxDeclaration =
|
|
282
|
-
? mdxModule.mdxDeclaration
|
|
283
|
-
: undefined;
|
|
312
|
+
const mdxDeclaration = (0, exports.getMDXModuleProperty)(mdxModule, "mdxDeclaration");
|
|
284
313
|
const printer = await (0, printer_1.getPrinter)(
|
|
285
314
|
// module mandatory
|
|
286
315
|
printerModule,
|
|
@@ -302,14 +331,14 @@ const generateDocFromSchema = async ({ baseURL, customDirective, diffMethod, doc
|
|
|
302
331
|
onlyDocDirectives,
|
|
303
332
|
printTypeOptions,
|
|
304
333
|
skipDocDirectives,
|
|
305
|
-
}, formatter, mdxDeclaration
|
|
334
|
+
}, formatter, mdxDeclaration,
|
|
335
|
+
// Pass event emitter to enable print events
|
|
336
|
+
events);
|
|
306
337
|
// allow mdxModule to specify custom extension
|
|
338
|
+
const mdxExtensionFromModule = (0, exports.getMDXModuleProperty)(mdxModule, "mdxExtension");
|
|
307
339
|
let mdxExtension;
|
|
308
|
-
if (
|
|
309
|
-
|
|
310
|
-
"mdxExtension" in mdxModule) {
|
|
311
|
-
mdxExtension = mdxModule
|
|
312
|
-
.mdxExtension;
|
|
340
|
+
if (mdxExtensionFromModule) {
|
|
341
|
+
mdxExtension = mdxExtensionFromModule;
|
|
313
342
|
}
|
|
314
343
|
else if (mdxModule) {
|
|
315
344
|
mdxExtension = exports.FILE_EXTENSION.MDX;
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export { RenderRootTypesEvents } from "./events/render-root-types-events";
|
|
|
12
12
|
export { RenderHomepageEvents } from "./events/render-homepage-events";
|
|
13
13
|
export { RenderTypeEntitiesEvents } from "./events/render-type-entities-events";
|
|
14
14
|
export { GenerateIndexMetafileEvents } from "./events/generate-index-metafile-events";
|
|
15
|
+
export { PrintTypeEvents } from "./events/print-type-events";
|
|
15
16
|
export type { CancellableEvent } from "./events/base";
|
|
16
17
|
export type { SchemaEvent as SchemaLoadEvent } from "./events/schema-load";
|
|
17
18
|
export type { DiffCheckEvent } from "./events/diff-check";
|
|
@@ -19,4 +20,5 @@ export type { RenderRootTypesEvent } from "./events/render-root-types";
|
|
|
19
20
|
export type { RenderHomepageEvent } from "./events/render-homepage";
|
|
20
21
|
export type { RenderTypeEntitiesEvent } from "./events/render-type-entities";
|
|
21
22
|
export type { GenerateIndexMetafileEvent } from "./events/generate-index-metafile";
|
|
23
|
+
export type { PrintCodeEvent, PrintCodeEventData, PrintTypeEvent, PrintTypeEventData, } from "./events/print-type";
|
|
22
24
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGvC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,qB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AAE,MAAM,+BAA+B,CAAC;AAC7E,YAAY,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AACnF,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,kBAAkB,GACnB,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/* istanbul ignore file */
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.GenerateIndexMetafileEvents = exports.RenderTypeEntitiesEvents = exports.RenderHomepageEvents = exports.RenderRootTypesEvents = exports.DiffEvents = exports.SchemaEvents = exports.EVENT_CALLBACK_MAP = exports.registerMDXEventHandlers = exports.resetEvents = exports.getEvents = exports.buildConfig = exports.generateDocFromSchema = void 0;
|
|
7
|
+
exports.PrintTypeEvents = exports.GenerateIndexMetafileEvents = exports.RenderTypeEntitiesEvents = exports.RenderHomepageEvents = exports.RenderRootTypesEvents = exports.DiffEvents = exports.SchemaEvents = exports.EVENT_CALLBACK_MAP = exports.registerMDXEventHandlers = exports.resetEvents = exports.getEvents = exports.buildConfig = exports.generateDocFromSchema = void 0;
|
|
8
8
|
const generator_1 = require("./generator");
|
|
9
9
|
Object.defineProperty(exports, "generateDocFromSchema", { enumerable: true, get: function () { return generator_1.generateDocFromSchema; } });
|
|
10
10
|
const config_1 = require("./config");
|
|
@@ -30,3 +30,5 @@ const render_type_entities_events_1 = require("./events/render-type-entities-eve
|
|
|
30
30
|
Object.defineProperty(exports, "RenderTypeEntitiesEvents", { enumerable: true, get: function () { return render_type_entities_events_1.RenderTypeEntitiesEvents; } });
|
|
31
31
|
const generate_index_metafile_events_1 = require("./events/generate-index-metafile-events");
|
|
32
32
|
Object.defineProperty(exports, "GenerateIndexMetafileEvents", { enumerable: true, get: function () { return generate_index_metafile_events_1.GenerateIndexMetafileEvents; } });
|
|
33
|
+
const print_type_events_1 = require("./events/print-type-events");
|
|
34
|
+
Object.defineProperty(exports, "PrintTypeEvents", { enumerable: true, get: function () { return print_type_events_1.PrintTypeEvents; } });
|
package/dist/printer.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This module provides the functionality to load and initialize a printer for GraphQL schema documentation.
|
|
5
5
|
* It dynamically imports a printer module and configures it with the provided schema and options.
|
|
6
6
|
*/
|
|
7
|
-
import type { Formatter, IPrinter, Maybe, PackageName, PrinterConfig, PrinterOptions } from "@graphql-markdown/types";
|
|
7
|
+
import type { Formatter, IPrinter, Maybe, PackageName, PrinterConfig, PrinterEventEmitter, PrinterOptions } from "@graphql-markdown/types";
|
|
8
8
|
/**
|
|
9
9
|
* Loads and initializes a printer module for GraphQL schema documentation.
|
|
10
10
|
*
|
|
@@ -49,5 +49,5 @@ import type { Formatter, IPrinter, Maybe, PackageName, PrinterConfig, PrinterOpt
|
|
|
49
49
|
* const output = printer.printSchema();
|
|
50
50
|
* ```
|
|
51
51
|
*/
|
|
52
|
-
export declare const getPrinter: (printerModule?: Maybe<PackageName>, config?: Maybe<PrinterConfig>, options?: Maybe<PrinterOptions>, formatter?: Partial<Formatter> | undefined, mdxDeclaration?: Maybe<string>) => Promise<typeof IPrinter>;
|
|
52
|
+
export declare const getPrinter: (printerModule?: Maybe<PackageName>, config?: Maybe<PrinterConfig>, options?: Maybe<PrinterOptions>, formatter?: Partial<Formatter> | undefined, mdxDeclaration?: Maybe<string>, eventEmitter?: Maybe<PrinterEventEmitter>) => Promise<typeof IPrinter>;
|
|
53
53
|
//# sourceMappingURL=printer.d.ts.map
|
package/dist/printer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../src/printer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EACR,KAAK,EACL,WAAW,EAEX,aAAa,EACb,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../src/printer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EACR,KAAK,EACL,WAAW,EAEX,aAAa,EACb,mBAAmB,EACnB,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,eAAO,MAAM,UAAU,yPAoCtB,CAAC"}
|
package/dist/printer.js
CHANGED
|
@@ -78,7 +78,7 @@ exports.getPrinter = void 0;
|
|
|
78
78
|
* const output = printer.printSchema();
|
|
79
79
|
* ```
|
|
80
80
|
*/
|
|
81
|
-
const getPrinter = async (printerModule, config, options, formatter, mdxDeclaration) => {
|
|
81
|
+
const getPrinter = async (printerModule, config, options, formatter, mdxDeclaration, eventEmitter) => {
|
|
82
82
|
if (typeof printerModule !== "string") {
|
|
83
83
|
throw new TypeError("Invalid printer module name.");
|
|
84
84
|
}
|
|
@@ -88,7 +88,7 @@ const getPrinter = async (printerModule, config, options, formatter, mdxDeclarat
|
|
|
88
88
|
try {
|
|
89
89
|
const { Printer } = await Promise.resolve(`${printerModule}`).then(s => __importStar(require(s)));
|
|
90
90
|
const { schema, baseURL, linkRoot } = config;
|
|
91
|
-
await Printer.init(schema, baseURL, linkRoot, { ...options }, formatter, mdxDeclaration);
|
|
91
|
+
await Printer.init(schema, baseURL, linkRoot, { ...options }, formatter, mdxDeclaration, eventEmitter);
|
|
92
92
|
return Printer;
|
|
93
93
|
}
|
|
94
94
|
catch {
|
package/dist/renderer.js
CHANGED
|
@@ -454,7 +454,7 @@ class Renderer {
|
|
|
454
454
|
return this.formatCategoryFolderName(categoryName, false);
|
|
455
455
|
},
|
|
456
456
|
};
|
|
457
|
-
content = this.printer.printType(fileName, type, printOptions);
|
|
457
|
+
content = await this.printer.printType(fileName, type, printOptions);
|
|
458
458
|
if (typeof content !== "string" || content === "") {
|
|
459
459
|
(0, logger_1.log)(`No content generated for "${name}" - printType returned empty`, logger_1.LogLevel.warn);
|
|
460
460
|
return undefined;
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/graphql-markdown/graphql-markdown/issues"
|
|
7
7
|
},
|
|
8
|
-
"version": "1.
|
|
8
|
+
"version": "1.18.0",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -63,18 +63,18 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@fastify/deepmerge": "^3.2.0",
|
|
66
|
-
"@graphql-markdown/graphql": "
|
|
67
|
-
"@graphql-markdown/logger": "
|
|
68
|
-
"@graphql-markdown/utils": "
|
|
66
|
+
"@graphql-markdown/graphql": "workspace:^",
|
|
67
|
+
"@graphql-markdown/logger": "workspace:^",
|
|
68
|
+
"@graphql-markdown/utils": "workspace:^"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
|
-
"@graphql-markdown/diff": "
|
|
72
|
-
"@graphql-markdown/helpers": "
|
|
73
|
-
"@graphql-markdown/printer-legacy": "
|
|
74
|
-
"graphql-config": "
|
|
71
|
+
"@graphql-markdown/diff": "workspace:^",
|
|
72
|
+
"@graphql-markdown/helpers": "workspace:^",
|
|
73
|
+
"@graphql-markdown/printer-legacy": "workspace:^",
|
|
74
|
+
"graphql-config": "catalog:"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@graphql-markdown/types": "
|
|
77
|
+
"@graphql-markdown/types": "workspace:^"
|
|
78
78
|
},
|
|
79
79
|
"peerDependenciesMeta": {
|
|
80
80
|
"@graphql-markdown/printer-legacy": {
|