Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
import type { AsyncSubscription, Options, SubscribeCallback } from '@parcel/watcher';
export type NativeWatcherBackend = Pick<typeof import('@parcel/watcher'), 'subscribe'>;
export async function subscribeParcel(
parcel: NativeWatcherBackend,
dir: string,
onEvents: SubscribeCallback,
options?: Options,
platform: NodeJS.Platform = process.platform,
): Promise<AsyncSubscription> {
let deliver: SubscribeCallback | null = onEvents;
const subscription = await parcel.subscribe(
dir,
(err, events) => deliver?.(err, events),
options,
);
return {
async unsubscribe() {
if (deliver === null) return;
deliver = null;
// UPSTREAM(parcel-bundler/watcher#262): the win32 native unsubscribe frees the subscription while its read's completion is still queued
if (platform === 'win32') return;
await subscription.unsubscribe();
},
};
}