Skip to content

Visualize Your Ideas With Code

docs: custom typedoc plugin (#113)

Jacob544e45b95770
diff --git a/.eslintrc.json b/.eslintrc.json
index 2efee2b7..5dbb48d7 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -22,6 +22,7 @@
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-non-null-assertion": "off",
+ "@typescript-eslint/no-namespace": "off",
"tsdoc/syntax": "warn"
}
}
diff --git a/.gitignore b/.gitignore
index 21404534..3fd9ae7e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,5 @@
node_modules
lib
-api
dist
test
.idea
diff --git a/package-lock.json b/package-lock.json
index 5778f613..e3198f50 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9203,15 +9203,6 @@
"node": ">=6.0.0"
}
},
- "node_modules/docusaurus-plugin-typedoc": {
- "version": "0.17.5",
- "dev": true,
- "license": "MIT",
- "peerDependencies": {
- "typedoc": ">=0.22.0",
- "typedoc-plugin-markdown": ">=3.11.10"
- }
- },
"node_modules/dom-converter": {
"version": "0.2.0",
"license": "MIT",
@@ -13679,9 +13670,10 @@
}
},
"node_modules/marked": {
- "version": "4.0.18",
+ "version": "4.2.4",
+ "resolved": "https://registry.npmjs.org/marked/-/marked-4.2.4.tgz",
+ "integrity": "sha512-Wcc9ikX7Q5E4BYDPvh1C6QNSxrjC9tBgz+A/vAhp59KXUgachw++uMvMKiSW8oA85nopmPZcEvBoex/YLMsiyA==",
"dev": true,
- "license": "MIT",
"bin": {
"marked": "bin/marked.js"
},
@@ -13741,6 +13733,12 @@
"version": "2.0.14",
"license": "CC0-1.0"
},
+ "node_modules/mdn-links": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/mdn-links/-/mdn-links-0.1.0.tgz",
+ "integrity": "sha512-m+gI2Hrgro1O0SwqHd9cFkqN8VGzP56eprB63gxu6z9EFQDMeaR083wcNqMVADIbgiMP/TOCCe0ZIXHLBv2tUg==",
+ "dev": true
+ },
"node_modules/mdurl": {
"version": "1.0.1",
"license": "MIT"
@@ -18021,13 +18019,14 @@
}
},
"node_modules/shiki": {
- "version": "0.10.1",
+ "version": "0.11.1",
+ "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.11.1.tgz",
+ "integrity": "sha512-EugY9VASFuDqOexOgXR18ZV+TbFrQHeCpEYaXamO+SZlsnT/2LxuLBX25GGtIrwaEVFXUAbUQ601SWE2rMwWHA==",
"dev": true,
- "license": "MIT",
"dependencies": {
"jsonc-parser": "^3.0.0",
"vscode-oniguruma": "^1.6.1",
- "vscode-textmate": "5.2.0"
+ "vscode-textmate": "^6.0.0"
}
},
"node_modules/side-channel": {
@@ -19106,14 +19105,15 @@
}
},
"node_modules/typedoc": {
- "version": "0.23.7",
+ "version": "0.23.21",
+ "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.23.21.tgz",
+ "integrity": "sha512-VNE9Jv7BgclvyH9moi2mluneSviD43dCE9pY8RWkO88/DrEgJZk9KpUk7WO468c9WWs/+aG6dOnoH7ccjnErhg==",
"dev": true,
- "license": "Apache-2.0",
"dependencies": {
"lunr": "^2.3.9",
- "marked": "^4.0.16",
+ "marked": "^4.0.19",
"minimatch": "^5.1.0",
- "shiki": "^0.10.1"
+ "shiki": "^0.11.1"
},
"bin": {
"typedoc": "bin/typedoc"
@@ -19122,18 +19122,7 @@
"node": ">= 14.14"
},
"peerDependencies": {
- "typescript": "4.6.x || 4.7.x"
- }
- },
- "node_modules/typedoc-plugin-markdown": {
- "version": "3.13.3",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "handlebars": "^4.7.7"
- },
- "peerDependencies": {
- "typedoc": ">=0.23.0"
+ "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x"
}
},
"node_modules/typedoc/node_modules/brace-expansion": {
@@ -19815,9 +19804,10 @@
"license": "MIT"
},
"node_modules/vscode-textmate": {
- "version": "5.2.0",
- "dev": true,
- "license": "MIT"
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-6.0.0.tgz",
+ "integrity": "sha512-gu73tuZfJgu+mvCSy4UZwd2JXykjK9zAZsfmDeut5dx/1a7FeTk0XwJsSuqQn+cuMCGVbIBfl+s53X4T19DnzQ==",
+ "dev": true
},
"node_modules/w3c-hr-time": {
"version": "1.0.2",
@@ -20620,13 +20610,13 @@
},
"packages/2d": {
"name": "@motion-canvas/2d",
- "version": "12.0.0-alpha.5",
+ "version": "12.0.1",
"license": "MIT",
"dependencies": {
"code-fns": "^0.7.0"
},
"devDependencies": {
- "@motion-canvas/core": "^12.0.0-alpha.4",
+ "@motion-canvas/core": "^12.0.0",
"typescript": "^4.7.4"
},
"peerDependencies": {
@@ -20635,7 +20625,7 @@
},
"packages/core": {
"name": "@motion-canvas/core",
- "version": "12.0.0-alpha.4",
+ "version": "12.0.0",
"license": "MIT",
"dependencies": {
"@types/chroma-js": "^2.1.4",
@@ -20655,7 +20645,7 @@
},
"packages/create": {
"name": "@motion-canvas/create",
- "version": "12.0.0-alpha.5",
+ "version": "12.0.1",
"license": "MIT",
"dependencies": {
"prompts": "^2.4.2"
@@ -20664,10 +20654,10 @@
"create-motion-canvas": "index.js"
},
"devDependencies": {
- "@motion-canvas/2d": "^12.0.0-alpha.5",
- "@motion-canvas/core": "^12.0.0-alpha.4",
- "@motion-canvas/ui": "^12.0.0-alpha.4",
- "@motion-canvas/vite-plugin": "^12.0.0-alpha.3"
+ "@motion-canvas/2d": "^12.0.1",
+ "@motion-canvas/core": "^12.0.0",
+ "@motion-canvas/ui": "^12.0.0",
+ "@motion-canvas/vite-plugin": "^12.0.0"
}
},
"packages/docs": {
@@ -20688,9 +20678,8 @@
"devDependencies": {
"@docusaurus/module-type-aliases": "^2.0.0",
"@tsconfig/docusaurus": "^1.0.5",
- "docusaurus-plugin-typedoc": "^0.17.5",
- "typedoc": "^0.23.7",
- "typedoc-plugin-markdown": "^3.13.3",
+ "mdn-links": "^0.1.0",
+ "typedoc": "^0.23.21",
"typescript": "^4.7.4"
},
"engines": {
@@ -20729,10 +20718,10 @@
},
"packages/player": {
"name": "@motion-canvas/player",
- "version": "12.0.0-alpha.4",
+ "version": "12.0.0",
"license": "MIT",
"devDependencies": {
- "@motion-canvas/core": "^12.0.0-alpha.4",
+ "@motion-canvas/core": "^12.0.0",
"terser": "^5.16.1",
"typescript": "^4.6.4",
"vite": "^3.0.4"
@@ -20757,10 +20746,10 @@
},
"packages/ui": {
"name": "@motion-canvas/ui",
- "version": "12.0.0-alpha.4",
+ "version": "12.0.0",
"license": "MIT",
"devDependencies": {
- "@motion-canvas/core": "^12.0.0-alpha.4",
+ "@motion-canvas/core": "^12.0.0",
"@preact/preset-vite": "^2.3.0",
"preact": "10.7.3",
"source-map-js": "^1.0.2",
@@ -20782,7 +20771,7 @@
},
"packages/vite-plugin": {
"name": "@motion-canvas/vite-plugin",
- "version": "12.0.0-alpha.3",
+ "version": "12.0.0",
"license": "MIT",
"dependencies": {
"mime-types": "^2.1.35"
@@ -23910,7 +23899,7 @@
"@motion-canvas/2d": {
"version": "file:packages/2d",
"requires": {
- "@motion-canvas/core": "^12.0.0-alpha.4",
+ "@motion-canvas/core": "^12.0.0",
"code-fns": "^0.7.0",
"typescript": "^4.7.4"
}
@@ -23931,10 +23920,10 @@
"@motion-canvas/create": {
"version": "file:packages/create",
"requires": {
- "@motion-canvas/2d": "^12.0.0-alpha.5",
- "@motion-canvas/core": "^12.0.0-alpha.4",
- "@motion-canvas/ui": "^12.0.0-alpha.4",
- "@motion-canvas/vite-plugin": "^12.0.0-alpha.3",
+ "@motion-canvas/2d": "^12.0.1",
+ "@motion-canvas/core": "^12.0.0",
+ "@motion-canvas/ui": "^12.0.0",
+ "@motion-canvas/vite-plugin": "^12.0.0",
"prompts": "^2.4.2"
}
},
@@ -23949,13 +23938,12 @@
"@motion-canvas/player": "*",
"@tsconfig/docusaurus": "^1.0.5",
"clsx": "^1.2.0",
- "docusaurus-plugin-typedoc": "^0.17.5",
+ "mdn-links": "^0.1.0",
"prism-react-renderer": "^1.3.5",
"raw-loader": "^4.0.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
- "typedoc": "^0.23.7",
- "typedoc-plugin-markdown": "^3.13.3",
+ "typedoc": "^0.23.21",
"typescript": "^4.7.4"
}
},
@@ -23967,10 +23955,10 @@
"@motion-canvas/ui": "*",
"@motion-canvas/vite-plugin": "*",
"@types/puppeteer": "^7.0.4",
- "jest-image-snapshot": "*",
+ "jest-image-snapshot": "^6.1.0",
"puppeteer": "^19.3.0",
"vite": "^3.0.5",
- "vitest": "*"
+ "vitest": "^0.25.5"
}
},
"@motion-canvas/examples": {
@@ -23986,7 +23974,7 @@
"@motion-canvas/player": {
"version": "file:packages/player",
"requires": {
- "@motion-canvas/core": "^12.0.0-alpha.4",
+ "@motion-canvas/core": "^12.0.0",
"terser": "^5.16.1",
"typescript": "^4.6.4",
"vite": "^3.0.4"
@@ -24005,7 +23993,7 @@
"@motion-canvas/ui": {
"version": "file:packages/ui",
"requires": {
- "@motion-canvas/core": "^12.0.0-alpha.4",
+ "@motion-canvas/core": "^12.0.0",
"@preact/preset-vite": "^2.3.0",
"preact": "10.7.3",
"source-map-js": "^1.0.2",
@@ -26951,11 +26939,6 @@
"esutils": "^2.0.2"
}
},
- "docusaurus-plugin-typedoc": {
- "version": "0.17.5",
- "dev": true,
- "requires": {}
- },
"dom-converter": {
"version": "0.2.0",
"requires": {
@@ -29855,7 +29838,9 @@
"version": "1.0.4"
},
"marked": {
- "version": "4.0.18",
+ "version": "4.2.4",
+ "resolved": "https://registry.npmjs.org/marked/-/marked-4.2.4.tgz",
+ "integrity": "sha512-Wcc9ikX7Q5E4BYDPvh1C6QNSxrjC9tBgz+A/vAhp59KXUgachw++uMvMKiSW8oA85nopmPZcEvBoex/YLMsiyA==",
"dev": true
},
"mdast-squeeze-paragraphs": {
@@ -29889,6 +29874,12 @@
"mdn-data": {
"version": "2.0.14"
},
+ "mdn-links": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/mdn-links/-/mdn-links-0.1.0.tgz",
+ "integrity": "sha512-m+gI2Hrgro1O0SwqHd9cFkqN8VGzP56eprB63gxu6z9EFQDMeaR083wcNqMVADIbgiMP/TOCCe0ZIXHLBv2tUg==",
+ "dev": true
+ },
"mdurl": {
"version": "1.0.1"
},
@@ -32554,12 +32545,14 @@
}
},
"shiki": {
- "version": "0.10.1",
+ "version": "0.11.1",
+ "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.11.1.tgz",
+ "integrity": "sha512-EugY9VASFuDqOexOgXR18ZV+TbFrQHeCpEYaXamO+SZlsnT/2LxuLBX25GGtIrwaEVFXUAbUQ601SWE2rMwWHA==",
"dev": true,
"requires": {
"jsonc-parser": "^3.0.0",
"vscode-oniguruma": "^1.6.1",
- "vscode-textmate": "5.2.0"
+ "vscode-textmate": "^6.0.0"
}
},
"side-channel": {
@@ -33244,13 +33237,15 @@
}
},
"typedoc": {
- "version": "0.23.7",
+ "version": "0.23.21",
+ "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.23.21.tgz",
+ "integrity": "sha512-VNE9Jv7BgclvyH9moi2mluneSviD43dCE9pY8RWkO88/DrEgJZk9KpUk7WO468c9WWs/+aG6dOnoH7ccjnErhg==",
"dev": true,
"requires": {
"lunr": "^2.3.9",
- "marked": "^4.0.16",
+ "marked": "^4.0.19",
"minimatch": "^5.1.0",
- "shiki": "^0.10.1"
+ "shiki": "^0.11.1"
},
"dependencies": {
"brace-expansion": {
@@ -33269,13 +33264,6 @@
}
}
},
- "typedoc-plugin-markdown": {
- "version": "3.13.3",
- "dev": true,
- "requires": {
- "handlebars": "^4.7.7"
- }
- },
"typescript": {
"version": "4.7.4"
},
@@ -33617,7 +33605,9 @@
"version": "1.6.2"
},
"vscode-textmate": {
- "version": "5.2.0",
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-6.0.0.tgz",
+ "integrity": "sha512-gu73tuZfJgu+mvCSy4UZwd2JXykjK9zAZsfmDeut5dx/1a7FeTk0XwJsSuqQn+cuMCGVbIBfl+s53X4T19DnzQ==",
"dev": true
},
"w3c-hr-time": {
diff --git a/packages/2d/src/components/Layout.ts b/packages/2d/src/components/Layout.ts
index cbfc88cb..2a25ee93 100644
--- a/packages/2d/src/components/Layout.ts
+++ b/packages/2d/src/components/Layout.ts
@@ -397,7 +397,7 @@ export class Layout extends Node {
* @remarks
* When the mode is `null`, its value will be inherited from the parent.
*
- * Use {@link Layout.mode} to get the raw mode set for this node (without
+ * Use {@link layout} to get the raw mode set for this node (without
* inheritance).
*/
@computed()
diff --git a/packages/2d/src/globals.d.ts b/packages/2d/src/globals.d.ts
index c044c1c9..1da3d9ea 100644
--- a/packages/2d/src/globals.d.ts
+++ b/packages/2d/src/globals.d.ts
@@ -1,2 +1,2 @@
-/* eslint-disable @typescript-eslint/no-unused-vars,@typescript-eslint/no-namespace */
+/* eslint-disable @typescript-eslint/no-unused-vars */
/// <reference types="@motion-canvas/core/project" />
diff --git a/packages/2d/src/jsx-runtime.ts b/packages/2d/src/jsx-runtime.ts
index c082b3bc..f3866767 100644
--- a/packages/2d/src/jsx-runtime.ts
+++ b/packages/2d/src/jsx-runtime.ts
@@ -6,7 +6,6 @@ import type {
JSXProps,
} from './components';
-// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace JSX {
export type Element = Node;
export type ElementClass = Node;
diff --git a/packages/2d/tsdoc.json b/packages/2d/tsdoc.json
new file mode 100644
index 00000000..f5a4dc61
--- /dev/null
+++ b/packages/2d/tsdoc.json
@@ -0,0 +1,4 @@
+{
+ "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
+ "extends": ["../../tsdoc.json"]
+}
diff --git a/packages/core/project.d.ts b/packages/core/project.d.ts
index 1578b7ae..7b977085 100644
--- a/packages/core/project.d.ts
+++ b/packages/core/project.d.ts
@@ -1,4 +1,4 @@
-/* eslint-disable @typescript-eslint/no-unused-vars,@typescript-eslint/no-namespace */
+/* eslint-disable @typescript-eslint/no-unused-vars */
/// <reference types="vite/client" />
declare module '*?img' {
diff --git a/packages/core/src/events/EventDispatcherBase.ts b/packages/core/src/events/EventDispatcherBase.ts
index bf9cf1cf..c2343277 100644
--- a/packages/core/src/events/EventDispatcherBase.ts
+++ b/packages/core/src/events/EventDispatcherBase.ts
@@ -18,7 +18,7 @@ export abstract class EventDispatcherBase<
private subscribers = new Set<THandler>();
/**
- * {@inheritDoc SubscribableEvent.subscribe}
+ * {@inheritDoc Subscribable.subscribe}
*/
public subscribe(handler: THandler) {
this.subscribers.add(handler);
@@ -26,7 +26,7 @@ export abstract class EventDispatcherBase<
}
/**
- * {@inheritDoc SubscribableEvent.unsubscribe}
+ * {@inheritDoc Subscribable.unsubscribe}
*/
public unsubscribe(handler: THandler) {
this.subscribers.delete(handler);
diff --git a/packages/core/src/events/FlagDispatcher.ts b/packages/core/src/events/FlagDispatcher.ts
index 2e4aacd0..ab21ed5b 100644
--- a/packages/core/src/events/FlagDispatcher.ts
+++ b/packages/core/src/events/FlagDispatcher.ts
@@ -58,9 +58,6 @@ export class FlagDispatcher extends EventDispatcherBase<void> {
return this.value;
}
- /**
- * {@inheritDoc}
- */
public subscribe(handler: EventHandler<void>) {
const unsubscribe = super.subscribe(handler);
if (this.value) {
diff --git a/packages/core/src/flow/index.ts b/packages/core/src/flow/index.ts
index 234ade8b..ab911e28 100644
--- a/packages/core/src/flow/index.ts
+++ b/packages/core/src/flow/index.ts
@@ -1,8 +1,8 @@
/**
* Utilities for controlling the flow and timing of an animation.
- *
- * @module
+ * @packageDocumentation
*/
+
export * from './all';
export * from './any';
export * from './chain';
diff --git a/packages/core/src/globals.d.ts b/packages/core/src/globals.d.ts
index 3ed18ff3..262cf56e 100644
--- a/packages/core/src/globals.d.ts
+++ b/packages/core/src/globals.d.ts
@@ -1,3 +1,3 @@
-/* eslint-disable @typescript-eslint/no-unused-vars,@typescript-eslint/no-namespace */
+/* eslint-disable @typescript-eslint/no-unused-vars */
declare type Callback = (...args: any[]) => void;
diff --git a/packages/core/src/player/Player.ts b/packages/core/src/player/Player.ts
index 79140467..5bd4493e 100644
--- a/packages/core/src/player/Player.ts
+++ b/packages/core/src/player/Player.ts
@@ -325,6 +325,12 @@ export class Player {
if (state.paused && previousState !== PlaybackState.Paused) {
await this.project.render();
}
+
+ // Sync the audio if the animation is too far ahead.
+ if (this.project.time > this.project.audio.getTime() + MAX_AUDIO_DESYNC) {
+ this.project.syncAudio();
+ }
+
this.request();
return;
}
diff --git a/packages/core/src/scenes/Scene.ts b/packages/core/src/scenes/Scene.ts
index 1ebb1118..eb6e0ddd 100644
--- a/packages/core/src/scenes/Scene.ts
+++ b/packages/core/src/scenes/Scene.ts
@@ -63,11 +63,13 @@ export enum SceneRenderEvent {
*/
BeforeRender,
/**
- * Occurs at the beginning of a render when the Scene's `useContext` handlers are applied.
+ * Occurs at the beginning of a render when the Scene's
+ * {@link utils~useContext} handlers are applied.
*/
BeginRender,
/**
- * Occurs at the end of a render when the Scene's `useContextAfter` handlers are applied.
+ * Occurs at the end of a render when the Scene's
+ * {@link utils~useContextAfter} handlers are applied.
*/
FinishRender,
/**
diff --git a/packages/core/src/scenes/TimeEvents.ts b/packages/core/src/scenes/TimeEvents.ts
index 35bf7598..79a278d1 100644
--- a/packages/core/src/scenes/TimeEvents.ts
+++ b/packages/core/src/scenes/TimeEvents.ts
@@ -14,7 +14,7 @@ export interface TimeEvent {
* was registered.
*
* @remarks
- * In other words, the moment at which {@link waitUntil} for this event
+ * In other words, the moment at which {@link flow~waitUntil} for this event
* was invoked.
*/
initialTime: number;
diff --git a/packages/core/src/threading/Thread.ts b/packages/core/src/threading/Thread.ts
index f218e29c..ad9687f5 100644
--- a/packages/core/src/threading/Thread.ts
+++ b/packages/core/src/threading/Thread.ts
@@ -28,7 +28,7 @@ export class Thread {
* The current time of this thread.
*
* @remarks
- * Used by {@link waitFor} and other time-based functions to properly
+ * Used by {@link flow~waitFor} and other time-based functions to properly
* support durations shorter than one frame.
*/
public readonly time = createSignal(0);
diff --git a/packages/core/src/threading/ThreadGenerator.ts b/packages/core/src/threading/ThreadGenerator.ts
index b026df01..0d2cc317 100644
--- a/packages/core/src/threading/ThreadGenerator.ts
+++ b/packages/core/src/threading/ThreadGenerator.ts
@@ -14,27 +14,25 @@ export function isPromisable(value: any): value is Promisable<any> {
* @example
* Yielded values can be used to control the flow of animation:
*
- * - Progress to the next frame:
+ * Progress to the next frame:
* ```ts
* yield;
* ```
*
- * - Run another generator synchronously:
+ * Run another generator synchronously:
* ```ts
* yield* generatorFunction();
* ```
*
- * - Run another generator concurrently:
+ * Run another generator concurrently:
* ```ts
* const task = yield generatorFunction();
* ```
-
- * - Await a [Promise][promise]:
+ *
+ * Await a Promise:
* ```ts
* const result = yield asyncFunction();
* ```
- *
- * [promise]: https://developer.mozilla.org/en-US/docs/web/javascript/reference/global_objects/promise
*/
export type ThreadGenerator = Generator<
ThreadGenerator | Promise<any> | Promisable<any> | void,
diff --git a/packages/core/src/threading/index.ts b/packages/core/src/threading/index.ts
index 53678339..a211b34f 100644
--- a/packages/core/src/threading/index.ts
+++ b/packages/core/src/threading/index.ts
@@ -1,7 +1,7 @@
/**
* Thread management.
*
- * @module
+ * @packageDocumentation
*/
export * from './cancel';
export * from './join';
diff --git a/packages/core/src/types/Vector.ts b/packages/core/src/types/Vector.ts
index a1557c13..2f1e03c3 100644
--- a/packages/core/src/types/Vector.ts
+++ b/packages/core/src/types/Vector.ts
@@ -14,6 +14,9 @@ export type PossibleVector2<T = number> =
| T
| [T, T];
+/**
+ * Represents a two-dimensional vector.
+ */
export class Vector2 implements Type {
public static readonly symbol = Symbol.for(
'@motion-canvas/core/types/Vector2',
diff --git a/packages/core/src/types/index.ts b/packages/core/src/types/index.ts
index d4c1b9f2..5b296996 100644
--- a/packages/core/src/types/index.ts
+++ b/packages/core/src/types/index.ts
@@ -4,4 +4,5 @@ export * from './Matrix';
export * from './Origin';
export * from './Rect';
export * from './Spacing';
+export * from './Type';
export * from './Vector';
diff --git a/packages/core/src/utils/useTime.ts b/packages/core/src/utils/useTime.ts
index d78daa46..fe949602 100644
--- a/packages/core/src/utils/useTime.ts
+++ b/packages/core/src/utils/useTime.ts
@@ -5,7 +5,7 @@ import {useThread} from './useThread';
*
* @remarks
* The returned value accounts for offsets caused by functions such as
- * {@link waitFor}.
+ * {@link flow~waitFor}.
*
* @example
* ```ts
diff --git a/packages/docs/docs/guides/getting-started/flow.mdx b/packages/docs/docs/guides/getting-started/flow.mdx
index ad2fd8b5..792b5997 100644
--- a/packages/docs/docs/guides/getting-started/flow.mdx
+++ b/packages/docs/docs/guides/getting-started/flow.mdx
@@ -93,4 +93,4 @@ You can read more about them in the [tweening](/guides/getting-started/tweening)
Another kind of generators are _flow generators_. They take one or more generators as
their input and combine them together. We've mentioned the `all()` generator in
-the quickstart section, but you can find them all in [the API documentation](/api/core/modules/flow).
+the quickstart section, but you can find them all in [the API documentation](/api/core/flow).
diff --git a/packages/docs/docusaurus.config.js b/packages/docs/docusaurus.config.js
index e2f4a7a0..a62918fc 100644
--- a/packages/docs/docusaurus.config.js
+++ b/packages/docs/docusaurus.config.js
@@ -35,12 +35,7 @@ const config = {
position: 'left',
label: 'Guides',
},
- {
- type: 'docSidebar',
- sidebarId: 'api',
- position: 'left',
- label: 'API',
- },
+ {to: '/api/core', label: 'API', position: 'left'},
{to: '/blog', label: 'Blog', position: 'left'},
{
href: 'https://github.com/motion-canvas',
@@ -129,47 +124,7 @@ const config = {
'@docusaurus/plugin-content-pages',
'@docusaurus/plugin-debug',
'@docusaurus/plugin-sitemap',
- [
- 'docusaurus-plugin-typedoc',
- {
- id: 'core',
- out: 'api/core',
- excludeExternals: true,
- entryPoints: [
- '../core/',
- '../core/src/decorators',
- '../core/src/events',
- '../core/src/flow',
- '../core/src/helpers',
- '../core/src/media',
- '../core/src/player',
- '../core/src/scenes',
- '../core/src/threading',
- '../core/src/transitions',
- '../core/src/tweening',
- '../core/src/types',
- '../core/src/utils',
- ],
- tsconfig: '../core/tsconfig.build.json',
- },
- ],
- [
- 'docusaurus-plugin-typedoc',
- {
- id: '2d',
- out: 'api/2d',
- excludeExternals: true,
- entryPoints: [
- '../2d/src/components',
- '../2d/src/curves',
- '../2d/src/decorators',
- '../2d/src/partials',
- '../2d/src/scenes',
- '../2d/src/utils',
- ],
- tsconfig: '../2d/tsconfig.json',
- },
- ],
+ require('./typedoc'),
],
};
diff --git a/packages/docs/package.json b/packages/docs/package.json
index d65e046a..d98ae04f 100644
--- a/packages/docs/package.json
+++ b/packages/docs/package.json
@@ -29,9 +29,8 @@
"devDependencies": {
"@docusaurus/module-type-aliases": "^2.0.0",
"@tsconfig/docusaurus": "^1.0.5",
- "docusaurus-plugin-typedoc": "^0.17.5",
- "typedoc": "^0.23.7",
- "typedoc-plugin-markdown": "^3.13.3",
+ "mdn-links": "^0.1.0",
+ "typedoc": "^0.23.21",
"typescript": "^4.7.4"
},
"browserslist": {
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index d2f06fdc..53f79e57 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -45,18 +45,6 @@ function createApiSidebar(name) {
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
const sidebars = {
guides: [{type: 'autogenerated', dirName: 'guides'}],
- api: [
- {
- type: 'category',
- label: 'Core',
- items: createApiSidebar('api/core'),
- },
- {
- type: 'category',
- label: '2D',
- items: createApiSidebar('api/2d'),
- },
- ],
};
module.exports = sidebars;
diff --git a/packages/docs/src/Icon/ExternalLink/index.tsx b/packages/docs/src/Icon/ExternalLink/index.tsx
new file mode 100644
index 00000000..50c481e9
--- /dev/null
+++ b/packages/docs/src/Icon/ExternalLink/index.tsx
@@ -0,0 +1,29 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+import React, {ComponentProps} from 'react';
+
+export default function IconExternalLink({
+ width = 24,
+ height = 24,
+ ...props
+}: ComponentProps<'svg'>): JSX.Element {
+ return (
+ <svg
+ width={width}
+ height={height}
+ aria-hidden="true"
+ viewBox="0 0 24 24"
+ {...props}
+ >
+ <path
+ d="M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"
+ fill="currentColor"
+ />
+ </svg>
+ );
+}
diff --git a/packages/docs/src/Icon/Filters/index.tsx b/packages/docs/src/Icon/Filters/index.tsx
new file mode 100644
index 00000000..c8647015
--- /dev/null
+++ b/packages/docs/src/Icon/Filters/index.tsx
@@ -0,0 +1,22 @@
+import React, {ComponentProps} from 'react';
+
+export default function IconFilters({
+ width = 24,
+ height = 24,
+ ...props
+}: ComponentProps<'svg'>): JSX.Element {
+ return (
+ <svg
+ viewBox="0 0 24 24"
+ width={width}
+ height={height}
+ aria-hidden
+ {...props}
+ >
+ <path
+ d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"
+ fill="currentColor"
+ />
+ </svg>
+ );
+}
diff --git a/packages/docs/src/components/AnimationPlayer/index.tsx b/packages/docs/src/components/AnimationPlayer/index.tsx
index 3cf38211..7ce83a37 100644
--- a/packages/docs/src/components/AnimationPlayer/index.tsx
+++ b/packages/docs/src/components/AnimationPlayer/index.tsx
@@ -10,7 +10,6 @@ if (ExecutionEnvironment.canUseDOM) {
}
declare global {
- // eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'motion-canvas-player': MotionCanvasPlayerProps & ComponentProps<'div'>;
diff --git a/packages/docs/src/components/Api/ApiItem.tsx b/packages/docs/src/components/Api/ApiItem.tsx
new file mode 100644
index 00000000..bab28924
--- /dev/null
+++ b/packages/docs/src/components/Api/ApiItem.tsx
@@ -0,0 +1,89 @@
+import React, {useMemo} from 'react';
+import DocItemMetadata from '@theme/DocItem/Metadata';
+import DocItemLayout from '@theme/DocItem/Layout';
+import {DocProvider} from '@docusaurus/theme-common/internal';
+import Item from '@site/src/components/Api/Item';
+import {useApiLookup} from '@site/src/contexts/api';
+import {ThemeDictProvider, themeToDict} from '@site/src/contexts/codeTheme';
+import {usePrismTheme} from '@docusaurus/theme-common';
+import {matchFilters, useFilters} from '@site/src/contexts/filters';
+import {TOCItem} from '@docusaurus/mdx-loader';
+import Tooltip from '@site/src/components/Tooltip';
+import type {JSONOutput} from 'typedoc';
+
+interface ApiItemProps {
+ route: {
+ reflectionId: number;
+ };
+}
+
+export default function ApiItem({route}: ApiItemProps): JSX.Element {
+ const theme = usePrismTheme();
+ const dictionary = useMemo(() => themeToDict(theme, 'typescript'), [theme]);
+ const lookup = useApiLookup();
+ const reflection: JSONOutput.DeclarationReflection =
+ lookup[route.reflectionId];
+ const [filters] = useFilters();
+ const toc = useMemo(() => {
+ const toc: TOCItem[] = [];
+ if (!reflection.groups) {
+ return toc;
+ }
+
+ for (const group of reflection.groups) {
+ toc.push({
+ value: group.title,
+ id: group.title,
+ level: 2,
+ });
+ if (group.children) {
+ for (const id of group.children) {
+ const child = lookup[id];
+ if (!child || child.hasOwnPage || !matchFilters(filters, child)) {
+ continue;
+ }
+ toc.push({
+ value: `<code>${child.name}</code>`,
+ id: child.anchor,
+ level: 3,
+ });
+ }
+ }
+ }
+ return toc;
+ }, [reflection, filters]);
+
+ return (
+ <DocProvider
+ content={{
+ frontMatter: {},
+ metadata: {
+ id: reflection.docId,
+ unversionedId: reflection.docId,
+ version: 'current',
+ title: reflection.name,
+ description: reflection.comment?.summaryText,
+ slug: reflection.url,
+ permalink: reflection.url,
+ editUrl: reflection.sources?.[0]?.url ?? undefined,
+ draft: false,
+ tags: [],
+ frontMatter: {},
+ next: reflection.next,
+ previous: reflection.previous,
+ },
+ toc,
+ assets: {},
+ }}
+ >
+ <ThemeDictProvider dictionary={dictionary}>
+ <DocItemMetadata />
+ <Tooltip>
+ <DocItemLayout>
+ <Item reflection={reflection} />
+ </DocItemLayout>
+ </Tooltip>
+ </ThemeDictProvider>
+ </DocProvider>
+ );
+}
diff --git a/packages/docs/src/components/Api/ApiPage.tsx b/packages/docs/src/components/Api/ApiPage.tsx
new file mode 100644
index 00000000..94f084c0
--- /dev/null
+++ b/packages/docs/src/components/Api/ApiPage.tsx
@@ -0,0 +1,53 @@
+import React, {FunctionComponent} from 'react';
+import DocPage, {Props} from '@theme/DocPage';
+import {
+ ApiLookups,
+ ApiProvider,
+ ReflectionReference,
+} from '@site/src/contexts/api';
+import {PropSidebar} from '@docusaurus/plugin-content-docs';
+import {FiltersProvider} from '@site/src/contexts/filters';
+
+interface ApiPageProps extends Props {
+ lookup: {
+ lookups: ApiLookups;
+ urlLookups: Record<string, ReflectionReference>;
+ sidebar: PropSidebar;
+ };
+ contents: Record<string, FunctionComponent>;
+ route: {
+ reflectionId: number;
+ };
+}
+
+export default function ApiPage(props: ApiPageProps) {
+ const {lookup, contents, ...rest} = props;
+
+ return (
+ <ApiProvider
+ lookup={lookup.lookups}
+ urlLookup={lookup.urlLookups}
+ contents={contents}
+ id={props.route.reflectionId}
+ >
+ <FiltersProvider>
+ <DocPage
+ {...rest}
+ versionMetadata={{
+ version: 'current',
+ pluginId: 'typedoc',
+ className: '',
+ badge: false,
+ docs: {},
+ banner: null,
+ isLast: false,
+ label: 'test',
+ docsSidebars: {
+ api: lookup.sidebar,
+ },
+ }}
+ />
+ </FiltersProvider>
+ </ApiProvider>
+ );
+}
diff --git a/packages/docs/src/components/Api/Code/CodeBlock.tsx b/packages/docs/src/components/Api/Code/CodeBlock.tsx
new file mode 100644
index 00000000..39f83cd2
--- /dev/null
+++ b/packages/docs/src/components/Api/Code/CodeBlock.tsx
@@ -0,0 +1,63 @@
+import React, {ReactNode} from 'react';
+import {useCodeWordWrap} from '@docusaurus/theme-common/internal';
+import {useTokenStyle} from '@site/src/contexts/codeTheme';
+import clsx from 'clsx';
+import styles from '@docusaurus/theme-classic/lib/theme/CodeBlock/Content/styles.module.css';
+import customStyles from '@site/src/components/Api/Code/styles.module.css';
+import IconExternalLink from '@site/src/Icon/ExternalLink';
+
+export default function CodeBlock({
+ children,
+ highlight,
+ onClick,
+ link,
+}: {
+ children: ReactNode | ReactNode[];
+ highlight?: boolean;
+ onClick?: () => void;
+ link?: string;
+}) {
+ const wordWrap = useCodeWordWrap();
+ const plainStyle = useTokenStyle();
+
+ return (
+ <div
+ className={clsx(
+ styles.codeBlockContent,
+ customStyles.codeBlock,
+ highlight && customStyles.highlight,
+ onClick && customStyles.pointer,
+ )}
+ >
+ <pre
+ onClick={onClick}
+ onKeyDown={e => {
+ if (e.key === 'Enter') {
+ onClick?.();
+ }
+ }}
+ tabIndex={0}
+ ref={wordWrap.codeBlockRef}
+ className={clsx(styles.codeBlock, 'thin-scrollbar')}
+ >
+ <code className={styles.codeBlockLines} style={plainStyle}>
+ {children}
+ </code>
+ </pre>
+ {link && (
+ <div className={styles.buttonGroup}>
+ <button
+ title="Go to source"
+ className="clean-btn"
+ onClick={e => {
+ e.preventDefault();
+ window.open(link, '_blank');
+ }}
+ >
+ <IconExternalLink width={18} height={18} />
+ </button>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/packages/docs/src/components/Api/Code/Container.tsx b/packages/docs/src/components/Api/Code/Container.tsx
new file mode 100644
index 00000000..cce4f6d2
--- /dev/null
+++ b/packages/docs/src/components/Api/Code/Container.tsx
@@ -0,0 +1,20 @@
+import React, {ReactNode} from 'react';
+
+import Container from '@theme/CodeBlock/Container';
+import clsx from 'clsx';
+import styles from './styles.module.css';
+
+export default function ApiContainer({
+ children,
+}: {
+ children: ReactNode | ReactNode[];
+}) {
+ return (
+ <Container
+ as="div"
+ className={clsx(styles.codeBlockContainer, 'language-typescript')}
+ >
+ {children}
+ </Container>
+ );
+}
diff --git a/packages/docs/src/components/Api/Code/Line.tsx b/packages/docs/src/components/Api/Code/Line.tsx
new file mode 100644
index 00000000..d23d87d4
--- /dev/null
+++ b/packages/docs/src/components/Api/Code/Line.tsx
@@ -0,0 +1,38 @@
+import React, {ReactNode, useLayoutEffect, useRef} from 'react';
+
+import styles from './styles.module.css';
+import clsx from 'clsx';
+
+export default function Line({children}: {children?: ReactNode | ReactNode[]}) {
+ const line = useRef<HTMLSpanElement>();
+
+ useLayoutEffect(() => {
+ if (!line.current) return;
+ const parent = line.current.closest('pre');
+ if (parent.scrollWidth > parent.clientWidth) {
+ const lists: HTMLElement[] = Array.from(
+ line.current.querySelectorAll(`.${styles.elements}`),
+ );
+
+ const multiple = lists.filter(list => list.children.length > 1);
+ while (parent.scrollWidth > parent.clientWidth && lists.length > 0) {
+ if (multiple.length > 0) {
+ multiple.shift().classList.add(styles.wrap);
+ } else {
+ lists.shift().classList.add(styles.wrap);
+ }
+ }
+ }
+ });
+
+ return (
+ <>
+ {children && (
+ <span ref={line} className={clsx(styles.line, 'token-line')}>
+ {children}
+ </span>
+ )}
+ <br />
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Code/Token.tsx b/packages/docs/src/components/Api/Code/Token.tsx
new file mode 100644
index 00000000..95ccb7c7
--- /dev/null
+++ b/packages/docs/src/components/Api/Code/Token.tsx
@@ -0,0 +1,28 @@
+import React, {ReactNode} from 'react';
+import {useTokenProps} from '@site/src/contexts/codeTheme';
+import Link from '@docusaurus/Link';
+
+export default function Token({
+ children,
+ type,
+ to,
+ id,
+ tooltip,
+}: {
+ children: ReactNode | ReactNode[];
+ type?: string;
+ to?: string;
+ id?: string;
+ tooltip?: boolean;
+}) {
+ const props = useTokenProps(type);
+ return to ? (
+ <Link id={id} to={to} data-tooltip={tooltip} {...props}>
+ {children}
+ </Link>
+ ) : (
+ <span id={id} {...props}>
+ {children}
+ </span>
+ );
+}
diff --git a/packages/docs/src/components/Api/Code/TokenList.tsx b/packages/docs/src/components/Api/Code/TokenList.tsx
new file mode 100644
index 00000000..05bd6bf3
--- /dev/null
+++ b/packages/docs/src/components/Api/Code/TokenList.tsx
@@ -0,0 +1,52 @@
+import React, {ReactNode} from 'react';
+
+import styles from './styles.module.css';
+import clsx from 'clsx';
+
+export enum ListType {
+ None,
+ Angle,
+ Curly,
+ Square,
+ Parentheses,
+}
+
+export enum Separator {
+ Comma = ', ',
+ Pipe = ' | ',
+ Ampersand = ' & ',
+}
+
+const classes: Record<ListType, string> = {
+ [ListType.None]: styles.none,
+ [ListType.Angle]: styles.angle,
+ [ListType.Curly]: styles.curly,
+ [ListType.Square]: styles.square,
+ [ListType.Parentheses]: styles.parentheses,
+};
+
+export default function TokenList({
+ children,
+ type,
+ separator,
+}: {
+ children: ReactNode[];
+ type?: ListType;
+ separator?: Separator;
+}) {
+ return (
+ <span className={clsx(styles.list, classes[type ?? ListType.None])}>
+ <span className={styles.elements}>
+ {children.flatMap((child, index) => (
+ <span
+ data-separator={separator ?? Separator.Comma}
+ key={index}
+ className={styles.element}
+ >
+ {child}
+ </span>
+ ))}
+ </span>
+ </span>
+ );
+}
diff --git a/packages/docs/src/components/Api/Code/styles.module.css b/packages/docs/src/components/Api/Code/styles.module.css
new file mode 100644
index 00000000..5c16b235
--- /dev/null
+++ b/packages/docs/src/components/Api/Code/styles.module.css
@@ -0,0 +1,104 @@
+.list {
+}
+.elements {
+}
+
+.element:not(:last-child)::after {
+ content: attr(data-separator);
+}
+.elements.wrap > .element::after {
+ content: attr(data-separator) '\a';
+}
+.elements.wrap::before {
+ content: '\a';
+}
+.elements.wrap::after {
+ content: '';
+}
+.wrap .elements.wrap::after {
+ padding-left: 2ch;
+}
+.wrap .wrap .elements.wrap::after {
+ padding-left: 4ch;
+}
+
+.elements.wrap > .element {
+ padding-left: 2ch;
+}
+.wrap .elements.wrap > .element {
+ padding-left: 4ch;
+}
+.wrap .wrap .elements.wrap > .element {
+ padding-left: 6ch;
+}
+
+.angle::before {
+ content: '<';
+}
+.angle::after {
+ content: '>';
+}
+.curly::before {
+ content: '{';
+}
+.curly::after {
+ content: '}';
+}
+.square::before {
+ content: '[';
+}
+.square::after {
+ content: ']';
+}
+.parentheses::before {
+ content: '(';
+}
+.parentheses::after {
+ content: ')';
+}
+
+.codeBlockContainer hr {
+ margin: 0;
+ background-color: #141414;
+}
+.blockSeparator {
+ margin: 0;
+ background-color: #141414;
+}
+.codeBlock {
+ border-radius: var(--ifm-pre-border-radius);
+}
+.codeBlock.highlight {
+ --prism-background-color: var(--ifm-code-background);
+}
+.codeBlock.highlight > pre > code {
+ border-left: var(--ifm-alert-border-left-width) solid
+ var(--ifm-color-emphasis-400);
+ padding-left: calc(
+ var(--ifm-pre-padding) - var(--ifm-alert-border-left-width)
+ );
+ border-radius: var(--ifm-pre-border-radius);
+}
+.codeBlock:first-child:not(:last-child) {
+ --ifm-pre-border-radius: var(--ifm-global-radius) var(--ifm-global-radius) 0 0;
+ border-bottom: 1px solid var(--ifm-color-emphasis-300);
+}
+.codeBlock:not(:first-child):not(:last-child) {
+ --ifm-pre-border-radius: 0;
+ border-bottom: 1px solid var(--ifm-color-emphasis-300);
+}
+.codeBlock:not(:first-child):last-child {
+ --ifm-pre-border-radius: 0 0 var(--ifm-global-radius) var(--ifm-global-radius);
+}
+
+.codeBlock.pointer {
+ cursor: pointer;
+}
+.codeBlock.pointer:hover {
+ --prism-background-color: var(--ifm-code-hover-background);
+}
+
+.codeBlockContainer {
+ position: relative;
+ scroll-margin-top: calc(var(--ifm-navbar-height) + var(--ifm-leading));
+}
\ No newline at end of file
diff --git a/packages/docs/src/components/Api/Comment/Summary.tsx b/packages/docs/src/components/Api/Comment/Summary.tsx
new file mode 100644
index 00000000..d69c5446
--- /dev/null
+++ b/packages/docs/src/components/Api/Comment/Summary.tsx
@@ -0,0 +1,7 @@
+import React from 'react';
+import {useApiContent} from '@site/src/contexts/api';
+
+export default function Summary({id}: {id: string}) {
+ const Content = useApiContent(id);
+ return <Content />;
+}
diff --git a/packages/docs/src/components/Api/Comment/index.tsx b/packages/docs/src/components/Api/Comment/index.tsx
new file mode 100644
index 00000000..68fa5ad8
--- /dev/null
+++ b/packages/docs/src/components/Api/Comment/index.tsx
@@ -0,0 +1,33 @@
+import React, {useMemo} from 'react';
+import type {JSONOutput} from 'typedoc';
+import Summary from '@site/src/components/Api/Comment/Summary';
+
+export default function Comment({
+ comment,
+ withExamples = true,
+}: {
+ comment: JSONOutput.Comment;
+ withExamples?: boolean;
+}) {
+ const remarks = useMemo(() => {
+ return comment?.blockTags?.find(({tag}) => tag === '@remarks');
+ }, [comment]);
+ const examples = useMemo(() => {
+ return comment?.blockTags?.filter(({tag}) => tag === '@example') ?? [];
+ }, [comment]);
+
+ return (
+ <>
+ <Summary id={comment?.summaryId} />
+ <Summary id={remarks?.contentId} />
+ {withExamples && examples.length > 0 && (
+ <>
+ <h4>Examples</h4>
+ {examples.map(example => (
+ <Summary id={example.contentId} />
+ ))}
+ </>
+ )}
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Filters/Controls.tsx b/packages/docs/src/components/Api/Filters/Controls.tsx
new file mode 100644
index 00000000..be0c9ebc
--- /dev/null
+++ b/packages/docs/src/components/Api/Filters/Controls.tsx
@@ -0,0 +1,117 @@
+import React, {useEffect, useRef, useState} from 'react';
+import {useFilters} from '@site/src/contexts/filters';
+import IconFilters from '@site/src/Icon/Filters';
+import clsx from 'clsx';
+import styles from './index.module.css';
+
+export default function Controls() {
+ const dropdownRef = useRef<HTMLDivElement>(null);
+ const [showDropdown, setShowDropdown] = useState(false);
+ const [filter, setFilter] = useFilters();
+
+ useEffect(() => {
+ const handleClickOutside = (event: MouseEvent | TouchEvent) => {
+ if (
+ !dropdownRef.current ||
+ dropdownRef.current.contains(event.target as Node)
+ ) {
+ return;
+ }
+ setShowDropdown(false);
+ };
+
+ document.addEventListener('mousedown', handleClickOutside);
+ document.addEventListener('touchstart', handleClickOutside);
+
+ return () => {
+ document.removeEventListener('mousedown', handleClickOutside);
+ document.removeEventListener('touchstart', handleClickOutside);
+ };
+ }, [dropdownRef]);
+
+ return (
+ <>
+ <div
+ ref={dropdownRef}
+ className={clsx(
+ 'dropdown dropdown--right margin-bottom--md',
+ showDropdown && 'dropdown--show',
+ )}
+ >
+ <a
+ href="#"
+ aria-haspopup="true"
+ aria-expanded={false}
+ role="button"
+ onClick={e => {
+ e.preventDefault();
+ setShowDropdown(!showDropdown);
+ }}
+ onKeyDown={e => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ setShowDropdown(!showDropdown);
+ }
+ }}
+ >
+ Filters
+ <IconFilters className={styles.icon} />
+ </a>
+ <ul className="dropdown__menu">
+ <li>
+ <label
+ htmlFor="private"
+ className={clsx(
+ 'dropdown__link',
+ filter.private && 'dropdown__link--active',
+ )}
+ >
+ <input
+ id="private"
+ type="checkbox"
+ className="margin-right--md"
+ checked={filter.private}
+ onChange={e => {
+ setFilter({
+ ...filter,
+ private: e.target.checked,
+ });
+ }}
+ />
+ Protected members
+ </label>
+ </li>
+ <li
+ onKeyDown={e => {
+ if (e.key === 'Tab') {
+ setShowDropdown(false);
+ }
+ }}
+ >
+ <label
+ htmlFor="inherited"
+ className={clsx(
+ 'dropdown__link',
+ filter.inherited && 'dropdown__link--active',
+ )}
+ >
+ <input
+ id="inherited"
+ type="checkbox"
+ className="margin-right--md"
+ checked={filter.inherited}
+ onChange={e => {
+ setFilter({
+ ...filter,
+ inherited: e.target.checked,
+ });
+ }}
+ />
+ Inherited members
+ </label>
+ </li>
+ </ul>
+ </div>
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Filters/index.module.css b/packages/docs/src/components/Api/Filters/index.module.css
new file mode 100644
index 00000000..b55e3b89
--- /dev/null
+++ b/packages/docs/src/components/Api/Filters/index.module.css
@@ -0,0 +1,18 @@
+.header {
+ flex-direction: row-reverse;
+}
+
+.filters {
+ width: auto;
+ flex-shrink: 0;
+ flex-grow: 0;
+ white-space: nowrap;
+ display: flex;
+ justify-content: end;
+ align-items: start;
+}
+
+.icon {
+ margin-left: 0.3em;
+ margin-bottom: -0.3em;
+}
diff --git a/packages/docs/src/components/Api/Filters/index.tsx b/packages/docs/src/components/Api/Filters/index.tsx
new file mode 100644
index 00000000..ac7bc28f
--- /dev/null
+++ b/packages/docs/src/components/Api/Filters/index.tsx
@@ -0,0 +1,26 @@
+import React, {ReactNode} from 'react';
+import Controls from './Controls';
+import clsx from 'clsx';
+import styles from './index.module.css';
+import {ReflectionKind} from '@site/src/components/Api/ReflectionKind';
+
+export default function Filters({
+ children,
+ kind,
+}: {
+ children: ReactNode;
+ kind: ReflectionKind;
+}) {
+ if (kind === ReflectionKind.Class || kind === ReflectionKind.Interface) {
+ return (
+ <div className={clsx('row', styles.header)}>
+ <div className={clsx('col', styles.filters)}>
+ <Controls />
+ </div>
+ <div className="col">{children}</div>
+ </div>
+ );
+ }
+
+ return <>{children}</>;
+}
diff --git a/packages/docs/src/components/Api/Group/Category.tsx b/packages/docs/src/components/Api/Group/Category.tsx
new file mode 100644
index 00000000..cef0a458
--- /dev/null
+++ b/packages/docs/src/components/Api/Group/Category.tsx
@@ -0,0 +1,37 @@
+import React from 'react';
+import Item from '@site/src/components/Api/Item';
+import ReferenceType from '@site/src/components/Api/Type/ReferenceType';
+import {FilteredGroup} from '@site/src/components/Api/Group/index';
+
+export default function Category({group}: {group: FilteredGroup}) {
+ if (
+ group.title === 'Constructors' &&
+ group.external.length === 0 &&
+ group.nested.length === 1
+ ) {
+ return <Item reflection={group.nested[0]} />;
+ }
+
+ return (
+ <>
+ {group.external.length > 0 && (
+ <ul>
+ {group.external.map(child => (
+ <li>
+ <code>
+ <ReferenceType type={child} />
+ </code>
+ </li>
+ ))}
+ </ul>
+ )}
+ {group.nested.length > 0 &&
+ group.nested.map((child, index) => (
+ <React.Fragment key={child.id}>
+ {index > 0 && <hr />}
+ <Item reflection={child} />
+ </React.Fragment>
+ ))}
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Group/index.tsx b/packages/docs/src/components/Api/Group/index.tsx
new file mode 100644
index 00000000..6c55d2bf
--- /dev/null
+++ b/packages/docs/src/components/Api/Group/index.tsx
@@ -0,0 +1,105 @@
+import React, {useEffect, useMemo} from 'react';
+import {useLocation} from '@docusaurus/router';
+import {ApiLookup, useApiLookup} from '@site/src/contexts/api';
+import {useTabGroupChoice} from '@docusaurus/theme-common/internal';
+import Heading from '@theme/Heading';
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+import Category from '@site/src/components/Api/Group/Category';
+import {Filters, matchFilters, useFilters} from '@site/src/contexts/filters';
+import type {JSONOutput} from 'typedoc';
+
+export interface FilteredGroup {
+ title: string;
+ external: JSONOutput.Reflection[];
+ nested: JSONOutput.Reflection[];
+ anchors: string[];
+}
+
+function filterGroup(
+ group: JSONOutput.ReflectionGroup,
+ lookup: ApiLookup,
+ filters: Filters,
+): FilteredGroup {
+ const external = [];
+ const nested = [];
+ const anchors = [];
+ for (const child of group.children) {
+ const reference = lookup[child];
+ if (!reference || !matchFilters(filters, reference)) continue;
+
+ anchors.push(reference.anchor);
+ if (reference.hasOwnPage) {
+ external.push(reference);
+ } else {
+ nested.push(reference);
+ }
+ }
+
+ if (external.length > 0 || nested.length > 0) {
+ return {
+ title: group.title,
+ external,
+ nested,
+ anchors,
+ };
+ }
+}
+
+export default function Group({group}: {group: JSONOutput.ReflectionGroup}) {
+ const location = useLocation();
+ const lookup = useApiLookup();
+ const {setTabGroupChoices} = useTabGroupChoice();
+ const hash = location.hash.split('-')[0].slice(1);
+ const [filters] = useFilters();
+
+ const categories = useMemo(
+ () =>
+ (group.categories ?? [group])
+ .map(group => filterGroup(group, lookup, filters))
+ .filter(group => !!group),
+ [group, lookup, filters],
+ );
+
+ useEffect(() => {
+ if (categories.length === 1) return;
+
+ const hash = location.hash.split('-')[0].slice(1);
+ for (const category of categories) {
+ if (category.anchors.includes(hash)) {
+ setTabGroupChoices(group.title, category.title);
+ return;
+ }
+ }
+ }, [location.hash, categories]);
+
+ if (categories.length === 0) {
+ return <></>;
+ }
+
+ return (
+ <>
+ <Heading as={'h2'} id={group.title}>
+ {group.title}
+ </Heading>
+ {categories.length > 1 ? (
+ <Tabs groupId={group.title}>
+ {categories.map(category => {
+ return (
+ <TabItem
+ default={category.anchors.includes(hash)}
+ value={category.title}
+ label={category.title}
+ className="margin-top--lg"
+ >
+ <Category group={category} />
+ </TabItem>
+ );
+ })}
+ </Tabs>
+ ) : (
+ <Category group={categories[0]} />
+ )}
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Item/ClassItem.tsx b/packages/docs/src/components/Api/Item/ClassItem.tsx
new file mode 100644
index 00000000..f9c4d88b
--- /dev/null
+++ b/packages/docs/src/components/Api/Item/ClassItem.tsx
@@ -0,0 +1,71 @@
+import React from 'react';
+import CodeBlock from '@site/src/components/Api/Code/CodeBlock';
+import Container from '@site/src/components/Api/Code/Container';
+import Preview from '@site/src/components/Api/Preview';
+import Signatures from '@site/src/components/Api/Signatures';
+import Line from '@site/src/components/Api/Code/Line';
+import type {JSONOutput} from 'typedoc';
+import Comment from '@site/src/components/Api/Comment';
+import ReferenceType from '@site/src/components/Api/Type/ReferenceType';
+import TypeParameters from '@site/src/components/Api/TypeParameters';
+import Filters from '@site/src/components/Api/Filters';
+import Group from '@site/src/components/Api/Group';
+
+export default function ClassItem({
+ reflection,
+}: {
+ reflection: JSONOutput.DeclarationReflection;
+}) {
+ return (
+ <>
+ <Container>
+ <CodeBlock link={reflection.sources?.[0]?.url}>
+ <Line>
+ <Preview reflection={reflection} />
+ </Line>
+ </CodeBlock>
+ </Container>
+ <Filters kind={reflection.kind}>
+ <Comment comment={reflection.comment} />
+ </Filters>
+ <TypeParameters parameters={reflection.typeParameters}></TypeParameters>
+ {reflection.implementedBy?.length && (
+ <>
+ <h4>Implemented by</h4>
+ <ul>
+ {reflection.implementedBy.map(type => (
+ <li key={type.id}>
+ <code>
+ <ReferenceType type={type} />
+ </code>
+ </li>
+ ))}
+ </ul>
+ </>
+ )}
+ {reflection.extendedBy?.length && (
+ <>
+ <h4>Extended by</h4>
+ <ul>
+ {reflection.extendedBy.map(type => (
+ <li key={type.id}>
+ <code>
+ <ReferenceType type={type} />
+ </code>
+ </li>
+ ))}
+ </ul>
+ </>
+ )}
+ {reflection.signatures && (
+ <>
+ <h2>Callable</h2>
+ <Signatures signatures={reflection.signatures} />
+ </>
+ )}
+ {reflection.groups?.map(group => (
+ <Group group={group} key={group.title} />
+ ))}
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Item/FunctionItem.tsx b/packages/docs/src/components/Api/Item/FunctionItem.tsx
new file mode 100644
index 00000000..c98ae38e
--- /dev/null
+++ b/packages/docs/src/components/Api/Item/FunctionItem.tsx
@@ -0,0 +1,52 @@
+import React from 'react';
+
+import Signatures from '@site/src/components/Api/Signatures';
+import type {JSONOutput} from 'typedoc';
+import Heading from '@theme/Heading';
+import ReferenceType from '@site/src/components/Api/Type/ReferenceType';
+
+export default function FunctionItem({
+ reflection,
+}: {
+ reflection: JSONOutput.DeclarationReflection;
+}) {
+ const signatures = [
+ ...(reflection.signatures ?? []),
+ reflection.setSignature,
+ reflection.getSignature,
+ reflection.indexSignature,
+ ].filter(item => !!item);
+
+ return (
+ <>
+ {reflection.hasOwnPage ? (
+ <h1>{reflection.name}</h1>
+ ) : (
+ <Heading as="h3" id={reflection.anchor}>
+ <code>{reflection.name}</code>
+ </Heading>
+ )}
+ <Signatures
+ signatures={signatures}
+ flags={reflection.flags}
+ source={reflection.sources?.[0]}
+ />
+ {reflection.inheritedFrom && (
+ <>
+ Inherited from{' '}
+ <code>
+ <ReferenceType type={reflection.inheritedFrom} />
+ </code>
+ </>
+ )}
+ {reflection.overwrites && (
+ <>
+ Overwrites{' '}
+ <code>
+ <ReferenceType type={reflection.overwrites} />
+ </code>
+ </>
+ )}
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Item/ModuleItem.tsx b/packages/docs/src/components/Api/Item/ModuleItem.tsx
new file mode 100644
index 00000000..2f263cf9
--- /dev/null
+++ b/packages/docs/src/components/Api/Item/ModuleItem.tsx
@@ -0,0 +1,26 @@
+import React from 'react';
+import type {JSONOutput} from 'typedoc';
+import Comment from '@site/src/components/Api/Comment';
+import Group from '@site/src/components/Api/Group';
+import Filters from '@site/src/components/Api/Filters';
+import CodeBlock from '@theme/CodeBlock';
+
+export default function ModuleItem({
+ reflection,
+}: {
+ reflection: JSONOutput.DeclarationReflection;
+}) {
+ return (
+ <>
+ <CodeBlock language="ts">
+ import {'{...}'} from "{reflection.importPath}";
+ </CodeBlock>
+ <Filters kind={reflection.kind}>
+ <Comment comment={reflection.comment} />
+ </Filters>
+ {reflection.groups?.map(group => (
+ <Group group={group} key={group.title} />
+ ))}
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Item/ProjectItem.tsx b/packages/docs/src/components/Api/Item/ProjectItem.tsx
new file mode 100644
index 00000000..b4747585
--- /dev/null
+++ b/packages/docs/src/components/Api/Item/ProjectItem.tsx
@@ -0,0 +1,39 @@
+import React from 'react';
+import type {JSONOutput} from 'typedoc';
+import {useApiLookup} from '@site/src/contexts/api';
+import Link from '@docusaurus/Link';
+import clsx from 'clsx';
+import styles from './styles.module.css';
+
+export default function ProjectItem({
+ reflection,
+}: {
+ reflection: JSONOutput.DeclarationReflection;
+}) {
+ const lookup = useApiLookup();
+ const modules = reflection.groups[0].children
+ .map(id => lookup[id])
+ .filter(module => !!module);
+
+ return (
+ <article className="margin-top--lg">
+ <section className={clsx('row')}>
+ {modules.map(module => (
+ <article key={module.id} className="col col--6 margin-bottom--lg">
+ <Link
+ href={module.href}
+ className={clsx('card padding--lg', styles.cardContainer)}
+ >
+ <h2 className={clsx('text--truncate', styles.cardTitle)}>
+ <code>{module.name}</code>
+ </h2>
+ <div className={clsx('text--truncate', styles.cardDescription)}>
+ {module.comment?.summaryText ?? '\u00A0'}
+ </div>
+ </Link>
+ </article>
+ ))}
+ </section>
+ </article>
+ );
+}
diff --git a/packages/docs/src/components/Api/Item/PropertyItem.tsx b/packages/docs/src/components/Api/Item/PropertyItem.tsx
new file mode 100644
index 00000000..9bf23f79
--- /dev/null
+++ b/packages/docs/src/components/Api/Item/PropertyItem.tsx
@@ -0,0 +1,44 @@
+import React from 'react';
+
+import CodeBlock from '@site/src/components/Api/Code/CodeBlock';
+import Container from '@site/src/components/Api/Code/Container';
+import Line from '@site/src/components/Api/Code/Line';
+import PropertyPreview from '@site/src/components/Api/Preview/PropertyPreview';
+import Heading from '@theme/Heading';
+import Comment from '@site/src/components/Api/Comment';
+import ReferenceType from '@site/src/components/Api/Type/ReferenceType';
+import type {JSONOutput} from 'typedoc';
+
+export default function PropertyItem({
+ reflection,
+}: {
+ reflection: JSONOutput.DeclarationReflection;
+}) {
+ return (
+ <>
+ {reflection.hasOwnPage ? (
+ <h1>{reflection.name}</h1>
+ ) : (
+ <Heading as="h3" id={reflection.anchor}>
+ <code>{reflection.name}</code>
+ </Heading>
+ )}
+ <Container>
+ <CodeBlock link={reflection.sources?.[0]?.url}>
+ <Line>
+ <PropertyPreview reflection={reflection} />
+ </Line>
+ </CodeBlock>
+ </Container>
+ <Comment comment={reflection.comment} />
+ {reflection.inheritedFrom && (
+ <>
+ Inherited from{' '}
+ <code>
+ <ReferenceType type={reflection.inheritedFrom} />
+ </code>
+ </>
+ )}
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Item/TypeAliasItem.tsx b/packages/docs/src/components/Api/Item/TypeAliasItem.tsx
new file mode 100644
index 00000000..07028cf9
--- /dev/null
+++ b/packages/docs/src/components/Api/Item/TypeAliasItem.tsx
@@ -0,0 +1,60 @@
+import React from 'react';
+
+import {useApiLookup} from '@site/src/contexts/api';
+import CodeBlock from '@site/src/components/Api/Code/CodeBlock';
+import Container from '@site/src/components/Api/Code/Container';
+import Line from '@site/src/components/Api/Code/Line';
+import Preview from '@site/src/components/Api/Preview';
+import Item from '@site/src/components/Api/Item';
+import Heading from '@theme/Heading';
+import Comment from '@site/src/components/Api/Comment';
+import TypeParameters from '@site/src/components/Api/TypeParameters';
+import Signatures from '@site/src/components/Api/Signatures';
+import type {JSONOutput} from 'typedoc';
+
+export default function TypeAliasItem({
+ reflection,
+}: {
+ reflection: JSONOutput.DeclarationReflection;
+}) {
+ const lookup = useApiLookup();
+
+ return (
+ <>
+ <Heading as="h3" id={reflection.anchor}>
+ <code>{reflection.name}</code>
+ </Heading>
+ <Container>
+ <CodeBlock link={reflection.sources?.[0]?.url}>
+ <Line>
+ <Preview reflection={reflection} />
+ </Line>
+ </CodeBlock>
+ </Container>
+ <Comment comment={reflection.comment} />
+ <TypeParameters parameters={reflection.typeParameters}></TypeParameters>
+ {reflection.signatures && (
+ <>
+ <h2>Callable</h2>
+ <Signatures signatures={reflection.signatures} />
+ </>
+ )}
+ {reflection.groups?.map(group => (
+ <React.Fragment key={group.title}>
+ <h2>{group.title}</h2>
+ {group.children
+ .map(child => lookup[child])
+ .filter(
+ child =>
+ child &&
+ (child.flags.isPublic ||
+ (!child.flags.isProtected && !child.flags.isPrivate)),
+ )
+ .map(child => (
+ <Item key={child.id} reflection={child} />
+ ))}
+ </React.Fragment>
+ ))}
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Item/index.tsx b/packages/docs/src/components/Api/Item/index.tsx
new file mode 100644
index 00000000..bd893804
--- /dev/null
+++ b/packages/docs/src/components/Api/Item/index.tsx
@@ -0,0 +1,66 @@
+import React, {useMemo} from 'react';
+import type {JSONOutput} from 'typedoc';
+import {ReflectionKind} from '../ReflectionKind';
+import ClassItem from '@site/src/components/Api/Item/ClassItem';
+import FunctionItem from '@site/src/components/Api/Item/FunctionItem';
+import PropertyItem from '@site/src/components/Api/Item/PropertyItem';
+import TypeAliasItem from '@site/src/components/Api/Item/TypeAliasItem';
+import ModuleItem from '@site/src/components/Api/Item/ModuleItem';
+import ProjectItem from '@site/src/components/Api/Item/ProjectItem';
+
+export default function Item({
+ reflection,
+}: {
+ reflection: JSONOutput.DeclarationReflection;
+}) {
+ const Component = useMemo(() => {
+ switch (reflection.kind as ReflectionKind) {
+ case ReflectionKind.Project:
+ return ProjectItem;
+ case ReflectionKind.Module:
+ return ModuleItem;
+ case ReflectionKind.Namespace:
+ case ReflectionKind.Enum:
+ case ReflectionKind.Class:
+ case ReflectionKind.Interface:
+ return ClassItem;
+ case ReflectionKind.Function:
+ case ReflectionKind.Accessor:
+ case ReflectionKind.Constructor:
+ case ReflectionKind.Method:
+ return FunctionItem;
+ case ReflectionKind.Variable:
+ case ReflectionKind.Property:
+ case ReflectionKind.EnumMember:
+ return PropertyItem;
+ case ReflectionKind.CallSignature:
+ break;
+ case ReflectionKind.IndexSignature:
+ break;
+ case ReflectionKind.ConstructorSignature:
+ break;
+ case ReflectionKind.Parameter:
+ break;
+ case ReflectionKind.TypeLiteral:
+ break;
+ case ReflectionKind.TypeParameter:
+ break;
+ case ReflectionKind.GetSignature:
+ break;
+ case ReflectionKind.SetSignature:
+ break;
+ case ReflectionKind.ObjectLiteral:
+ break;
+ case ReflectionKind.TypeAlias:
+ return TypeAliasItem;
+ case ReflectionKind.Reference:
+ break;
+ }
+
+ throw new Error(
+ `Missing component for reflection: ${reflection.kindString}`,
+ );
+ }, [reflection.kind]);
+
+ return <Component reflection={reflection} />;
+}
diff --git a/packages/docs/src/components/Api/Item/styles.module.css b/packages/docs/src/components/Api/Item/styles.module.css
new file mode 100644
index 00000000..4f7ad27f
--- /dev/null
+++ b/packages/docs/src/components/Api/Item/styles.module.css
@@ -0,0 +1,27 @@
+.cardContainer {
+ --ifm-link-color: var(--ifm-color-emphasis-800);
+ --ifm-link-hover-color: var(--ifm-color-emphasis-700);
+ --ifm-link-hover-decoration: none;
+
+ box-shadow: 0 1.5px 3px 0 rgb(0 0 0 / 15%);
+ border: 1px solid var(--ifm-color-emphasis-200);
+ transition: all var(--ifm-transition-fast) ease;
+ transition-property: border, box-shadow;
+}
+
+.cardContainer:hover {
+ border-color: var(--ifm-color-primary);
+ box-shadow: 0 3px 6px 0 rgb(0 0 0 / 20%);
+}
+
+.cardContainer *:last-child {
+ margin-bottom: 0;
+}
+
+.cardTitle {
+ font-size: 1.2rem;
+}
+
+.cardDescription {
+ font-size: 0.8rem;
+}
diff --git a/packages/docs/src/components/Api/Parameters/index.tsx b/packages/docs/src/components/Api/Parameters/index.tsx
new file mode 100644
index 00000000..cedf1326
--- /dev/null
+++ b/packages/docs/src/components/Api/Parameters/index.tsx
@@ -0,0 +1,32 @@
+import React from 'react';
+import type {JSONOutput} from 'typedoc';
+import Summary from '@site/src/components/Api/Comment/Summary';
+import ParameterPreview from '@site/src/components/Api/Preview/ParameterPreview';
+
+export default function Parameters({
+ parameters,
+}: {
+ parameters: JSONOutput.ParameterReflection[];
+}) {
+ if (!parameters?.length) {
+ return <></>;
+ }
+
+ return (
+ <>
+ <h4>Parameters</h4>
+ <ul>
+ {parameters.map(parameter => (
+ <li key={parameter.id}>
+ <code>
+ <ParameterPreview
+ reflection={parameter as JSONOutput.ParameterReflection}
+ />
+ </code>
+ <Summary id={parameter.comment?.summaryId} />
+ </li>
+ ))}
+ </ul>
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Preview/ClassPreview.tsx b/packages/docs/src/components/Api/Preview/ClassPreview.tsx
new file mode 100644
index 00000000..92b1cd50
--- /dev/null
+++ b/packages/docs/src/components/Api/Preview/ClassPreview.tsx
@@ -0,0 +1,57 @@
+import React from 'react';
+
+import type {JSONOutput} from 'typedoc';
+import Token from '@site/src/components/Api/Code/Token';
+import Type from '@site/src/components/Api/Type';
+import TokenList, {ListType} from '@site/src/components/Api/Code/TokenList';
+import FlagsPreview from '@site/src/components/Api/Preview/FlagsPreview';
+import {ReflectionKind} from '@site/src/components/Api/ReflectionKind';
+import TypeParameterPreview from '@site/src/components/Api/Preview/TypeParameterPreview';
+
+const mainKeyword = {
+ [ReflectionKind.Namespace]: 'namespace',
+ [ReflectionKind.Enum]: 'enum',
+ [ReflectionKind.Class]: 'class',
+ [ReflectionKind.Interface]: 'interface',
+};
+
+export default function ClassPreview({
+ reflection,
+}: {
+ reflection: JSONOutput.DeclarationReflection;
+}) {
+ return (
+ <>
+ <FlagsPreview flags={reflection.flags} />
+ <Token type="keyword">{mainKeyword[reflection.kind]} </Token>
+ <Token type="class-name">{reflection.name}</Token>
+ {!!reflection.typeParameters?.length && (
+ <TokenList type={ListType.Angle}>
+ {reflection.typeParameters.map((type, index) => (
+ <TypeParameterPreview key={index} reflection={type} />
+ ))}
+ </TokenList>
+ )}{' '}
+ {!!reflection.extendedTypes?.length && (
+ <>
+ <Token type="keyword">extends </Token>
+ <TokenList>
+ {reflection.extendedTypes.map((type, index) => (
+ <Type key={index} type={type} />
+ ))}
+ </TokenList>
+ </>
+ )}
+ {!!reflection.implementedTypes?.length && (
+ <>
+ <Token type="keyword">implements </Token>
+ <TokenList>
+ {reflection.implementedTypes.map((type, index) => (
+ <Type key={index} type={type} />
+ ))}
+ </TokenList>
+ </>
+ )}
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Preview/FlagsPreview.tsx b/packages/docs/src/components/Api/Preview/FlagsPreview.tsx
new file mode 100644
index 00000000..9b87508f
--- /dev/null
+++ b/packages/docs/src/components/Api/Preview/FlagsPreview.tsx
@@ -0,0 +1,48 @@
+import React from 'react';
+import type {JSONOutput} from 'typedoc';
+import Token from '@site/src/components/Api/Code/Token';
+
+export default function FlagsPreview({
+ flags,
+ explicitAccessModifier,
+}: {
+ flags: JSONOutput.ReflectionFlags;
+ explicitAccessModifier?: boolean;
+}) {
+ const tokens = [];
+
+ if (flags?.isAbstract) {
+ tokens.push('abstract');
+ }
+ if (flags?.isStatic) {
+ tokens.push('static');
+ }
+ if (flags?.isConst) {
+ tokens.push('const');
+ }
+ if (flags?.isReadonly) {
+ tokens.push('readonly');
+ }
+ if (flags?.isPrivate) {
+ tokens.push('private');
+ }
+ if (flags?.isProtected) {
+ tokens.push('protected');
+ }
+ if (
+ flags?.isPublic ||
+ (explicitAccessModifier && !flags?.isProtected && !flags?.isPrivate)
+ ) {
+ tokens.push('public');
+ }
+
+ return (
+ <>
+ {tokens.map(token => (
+ <Token key={token} type="keyword">
+ {token}{' '}
+ </Token>
+ ))}
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Preview/FunctionPreview.tsx b/packages/docs/src/components/Api/Preview/FunctionPreview.tsx
new file mode 100644
index 00000000..ca08efd4
--- /dev/null
+++ b/packages/docs/src/components/Api/Preview/FunctionPreview.tsx
@@ -0,0 +1,18 @@
+import React from 'react';
+
+import type {JSONOutput} from 'typedoc';
+import SignaturePreview from '@site/src/components/Api/Preview/SignaturePreview';
+
+export default function FunctionPreview({
+ reflection,
+}: {
+ reflection: JSONOutput.DeclarationReflection;
+}) {
+ const signature =
+ reflection.signatures?.[0] ??
+ reflection.getSignature ??
+ reflection.setSignature ??
+ reflection.indexSignature;
+
+ return <SignaturePreview reflection={signature} />;
+}
diff --git a/packages/docs/src/components/Api/Preview/ParameterPreview.tsx b/packages/docs/src/components/Api/Preview/ParameterPreview.tsx
new file mode 100644
index 00000000..661f3271
--- /dev/null
+++ b/packages/docs/src/components/Api/Preview/ParameterPreview.tsx
@@ -0,0 +1,37 @@
+import React from 'react';
+import type {JSONOutput} from 'typedoc';
+import Type from '@site/src/components/Api/Type';
+import Token from '@site/src/components/Api/Code/Token';
+import FlagsPreview from '@site/src/components/Api/Preview/FlagsPreview';
+
+export default function ParameterPreview({
+ reflection,
+}: {
+ reflection: JSONOutput.ParameterReflection;
+}) {
+ const name =
+ reflection.name === '__namedParameters' ? '{...}' : reflection.name;
+
+ return (
+ <>
+ <FlagsPreview flags={reflection.flags} />
+ {reflection.flags.isRest && '...'}
+ <Token
+ id={reflection.anchor}
+ to={reflection.anchor ? `#${reflection.anchor}` : undefined}
+ type="plain"
+ >
+ {name}
+ </Token>
+ {reflection.flags.isOptional && '?'}
+ {': '}
+ {reflection.type && <Type type={reflection.type} />}
+ {reflection.defaultValue && (
+ <>
+ {' = '}
+ <Token type="plain">{reflection.defaultValue}</Token>
+ </>
+ )}
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Preview/PropertyPreview.tsx b/packages/docs/src/components/Api/Preview/PropertyPreview.tsx
new file mode 100644
index 00000000..fb2e40b2
--- /dev/null
+++ b/packages/docs/src/components/Api/Preview/PropertyPreview.tsx
@@ -0,0 +1,12 @@
+import React from 'react';
+
+import type {JSONOutput} from 'typedoc';
+import ParameterPreview from '@site/src/components/Api/Preview/ParameterPreview';
+
+export default function PropertyPreview({
+ reflection,
+}: {
+ reflection: JSONOutput.SignatureReflection;
+}) {
+ return <ParameterPreview reflection={reflection} />;
+}
diff --git a/packages/docs/src/components/Api/Preview/SignaturePreview.tsx b/packages/docs/src/components/Api/Preview/SignaturePreview.tsx
new file mode 100644
index 00000000..877d5241
--- /dev/null
+++ b/packages/docs/src/components/Api/Preview/SignaturePreview.tsx
@@ -0,0 +1,80 @@
+import React from 'react';
+
+import type {JSONOutput} from 'typedoc';
+import {ReflectionKind} from '@site/src/components/Api/ReflectionKind';
+import ParameterPreview from '@site/src/components/Api/Preview/ParameterPreview';
+import Type from '@site/src/components/Api/Type';
+import Token from '@site/src/components/Api/Code/Token';
+import TokenList, {ListType} from '@site/src/components/Api/Code/TokenList';
+import TypeParameterPreview from '@site/src/components/Api/Preview/TypeParameterPreview';
+import {getUrl, useApiLookup} from '@site/src/contexts/api';
+import FlagsPreview from '@site/src/components/Api/Preview/FlagsPreview';
+
+export default function SignaturePreview({
+ reflection,
+ flags,
+}: {
+ reflection: JSONOutput.SignatureReflection;
+ flags?: JSONOutput.ReflectionFlags;
+}) {
+ const lookup = useApiLookup();
+ const isArrow = reflection.name === '__type';
+
+ return (
+ <>
+ <FlagsPreview
+ flags={flags ?? reflection.flags}
+ explicitAccessModifier={!isArrow}
+ />
+ {reflection.kind === ReflectionKind.GetSignature && (
+ <Token type="keyword">get </Token>
+ )}
+ {reflection.kind === ReflectionKind.SetSignature && (
+ <Token type="keyword">set </Token>
+ )}
+ {reflection.overwrites && (
+ <>
+ <Token to={getUrl(lookup[reflection.overwrites.id])} type="keyword">
+ override
+ </Token>{' '}
+ </>
+ )}
+ {reflection.kind === ReflectionKind.ConstructorSignature ? (
+ <>
+ <Token to={'#'} type="keyword">
+ new
+ </Token>{' '}
+ <Token type="plain">
+ {(reflection.type as JSONOutput.ReferenceType).name}
+ </Token>
+ </>
+ ) : isArrow ? (
+ ''
+ ) : (
+ <Token type="plain">{reflection.name}</Token>
+ )}
+ {!!reflection.typeParameter?.length && (
+ <TokenList type={ListType.Angle}>
+ {reflection.typeParameter.map(type => (
+ <TypeParameterPreview key={type.id} reflection={type} />
+ ))}
+ </TokenList>
+ )}
+ {reflection.parameters?.length ? (
+ <TokenList type={ListType.Parentheses}>
+ {reflection.parameters.map(parameter => (
+ <ParameterPreview key={parameter.id} reflection={parameter} />
+ ))}
+ </TokenList>
+ ) : (
+ '()'
+ )}
+ {reflection.type && (
+ <>
+ {isArrow ? ' => ' : ': '}
+ <Type type={reflection.type} />
+ </>
+ )}
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Preview/TypeAliasPreview.tsx b/packages/docs/src/components/Api/Preview/TypeAliasPreview.tsx
new file mode 100644
index 00000000..8aaaa047
--- /dev/null
+++ b/packages/docs/src/components/Api/Preview/TypeAliasPreview.tsx
@@ -0,0 +1,31 @@
+import React from 'react';
+
+import type {JSONOutput} from 'typedoc';
+import Token from '@site/src/components/Api/Code/Token';
+import TokenList, {ListType} from '@site/src/components/Api/Code/TokenList';
+import Type from '@site/src/components/Api/Type';
+import TypeParameterPreview from '@site/src/components/Api/Preview/TypeParameterPreview';
+import FlagsPreview from '@site/src/components/Api/Preview/FlagsPreview';
+
+export default function TypeAliasPreview({
+ reflection,
+}: {
+ reflection: JSONOutput.DeclarationReflection;
+}) {
+ return (
+ <>
+ <FlagsPreview flags={reflection.flags} />
+ <Token type="keyword">type </Token>
+ <Token type="class-name">{reflection.name}</Token>
+ {reflection.typeParameters && (
+ <TokenList type={ListType.Angle}>
+ {reflection.typeParameters.map((type, index) => (
+ <TypeParameterPreview key={index} reflection={type} />
+ ))}
+ </TokenList>
+ )}
+ {' = '}
+ <Type type={reflection.type} />
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Preview/TypeLiteralPreview.tsx b/packages/docs/src/components/Api/Preview/TypeLiteralPreview.tsx
new file mode 100644
index 00000000..da6f413f
--- /dev/null
+++ b/packages/docs/src/components/Api/Preview/TypeLiteralPreview.tsx
@@ -0,0 +1,32 @@
+import React from 'react';
+
+import type {JSONOutput} from 'typedoc';
+import Token from '@site/src/components/Api/Code/Token';
+import TokenList, {ListType} from '@site/src/components/Api/Code/TokenList';
+import SignaturePreview from '@site/src/components/Api/Preview/SignaturePreview';
+import Preview from '@site/src/components/Api/Preview';
+
+export default function TypeLiteralPreview({
+ reflection,
+}: {
+ reflection: JSONOutput.DeclarationReflection;
+}) {
+ if (reflection.signatures) {
+ return <SignaturePreview reflection={reflection.signatures[0]} />;
+ }
+ if (reflection.children) {
+ return (
+ <TokenList type={ListType.Curly}>
+ {reflection.children.map(child => (
+ <Preview key={child.id} reflection={child} />
+ ))}
+ </TokenList>
+ );
+ }
+
+ return (
+ <>
+ <Token type="keyword">unknown</Token>
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Preview/TypeParameterPreview.tsx b/packages/docs/src/components/Api/Preview/TypeParameterPreview.tsx
new file mode 100644
index 00000000..d6acf13e
--- /dev/null
+++ b/packages/docs/src/components/Api/Preview/TypeParameterPreview.tsx
@@ -0,0 +1,39 @@
+import React from 'react';
+import type {JSONOutput} from 'typedoc';
+import FlagsSummary from '@site/src/components/Api/Preview/FlagsPreview';
+import Token from '@site/src/components/Api/Code/Token';
+import Type from '@site/src/components/Api/Type';
+
+export default function TypeParameterPreview({
+ reflection,
+}: {
+ reflection: JSONOutput.TypeParameterReflection;
+}) {
+ return (
+ <>
+ <FlagsSummary flags={reflection.flags} />
+ {reflection.varianceModifier && (
+ <Token type="keyword">{reflection.varianceModifier} </Token>
+ )}
+ <Token
+ id={reflection.anchor}
+ to={reflection.anchor ? `#${reflection.anchor}` : undefined}
+ type="class-name"
+ >
+ {reflection.name}
+ </Token>
+ {reflection.type && (
+ <>
+ {' extends '}
+ <Type type={reflection.type} />
+ </>
+ )}
+ {reflection.default && (
+ <>
+ {' = '}
+ <Type type={reflection.default} />
+ </>
+ )}
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Preview/index.tsx b/packages/docs/src/components/Api/Preview/index.tsx
new file mode 100644
index 00000000..e96b0438
--- /dev/null
+++ b/packages/docs/src/components/Api/Preview/index.tsx
@@ -0,0 +1,72 @@
+import React, {useMemo} from 'react';
+import {ReflectionKind} from '@site/src/components/Api/ReflectionKind';
+import SignaturePreview from '@site/src/components/Api/Preview/SignaturePreview';
+import PropertyPreview from '@site/src/components/Api/Preview/PropertyPreview';
+import ClassPreview from '@site/src/components/Api/Preview/ClassPreview';
+import TypeAliasPreview from '@site/src/components/Api/Preview/TypeAliasPreview';
+import TypeParameterPreview from '@site/src/components/Api/Preview/TypeParameterPreview';
+import TypeLiteralPreview from '@site/src/components/Api/Preview/TypeLiteralPreview';
+import FunctionPreview from '@site/src/components/Api/Preview/FunctionPreview';
+import type {JSONOutput} from 'typedoc';
+
+export default function CodePreview({
+ reflection,
+}: {
+ reflection: JSONOutput.DeclarationReflection;
+}) {
+ const Component = useMemo(() => {
+ switch (reflection.kind as ReflectionKind) {
+ case ReflectionKind.Project:
+ break;
+ case ReflectionKind.Module:
+ break;
+ case ReflectionKind.EnumMember:
+ break;
+ case ReflectionKind.Variable:
+ break;
+ case ReflectionKind.Function:
+ break;
+ case ReflectionKind.Namespace:
+ case ReflectionKind.Enum:
+ case ReflectionKind.Class:
+ case ReflectionKind.Interface:
+ return ClassPreview;
+ case ReflectionKind.Constructor:
+ return SignaturePreview;
+ case ReflectionKind.Property:
+ return PropertyPreview;
+ case ReflectionKind.Method:
+ return FunctionPreview;
+ case ReflectionKind.CallSignature:
+ break;
+ case ReflectionKind.IndexSignature:
+ break;
+ case ReflectionKind.ConstructorSignature:
+ break;
+ case ReflectionKind.Parameter:
+ break;
+ case ReflectionKind.TypeLiteral:
+ return TypeLiteralPreview;
+ case ReflectionKind.TypeParameter:
+ return TypeParameterPreview;
+ case ReflectionKind.Accessor:
+ break;
+ case ReflectionKind.GetSignature:
+ break;
+ case ReflectionKind.SetSignature:
+ break;
+ case ReflectionKind.ObjectLiteral:
+ break;
+ case ReflectionKind.TypeAlias:
+ return TypeAliasPreview;
+ case ReflectionKind.Reference:
+ break;
+ }
+
+ throw new Error(
+ `Missing component for reflection: ${reflection.kindString}`,
+ );
+ }, [reflection.id]);
+
+ return <Component reflection={reflection} />;
+}
diff --git a/packages/docs/src/components/Api/ReflectionKind.ts b/packages/docs/src/components/Api/ReflectionKind.ts
new file mode 100644
index 00000000..506bf165
--- /dev/null
+++ b/packages/docs/src/components/Api/ReflectionKind.ts
@@ -0,0 +1,26 @@
+export enum ReflectionKind {
+ Project = 1,
+ Module = 2,
+ Namespace = 4,
+ Enum = 8,
+ EnumMember = 16,
+ Variable = 32,
+ Function = 64,
+ Class = 128,
+ Interface = 256,
+ Constructor = 512,
+ Property = 1024,
+ Method = 2048,
+ CallSignature = 4096,
+ IndexSignature = 8192,
+ ConstructorSignature = 16384,
+ Parameter = 32768,
+ TypeLiteral = 65536,
+ TypeParameter = 131072,
+ Accessor = 262144,
+ GetSignature = 524288,
+ SetSignature = 1048576,
+ ObjectLiteral = 2097152,
+ TypeAlias = 4194304,
+ Reference = 8388608,
+}
diff --git a/packages/docs/src/components/Api/Signatures/index.tsx b/packages/docs/src/components/Api/Signatures/index.tsx
new file mode 100644
index 00000000..02007f38
--- /dev/null
+++ b/packages/docs/src/components/Api/Signatures/index.tsx
@@ -0,0 +1,46 @@
+import React, {useState} from 'react';
+
+import Container from '@site/src/components/Api/Code/Container';
+import CodeBlock from '@site/src/components/Api/Code/CodeBlock';
+import SignaturePreview from '@site/src/components/Api/Preview/SignaturePreview';
+import Line from '@site/src/components/Api/Code/Line';
+import Comment from '@site/src/components/Api/Comment';
+import TypeParameters from '@site/src/components/Api/TypeParameters';
+import type {JSONOutput} from 'typedoc';
+import Parameters from '@site/src/components/Api/Parameters';
+
+export default function Signatures({
+ signatures,
+ flags,
+ source,
+}: {
+ signatures: JSONOutput.SignatureReflection[];
+ flags?: JSONOutput.ReflectionFlags;
+ source?: JSONOutput.SourceReference;
+}) {
+ const [signature, setSignature] = useState(signatures[0]);
+
+ return (
+ <>
+ <Container>
+ {signatures.map(child => (
+ <CodeBlock
+ link={source?.url}
+ key={child.id}
+ highlight={signatures.length > 1 && child.id === signature.id}
+ onClick={
+ signatures.length > 1 ? () => setSignature(child) : undefined
+ }
+ >
+ <Line>
+ <SignaturePreview reflection={child} flags={flags} />
+ </Line>
+ </CodeBlock>
+ ))}
+ </Container>
+ <Comment comment={signature.comment} />
+ <TypeParameters parameters={signature.typeParameter}></TypeParameters>
+ <Parameters parameters={signature.parameters}></Parameters>
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Type/ArrayType.tsx b/packages/docs/src/components/Api/Type/ArrayType.tsx
new file mode 100644
index 00000000..f48b8a53
--- /dev/null
+++ b/packages/docs/src/components/Api/Type/ArrayType.tsx
@@ -0,0 +1,13 @@
+import React from 'react';
+
+import type {JSONOutput} from 'typedoc';
+import Type from '@site/src/components/Api/Type';
+
+export default function ArrayType({type}: {type: JSONOutput.ArrayType}) {
+ return (
+ <>
+ <Type type={type.elementType} />
+ []
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Type/ConditionalType.tsx b/packages/docs/src/components/Api/Type/ConditionalType.tsx
new file mode 100644
index 00000000..7da8fe90
--- /dev/null
+++ b/packages/docs/src/components/Api/Type/ConditionalType.tsx
@@ -0,0 +1,23 @@
+import React from 'react';
+
+import type {JSONOutput} from 'typedoc';
+import Type from '@site/src/components/Api/Type';
+import Token from '@site/src/components/Api/Code/Token';
+
+export default function ConditionalType({
+ type,
+}: {
+ type: JSONOutput.ConditionalType;
+}) {
+ return (
+ <>
+ <Type type={type.checkType} />
+ <Token type="keyword"> extends </Token>
+ <Type type={type.extendsType} />
+ {' ? '}
+ <Type type={type.trueType} />
+ {' : '}
+ <Type type={type.falseType} />
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Type/IndexedAccessType.tsx b/packages/docs/src/components/Api/Type/IndexedAccessType.tsx
new file mode 100644
index 00000000..288bdfea
--- /dev/null
+++ b/packages/docs/src/components/Api/Type/IndexedAccessType.tsx
@@ -0,0 +1,17 @@
+import React from 'react';
+
+import type {JSONOutput} from 'typedoc';
+import Type from '@site/src/components/Api/Type';
+
+export default function IndexedAccessType({
+ type,
+}: {
+ type: JSONOutput.IndexedAccessType;
+}) {
+ return (
+ <>
+ <Type type={type.objectType} />
+ [<Type type={type.indexType} />]
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Type/InferredType.tsx b/packages/docs/src/components/Api/Type/InferredType.tsx
new file mode 100644
index 00000000..eef8d4c6
--- /dev/null
+++ b/packages/docs/src/components/Api/Type/InferredType.tsx
@@ -0,0 +1,13 @@
+import React from 'react';
+
+import type {JSONOutput} from 'typedoc';
+import Token from '@site/src/components/Api/Code/Token';
+
+export default function InferredType({type}: {type: JSONOutput.InferredType}) {
+ return (
+ <>
+ <Token type="keyword">infer </Token>
+ <Token type="constant">{type.name}</Token>
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Type/IntersectionType.tsx b/packages/docs/src/components/Api/Type/IntersectionType.tsx
new file mode 100644
index 00000000..2af41874
--- /dev/null
+++ b/packages/docs/src/components/Api/Type/IntersectionType.tsx
@@ -0,0 +1,22 @@
+import React from 'react';
+
+import type {JSONOutput} from 'typedoc';
+import Type from '@site/src/components/Api/Type';
+import TokenList, {
+ ListType,
+ Separator,
+} from '@site/src/components/Api/Code/TokenList';
+
+export default function IntersectionType({
+ type,
+}: {
+ type: JSONOutput.IntersectionType;
+}) {
+ return (
+ <TokenList type={ListType.Parentheses} separator={Separator.Ampersand}>
+ {type.types.map((item, index) => (
+ <Type key={index} type={item} />
+ ))}
+ </TokenList>
+ );
+}
diff --git a/packages/docs/src/components/Api/Type/IntrinsicType.tsx b/packages/docs/src/components/Api/Type/IntrinsicType.tsx
new file mode 100644
index 00000000..8bf0e4d8
--- /dev/null
+++ b/packages/docs/src/components/Api/Type/IntrinsicType.tsx
@@ -0,0 +1,12 @@
+import React from 'react';
+
+import type {JSONOutput} from 'typedoc';
+import Token from '@site/src/components/Api/Code/Token';
+
+export default function IntrinsicType({
+ type,
+}: {
+ type: JSONOutput.IntrinsicType;
+}) {
+ return <Token type="keyword">{type.name}</Token>;
+}
diff --git a/packages/docs/src/components/Api/Type/LiteralType.tsx b/packages/docs/src/components/Api/Type/LiteralType.tsx
new file mode 100644
index 00000000..90f84aed
--- /dev/null
+++ b/packages/docs/src/components/Api/Type/LiteralType.tsx
@@ -0,0 +1,26 @@
+import React, {useMemo} from 'react';
+
+import type {JSONOutput} from 'typedoc';
+import Token from '@site/src/components/Api/Code/Token';
+
+export default function LiteralType({type}: {type: JSONOutput.LiteralType}) {
+ const [value, token] = useMemo(() => {
+ if (type.value === null) {
+ return ['null', 'keyword'];
+ }
+ switch (typeof type.value) {
+ case 'object':
+ return [(type.value.negative ? '-' : '') + type.value.value, 'number'];
+ case 'boolean':
+ return [type.value, 'keyword'];
+ case 'number':
+ return [type.value, 'number'];
+ case 'string':
+ return [`'${type.value}'`, 'string'];
+ default:
+ return [type.value, 'constant'];
+ }
+ }, [type.value]);
+
+ return <Token type={token}>{value}</Token>;
+}
diff --git a/packages/docs/src/components/Api/Type/PredicateType.tsx b/packages/docs/src/components/Api/Type/PredicateType.tsx
new file mode 100644
index 00000000..946713e2
--- /dev/null
+++ b/packages/docs/src/components/Api/Type/PredicateType.tsx
@@ -0,0 +1,20 @@
+import React from 'react';
+
+import type {JSONOutput} from 'typedoc';
+import Type from '@site/src/components/Api/Type';
+import Token from '@site/src/components/Api/Code/Token';
+
+export default function PredicateType({
+ type,
+}: {
+ type: JSONOutput.PredicateType;
+}) {
+ // TODO Figure out what `type.asserts` does.
+ return (
+ <>
+ <Token>{type.name} </Token>
+ <Token type="keyword">is </Token>
+ <Type type={type.targetType} />
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Type/QueryType.tsx b/packages/docs/src/components/Api/Type/QueryType.tsx
new file mode 100644
index 00000000..363a3379
--- /dev/null
+++ b/packages/docs/src/components/Api/Type/QueryType.tsx
@@ -0,0 +1,14 @@
+import React from 'react';
+
+import type {JSONOutput} from 'typedoc';
+import Token from '@site/src/components/Api/Code/Token';
+import Type from '@site/src/components/Api/Type';
+
+export default function QueryType({type}: {type: JSONOutput.QueryType}) {
+ return (
+ <>
+ <Token type="keyword">typeof </Token>
+ <Type type={type.queryType} />
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Type/ReferenceType.tsx b/packages/docs/src/components/Api/Type/ReferenceType.tsx
new file mode 100644
index 00000000..20574b89
--- /dev/null
+++ b/packages/docs/src/components/Api/Type/ReferenceType.tsx
@@ -0,0 +1,32 @@
+import React from 'react';
+
+import Token from '@site/src/components/Api/Code/Token';
+import TokenList, {ListType} from '@site/src/components/Api/Code/TokenList';
+import Type from '@site/src/components/Api/Type';
+import {getUrl, useApiLookup} from '@site/src/contexts/api';
+import type {JSONOutput} from 'typedoc';
+
+export default function ReferenceType({
+ type,
+}: {
+ type: JSONOutput.ReferenceType;
+}) {
+ const lookup = useApiLookup(type.lookupId);
+ const reference = lookup[type.id];
+ const to = type.externalUrl ?? getUrl(reference);
+
+ return (
+ <>
+ <Token to={to} type={to ? 'class-name' : 'constant'} tooltip>
+ {type.name}
+ </Token>
+ {!!type.typeArguments?.length && (
+ <TokenList type={ListType.Angle}>
+ {type.typeArguments.map((type, index) => (
+ <Type key={index} type={type} />
+ ))}
+ </TokenList>
+ )}
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Type/ReflectionType.tsx b/packages/docs/src/components/Api/Type/ReflectionType.tsx
new file mode 100644
index 00000000..baea4500
--- /dev/null
+++ b/packages/docs/src/components/Api/Type/ReflectionType.tsx
@@ -0,0 +1,12 @@
+import React from 'react';
+
+import type {JSONOutput} from 'typedoc';
+import Preview from '@site/src/components/Api/Preview';
+
+export default function ReflectionType({
+ type,
+}: {
+ type: JSONOutput.ReflectionType;
+}) {
+ return <Preview reflection={type.declaration} />;
+}
diff --git a/packages/docs/src/components/Api/Type/TemplateLiteralType.tsx b/packages/docs/src/components/Api/Type/TemplateLiteralType.tsx
new file mode 100644
index 00000000..1a51088a
--- /dev/null
+++ b/packages/docs/src/components/Api/Type/TemplateLiteralType.tsx
@@ -0,0 +1,26 @@
+import React from 'react';
+
+import type {JSONOutput} from 'typedoc';
+import Type from '@site/src/components/Api/Type';
+import Token from '@site/src/components/Api/Code/Token';
+
+export default function TemplateLiteralType({
+ type,
+}: {
+ type: JSONOutput.TemplateLiteralType;
+}) {
+ return (
+ <>
+ <Token type="string">`{type.head}</Token>
+ {type.tail.map(([type, text], index) => (
+ <>
+ {'${'}
+ <Type key={index} type={type} />
+ {'}'}
+ <Token type="string">{text}</Token>
+ </>
+ ))}
+ <Token type="string">`</Token>
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Type/TupleType.tsx b/packages/docs/src/components/Api/Type/TupleType.tsx
new file mode 100644
index 00000000..92e6cf83
--- /dev/null
+++ b/packages/docs/src/components/Api/Type/TupleType.tsx
@@ -0,0 +1,15 @@
+import React from 'react';
+
+import type {JSONOutput} from 'typedoc';
+import Type from '@site/src/components/Api/Type';
+import TokenList, {ListType} from '@site/src/components/Api/Code/TokenList';
+
+export default function TupleType({type}: {type: JSONOutput.TupleType}) {
+ return (
+ <TokenList type={ListType.Square}>
+ {type.elements.map((type, index) => (
+ <Type key={index} type={type} />
+ ))}
+ </TokenList>
+ );
+}
diff --git a/packages/docs/src/components/Api/Type/TypeOperatorType.tsx b/packages/docs/src/components/Api/Type/TypeOperatorType.tsx
new file mode 100644
index 00000000..936ebb2a
--- /dev/null
+++ b/packages/docs/src/components/Api/Type/TypeOperatorType.tsx
@@ -0,0 +1,18 @@
+import React from 'react';
+
+import type {JSONOutput} from 'typedoc';
+import Type from '@site/src/components/Api/Type';
+import Token from '@site/src/components/Api/Code/Token';
+
+export default function TypeOperatorType({
+ type,
+}: {
+ type: JSONOutput.TypeOperatorType;
+}) {
+ return (
+ <>
+ <Token type="keyword">{type.operator} </Token>
+ <Type type={type.target} />
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Api/Type/UnionType.tsx b/packages/docs/src/components/Api/Type/UnionType.tsx
new file mode 100644
index 00000000..34ffaba0
--- /dev/null
+++ b/packages/docs/src/components/Api/Type/UnionType.tsx
@@ -0,0 +1,18 @@
+import React from 'react';
+
+import type {JSONOutput} from 'typedoc';
+import Type from '@site/src/components/Api/Type';
+import TokenList, {
+ ListType,
+ Separator,
+} from '@site/src/components/Api/Code/TokenList';
+
+export default function UnionType({type}: {type: JSONOutput.UnionType}) {
+ return (
+ <TokenList type={ListType.Parentheses} separator={Separator.Pipe}>
+ {type.types.map((item, index) => (
+ <Type key={index} type={item} />
+ ))}
+ </TokenList>
+ );
+}
diff --git a/packages/docs/src/components/Api/Type/index.tsx b/packages/docs/src/components/Api/Type/index.tsx
new file mode 100644
index 00000000..3c608506
--- /dev/null
+++ b/packages/docs/src/components/Api/Type/index.tsx
@@ -0,0 +1,72 @@
+import React, {useMemo} from 'react';
+import ReferenceType from '@site/src/components/Api/Type/ReferenceType';
+import IntrinsicType from '@site/src/components/Api/Type/IntrinsicType';
+import TupleType from '@site/src/components/Api/Type/TupleType';
+import ArrayType from '@site/src/components/Api/Type/ArrayType';
+import UnionType from '@site/src/components/Api/Type/UnionType';
+import LiteralType from '@site/src/components/Api/Type/LiteralType';
+import PredicateType from '@site/src/components/Api/Type/PredicateType';
+import ReflectionType from '@site/src/components/Api/Type/ReflectionType';
+import IntersectionType from '@site/src/components/Api/Type/IntersectionType';
+import TemplateLiteralType from '@site/src/components/Api/Type/TemplateLiteralType';
+import QueryType from '@site/src/components/Api/Type/QueryType';
+import ConditionalType from '@site/src/components/Api/Type/ConditionalType';
+import InferredType from '@site/src/components/Api/Type/InferredType';
+import IndexedAccessType from '@site/src/components/Api/Type/IndexedAccessType';
+import TypeOperatorType from '@site/src/components/Api/Type/TypeOperatorType';
+import type {JSONOutput} from 'typedoc';
+
+export interface CodeTypeProps {
+ type: JSONOutput.SomeType;
+}
+
+export default function CodeType(props: CodeTypeProps) {
+ const TypeComponent = useMemo(() => {
+ switch (props.type.type) {
+ case 'rest':
+ break;
+ case 'typeOperator':
+ return TypeOperatorType;
+ case 'conditional':
+ return ConditionalType;
+ case 'reflection':
+ return ReflectionType;
+ case 'query':
+ return QueryType;
+ case 'named-tuple-member':
+ break;
+ case 'optional':
+ break;
+ case 'union':
+ return UnionType;
+ case 'intrinsic':
+ return IntrinsicType;
+ case 'literal':
+ return LiteralType;
+ case 'unknown':
+ break;
+ case 'reference':
+ return ReferenceType;
+ case 'predicate':
+ return PredicateType;
+ case 'tuple':
+ return TupleType;
+ case 'array':
+ return ArrayType;
+ case 'intersection':
+ return IntersectionType;
+ case 'inferred':
+ return InferredType;
+ case 'mapped':
+ break;
+ case 'template-literal':
+ return TemplateLiteralType;
+ case 'indexedAccess':
+ return IndexedAccessType;
+ }
+
+ throw new Error(`Missing component for type: ${props.type.type}`);
+ }, [props.type]) as React.FC<CodeTypeProps>;
+
+ return <TypeComponent {...props} />;
+}
diff --git a/packages/docs/src/components/Api/TypeParameters/index.tsx b/packages/docs/src/components/Api/TypeParameters/index.tsx
new file mode 100644
index 00000000..2af145be
--- /dev/null
+++ b/packages/docs/src/components/Api/TypeParameters/index.tsx
@@ -0,0 +1,30 @@
+import React from 'react';
+import type {JSONOutput} from 'typedoc';
+import TypeParameterPreview from '@site/src/components/Api/Preview/TypeParameterPreview';
+import Summary from '@site/src/components/Api/Comment/Summary';
+
+export default function TypeParameters({
+ parameters,
+}: {
+ parameters: JSONOutput.TypeParameterReflection[];
+}) {
+ if (!parameters?.length) {
+ return <></>;
+ }
+
+ return (
+ <>
+ <h4>Type Parameters</h4>
+ <ul>
+ {parameters.map(parameter => (
+ <li key={parameter.id}>
+ <code>
+ <TypeParameterPreview reflection={parameter} />
+ </code>
+ <Summary id={parameter.comment?.summaryId} />
+ </li>
+ ))}
+ </ul>
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Tooltip/index.tsx b/packages/docs/src/components/Tooltip/index.tsx
new file mode 100644
index 00000000..758c8e69
--- /dev/null
+++ b/packages/docs/src/components/Tooltip/index.tsx
@@ -0,0 +1,109 @@
+import React, {
+ ReactNode,
+ useCallback,
+ useEffect,
+ useRef,
+ useState,
+} from 'react';
+import useIsBrowser from '@docusaurus/useIsBrowser';
+import styles from './styles.module.css';
+import clsx from 'clsx';
+import {useUrlLookup} from '@site/src/contexts/api';
+import Comment from '@site/src/components/Api/Comment';
+
+const WIDTH = 480 + 16;
+
+export default function Tooltip({children}: {children: ReactNode}) {
+ const isBrowser = useIsBrowser();
+ const urlLookup = useUrlLookup();
+
+ const [show, setShow] = useState(false);
+ const [comment, setComment] = useState(null);
+ const containerRef = useRef<HTMLDivElement>();
+ const linkRef = useRef<HTMLAnchorElement>();
+ const tooltipRef = useRef<HTMLDivElement>();
+
+ const updatePosition = useCallback(() => {
+ if (!linkRef.current || !tooltipRef.current) return;
+
+ const rect = linkRef.current.getBoundingClientRect();
+ const width = window.innerWidth;
+ let right = width - rect.left - WIDTH;
+ if (right < 0) {
+ right = 0;
+ }
+
+ tooltipRef.current.style.right = `${right}px`;
+ tooltipRef.current.style.top = `${rect.bottom}px`;
+ }, []);
+
+ useEffect(() => {
+ if (!isBrowser) {
+ return;
+ }
+
+ const onEnter = e => {
+ if (
+ !e.target.href ||
+ !containerRef.current?.contains(e.target) ||
+ tooltipRef.current?.contains(e.target)
+ ) {
+ return;
+ }
+
+ const url = new URL(e.target.href, document.baseURI);
+ if (url.pathname === window.location.pathname) {
+ return;
+ }
+
+ const reflection = urlLookup(url.pathname + url.hash);
+ if (!reflection?.comment?.summary) {
+ return;
+ }
+
+ linkRef.current = e.target;
+ setShow(true);
+ setComment(reflection.comment);
+ updatePosition();
+ };
+
+ const onLeave = e => {
+ if (e.target === linkRef.current) {
+ setShow(false);
+ }
+ };
+
+ document.addEventListener('mouseenter', onEnter, true);
+ document.addEventListener('focus', onEnter, true);
+ document.addEventListener('mouseleave', onLeave, true);
+ document.addEventListener('blur', onLeave, true);
+ document.addEventListener('scroll', updatePosition);
+ return () => {
+ document.removeEventListener('mouseenter', onEnter, true);
+ document.removeEventListener('focus', onEnter, true);
+ document.removeEventListener('mouseleave', onLeave, true);
+ document.removeEventListener('blur', onLeave, true);
+ document.removeEventListener('scroll', updatePosition);
+ };
+ }, [isBrowser]);
+
+ useEffect(() => {
+ updatePosition();
+ });
+
+ return (
+ <div ref={containerRef}>
+ {children}
+ <div
+ ref={tooltipRef}
+ className={clsx(
+ styles.tooltip,
+ 'padding--md margin-horiz--md',
+ show && styles.active,
+ )}
+ >
+ {comment && <Comment comment={comment} withExamples={false} />}
+ </div>
+ </div>
+ );
+}
diff --git a/packages/docs/src/components/Tooltip/styles.module.css b/packages/docs/src/components/Tooltip/styles.module.css
new file mode 100644
index 00000000..16c3698c
--- /dev/null
+++ b/packages/docs/src/components/Tooltip/styles.module.css
@@ -0,0 +1,39 @@
+.tooltipContainer {
+ display: inline;
+ overflow: visible;
+}
+
+.tooltip.active,
+.tooltip:hover {
+ visibility: visible;
+ transition: visibility 0.5s step-end, transform 0.1s 0.5s ease-out,
+ opacity 0.1s 0.5s;
+ transform: translateY(8px);
+ opacity: 1;
+}
+
+.tooltip:hover {
+ transition: none;
+}
+
+.tooltip {
+ width: min(480px, calc(100vw - 2rem));
+ font-family: var(--ifm-font-family-base);
+ font-size: 16px;
+ white-space: normal;
+ position: fixed;
+ background-color: var(--ifm-background-color);
+ border-radius: var(--ifm-global-radius);
+ border: 1px solid var(--ifm-color-emphasis-300);
+ box-shadow: var(--ifm-global-shadow-tl);
+ visibility: hidden;
+ transform: translateY(16px);
+ opacity: 0;
+
+ transition: visibility 0.1s step-end, transform 0.1s ease-in, opacity 0.1s;
+ transition-delay: 0.1s;
+}
+
+.tooltip p:last-child {
+ margin-bottom: 0;
+}
\ No newline at end of file
diff --git a/packages/docs/src/contexts/api.tsx b/packages/docs/src/contexts/api.tsx
new file mode 100644
index 00000000..2fc12c6c
--- /dev/null
+++ b/packages/docs/src/contexts/api.tsx
@@ -0,0 +1,104 @@
+import React, {FunctionComponent, ReactNode, useContext} from 'react';
+import type {JSONOutput} from 'typedoc';
+
+declare module 'typedoc' {
+ namespace JSONOutput {
+ interface ReferenceType {
+ lookupId?: number;
+ }
+
+ interface Reflection {
+ docId: string;
+ href: string;
+ url: string;
+ hasOwnPage: boolean;
+ anchor?: string;
+ next?: any;
+ previous?: any;
+ importPath?: string;
+ }
+
+ interface Comment {
+ summaryText?: string;
+ summaryId?: string;
+ }
+
+ interface CommentTag {
+ contentId: string;
+ }
+ }
+}
+
+export interface ReflectionReference {
+ id: number;
+ projectId: number;
+}
+
+export interface ApiContext {
+ lookup: ApiLookups;
+ urlLookup: Record<string, ReflectionReference>;
+ contents: Record<string, FunctionComponent>;
+ id: number;
+}
+
+export type ApiLookup = Record<number, JSONOutput.Reflection>;
+export type ApiLookups = Record<number, ApiLookup>;
+
+const Context = React.createContext<ApiContext>({
+ lookup: {},
+ urlLookup: {},
+ contents: {},
+ id: 0,
+});
+
+export function ApiProvider({
+ children,
+ lookup,
+ urlLookup,
+ contents,
+ id,
+}: {
+ children: ReactNode;
+ lookup: ApiLookups;
+ urlLookup: Record<string, ReflectionReference>;
+ contents: Record<string, FunctionComponent>;
+ id: number;
+}) {
+ return (
+ <Context.Provider value={{lookup, contents, urlLookup, id}}>
+ {children}
+ </Context.Provider>
+ );
+}
+
+export function useApiContext(): ApiContext {
+ return useContext(Context);
+}
+
+export function useApiLookup(customId?: number): ApiLookup {
+ const {lookup, id} = useContext(Context);
+ return lookup[customId ?? id];
+}
+
+export function useUrlLookup(): (url: string) => JSONOutput.Reflection | null {
+ const {urlLookup, lookup} = useContext(Context);
+
+ return url => {
+ const reference = urlLookup[url];
+ if (!reference) {
+ return null;
+ }
+
+ return lookup[reference.projectId]?.[reference.id] ?? null;
+ };
+}
+
+export function useApiContent(id: string): FunctionComponent {
+ const {contents} = useContext(Context);
+ return contents[id] ?? React.Fragment;
+}
+
+export function getUrl(reflection?: JSONOutput.DeclarationReflection) {
+ if (!reflection) return undefined;
+ return reflection.href;
+}
diff --git a/packages/docs/src/contexts/codeTheme.tsx b/packages/docs/src/contexts/codeTheme.tsx
new file mode 100644
index 00000000..7dd69bfb
--- /dev/null
+++ b/packages/docs/src/contexts/codeTheme.tsx
@@ -0,0 +1,60 @@
+import {Language, PrismTheme} from 'prism-react-renderer';
+import React, {ReactNode, useContext} from 'react';
+
+export type StyleObj = {
+ [key: string]: string | number | void;
+};
+
+export type ThemeDict = {
+ root: StyleObj;
+ plain: StyleObj;
+ [type: string]: StyleObj;
+};
+
+export function themeToDict(theme: PrismTheme, language: Language): ThemeDict {
+ const {plain} = theme;
+ const base: ThemeDict = Object.create(null);
+
+ const themeDict = theme.styles.reduce((acc, themeEntry) => {
+ const {languages, style} = themeEntry;
+ if (languages && !languages.includes(language)) {
+ return acc;
+ }
+
+ themeEntry.types.forEach(type => {
+ acc[type] = {...acc[type], ...style};
+ });
+
+ return acc;
+ }, base);
+
+ themeDict.root = plain;
+ themeDict.plain = {...plain, backgroundColor: null};
+
+ return themeDict;
+}
+
+const Context = React.createContext<ThemeDict | null>(null);
+
+export function ThemeDictProvider({
+ children,
+ dictionary,
+}: {
+ children: ReactNode;
+ dictionary: ThemeDict;
+}) {
+ return <Context.Provider value={dictionary}>{children}</Context.Provider>;
+}
+
+export function useTokenProps(type = 'plain') {
+ const dictionary = useContext(Context);
+ return {
+ className: `token ${type}`,
+ style: dictionary[type] ?? dictionary.plain,
+ };
+}
+
+export function useTokenStyle(type = 'plain') {
+ const dictionary = useContext(Context);
+ return dictionary[type] ?? dictionary.plain;
+}
diff --git a/packages/docs/src/contexts/filters.tsx b/packages/docs/src/contexts/filters.tsx
new file mode 100644
index 00000000..3feb6244
--- /dev/null
+++ b/packages/docs/src/contexts/filters.tsx
@@ -0,0 +1,69 @@
+import React, {ReactNode, useContext, useState} from 'react';
+import type {JSONOutput} from 'typedoc';
+import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
+import useIsBrowser from '@docusaurus/useIsBrowser';
+
+export interface Filters {
+ private: boolean;
+ inherited: boolean;
+}
+
+type FiltersContext = [Filters, (value: Filters) => void];
+
+const FILTERS_KEY = 'api-filters';
+
+const storedValue = ExecutionEnvironment.canUseDOM
+ ? localStorage.getItem(FILTERS_KEY)
+ : null;
+const defaultValue = storedValue
+ ? JSON.parse(storedValue)
+ : {
+ inherited: true,
+ private: false,
+ };
+
+const Context = React.createContext<FiltersContext>([
+ defaultValue,
+ () => {
+ // do nothing
+ },
+]);
+
+export function FiltersProvider({children}: {children: ReactNode}) {
+ const [filters, setFilters] = useState<Filters>(defaultValue);
+ const isBrowser = useIsBrowser();
+
+ return (
+ <Context.Provider
+ value={[
+ filters,
+ value => {
+ if (isBrowser) {
+ localStorage.setItem(FILTERS_KEY, JSON.stringify(value));
+ }
+ setFilters(value);
+ },
+ ]}
+ >
+ {children}
+ </Context.Provider>
+ );
+}
+
+export function useFilters(): FiltersContext {
+ return useContext(Context);
+}
+
+export function matchFilters(
+ filter: Filters,
+ reflection: JSONOutput.DeclarationReflection,
+) {
+ const isPrivate =
+ reflection.flags?.isPrivate || reflection.flags?.isProtected;
+ if (!filter.private && isPrivate) return false;
+
+ const isInherited = !!reflection.inheritedFrom;
+ if (!filter.inherited && isInherited) return false;
+
+ return true;
+}
diff --git a/packages/docs/src/css/custom.css b/packages/docs/src/css/custom.css
index 7a3469d5..1c3b2c05 100644
--- a/packages/docs/src/css/custom.css
+++ b/packages/docs/src/css/custom.css
@@ -24,6 +24,12 @@
--ifm-color-gray-800: #444444;
--ifm-color-gray-900: #1c1c1c;
+ --ifm-color-secondary-dark: #666666;
+ --ifm-color-success-dark: #99c47a;
+ --ifm-color-info-dark: #68abdf;
+ --ifm-color-warning-dark: #ffc66d;
+ --ifm-color-danger-dark: #ff6470;
+
--ifm-color-secondary-contrast-foreground: var(--ifm-font-color-base);
--ifm-color-success-contrast-foreground: var(--ifm-font-color-base);
--ifm-color-info-contrast-foreground: var(--ifm-font-color-base);
@@ -39,6 +45,8 @@
--ifm-color-emphasis-300: rgba(60, 60, 60, 0.12);
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1);
--code-background-color: var(--ifm-background-surface-color);
+ --ifm-code-hover-background: #f0f0f0;
+ --ifm-hr-background-color: var(--ifm-color-emphasis-300);
--ifm-global-radius: 4px;
--ifm-alert-border-left-width: 4px;
@@ -46,27 +54,38 @@
sans-serif;
--ifm-font-family-monospace: JetBrains Mono, Consolas, monospace;
--ifm-pre-line-height: 1.6;
+
+ --ifm-h3-font-size: 1.5rem;
}
/* For readability concerns, you should choose a lighter palette in dark mode. */
html[data-theme='dark'] {
- --ifm-color-primary: #25c2a0;
- --ifm-color-primary-dark: #21af90;
- --ifm-color-primary-darker: #1fa588;
- --ifm-color-primary-darkest: #1a8870;
- --ifm-color-primary-light: #29d5b0;
- --ifm-color-primary-lighter: #32d8b4;
- --ifm-color-primary-lightest: #4fddbf;
+ --ifm-color-primary: #25c281;
+ --ifm-color-primary-dark: #21af74;
+ --ifm-color-primary-darker: #1fa56e;
+ --ifm-color-primary-darkest: #1a885a;
+ --ifm-color-primary-light: #29d58e;
+ --ifm-color-primary-lighter: #32d893;
+ --ifm-color-primary-lightest: #4fdda2;
+
--ifm-background-color: #242424;
--ifm-background-surface-color: #1a1a1a;
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3);
--ifm-navbar-background-color: rgba(36, 36, 36, 0.7);
+ --ifm-code-background: var(--ifm-background-surface-color);
+ --ifm-code-hover-background: #141414;
- --ifm-color-secondary-dark: #fff;
- --ifm-color-success-dark: #55c244;
- --ifm-color-info-dark: #4cb3d4;
- --ifm-color-warning-dark: #e6a700;
- --ifm-color-danger-dark: #e13238;
+ --ifm-color-secondary-dark: #f8f8f8;
+ --ifm-color-success-dark: #7ac445;
+ --ifm-color-info-dark: #50a0de;
+ --ifm-color-warning-dark: #ffaa00;
+ --ifm-color-danger-dark: #ff3849;
+
+ --ifm-color-secondary-contrast-foreground: var(--ifm-font-color-base);
+ --ifm-color-success-contrast-foreground: var(--ifm-font-color-base);
+ --ifm-color-info-contrast-foreground: var(--ifm-font-color-base);
+ --ifm-color-warning-contrast-foreground: var(--ifm-font-color-base);
+ --ifm-color-danger-contrast-foreground: var(--ifm-font-color-base);
--ifm-color-emphasis-300: rgba(84, 84, 84, 0.48);
--ifm-toc-border-color: var(--ifm-color-emphasis-300);
@@ -88,9 +107,24 @@ html[data-theme='dark'] {
html {
height: 100%;
+ accent-color: var(--ifm-color-primary);
}
a.button:hover {
color: var(--ifm-button-color);
text-decoration: none;
}
+
+@media screen and (max-width: 996px) {
+ :root {
+ --ifm-navbar-background-color: rgb(255, 255, 255);
+ }
+
+ html[data-theme='dark'] {
+ --ifm-navbar-background-color: rgb(36, 36, 36);
+ }
+
+ .navbar {
+ backdrop-filter: none;
+ }
+}
diff --git a/packages/docs/src/theme/Admonition/styles.module.css b/packages/docs/src/theme/Admonition/styles.module.css
index 50751bb9..830a1aa5 100644
--- a/packages/docs/src/theme/Admonition/styles.module.css
+++ b/packages/docs/src/theme/Admonition/styles.module.css
@@ -1,4 +1,6 @@
span .icon {
width: 24px;
height: 24px;
+
+ fill: var(--ifm-alert-border-color);
}
diff --git a/packages/docs/typedoc.js b/packages/docs/typedoc.js
new file mode 100644
index 00000000..208a8679
--- /dev/null
+++ b/packages/docs/typedoc.js
@@ -0,0 +1,360 @@
+// @ts-check
+
+const {
+ Application,
+ TSConfigReader,
+ ReflectionKind,
+ Reflection,
+ DeclarationReflection,
+ CommentTag,
+ Comment,
+} = require('typedoc');
+const mdn = require('mdn-links');
+
+module.exports = () => ({
+ name: 'docusaurus-typedoc-plugin',
+ async loadContent() {
+ const core = await parseTypes(
+ {
+ theme: 'custom',
+ excludeInternal: true,
+ excludePrivate: true,
+ entryPoints: [
+ '../core/src/index.ts',
+ '../core/src/decorators',
+ '../core/src/events',
+ '../core/src/flow',
+ '../core/src/helpers',
+ '../core/src/media',
+ '../core/src/player',
+ '../core/src/scenes',
+ '../core/src/threading',
+ '../core/src/transitions',
+ '../core/src/tweening',
+ '../core/src/types',
+ '../core/src/utils',
+ ],
+ tsconfig: '../core/tsconfig.build.json',
+ },
+ 'core',
+ );
+ return [
+ core,
+ await parseTypes(
+ {
+ theme: 'custom',
+ excludeExternals: true,
+ excludeInternal: true,
+ excludePrivate: true,
+ entryPoints: [
+ '../2d/src/components',
+ '../2d/src/curves',
+ '../2d/src/decorators',
+ '../2d/src/partials',
+ '../2d/src/scenes',
+ '../2d/src/utils',
+ ],
+ tsconfig: '../2d/tsconfig.json',
+ },
+ '2d',
+ core,
+ ),
+ ];
+ },
+ async contentLoaded({content, actions}) {
+ if (content === null) {
+ return;
+ }
+
+ const sidebar = [];
+ const lookups = {};
+ const promises = [];
+ let urlLookups = {};
+ let previousProject;
+ let imports = '';
+ let exports = '';
+
+ for (const project of content) {
+ urlLookups = {
+ ...urlLookups,
+ ...project.urlLookup,
+ };
+ for (let i = 0; i < project.mdContents.length; i++) {
+ const md = project.mdContents[i];
+ const name = getContentName(project.id, i);
+
+ promises.push(actions.createData(`${name}.md`, md));
+ imports += `import ${name} from "./${name}.md";\n`;
+ exports += `${name},\n`;
+ }
+
+ lookups[project.id] = project.lookup;
+ sidebar.push(project.sidebar);
+ if (previousProject) {
+ let previous = previousProject.sidebar;
+ while (previous.items?.length) {
+ previous = previous.items.at(-1);
+ }
+ previousProject.lookup[previous.reflectionId].next = {
+ title: project.sidebar.label,
+ permalink: project.sidebar.href,
+ };
+ project.lookup[project.id].previous = {
+ title: previous.label,
+ permalink: previous.href,
+ };
+ }
+ previousProject = project;
+ }
+
+ await Promise.all(promises);
+ const lookupData = await actions.createData(
+ 'lookup.json',
+ JSON.stringify({sidebar, lookups, urlLookups}),
+ );
+
+ const contents = await actions.createData(
+ 'test.js',
+ `${imports}const contents = {\n${exports}};\nexport default contents;`,
+ );
+
+ for (const project of content) {
+ actions.addRoute({
+ path: project.lookup[project.id].url,
+ component: '@site/src/components/Api/ApiPage.tsx',
+ routes: Object.values(project.lookup)
+ .filter(reflection => reflection.hasOwnPage)
+ .map(reflection => ({
+ path: reflection.url,
+ component: '@site/src/components/Api/ApiItem.tsx',
+ exact: true,
+ sidebar: 'api',
+ reflectionId: reflection.id,
+ })),
+ modules: {
+ lookup: lookupData,
+ contents: contents,
+ },
+ exact: false,
+ reflectionId: project.id,
+ projectName: project.name,
+ });
+ }
+ },
+});
+
+async function parseTypes(options, projectName, externalProject) {
+ const app = new Application();
+ app.options.addReader(new TSConfigReader());
+ app.bootstrap(options);
+
+ app.converter.addUnknownSymbolResolver(ref => {
+ const name = ref.symbolReference.path[0].path;
+ if (externalProject) {
+ let reference = externalProject.nameLookup[name];
+ if (!reference) {
+ const match = /(.+)<.*>(.*)/.exec(name);
+ if (match) {
+ const name = match[1] + match[2];
+ reference = externalProject.nameLookup[name];
+ }
+ }
+ if (reference) {
+ if (ref.symbolReference.path.length > 0) {
+ for (const value of ref.symbolReference.path.slice(1)) {
+ reference = reference.children.find(
+ child => child.name === value.path,
+ );
+ }
+ }
+
+ return reference.href;
+ }
+ }
+
+ return mdn.getLink(name) ?? undefined;
+ });
+
+ const project = app.convert();
+ if (!project) return null;
+
+ const hasOwnPage = [
+ ReflectionKind.Module,
+ ReflectionKind.Reference,
+ ReflectionKind.Interface,
+ ReflectionKind.Namespace,
+ ReflectionKind.Project,
+ ReflectionKind.Class,
+ ReflectionKind.Enum,
+ ];
+
+ const traverse = reflection => {
+ reflection.hasOwnPage = hasOwnPage.includes(reflection.kind);
+ reflection.docId = reflection.parent
+ ? `${reflection.parent.docId}-${reflection.name}`
+ : reflection.name;
+
+ if (reflection.hasOwnPage) {
+ reflection.url = `${reflection.parent.url}/${reflection.name}`;
+ reflection.sidebar = {
+ type: 'link',
+ href: reflection.url,
+ label: reflection.name,
+ reflectionId: reflection.id,
+ };
+ reflection.parent.sidebar ??= {};
+ reflection.parent.sidebar.type = 'category';
+ reflection.parent.sidebar.collapsed = true;
+ reflection.parent.sidebar.collapsible = true;
+ reflection.parent.sidebar.items ??= [];
+ reflection.parent.sidebar.items.push(reflection.sidebar);
+
+ let previous = reflection.parent.sidebar.items.at(-2);
+ while (previous?.items?.length) {
+ previous = previous.items.at(-1);
+ }
+ if (!previous) {
+ previous = reflection.parent.sidebar;
+ }
+ if (previous) {
+ previous.next = {
+ title: reflection.name,
+ permalink: reflection.url,
+ };
+ reflection.sidebar.previous = {
+ title: previous.label,
+ permalink: previous.href,
+ };
+ }
+ } else {
+ reflection.url = reflection.parent.url;
+ if (reflection.parent.anchor) {
+ reflection.anchor = reflection.parent.anchor + '-' + reflection.name;
+ } else {
+ reflection.anchor = reflection.name;
+ }
+ }
+
+ reflection.href = reflection.anchor
+ ? reflection.url + '#' + reflection.anchor
+ : reflection.url;
+
+ reflection.traverse(traverse);
+ };
+
+ project.url = `/api/${projectName}`;
+ project.href = project.url;
+ project.docId = project.name;
+ project.hasOwnPage = true;
+ project.sidebar = {
+ type: 'link',
+ href: project.url,
+ label: project.name,
+ };
+ project.traverse(traverse);
+
+ const lookup = {};
+ const nameLookup = {};
+ const urlLookup = {};
+ app.serializer.addSerializer({
+ priority: -Infinity,
+ supports(item) {
+ return item instanceof Reflection;
+ },
+ toObject(item, obj) {
+ urlLookup[item.href] = {
+ id: item.id,
+ projectId: project.id,
+ };
+ nameLookup[obj.name] = obj;
+ lookup[obj.id] = obj;
+ obj.url = item.url;
+ obj.anchor = item.anchor;
+ obj.href = item.href;
+ obj.hasOwnPage = item.hasOwnPage;
+ obj.docId = item.docId;
+ obj.next = item.sidebar?.next;
+ obj.previous = item.sidebar?.previous;
+ return obj;
+ },
+ });
+
+ app.serializer.addSerializer({
+ priority: -Infinity,
+ supports(item) {
+ return (
+ item instanceof DeclarationReflection &&
+ item.kind === ReflectionKind.Module
+ );
+ },
+ toObject(item, obj) {
+ obj.importPath =
+ item.name === 'index'
+ ? `${project.name}/lib`
+ : `${project.name}/lib/${item.name}`;
+ return obj;
+ },
+ });
+
+ const mdContents = [];
+ app.serializer.addSerializer({
+ priority: -Infinity,
+ supports(item) {
+ return item instanceof Comment || item instanceof CommentTag;
+ },
+ toObject(item, obj) {
+ if (item instanceof CommentTag) {
+ obj.contentId = getContentName(project.id, mdContents.length);
+ mdContents.push(partsToMarkdown(item.content));
+ }
+
+ if (item.summary) {
+ obj.summaryText = partsToText(item.summary);
+ obj.summaryId = getContentName(project.id, mdContents.length);
+ mdContents.push(partsToMarkdown(item.summary));
+ }
+ return obj;
+ },
+ });
+ app.serializer.projectToObject(project);
+
+ return {
+ id: project.id,
+ name: projectName,
+ lookup,
+ sidebar: project.sidebar,
+ nameLookup,
+ urlLookup,
+ mdContents,
+ };
+}
+
+function getContentName(project, index) {
+ return `content_${project}_${index}`;
+}
+
+function partsToMarkdown(parts) {
+ return parts
+ .map(part => {
+ if (part.kind === 'inline-tag' && part.tag === '@link') {
+ if (part.target instanceof DeclarationReflection) {
+ return `[\`${part.text}\`](${part.target.href})`;
+ } else {
+ return `[\`${part.text}\`](${part.target})`;
+ }
+ }
+ return part.text;
+ })
+ .join('');
+}
+
+function partsToText(parts) {
+ return parts
+ .map(part => {
+ if (part.kind === 'code') {
+ return part.text.startsWith('```') ? '' : part.text.slice(1, -1);
+ }
+ return part.text;
+ })
+ .join('');
+}
diff --git a/tsdoc.json b/tsdoc.json
index e2fff3f9..18246aa5 100644
--- a/tsdoc.json
+++ b/tsdoc.json
@@ -12,10 +12,16 @@
{
"tagName": "@default",
"syntaxKind": "modifier"
+ },
+ {
+ "tagName": "@category",
+ "syntaxKind": "modifier"
}
],
"supportForTags": {
+ "@packageDocumentation": true,
"@module": true,
+ "@category": true,
"@param": true,
"@deprecated": true,
"@returns": true,