-
Notifications
You must be signed in to change notification settings - Fork 22
/
provides.ts
35 lines (28 loc) · 875 Bytes
/
provides.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
// Copyright 2023 DXOS.org
//
import { type IntentContext } from './IntentContext';
import { type IntentResolver } from './intent';
import { type Plugin } from '../PluginHost';
export type IntentResolverProvides = {
intent: {
resolver: IntentResolver;
};
};
export type IntentPluginProvides = {
intent: IntentContext;
};
export const parseIntentPlugin = (plugin: Plugin) =>
(plugin.provides as any).intent?.dispatch ? (plugin as Plugin<IntentPluginProvides>) : undefined;
export const parseIntentResolverPlugin = (plugin: Plugin) =>
(plugin.provides as any).intent?.resolver ? (plugin as Plugin<IntentResolverProvides>) : undefined;
//
// Intents
//
const INTENT_ACTION = 'dxos.org/plugin/intent';
export enum IntentAction {
/**
* Fired after an intent is dispatched if the intent is undoable.
*/
SHOW_UNDO = `${INTENT_ACTION}/show-undo`,
}