@wireweave/core 3.1.0-beta.9 → 4.0.0-beta.12

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.
Files changed (50) hide show
  1. package/README.md +17 -126
  2. package/dist/app.cjs +31 -0
  3. package/dist/app.d.cts +488 -0
  4. package/dist/app.d.ts +488 -0
  5. package/dist/app.js +31 -0
  6. package/dist/chunk-3RWGG5EC.js +18088 -0
  7. package/dist/chunk-4TMDPWPR.cjs +196 -0
  8. package/dist/chunk-5DGRIQDU.cjs +842 -0
  9. package/dist/chunk-7VTK6LHL.cjs +4374 -0
  10. package/dist/chunk-ETV4XYOV.cjs +7 -0
  11. package/dist/chunk-IMUVIIJR.cjs +18088 -0
  12. package/dist/chunk-JJWAFHSV.js +842 -0
  13. package/dist/chunk-MD6MNOEQ.cjs +2905 -0
  14. package/dist/chunk-PKBMQBKP.js +7 -0
  15. package/dist/chunk-QOS4IC75.js +4374 -0
  16. package/dist/chunk-R5WBZWBC.js +196 -0
  17. package/dist/chunk-V3HVWC7C.js +2905 -0
  18. package/dist/chunk-WV724EAW.js +0 -0
  19. package/dist/chunk-XENFKHRC.cjs +1 -0
  20. package/dist/chunk-XYACLXXF.js +51612 -0
  21. package/dist/chunk-ZPHNXJRY.cjs +51612 -0
  22. package/dist/index-Br7pNaf3.d.cts +240 -0
  23. package/dist/index-CghCKUPx.d.ts +337 -0
  24. package/dist/index-Da_B3eoM.d.ts +240 -0
  25. package/dist/index-G906GEtg.d.cts +337 -0
  26. package/dist/index.cjs +963 -64577
  27. package/dist/index.d.cts +13 -522
  28. package/dist/index.d.ts +13 -522
  29. package/dist/index.js +711 -64118
  30. package/dist/interaction.cjs +17 -0
  31. package/dist/interaction.d.cts +3 -0
  32. package/dist/interaction.d.ts +3 -0
  33. package/dist/interaction.js +17 -0
  34. package/dist/parser.cjs +18 -7832
  35. package/dist/parser.d.cts +10 -1
  36. package/dist/parser.d.ts +10 -1
  37. package/dist/parser.js +16 -7800
  38. package/dist/renderer.cjs +7 -53162
  39. package/dist/renderer.d.cts +19 -239
  40. package/dist/renderer.d.ts +19 -239
  41. package/dist/renderer.js +37 -53137
  42. package/dist/spec.cjs +42 -2883
  43. package/dist/spec.d.cts +4 -75
  44. package/dist/spec.d.ts +4 -75
  45. package/dist/spec.js +25 -2818
  46. package/dist/types-Dkgr0Wyc.d.cts +75 -0
  47. package/dist/types-Dkgr0Wyc.d.ts +75 -0
  48. package/dist/v4-types-Baz9yqAS.d.cts +137 -0
  49. package/dist/v4-types-Baz9yqAS.d.ts +137 -0
  50. package/package.json +22 -1
package/dist/app.d.ts ADDED
@@ -0,0 +1,488 @@
1
+ import { aK as SourceLocation, aa as LayoutDefinitionNode, z as ComponentDefinitionNode, as as PageNode } from './types-vhPCZpAW.js';
2
+ import { J as JsonObject, k as V4SourceSpan, P as ParsedDocument, a as CanonicalModule, g as JsonValue } from './v4-types-Baz9yqAS.js';
3
+ import { S as SiteOptions } from './index-Da_B3eoM.js';
4
+
5
+ /** A source file and exact span within it. */
6
+ interface AppSourceSpan {
7
+ sourceId: string;
8
+ location: SourceLocation;
9
+ }
10
+ /** The two reusable definition kinds addressable by an app reference. */
11
+ type AppDefinitionKind = 'layout' | 'component';
12
+ /** Every stable, top-level node kind in a linked application. */
13
+ type AppNodeKind = AppDefinitionKind | 'screen';
14
+ /** A manifest entry assigning one module its stable application namespace. */
15
+ interface AppManifestModule {
16
+ id: string;
17
+ namespace: string;
18
+ location: SourceLocation;
19
+ }
20
+ /**
21
+ * Core-owned manifest describing the modules that make up one application.
22
+ * @public
23
+ */
24
+ interface AppManifest {
25
+ id: string;
26
+ sourceId: string;
27
+ modules: readonly AppManifestModule[];
28
+ }
29
+ /** A reference to a layout or component, local to the owner namespace by default. */
30
+ interface AppReferenceInput {
31
+ kind: AppDefinitionKind;
32
+ id: string;
33
+ namespace?: string;
34
+ source: AppSourceSpan;
35
+ }
36
+ interface AppNodeInput<TNode> {
37
+ /** Stable identifier within the module namespace and node kind. */
38
+ id: string;
39
+ node: TNode;
40
+ source: AppSourceSpan;
41
+ }
42
+ /** A layout declaration and the reusable definitions it depends on. */
43
+ interface AppLayoutInput extends AppNodeInput<LayoutDefinitionNode> {
44
+ references?: readonly AppReferenceInput[];
45
+ }
46
+ /** A component declaration and the reusable definitions it depends on. */
47
+ interface AppComponentInput extends AppNodeInput<ComponentDefinitionNode> {
48
+ references?: readonly AppReferenceInput[];
49
+ }
50
+ /** A screen declaration and the layouts/components it consumes. */
51
+ interface AppScreenInput extends AppNodeInput<PageNode> {
52
+ references?: readonly AppReferenceInput[];
53
+ }
54
+ /**
55
+ * One parsed Wireweave module supplied to the Core linker.
56
+ * @public
57
+ */
58
+ interface AppModuleInput {
59
+ id: string;
60
+ source: AppSourceSpan;
61
+ layouts: readonly AppLayoutInput[];
62
+ components: readonly AppComponentInput[];
63
+ screens: readonly AppScreenInput[];
64
+ }
65
+ /** Opaque stable identity assigned by the linker. */
66
+ type AppNodeId = string & {
67
+ readonly __appNodeId: unique symbol;
68
+ };
69
+ /** Stable identity of one expanded component invocation. */
70
+ type AppComponentInstanceId = string & {
71
+ readonly __appComponentInstanceId: unique symbol;
72
+ };
73
+ /** A reference whose target has been resolved to stable app identity. */
74
+ interface ResolvedAppReference {
75
+ kind: AppDefinitionKind;
76
+ id: string;
77
+ namespace: string;
78
+ targetId: AppNodeId;
79
+ source: AppSourceSpan;
80
+ }
81
+ interface ResolvedAppNode<TKind extends AppNodeKind, TNode> {
82
+ nodeId: AppNodeId;
83
+ kind: TKind;
84
+ id: string;
85
+ moduleId: string;
86
+ namespace: string;
87
+ node: TNode;
88
+ source: AppSourceSpan;
89
+ references: readonly ResolvedAppReference[];
90
+ }
91
+ type ResolvedAppLayout = ResolvedAppNode<'layout', LayoutDefinitionNode>;
92
+ type ResolvedAppComponent = ResolvedAppNode<'component', ComponentDefinitionNode>;
93
+ type ResolvedAppScreen = ResolvedAppNode<'screen', PageNode>;
94
+ /** Stable node-to-source mapping emitted in manifest order. */
95
+ interface AppSourceMapEntry {
96
+ nodeId: AppNodeId;
97
+ source: AppSourceSpan;
98
+ }
99
+ /** One resolved module in a linked application document. */
100
+ interface ResolvedAppModule {
101
+ id: string;
102
+ namespace: string;
103
+ layouts: readonly ResolvedAppLayout[];
104
+ components: readonly ResolvedAppComponent[];
105
+ screens: readonly ResolvedAppScreen[];
106
+ }
107
+ /**
108
+ * Core's dependency-closed representation of a multi-module application.
109
+ * @public
110
+ */
111
+ interface AppDocument {
112
+ type: 'AppDocument';
113
+ id: string;
114
+ modules: readonly ResolvedAppModule[];
115
+ layouts: readonly ResolvedAppLayout[];
116
+ components: readonly ResolvedAppComponent[];
117
+ screens: readonly ResolvedAppScreen[];
118
+ sourceMap: readonly AppSourceMapEntry[];
119
+ }
120
+ /** Stable machine-readable linker diagnostic kinds. */
121
+ type AppLinkDiagnosticCode = 'missing-module' | 'duplicate-module' | 'duplicate-namespace' | 'duplicate-definition' | 'duplicate-screen' | 'missing-reference' | 'cyclic-reference' | 'invalid-component-definition' | 'invalid-component-invocation';
122
+ /**
123
+ * A deterministic linker failure with the exact source span that caused it.
124
+ * @public
125
+ */
126
+ interface AppLinkDiagnostic {
127
+ code: AppLinkDiagnosticCode;
128
+ message: string;
129
+ source: AppSourceSpan;
130
+ }
131
+ type AppLinkResult = {
132
+ ok: true;
133
+ document: AppDocument;
134
+ diagnostics: readonly [];
135
+ } | {
136
+ ok: false;
137
+ document: null;
138
+ diagnostics: readonly AppLinkDiagnostic[];
139
+ };
140
+
141
+ interface Diagnostic {
142
+ severity: 'error';
143
+ code: string;
144
+ phase: 'schema' | 'import' | 'link' | 'compile';
145
+ sourceId: string;
146
+ start: number;
147
+ end: number;
148
+ path: string;
149
+ messageKey: string;
150
+ details: JsonObject;
151
+ related: {
152
+ sourceId: string;
153
+ start: number;
154
+ end: number;
155
+ }[];
156
+ }
157
+ type AppResult<T> = {
158
+ ok: true;
159
+ value: T;
160
+ diagnostics: readonly [];
161
+ } | {
162
+ ok: false;
163
+ value: null;
164
+ html: null;
165
+ diagnostics: readonly Diagnostic[];
166
+ };
167
+ interface ScreenReference {
168
+ namespace: string;
169
+ id: string;
170
+ variant?: string;
171
+ }
172
+ interface CreateAppBundleOptions {
173
+ id: string;
174
+ entry: ScreenReference;
175
+ profile: JsonObject;
176
+ states: JsonObject[];
177
+ registry: ParsedDocument['registry'];
178
+ fixtures: JsonObject[];
179
+ /** Exact original module bytes. Source maps address these bytes as moduleId.wf. */
180
+ moduleSources: Readonly<Record<string, string>>;
181
+ }
182
+ declare const bundleBrand: unique symbol;
183
+ declare const linkedBrand: unique symbol;
184
+ interface AppBundle {
185
+ readonly [bundleBrand]: true;
186
+ readonly schemaVersion: '1.0.0';
187
+ readonly languageVersion: '4.0.0';
188
+ readonly id: string;
189
+ readonly entry: Readonly<ScreenReference>;
190
+ readonly profile: Readonly<JsonObject>;
191
+ readonly states: readonly JsonObject[];
192
+ readonly registry: Readonly<ParsedDocument['registry']>;
193
+ readonly fixtures: readonly JsonObject[];
194
+ readonly modules: readonly CanonicalModule[];
195
+ }
196
+ type InstanceStep = {
197
+ kind: 'use';
198
+ id: string;
199
+ } | {
200
+ kind: 'repeat';
201
+ id: string;
202
+ index: number;
203
+ };
204
+ interface LinkedIdentity {
205
+ namespace: string;
206
+ definitionKind: 'page' | 'layout' | 'component';
207
+ definitionId: string;
208
+ instanceRoot: {
209
+ kind: 'screen';
210
+ namespace: string;
211
+ id: string;
212
+ } | {
213
+ kind: 'shell';
214
+ namespace: string;
215
+ id: string;
216
+ profileDigest: string;
217
+ };
218
+ instancePath: InstanceStep[];
219
+ localId: string;
220
+ }
221
+ interface SourceMapEntry {
222
+ renderedId: string;
223
+ identity: LinkedIdentity;
224
+ moduleId: string;
225
+ source: Readonly<V4SourceSpan>;
226
+ invocationSources: readonly Readonly<V4SourceSpan>[];
227
+ requirementRefs: readonly string[];
228
+ obligationRefs: readonly string[];
229
+ operationIds: readonly string[];
230
+ }
231
+ interface LinkedApp {
232
+ readonly [linkedBrand]: true;
233
+ readonly kind: 'LinkedApp';
234
+ readonly languageVersion: '4.0.0';
235
+ readonly id: string;
236
+ readonly digest: string;
237
+ readonly sourceMap: readonly SourceMapEntry[];
238
+ }
239
+ interface AppArtifact {
240
+ readonly kind: 'AppArtifact';
241
+ readonly schemaVersion: '1.0.0';
242
+ readonly languageVersion: '4.0.0';
243
+ readonly html: string;
244
+ readonly mediaType: 'text/html';
245
+ readonly byteLength: number;
246
+ readonly digest: string;
247
+ readonly modelDigest: string;
248
+ readonly profileDigest: string;
249
+ readonly runtimeDigest: string;
250
+ readonly registryDigest: string;
251
+ readonly entry: Readonly<ScreenReference>;
252
+ readonly screenIndex: readonly {
253
+ route: ScreenReference;
254
+ renderedId: string;
255
+ }[];
256
+ readonly operationIndex: readonly {
257
+ renderedId: string;
258
+ handlerId: string;
259
+ operationId: string;
260
+ executionClass: string;
261
+ operation: JsonObject;
262
+ }[];
263
+ readonly diagnostics: readonly [];
264
+ readonly sourceMap: readonly SourceMapEntry[];
265
+ readonly manifest: {
266
+ readonly appId: string;
267
+ readonly modelDigest: string;
268
+ readonly profileDigest: string;
269
+ readonly registryDigest: string;
270
+ readonly htmlDigest: string;
271
+ readonly runtimeDigest: string;
272
+ readonly executionScope: 'standard-1';
273
+ readonly unsupportedOperations: readonly {
274
+ renderedId: string;
275
+ handlerId: string;
276
+ operationId: string;
277
+ }[];
278
+ };
279
+ }
280
+ declare function createAppBundle(documents: readonly ParsedDocument[], options: CreateAppBundleOptions): AppResult<AppBundle>;
281
+
282
+ /**
283
+ * Create the stable identity used by linked documents and source maps.
284
+ * Each segment is encoded so punctuation in authored identifiers cannot collide.
285
+ *
286
+ * @public
287
+ */
288
+ declare function createAppNodeId(namespace: string, kind: AppNodeKind, id: string): AppNodeId;
289
+ /** Create the stable identity of an invocation from its owner and structural path. */
290
+ declare function createAppComponentInstanceId(ownerId: AppNodeId, targetId: AppNodeId, path: readonly number[]): AppComponentInstanceId;
291
+ /**
292
+ * Link parsed Wireweave modules into one dependency-closed application document.
293
+ * The function is pure and returns no document whenever validation finds an error.
294
+ *
295
+ * @public
296
+ * @example
297
+ * `const result = linkApp(manifest, modules)`
298
+ */
299
+ declare function linkApp(bundle: AppBundle): AppResult<LinkedApp>;
300
+ declare function linkApp(manifest: AppManifest, modules: readonly AppModuleInput[]): AppLinkResult;
301
+
302
+ /**
303
+ * Options for {@link compileApp}.
304
+ *
305
+ * Application artifacts always use neutral annotation styling. The option is
306
+ * intentionally omitted here so every compiler caller gets the same wireframe
307
+ * presentation while legacy render entry points keep their historical default.
308
+ *
309
+ * @public
310
+ */
311
+ type CompileAppOptions = Omit<SiteOptions, 'annotationStyle'>;
312
+ /** Result of linking modules and compiling the resulting application. @public */
313
+ type AppCompileResult = {
314
+ ok: true;
315
+ document: AppDocument;
316
+ html: string;
317
+ diagnostics: readonly [];
318
+ } | {
319
+ ok: false;
320
+ document: null;
321
+ html: null;
322
+ diagnostics: readonly AppLinkDiagnostic[];
323
+ };
324
+ /**
325
+ * Compile one linked application into a deterministic, self-contained HTML document.
326
+ *
327
+ * The linker has already expanded component invocations and resolved shared
328
+ * layouts. This function only projects those resolved nodes into the generic
329
+ * site compositor, using stable app identities for layout names so modules
330
+ * cannot collide.
331
+ *
332
+ * @public
333
+ * @example
334
+ * `const html = compileApp(linked.document)`
335
+ */
336
+ declare function compileApp(document: LinkedApp): AppResult<AppArtifact>;
337
+ declare function compileApp(document: AppDocument, options?: CompileAppOptions): string;
338
+ /**
339
+ * Link application modules and compile them when linking succeeds.
340
+ *
341
+ * Linker diagnostics remain explicit and no partial HTML is emitted on failure.
342
+ *
343
+ * @public
344
+ * @example
345
+ * `const result = linkAndCompileApp(manifest, modules)`
346
+ */
347
+ declare function linkAndCompileApp(bundle: AppBundle): AppResult<AppArtifact>;
348
+ declare function linkAndCompileApp(manifest: AppManifest, modules: readonly AppModuleInput[], options?: CompileAppOptions): AppCompileResult;
349
+ type RuntimeInput = {
350
+ kind: 'event';
351
+ source: LinkedIdentity;
352
+ event: 'click' | 'input' | 'change' | 'submit' | 'keydown' | 'focus' | 'blur';
353
+ value?: JsonValue;
354
+ checked?: boolean;
355
+ key?: string;
356
+ } | {
357
+ kind: 'advanceClock';
358
+ deltaMs: number;
359
+ } | {
360
+ kind: 'address';
361
+ fragment: string;
362
+ } | {
363
+ kind: 'reset';
364
+ };
365
+ interface RuntimeOperation {
366
+ id: string;
367
+ executionClass: 'executable' | 'simulated' | 'specified';
368
+ effect: JsonObject;
369
+ after: string[];
370
+ onFailure: 'stop' | 'continue';
371
+ }
372
+ interface RuntimeTrace {
373
+ schemaVersion: '1.0.0';
374
+ appId: string;
375
+ modelDigest: string;
376
+ profileDigest: string;
377
+ sequence: number;
378
+ resetGeneration: number;
379
+ virtualTime: number;
380
+ route: ScreenReference | null;
381
+ source: LinkedIdentity | null;
382
+ renderedId: string | null;
383
+ handlerId: string | null;
384
+ operationId: string | null;
385
+ executionClass: string;
386
+ event: JsonObject;
387
+ stateDeltaDigest: string;
388
+ result: string;
389
+ diagnostic: string | null;
390
+ }
391
+ interface RuntimeControl {
392
+ value: JsonValue;
393
+ checked: boolean;
394
+ pending?: boolean;
395
+ }
396
+ interface RuntimeActivation {
397
+ id: number;
398
+ owner: string;
399
+ handlerId: string;
400
+ event: JsonObject;
401
+ index: number;
402
+ statuses: Record<string, string>;
403
+ }
404
+ interface RuntimeRequest {
405
+ id: string;
406
+ generation: number;
407
+ sequence: number;
408
+ activation: number;
409
+ owner: string;
410
+ operation: RuntimeOperation;
411
+ resultKey: string;
412
+ statusKey: string;
413
+ errorKey: string;
414
+ deadline: number;
415
+ responseAt: number;
416
+ outcome: string;
417
+ value: JsonValue;
418
+ }
419
+ interface RuntimeScheduled {
420
+ time: number;
421
+ priority: number;
422
+ sequence: number;
423
+ requestId: string;
424
+ generation: number;
425
+ owner: string;
426
+ operationId: string;
427
+ }
428
+ interface RuntimeQueued {
429
+ source: string;
430
+ event: JsonObject;
431
+ handlerId: string | null;
432
+ }
433
+ interface RuntimeBrowserEffect {
434
+ kind: 'push' | 'replace' | 'traverse' | 'compensate' | 'external';
435
+ fragment: string;
436
+ sequence: number;
437
+ delta: number;
438
+ }
439
+ interface RuntimeSnapshot {
440
+ modelDigest: string;
441
+ profileDigest: string;
442
+ resetGeneration: number;
443
+ virtualTime: number;
444
+ sequence: number;
445
+ requestSequence: number;
446
+ activationSequence: number;
447
+ states: Record<string, JsonValue>;
448
+ controls: Record<string, RuntimeControl>;
449
+ invalid: Record<string, string>;
450
+ route: ScreenReference | null;
451
+ address: string;
452
+ history: {
453
+ fragment: string;
454
+ sequence: number;
455
+ }[];
456
+ historyIndex: number;
457
+ nextHistorySequence: number;
458
+ overlays: {
459
+ id: string;
460
+ opener: string | null;
461
+ modal: boolean;
462
+ }[];
463
+ focus: string | null;
464
+ selection: Record<string, number>;
465
+ expanded: Record<string, boolean>;
466
+ viewMode: 'fixed' | 'accessible';
467
+ fixtureCursors: Record<string, number>;
468
+ requests: Record<string, RuntimeRequest>;
469
+ reservations: Record<string, string>;
470
+ activations: Record<string, RuntimeActivation>;
471
+ queue: RuntimeQueued[];
472
+ scheduled: RuntimeScheduled[];
473
+ trace: RuntimeTrace[];
474
+ effects: RuntimeBrowserEffect[];
475
+ diagnostic: string | null;
476
+ suspended: boolean;
477
+ }
478
+ /** Creates fresh state from the verified linked model; no DOM or wall clock is consulted. */
479
+ declare function createRuntime(linked: LinkedApp, options?: {
480
+ fragment?: string;
481
+ }): RuntimeSnapshot;
482
+ /** Applies one closed conformance input. The supplied snapshot is never mutated. */
483
+ declare function reduceEvent(snapshot: RuntimeSnapshot, input: RuntimeInput): RuntimeSnapshot;
484
+ declare function advanceClock(snapshot: RuntimeSnapshot, deltaMs: number): RuntimeSnapshot;
485
+ declare function resetRuntime(snapshot: RuntimeSnapshot): RuntimeSnapshot;
486
+ declare function renderSite(bundle: AppBundle): AppResult<AppArtifact>;
487
+
488
+ export { type AppArtifact, type AppBundle, type AppCompileResult, type AppComponentInput, type AppComponentInstanceId, type AppDefinitionKind, type AppDocument, type AppLayoutInput, type AppLinkDiagnostic, type AppLinkDiagnosticCode, type AppLinkResult, type AppManifest, type AppManifestModule, type AppModuleInput, type AppNodeId, type AppNodeKind, type AppReferenceInput, type AppResult, type AppScreenInput, type AppSourceMapEntry, type AppSourceSpan, type CompileAppOptions, type CreateAppBundleOptions, type Diagnostic, type InstanceStep, type LinkedApp, type LinkedIdentity, type ResolvedAppComponent, type ResolvedAppLayout, type ResolvedAppModule, type ResolvedAppReference, type ResolvedAppScreen, type RuntimeBrowserEffect, type RuntimeInput, type RuntimeSnapshot, type RuntimeTrace, type ScreenReference, type SourceMapEntry, advanceClock, compileApp, createAppBundle, createAppComponentInstanceId, createAppNodeId, createRuntime, linkAndCompileApp, linkApp, reduceEvent, renderSite, resetRuntime };
package/dist/app.js ADDED
@@ -0,0 +1,31 @@
1
+ import {
2
+ advanceClock,
3
+ compileApp,
4
+ createAppBundle,
5
+ createAppComponentInstanceId,
6
+ createAppNodeId,
7
+ createRuntime,
8
+ linkAndCompileApp,
9
+ linkApp,
10
+ reduceEvent,
11
+ renderSite,
12
+ resetRuntime
13
+ } from "./chunk-QOS4IC75.js";
14
+ import "./chunk-3RWGG5EC.js";
15
+ import "./chunk-JJWAFHSV.js";
16
+ import "./chunk-XYACLXXF.js";
17
+ import "./chunk-V3HVWC7C.js";
18
+ import "./chunk-PKBMQBKP.js";
19
+ export {
20
+ advanceClock,
21
+ compileApp,
22
+ createAppBundle,
23
+ createAppComponentInstanceId,
24
+ createAppNodeId,
25
+ createRuntime,
26
+ linkAndCompileApp,
27
+ linkApp,
28
+ reduceEvent,
29
+ renderSite,
30
+ resetRuntime
31
+ };