Migrate types to use @quartz-community/types exports

Replace ambient quartz-compat.d.ts and quartz-community.d.ts
declarations with direct imports from @quartz-community/types.
Export GraphOptions and D3Config from local component files instead
of ambient module augmentation.
This commit is contained in:
saberzero1 2026-02-13 13:18:34 +01:00
parent 768a983440
commit 256aa325b8
No known key found for this signature in database
9 changed files with 36 additions and 194 deletions

35
package-lock.json generated
View file

@ -9,7 +9,7 @@
"version": "0.1.0",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "github:quartz-community/types",
"@quartz-community/types": "file:../types",
"@quartz-community/utils": "github:quartz-community/utils"
},
"devDependencies": {
@ -43,6 +43,26 @@
}
}
},
"../types": {
"name": "@quartz-community/types",
"version": "0.2.0",
"license": "MIT",
"dependencies": {
"@types/hast": "^3.0.4",
"@types/mdast": "^4.0.4",
"preact": "^10.26.5",
"unified": "^11.0.5",
"vfile": "^6.0.3"
},
"devDependencies": {
"tsup": "^8.5.0",
"typescript": "^5.9.3"
},
"engines": {
"node": ">=22",
"npm": ">=10.9.2"
}
},
"node_modules/@esbuild/aix-ppc64": {
"version": "0.27.3",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.3.tgz",
@ -712,16 +732,8 @@
}
},
"node_modules/@quartz-community/types": {
"version": "0.2.0",
"resolved": "git+ssh://git@github.com/quartz-community/types.git#9b8fbbdec4a629f3b62885b0a6d7c31a40875c1c",
"license": "MIT",
"dependencies": {
"preact": "^10.26.5"
},
"engines": {
"node": ">=22",
"npm": ">=10.9.2"
}
"resolved": "../types",
"link": true
},
"node_modules/@quartz-community/utils": {
"version": "0.1.0",
@ -2958,6 +2970,7 @@
"version": "10.28.3",
"resolved": "https://registry.npmjs.org/preact/-/preact-10.28.3.tgz",
"integrity": "sha512-tCmoRkPQLpBeWzpmbhryairGnhW9tKV6c6gr/w+RhoRoKEJwsjzipwp//1oCpGPOchvSLaAPlpcJi9MwMmoPyA==",
"dev": true,
"license": "MIT",
"funding": {
"type": "opencollective",

View file

@ -66,7 +66,7 @@
}
},
"dependencies": {
"@quartz-community/types": "github:quartz-community/types",
"@quartz-community/types": "file:../types",
"@quartz-community/utils": "github:quartz-community/utils"
},
"devDependencies": {

View file

@ -70,7 +70,7 @@ export default ((userOpts?: Partial<GraphOptions>) => {
return (
<div class={classNames(displayClass, "graph")}>
<h3>{i18n(cfg.locale).components.graph.title}</h3>
<h3>{i18n(cfg.locale ?? "en-US").components.graph.title}</h3>
<div class="graph-outer">
<div class="graph-container" data-cfg={JSON.stringify(localGraph)}></div>
<button class="global-graph-icon" aria-label="Global Graph">

View file

@ -1,2 +1,2 @@
export { default as Graph } from "./Graph";
export type { GraphOptions, D3Config } from "@quartz-community/types";
export type { GraphOptions, D3Config } from "./Graph";

View file

@ -1,3 +1,3 @@
export { default as Graph } from "./components/Graph";
export type { GraphOptions, D3Config } from "@quartz-community/types";
export type { GraphOptions, D3Config } from "./components/Graph";
export { manifest } from "./manifest";

View file

@ -1,15 +1,18 @@
export type {
BuildCtx,
ChangeEvent,
CSSResource,
JSResource,
ProcessedContent,
QuartzEmitterPlugin,
QuartzEmitterPluginInstance,
QuartzFilterPlugin,
QuartzFilterPluginInstance,
QuartzPluginData,
QuartzTransformerPlugin,
QuartzTransformerPluginInstance,
} from "@jackyzha0/quartz/plugins/types";
export type { ProcessedContent, QuartzPluginData } from "@jackyzha0/quartz/plugins/vfile";
export type { BuildCtx } from "@jackyzha0/quartz/util/ctx";
export type { CSSResource, JSResource, StaticResources } from "@jackyzha0/quartz/util/resources";
StaticResources,
} from "@quartz-community/types";
export interface ExampleTransformerOptions {
/** Token used to highlight text, defaults to ==highlight== */

View file

@ -21,6 +21,6 @@
"jsx": "react-jsx",
"jsxImportSource": "preact"
},
"include": ["src", "test", "types", "tsup.config.ts", "vitest.config.ts"],
"include": ["src", "test", "tsup.config.ts", "vitest.config.ts"],
"exclude": ["dist", "node_modules"]
}

View file

@ -1,24 +0,0 @@
export {};
declare module "@quartz-community/types" {
export interface D3Config {
drag: boolean;
zoom: boolean;
depth: number;
scale: number;
repelForce: number;
centerForce: number;
linkDistance: number;
fontSize: number;
opacityScale: number;
removeTags: string[];
showTags: boolean;
focusOnHover?: boolean;
enableRadial?: boolean;
}
export interface GraphOptions {
localGraph?: Partial<D3Config>;
globalGraph?: Partial<D3Config>;
}
}

View file

@ -1,150 +0,0 @@
declare module "@jackyzha0/quartz/components/types" {
export type QuartzComponent = unknown;
}
declare module "@jackyzha0/quartz/util/path" {
export type FilePath = string & { _brand: "FilePath" };
export type FullSlug = string & { _brand: "FullSlug" };
export function joinSegments(...segments: string[]): FilePath;
}
declare module "@jackyzha0/quartz/util/resources" {
export type JSResource =
| {
loadTime: "beforeDOMReady" | "afterDOMReady";
moduleType?: "module";
spaPreserve?: boolean;
src: string;
contentType: "external";
}
| {
loadTime: "beforeDOMReady" | "afterDOMReady";
moduleType?: "module";
spaPreserve?: boolean;
script: string;
contentType: "inline";
};
export type CSSResource = {
content: string;
inline?: boolean;
spaPreserve?: boolean;
};
export interface StaticResources {
css: CSSResource[];
js: JSResource[];
additionalHead: unknown[];
}
}
declare module "@jackyzha0/quartz/util/ctx" {
import type { QuartzConfig } from "@jackyzha0/quartz/cfg";
import type { FilePath, FullSlug } from "@jackyzha0/quartz/util/path";
export interface Argv {
directory: string;
verbose: boolean;
output: string;
serve: boolean;
watch: boolean;
port: number;
wsPort: number;
remoteDevHost?: string;
concurrency?: number;
}
export interface BuildCtx {
buildId: string;
argv: Argv;
cfg: QuartzConfig;
allSlugs: FullSlug[];
allFiles: FilePath[];
incremental: boolean;
}
}
declare module "@jackyzha0/quartz/cfg" {
export interface QuartzConfig {
configuration: {
baseUrl?: string;
};
}
}
declare module "@jackyzha0/quartz/plugins/vfile" {
import type { Root as HtmlRoot } from "hast";
import type { Root as MdRoot } from "mdast";
import type { Data, VFile } from "vfile";
export type QuartzPluginData = Data;
export type MarkdownContent = [MdRoot, VFile];
export type ProcessedContent = [HtmlRoot, VFile];
}
declare module "@jackyzha0/quartz/plugins/types" {
import type { PluggableList } from "unified";
import type { StaticResources } from "@jackyzha0/quartz/util/resources";
import type { ProcessedContent } from "@jackyzha0/quartz/plugins/vfile";
import type { QuartzComponent } from "@jackyzha0/quartz/components/types";
import type { FilePath } from "@jackyzha0/quartz/util/path";
import type { BuildCtx } from "@jackyzha0/quartz/util/ctx";
import type { VFile } from "vfile";
export interface PluginTypes {
transformers: QuartzTransformerPluginInstance[];
filters: QuartzFilterPluginInstance[];
emitters: QuartzEmitterPluginInstance[];
}
type OptionType = object | undefined;
type ExternalResourcesFn = (ctx: BuildCtx) => Partial<StaticResources> | undefined;
export type QuartzTransformerPlugin<Options extends OptionType = undefined> = (
opts?: Options,
) => QuartzTransformerPluginInstance;
export type QuartzTransformerPluginInstance = {
name: string;
textTransform?: (ctx: BuildCtx, src: string) => string;
markdownPlugins?: (ctx: BuildCtx) => PluggableList;
htmlPlugins?: (ctx: BuildCtx) => PluggableList;
externalResources?: ExternalResourcesFn;
};
export type QuartzFilterPlugin<Options extends OptionType = undefined> = (
opts?: Options,
) => QuartzFilterPluginInstance;
export type QuartzFilterPluginInstance = {
name: string;
shouldPublish(ctx: BuildCtx, content: ProcessedContent): boolean;
};
export type ChangeEvent = {
type: "add" | "change" | "delete";
path: FilePath;
file?: VFile;
};
export type QuartzEmitterPlugin<Options extends OptionType = undefined> = (
opts?: Options,
) => QuartzEmitterPluginInstance;
export type QuartzEmitterPluginInstance = {
name: string;
emit: (
ctx: BuildCtx,
content: ProcessedContent[],
resources: StaticResources,
) => Promise<FilePath[]> | AsyncGenerator<FilePath>;
partialEmit?: (
ctx: BuildCtx,
content: ProcessedContent[],
resources: StaticResources,
changeEvents: ChangeEvent[],
) => Promise<FilePath[]> | AsyncGenerator<FilePath> | null;
getQuartzComponents?: (ctx: BuildCtx) => QuartzComponent[];
externalResources?: ExternalResourcesFn;
};
}