Cleaning some dependencies
parent
7b955ef26a
commit
5c8332a109
|
@ -1,4 +1,4 @@
|
||||||
import { path } from "./lib/deps_server.ts";
|
import * as path from "@std/path";
|
||||||
import * as esbuild from "esbuild";
|
import * as esbuild from "esbuild";
|
||||||
import { compileManifests } from "./cmd/compile.ts";
|
import { compileManifests } from "./cmd/compile.ts";
|
||||||
import { builtinPlugNames } from "./plugs/builtin_plugs.ts";
|
import { builtinPlugNames } from "./plugs/builtin_plugs.ts";
|
||||||
|
|
|
@ -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 { denoPlugins } from "@luca/esbuild-deno-loader";
|
||||||
import * as esbuild from "esbuild";
|
import * as esbuild from "esbuild";
|
||||||
import { bundleAssets } from "../lib/asset_bundle/builder.ts";
|
import { bundleAssets } from "../lib/asset_bundle/builder.ts";
|
||||||
|
|
|
@ -3,14 +3,11 @@ import type { ScriptObject } from "../plugs/index/script.ts";
|
||||||
import {
|
import {
|
||||||
LuaEnv,
|
LuaEnv,
|
||||||
LuaFunction,
|
LuaFunction,
|
||||||
LuaNativeJSFunction,
|
|
||||||
LuaRuntimeError,
|
LuaRuntimeError,
|
||||||
} from "$common/space_lua/runtime.ts";
|
} from "$common/space_lua/runtime.ts";
|
||||||
import { parse as parseLua } from "$common/space_lua/parse.ts";
|
import { parse as parseLua } from "$common/space_lua/parse.ts";
|
||||||
import { evalStatement } from "$common/space_lua/eval.ts";
|
import { evalStatement } from "$common/space_lua/eval.ts";
|
||||||
import { jsToLuaValue } from "$common/space_lua/runtime.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 {
|
import {
|
||||||
type PageRef,
|
type PageRef,
|
||||||
parsePageRef,
|
parsePageRef,
|
||||||
|
@ -18,7 +15,6 @@ import {
|
||||||
import type { ScriptEnvironment } from "$common/space_script.ts";
|
import type { ScriptEnvironment } from "$common/space_script.ts";
|
||||||
import { luaValueToJS } from "$common/space_lua/runtime.ts";
|
import { luaValueToJS } from "$common/space_lua/runtime.ts";
|
||||||
import type { ASTCtx } from "$common/space_lua/ast.ts";
|
import type { ASTCtx } from "$common/space_lua/ast.ts";
|
||||||
import { lua } from "@silverbulletmd/silverbullet/syscalls";
|
|
||||||
import type { ObjectQuery } from "@silverbulletmd/silverbullet/types";
|
import type { ObjectQuery } from "@silverbulletmd/silverbullet/types";
|
||||||
import { buildLuaEnv } from "$common/space_lua_api.ts";
|
import { buildLuaEnv } from "$common/space_lua_api.ts";
|
||||||
|
|
||||||
|
|
|
@ -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 { AssetBundle } from "./bundle.ts";
|
||||||
|
import { walk } from "@std/fs";
|
||||||
|
import { mime } from "mimetypes";
|
||||||
|
|
||||||
export async function bundleAssets(
|
export async function bundleAssets(
|
||||||
rootPath: string,
|
rootPath: string,
|
||||||
|
@ -39,7 +42,7 @@ export async function bundleFolder(
|
||||||
) {
|
) {
|
||||||
const bundle = new AssetBundle();
|
const bundle = new AssetBundle();
|
||||||
|
|
||||||
await Deno.mkdir(path.dirname(bundlePath), { recursive: true });
|
await Deno.mkdir(dirname(bundlePath), { recursive: true });
|
||||||
for await (
|
for await (
|
||||||
const { path: filePath } of walk(rootPath, { includeDirs: false })
|
const { path: filePath } of walk(rootPath, { includeDirs: false })
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
import type { KV, KvKey } from "../../plug-api/types.ts";
|
import type { KV, KvKey } from "../../plug-api/types.ts";
|
||||||
import type { KvPrimitives, KvQueryOptions } from "./kv_primitives.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 sep = "\0";
|
||||||
const objectStoreName = "data";
|
const objectStoreName = "data";
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
// Remember to keep in sync with deno.json !
|
|
||||||
// We have to use different deps for client and server as esbuild doesn't
|
|
||||||
// support wildcard exporting. See https://github.com/evanw/esbuild/issues/1420
|
|
||||||
export {
|
|
||||||
type IDBPDatabase,
|
|
||||||
openDB,
|
|
||||||
} from "https://esm.sh/idb@7.1.1/with-async-ittr";
|
|
|
@ -1,9 +0,0 @@
|
||||||
// Remember to keep in sync with deno.json !
|
|
||||||
// We have to use different deps for client and server as esbuild doesn't
|
|
||||||
// support wildcard exporting. See https://github.com/evanw/esbuild/issues/1420
|
|
||||||
export { globToRegExp } from "@std/path";
|
|
||||||
export { walk } from "@std/fs";
|
|
||||||
export * as path from "@std/path";
|
|
||||||
export { mime } from "mimetypes";
|
|
||||||
export * as YAML from "@std/yaml";
|
|
||||||
export { Cron } from "https://deno.land/x/croner@4.4.1/src/croner.js";
|
|
|
@ -1,5 +1,5 @@
|
||||||
import type { Hook, Manifest } from "../types.ts";
|
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 { System } from "../system.ts";
|
||||||
import type { CronHookT } from "$lib/manifest.ts";
|
import type { CronHookT } from "$lib/manifest.ts";
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import type { FileMeta } from "../../../plug-api/types.ts";
|
import type { FileMeta } from "../../../plug-api/types.ts";
|
||||||
import { assert } from "@std/assert";
|
import { assert } from "@std/assert";
|
||||||
import { path } from "../../deps_server.ts";
|
|
||||||
import fileSystemSyscalls from "./fs.deno.ts";
|
import fileSystemSyscalls from "./fs.deno.ts";
|
||||||
|
import { dirname, resolve } from "@std/path";
|
||||||
|
|
||||||
Deno.test("Test FS operations", async () => {
|
Deno.test("Test FS operations", async () => {
|
||||||
const thisFolder = path.resolve(
|
const thisFolder = resolve(
|
||||||
path.dirname(new URL(import.meta.url).pathname),
|
dirname(new URL(import.meta.url).pathname),
|
||||||
);
|
);
|
||||||
const syscalls = fileSystemSyscalls(thisFolder);
|
const syscalls = fileSystemSyscalls(thisFolder);
|
||||||
const allFiles: FileMeta[] = await syscalls["fs.listFiles"](
|
const allFiles: FileMeta[] = await syscalls["fs.listFiles"](
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
import type { SysCallMapping } from "../system.ts";
|
import type { SysCallMapping } from "../system.ts";
|
||||||
import { mime, path, walk } from "../../deps_server.ts";
|
|
||||||
import type { FileMeta } from "../../../plug-api/types.ts";
|
import type { FileMeta } from "../../../plug-api/types.ts";
|
||||||
import { base64DecodeDataUrl, base64Encode } from "../../crypto.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 {
|
export default function fileSystemSyscalls(root = "/"): SysCallMapping {
|
||||||
function resolvedPath(p: string): string {
|
function resolvedPath(p: string): string {
|
||||||
p = path.resolve(root, p);
|
p = resolve(root, p);
|
||||||
if (!p.startsWith(root)) {
|
if (!p.startsWith(root)) {
|
||||||
throw Error("Path outside root, not allowed");
|
throw Error("Path outside root, not allowed");
|
||||||
}
|
}
|
||||||
|
@ -48,7 +50,7 @@ export default function fileSystemSyscalls(root = "/"): SysCallMapping {
|
||||||
encoding: "utf8" | "dataurl" = "utf8",
|
encoding: "utf8" | "dataurl" = "utf8",
|
||||||
): Promise<FileMeta> => {
|
): Promise<FileMeta> => {
|
||||||
const p = resolvedPath(filePath);
|
const p = resolvedPath(filePath);
|
||||||
await Deno.mkdir(path.dirname(p), { recursive: true });
|
await Deno.mkdir(dirname(p), { recursive: true });
|
||||||
if (encoding === "utf8") {
|
if (encoding === "utf8") {
|
||||||
await Deno.writeTextFile(p, text);
|
await Deno.writeTextFile(p, text);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -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
|
// @ts-ignore: syscall is a global function
|
||||||
globalThis.syscall = (name: string, ...args: readonly any[]) => {
|
globalThis.syscall = (name: string, ...args: readonly any[]) => {
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case "yaml.parse":
|
case "yaml.parse":
|
||||||
return Promise.resolve(YAML.parse(args[0]));
|
return Promise.resolve(parseYaml(args[0]));
|
||||||
case "system.applyAttributeExtractors":
|
case "system.applyAttributeExtractors":
|
||||||
return Promise.resolve({});
|
return Promise.resolve({});
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue