@x1a0f3n9/dsh-client-ui-slots 0.1.5-rc.2
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 +21 -0
- package/README.i18n.yaml +6 -0
- package/README.md +104 -0
- package/README.zh.md +104 -0
- package/lib/index.js +433 -0
- package/lib/types/index.d.ts +740 -0
- package/lib/types/renderer.d.ts +215 -0
- package/lib/types/store.d.ts +3 -0
- package/package.json +37 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/** React-free contracts between the slot host and an installed renderer. */
|
|
2
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
+
import type { ReactNode } from 'react';
|
|
4
|
+
import type { ObservableSnapshot } from '@x1a0f3n9/dsh-client-store';
|
|
5
|
+
import type { SessionAreaProps, SlotEntryDef, SlotScope, SlotSpec, StoredEntry, Translate } from './index.ts';
|
|
6
|
+
/**
|
|
7
|
+
* The locale face the render machinery consumes: namespace binding plus an
|
|
8
|
+
* observable revision (getSnapshot/subscribe pair — the same HostObservable
|
|
9
|
+
* currency as every other standard-kit source). The revision moves on every
|
|
10
|
+
* active-locale or registry change; the renderer re-derives each entry's `t`
|
|
11
|
+
* from (namespace, revision), so a locale switch hands out NEW function
|
|
12
|
+
* references and memoized components re-render naturally. Implemented by the
|
|
13
|
+
* locale plugin, installed through the `ui-renderer` SlotRegistry.
|
|
14
|
+
* Install before the first render that needs the seat: outlets bind their
|
|
15
|
+
* revision subscription at mount, and a face appearing later has no channel
|
|
16
|
+
* to notify already-mounted outlets (the locale plugin is immediately-tier
|
|
17
|
+
* infrastructure, so normal compositions install during boot).
|
|
18
|
+
*/
|
|
19
|
+
export interface LocaleFace extends HostObservable<{
|
|
20
|
+
revision: number;
|
|
21
|
+
}> {
|
|
22
|
+
/**
|
|
23
|
+
* Bind a namespace to a translate function reading the active locale at
|
|
24
|
+
* call time. Identity may be stable per namespace — freshness of rendered
|
|
25
|
+
* text is carried by the renderer's (ns, revision) seat derivation, not by
|
|
26
|
+
* this binding.
|
|
27
|
+
* @param ns - dictionary namespace.
|
|
28
|
+
* @returns the namespace-bound translate function.
|
|
29
|
+
*/
|
|
30
|
+
bind(ns: string): Translate;
|
|
31
|
+
}
|
|
32
|
+
/** Observable currency shared by domain sources, stores, and the renderer. */
|
|
33
|
+
export type HostObservable<T> = ObservableSnapshot<T>;
|
|
34
|
+
/**
|
|
35
|
+
* Convert one standard source name to its rendered Hook prop name.
|
|
36
|
+
* @param name - registered fixed or keyed source name.
|
|
37
|
+
* @returns the `use<Name>` prop exposed to Slot components.
|
|
38
|
+
*/
|
|
39
|
+
export declare function standardHookPropName(name: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Type-erased store instance face at the render boundary (the typed twin is
|
|
42
|
+
* {@link StoreInstance}): a bare snapshot source plus the draft-stripped
|
|
43
|
+
* action callbacks. No React hook crosses this boundary — the render machinery
|
|
44
|
+
* binds `useStore` from the source at its own side (cached per instance);
|
|
45
|
+
* typing lands at the component boundary via {@link PropsStore}.
|
|
46
|
+
*/
|
|
47
|
+
export interface StoreInstanceLike {
|
|
48
|
+
getSnapshot(): unknown;
|
|
49
|
+
/**
|
|
50
|
+
* Subscribe to state changes (uSES subscribe side).
|
|
51
|
+
* @param fn - change callback.
|
|
52
|
+
* @returns unsubscribe.
|
|
53
|
+
*/
|
|
54
|
+
subscribe(fn: () => void): () => void;
|
|
55
|
+
readonly actions: Record<string, (...params: never[]) => void>;
|
|
56
|
+
}
|
|
57
|
+
/** Resolve one member of an open-key standard hook family. */
|
|
58
|
+
export type KeyedStandardSource = (key: string) => HostObservable<unknown> | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Framework-neutral inputs from which the renderer materializes standard
|
|
61
|
+
* props. A scope adapter keeps member names present while its binding is
|
|
62
|
+
* absent so optional slots retain a stable Hook call order.
|
|
63
|
+
*/
|
|
64
|
+
export interface StandardSourceBinding {
|
|
65
|
+
/** Scope identity; absent for root data and an optional scope with no selection. */
|
|
66
|
+
readonly key: string | undefined;
|
|
67
|
+
/** Fixed-name sources; each `name` becomes a `useName` selector Hook. */
|
|
68
|
+
readonly hooks: Readonly<Record<string, HostObservable<unknown> | undefined>>;
|
|
69
|
+
/** Open-key source families; each `name` becomes a `useName(key, selector)` Hook. */
|
|
70
|
+
readonly keyedHooks: Readonly<Record<string, KeyedStandardSource | undefined>>;
|
|
71
|
+
/** Stable plain values copied into standard props. */
|
|
72
|
+
readonly props: Readonly<Record<string, unknown>>;
|
|
73
|
+
}
|
|
74
|
+
/** Materialized binding for one live non-root scope. */
|
|
75
|
+
export interface ScopedStandardSourceBinding extends StandardSourceBinding {
|
|
76
|
+
readonly key: string;
|
|
77
|
+
readonly ctx: Context;
|
|
78
|
+
}
|
|
79
|
+
/** One installed source of bindings for a non-root Slot scope. */
|
|
80
|
+
export interface SlotScopeAdapter {
|
|
81
|
+
/** Binding that follows the current selection, including its absent projection. */
|
|
82
|
+
readonly current: HostObservable<StandardSourceBinding>;
|
|
83
|
+
/**
|
|
84
|
+
* Resolve an already-materialized binding.
|
|
85
|
+
* @param key - scope identity.
|
|
86
|
+
* @returns the binding, or `undefined` when the identity is unavailable.
|
|
87
|
+
*/
|
|
88
|
+
resolve(key: string): ScopedStandardSourceBinding | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Render the scope owner's area seat over the current binding. The renderer
|
|
91
|
+
* binds this function to the standard `SessionProvider` prop without owning
|
|
92
|
+
* Session selection semantics.
|
|
93
|
+
* @param binding - current scope binding, including its absent projection.
|
|
94
|
+
* @param props - render-prop body and empty branch.
|
|
95
|
+
* @returns rendered scope area.
|
|
96
|
+
*/
|
|
97
|
+
renderArea?(binding: StandardSourceBinding, props: SessionAreaProps): ReactNode;
|
|
98
|
+
}
|
|
99
|
+
/** Root standard-source contribution installed by one domain UI package. */
|
|
100
|
+
export interface RootStandardSourceContribution {
|
|
101
|
+
readonly hooks?: Readonly<Record<string, HostObservable<unknown>>>;
|
|
102
|
+
readonly keyedHooks?: Readonly<Record<string, KeyedStandardSource>>;
|
|
103
|
+
readonly props?: Readonly<Record<string, unknown>>;
|
|
104
|
+
}
|
|
105
|
+
/** renderSlot dispatch options at the machinery level. */
|
|
106
|
+
export interface RenderOpts {
|
|
107
|
+
entryKey?: string;
|
|
108
|
+
only?: string;
|
|
109
|
+
fallback?: ReactNode;
|
|
110
|
+
/** Opaque occurrence context consumed only by function-valued injected Hooks. */
|
|
111
|
+
hookContext?: unknown;
|
|
112
|
+
}
|
|
113
|
+
/** Host API the `ui-renderer` SlotRegistry presents to its React renderer. */
|
|
114
|
+
export interface SlotRendererHost {
|
|
115
|
+
/**
|
|
116
|
+
* Subscribe to a key's registration changes (microtask-batched).
|
|
117
|
+
* @param key - slot key.
|
|
118
|
+
* @param fn - change callback.
|
|
119
|
+
* @returns unsubscribe.
|
|
120
|
+
*/
|
|
121
|
+
subscribe(key: string, fn: () => void): () => void;
|
|
122
|
+
/**
|
|
123
|
+
* Monotonic version for uSES pairing.
|
|
124
|
+
* @param key - slot key.
|
|
125
|
+
* @returns current version.
|
|
126
|
+
*/
|
|
127
|
+
getVersion(key: string): number;
|
|
128
|
+
/**
|
|
129
|
+
* Snapshot the registered entries for a key (stable reference between mutations).
|
|
130
|
+
* @param key - slot key.
|
|
131
|
+
* @returns entries in registration (list: order) sequence.
|
|
132
|
+
*/
|
|
133
|
+
entriesOf(key: string): readonly StoredEntry[];
|
|
134
|
+
/**
|
|
135
|
+
* Shadowing winners per cell for a key — the render read for single/keyed/
|
|
136
|
+
* list dispatch: the first live (non-abdicated) entry of each cell in
|
|
137
|
+
* priority order; chain keys pass through unchanged (election consumes
|
|
138
|
+
* every entry). Fresh array per call — a render-body read, not a uSES
|
|
139
|
+
* getSnapshot source.
|
|
140
|
+
* @param key - slot key.
|
|
141
|
+
* @returns the winning entry per occupied cell.
|
|
142
|
+
*/
|
|
143
|
+
entriesOfSlot(key: string): readonly StoredEntry[];
|
|
144
|
+
/**
|
|
145
|
+
* Report an entry boundary crash. With `info.abdicate` (shadowing kinds)
|
|
146
|
+
* the entry retires from its cell, one-shot, so the next survivor renders;
|
|
147
|
+
* chain crashes report without abdicating. The registration stays on the
|
|
148
|
+
* ledger either way.
|
|
149
|
+
* @param key - slot key the entry rendered under.
|
|
150
|
+
* @param entry - the crashed entry.
|
|
151
|
+
* @param error - the crash cause.
|
|
152
|
+
* @param info - `abdicate`: whether the crash retires the entry from its cell.
|
|
153
|
+
*/
|
|
154
|
+
reportEntryError(key: string, entry: StoredEntry, error: unknown, info: {
|
|
155
|
+
abdicate: boolean;
|
|
156
|
+
}): void;
|
|
157
|
+
/**
|
|
158
|
+
* Declared runtime spec from the declarations ledger.
|
|
159
|
+
* @param key - slot key.
|
|
160
|
+
* @returns the spec, or undefined while the key is undeclared (outlets render empty).
|
|
161
|
+
*/
|
|
162
|
+
specOf(key: string): SlotSpec<SlotEntryDef> | undefined;
|
|
163
|
+
/**
|
|
164
|
+
* Stale-authorization check: whether the entry is still in the ledger.
|
|
165
|
+
* @param entry - a previously rendered entry.
|
|
166
|
+
* @returns false once the entry's registration was disposed.
|
|
167
|
+
*/
|
|
168
|
+
isLive(entry: StoredEntry): boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Resolve (create or return cached) the store instance for an entry's
|
|
171
|
+
* declared handle under a scope key; lifecycle rides the ledger axis.
|
|
172
|
+
* @param entry - entry whose declaration carries the handle.
|
|
173
|
+
* @param scopeBinding - exact Session binding for scoped slots, undefined for root scope.
|
|
174
|
+
* @returns the instance, or undefined when the entry declares no store.
|
|
175
|
+
*/
|
|
176
|
+
storeOf(entry: StoredEntry, scopeBinding: ScopedStandardSourceBinding | undefined): StoreInstanceLike | undefined;
|
|
177
|
+
/** Root standard data assembled from domain-owned contributions. */
|
|
178
|
+
readonly root: HostObservable<StandardSourceBinding>;
|
|
179
|
+
/** Monotonic source updated whenever the installed scope-adapter roster changes. */
|
|
180
|
+
readonly scopeRevision: HostObservable<number>;
|
|
181
|
+
/**
|
|
182
|
+
* Resolve the adapter installed for one non-root scope.
|
|
183
|
+
* `session` and `session-maybe` intentionally resolve the same adapter.
|
|
184
|
+
* @param scope - Slot scope.
|
|
185
|
+
* @returns adapter, or `undefined` when the composition omitted its owner.
|
|
186
|
+
*/
|
|
187
|
+
scope(scope: Exclude<SlotScope, 'root'>): SlotScopeAdapter | undefined;
|
|
188
|
+
/**
|
|
189
|
+
* Installed locale face backing the `t` standard seat (absent until the
|
|
190
|
+
* locale plugin installs one; rendering an entry that declared `locale:`
|
|
191
|
+
* without it is an assembly failure).
|
|
192
|
+
*/
|
|
193
|
+
locale?: LocaleFace | undefined;
|
|
194
|
+
}
|
|
195
|
+
/** The installation contract between the `ui-renderer` SlotRegistry and its React renderer. */
|
|
196
|
+
export interface SlotRenderer {
|
|
197
|
+
/**
|
|
198
|
+
* Render the root slot tree over the host API (the only ctx-level entry).
|
|
199
|
+
* @param host - the installing service's host API.
|
|
200
|
+
* @param ownerProps - owner props from the shell's renderSlot('root', ...) call.
|
|
201
|
+
* @returns the rendered tree.
|
|
202
|
+
*/
|
|
203
|
+
renderRoot(host: SlotRendererHost, ownerProps: object): ReactNode;
|
|
204
|
+
}
|
|
205
|
+
/** Thrown when a retained renderSlot binding is invoked after its declaring entry was disposed. */
|
|
206
|
+
export declare class StaleAuthorizationError extends Error {
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Thrown when a renderSlot binding is invoked for a key outside its entry's
|
|
210
|
+
* children declaration (plain-JS backstop; typed callers are narrowed
|
|
211
|
+
* statically).
|
|
212
|
+
*/
|
|
213
|
+
export declare class SlotOwnershipError extends Error {
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Slot-facing re-exports of the React-free store contracts. */
|
|
2
|
+
export type { ActionsDecl, BakedActions, BoundActions, DefineStore, HandleOf, MaybeSnapshotSelectorHook, PropsStore, SnapshotSelectorHook, StoreDecl, StoreFactory, StoreHandle, StoreInstance, StoreSpec, } from '@x1a0f3n9/dsh-client-store';
|
|
3
|
+
//# sourceMappingURL=store.d.ts.map
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@x1a0f3n9/dsh-client-ui-slots",
|
|
3
|
+
"description": "Slot registry pure core: SlotMap declaration merging, single register composition API, four-share props types, store-seat types, renderer install seam",
|
|
4
|
+
"version": "0.1.5-rc.2",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
|
|
11
|
+
"directory": "packages/client/ui-slots"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "lib/index.js",
|
|
15
|
+
"types": "lib/types/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/types/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./src/*": "./src/*",
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/react": "~18.3.1",
|
|
27
|
+
"@x1a0f3n9/dsh-client-store": "^0.1.5-rc.2",
|
|
28
|
+
"@deepseek-ai/cordis": "^4.0.2"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"lib/index.js",
|
|
32
|
+
"lib/types/**/*.d.ts"
|
|
33
|
+
],
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@deepseek-ai/cordis": "^4.0.2"
|
|
36
|
+
}
|
|
37
|
+
}
|