Skip to content

Commit

Permalink
Cleaning some dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
zefhemel committed Oct 11, 2024
1 parent 7b955ef commit 5c8332a
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 34 deletions.
2 changes: 1 addition & 1 deletion build_plugs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { path } from "./lib/deps_server.ts";
import * as path from "@std/path";
import * as esbuild from "esbuild";
import { compileManifests } from "./cmd/compile.ts";
import { builtinPlugNames } from "./plugs/builtin_plugs.ts";
Expand Down
3 changes: 2 additions & 1 deletion cmd/compile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { path, YAML } from "../lib/deps_server.ts";
import * as path from "@std/path";
import * as YAML from "@std/yaml";
import { denoPlugins } from "@luca/esbuild-deno-loader";
import * as esbuild from "esbuild";
import { bundleAssets } from "../lib/asset_bundle/builder.ts";
Expand Down
4 changes: 0 additions & 4 deletions common/space_lua.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,18 @@ import type { ScriptObject } from "../plugs/index/script.ts";
import {
LuaEnv,
LuaFunction,
LuaNativeJSFunction,
LuaRuntimeError,
} from "$common/space_lua/runtime.ts";
import { parse as parseLua } from "$common/space_lua/parse.ts";
import { evalStatement } from "$common/space_lua/eval.ts";
import { jsToLuaValue } from "$common/space_lua/runtime.ts";
import { LuaBuiltinFunction } from "$common/space_lua/runtime.ts";
import { LuaTable } from "$common/space_lua/runtime.ts";
import {
type PageRef,
parsePageRef,
} from "@silverbulletmd/silverbullet/lib/page_ref";
import type { ScriptEnvironment } from "$common/space_script.ts";
import { luaValueToJS } from "$common/space_lua/runtime.ts";
import type { ASTCtx } from "$common/space_lua/ast.ts";
import { lua } from "@silverbulletmd/silverbullet/syscalls";
import type { ObjectQuery } from "@silverbulletmd/silverbullet/types";
import { buildLuaEnv } from "$common/space_lua_api.ts";

Expand Down
7 changes: 5 additions & 2 deletions lib/asset_bundle/builder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { globToRegExp, mime, path, walk } from "../deps_server.ts";
// import { globToRegExp, mime, path, walk } from "../deps_server.ts";
import { dirname, globToRegExp } from "@std/path";
import { AssetBundle } from "./bundle.ts";
import { walk } from "@std/fs";
import { mime } from "mimetypes";

export async function bundleAssets(
rootPath: string,
Expand Down Expand Up @@ -39,7 +42,7 @@ export async function bundleFolder(
) {
const bundle = new AssetBundle();

await Deno.mkdir(path.dirname(bundlePath), { recursive: true });
await Deno.mkdir(dirname(bundlePath), { recursive: true });
for await (
const { path: filePath } of walk(rootPath, { includeDirs: false })
) {
Expand Down
5 changes: 4 additions & 1 deletion lib/data/indexeddb_kv_primitives.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type { KV, KvKey } from "../../plug-api/types.ts";
import type { KvPrimitives, KvQueryOptions } from "./kv_primitives.ts";
import { type IDBPDatabase, openDB } from "../deps_client.ts";
import {
type IDBPDatabase,
openDB,
} from "https://esm.sh/idb@7.1.1/with-async-ittr";

const sep = "\0";
const objectStoreName = "data";
Expand Down
7 changes: 0 additions & 7 deletions lib/deps_client.ts

This file was deleted.

9 changes: 0 additions & 9 deletions lib/deps_server.ts

This file was deleted.

2 changes: 1 addition & 1 deletion lib/plugos/hooks/cron.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Hook, Manifest } from "../types.ts";
import { Cron } from "../../deps_server.ts";
import { Cron } from "https://deno.land/x/croner@4.4.1/src/croner.js";
import type { System } from "../system.ts";
import type { CronHookT } from "$lib/manifest.ts";

Expand Down
6 changes: 3 additions & 3 deletions lib/plugos/syscalls/fs.deno.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { FileMeta } from "../../../plug-api/types.ts";
import { assert } from "@std/assert";
import { path } from "../../deps_server.ts";
import fileSystemSyscalls from "./fs.deno.ts";
import { dirname, resolve } from "@std/path";

Deno.test("Test FS operations", async () => {
const thisFolder = path.resolve(
path.dirname(new URL(import.meta.url).pathname),
const thisFolder = resolve(
dirname(new URL(import.meta.url).pathname),
);
const syscalls = fileSystemSyscalls(thisFolder);
const allFiles: FileMeta[] = await syscalls["fs.listFiles"](
Expand Down
8 changes: 5 additions & 3 deletions lib/plugos/syscalls/fs.deno.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type { SysCallMapping } from "../system.ts";
import { mime, path, walk } from "../../deps_server.ts";
import type { FileMeta } from "../../../plug-api/types.ts";
import { base64DecodeDataUrl, base64Encode } from "../../crypto.ts";
import { dirname, resolve } from "@std/path";
import { mime } from "mimetypes";
import { walk } from "@std/fs";

export default function fileSystemSyscalls(root = "/"): SysCallMapping {
function resolvedPath(p: string): string {
p = path.resolve(root, p);
p = resolve(root, p);
if (!p.startsWith(root)) {
throw Error("Path outside root, not allowed");
}
Expand Down Expand Up @@ -48,7 +50,7 @@ export default function fileSystemSyscalls(root = "/"): SysCallMapping {
encoding: "utf8" | "dataurl" = "utf8",
): Promise<FileMeta> => {
const p = resolvedPath(filePath);
await Deno.mkdir(path.dirname(p), { recursive: true });
await Deno.mkdir(dirname(p), { recursive: true });
if (encoding === "utf8") {
await Deno.writeTextFile(p, text);
} else {
Expand Down
4 changes: 2 additions & 2 deletions plug-api/lib/syscall_mock.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { YAML } from "../../lib/deps_server.ts";
import { parse as parseYaml } from "@std/yaml";

// @ts-ignore: syscall is a global function
globalThis.syscall = (name: string, ...args: readonly any[]) => {
switch (name) {
case "yaml.parse":
return Promise.resolve(YAML.parse(args[0]));
return Promise.resolve(parseYaml(args[0]));
case "system.applyAttributeExtractors":
return Promise.resolve({});
default:
Expand Down

0 comments on commit 5c8332a

Please sign in to comment.