@askrjs/askr 0.0.88 → 0.0.89

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 (51) hide show
  1. package/dist/actions/index.d.ts +1 -1
  2. package/dist/actions/index.js +1 -1
  3. package/dist/{activity-VMb7aJVx.d.ts → activity-CF2_JvJs.d.ts} +1 -1
  4. package/dist/{activity-C9naVZwy.js → activity-CQKEAORw.js} +3 -2
  5. package/dist/benchmark.js +5 -5
  6. package/dist/boot/index.d.ts +6 -4
  7. package/dist/boot/index.js +1 -1
  8. package/dist/{boot-BVHzYQz8.js → boot-CrbszDjZ.js} +24 -14
  9. package/dist/{component-internal-uVCJAre6.js → component-internal-C4uwwUaK.js} +31 -2
  10. package/dist/components/index.d.ts +1 -1
  11. package/dist/control/index.d.ts +1 -1
  12. package/dist/control/index.js +1 -1
  13. package/dist/{control-DlwTrXBN.js → control-CON10J1p.js} +1 -1
  14. package/dist/{control-x8iehxf7.d.ts → control-D-FIa-n-.d.ts} +2 -0
  15. package/dist/{csp-nonce-CUscoNF1.js → csp-nonce-DH0TrDij.js} +1 -1
  16. package/dist/data/index.d.ts +3 -2
  17. package/dist/data/index.js +3 -3
  18. package/dist/{data-CXZ-FOa7.js → data-BmZC1kDn.js} +27 -9
  19. package/dist/{data-runtime-CnVeSvJz.js → data-runtime-SC6zzAwh.js} +10 -5
  20. package/dist/{deferred-BCgoep1C.js → deferred-Bh-nZhZF.js} +2 -2
  21. package/dist/{for-internal-Be7x2TFd.js → for-internal-Bsm0B8GZ.js} +1 -1
  22. package/dist/foundations/index.d.ts +1 -1
  23. package/dist/foundations/state/index.d.ts +1 -1
  24. package/dist/foundations/structures/index.d.ts +1 -1
  25. package/dist/{index-BYWsbogt.d.ts → index-BU17hud9.d.ts} +1 -1
  26. package/dist/index-CPlPDbEY.d.ts +64 -0
  27. package/dist/{index-DODUjRdZ.d.ts → index-Cf2ANwPL.d.ts} +1 -1
  28. package/dist/{index-yDjeTqs5.d.ts → index-Izwp_ESC.d.ts} +18 -3
  29. package/dist/index.d.ts +6 -5
  30. package/dist/index.js +7 -7
  31. package/dist/{lifecycle-operations-DTO93Hrl.js → lifecycle-operations-CMK1AN2C.js} +1 -1
  32. package/dist/{navigate-kJ_EW8Y8.d.ts → navigate-BO7M2iUG.d.ts} +1 -1
  33. package/dist/{navigate-Bz6hh2JB.js → navigate-DIOaNAcS.js} +5 -4
  34. package/dist/{query-registry-p_0kkieE.js → query-registry-IACQeDqi.js} +1 -1
  35. package/dist/{renderer-5bjf5dIf.js → renderer-y2DL627q.js} +3 -3
  36. package/dist/{resolution-BRmiFYvw.js → resolution-D3UO6aKA.js} +40 -4
  37. package/dist/{resource-operation-B94oj6xT.js → resource-operation-CYDU3XzS.js} +1 -1
  38. package/dist/resources/index.d.ts +2 -2
  39. package/dist/resources/index.js +4 -4
  40. package/dist/router/index.d.ts +26 -5
  41. package/dist/router/index.js +6 -6
  42. package/dist/ssg/index.d.ts +2 -2
  43. package/dist/ssg/index.js +4 -4
  44. package/dist/ssr/index.d.ts +4 -3
  45. package/dist/ssr/index.js +1 -1
  46. package/dist/{ssr-D3hUAWyQ.js → ssr-DXGtDJd7.js} +6 -6
  47. package/dist/testing/index.d.ts +35 -4
  48. package/dist/testing/index.js +150 -3
  49. package/dist/{index-SGxMZLAc.d.ts → types-iAmDSV6o.d.ts} +6 -63
  50. package/dist/{verify-hydration-Bd1kGLmH.js → verify-hydration-AdrYLDxd.js} +1 -1
  51. package/package.json +2 -2
@@ -1,7 +1,9 @@
1
1
  import { r as flushRuntimeScheduler } from "../access-Dpfoi4cA.js";
2
- import { l as addInvalidationListener, t as createDataRuntime } from "../data-runtime-CnVeSvJz.js";
2
+ import { u as recordReadableRead } from "../readable-B5NtV7V0.js";
3
+ import { l as addInvalidationListener, t as createDataRuntime } from "../data-runtime-SC6zzAwh.js";
4
+ import { a as notifySource, i as normalizeAsyncDataError, r as createReadableSource } from "../data-BmZC1kDn.js";
3
5
  import { r as computeRouteActivityMatches } from "../route-matching-DqULzZtC.js";
4
- import { a as cleanupApp, r as createSPA, t as createIsland } from "../boot-BVHzYQz8.js";
6
+ import { a as cleanupApp, r as createSPA, t as createIsland } from "../boot-CrbszDjZ.js";
5
7
  //#region src/testing/render.ts
6
8
  const renderStates = /* @__PURE__ */ new WeakMap();
7
9
  const eventConstructorNames = {
@@ -169,6 +171,7 @@ async function renderRoute(options) {
169
171
  root: container,
170
172
  registry: options.registry,
171
173
  auth: options.auth,
174
+ dataRuntime: options.dataRuntime,
172
175
  cleanupStrict: options.cleanupStrict
173
176
  });
174
177
  flush();
@@ -218,6 +221,150 @@ function createQueryTestRegistry() {
218
221
  }
219
222
  };
220
223
  }
224
+ /** Create a keyed mutation fixture registry for a test render runtime. */
225
+ function createMutationTestRegistry() {
226
+ const runtime = createDataRuntime();
227
+ return {
228
+ runtime,
229
+ set(key, mutation) {
230
+ if (typeof key !== "string" || key.length === 0) throw new TypeError("@askrjs/askr/testing mutation registry keys must be non-empty strings.");
231
+ const previous = runtime.mutationTestOverrides.get(key);
232
+ if (previous && previous !== mutation) previous.reset();
233
+ runtime.mutationTestOverrides.set(key, mutation);
234
+ },
235
+ delete(key) {
236
+ runtime.mutationTestOverrides.get(key)?.reset();
237
+ runtime.mutationTestOverrides.delete(key);
238
+ },
239
+ clear() {
240
+ for (const mutation of runtime.mutationTestOverrides.values()) mutation.reset();
241
+ runtime.mutationTestOverrides.clear();
242
+ }
243
+ };
244
+ }
245
+ var MutableMutationFixture = class {
246
+ constructor(initial = {}) {
247
+ this.source = createReadableSource();
248
+ this.receivedInputs = [];
249
+ this.active = null;
250
+ const hasResult = Object.prototype.hasOwnProperty.call(initial, "result");
251
+ if (initial.pending && (initial.error != null || hasResult)) throw new TypeError("@askrjs/askr/testing mutation fixtures cannot be pending and settled.");
252
+ if (initial.error != null && hasResult) throw new TypeError("@askrjs/askr/testing mutation fixtures cannot have both error and result.");
253
+ this.state = initial.pending ? {
254
+ status: "pending",
255
+ error: null,
256
+ result: null
257
+ } : initial.error != null ? {
258
+ status: "error",
259
+ error: initial.error,
260
+ result: null
261
+ } : hasResult ? {
262
+ status: "success",
263
+ error: null,
264
+ result: initial.result
265
+ } : {
266
+ status: "idle",
267
+ error: null,
268
+ result: null
269
+ };
270
+ }
271
+ get status() {
272
+ recordReadableRead(this.source);
273
+ return this.state.status;
274
+ }
275
+ get pending() {
276
+ recordReadableRead(this.source);
277
+ return this.state.status === "pending";
278
+ }
279
+ get error() {
280
+ recordReadableRead(this.source);
281
+ return this.state.error;
282
+ }
283
+ get result() {
284
+ recordReadableRead(this.source);
285
+ return this.state.result;
286
+ }
287
+ get inputs() {
288
+ return this.receivedInputs;
289
+ }
290
+ execute(input) {
291
+ this.abort();
292
+ this.receivedInputs.push(input);
293
+ this.setPending();
294
+ return new Promise((resolve, reject) => {
295
+ this.active = {
296
+ resolve,
297
+ reject
298
+ };
299
+ });
300
+ }
301
+ setPending() {
302
+ this.setState({
303
+ status: "pending",
304
+ error: null,
305
+ result: null
306
+ });
307
+ }
308
+ succeed(result) {
309
+ const active = this.active;
310
+ this.active = null;
311
+ this.setState({
312
+ status: "success",
313
+ error: null,
314
+ result
315
+ });
316
+ active?.resolve(result);
317
+ }
318
+ fail(error) {
319
+ const normalized = normalizeAsyncDataError(error, "Unknown mutation fixture error");
320
+ const active = this.active;
321
+ this.active = null;
322
+ this.setState({
323
+ status: "error",
324
+ error: normalized,
325
+ result: null
326
+ });
327
+ active?.reject(normalized);
328
+ }
329
+ abort() {
330
+ const active = this.active;
331
+ this.active = null;
332
+ this.setState({
333
+ status: "idle",
334
+ error: null,
335
+ result: null
336
+ });
337
+ if (active) {
338
+ const error = /* @__PURE__ */ new Error("Mutation fixture aborted.");
339
+ error.name = "AbortError";
340
+ active.reject(error);
341
+ }
342
+ }
343
+ reset() {
344
+ this.abort();
345
+ }
346
+ setState(state) {
347
+ this.state = state;
348
+ notifySource(this.source);
349
+ }
350
+ };
351
+ function createMutationFixture(initial = {}) {
352
+ return new MutableMutationFixture(initial);
353
+ }
354
+ const mutationState = Object.assign(createMutationFixture, {
355
+ idle() {
356
+ return createMutationFixture();
357
+ },
358
+ pending() {
359
+ return createMutationFixture({ pending: true });
360
+ },
361
+ success(result) {
362
+ return createMutationFixture({ result });
363
+ },
364
+ error(error) {
365
+ return createMutationFixture({ error });
366
+ }
367
+ });
221
368
  function normalizeRefresh(options) {
222
369
  return async () => {
223
370
  await options?.refresh?.();
@@ -380,4 +527,4 @@ function getRouteWarnings(options) {
380
527
  });
381
528
  }
382
529
  //#endregion
383
- export { cleanup, click, createInvalidationRecorder, createQueryTestRegistry, dispatch, flush, getRouteWarnings, matchRoute, mockQuery, mount, queryState, render, renderRoute, submit, type };
530
+ export { cleanup, click, createInvalidationRecorder, createMutationTestRegistry, createQueryTestRegistry, dispatch, flush, getRouteWarnings, matchRoute, mockQuery, mount, mutationState, queryState, render, renderRoute, submit, type };
@@ -6,11 +6,14 @@ interface DataRuntime {
6
6
  readonly queryData: Map<string, unknown>;
7
7
  /** Test-only query overrides keyed by the canonical query key. */
8
8
  readonly queryTestOverrides: Map<string, unknown>;
9
+ /** Test-only mutation overrides keyed by the canonical mutation key. */
10
+ readonly mutationTestOverrides: Map<string, unknown>;
9
11
  }
10
12
  interface DataRuntimeOptions {
11
13
  queryCache?: Map<string, unknown>;
12
14
  queryData?: Map<string, unknown>;
13
15
  queryTestOverrides?: Map<string, unknown>;
16
+ mutationTestOverrides?: Map<string, unknown>;
14
17
  }
15
18
  interface QueryDefinition<TInput, TResult extends {}> {
16
19
  readonly key: (input: TInput) => string;
@@ -163,6 +166,8 @@ type QueryOptions<T> = {
163
166
  skipInitialFetch?: boolean;
164
167
  };
165
168
  type MutationOptions<TInput, TResult> = {
169
+ /** Stable identity used by runtime-scoped mutation test overrides. */
170
+ key?: string;
166
171
  action: (input: TInput, ctx: {
167
172
  signal: AbortSignal;
168
173
  }) => Promise<TResult>;
@@ -171,66 +176,4 @@ type MutationOptions<TInput, TResult> = {
171
176
  runtime?: DataRuntime;
172
177
  };
173
178
  //#endregion
174
- //#region src/common/telemetry.d.ts
175
- interface TelemetryFields {
176
- requestId?: string;
177
- traceId?: string;
178
- route?: string;
179
- action?: string;
180
- operation?: string;
181
- status?: number;
182
- durationMs?: number;
183
- }
184
- type TelemetrySpan = <T>(fields: TelemetryFields, work: () => T) => T;
185
- /**
186
- * Structural subset implemented by `createTelemetry()` from `@askrjs/otel`.
187
- * Core does not install an OpenTelemetry SDK, backend, or exporter.
188
- */
189
- interface CoreTelemetry {
190
- routeMatch?: TelemetrySpan;
191
- loader?: TelemetrySpan;
192
- queryPrefetch?: TelemetrySpan;
193
- ssrRender?: TelemetrySpan;
194
- }
195
- //#endregion
196
- //#region src/data/mutation-cell.d.ts
197
- declare function createMutation<TInput, TResult>(options: MutationOptions<TInput, TResult>): Mutation<TInput, TResult>;
198
- //#endregion
199
- //#region src/data/query-cell.d.ts
200
- declare function createQuery<T extends {}>(options: QueryOptions<T>): Query<T>;
201
- declare function createQuery<TInput, TResult extends {}>(definition: QueryDefinition<TInput, TResult>, input: TInput, options?: Omit<QueryOptions<TResult>, 'key' | 'fetch'>): Query<TResult>;
202
- //#endregion
203
- //#region src/data/data-runtime.d.ts
204
- declare function createDataRuntime(options?: DataRuntimeOptions): DataRuntime;
205
- declare function getDefaultDataRuntime(): DataRuntime;
206
- //#endregion
207
- //#region src/data/invalidation.d.ts
208
- declare function invalidate(prefix: string, options?: InvalidateOptions): void;
209
- declare function queryScope(namespace: string): QueryScope;
210
- declare function invalidateOnInterval(prefix: string, options: InvalidateOnIntervalOptions): void;
211
- //#endregion
212
- //#region src/data/query-registry.d.ts
213
- interface ServerQueryRegistry {
214
- readonly entries: readonly ServerQueryEntry<unknown, {}>[];
215
- get<TInput, TResult extends {}>(query: QueryDefinition<TInput, TResult>): ServerQueryHandler<TInput, TResult> | undefined;
216
- }
217
- interface ServerQueryEntry<TInput, TResult extends {}> {
218
- readonly query: QueryDefinition<TInput, TResult>;
219
- readonly handler: ServerQueryHandler<TInput, TResult>;
220
- }
221
- declare function serveQuery<TInput, TResult extends {}>(query: QueryDefinition<TInput, TResult>, handler: ServerQueryHandler<TInput, TResult>): ServerQueryEntry<TInput, TResult>;
222
- declare function defineServerQueries(...entries: readonly ServerQueryEntry<any, any>[]): ServerQueryRegistry;
223
- declare function defineQuery<TInput, TResult extends {}>(definition: QueryDefinition<TInput, TResult>): QueryDefinition<TInput, TResult>;
224
- declare function createQueryPrefetchContext(options?: {
225
- runtime?: DataRuntime;
226
- registry?: ServerQueryRegistry;
227
- request?: Request;
228
- signal?: AbortSignal;
229
- mode?: 'ssr' | 'spa';
230
- telemetry?: CoreTelemetry;
231
- }): QueryPrefetchContext;
232
- declare function prefetchQuery<TInput, TResult extends {}>(context: QueryPrefetchContext, query: QueryDefinition<TInput, TResult>, input: TInput): Promise<boolean>;
233
- declare function dehydrateDataRuntime(runtime: DataRuntime): Record<string, unknown>;
234
- declare function hydrateDataRuntime(runtime: DataRuntime, data: unknown): void;
235
- //#endregion
236
- export { ServerQueryHandler as A, Query as C, QueryPrefetchContext as D, QueryKeyPart as E, QueryScope as O, Mutation as S, QueryDefinition as T, CoreTelemetry as _, defineServerQueries as a, InvalidateOnIntervalOptions as b, prefetchQuery as c, invalidateOnInterval as d, queryScope as f, createMutation as g, createQuery as h, defineQuery as i, QueryStaleReason as k, serveQuery as l, getDefaultDataRuntime as m, ServerQueryRegistry as n, dehydrateDataRuntime as o, createDataRuntime as p, createQueryPrefetchContext as r, hydrateDataRuntime as s, ServerQueryEntry as t, invalidate as u, DataRuntime as v, QueryConsistency as w, InvalidateOptions as x, DataRuntimeOptions as y };
179
+ export { Mutation as a, QueryConsistency as c, QueryOptions as d, QueryPrefetchContext as f, ServerQueryHandler as h, InvalidateOptions as i, QueryDefinition as l, QueryStaleReason as m, DataRuntimeOptions as n, MutationOptions as o, QueryScope as p, InvalidateOnIntervalOptions as r, Query as s, DataRuntime as t, QueryKeyPart as u };
@@ -1,6 +1,6 @@
1
1
  import { m as withHydrationVerificationRender } from "./render-context-D0Hoj9dW.js";
2
2
  import { t as SSR_RENDER_DATA_ATTR } from "./ssr-DSHd_Q9K.js";
3
- import { a as renderResolvedToStringSync } from "./ssr-D3hUAWyQ.js";
3
+ import { a as renderResolvedToStringSync } from "./ssr-DXGtDJd7.js";
4
4
  //#region src/ssr/verify-hydration.ts
5
5
  function normalizeHydrationHtml(html) {
6
6
  const template = document.createElement("template");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askrjs/askr",
3
- "version": "0.0.88",
3
+ "version": "0.0.89",
4
4
  "description": "Actor-backed deterministic UI framework",
5
5
  "keywords": [
6
6
  "askr",
@@ -152,7 +152,7 @@
152
152
  "@askrjs/schema": ">=0.0.5 <0.1.0"
153
153
  },
154
154
  "devDependencies": {
155
- "@types/node": "^26.1.2",
155
+ "@types/node": "^26.2.0",
156
156
  "@typescript/native": "npm:typescript@^7.0.2",
157
157
  "@vitest/browser-playwright": "4.1.10",
158
158
  "cross-env": "^10.1.0",