@nac3/runtime 2.5.2 → 2.8.0

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/dist/nac.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // Generated by build.mjs -- do not edit. Source: js/nac.js
2
- // Core runtime surface for @nac3/runtime v2.5.2.
2
+ // Core runtime surface for @nac3/runtime v2.8.0.
3
3
  // The data-table (dt_*) + brownfield primitives live in the
4
4
  // extensions entry: import '@nac3/runtime/extensions' and see
5
5
  // the NACExtensions interface in nac-v2-extensions.d.ts.
@@ -21,6 +21,10 @@ export interface ManifestElement {
21
21
  role: string;
22
22
  label_i18n?: Record<string, string>;
23
23
  actions?: Array<{ verb: string; label_i18n?: Record<string, string> }>;
24
+ /** The id that has to be operated before this element can be
25
+ * (SPEC.md 4.2, since 2.7.0). click() still refuses the element
26
+ * while it is hidden, and names this id when it does. */
27
+ undrivable_until?: string;
24
28
  [k: string]: unknown;
25
29
  }
26
30
 
@@ -61,6 +65,92 @@ export interface ValidateGlobalReport {
61
65
  timestamp: number;
62
66
  }
63
67
 
68
+ /** A verb argument as the manifest declares it (V26-01, SPEC 15.11). */
69
+ export interface ParamDecl {
70
+ name: string;
71
+ type: 'string' | 'number' | 'boolean' | 'object' | 'array';
72
+ required?: boolean;
73
+ unit?: string;
74
+ min?: number;
75
+ max?: number;
76
+ enum?: unknown[];
77
+ label?: string;
78
+ hint?: string;
79
+ }
80
+
81
+ /** What NAC.plugins() / NAC.describePlugin() hand back (V26-01, SPEC 15.10).
82
+ It is a COPY: mutating it cannot reach the live registry. */
83
+ export interface PluginDescriptor {
84
+ slug: string;
85
+ label: string | null;
86
+ hint: string | null;
87
+ /** v2.7 (SPEC 19.1): does this plugin declare the headless profile --
88
+ every binding reachable with no document at all? */
89
+ headless: boolean;
90
+ verbs: Array<{
91
+ verb_path: string;
92
+ backend: string | null;
93
+ label: string | null;
94
+ hint: string | null;
95
+ params: ParamDecl[] | null;
96
+ handle?: string;
97
+ }>;
98
+ state: Array<{
99
+ state_path: string;
100
+ backends: Array<string | null>;
101
+ label: string | null;
102
+ hint: string | null;
103
+ unit: string | null;
104
+ }>;
105
+ events: Array<{
106
+ event_path: string;
107
+ backend: string | null;
108
+ label: string | null;
109
+ hint: string | null;
110
+ observe: string[] | null;
111
+ event?: string;
112
+ }>;
113
+ }
114
+
115
+ /** What NAC.profile() answers (v2.7, SPEC 19.1). `headless` is
116
+ MEASURED from the manifest; `declared_headless` is what the
117
+ manifest claimed. They differ when a manifest would work with no
118
+ document but never said so. */
119
+ export interface PluginProfile {
120
+ slug: string;
121
+ declared_headless: boolean;
122
+ headless: boolean;
123
+ dom_required: Array<{
124
+ kind: 'verb' | 'state' | 'event';
125
+ path: string;
126
+ backend: string | null;
127
+ why: string;
128
+ binding_index?: number;
129
+ observes?: string;
130
+ }>;
131
+ }
132
+
133
+ /** One provenance row as a sink receives it (v2.7, SPEC 19.4). Same
134
+ type names and same detail shape as the DOM event family of 15.7 --
135
+ the bus changes, the contract does not. */
136
+ export interface ProvenanceRow {
137
+ type: string;
138
+ detail: Record<string, unknown>;
139
+ }
140
+
141
+ /** What NAC.provenanceStatus() answers (v2.7, SPEC 19.4). `dropped`
142
+ counts the rows that reached NEITHER bus, so a loss outside the
143
+ headless profile is readable instead of silent. */
144
+ export interface ProvenanceStatus {
145
+ document: boolean;
146
+ sink: boolean;
147
+ observable: boolean;
148
+ to_document: number;
149
+ to_sink: number;
150
+ dropped: number;
151
+ sink_errors: number;
152
+ }
153
+
64
154
  /** Subscription handle returned by NAC.subscribe (V25-01). */
65
155
  export interface SubscriptionHandle {
66
156
  __v25_sub: true;
@@ -100,6 +190,26 @@ export interface NACRuntime {
100
190
  list(...args: unknown[]): unknown;
101
191
  find(...args: unknown[]): unknown;
102
192
  read_feedback(...args: unknown[]): unknown;
193
+
194
+ /* the role vocabulary (v2.8). Typed out in full rather than as
195
+ unknown[], because the whole point of 2.8 is that a consumer can
196
+ learn the vocabulary without reading the implementation -- and a
197
+ declaration that says unknown sends it back to the source. */
198
+ roles(): {
199
+ spec_version: string;
200
+ canonical: string[];
201
+ aliases: Record<string, string>;
202
+ registered: Array<{
203
+ role: string; events: string[]; clickable: boolean;
204
+ describes: string | null; plugin: string | null; source: 'registered';
205
+ }>;
206
+ click_events: Record<string, string[]>;
207
+ no_click_event: string[];
208
+ };
209
+ canonical_role(role: string): string;
210
+ register_role(name: string, spec?: {
211
+ events?: string[]; describes?: string; plugin?: string;
212
+ }): { ok: true; role: string; already: boolean };
103
213
  snapshot_state(...args: unknown[]): unknown;
104
214
  validate(...args: unknown[]): unknown;
105
215
  validate_global(): ValidateGlobalReport;
@@ -139,12 +249,31 @@ export interface NACRuntime {
139
249
  revoke_authority(scope: string): void;
140
250
 
141
251
  /* v2.5 V25-01 Block A -- plugin extension contract (canvas + API) */
142
- registerPlugin(slug: string, manifest: { verbs?: object; state?: object; events?: object }): void;
252
+ registerPlugin(slug: string, manifest: { label?: string; hint?: string; headless?: boolean; verbs?: object; state?: object; events?: object }): void;
143
253
  call(plugin: string, verb_path: string, args?: unknown): Promise<unknown>;
144
254
  read(plugin: string, state_path: string): Promise<unknown>;
145
255
  subscribe(plugin: string, event_path: string, cb: (...args: unknown[]) => void): SubscriptionHandle;
146
256
  unsubscribe(handle: SubscriptionHandle): void;
147
257
 
258
+ /* v2.6 V26-01 -- discovery (SPEC 15.10) + self-description (15.11) +
259
+ API handles for an object that never lands on window (15.4). The
260
+ first two are SYNCHRONOUS: they read a local object. */
261
+ plugins(): PluginDescriptor[];
262
+ describePlugin(slug: string): PluginDescriptor;
263
+ registerApiHandle(name: string, obj: object): void;
264
+ unregisterApiHandle(name: string): boolean;
265
+ apiHandles(): string[];
266
+
267
+ /* v2.7 -- the headless profile (SPEC 19, decision D-26). The manifest
268
+ IS the surface where no document exists: profile() says whether a
269
+ plugin needs one, setEventSink() carries the nac:plugin:* family
270
+ over a bus that is not the DOM, and provenanceStatus() makes both
271
+ the delivery and any loss readable. */
272
+ profile(slug: string): PluginProfile;
273
+ setEventSink(fn: ((row: ProvenanceRow) => void) | null): ((row: ProvenanceRow) => void) | null;
274
+ eventSink(): ((row: ProvenanceRow) => void) | null;
275
+ provenanceStatus(): ProvenanceStatus;
276
+
148
277
  /* v2.5 V25-03 Block C -- asistive labels */
149
278
  narrate(plugin: string | null, nac_id: string): string | null;
150
279