* Don't require auth for .ping * Finally introducing loggers * Remove file list caching from disk_space_primitives I don't think this is required anymore with the sync model * Simplification of space primitives and more tests * More reliable online status * Add .zed settings * Remove selfUpdate argument from `writeFile` no longer used - Add `sync` config schema and document sync options - Move sync config handling to client boot logic - Move BootConfig type to ui_types.ts - Remove sync env vars from server - Update documentation for sync and architecture * Improve sync logic and proxy routing for full sync state * Add BoxProxy for late-bound client and improve Lua boot - Add isMobile syscall for editor * Add concurrency to sync process and log indexing duration * Better service worker lifecycle management
60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
import type { SysCallMapping } from "../../lib/plugos/system.ts";
|
|
import type {
|
|
LuaCollectionQuery,
|
|
LuaQueryCollection,
|
|
} from "../../lib/space_lua/query_collection.ts";
|
|
import {
|
|
jsToLuaValue,
|
|
type LuaEnv,
|
|
type LuaStackFrame,
|
|
type LuaTable,
|
|
} from "../../lib/space_lua/runtime.ts";
|
|
|
|
import type { Client } from "../client.ts";
|
|
|
|
export function indexSyscalls(client: Client): SysCallMapping {
|
|
return {
|
|
"index.tag": (_ctx, tagName: string): LuaQueryCollection => {
|
|
return {
|
|
query: (
|
|
query: LuaCollectionQuery,
|
|
env: LuaEnv,
|
|
sf: LuaStackFrame,
|
|
): Promise<any[]> => {
|
|
return client.ds.luaQuery(
|
|
["idx", tagName],
|
|
query,
|
|
env,
|
|
sf,
|
|
(key, value: any) => {
|
|
const tag = key[1];
|
|
const tagDef = client.config.get<LuaTable | undefined>(
|
|
["tagDefinitions", tag],
|
|
undefined,
|
|
);
|
|
if (!tagDef || !tagDef.has("metatable")) {
|
|
// Return as is
|
|
return value;
|
|
}
|
|
// Convert to LuaTable
|
|
value = jsToLuaValue(value);
|
|
value.metatable = tagDef.get("metatable");
|
|
return value;
|
|
},
|
|
);
|
|
},
|
|
};
|
|
},
|
|
"index.ensureFullIndex": (_ctx) => {
|
|
return client.clientSystem.ensureFullIndex();
|
|
},
|
|
"lua:index.defineTag": (_ctx, tagDef: LuaTable) => {
|
|
// Using 'lua:' prefix to _not_ convert tagDef to a JS version (but keep original LuaTable)
|
|
if (!tagDef.has("name")) {
|
|
throw new Error("A tag name is required");
|
|
}
|
|
client.config.set(["tagDefinitions", tagDef.get("name")], tagDef);
|
|
},
|
|
};
|
|
}
|