ngx-json-render 0.2.0 → 0.3.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/README.md +363 -14
- package/fesm2022/ngx-json-render-testing.mjs +389 -0
- package/fesm2022/ngx-json-render-testing.mjs.map +1 -0
- package/fesm2022/ngx-json-render.mjs +882 -403
- package/fesm2022/ngx-json-render.mjs.map +1 -1
- package/package.json +5 -1
- package/types/ngx-json-render-testing.d.ts +197 -0
- package/types/ngx-json-render.d.ts +329 -60
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { signal, ChangeDetectionStrategy, Component, provideZonelessChangeDetection } from '@angular/core';
|
|
3
|
+
import { TestBed } from '@angular/core/testing';
|
|
4
|
+
import { JsonRenderer, JsonRenderValidationService } from 'ngx-json-render';
|
|
5
|
+
|
|
6
|
+
/** The rejection `fetch` raises when its signal fires. */
|
|
7
|
+
function abortError() {
|
|
8
|
+
const error = new Error('The operation was aborted.');
|
|
9
|
+
error.name = 'AbortError';
|
|
10
|
+
return error;
|
|
11
|
+
}
|
|
12
|
+
/** A JSON error body, shaped the way the streaming hooks read it. */
|
|
13
|
+
function errorResponse(status, message) {
|
|
14
|
+
return new Response(JSON.stringify({ message }), {
|
|
15
|
+
status,
|
|
16
|
+
headers: { 'Content-Type': 'application/json' },
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function parseBody(body) {
|
|
20
|
+
try {
|
|
21
|
+
const parsed = JSON.parse(String(body ?? '{}'));
|
|
22
|
+
return parsed && typeof parsed === 'object'
|
|
23
|
+
? parsed
|
|
24
|
+
: {};
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The prompt of a request, from either hook's body shape. Both are the
|
|
32
|
+
* package's own, so the default knows them and a test does not have to.
|
|
33
|
+
*/
|
|
34
|
+
function defaultPromptOf(body) {
|
|
35
|
+
const prompt = body['prompt'];
|
|
36
|
+
if (typeof prompt === 'string')
|
|
37
|
+
return prompt;
|
|
38
|
+
const messages = body['messages'];
|
|
39
|
+
if (!Array.isArray(messages) || messages.length === 0)
|
|
40
|
+
return '';
|
|
41
|
+
const last = messages[messages.length - 1];
|
|
42
|
+
const content = last?.content;
|
|
43
|
+
return typeof content === 'string' ? content : '';
|
|
44
|
+
}
|
|
45
|
+
function toFinder(recordings) {
|
|
46
|
+
if (typeof recordings === 'function')
|
|
47
|
+
return recordings;
|
|
48
|
+
if (Array.isArray(recordings))
|
|
49
|
+
return () => recordings;
|
|
50
|
+
const byPrompt = recordings;
|
|
51
|
+
return (prompt) => byPrompt[prompt];
|
|
52
|
+
}
|
|
53
|
+
function replay(lines, delayMs, signal) {
|
|
54
|
+
const encoder = new TextEncoder();
|
|
55
|
+
return new ReadableStream({
|
|
56
|
+
start(controller) {
|
|
57
|
+
let index = 0;
|
|
58
|
+
let timer = null;
|
|
59
|
+
// A superseded or stopped generation has to die mid-flight the way a
|
|
60
|
+
// real request does, or a test of that behaviour proves nothing.
|
|
61
|
+
const onAbort = () => {
|
|
62
|
+
if (timer)
|
|
63
|
+
clearTimeout(timer);
|
|
64
|
+
controller.error(abortError());
|
|
65
|
+
};
|
|
66
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
67
|
+
const push = () => {
|
|
68
|
+
if (index >= lines.length) {
|
|
69
|
+
signal?.removeEventListener('abort', onAbort);
|
|
70
|
+
controller.close();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
controller.enqueue(encoder.encode(`${lines[index++]}\n`));
|
|
74
|
+
timer = setTimeout(push, delayMs);
|
|
75
|
+
};
|
|
76
|
+
timer = setTimeout(push, delayMs);
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* A `fetch` that answers the streaming hooks from a recording instead of a
|
|
82
|
+
* server.
|
|
83
|
+
*
|
|
84
|
+
* Both {@link injectUIStream} and {@link injectChatUI} take any function with
|
|
85
|
+
* fetch's shape, so a test runs the real client — request body, streamed
|
|
86
|
+
* lines, usage metadata, abort on supersede — with no server, no API key and
|
|
87
|
+
* no global patched behind the test's back. Only the transport is recorded.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* const ui = injectUIStream({
|
|
92
|
+
* api: '/api/generate',
|
|
93
|
+
* fetch: recordedTransport(specStream(spec)),
|
|
94
|
+
* });
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @example Different answers per prompt, at a visible pace:
|
|
98
|
+
* ```ts
|
|
99
|
+
* recordedTransport(
|
|
100
|
+
* { 'a dashboard': specStream(dashboard), 'a form': specStream(form) },
|
|
101
|
+
* { delayMs: 20 },
|
|
102
|
+
* );
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
function recordedTransport(recordings, options = {}) {
|
|
106
|
+
const { delayMs = 0, promptOf = defaultPromptOf } = options;
|
|
107
|
+
const find = toFinder(recordings);
|
|
108
|
+
return async (_input, init) => {
|
|
109
|
+
const failure = typeof options.fail === 'function' ? options.fail() : options.fail;
|
|
110
|
+
if (failure) {
|
|
111
|
+
return errorResponse(failure.status ?? 500, failure.message ?? 'The recorded server failed this request.');
|
|
112
|
+
}
|
|
113
|
+
const body = parseBody(init?.body);
|
|
114
|
+
const prompt = promptOf(body);
|
|
115
|
+
const lines = find(prompt, body);
|
|
116
|
+
if (!lines) {
|
|
117
|
+
return errorResponse(404, `No recording for ${JSON.stringify(prompt)}.`);
|
|
118
|
+
}
|
|
119
|
+
const signal = init?.signal ?? null;
|
|
120
|
+
if (signal?.aborted)
|
|
121
|
+
throw abortError();
|
|
122
|
+
return new Response(replay(lines, delayMs, signal), { status: 200 });
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/** Escape a JSON Pointer segment (RFC 6901). */
|
|
126
|
+
function pointer(segment) {
|
|
127
|
+
return segment.replace(/~/g, '~0').replace(/\//g, '~1');
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The JSONL patch lines a model would emit to build `spec`: the root, then
|
|
131
|
+
* the state, then one line per element in declaration order.
|
|
132
|
+
*
|
|
133
|
+
* Recording a stream by hand means writing patches by hand; this writes them
|
|
134
|
+
* from the spec a test already has, so the test says what it renders rather
|
|
135
|
+
* than how the wire spells it.
|
|
136
|
+
*/
|
|
137
|
+
function specStream(spec) {
|
|
138
|
+
const lines = [
|
|
139
|
+
JSON.stringify({ op: 'add', path: '/root', value: spec.root }),
|
|
140
|
+
];
|
|
141
|
+
if (spec.state) {
|
|
142
|
+
lines.push(JSON.stringify({ op: 'add', path: '/state', value: spec.state }));
|
|
143
|
+
}
|
|
144
|
+
for (const [key, element] of Object.entries(spec.elements ?? {})) {
|
|
145
|
+
lines.push(JSON.stringify({
|
|
146
|
+
op: 'add',
|
|
147
|
+
path: `/elements/${pointer(key)}`,
|
|
148
|
+
value: element,
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
151
|
+
return lines;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The usage metadata line `injectUIStream` reads into its `usage` signal.
|
|
155
|
+
* Append it to a recording to exercise that path.
|
|
156
|
+
*/
|
|
157
|
+
function usageLine(usage) {
|
|
158
|
+
return JSON.stringify({
|
|
159
|
+
__meta: 'usage',
|
|
160
|
+
promptTokens: usage.promptTokens ?? 0,
|
|
161
|
+
completionTokens: usage.completionTokens ?? 0,
|
|
162
|
+
totalTokens: usage.totalTokens ?? 0,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
class JrTestHost {
|
|
167
|
+
spec = signal(null, ...(ngDevMode ? [{ debugName: "spec" }] : /* istanbul ignore next */ []));
|
|
168
|
+
registry = signal({}, ...(ngDevMode ? [{ debugName: "registry" }] : /* istanbul ignore next */ []));
|
|
169
|
+
loading = signal(false, ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
|
|
170
|
+
state = signal(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
|
|
171
|
+
store = signal(null, ...(ngDevMode ? [{ debugName: "store" }] : /* istanbul ignore next */ []));
|
|
172
|
+
handlers = signal(undefined, ...(ngDevMode ? [{ debugName: "handlers" }] : /* istanbul ignore next */ []));
|
|
173
|
+
onAction = signal(null, ...(ngDevMode ? [{ debugName: "onAction" }] : /* istanbul ignore next */ []));
|
|
174
|
+
navigate = signal(null, ...(ngDevMode ? [{ debugName: "navigate" }] : /* istanbul ignore next */ []));
|
|
175
|
+
fallback = signal(null, ...(ngDevMode ? [{ debugName: "fallback" }] : /* istanbul ignore next */ []));
|
|
176
|
+
functions = signal(undefined, ...(ngDevMode ? [{ debugName: "functions" }] : /* istanbul ignore next */ []));
|
|
177
|
+
validationFunctions = signal(undefined, ...(ngDevMode ? [{ debugName: "validationFunctions" }] : /* istanbul ignore next */ []));
|
|
178
|
+
directives = signal(undefined, ...(ngDevMode ? [{ debugName: "directives" }] : /* istanbul ignore next */ []));
|
|
179
|
+
record = () => { };
|
|
180
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: JrTestHost, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
181
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.22", type: JrTestHost, isStandalone: true, selector: "jr-test-host", ngImport: i0, template: `
|
|
182
|
+
<json-render
|
|
183
|
+
[spec]="spec()"
|
|
184
|
+
[registry]="registry()"
|
|
185
|
+
[loading]="loading()"
|
|
186
|
+
[state]="state()"
|
|
187
|
+
[store]="store()"
|
|
188
|
+
[handlers]="handlers()"
|
|
189
|
+
[onAction]="onAction()"
|
|
190
|
+
[navigate]="navigate()"
|
|
191
|
+
[fallback]="fallback()"
|
|
192
|
+
[functions]="functions()"
|
|
193
|
+
[validationFunctions]="validationFunctions()"
|
|
194
|
+
[directives]="directives()"
|
|
195
|
+
(stateChange)="record($event)"
|
|
196
|
+
/>
|
|
197
|
+
`, isInline: true, dependencies: [{ kind: "component", type: JsonRenderer, selector: "json-render", inputs: ["spec", "registry", "loading", "fallback", "validate", "state", "store", "handlers", "onAction", "navigate", "validationFunctions", "functions", "directives"], outputs: ["stateChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
198
|
+
}
|
|
199
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: JrTestHost, decorators: [{
|
|
200
|
+
type: Component,
|
|
201
|
+
args: [{
|
|
202
|
+
selector: 'jr-test-host',
|
|
203
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
204
|
+
imports: [JsonRenderer],
|
|
205
|
+
template: `
|
|
206
|
+
<json-render
|
|
207
|
+
[spec]="spec()"
|
|
208
|
+
[registry]="registry()"
|
|
209
|
+
[loading]="loading()"
|
|
210
|
+
[state]="state()"
|
|
211
|
+
[store]="store()"
|
|
212
|
+
[handlers]="handlers()"
|
|
213
|
+
[onAction]="onAction()"
|
|
214
|
+
[navigate]="navigate()"
|
|
215
|
+
[fallback]="fallback()"
|
|
216
|
+
[functions]="functions()"
|
|
217
|
+
[validationFunctions]="validationFunctions()"
|
|
218
|
+
[directives]="directives()"
|
|
219
|
+
(stateChange)="record($event)"
|
|
220
|
+
/>
|
|
221
|
+
`,
|
|
222
|
+
}]
|
|
223
|
+
}] });
|
|
224
|
+
/**
|
|
225
|
+
* Wrap every handler so a dispatch is recorded whether or not the action is
|
|
226
|
+
* handled. Without this, `dispatched` would silently omit exactly the actions
|
|
227
|
+
* a test bothered to wire up.
|
|
228
|
+
*/
|
|
229
|
+
function recordingHandlers(handlers, dispatched) {
|
|
230
|
+
if (!handlers)
|
|
231
|
+
return undefined;
|
|
232
|
+
const wrapped = {};
|
|
233
|
+
for (const [name, handler] of Object.entries(handlers)) {
|
|
234
|
+
wrapped[name] = (params) => {
|
|
235
|
+
dispatched.push({ name, params });
|
|
236
|
+
return handler(params);
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
return wrapped;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Configure the TestBed, unless the test already did.
|
|
243
|
+
*
|
|
244
|
+
* A test that called `TestBed.runInInjectionContext` first — or that renders
|
|
245
|
+
* a second spec — has an instantiated module, and configuring it again
|
|
246
|
+
* throws. Its own module stands; the only thing that cannot be salvaged is
|
|
247
|
+
* this call's `providers`, so that is the one case worth failing over.
|
|
248
|
+
*/
|
|
249
|
+
function configureTestBed(providers) {
|
|
250
|
+
try {
|
|
251
|
+
TestBed.configureTestingModule({
|
|
252
|
+
providers: [provideZonelessChangeDetection(), ...providers],
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
catch {
|
|
256
|
+
if (providers.length > 0) {
|
|
257
|
+
throw new Error('renderSpec: the TestBed was already instantiated, so `providers` cannot be applied. Pass them to your own TestBed.configureTestingModule() call instead.');
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Render a spec against a registry and hand back the few things a test does
|
|
263
|
+
* to it.
|
|
264
|
+
*
|
|
265
|
+
* Testing a catalog component otherwise means a host component, a TestBed
|
|
266
|
+
* module, a zoneless provider, two settle passes and a `querySelector` — the
|
|
267
|
+
* same twenty lines in every project that adopts this package, none of them
|
|
268
|
+
* about the component under test.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```ts
|
|
272
|
+
* const ui = await renderSpec(
|
|
273
|
+
* {
|
|
274
|
+
* root: 'save',
|
|
275
|
+
* elements: {
|
|
276
|
+
* save: { type: 'Button', props: { label: 'Save' }, on: { press: { action: 'save' } } },
|
|
277
|
+
* },
|
|
278
|
+
* },
|
|
279
|
+
* { registry: { Button: MyButton } },
|
|
280
|
+
* );
|
|
281
|
+
*
|
|
282
|
+
* expect(ui.text('button')).toBe('Save');
|
|
283
|
+
* await ui.click('button');
|
|
284
|
+
* expect(ui.dispatched).toEqual([{ name: 'save', params: {} }]);
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
async function renderSpec(spec, options) {
|
|
288
|
+
const dispatched = [];
|
|
289
|
+
const changes = [];
|
|
290
|
+
configureTestBed(options.providers ?? []);
|
|
291
|
+
const fixture = TestBed.createComponent(JrTestHost);
|
|
292
|
+
const host = fixture.componentInstance;
|
|
293
|
+
host.registry.set(options.registry);
|
|
294
|
+
host.loading.set(options.loading ?? false);
|
|
295
|
+
host.state.set(options.state);
|
|
296
|
+
host.store.set(options.store ?? null);
|
|
297
|
+
host.handlers.set(recordingHandlers(options.handlers, dispatched));
|
|
298
|
+
host.onAction.set((name, params) => {
|
|
299
|
+
dispatched.push({ name, params });
|
|
300
|
+
return options.onAction?.(name, params);
|
|
301
|
+
});
|
|
302
|
+
host.navigate.set(options.navigate ?? null);
|
|
303
|
+
host.fallback.set(options.fallback ?? null);
|
|
304
|
+
host.functions.set(options.functions);
|
|
305
|
+
host.validationFunctions.set(options.validationFunctions);
|
|
306
|
+
host.directives.set(options.directives);
|
|
307
|
+
host.record = (batch) => changes.push(...batch);
|
|
308
|
+
host.spec.set(spec);
|
|
309
|
+
const settle = async () => {
|
|
310
|
+
// Twice: the first pass runs the effects that a render schedules, the
|
|
311
|
+
// second renders what those effects changed. One pass leaves a test
|
|
312
|
+
// asserting against a frame that no browser would ever show.
|
|
313
|
+
await fixture.whenStable();
|
|
314
|
+
fixture.detectChanges();
|
|
315
|
+
await fixture.whenStable();
|
|
316
|
+
};
|
|
317
|
+
await settle();
|
|
318
|
+
const element = fixture.nativeElement;
|
|
319
|
+
// Found by predicate rather than with `By.directive`, which would make
|
|
320
|
+
// @angular/platform-browser a dependency of this entry point for one line.
|
|
321
|
+
const rendererElement = fixture.debugElement.query((candidate) => candidate.componentInstance instanceof JsonRenderer);
|
|
322
|
+
const renderer = rendererElement.componentInstance;
|
|
323
|
+
const store = renderer.stateStore;
|
|
324
|
+
// From the renderer's own injector: these services are provided by the
|
|
325
|
+
// component, so the root TestBed injector has never heard of them.
|
|
326
|
+
const validation = rendererElement.injector.get(JsonRenderValidationService);
|
|
327
|
+
const resolve = (target) => {
|
|
328
|
+
if (typeof target !== 'string')
|
|
329
|
+
return target;
|
|
330
|
+
const found = element.querySelector(target);
|
|
331
|
+
if (!found) {
|
|
332
|
+
throw new Error(`renderSpec: nothing matches ${JSON.stringify(target)}. Rendered HTML:\n${element.innerHTML}`);
|
|
333
|
+
}
|
|
334
|
+
return found;
|
|
335
|
+
};
|
|
336
|
+
return {
|
|
337
|
+
fixture,
|
|
338
|
+
element,
|
|
339
|
+
renderer,
|
|
340
|
+
store,
|
|
341
|
+
validation,
|
|
342
|
+
dispatched,
|
|
343
|
+
changes,
|
|
344
|
+
async setSpec(next) {
|
|
345
|
+
host.spec.set(next);
|
|
346
|
+
await settle();
|
|
347
|
+
},
|
|
348
|
+
async setLoading(loading) {
|
|
349
|
+
host.loading.set(loading);
|
|
350
|
+
await settle();
|
|
351
|
+
},
|
|
352
|
+
settle,
|
|
353
|
+
read: (path) => store.get(path),
|
|
354
|
+
async write(path, value) {
|
|
355
|
+
store.set(path, value);
|
|
356
|
+
await settle();
|
|
357
|
+
},
|
|
358
|
+
state: () => store.state(),
|
|
359
|
+
text: (selector) => ((selector ? resolve(selector) : element).textContent ?? '').trim(),
|
|
360
|
+
texts: (selector) => Array.from(element.querySelectorAll(selector)).map((el) => (el.textContent ?? '').trim()),
|
|
361
|
+
find: (selector) => resolve(selector),
|
|
362
|
+
findAll: (selector) => Array.from(element.querySelectorAll(selector)),
|
|
363
|
+
async click(target) {
|
|
364
|
+
resolve(target).click();
|
|
365
|
+
await settle();
|
|
366
|
+
},
|
|
367
|
+
async fill(target, value) {
|
|
368
|
+
const input = resolve(target);
|
|
369
|
+
input.value = value;
|
|
370
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
371
|
+
await settle();
|
|
372
|
+
},
|
|
373
|
+
destroy: () => fixture.destroy(),
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/*
|
|
378
|
+
* Public API Surface of ngx-json-render/testing
|
|
379
|
+
*
|
|
380
|
+
* Test utilities, shipped as a separate entry point so nothing here can be
|
|
381
|
+
* pulled into an application bundle by accident.
|
|
382
|
+
*/
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Generated bundle index. Do not edit.
|
|
386
|
+
*/
|
|
387
|
+
|
|
388
|
+
export { recordedTransport, renderSpec, specStream, usageLine };
|
|
389
|
+
//# sourceMappingURL=ngx-json-render-testing.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngx-json-render-testing.mjs","sources":["../../../projects/ngx-json-render/testing/src/recorded-transport.ts","../../../projects/ngx-json-render/testing/src/render-spec.ts","../../../projects/ngx-json-render/testing/src/public-api.ts","../../../projects/ngx-json-render/testing/src/ngx-json-render-testing.ts"],"sourcesContent":["import type { Spec } from '@json-render/core';\n\n/**\n * The lines of one recorded response body, in the order the server sent them,\n * without their trailing newlines.\n */\nexport type Recording = readonly string[];\n\n/**\n * What to replay for a request. Either one recording for every request, a\n * lookup by prompt, or a function for anything more involved.\n */\nexport type Recordings =\n | Recording\n | Readonly<Record<string, Recording>>\n | ((\n prompt: string,\n body: Readonly<Record<string, unknown>>,\n ) => Recording | undefined);\n\n/** An error the recorded server answers with instead of a stream. */\nexport interface RecordedFailure {\n /** HTTP status. Defaults to 500. */\n status?: number;\n /** The `message` field of the JSON error body. */\n message?: string;\n}\n\n/** Options for {@link recordedTransport}. */\nexport interface RecordedTransportOptions {\n /**\n * Milliseconds between lines — the pace a model would emit them at.\n * Defaults to 0, which still yields to the event loop between lines, so a\n * test can observe the stream in flight.\n */\n delayMs?: number;\n /**\n * Answer with an error instead of a stream. A function is called per\n * request, so a test can turn the failure on and off between sends.\n */\n fail?: RecordedFailure | (() => RecordedFailure | null | undefined);\n /**\n * Pull the prompt out of the request body. The default reads `prompt`\n * (what `injectUIStream` sends) and falls back to the last message's\n * content (what `injectChatUI` sends).\n */\n promptOf?: (body: Readonly<Record<string, unknown>>) => string;\n}\n\n/** The rejection `fetch` raises when its signal fires. */\nfunction abortError(): Error {\n const error = new Error('The operation was aborted.');\n error.name = 'AbortError';\n return error;\n}\n\n/** A JSON error body, shaped the way the streaming hooks read it. */\nfunction errorResponse(status: number, message: string): Response {\n return new Response(JSON.stringify({ message }), {\n status,\n headers: { 'Content-Type': 'application/json' },\n });\n}\n\nfunction parseBody(body: BodyInit | null | undefined): Record<string, unknown> {\n try {\n const parsed: unknown = JSON.parse(String(body ?? '{}'));\n return parsed && typeof parsed === 'object'\n ? (parsed as Record<string, unknown>)\n : {};\n } catch {\n return {};\n }\n}\n\n/**\n * The prompt of a request, from either hook's body shape. Both are the\n * package's own, so the default knows them and a test does not have to.\n */\nfunction defaultPromptOf(body: Readonly<Record<string, unknown>>): string {\n const prompt = body['prompt'];\n if (typeof prompt === 'string') return prompt;\n\n const messages = body['messages'];\n if (!Array.isArray(messages) || messages.length === 0) return '';\n const last: unknown = messages[messages.length - 1];\n const content = (last as { content?: unknown } | null)?.content;\n return typeof content === 'string' ? content : '';\n}\n\nfunction toFinder(\n recordings: Recordings,\n): (prompt: string, body: Record<string, unknown>) => Recording | undefined {\n if (typeof recordings === 'function') return recordings;\n if (Array.isArray(recordings)) return () => recordings as Recording;\n const byPrompt = recordings as Readonly<Record<string, Recording>>;\n return (prompt) => byPrompt[prompt];\n}\n\nfunction replay(\n lines: Recording,\n delayMs: number,\n signal: AbortSignal | null,\n): ReadableStream<Uint8Array> {\n const encoder = new TextEncoder();\n return new ReadableStream<Uint8Array>({\n start(controller) {\n let index = 0;\n let timer: ReturnType<typeof setTimeout> | null = null;\n\n // A superseded or stopped generation has to die mid-flight the way a\n // real request does, or a test of that behaviour proves nothing.\n const onAbort = () => {\n if (timer) clearTimeout(timer);\n controller.error(abortError());\n };\n signal?.addEventListener('abort', onAbort, { once: true });\n\n const push = () => {\n if (index >= lines.length) {\n signal?.removeEventListener('abort', onAbort);\n controller.close();\n return;\n }\n controller.enqueue(encoder.encode(`${lines[index++]}\\n`));\n timer = setTimeout(push, delayMs);\n };\n timer = setTimeout(push, delayMs);\n },\n });\n}\n\n/**\n * A `fetch` that answers the streaming hooks from a recording instead of a\n * server.\n *\n * Both {@link injectUIStream} and {@link injectChatUI} take any function with\n * fetch's shape, so a test runs the real client — request body, streamed\n * lines, usage metadata, abort on supersede — with no server, no API key and\n * no global patched behind the test's back. Only the transport is recorded.\n *\n * @example\n * ```ts\n * const ui = injectUIStream({\n * api: '/api/generate',\n * fetch: recordedTransport(specStream(spec)),\n * });\n * ```\n *\n * @example Different answers per prompt, at a visible pace:\n * ```ts\n * recordedTransport(\n * { 'a dashboard': specStream(dashboard), 'a form': specStream(form) },\n * { delayMs: 20 },\n * );\n * ```\n */\nexport function recordedTransport(\n recordings: Recordings,\n options: RecordedTransportOptions = {},\n): typeof globalThis.fetch {\n const { delayMs = 0, promptOf = defaultPromptOf } = options;\n const find = toFinder(recordings);\n\n return async (_input, init) => {\n const failure =\n typeof options.fail === 'function' ? options.fail() : options.fail;\n if (failure) {\n return errorResponse(\n failure.status ?? 500,\n failure.message ?? 'The recorded server failed this request.',\n );\n }\n\n const body = parseBody(init?.body);\n const prompt = promptOf(body);\n const lines = find(prompt, body);\n if (!lines) {\n return errorResponse(404, `No recording for ${JSON.stringify(prompt)}.`);\n }\n\n const signal = init?.signal ?? null;\n if (signal?.aborted) throw abortError();\n\n return new Response(replay(lines, delayMs, signal), { status: 200 });\n };\n}\n\n/** Escape a JSON Pointer segment (RFC 6901). */\nfunction pointer(segment: string): string {\n return segment.replace(/~/g, '~0').replace(/\\//g, '~1');\n}\n\n/**\n * The JSONL patch lines a model would emit to build `spec`: the root, then\n * the state, then one line per element in declaration order.\n *\n * Recording a stream by hand means writing patches by hand; this writes them\n * from the spec a test already has, so the test says what it renders rather\n * than how the wire spells it.\n */\nexport function specStream(spec: Spec): string[] {\n const lines = [\n JSON.stringify({ op: 'add', path: '/root', value: spec.root }),\n ];\n if (spec.state) {\n lines.push(\n JSON.stringify({ op: 'add', path: '/state', value: spec.state }),\n );\n }\n for (const [key, element] of Object.entries(spec.elements ?? {})) {\n lines.push(\n JSON.stringify({\n op: 'add',\n path: `/elements/${pointer(key)}`,\n value: element,\n }),\n );\n }\n return lines;\n}\n\n/**\n * The usage metadata line `injectUIStream` reads into its `usage` signal.\n * Append it to a recording to exercise that path.\n */\nexport function usageLine(usage: {\n promptTokens?: number;\n completionTokens?: number;\n totalTokens?: number;\n}): string {\n return JSON.stringify({\n __meta: 'usage',\n promptTokens: usage.promptTokens ?? 0,\n completionTokens: usage.completionTokens ?? 0,\n totalTokens: usage.totalTokens ?? 0,\n });\n}\n","import {\n ChangeDetectionStrategy,\n Component,\n type Provider,\n type Type,\n provideZonelessChangeDetection,\n signal,\n} from '@angular/core';\nimport { type ComponentFixture, TestBed } from '@angular/core/testing';\nimport type {\n ActionHandler,\n ComputedFunction,\n DirectiveDefinition,\n Spec,\n StateStore,\n ValidationFunction,\n} from '@json-render/core';\nimport {\n type ComponentRegistry,\n JsonRenderStateService,\n JsonRenderValidationService,\n JsonRenderer,\n type RegistryEntry,\n type StateChange,\n type StateModel,\n} from 'ngx-json-render';\n\n/** One action the spec asked for, in the order it was dispatched. */\nexport interface DispatchedAction {\n name: string;\n params?: Record<string, unknown>;\n}\n\n/** Options for {@link renderSpec}. Everything but `registry` is optional. */\nexport interface RenderSpecOptions {\n /** Catalog type name → Angular component. The one required option. */\n registry: ComponentRegistry;\n /** Initial state model. Defaults to the spec's own `state`. */\n state?: StateModel;\n /** External store, for controlled mode. */\n store?: StateStore | null;\n /** Action handlers by name. Dispatches are recorded either way. */\n handlers?: Record<string, ActionHandler>;\n /** Catch-all handler for actions with no dedicated handler. */\n onAction?: (name: string, params?: Record<string, unknown>) => unknown;\n /** Navigation function for `onSuccess: { navigate }`. */\n navigate?: (path: string) => void;\n /** Fallback component for unknown types. */\n fallback?: Type<unknown> | RegistryEntry | null;\n /** Named functions for `$computed` props. */\n functions?: Record<string, ComputedFunction>;\n /** Custom validation functions. */\n validationFunctions?: Record<string, ValidationFunction>;\n /** Custom directives for `$`-prefixed values. */\n directives?: DirectiveDefinition[];\n /** Render as if the spec were still streaming. */\n loading?: boolean;\n /** Extra TestBed providers, e.g. a `JR_CONFIRM_DIALOG` replacement. */\n providers?: Provider[];\n}\n\n/**\n * A rendered spec, and the handful of things a test does to one.\n *\n * `fixture` and `element` are there for everything this does not cover — the\n * harness is a shortcut, not a wall.\n */\nexport interface SpecHarness {\n /** The fixture of the host that owns the `<json-render>`. */\n readonly fixture: ComponentFixture<unknown>;\n /** The host element, the root of the rendered DOM. */\n readonly element: HTMLElement;\n /** The renderer instance. */\n readonly renderer: JsonRenderer;\n /** The renderer's state store. */\n readonly store: JsonRenderStateService;\n /** The renderer's validation service. */\n readonly validation: JsonRenderValidationService;\n /** Every action the spec dispatched, handled or not, in order. */\n readonly dispatched: readonly DispatchedAction[];\n /** Every state change the renderer emitted, flattened, in order. */\n readonly changes: readonly StateChange[];\n\n /** Render a different spec (a later streaming frame, say). */\n setSpec(spec: Spec | null): Promise<void>;\n /** Flip the loading flag catalog components see. */\n setLoading(loading: boolean): Promise<void>;\n /** Let effects, promises and change detection finish. */\n settle(): Promise<void>;\n\n /** Read a state path, e.g. `/form/email`. */\n read(path: string): unknown;\n /** Write a state path and settle. */\n write(path: string, value: unknown): Promise<void>;\n /** The whole state model. */\n state(): StateModel;\n\n /** Trimmed text of the first match, or of everything when given nothing. */\n text(selector?: string): string;\n /** Trimmed text of every match. */\n texts(selector: string): string[];\n /** The first match. Throws when there is none. */\n find<T extends HTMLElement>(selector: string): T;\n /** Every match, possibly none. */\n findAll<T extends HTMLElement>(selector: string): T[];\n /** Click an element (or the first match of a selector) and settle. */\n click(target: string | Element): Promise<void>;\n /** Set an input's value, fire `input`, and settle. */\n fill(target: string | Element, value: string): Promise<void>;\n\n /** Destroy the fixture. Rarely needed — TestBed resets between tests. */\n destroy(): void;\n}\n\n@Component({\n selector: 'jr-test-host',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [JsonRenderer],\n template: `\n <json-render\n [spec]=\"spec()\"\n [registry]=\"registry()\"\n [loading]=\"loading()\"\n [state]=\"state()\"\n [store]=\"store()\"\n [handlers]=\"handlers()\"\n [onAction]=\"onAction()\"\n [navigate]=\"navigate()\"\n [fallback]=\"fallback()\"\n [functions]=\"functions()\"\n [validationFunctions]=\"validationFunctions()\"\n [directives]=\"directives()\"\n (stateChange)=\"record($event)\"\n />\n `,\n})\nclass JrTestHost {\n readonly spec = signal<Spec | null>(null);\n readonly registry = signal<ComponentRegistry>({});\n readonly loading = signal(false);\n readonly state = signal<StateModel | undefined>(undefined);\n readonly store = signal<StateStore | null>(null);\n readonly handlers = signal<Record<string, ActionHandler> | undefined>(\n undefined,\n );\n readonly onAction = signal<\n ((name: string, params?: Record<string, unknown>) => unknown) | null\n >(null);\n readonly navigate = signal<((path: string) => void) | null>(null);\n readonly fallback = signal<Type<unknown> | RegistryEntry | null>(null);\n readonly functions = signal<Record<string, ComputedFunction> | undefined>(\n undefined,\n );\n readonly validationFunctions = signal<\n Record<string, ValidationFunction> | undefined\n >(undefined);\n readonly directives = signal<DirectiveDefinition[] | undefined>(undefined);\n\n record: (changes: StateChange[]) => void = () => {};\n}\n\n/**\n * Wrap every handler so a dispatch is recorded whether or not the action is\n * handled. Without this, `dispatched` would silently omit exactly the actions\n * a test bothered to wire up.\n */\nfunction recordingHandlers(\n handlers: Record<string, ActionHandler> | undefined,\n dispatched: DispatchedAction[],\n): Record<string, ActionHandler> | undefined {\n if (!handlers) return undefined;\n const wrapped: Record<string, ActionHandler> = {};\n for (const [name, handler] of Object.entries(handlers)) {\n wrapped[name] = (params: Record<string, unknown>) => {\n dispatched.push({ name, params });\n return handler(params);\n };\n }\n return wrapped;\n}\n\n/**\n * Configure the TestBed, unless the test already did.\n *\n * A test that called `TestBed.runInInjectionContext` first — or that renders\n * a second spec — has an instantiated module, and configuring it again\n * throws. Its own module stands; the only thing that cannot be salvaged is\n * this call's `providers`, so that is the one case worth failing over.\n */\nfunction configureTestBed(providers: Provider[]): void {\n try {\n TestBed.configureTestingModule({\n providers: [provideZonelessChangeDetection(), ...providers],\n });\n } catch {\n if (providers.length > 0) {\n throw new Error(\n 'renderSpec: the TestBed was already instantiated, so `providers` cannot be applied. Pass them to your own TestBed.configureTestingModule() call instead.',\n );\n }\n }\n}\n\n/**\n * Render a spec against a registry and hand back the few things a test does\n * to it.\n *\n * Testing a catalog component otherwise means a host component, a TestBed\n * module, a zoneless provider, two settle passes and a `querySelector` — the\n * same twenty lines in every project that adopts this package, none of them\n * about the component under test.\n *\n * @example\n * ```ts\n * const ui = await renderSpec(\n * {\n * root: 'save',\n * elements: {\n * save: { type: 'Button', props: { label: 'Save' }, on: { press: { action: 'save' } } },\n * },\n * },\n * { registry: { Button: MyButton } },\n * );\n *\n * expect(ui.text('button')).toBe('Save');\n * await ui.click('button');\n * expect(ui.dispatched).toEqual([{ name: 'save', params: {} }]);\n * ```\n */\nexport async function renderSpec(\n spec: Spec | null,\n options: RenderSpecOptions,\n): Promise<SpecHarness> {\n const dispatched: DispatchedAction[] = [];\n const changes: StateChange[] = [];\n\n configureTestBed(options.providers ?? []);\n\n const fixture = TestBed.createComponent(JrTestHost);\n const host = fixture.componentInstance;\n\n host.registry.set(options.registry);\n host.loading.set(options.loading ?? false);\n host.state.set(options.state);\n host.store.set(options.store ?? null);\n host.handlers.set(recordingHandlers(options.handlers, dispatched));\n host.onAction.set((name, params) => {\n dispatched.push({ name, params });\n return options.onAction?.(name, params);\n });\n host.navigate.set(options.navigate ?? null);\n host.fallback.set(options.fallback ?? null);\n host.functions.set(options.functions);\n host.validationFunctions.set(options.validationFunctions);\n host.directives.set(options.directives);\n host.record = (batch) => changes.push(...batch);\n host.spec.set(spec);\n\n const settle = async () => {\n // Twice: the first pass runs the effects that a render schedules, the\n // second renders what those effects changed. One pass leaves a test\n // asserting against a frame that no browser would ever show.\n await fixture.whenStable();\n fixture.detectChanges();\n await fixture.whenStable();\n };\n await settle();\n\n const element = fixture.nativeElement as HTMLElement;\n // Found by predicate rather than with `By.directive`, which would make\n // @angular/platform-browser a dependency of this entry point for one line.\n const rendererElement = fixture.debugElement.query(\n (candidate) => candidate.componentInstance instanceof JsonRenderer,\n );\n const renderer = rendererElement.componentInstance as JsonRenderer;\n const store = renderer.stateStore;\n // From the renderer's own injector: these services are provided by the\n // component, so the root TestBed injector has never heard of them.\n const validation = rendererElement.injector.get(JsonRenderValidationService);\n\n const resolve = (target: string | Element): HTMLElement => {\n if (typeof target !== 'string') return target as HTMLElement;\n const found = element.querySelector<HTMLElement>(target);\n if (!found) {\n throw new Error(\n `renderSpec: nothing matches ${JSON.stringify(target)}. Rendered HTML:\\n${element.innerHTML}`,\n );\n }\n return found;\n };\n\n return {\n fixture,\n element,\n renderer,\n store,\n validation,\n dispatched,\n changes,\n\n async setSpec(next) {\n host.spec.set(next);\n await settle();\n },\n async setLoading(loading) {\n host.loading.set(loading);\n await settle();\n },\n settle,\n\n read: (path) => store.get(path),\n async write(path, value) {\n store.set(path, value);\n await settle();\n },\n state: () => store.state(),\n\n text: (selector) =>\n ((selector ? resolve(selector) : element).textContent ?? '').trim(),\n texts: (selector) =>\n Array.from(element.querySelectorAll(selector)).map((el) =>\n (el.textContent ?? '').trim(),\n ),\n find: <T extends HTMLElement>(selector: string) => resolve(selector) as T,\n findAll: <T extends HTMLElement>(selector: string) =>\n Array.from(element.querySelectorAll<T>(selector)),\n async click(target) {\n resolve(target).click();\n await settle();\n },\n async fill(target, value) {\n const input = resolve(target) as HTMLInputElement;\n input.value = value;\n input.dispatchEvent(new Event('input', { bubbles: true }));\n await settle();\n },\n\n destroy: () => fixture.destroy(),\n };\n}\n","/*\n * Public API Surface of ngx-json-render/testing\n *\n * Test utilities, shipped as a separate entry point so nothing here can be\n * pulled into an application bundle by accident.\n */\n\nexport {\n recordedTransport,\n specStream,\n usageLine,\n type Recording,\n type Recordings,\n type RecordedFailure,\n type RecordedTransportOptions,\n} from './recorded-transport';\nexport {\n renderSpec,\n type DispatchedAction,\n type RenderSpecOptions,\n type SpecHarness,\n} from './render-spec';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAiDA;AACA,SAAS,UAAU,GAAA;AACjB,IAAA,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,4BAA4B,CAAC;AACrD,IAAA,KAAK,CAAC,IAAI,GAAG,YAAY;AACzB,IAAA,OAAO,KAAK;AACd;AAEA;AACA,SAAS,aAAa,CAAC,MAAc,EAAE,OAAe,EAAA;IACpD,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE;QAC/C,MAAM;AACN,QAAA,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;AAChD,KAAA,CAAC;AACJ;AAEA,SAAS,SAAS,CAAC,IAAiC,EAAA;AAClD,IAAA,IAAI;AACF,QAAA,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC;AACxD,QAAA,OAAO,MAAM,IAAI,OAAO,MAAM,KAAK;AACjC,cAAG;cACD,EAAE;IACR;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,EAAE;IACX;AACF;AAEA;;;AAGG;AACH,SAAS,eAAe,CAAC,IAAuC,EAAA;AAC9D,IAAA,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC;IAC7B,IAAI,OAAO,MAAM,KAAK,QAAQ;AAAE,QAAA,OAAO,MAAM;AAE7C,IAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC;AACjC,IAAA,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,MAAM,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