Files
webstudio/apps/builder/app/shared/pubsub/index.ts
T
Oleg Isonen 5a57234c75 revert: Store Content Block content in MDX assets
Revert the accidental merge of #6125 so the implementation can continue in draft PR #6181.
2026-08-18 13:23:32 +01:00

27 lines
770 B
TypeScript

import { atom } from "nanostores";
import { createPubsub } from "./create";
// Allow commands to declare their types
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface CommandRegistry {}
// Generate namespaced command types from CommandRegistry
type NamespacedCommands = {
[K in keyof CommandRegistry as `command:${K & string}`]: CommandRegistry[K];
};
export interface PubsubMap extends NamespacedCommands {
command: {
source: string;
name: string;
[key: string]: unknown;
};
}
export const { publish, usePublish, useSubscribe, subscribe } =
createPubsub<PubsubMap>();
export type Publish = typeof publish;
export type UsePublish = typeof usePublish;
export const $publisher = atom<{ publish?: Publish }>({});