Rename Dataspace.global to Dataspace.local

This commit is contained in:
Tony Garnock-Jones 2024-04-15 10:26:27 +02:00
parent 40bc9aadd3
commit 4a05bbad73
6 changed files with 13 additions and 14 deletions

View File

@ -46,17 +46,16 @@ export class DataspaceObserver implements IndexObserver<Turn> {
}
export class Dataspace implements Partial<Entity> {
private static _global: Ref | undefined = void 0;
private static _local: Ref | undefined = void 0;
static get global(): Ref {
if (Dataspace._global === void 0) {
static get local(): Ref {
if (Dataspace._local === void 0) {
Dataspace.boot(ds => {
Turn.activeFacet.actor.name = Symbol.for('Dataspace.global');
// Cast to any because `global` is otherwise readonly (!)
Dataspace._global = ds;
Turn.activeFacet.actor.name = Symbol.for('Dataspace.local');
Dataspace._local = ds;
});
}
return Dataspace._global!;
return Dataspace._local!;
}
// Alias for syndicatec code generator to use, plus hook for fallback use outside a Turn
@ -73,7 +72,7 @@ export class Dataspace implements Partial<Entity> {
if (Turn.active) {
return Turn.active._spawn(bootProc);
} else {
return Actor.boot(bootProc, void 0, Dataspace.global.relay.actor.space);
return Actor.boot(bootProc, void 0, Dataspace.local.relay.actor.space);
}
}

View File

@ -11,7 +11,7 @@ export type UIFragmentRecord = ReturnType<typeof P.UIFragment>;
import { HtmlFragments } from "./html";
export * from "./html";
export function boot(ds = Dataspace.global) {
export function boot(ds = Dataspace.local) {
spawnGlobalEventFactory(ds);
spawnWindowEventFactory(ds);
spawnUIFragmentFactory(ds);

View File

@ -8,7 +8,7 @@ export { HtmlTemplater, template, HtmlFragment } from "./html";
export assertion type LocationHash(hash: string);
export type LocationHash = ReturnType<typeof LocationHash>;
export function boot(ds = Dataspace.global) {
export function boot(ds = Dataspace.local) {
spawnLocationHashTracker(ds);
}

View File

@ -7,7 +7,7 @@ import Pos = Syntax.Pos;
import * as Syndicate from '@syndicate-lang/core';
Object.defineProperty(globalThis, 'currentSyndicateTarget', {
value: Syndicate.Dataspace.global,
value: Syndicate.Dataspace.local,
writable: false,
});

View File

@ -20,7 +20,7 @@ export function sleep(ds: Ref, seconds: number, cb: () => void): void {
}
}
export function boot(ds = Dataspace.global) {
export function boot(ds = Dataspace.local) {
spawn named 'timer/PeriodicTick' {
at ds {
during Observe({

View File

@ -39,7 +39,7 @@ type TransportState = {
peer: Ref,
};
export function boot(ds = Dataspace.global, debug: boolean = false, WebSocketConstructor?: typeof WebSocket) {
export function boot(ds = Dataspace.local, debug: boolean = false, WebSocketConstructor?: typeof WebSocket) {
spawn named 'transportConnector' {
at ds {
during Observe({ "pattern": :pattern G.TransportConnection({
@ -470,7 +470,7 @@ export function contactRemote(
controlObject: Ref,
transportAddr: AnyValue,
) => void,
ds = Dataspace.global,
ds = Dataspace.local,
) {
const routeValue = 'pathSteps' in route ? G.fromRoute(G.Route(route)) : route;
at ds {