Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
Structure update + Error tracking fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
scarletquasar committed Aug 5, 2023
1 parent 109038b commit 907134b
Show file tree
Hide file tree
Showing 61 changed files with 55 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { interopCache } from "logic/runtime/interop-cache-core";
import { Result } from "logic/partials/modules/std/functional/Result";
import { Result } from "logic/api/modules/std/functional/Result";
import { TableLike } from "types/internal/generic-types";
import { ConsoleColor } from "types/internal/console-types"

Expand Down Expand Up @@ -284,21 +284,31 @@ function timeEnd(
}

function write(target: string, color: ConsoleColor): Result<Error, []> {
if(typeof target != "string") {
interopCache.clinet.write(toLoggableOutput(target), color);
return Result.right([]);
try {
if (typeof target != "string") {
interopCache.clinet.write(toLoggableOutput(target), color);
return Result.right([]);
}

return Result.left(new Error("Invalid write value"));
}
catch (e) {
return Result.left(e);
}

return Result.left(new Error("Invalid write value"));
}

function writeLine(target: string, color: ConsoleColor): Result<Error, []> {
if(typeof target != "string") {
interopCache.clinet.writeLine(toLoggableOutput(target), color);
return Result.right([]);
try {
if (typeof target != "string") {
interopCache.clinet.writeLine(toLoggableOutput(target), color);
return Result.right([]);
}

return Result.left(new Error("Invalid write value"));
}
catch (e) {
return Result.left(e);
}

return Result.left(new Error("Invalid write value"));
}

export {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { clear, error, log, table, time, timeEnd, warn, write, writeLine } from "logic/partials/modules/console/console-core";
import { clear, error, log, table, time, timeEnd, warn, write, writeLine } from "logic/api/modules/console/console-core";

const console = {
time,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { _crypto } from "logic/partials/statics/_Crypto";
import { error } from "logic/partials/modules/console/console-core";
import { _nextTick } from "logic/partials/modules/std/async/_nextTick";
import { _crypto } from "logic/api/statics/_Crypto";
import { error } from "logic/api/modules/console/console-core";
import { _nextTick } from "logic/api/modules/std/async/_nextTick";
import { getStaticProperty } from "./dotnet-interop-core";
import { InteropMethod } from "types/internal/dotnet-interop-types";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import {
} from "types/internal/http-types";

//Logic imports
import { getStaticMethod } from "logic/partials/modules/dotnet/dotnet-interop-core";
import { _tryStringify } from "logic/partials/modules/std/json/_tryStringify";
import { _tryParse } from "logic/partials/modules/std/json/_tryParse";
import { _nextTick } from "logic/partials/modules/std/async/_nextTick";
import { getStaticMethod } from "logic/api/modules/dotnet/dotnet-interop-core";
import { _tryStringify } from "logic/api/modules/std/json/_tryStringify";
import { _tryParse } from "logic/api/modules/std/json/_tryParse";
import { _nextTick } from "logic/api/modules/std/async/_nextTick";
import { Melon } from "logic/index";
import { http } from "logic/partials/modules/http/http";
import { http } from "logic/api/modules/http/http";

function $static(response: any, type: `${string}/${string}`, headers: Record<string, any> = {}) {
const serialize = getStaticMethod("Newtonsoft.Json:JsonConvert:SerializeObject");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//Logic imports
import { request, requestAsync, fetch, app, $static, result } from "logic/partials/modules/http/http-basic-core"
import { request, requestAsync, fetch, app, $static, result } from "logic/api/modules/http/http-basic-core"

const http = {
_apps: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import type { OutputFriendly } from "types/internal/generic-types";
import type { EventType, EventCaller, EventAction } from "types/internal/runtime-types";

//Logic Imports
import { _crypto } from "logic/partials/statics/_Crypto";
import { _log } from "logic/partials/modules/console/_log";
import { _crypto } from "logic/api/statics/_Crypto";
import { _log } from "logic/api/modules/console/_log";

class Event implements OutputFriendly {
public name: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//Logic Imports
import { EventChain, Event } from "logic/partials/modules/runtime/runtime-event";
import { EventChain, Event } from "logic/api/modules/runtime/runtime-event";

const eventChain = new EventChain();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { _compare } from "logic/partials/modules/data/_compare";
import { _compare } from "logic/api/modules/data/_compare";

class AssertHandler {
static getProblems(assert: Assert) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { write, writeLine } from "logic/partials/modules/console/console-core";
import { write, writeLine } from "logic/api/modules/console/console-core";
import { Assert, AssertHandler } from "./Assert";

function test(description: string, handler: (assert: Assert) => void) {
Expand Down
25 changes: 12 additions & 13 deletions projects/core/logic/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
// Utilitary imports
import { setupEnvironmentVariables } from "logic/runtime/global-environment-core";
import { addPrototypeExtension } from "./partials/utils/generic/addPrototypeExtension";
import { addPrototypeExtension } from "./runtime/injections-core";
import { and } from "logic/runtime/global-extensions";

// Isolated imports
import { _Version } from "./partials/constructors/_Version"
import { _Version } from "./api/constructors/_Version"

// Module imports
import { console as _console } from "logic/partials/modules/console/console"
import { dotnet } from "./partials/modules/dotnet/dotnet"
import { _crypto } from "./partials/statics/_Crypto"
import { _fs } from "./partials/modules/fs/fs"
import { _guards } from "./partials/modules/guards/_guards"
import { http } from "./partials/modules/http/http"
import { _std } from "./partials/modules/std/_std"
import { _data } from "./partials/modules/data/_data"
import { testing } from "./partials/modules/testing/testing"
import { runtime } from "./partials/modules/runtime/runtime"
import { interopCache } from "./runtime/interop-cache-core";
import { console as _console } from "logic/api/modules/console/console"
import { dotnet } from "./api/modules/dotnet/dotnet"
import { _crypto } from "./api/statics/_Crypto"
import { _fs } from "./api/modules/fs/fs"
import { _guards } from "./api/modules/guards/_guards"
import { http } from "./api/modules/http/http"
import { _std } from "./api/modules/std/_std"
import { _data } from "./api/modules/data/_data"
import { testing } from "./api/modules/testing/testing"
import { runtime } from "./api/modules/runtime/runtime"

setupEnvironmentVariables();
addPrototypeExtension(Object, "and", and);
Expand Down
6 changes: 3 additions & 3 deletions projects/core/logic/runtime/global-environment-core.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { readText } from "logic/partials/modules/fs/fs-raw-file-management";
import { _setEnvironmentVariable } from "logic/partials/modules/std/environment/_setEnvironmentVariable";
import { readText } from "logic/api/modules/fs/fs-raw-file-management";
import { _setEnvironmentVariable } from "logic/api/modules/std/environment/_setEnvironmentVariable";
import { interopCache } from "logic/runtime/interop-cache-core";
import { _guards } from "logic/partials/modules/guards/_guards";
import { _guards } from "logic/api/modules/guards/_guards";
import { Primitive } from "types/internal/generic-types";

function setupEnvironmentVariables() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Unsafe: Can allow prototype pollution; Should not be exposed

function addPrototypeExtension(base: any, name: string, value: any) {
base["prototype"][name] = value;
}
Expand Down
2 changes: 1 addition & 1 deletion projects/core/logic/runtime/interop-cache-core.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getStaticMethod } from "logic/partials/modules/dotnet/dotnet-interop-core";
import { getStaticMethod } from "logic/api/modules/dotnet/dotnet-interop-core";

const interopCache = {
serialization: {
Expand Down
2 changes: 1 addition & 1 deletion projects/native/MelonRuntime.Core/Scripts/core.js

Large diffs are not rendered by default.

0 comments on commit 907134b

Please sign in to comment.