* Moved YAML library import to index plug (so no async syscalls anymore) should speed things up * Merged task and item indexing * Merged tasks plug into index (questionable) * taskstate is now no longer a tag, but needs to be configured via configs
81 lines
2.6 KiB
TypeScript
81 lines
2.6 KiB
TypeScript
import { Config } from "../client/config.ts";
|
|
import { DataStore } from "../client/data/datastore.ts";
|
|
import { MemoryKvPrimitives } from "../client/data/memory_kv_primitives.ts";
|
|
import { DataStoreMQ } from "../client/data/mq.datastore.ts";
|
|
import { EventHook } from "../client/plugos/hooks/event.ts";
|
|
import {
|
|
dataStoreReadSyscalls,
|
|
dataStoreWriteSyscalls,
|
|
} from "../client/plugos/syscalls/datastore.ts";
|
|
import { eventSyscalls } from "../client/plugos/syscalls/event.ts";
|
|
import { indexSyscalls } from "../client/plugos/syscalls/index.ts";
|
|
import { jsonschemaSyscalls } from "../client/plugos/syscalls/jsonschema.ts";
|
|
import { languageSyscalls } from "../client/plugos/syscalls/language.ts";
|
|
import { luaSyscalls } from "../client/plugos/syscalls/lua.ts";
|
|
import { markdownSyscalls } from "../client/plugos/syscalls/markdown.ts";
|
|
import { mqSyscalls } from "../client/plugos/syscalls/mq.ts";
|
|
import {
|
|
spaceReadSyscalls,
|
|
spaceWriteSyscalls,
|
|
} from "../client/plugos/syscalls/space.ts";
|
|
import { systemSyscalls } from "../client/plugos/syscalls/system.ts";
|
|
import { System } from "../client/plugos/system.ts";
|
|
import { Space } from "../client/space.ts";
|
|
import { SpaceLuaEnvironment } from "../client/space_lua.ts";
|
|
import { DataStoreSpacePrimitives } from "../client/spaces/datastore_space_primitives.ts";
|
|
|
|
export function createMockSystem() {
|
|
const system = new System<any>();
|
|
const eventHook = new EventHook();
|
|
system.addHook(eventHook);
|
|
const kv = new MemoryKvPrimitives();
|
|
const spacePrimitives = new DataStoreSpacePrimitives(kv);
|
|
const ds = new DataStore(kv);
|
|
|
|
const space = new Space(spacePrimitives, eventHook);
|
|
const mq = new DataStoreMQ(ds, eventHook);
|
|
const config = new Config();
|
|
const clientMock: any = {
|
|
space,
|
|
config,
|
|
};
|
|
|
|
const clientSystemMock: any = {
|
|
system: system,
|
|
spaceLuaEnv: new SpaceLuaEnvironment(system),
|
|
};
|
|
clientMock.clientSystem = clientSystemMock;
|
|
|
|
system.registerSyscalls(
|
|
[],
|
|
eventSyscalls(eventHook, clientMock),
|
|
spaceReadSyscalls(clientMock),
|
|
spaceWriteSyscalls(clientMock),
|
|
markdownSyscalls(clientMock),
|
|
languageSyscalls(),
|
|
jsonschemaSyscalls(),
|
|
indexSyscalls(clientMock),
|
|
luaSyscalls(clientSystemMock),
|
|
mqSyscalls(mq),
|
|
dataStoreReadSyscalls(ds, clientSystemMock),
|
|
dataStoreWriteSyscalls(ds),
|
|
systemSyscalls(clientMock, false),
|
|
);
|
|
|
|
// @ts-ignore: global
|
|
globalThis.syscall = (name: string, ...args: any): Promise<any> => {
|
|
return system.localSyscall(name, args);
|
|
};
|
|
|
|
return {
|
|
system,
|
|
eventHook,
|
|
config,
|
|
kv,
|
|
spacePrimitives,
|
|
mq,
|
|
ds,
|
|
space,
|
|
};
|
|
}
|