@devframes/plugin-messages 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +49 -0
- package/bin.mjs +13 -0
- package/dist/cli.d.mts +12 -0
- package/dist/cli.mjs +14 -0
- package/dist/client/index.d.mts +21619 -0
- package/dist/client/index.mjs +4479 -0
- package/dist/constants.d.mts +14 -0
- package/dist/constants.mjs +14 -0
- package/dist/index.d.mts +41 -0
- package/dist/index.mjs +3 -0
- package/dist/node/index.d.mts +16 -0
- package/dist/node/index.mjs +3 -0
- package/dist/node-CatHJRC8.mjs +43 -0
- package/dist/rpc/index.d.mts +87 -0
- package/dist/rpc/index.mjs +2 -0
- package/dist/rpc-DmXPM8sl.mjs +115 -0
- package/dist/spa/assets/index-Bw3UENMO.js +2 -0
- package/dist/spa/assets/index-LJ-gjktr.css +1 -0
- package/dist/spa/index.html +17 -0
- package/dist/src-CY7M8Mzi.mjs +50 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +1 -0
- package/dist/vite.d.mts +12 -0
- package/dist/vite.mjs +14 -0
- package/package.json +87 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/constants.d.ts
|
|
2
|
+
/** Devframe id — drives the hosted mount path `/__<id>/` and RPC namespacing. */
|
|
3
|
+
declare const PLUGIN_ID = "devframes-plugin-messages";
|
|
4
|
+
/** Preferred standalone CLI port (901x band shared by the core-ish plugins). */
|
|
5
|
+
declare const DEFAULT_PORT = 9014;
|
|
6
|
+
/**
|
|
7
|
+
* Server→client notification broadcast by the hub context whenever the
|
|
8
|
+
* message list changes (add/update/remove/clear). Mirrors `@devframes/hub`'s
|
|
9
|
+
* internal event name; kept as a literal so the client bundle carries no hub
|
|
10
|
+
* build dependency.
|
|
11
|
+
*/
|
|
12
|
+
declare const MESSAGES_UPDATED_EVENT = "devframe:messages:updated";
|
|
13
|
+
//#endregion
|
|
14
|
+
export { DEFAULT_PORT, MESSAGES_UPDATED_EVENT, PLUGIN_ID };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/constants.ts
|
|
2
|
+
/** Devframe id — drives the hosted mount path `/__<id>/` and RPC namespacing. */
|
|
3
|
+
const PLUGIN_ID = "devframes-plugin-messages";
|
|
4
|
+
/** Preferred standalone CLI port (901x band shared by the core-ish plugins). */
|
|
5
|
+
const DEFAULT_PORT = 9014;
|
|
6
|
+
/**
|
|
7
|
+
* Server→client notification broadcast by the hub context whenever the
|
|
8
|
+
* message list changes (add/update/remove/clear). Mirrors `@devframes/hub`'s
|
|
9
|
+
* internal event name; kept as a literal so the client bundle carries no hub
|
|
10
|
+
* build dependency.
|
|
11
|
+
*/
|
|
12
|
+
const MESSAGES_UPDATED_EVENT = "devframe:messages:updated";
|
|
13
|
+
//#endregion
|
|
14
|
+
export { DEFAULT_PORT, MESSAGES_UPDATED_EVENT, PLUGIN_ID };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DEFAULT_PORT, MESSAGES_UPDATED_EVENT, PLUGIN_ID } from "./constants.mjs";
|
|
2
|
+
import { DevframeMessageEntry, DevframeMessageEntryFrom, DevframeMessageEntryInput, DevframeMessageLevel, DevframeMessagesListDelta } from "./types.mjs";
|
|
3
|
+
import { DevframeDefinition } from "devframe/types";
|
|
4
|
+
|
|
5
|
+
//#region src/index.d.ts
|
|
6
|
+
interface MessagesDevframeOptions {
|
|
7
|
+
/** Override the devframe id (and default CLI command / mount path). */
|
|
8
|
+
id?: string;
|
|
9
|
+
/** Override the display name shown in a host dock. */
|
|
10
|
+
name?: string;
|
|
11
|
+
/** Override the dock icon. */
|
|
12
|
+
icon?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Override the mount path. Left unset, the SPA mounts at `/` standalone
|
|
15
|
+
* and `/__<id>/` when hosted (Vite/embedded).
|
|
16
|
+
*/
|
|
17
|
+
basePath?: string;
|
|
18
|
+
/** Preferred standalone CLI port. */
|
|
19
|
+
port?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Require the trust handshake on the standalone server. Defaults to
|
|
22
|
+
* `false` (auto-trust) since the panel is a single-user localhost tool.
|
|
23
|
+
* Hosted adapters manage their own auth.
|
|
24
|
+
*/
|
|
25
|
+
auth?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Build a {@link DevframeDefinition} for the hub message feed panel —
|
|
29
|
+
* a portable view over `ctx.messages`, ported from vitejs/devtools'
|
|
30
|
+
* built-in Messages view. The same definition runs standalone
|
|
31
|
+
* (`/cli`, `/spa`, `/build`) and mounts into a host (`/vite`, hub);
|
|
32
|
+
* a hub host is what feeds it live entries.
|
|
33
|
+
*
|
|
34
|
+
* @experimental This plugin is experimental and may change without a major
|
|
35
|
+
* version bump until it stabilizes.
|
|
36
|
+
*/
|
|
37
|
+
declare function createMessagesDevframe(options?: MessagesDevframeOptions): DevframeDefinition;
|
|
38
|
+
/** The default messages devframe definition. */
|
|
39
|
+
declare const messagesDevframe: DevframeDefinition;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { DEFAULT_PORT, type DevframeMessageEntry, type DevframeMessageEntryFrom, type DevframeMessageEntryInput, type DevframeMessageLevel, type DevframeMessagesListDelta, MESSAGES_UPDATED_EVENT, MessagesDevframeOptions, PLUGIN_ID, createMessagesDevframe, messagesDevframe as default };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { n as messagesDevframe, t as createMessagesDevframe } from "./src-CY7M8Mzi.mjs";
|
|
2
|
+
import { DEFAULT_PORT, MESSAGES_UPDATED_EVENT, PLUGIN_ID } from "./constants.mjs";
|
|
3
|
+
export { DEFAULT_PORT, MESSAGES_UPDATED_EVENT, PLUGIN_ID, createMessagesDevframe, messagesDevframe as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { serverFunctions } from "../rpc/index.mjs";
|
|
2
|
+
import { DevframeNodeContext } from "devframe/types";
|
|
3
|
+
|
|
4
|
+
//#region src/node/index.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Register the message-feed RPC functions on a devframe node context.
|
|
7
|
+
* Called from the definition's `setup(ctx)` and reusable by host adapters
|
|
8
|
+
* that wire their own context.
|
|
9
|
+
*
|
|
10
|
+
* The plugin reads the feed from the hub-attached `ctx.messages` host. On a
|
|
11
|
+
* plain (non-hub) context it warns once and keeps the RPC surface registered
|
|
12
|
+
* as no-ops, so the panel still renders — with an empty feed.
|
|
13
|
+
*/
|
|
14
|
+
declare function setupMessages(ctx: DevframeNodeContext): void;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { serverFunctions, setupMessages };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { PLUGIN_ID } from "./constants.mjs";
|
|
2
|
+
import { n as getMessagesHost, t as serverFunctions } from "./rpc-DmXPM8sl.mjs";
|
|
3
|
+
import { openHelpers } from "devframe/recipes/open-helpers";
|
|
4
|
+
import { colors } from "devframe/utils/colors";
|
|
5
|
+
import { defineDiagnostics } from "nostics";
|
|
6
|
+
import { ansiFormatter } from "nostics/formatters/ansi";
|
|
7
|
+
//#region src/diagnostics.ts
|
|
8
|
+
const formatAnsi = ansiFormatter(colors);
|
|
9
|
+
function reporter(d, { method = "warn" } = {}) {
|
|
10
|
+
console[method](formatAnsi(d));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Structured diagnostics for `@devframes/plugin-messages`. Node-side only.
|
|
14
|
+
* Codes use the plugin-private `DP_MESSAGES_` band (see the built-in
|
|
15
|
+
* plugins planning index) so they never collide with devframe core
|
|
16
|
+
* (`DF00xx`) or `@devframes/hub` (`DF80xx`).
|
|
17
|
+
*/
|
|
18
|
+
const diagnostics = defineDiagnostics({
|
|
19
|
+
docsBase: "https://devfra.me/errors",
|
|
20
|
+
reporters: [reporter],
|
|
21
|
+
codes: { DP_MESSAGES_0001: {
|
|
22
|
+
why: (p) => `"${p.id}" is mounted on a context without a hub messages host (\`ctx.messages\`) — its RPC surface stays registered but no-ops, so the panel will show an empty feed.`,
|
|
23
|
+
fix: "Mount this devframe through a hub host (`@devframes/hub`'s `createHubContext` + `mountDevframe`) to get a live message feed."
|
|
24
|
+
} }
|
|
25
|
+
});
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/node/index.ts
|
|
28
|
+
/**
|
|
29
|
+
* Register the message-feed RPC functions on a devframe node context.
|
|
30
|
+
* Called from the definition's `setup(ctx)` and reusable by host adapters
|
|
31
|
+
* that wire their own context.
|
|
32
|
+
*
|
|
33
|
+
* The plugin reads the feed from the hub-attached `ctx.messages` host. On a
|
|
34
|
+
* plain (non-hub) context it warns once and keeps the RPC surface registered
|
|
35
|
+
* as no-ops, so the panel still renders — with an empty feed.
|
|
36
|
+
*/
|
|
37
|
+
function setupMessages(ctx) {
|
|
38
|
+
if (!getMessagesHost(ctx)) diagnostics.DP_MESSAGES_0001({ id: PLUGIN_ID });
|
|
39
|
+
for (const fn of serverFunctions) ctx.rpc.register(fn);
|
|
40
|
+
for (const fn of openHelpers) if (!ctx.rpc.definitions.has(fn.name)) ctx.rpc.register(fn);
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { setupMessages as t };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import * as _$_devframes_hub_types0 from "@devframes/hub/types";
|
|
2
|
+
import * as _$devframe from "devframe";
|
|
3
|
+
import * as _$devframe_rpc0 from "devframe/rpc";
|
|
4
|
+
import { RpcDefinitionsToFunctions } from "devframe/rpc";
|
|
5
|
+
|
|
6
|
+
//#region src/rpc/index.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* The message-feed RPC functions registered by the plugin — thin, typed
|
|
9
|
+
* wrappers over the hub's `ctx.messages` host. Namespaced
|
|
10
|
+
* `devframes-plugin-messages:*` per the plugin convention.
|
|
11
|
+
*/
|
|
12
|
+
declare const serverFunctions: readonly [{
|
|
13
|
+
name: "devframes-plugin-messages:list";
|
|
14
|
+
type?: "query" | undefined;
|
|
15
|
+
cacheable?: boolean;
|
|
16
|
+
args?: undefined;
|
|
17
|
+
returns?: undefined;
|
|
18
|
+
jsonSerializable?: boolean;
|
|
19
|
+
agent?: _$devframe.RpcFunctionAgentOptions;
|
|
20
|
+
setup?: ((context: _$devframe.DevframeNodeContext) => _$devframe_rpc0.Thenable<_$devframe_rpc0.RpcFunctionSetupResult<[since?: number | null | undefined], Promise<_$_devframes_hub_types0.DevframeMessagesListDelta>>>) | undefined;
|
|
21
|
+
handler?: ((since?: number | null | undefined) => Promise<_$_devframes_hub_types0.DevframeMessagesListDelta>) | undefined;
|
|
22
|
+
dump?: _$devframe_rpc0.RpcDump<[since?: number | null | undefined], Promise<_$_devframes_hub_types0.DevframeMessagesListDelta>, _$devframe.DevframeNodeContext> | undefined;
|
|
23
|
+
snapshot?: boolean;
|
|
24
|
+
__cache?: WeakMap<object, _$devframe_rpc0.Thenable<_$devframe_rpc0.RpcFunctionSetupResult<[since?: number | null | undefined], Promise<_$_devframes_hub_types0.DevframeMessagesListDelta>>>> | undefined;
|
|
25
|
+
__promise?: _$devframe_rpc0.Thenable<_$devframe_rpc0.RpcFunctionSetupResult<[since?: number | null | undefined], Promise<_$_devframes_hub_types0.DevframeMessagesListDelta>>> | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
name: "devframes-plugin-messages:add";
|
|
28
|
+
type?: "action" | undefined;
|
|
29
|
+
cacheable?: boolean;
|
|
30
|
+
args?: undefined;
|
|
31
|
+
returns?: undefined;
|
|
32
|
+
jsonSerializable?: boolean;
|
|
33
|
+
agent?: _$devframe.RpcFunctionAgentOptions;
|
|
34
|
+
setup?: ((context: _$devframe.DevframeNodeContext) => _$devframe_rpc0.Thenable<_$devframe_rpc0.RpcFunctionSetupResult<[input: _$_devframes_hub_types0.DevframeMessageEntryInput], Promise<_$_devframes_hub_types0.DevframeMessageEntry | null>>>) | undefined;
|
|
35
|
+
handler?: ((input: _$_devframes_hub_types0.DevframeMessageEntryInput) => Promise<_$_devframes_hub_types0.DevframeMessageEntry | null>) | undefined;
|
|
36
|
+
dump?: _$devframe_rpc0.RpcDump<[input: _$_devframes_hub_types0.DevframeMessageEntryInput], Promise<_$_devframes_hub_types0.DevframeMessageEntry | null>, _$devframe.DevframeNodeContext> | undefined;
|
|
37
|
+
snapshot?: boolean;
|
|
38
|
+
__cache?: WeakMap<object, _$devframe_rpc0.Thenable<_$devframe_rpc0.RpcFunctionSetupResult<[input: _$_devframes_hub_types0.DevframeMessageEntryInput], Promise<_$_devframes_hub_types0.DevframeMessageEntry | null>>>> | undefined;
|
|
39
|
+
__promise?: _$devframe_rpc0.Thenable<_$devframe_rpc0.RpcFunctionSetupResult<[input: _$_devframes_hub_types0.DevframeMessageEntryInput], Promise<_$_devframes_hub_types0.DevframeMessageEntry | null>>> | undefined;
|
|
40
|
+
}, {
|
|
41
|
+
name: "devframes-plugin-messages:update";
|
|
42
|
+
type?: "action" | undefined;
|
|
43
|
+
cacheable?: boolean;
|
|
44
|
+
args?: undefined;
|
|
45
|
+
returns?: undefined;
|
|
46
|
+
jsonSerializable?: boolean;
|
|
47
|
+
agent?: _$devframe.RpcFunctionAgentOptions;
|
|
48
|
+
setup?: ((context: _$devframe.DevframeNodeContext) => _$devframe_rpc0.Thenable<_$devframe_rpc0.RpcFunctionSetupResult<[id: string, patch: Partial<_$_devframes_hub_types0.DevframeMessageEntryInput>], Promise<_$_devframes_hub_types0.DevframeMessageEntry | null>>>) | undefined;
|
|
49
|
+
handler?: ((id: string, patch: Partial<_$_devframes_hub_types0.DevframeMessageEntryInput>) => Promise<_$_devframes_hub_types0.DevframeMessageEntry | null>) | undefined;
|
|
50
|
+
dump?: _$devframe_rpc0.RpcDump<[id: string, patch: Partial<_$_devframes_hub_types0.DevframeMessageEntryInput>], Promise<_$_devframes_hub_types0.DevframeMessageEntry | null>, _$devframe.DevframeNodeContext> | undefined;
|
|
51
|
+
snapshot?: boolean;
|
|
52
|
+
__cache?: WeakMap<object, _$devframe_rpc0.Thenable<_$devframe_rpc0.RpcFunctionSetupResult<[id: string, patch: Partial<_$_devframes_hub_types0.DevframeMessageEntryInput>], Promise<_$_devframes_hub_types0.DevframeMessageEntry | null>>>> | undefined;
|
|
53
|
+
__promise?: _$devframe_rpc0.Thenable<_$devframe_rpc0.RpcFunctionSetupResult<[id: string, patch: Partial<_$_devframes_hub_types0.DevframeMessageEntryInput>], Promise<_$_devframes_hub_types0.DevframeMessageEntry | null>>> | undefined;
|
|
54
|
+
}, {
|
|
55
|
+
name: "devframes-plugin-messages:remove";
|
|
56
|
+
type?: "action" | undefined;
|
|
57
|
+
cacheable?: boolean;
|
|
58
|
+
args?: undefined;
|
|
59
|
+
returns?: undefined;
|
|
60
|
+
jsonSerializable?: boolean;
|
|
61
|
+
agent?: _$devframe.RpcFunctionAgentOptions;
|
|
62
|
+
setup?: ((context: _$devframe.DevframeNodeContext) => _$devframe_rpc0.Thenable<_$devframe_rpc0.RpcFunctionSetupResult<[id: string], Promise<void>>>) | undefined;
|
|
63
|
+
handler?: ((id: string) => Promise<void>) | undefined;
|
|
64
|
+
dump?: _$devframe_rpc0.RpcDump<[id: string], Promise<void>, _$devframe.DevframeNodeContext> | undefined;
|
|
65
|
+
snapshot?: boolean;
|
|
66
|
+
__cache?: WeakMap<object, _$devframe_rpc0.Thenable<_$devframe_rpc0.RpcFunctionSetupResult<[id: string], Promise<void>>>> | undefined;
|
|
67
|
+
__promise?: _$devframe_rpc0.Thenable<_$devframe_rpc0.RpcFunctionSetupResult<[id: string], Promise<void>>> | undefined;
|
|
68
|
+
}, {
|
|
69
|
+
name: "devframes-plugin-messages:clear";
|
|
70
|
+
type?: "action" | undefined;
|
|
71
|
+
cacheable?: boolean;
|
|
72
|
+
args?: undefined;
|
|
73
|
+
returns?: undefined;
|
|
74
|
+
jsonSerializable?: boolean;
|
|
75
|
+
agent?: _$devframe.RpcFunctionAgentOptions;
|
|
76
|
+
setup?: ((context: _$devframe.DevframeNodeContext) => _$devframe_rpc0.Thenable<_$devframe_rpc0.RpcFunctionSetupResult<[], Promise<void>>>) | undefined;
|
|
77
|
+
handler?: (() => Promise<void>) | undefined;
|
|
78
|
+
dump?: _$devframe_rpc0.RpcDump<[], Promise<void>, _$devframe.DevframeNodeContext> | undefined;
|
|
79
|
+
snapshot?: boolean;
|
|
80
|
+
__cache?: WeakMap<object, _$devframe_rpc0.Thenable<_$devframe_rpc0.RpcFunctionSetupResult<[], Promise<void>>>> | undefined;
|
|
81
|
+
__promise?: _$devframe_rpc0.Thenable<_$devframe_rpc0.RpcFunctionSetupResult<[], Promise<void>>> | undefined;
|
|
82
|
+
}];
|
|
83
|
+
declare module 'devframe' {
|
|
84
|
+
interface DevframeRpcServerFunctions extends RpcDefinitionsToFunctions<typeof serverFunctions> {}
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
export { serverFunctions };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { createDefineWrapperWithContext } from "devframe/rpc";
|
|
2
|
+
//#region src/rpc/functions/_define.ts
|
|
3
|
+
/**
|
|
4
|
+
* `defineRpcFunction` pre-bound to the framework-neutral
|
|
5
|
+
* {@link DevframeNodeContext}, so each function's `setup(ctx)` receives the
|
|
6
|
+
* typed node context instead of the default `undefined` context.
|
|
7
|
+
*/
|
|
8
|
+
const defineMessagesRpc = createDefineWrapperWithContext();
|
|
9
|
+
/**
|
|
10
|
+
* Read the hub-attached messages host off a node context, if present. The
|
|
11
|
+
* plugin talks to `ctx.messages` structurally so its shipped code carries no
|
|
12
|
+
* runtime dependency on `@devframes/hub` — hosts other than the hub can
|
|
13
|
+
* satisfy the same surface.
|
|
14
|
+
*/
|
|
15
|
+
function getMessagesHost(ctx) {
|
|
16
|
+
return ctx.messages;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/rpc/functions/add.ts
|
|
20
|
+
/**
|
|
21
|
+
* Add a message entry from a browser client. The origin is force-stamped
|
|
22
|
+
* `from: 'browser'` so client-originated entries can't impersonate the
|
|
23
|
+
* server. Returns the stored entry (with generated id/timestamp), or `null`
|
|
24
|
+
* when no messages host is attached.
|
|
25
|
+
*/
|
|
26
|
+
const messagesAdd = defineMessagesRpc({
|
|
27
|
+
name: "devframes-plugin-messages:add",
|
|
28
|
+
type: "action",
|
|
29
|
+
jsonSerializable: true,
|
|
30
|
+
setup: (ctx) => ({ handler: async (input) => {
|
|
31
|
+
const host = getMessagesHost(ctx);
|
|
32
|
+
if (!host) return null;
|
|
33
|
+
return (await host.add({
|
|
34
|
+
...input,
|
|
35
|
+
from: "browser"
|
|
36
|
+
})).entry;
|
|
37
|
+
} })
|
|
38
|
+
});
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/rpc/functions/clear.ts
|
|
41
|
+
/** Clear the whole message feed. */
|
|
42
|
+
const messagesClear = defineMessagesRpc({
|
|
43
|
+
name: "devframes-plugin-messages:clear",
|
|
44
|
+
type: "action",
|
|
45
|
+
jsonSerializable: true,
|
|
46
|
+
setup: (ctx) => ({ handler: async () => {
|
|
47
|
+
await getMessagesHost(ctx)?.clear();
|
|
48
|
+
} })
|
|
49
|
+
});
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/rpc/functions/list.ts
|
|
52
|
+
/**
|
|
53
|
+
* Read the message list incrementally. Pass the `version` from the previous
|
|
54
|
+
* result as `since` to receive only what changed; omit it for the initial
|
|
55
|
+
* full snapshot. Apply `removedIds` before upserting `entries`.
|
|
56
|
+
*
|
|
57
|
+
* `snapshot: true` bakes the full list into static builds, so the panel
|
|
58
|
+
* renders the last captured feed without a live server.
|
|
59
|
+
*/
|
|
60
|
+
const messagesList = defineMessagesRpc({
|
|
61
|
+
name: "devframes-plugin-messages:list",
|
|
62
|
+
type: "query",
|
|
63
|
+
jsonSerializable: true,
|
|
64
|
+
snapshot: true,
|
|
65
|
+
agent: {
|
|
66
|
+
title: "List messages",
|
|
67
|
+
description: "List the hub message feed — diagnostics, notifications, and tool output entries with level, category, labels, and positions."
|
|
68
|
+
},
|
|
69
|
+
setup: (ctx) => ({ handler: async (since) => {
|
|
70
|
+
const host = getMessagesHost(ctx);
|
|
71
|
+
if (!host) return {
|
|
72
|
+
entries: [],
|
|
73
|
+
removedIds: [],
|
|
74
|
+
version: 0,
|
|
75
|
+
full: true
|
|
76
|
+
};
|
|
77
|
+
return host.listSince(since);
|
|
78
|
+
} })
|
|
79
|
+
});
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/rpc/functions/remove.ts
|
|
82
|
+
/** Remove (dismiss) a single message entry by id. */
|
|
83
|
+
const messagesRemove = defineMessagesRpc({
|
|
84
|
+
name: "devframes-plugin-messages:remove",
|
|
85
|
+
type: "action",
|
|
86
|
+
jsonSerializable: true,
|
|
87
|
+
setup: (ctx) => ({ handler: async (id) => {
|
|
88
|
+
await getMessagesHost(ctx)?.remove(id);
|
|
89
|
+
} })
|
|
90
|
+
});
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/rpc/index.ts
|
|
93
|
+
/**
|
|
94
|
+
* The message-feed RPC functions registered by the plugin — thin, typed
|
|
95
|
+
* wrappers over the hub's `ctx.messages` host. Namespaced
|
|
96
|
+
* `devframes-plugin-messages:*` per the plugin convention.
|
|
97
|
+
*/
|
|
98
|
+
const serverFunctions = [
|
|
99
|
+
messagesList,
|
|
100
|
+
messagesAdd,
|
|
101
|
+
defineMessagesRpc({
|
|
102
|
+
name: "devframes-plugin-messages:update",
|
|
103
|
+
type: "action",
|
|
104
|
+
jsonSerializable: true,
|
|
105
|
+
setup: (ctx) => ({ handler: async (id, patch) => {
|
|
106
|
+
const host = getMessagesHost(ctx);
|
|
107
|
+
if (!host) return null;
|
|
108
|
+
return await host.update(id, patch) ?? null;
|
|
109
|
+
} })
|
|
110
|
+
}),
|
|
111
|
+
messagesRemove,
|
|
112
|
+
messagesClear
|
|
113
|
+
];
|
|
114
|
+
//#endregion
|
|
115
|
+
export { getMessagesHost as n, serverFunctions as t };
|