chore: les dix injections de useShape passent par le faux partage

Dix sites, pas les deux que le suivi annoncait : `(() => {}) as unknown as
UseShapeLike` survivait la ou le type etait encore `any` et ou le cast ne
disait donc rien. Ils prennent le faux partage, sans cast.
This commit is contained in:
Sylvain Duchesne
2026-09-24 19:00:25 +02:00
parent c5de1cea35
commit d4b392a119
6 changed files with 16 additions and 10 deletions
@@ -29,6 +29,7 @@
*/
import { test, expect, describe, mock, beforeEach } from "bun:test";
import { makeUseShapeHook } from "./use-shape-fake";
import { configure, storeRegistry, docs } from "../src/index";
import { configureStoreRegistry } from "../src/shared-wallet/bootstrap";
import { sparqlUpdate } from "../src/surface/docs";
@@ -84,7 +85,7 @@ function bootPage(quads: Quad[], lostAt: (query: string) => boolean): void {
return wallet.sparql_query(...a);
}),
};
configure({ ng: ng as unknown as NgLike, useShape: (() => {}) as unknown as UseShapeLike });
configure({ ng: ng as unknown as NgLike, useShape: makeUseShapeHook().hook });
configureStoreRegistry({ getSession: async () => SESSION, normalizeId: (id) => id.trim() });
}
+3 -2
View File
@@ -22,6 +22,7 @@
* another's document is decided by the system rather than by a variable in this file.
*/
import { test, expect, mock, afterEach } from "bun:test";
import { makeUseShapeHook } from "./use-shape-fake";
import { configure, getObjects, insertObject, initNg, storeRegistry } from "../src/index";
import { makeNg } from "../src/surface/ng-proxy";
import {
@@ -179,7 +180,7 @@ function inject(orm?: OrmDouble) {
const ng = makeFakeNg();
configure({
ng: ng as unknown as NgLike,
useShape: (() => {}) as unknown as UseShapeLike,
useShape: makeUseShapeHook().hook,
...(orm ? { getObjects: orm.getObjects, insertObject: orm.insertObject } : {}),
});
configureStoreRegistry({ getSession: async () => SESSION });
@@ -397,7 +398,7 @@ test("initNg hands the ORM this package's wrapped ng, not the argument", async (
const raw = { marker: "the raw SDK object" };
configure({
ng: ng as unknown as NgLike,
useShape: (() => {}) as unknown as UseShapeLike,
useShape: makeUseShapeHook().hook,
initNg: (...a: unknown[]) => void seen.push(...a),
});
configureStoreRegistry({ getSession: async () => SESSION });
@@ -31,6 +31,7 @@
*/
import { test, expect, describe, mock, afterAll, beforeEach } from "bun:test";
import { makeUseShapeHook } from "./use-shape-fake";
import { configure, docs, storeRegistry } from "../src/index";
import {
configureStoreRegistry,
@@ -292,7 +293,7 @@ function makeWallet(quads: Quad[] = []) {
function boot(quads: Quad[]): ReturnType<typeof makeWallet> {
const ng = makeWallet(quads);
configure({ ng: ng as unknown as NgLike, useShape: (() => {}) as unknown as UseShapeLike });
configure({ ng: ng as unknown as NgLike, useShape: makeUseShapeHook().hook });
configureStoreRegistry({ getSession: async () => SESSION, normalizeId: (id) => id.trim() });
return ng;
}
@@ -38,6 +38,7 @@
*/
import { test, expect, describe, afterAll, beforeEach } from "bun:test";
import { makeUseShapeHook } from "./use-shape-fake";
import { configure, useShapeQuery, storeRegistry } from "../src/index";
import type { ShapeObservable, ShapeQuery } from "../src/surface/use-shape-query";
import { configureStoreRegistry } from "../src/shared-wallet/bootstrap";
@@ -91,7 +92,7 @@ function bootPage(quads: Quad[]): FakeOrm {
const orm = makeOrm({ source: asOrmQuads });
configure({
ng: wallet as unknown as NgLike,
useShape: (() => {}) as unknown as UseShapeLike,
useShape: makeUseShapeHook().hook,
ormSubscription: orm.query,
});
configureStoreRegistry({ getSession: async () => SESSION, normalizeId: (id) => id.trim() });
@@ -275,7 +276,7 @@ describe("useShapeQuery tells 'there is nothing' from 'I could not find out'", (
});
configure({
ng: wallet as unknown as NgLike,
useShape: (() => {}) as unknown as UseShapeLike,
useShape: makeUseShapeHook().hook,
ormSubscription: orm.query,
});
configureStoreRegistry({ getSession: async () => SESSION, normalizeId: (id) => id.trim() });
@@ -22,6 +22,7 @@
*/
import { describe, it, expect, mock, beforeEach, afterEach, afterAll } from "bun:test";
import { makeUseShapeHook } from "./use-shape-fake";
import { useShapeQuery } from "../src/surface/use-shape-query";
import { configure } from "../src/index";
import { configureStoreRegistry, setCurrentUser, getCaps } from "../src/shared-wallet/bootstrap";
@@ -209,7 +210,7 @@ function inject(ng: ReturnType<typeof makeFake>, orm: FakeOrm) {
if (ng._noSubscribe) delete forwarded.doc_subscribe;
configure({
ng: forwarded as unknown as NgLike,
useShape: (() => {}) as unknown as UseShapeLike,
useShape: makeUseShapeHook().hook,
ormSubscription: orm.query,
});
configureStoreRegistry({
@@ -231,7 +232,7 @@ function reconfigure(ng: ReturnType<typeof makeFake>, orm: FakeOrm): void {
if (ng._noSubscribe) delete forwarded.doc_subscribe;
configure({
ng: forwarded as unknown as NgLike,
useShape: (() => {}) as unknown as UseShapeLike,
useShape: makeUseShapeHook().hook,
ormSubscription: orm.query,
});
configureStoreRegistry({
@@ -432,7 +433,7 @@ describe("useShapeQuery", () => {
inject(ng, orm);
// ...and then a bootstrap that forgot the injection. The read has nothing to go
// through, and an empty set would be the one lie this surface exists to prevent.
configure({ ng: ng as unknown as NgLike, useShape: (() => {}) as unknown as UseShapeLike });
configure({ ng: ng as unknown as NgLike, useShape: makeUseShapeHook().hook });
configureStoreRegistry({
getSession: async () => SESSION,
normalizeId: (u: string) => u.trim().replace(/^@+/, "").toLowerCase(),
+2 -1
View File
@@ -19,6 +19,7 @@
*/
import { mock } from "bun:test";
import { makeUseShapeHook } from "./use-shape-fake";
import { configure, storeRegistry } from "../src/index";
import {
configureStoreRegistry,
@@ -399,7 +400,7 @@ export function makeWallet(quads: Quad[], options: WalletOptions = {}): FakeWall
/** Wire the library onto `quads` — what a page load does. */
export function bootPage(quads: Quad[], options: WalletOptions = {}): FakeWallet {
const ng = makeWallet(quads, options);
configure({ ng: ng as unknown as NgLike, useShape: (() => {}) as unknown as UseShapeLike });
configure({ ng: ng as unknown as NgLike, useShape: makeUseShapeHook().hook });
configureStoreRegistry({ getSession: async () => SESSION, normalizeId: (id) => id.trim() });
return ng;
}