Classify source files into subdirectories
This commit is contained in:
parent
61174815eb
commit
fa47fa3e5e
|
@ -10,7 +10,7 @@
|
||||||
"@preserves/schema": "^0.4.0"
|
"@preserves/schema": "^0.4.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"regenerate": "rm -rf ./src/gen && preserves-schema-ts --module Actor=./src/actor.ts --module Protocol=./src/protocol.ts --output ./src/gen './schemas/**/*.prs'",
|
"regenerate": "rm -rf ./src/gen && preserves-schema-ts --module Actor=./src/runtime/actor.ts --module Protocol=./src/transport/protocol.ts --output ./src/gen './schemas/**/*.prs'",
|
||||||
"regenerate:watch": "yarn regenerate --watch",
|
"regenerate:watch": "yarn regenerate --watch",
|
||||||
"regenerate:bundle": "preserves-schemac './schemas/**/*.prs' > novy-syndicate.schema.bundle.bin",
|
"regenerate:bundle": "preserves-schemac './schemas/**/*.prs' > novy-syndicate.schema.bundle.bin",
|
||||||
"compile": "tsc",
|
"compile": "tsc",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
export default {
|
export default {
|
||||||
input: 'lib/sturdy-demo.js',
|
input: 'lib/examples/sturdy-demo.js',
|
||||||
output: {
|
output: {
|
||||||
file: 'index.js',
|
file: 'index.js',
|
||||||
format: 'umd',
|
format: 'umd',
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
version 1 .
|
version 1 .
|
||||||
|
pointer Actor.Ref .
|
||||||
|
|
||||||
Instance = <Instance @name string @argument any>.
|
Instance = <Instance @name string @argument any>.
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { Actor, Ref, Turn } from "./actor";
|
import { Actor, Ref, Turn } from "../runtime/actor";
|
||||||
import { Relay, spawnRelay } from "./relay";
|
import { Relay, spawnRelay } from "../transport/relay";
|
||||||
import { sturdyDecode } from "./sturdy";
|
import { sturdyDecode } from "../transport/sturdy";
|
||||||
import { Resolve, asSturdyRef, fromResolve } from "./gen/sturdy";
|
import { Resolve, asSturdyRef, fromResolve } from "../gen/sturdy";
|
||||||
import { during } from "./dataspace";
|
import { during } from "../runtime/dataspace";
|
||||||
|
|
||||||
import * as net from 'net';
|
import * as net from 'net';
|
||||||
import { Bytes } from "@preserves/core";
|
import { Bytes } from "@preserves/core";
|
|
@ -1,13 +1,13 @@
|
||||||
import { Actor, Handle, Turn } from './actor.js';
|
import { Actor, Handle, Turn } from '../runtime/actor.js';
|
||||||
import { Dataspace, during, observe } from './dataspace.js';
|
import { Dataspace, during, observe } from '../runtime/dataspace.js';
|
||||||
import { Relay, spawnRelay } from './relay.js';
|
import { Relay, spawnRelay } from '../transport/relay.js';
|
||||||
import * as net from 'net';
|
import * as net from 'net';
|
||||||
|
|
||||||
import { mint, sturdyEncode, validate } from './sturdy.js';
|
import { mint, sturdyEncode, validate } from '../transport/sturdy.js';
|
||||||
import { KEY_LENGTH } from './cryptography.js';
|
import { KEY_LENGTH } from '../transport/cryptography.js';
|
||||||
import { attenuate } from './rewrite.js';
|
import { attenuate } from '../runtime/rewrite.js';
|
||||||
import { Bytes, is } from '@preserves/core';
|
import { Bytes, is } from '@preserves/core';
|
||||||
import { $bind, Attenuation, Bind, fromBind, fromSturdyRef, toBind, toResolve, _val } from './gen/sturdy.js';
|
import { $bind, Attenuation, Bind, fromBind, fromSturdyRef, toBind, toResolve, _val } from '../gen/sturdy.js';
|
||||||
|
|
||||||
new Actor(t => {
|
new Actor(t => {
|
||||||
t.activeFacet.preventInertCheck();
|
t.activeFacet.preventInertCheck();
|
|
@ -1,6 +1,6 @@
|
||||||
import { BoxState, $SetBox, fromBoxState } from "./gen/box-protocol.js";
|
import { BoxState, $SetBox, fromBoxState } from "../gen/box-protocol.js";
|
||||||
import { fromObserve, Observe } from "./gen/dataspace.js";
|
import { fromObserve, Observe } from "../gen/dataspace.js";
|
||||||
import { Assertion, Handle, Ref, Turn } from "./actor.js";
|
import { Assertion, Handle, Ref, Turn } from "../runtime/actor.js";
|
||||||
|
|
||||||
let startTime = Date.now();
|
let startTime = Date.now();
|
||||||
let prevValue = 0;
|
let prevValue = 0;
|
|
@ -1,6 +1,6 @@
|
||||||
import { $BoxState, fromSetBox, SetBox } from "./gen/box-protocol.js";
|
import { $BoxState, fromSetBox, SetBox } from "../gen/box-protocol.js";
|
||||||
import { fromObserve, Observe } from "./gen/dataspace.js";
|
import { fromObserve, Observe } from "../gen/dataspace.js";
|
||||||
import { Assertion, Ref, Turn } from "./actor.js";
|
import { Assertion, Ref, Turn } from "../runtime/actor.js";
|
||||||
|
|
||||||
export default function (t: Turn, ds: Ref) {
|
export default function (t: Turn, ds: Ref) {
|
||||||
console.log('Spawning Client');
|
console.log('Spawning Client');
|
|
@ -1,40 +1,12 @@
|
||||||
import { Actor, Assertion, Ref, Turn } from './actor.js';
|
import { Actor, Assertion, Ref, Turn } from '../runtime/actor.js';
|
||||||
import { Dictionary, Record } from '@preserves/core';
|
import { Dictionary } from '@preserves/core';
|
||||||
import { Dataspace } from './dataspace.js';
|
import { Dataspace } from '../runtime/dataspace.js';
|
||||||
import { Worker } from 'worker_threads';
|
import { attenuate, CRec, Lit, Pattern, PCompound, rfilter, ConstructorSpec } from '../runtime/rewrite.js';
|
||||||
import { Relay, spawnRelay } from './relay.js';
|
import { $BoxState, $SetBox } from '../gen/box-protocol.js';
|
||||||
|
import { $Observe } from '../gen/dataspace.js';
|
||||||
|
import { spawnWorker } from '../worker/index.js';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import { attenuate, CRec, Lit, Pattern, PCompound, rfilter, ConstructorSpec } from './rewrite.js';
|
|
||||||
import { $BoxState, $SetBox } from './gen/box-protocol.js';
|
|
||||||
import { $Observe } from './gen/dataspace.js';
|
|
||||||
|
|
||||||
const Instance = Record.makeConstructor<{moduleName: string, arg: Assertion}>()(
|
|
||||||
Symbol.for('Instance'), ['moduleName', 'arg']);
|
|
||||||
|
|
||||||
function spawnWorker(t: Turn, moduleName: string, arg: Assertion) {
|
|
||||||
const w = new Worker(path.join(__dirname, 'wload.js'));
|
|
||||||
const reenable = t.activeFacet.preventInertCheck();
|
|
||||||
spawnRelay(t, {
|
|
||||||
packetWriter: bs => w.postMessage(bs),
|
|
||||||
setup(t: Turn, r: Relay) {
|
|
||||||
w.on('message', bs => r.accept(bs));
|
|
||||||
w.on('error', err => Turn.for(t.activeFacet, t => t.crash(err)));
|
|
||||||
w.on('exit', code => Turn.for(t.activeFacet, t => {
|
|
||||||
if (code === 0) {
|
|
||||||
t.stopActor();
|
|
||||||
} else {
|
|
||||||
t.crash(new Error(`Worker crashed with code ${code}`));
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
initialOid: 0,
|
|
||||||
}).then(factory => {
|
|
||||||
reenable();
|
|
||||||
new Actor(t => t.assert(factory, Instance(moduleName, arg)));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function spawnModule(t: Turn, moduleName: string, arg: Assertion) {
|
function spawnModule(t: Turn, moduleName: string, arg: Assertion) {
|
||||||
import(moduleName).then(m => t.freshen(t => t.spawn(t => m.default(t, arg))));
|
import(moduleName).then(m => t.freshen(t => t.spawn(t => m.default(t, arg))));
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
import { Turn, Entity, Facet } from './actor.js';
|
import { Turn, Entity, Facet } from '../runtime/actor.js';
|
||||||
import readline from 'readline';
|
import readline from 'readline';
|
||||||
|
|
||||||
export function attachReadline(t: Turn, entity: Partial<Entity>): Facet {
|
export function attachReadline(t: Turn, entity: Partial<Entity>): Facet {
|
|
@ -1,6 +1,6 @@
|
||||||
import { $joinedUser, $says, $user, asJoin, asSays, asUserInfo, fromNickClaim, fromSays, NickClaim, Says, UserId } from "./gen/secure-chat-protocol.js";
|
import { $joinedUser, $says, $user, asJoin, asSays, asUserInfo, fromNickClaim, fromSays, NickClaim, Says, UserId } from "../gen/secure-chat-protocol.js";
|
||||||
import { during, observe } from "./dataspace.js";
|
import { during, observe } from "../runtime/dataspace.js";
|
||||||
import { Assertion, Ref, Turn } from "./actor.js";
|
import { Assertion, Ref, Turn } from "../runtime/actor.js";
|
||||||
import { attachReadline } from './readline.js';
|
import { attachReadline } from './readline.js';
|
||||||
|
|
||||||
export default function (t: Turn, ds: Ref) {
|
export default function (t: Turn, ds: Ref) {
|
|
@ -11,11 +11,11 @@ import {
|
||||||
fromJoin,
|
fromJoin,
|
||||||
fromNickConflict,
|
fromNickConflict,
|
||||||
fromUserInfo,
|
fromUserInfo,
|
||||||
} from "./gen/secure-chat-protocol.js";
|
} from "../gen/secure-chat-protocol.js";
|
||||||
import { Assertion, Handle, Ref, Turn } from "./actor.js";
|
import { Assertion, Handle, Ref, Turn } from "../runtime/actor.js";
|
||||||
import { observe, during, $Observe, asObserve, Dataspace } from "./dataspace.js";
|
import { observe, during, $Observe, asObserve, Dataspace } from "../runtime/dataspace.js";
|
||||||
import { attenuate, rfilter, pRec, pPointer, pString, pLit } from "./rewrite.js";
|
import { attenuate, rfilter, pRec, pPointer, pString, pLit } from "../runtime/rewrite.js";
|
||||||
import { attenuate as sturdyAttenuate, fromBind, Bind, KEY_LENGTH, sturdyEncode, fromSturdyRef, mint } from "./sturdy.js";
|
import { attenuate as sturdyAttenuate, fromBind, Bind, KEY_LENGTH, sturdyEncode, fromSturdyRef, mint } from "../transport/sturdy.js";
|
||||||
import { Bytes } from "@preserves/core";
|
import { Bytes } from "@preserves/core";
|
||||||
|
|
||||||
export default function (t: Turn, gatekeeperDs: Ref) {
|
export default function (t: Turn, gatekeeperDs: Ref) {
|
|
@ -1,6 +1,6 @@
|
||||||
import { $Present, $Says, asPresent, asSays, fromPresent, fromSays, Present, Says } from "./gen/simple-chat-protocol.js";
|
import { $Present, $Says, asPresent, asSays, fromPresent, fromSays, Present, Says } from "../gen/simple-chat-protocol.js";
|
||||||
import { during, observe } from "./dataspace.js";
|
import { during, observe } from "../runtime/dataspace.js";
|
||||||
import { Assertion, Handle, Ref, Turn } from "./actor.js";
|
import { Assertion, Handle, Ref, Turn } from "../runtime/actor.js";
|
||||||
import { attachReadline } from './readline.js';
|
import { attachReadline } from './readline.js';
|
||||||
|
|
||||||
export default function (t: Turn, ds: Ref) {
|
export default function (t: Turn, ds: Ref) {
|
||||||
|
@ -27,7 +27,7 @@ export default function (t: Turn, ds: Ref) {
|
||||||
});
|
});
|
||||||
|
|
||||||
attachReadline(t, {
|
attachReadline(t, {
|
||||||
retract(t) { t.stop(); },
|
retract(t) { t.stopActor(); },
|
||||||
message(t, line: string) {
|
message(t, line: string) {
|
||||||
if (line.toLowerCase().startsWith('/nick ')) {
|
if (line.toLowerCase().startsWith('/nick ')) {
|
||||||
updateUsername(t, line.slice(5).trimLeft());
|
updateUsername(t, line.slice(5).trimLeft());
|
|
@ -1,8 +1,8 @@
|
||||||
import { newKey } from './cryptography.js';
|
import { newKey } from '../transport/cryptography.js';
|
||||||
import { attenuate, KEY_LENGTH, mint, Caveat, Rewrite, sturdyEncode, validate } from './sturdy.js';
|
import { attenuate, KEY_LENGTH, mint, Caveat, Rewrite, sturdyEncode, validate } from '../transport/sturdy.js';
|
||||||
import * as RW from './rewrite.js';
|
import * as RW from '../runtime/rewrite.js';
|
||||||
import { Bytes, Dictionary } from '@preserves/core';
|
import { Bytes, Dictionary } from '@preserves/core';
|
||||||
import { Ref } from 'actor.js';
|
import { Ref } from '../runtime/actor.js';
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const m1 = await mint('hello world', new Bytes(KEY_LENGTH));
|
const m1 = await mint('hello world', new Bytes(KEY_LENGTH));
|
|
@ -1,5 +1,5 @@
|
||||||
import * as _ from "@preserves/core";
|
import * as _ from "@preserves/core";
|
||||||
import * as _i_Actor from "../actor";
|
import * as _i_Actor from "../runtime/actor";
|
||||||
|
|
||||||
export const $BoxState = Symbol.for("BoxState");
|
export const $BoxState = Symbol.for("BoxState");
|
||||||
export const $SetBox = Symbol.for("SetBox");
|
export const $SetBox = Symbol.for("SetBox");
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as _ from "@preserves/core";
|
import * as _ from "@preserves/core";
|
||||||
import * as _i_Actor from "../actor";
|
import * as _i_Actor from "../runtime/actor";
|
||||||
|
|
||||||
export const $Observe = Symbol.for("Observe");
|
export const $Observe = Symbol.for("Observe");
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as _ from "@preserves/core";
|
import * as _ from "@preserves/core";
|
||||||
import * as _i_Protocol from "../protocol";
|
import * as _i_Protocol from "../transport/protocol";
|
||||||
|
|
||||||
export const $assert = Symbol.for("assert");
|
export const $assert = Symbol.for("assert");
|
||||||
export const $message = Symbol.for("message");
|
export const $message = Symbol.for("message");
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as _ from "@preserves/core";
|
import * as _ from "@preserves/core";
|
||||||
import * as _i_Actor from "../actor";
|
import * as _i_Actor from "../runtime/actor";
|
||||||
|
|
||||||
export const $claimNick = Symbol.for("claimNick");
|
export const $claimNick = Symbol.for("claimNick");
|
||||||
export const $joinedUser = Symbol.for("joinedUser");
|
export const $joinedUser = Symbol.for("joinedUser");
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as _ from "@preserves/core";
|
import * as _ from "@preserves/core";
|
||||||
import * as _i_Actor from "../actor";
|
import * as _i_Actor from "../runtime/actor";
|
||||||
|
|
||||||
export const $Present = Symbol.for("Present");
|
export const $Present = Symbol.for("Present");
|
||||||
export const $Says = Symbol.for("Says");
|
export const $Says = Symbol.for("Says");
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as _ from "@preserves/core";
|
import * as _ from "@preserves/core";
|
||||||
import * as _i_Actor from "../actor";
|
import * as _i_Actor from "../runtime/actor";
|
||||||
|
|
||||||
export const $Boolean = Symbol.for("Boolean");
|
export const $Boolean = Symbol.for("Boolean");
|
||||||
export const $ByteString = Symbol.for("ByteString");
|
export const $ByteString = Symbol.for("ByteString");
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
import * as _ from "@preserves/core";
|
import * as _ from "@preserves/core";
|
||||||
|
import * as _i_Actor from "../runtime/actor";
|
||||||
|
|
||||||
export const $Instance = Symbol.for("Instance");
|
export const $Instance = Symbol.for("Instance");
|
||||||
|
|
||||||
export type _ptr = never;
|
export type _ptr = _i_Actor.Ref;
|
||||||
|
|
||||||
export type _val = _.Value<_ptr>;
|
export type _val = _.Value<_ptr>;
|
||||||
|
|
||||||
export type Instance = {"name": string, "argument": _val};
|
export type Instance = {"name": string, "argument": _val};
|
||||||
|
|
||||||
|
|
||||||
export const _toPtr = () => { throw new _.DecodeError("Pointers forbidden"); };
|
export const _toPtr = (v: _val) => {let result: undefined | _ptr; result = _i_Actor.toRef(v); return result;};
|
||||||
|
|
||||||
export function Instance({name, argument}: {name: string, argument: _val}): Instance {return {"name": name, "argument": argument};}
|
export function Instance({name, argument}: {name: string, argument: _val}): Instance {return {"name": name, "argument": argument};}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { Assertion, Entity, Handle, LocalAction, Ref, Turn } from 'actor';
|
import { Assertion, Entity, Handle, LocalAction, Ref, Turn } from 'runtime/actor';
|
||||||
import { Dictionary, IdentityMap, is, Record, Tuple } from '@preserves/core';
|
import { Dictionary, IdentityMap, is, Record, Tuple } from '@preserves/core';
|
||||||
import { Bag, ChangeDescription } from './bag';
|
import { Bag, ChangeDescription } from './bag';
|
||||||
|
|
||||||
import { fromObserve, toObserve, Observe } from './gen/dataspace';
|
import { fromObserve, toObserve, Observe } from '../gen/dataspace';
|
||||||
export * from './gen/dataspace';
|
export * from '../gen/dataspace';
|
||||||
|
|
||||||
// Q. Why keep "Observe"? Why not do the clever trick of asserting the
|
// Q. Why keep "Observe"? Why not do the clever trick of asserting the
|
||||||
// observer, and having the dataspace read the implicit pattern it's
|
// observer, and having the dataspace read the implicit pattern it's
|
|
@ -23,8 +23,8 @@ import {
|
||||||
TRef,
|
TRef,
|
||||||
Template,
|
Template,
|
||||||
_val,
|
_val,
|
||||||
} from './gen/sturdy.js';
|
} from '../gen/sturdy.js';
|
||||||
export * from './gen/sturdy.js';
|
export * from '../gen/sturdy.js';
|
||||||
|
|
||||||
export type Bindings = { [name: string]: Assertion };
|
export type Bindings = { [name: string]: Assertion };
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Bytes, Reader } from '@preserves/core';
|
import { Bytes, Reader } from '@preserves/core';
|
||||||
import { fromSturdyRef, toSturdyRef, toCaveat, attenuate, sturdyDecode, sturdyEncode } from '../sturdy.js';
|
import { fromSturdyRef, toSturdyRef, toCaveat, attenuate, sturdyDecode, sturdyEncode } from '../transport/sturdy.js';
|
||||||
|
|
||||||
const [ base, pat ] = process.argv.slice(2);
|
const [ base, pat ] = process.argv.slice(2);
|
||||||
const baseCap = toSturdyRef(sturdyDecode(Bytes.fromHex(base ?? '')));
|
const baseCap = toSturdyRef(sturdyDecode(Bytes.fromHex(base ?? '')));
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Attenuation, toAttenuation } from './gen/sturdy.js';
|
import { Attenuation, toAttenuation } from '../gen/sturdy.js';
|
||||||
import * as IO from './gen/protocol.js';
|
import * as IO from '../gen/protocol.js';
|
||||||
import { Assertion, Ref } from './actor.js';
|
import { Assertion, Ref } from '../runtime/actor.js';
|
||||||
import { mapPointers } from '@preserves/core';
|
import { mapPointers } from '@preserves/core';
|
||||||
import { pointerNotAllowed } from './sturdy.js';
|
import { pointerNotAllowed } from './sturdy.js';
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { Actor, Assertion, Entity, Facet, Handle, Ref, Turn } from './actor.js';
|
import { Actor, Assertion, Entity, Facet, Handle, Ref, Turn } from '../runtime/actor.js';
|
||||||
import { BytesLike, canonicalString, Decoder, encode, FlexMap, IdentityMap, mapPointers, underlying, Value } from '@preserves/core';
|
import { BytesLike, canonicalString, Decoder, encode, FlexMap, IdentityMap, mapPointers, underlying, Value } from '@preserves/core';
|
||||||
import * as IO from './gen/protocol.js';
|
import * as IO from '../gen/protocol.js';
|
||||||
import { myRef, toWireRef, WireRef, WireSymbol, yourRef } from './protocol.js';
|
import { myRef, toWireRef, WireRef, WireSymbol, yourRef } from './protocol.js';
|
||||||
import { queueTask } from './task.js';
|
import { queueTask } from '../runtime/task.js';
|
||||||
import { attenuate } from './rewrite.js';
|
import { attenuate } from '../runtime/rewrite.js';
|
||||||
import { Attenuation, fromAttenuation } from './gen/sturdy.js';
|
import { Attenuation, fromAttenuation } from '../gen/sturdy.js';
|
||||||
import { pointerNotAllowed } from './sturdy.js';
|
import { pointerNotAllowed } from './sturdy.js';
|
||||||
|
|
||||||
export class SyncPeerEntity implements Entity {
|
export class SyncPeerEntity implements Entity {
|
|
@ -8,8 +8,8 @@
|
||||||
|
|
||||||
import { mac } from './cryptography.js';
|
import { mac } from './cryptography.js';
|
||||||
import { Bytes, decode, encode, is } from '@preserves/core';
|
import { Bytes, decode, encode, is } from '@preserves/core';
|
||||||
import * as S from './gen/sturdy.js';
|
import * as S from '../gen/sturdy.js';
|
||||||
export * from './gen/sturdy.js';
|
export * from '../gen/sturdy.js';
|
||||||
|
|
||||||
export type SturdyValue = S._val;
|
export type SturdyValue = S._val;
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
import { Actor, Assertion, Turn } from '../runtime/actor.js';
|
||||||
|
import { Relay, spawnRelay } from '../transport/relay.js';
|
||||||
|
import { Worker } from 'worker_threads';
|
||||||
|
import { fromInstance, Instance } from '../gen/worker.js';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
export function spawnWorker(t: Turn, moduleName: string, arg: Assertion) {
|
||||||
|
const w = new Worker(path.join(__dirname, 'wload.js'));
|
||||||
|
const reenable = t.activeFacet.preventInertCheck();
|
||||||
|
spawnRelay(t, {
|
||||||
|
packetWriter: bs => w.postMessage(bs),
|
||||||
|
setup(t: Turn, r: Relay) {
|
||||||
|
w.on('message', bs => r.accept(bs));
|
||||||
|
w.on('error', err => Turn.for(t.activeFacet, t => t.crash(err)));
|
||||||
|
w.on('exit', code => Turn.for(t.activeFacet, t => {
|
||||||
|
if (code === 0) {
|
||||||
|
t.stopActor();
|
||||||
|
} else {
|
||||||
|
t.crash(new Error(`Worker crashed with code ${code}`));
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
initialOid: 0,
|
||||||
|
}).then(factory => {
|
||||||
|
reenable();
|
||||||
|
new Actor(t => t.assert(factory, fromInstance(Instance({
|
||||||
|
name: moduleName,
|
||||||
|
argument: arg,
|
||||||
|
}))));
|
||||||
|
});
|
||||||
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
// Web Worker loader
|
// Web Worker loader
|
||||||
|
|
||||||
import { Actor, Turn, Assertion, Ref, __setNextActorId } from './actor.js';
|
import { Actor, Turn, Assertion, Ref, __setNextActorId } from '../runtime/actor.js';
|
||||||
import { Record } from '@preserves/core';
|
import { Record } from '@preserves/core';
|
||||||
import { parentPort, threadId } from 'worker_threads';
|
import { parentPort, threadId } from 'worker_threads';
|
||||||
import { Relay, spawnRelay } from './relay.js';
|
import { Relay, spawnRelay } from '../transport/relay.js';
|
||||||
|
|
||||||
const _Instance = Symbol.for('Instance');
|
const _Instance = Symbol.for('Instance');
|
||||||
const Instance = Record.makeConstructor<{moduleName: string, arg: Assertion}>()(
|
const Instance = Record.makeConstructor<{moduleName: string, arg: Assertion}>()(
|
Loading…
Reference in New Issue