@the-docs/plugin-contract 0.0.1-alpha.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.
@@ -0,0 +1,67 @@
1
+ import type { ComponentType } from "react";
2
+ export type JsonValue = null | boolean | number | string | JsonValue[] | {
3
+ [key: string]: JsonValue;
4
+ };
5
+ export type PluginTarget = {
6
+ kind: "code-fence";
7
+ /** Use `*` to handle code fences in every language. */
8
+ language: string;
9
+ } | {
10
+ kind: "asset";
11
+ extensions: readonly string[];
12
+ };
13
+ export type PluginInput = {
14
+ kind: "code-fence";
15
+ language: string;
16
+ content: string;
17
+ documentPath: string;
18
+ } | {
19
+ kind: "asset";
20
+ url: string;
21
+ extension: string;
22
+ content: Uint8Array;
23
+ documentPath: string;
24
+ };
25
+ export interface PluginParseContext {
26
+ /** Allows a build to cancel expensive parsing work. */
27
+ signal?: AbortSignal;
28
+ }
29
+ export interface PluginComponentProps<TModel extends JsonValue> {
30
+ model: TModel;
31
+ }
32
+ export interface ImageRenderOptions {
33
+ format: "png" | "svg" | "webp";
34
+ width?: number;
35
+ height?: number;
36
+ pixelRatio?: number;
37
+ theme?: string;
38
+ }
39
+ export interface GeneratedImage {
40
+ content: Uint8Array;
41
+ mediaType: string;
42
+ width?: number;
43
+ height?: number;
44
+ }
45
+ export interface MdxPlugin<TModel extends JsonValue> {
46
+ id: string;
47
+ version: string;
48
+ /** MDX constructs handled by this plugin. */
49
+ targets: readonly PluginTarget[];
50
+ /** Validate and convert source content into serializable data. */
51
+ parse(input: PluginInput, context: PluginParseContext): Promise<TModel>;
52
+ /** Runtime React renderer, loaded lazily. */
53
+ component: {
54
+ load(): Promise<{
55
+ default: ComponentType<PluginComponentProps<TModel>>;
56
+ }>;
57
+ };
58
+ /** Optional build-time image generation. */
59
+ build?: {
60
+ renderToImage(model: TModel, options: ImageRenderOptions): Promise<GeneratedImage>;
61
+ };
62
+ }
63
+ /**
64
+ * Defines an MDX plugin while preserving its model type for parse and render.
65
+ */
66
+ export declare function defineMdxPlugin<TModel extends JsonValue>(plugin: MdxPlugin<TModel>): MdxPlugin<TModel>;
67
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAE1C,MAAM,MAAM,SAAS,GACjB,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,EAAE,GACX;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAA;AAEhC,MAAM,MAAM,YAAY,GACpB;IACE,IAAI,EAAE,YAAY,CAAA;IAClB,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAA;CACjB,GACD;IACE,IAAI,EAAE,OAAO,CAAA;IACb,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;CAC9B,CAAA;AAEL,MAAM,MAAM,WAAW,GACnB;IACE,IAAI,EAAE,YAAY,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;CACrB,GACD;IACE,IAAI,EAAE,OAAO,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,UAAU,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAEL,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED,MAAM,WAAW,oBAAoB,CAAC,MAAM,SAAS,SAAS;IAC5D,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAA;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,UAAU,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,SAAS,CAAC,MAAM,SAAS,SAAS;IACjD,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IAEf,6CAA6C;IAC7C,OAAO,EAAE,SAAS,YAAY,EAAE,CAAA;IAEhC,kEAAkE;IAClE,KAAK,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAEvE,6CAA6C;IAC7C,SAAS,EAAE;QACT,IAAI,IAAI,OAAO,CAAC;YACd,OAAO,EAAE,aAAa,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAA;SACrD,CAAC,CAAA;KACH,CAAA;IAED,4CAA4C;IAC5C,KAAK,CAAC,EAAE;QACN,aAAa,CACX,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,cAAc,CAAC,CAAA;KAC3B,CAAA;CACF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,SAAS,SAAS,EACtD,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,GACxB,SAAS,CAAC,MAAM,CAAC,CAEnB"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Defines an MDX plugin while preserving its model type for parse and render.
3
+ */
4
+ export function defineMdxPlugin(plugin) {
5
+ return plugin;
6
+ }
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsFA;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAyB;IAEzB,OAAO,MAAM,CAAA;AACf,CAAC"}
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@the-docs/plugin-contract",
3
+ "version": "0.0.1-alpha.4",
4
+ "type": "module",
5
+ "peerDependencies": {
6
+ "react": "^19.2.6"
7
+ },
8
+ "devDependencies": {
9
+ "@types/react": "^19",
10
+ "react": "^19.2.6",
11
+ "typescript": "^6"
12
+ },
13
+ "exports": {
14
+ ".": "./dist/index.js"
15
+ },
16
+ "description": "The Docs plugin contract",
17
+ "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/thspacecode/the-docs.git",
21
+ "directory": "packages/plugin-contract"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "files": [
27
+ "dist"
28
+ ],
29
+ "scripts": {
30
+ "build": "rm -rf dist && tsc -p tsconfig.json --noEmit false --declaration --declarationMap --sourceMap --outDir dist --rootDir src --allowImportingTsExtensions false && node ../../scripts/copy-package-assets.mjs",
31
+ "format": "prettier --write \"**/*.{ts,tsx}\"",
32
+ "typecheck": "tsc --noEmit"
33
+ }
34
+ }