From d4b392a1190d092dda1bb4945696218323d0ec3b Mon Sep 17 00:00:00 2001 From: Sylvain Duchesne Date: Thu, 24 Sep 2026 19:00:25 +0200 Subject: [PATCH] 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. --- packages/polyfill/test/listing-surfaces-failure.test.ts | 3 ++- packages/polyfill/test/orm.test.ts | 5 +++-- packages/polyfill/test/reload-own-document.test.ts | 3 ++- .../polyfill/test/use-shape-query-surfaces-failure.test.ts | 5 +++-- packages/polyfill/test/use-shape-query.test.ts | 7 ++++--- packages/polyfill/test/wallet-fake.ts | 3 ++- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/packages/polyfill/test/listing-surfaces-failure.test.ts b/packages/polyfill/test/listing-surfaces-failure.test.ts index e3340ab..07476b1 100644 --- a/packages/polyfill/test/listing-surfaces-failure.test.ts +++ b/packages/polyfill/test/listing-surfaces-failure.test.ts @@ -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() }); } diff --git a/packages/polyfill/test/orm.test.ts b/packages/polyfill/test/orm.test.ts index da043c8..b15fb74 100644 --- a/packages/polyfill/test/orm.test.ts +++ b/packages/polyfill/test/orm.test.ts @@ -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 }); diff --git a/packages/polyfill/test/reload-own-document.test.ts b/packages/polyfill/test/reload-own-document.test.ts index dbf4cc8..bcfc82b 100644 --- a/packages/polyfill/test/reload-own-document.test.ts +++ b/packages/polyfill/test/reload-own-document.test.ts @@ -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 { 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; } diff --git a/packages/polyfill/test/use-shape-query-surfaces-failure.test.ts b/packages/polyfill/test/use-shape-query-surfaces-failure.test.ts index de707de..e6323a4 100644 --- a/packages/polyfill/test/use-shape-query-surfaces-failure.test.ts +++ b/packages/polyfill/test/use-shape-query-surfaces-failure.test.ts @@ -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() }); diff --git a/packages/polyfill/test/use-shape-query.test.ts b/packages/polyfill/test/use-shape-query.test.ts index f3b4d8a..71c1352 100644 --- a/packages/polyfill/test/use-shape-query.test.ts +++ b/packages/polyfill/test/use-shape-query.test.ts @@ -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, 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, 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(), diff --git a/packages/polyfill/test/wallet-fake.ts b/packages/polyfill/test/wallet-fake.ts index 439b888..58639d4 100644 --- a/packages/polyfill/test/wallet-fake.ts +++ b/packages/polyfill/test/wallet-fake.ts @@ -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; }