feat!: la famille ORM est publiee enveloppee, et le ng publie cesse de rendre des promesses
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
import { getConfig, rememberHandOver } from "../shared-wallet/bootstrap";
|
||||
import { settleIdentity } from "../shared-wallet/access-gate";
|
||||
import { captureSession, expectSession } from "../shared-wallet/session";
|
||||
import { wrappedNg } from "./ng-proxy";
|
||||
|
||||
/**
|
||||
* Forwards to the real `@ng-org/web` `init`, once the identifier is in the address bar.
|
||||
@@ -90,10 +91,33 @@ export function init(...args: any[]): any {
|
||||
return settleIdentity().then(delegate);
|
||||
}
|
||||
|
||||
/** Forwards to the real `@ng-org/orm` `initNg` (ORM signals). */
|
||||
// @provenance initNg kind=passthrough level=3 ref=sdk/js/orm/src/core.ts:initNg — upstream's own exported name for `initNgSignals`
|
||||
/**
|
||||
* Forwards to the real `@ng-org/orm` `initNg` (ORM signals) - with the `ng` in position 0
|
||||
* replaced by this package's own wrapped one.
|
||||
*
|
||||
* -- Why the substitution, and why it is invisible to the caller ------------
|
||||
* `initNg(ngImpl, session)` is how the ORM is told which `ng` to reach the engine
|
||||
* through: it resolves a module-level promise every subscription, every `insertObject`
|
||||
* and every batched patch awaits afterwards. So whatever is handed over HERE is the `ng`
|
||||
* every ORM write leaves by - and an ORM write leaves by `ng.graph_orm_update`, which is
|
||||
* where this package's write guard sits (`ng-proxy.ts`). Handing over the caller's raw
|
||||
* SDK object leaves that guard on a door nothing knocks on.
|
||||
*
|
||||
* It is the same argument `init`'s callback wrapping above rests on, and it lands the same
|
||||
* way: the invariant is carried by COMPOSITION rather than by an instruction a caller gets
|
||||
* to get wrong once. "Pass the package's `ng` to `initNg`" would be an ordering rule in
|
||||
* prose, unenforceable and silent when missed - and it WAS missed, by both consumers in
|
||||
* this repository, which is how the hole was found.
|
||||
*
|
||||
* Nothing is taken from the caller: `wrappedNg()` forwards every one of the 88 members to
|
||||
* the very object `configure()` received, and it is the same object `ng` publishes, so the
|
||||
* ORM now reaches the engine through exactly what the application does. The remaining
|
||||
* arguments and the return value pass straight through.
|
||||
*/
|
||||
// @provenance initNg kind=passthrough level=3 ref=sdk/js/orm/src/core.ts:initNg - upstream's own exported name for `initNgSignals`; the arguments and the return pass through, and the `ng` in position 0 is replaced by this package's wrapped one so the ORM's writes meet the emulated write guard
|
||||
export function initNg(...args: any[]): any {
|
||||
const f = getConfig().initNg;
|
||||
if (!f) throw new Error("[ng-eventually] initNg() not injected — pass it to configure()");
|
||||
return f(...args);
|
||||
const [, ...rest] = args;
|
||||
return f(wrappedNg(), ...rest);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user