...
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -4,7 +4,9 @@ target
|
||||
# for nix
|
||||
result
|
||||
dist
|
||||
rust_dist
|
||||
node_modules
|
||||
.env
|
||||
|
||||
# I put testing stuff for this projekt that I don't want to push to github into a folder called gitignore
|
||||
gitignore
|
||||
|
||||
19
.zed/tasks.json
Normal file
19
.zed/tasks.json
Normal file
@@ -0,0 +1,19 @@
|
||||
// Project tasks configuration. See https://zed.dev/docs/tasks for documentation.
|
||||
//
|
||||
// Example:
|
||||
[
|
||||
{
|
||||
"label": "obsidian dev",
|
||||
"command": "deno run --config ./packages/ppc/platform/obsidian/deno.json build",
|
||||
"use_new_terminal": false,
|
||||
"allow_concurrent_runs": false,
|
||||
"hide": "on_success",
|
||||
},
|
||||
{
|
||||
"label": "obsidian prod",
|
||||
"command": "deno run --config ./packages/ppc/platform/obsidian/deno.json build && mkdir -p $PPC_DEV_OBSIDIAN_PROD_VAULT_PLUGINS_DIR/ppc && cp -r ./packages/ppc/platform/obsidian/dist/* $PPC_DEV_OBSIDIAN_PROD_VAULT_PLUGINS_DIR/ppc",
|
||||
"use_new_terminal": false,
|
||||
"allow_concurrent_runs": false,
|
||||
"hide": "on_success",
|
||||
},
|
||||
]
|
||||
12
Cargo.toml
12
Cargo.toml
@@ -1,10 +1,10 @@
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
members = [
|
||||
"crates/mize",
|
||||
#"crates/vic",
|
||||
"crates/ppc",
|
||||
"crates/marts",
|
||||
"crates/macro_mize",
|
||||
#"crates/mme",
|
||||
"packages/mize",
|
||||
#"packages/vic",
|
||||
"packages/ppc",
|
||||
"packages/marts",
|
||||
"packages/ac_mize_macros",
|
||||
#"packages/mme",
|
||||
]
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
import esbuild from "esbuild";
|
||||
import process from "process";
|
||||
import builtins from "builtin-modules";
|
||||
|
||||
const banner =
|
||||
`/*
|
||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||
*/
|
||||
`;
|
||||
|
||||
const prod = (process.argv[2] === "production");
|
||||
|
||||
const context = await esbuild.context({
|
||||
banner: {
|
||||
js: banner,
|
||||
},
|
||||
entryPoints: ["plugin.ts"],
|
||||
bundle: true,
|
||||
external: [
|
||||
"obsidian",
|
||||
"electron",
|
||||
"@codemirror/autocomplete",
|
||||
"@codemirror/collab",
|
||||
"@codemirror/commands",
|
||||
"@codemirror/language",
|
||||
"@codemirror/lint",
|
||||
"@codemirror/search",
|
||||
"@codemirror/state",
|
||||
"@codemirror/view",
|
||||
"@lezer/common",
|
||||
"@lezer/highlight",
|
||||
"@lezer/lr",
|
||||
...builtins],
|
||||
format: "cjs",
|
||||
target: "es2020",
|
||||
logLevel: "info",
|
||||
sourcemap: prod ? false : "inline",
|
||||
treeShaking: true,
|
||||
outfile: "dist/main.js",
|
||||
loader: {
|
||||
".wasm": "binary",
|
||||
".workerjs": "text"
|
||||
},
|
||||
define: {
|
||||
"import.meta.url": '"obsidian-plugin"'
|
||||
},
|
||||
});
|
||||
|
||||
if (prod) {
|
||||
await context.rebuild();
|
||||
process.exit(0);
|
||||
} else {
|
||||
await context.watch();
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
import esbuild from "esbuild";
|
||||
import process from "process";
|
||||
import builtins from "builtin-modules";
|
||||
|
||||
const banner =
|
||||
`/*
|
||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||
if you want to view the source, please visit the github repository of this plugin
|
||||
*/
|
||||
`;
|
||||
|
||||
const prod = (process.argv[2] === "production");
|
||||
|
||||
const context = await esbuild.context({
|
||||
banner: {
|
||||
js: banner,
|
||||
},
|
||||
entryPoints: ["./plugin.ts"],
|
||||
bundle: true,
|
||||
external: [
|
||||
"obsidian",
|
||||
"electron",
|
||||
"@codemirror/autocomplete",
|
||||
"@codemirror/collab",
|
||||
"@codemirror/commands",
|
||||
"@codemirror/language",
|
||||
"@codemirror/lint",
|
||||
"@codemirror/search",
|
||||
"@codemirror/state",
|
||||
"@codemirror/view",
|
||||
"@lezer/common",
|
||||
"@lezer/highlight",
|
||||
"@lezer/lr",
|
||||
...builtins],
|
||||
format: "cjs",
|
||||
target: "es2018",
|
||||
logLevel: "info",
|
||||
sourcemap: prod ? false : "inline",
|
||||
treeShaking: true,
|
||||
outfile: "dist/main.js",
|
||||
minify: false,
|
||||
});
|
||||
|
||||
if (prod) {
|
||||
await context.rebuild();
|
||||
process.exit(0);
|
||||
} else {
|
||||
await context.watch();
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
{
|
||||
"name": "ppc-obsidian-plugin",
|
||||
"version": "0.1.0",
|
||||
"description": "Turnes obsidian into an PPC client",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"build:rust": "wasm-pack -vvvvv build -d src/platform/obsidian/rust_dist --target web --no-default-features --features target-obsidian",
|
||||
"build": "npm run build:rust && mkdir -p dist && touch dist/.hotreload && cp manifest.json dist && node esbuild.config.js production",
|
||||
"dev": ""
|
||||
},
|
||||
"keywords": [
|
||||
"obsidian",
|
||||
"plugin"
|
||||
],
|
||||
"author": "c2vi",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@flowershow/remark-wiki-link": "^2.0.4",
|
||||
"@instantdb/admin": "^0.21.3",
|
||||
"@instantdb/react": "^0.20.28",
|
||||
"@react-oauth/google": "^0.12.2",
|
||||
"esbuild": "^0.27.3",
|
||||
"mdast": "^3.0.0",
|
||||
"react": "19.1.0",
|
||||
"react-dom": "19.1.0",
|
||||
"remark-frontmatter": "^5.0.0",
|
||||
"remark-gfm": "^4.0.1",
|
||||
"remark-parse": "^11.0.0",
|
||||
"remark-stringify": "^11.0.0",
|
||||
"unified": "^11.0.5",
|
||||
"unist-util-visit": "^5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "^4",
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^19",
|
||||
"@types/react-dom": "^19",
|
||||
"@wasm-tool/rollup-plugin-rust": "^3.1.4",
|
||||
"binaryen": "^125.0.0",
|
||||
"builtin-modules": "3.3.0",
|
||||
"obsidian": "latest",
|
||||
"tailwindcss": "^4",
|
||||
"tslib": "^2.6.2",
|
||||
"typescript": "^5.5.4"
|
||||
}
|
||||
}
|
||||
2128
crates/ppc/src/platform/obsidian/pnpm-lock.yaml
generated
2128
crates/ppc/src/platform/obsidian/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,36 +0,0 @@
|
||||
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
||||
import commonjs from "@rollup/plugin-commonjs";
|
||||
import { base64 } from "rollup-plugin-base64";
|
||||
import typescript from "@rollup/plugin-typescript";
|
||||
import rust from "@wasm-tool/rollup-plugin-rust";
|
||||
|
||||
const banner = `/*
|
||||
THIS IS A GENERATED/BUNDLED FILE BY ROLLUP
|
||||
if you want to view the source visit the plugins github repository
|
||||
*/
|
||||
`;
|
||||
|
||||
export default {
|
||||
input: "plugin.ts",
|
||||
output: {
|
||||
file: "dist/main.js",
|
||||
sourcemap: "inline",
|
||||
format: "cjs",
|
||||
exports: "default",
|
||||
banner,
|
||||
},
|
||||
external: ["obsidian"],
|
||||
plugins: [
|
||||
//nodeResolve({ browser: true }),
|
||||
//commonjs(),
|
||||
//base64({ include: "**/*.wasm" }),
|
||||
typescript(),
|
||||
rust({
|
||||
inlineWasm: true,
|
||||
verbose: true,
|
||||
extraArgs: {
|
||||
cargo: ["--no-default-features", "--features", "target-obsidian"],
|
||||
},
|
||||
}),
|
||||
],
|
||||
};
|
||||
@@ -1 +0,0 @@
|
||||
cargo rustc --lib --target wasm32-unknown-unknown --crate-type cdylib --release --config 'profile.release.panic="abort"' --config profile.release.lto=true --config profile.release.codegen-units=1 --config profile.release.strip=true -Z panic-immediate-abort -Z build-std=panic_abort,core,std,alloc,proc_macro -Z build-std-features=optimize_for_size --config build.rustflags=["-Z","location-detail=none","-Z","fmt-debug=none"] --no-default-features --features target-obsidian
|
||||
4
deno.json
Normal file
4
deno.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"workspace": ["./packages/ppc/platform/obsidian", "./packages/marts"],
|
||||
"imports": {}
|
||||
}
|
||||
0
crates/mize/src/core/types/mod.rs → mize
Normal file → Executable file
0
crates/mize/src/core/types/mod.rs → mize
Normal file → Executable file
@@ -13,3 +13,6 @@ mize = { path = "../mize/", default-features = false }
|
||||
default = ["target-os"]
|
||||
target-os = [ "clap", "mize/target-os" ]
|
||||
target-wasm = [ "mize/target-wasm" ]
|
||||
|
||||
[lib]
|
||||
path = "lib.rs"
|
||||
170
packages/marts/c2vi/obsidian-canvas-patch.ts
Normal file
170
packages/marts/c2vi/obsidian-canvas-patch.ts
Normal file
@@ -0,0 +1,170 @@
|
||||
export function c2vi_obsidian_canvas_patch(mize: any) {
|
||||
const plugin = mize.get_part_native("obsidian");
|
||||
|
||||
window.pc = patchCanvas;
|
||||
window.upc = () => {
|
||||
unpatchCanvas(plugin, plugin.app.workspace.activeLeaf);
|
||||
};
|
||||
|
||||
console.log("hereeeeeeeeeeeeeeeee");
|
||||
// canvas patching
|
||||
plugin.registerEvent(
|
||||
plugin.app.workspace.on("file-open", (file: any) => {
|
||||
if (file?.extension === "canvas") {
|
||||
maybePathCanvas(plugin, plugin.app.workspace.activeLeaf);
|
||||
}
|
||||
}),
|
||||
);
|
||||
plugin.registerEvent(
|
||||
plugin.app.workspace.on("active-leaf-change", (file: any) => {
|
||||
if (file?.extension === "canvas") {
|
||||
maybePathCanvas(plugin, plugin.app.workspace.activeLeaf);
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const maybePathCanvas = (plugin: PPCObsidianPlugin, leaf: any | null) => {
|
||||
console.log("maybePathCanvas called");
|
||||
const file = plugin.app.workspace.getActiveFile();
|
||||
|
||||
if (file?.extension !== "canvas") return;
|
||||
console.log("patching canvas.....");
|
||||
|
||||
const canvas = plugin.app.workspace.activeLeaf.view.canvas;
|
||||
if ("isPatched" in canvas) return;
|
||||
|
||||
patchCanvas(plugin, leaf, canvas);
|
||||
};
|
||||
|
||||
function patchCanvas(plugin: PPCObsidianPlugin, leaf: any, canvas: any) {
|
||||
canvas.isPatched = true;
|
||||
const canvasEl = canvas.canvasEl;
|
||||
const canvasWrapperEl = canvasEl.parentElement;
|
||||
const overlay = createDiv();
|
||||
overlay.setAttr("class", "c2vi-canvas-overlay");
|
||||
const canvas_card_menue = canvasWrapperEl.childNodes[1];
|
||||
canvasWrapperEl.insertBefore(overlay, canvas_card_menue);
|
||||
Object.assign(overlay.style, {
|
||||
position: "absolute",
|
||||
inset: "0",
|
||||
//zIndex: "1337",
|
||||
});
|
||||
overlay.addEventListener("contextmenu", (e) => {
|
||||
if (e.button === 2) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
e.stopImmediatePropagation();
|
||||
}
|
||||
});
|
||||
overlay.addEventListener("mouseout", (e) => {
|
||||
const menu = document.getElementsByClassName("menu")[0];
|
||||
if (!menu) return;
|
||||
menu.addEventListener("pointerup", (e) => {
|
||||
console.log("pointerup on menu", e);
|
||||
e.target.click();
|
||||
/*
|
||||
menu.dispatchEvent(
|
||||
new MouseEvent("mousedown", {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true,
|
||||
clientX: e.clientX,
|
||||
clientY: e.clientY,
|
||||
button: e.button,
|
||||
buttons: e.buttons,
|
||||
view: window,
|
||||
}),
|
||||
);
|
||||
*/
|
||||
});
|
||||
});
|
||||
|
||||
setupEventPropagation("pointerdown", PointerEvent, overlay, canvasWrapperEl);
|
||||
setupEventPropagation("pointerup", PointerEvent, overlay, canvasWrapperEl);
|
||||
setupEventPropagation("mousedown", MouseEvent, overlay, canvasWrapperEl);
|
||||
setupEventPropagation("mouseup", MouseEvent, overlay, canvasWrapperEl);
|
||||
setupEventPropagation("click", MouseEvent, overlay, canvasWrapperEl);
|
||||
setupEventPropagation("dragstart", DragEvent, overlay, canvasWrapperEl);
|
||||
setupEventPropagation("dragstop", DragEvent, overlay, canvasWrapperEl);
|
||||
|
||||
window.a = canvasWrapperEl;
|
||||
window.b = overlay;
|
||||
|
||||
const mouseEvents = [
|
||||
"mousedown",
|
||||
"mouseup",
|
||||
"click",
|
||||
"dblclick",
|
||||
//"mousemove",
|
||||
"mouseover",
|
||||
"mouseout",
|
||||
"wheel",
|
||||
];
|
||||
|
||||
mouseEvents.forEach((eventType) => {
|
||||
canvasWrapperEl.addEventListener(
|
||||
eventType,
|
||||
(event) => {
|
||||
console.log(`Mouse Event Triggered: ${event.type}`, event);
|
||||
},
|
||||
{ passive: true },
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function unpatchCanvas(plugin: PPCObsidianPlugin, leaf: any) {
|
||||
const canvas = plugin.app.workspace.activeLeaf.view.canvas;
|
||||
if (!canvas.isPatched) return;
|
||||
canvas.isPatched = false;
|
||||
const canvasEl = canvas.canvasEl;
|
||||
const canvasWrapperEl = canvasEl.parentElement;
|
||||
|
||||
const targets = canvasEl.querySelectorAll(":scope > .c2vi-canvas-overlay");
|
||||
|
||||
targets.forEach((child) => child.remove());
|
||||
}
|
||||
|
||||
function setupEventPropagation(type: string, evClass, overlay: any, target) {
|
||||
overlay.addEventListener(type, (originalEvent) => {
|
||||
originalEvent.stopPropagation();
|
||||
originalEvent.stopImmediatePropagation();
|
||||
originalEvent.preventDefault();
|
||||
const newEvent = new evClass(type, originalEvent);
|
||||
if (type == "pointerdown" && originalEvent.ctrlKey == true) {
|
||||
dispatchContextMenue(
|
||||
target,
|
||||
originalEvent.clientX,
|
||||
originalEvent.clientY,
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (type === "pointerdown") {
|
||||
window.downEv = newEvent;
|
||||
}
|
||||
if (type === "pointerup") {
|
||||
window.upEv = newEvent;
|
||||
}
|
||||
newEvent.isTrusted = true;
|
||||
console.log("original Event of", type, originalEvent);
|
||||
console.log("new Event of", type, newEvent);
|
||||
target.dispatchEvent(newEvent);
|
||||
});
|
||||
}
|
||||
|
||||
function dispatchContextMenue(target, x, y) {
|
||||
const newEvent = new PointerEvent("contextmenu", {
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
composed: true,
|
||||
view: window,
|
||||
clientX: x,
|
||||
clientY: y,
|
||||
pointerType: "mouse",
|
||||
button: 2,
|
||||
buttons: 2,
|
||||
pointerId: 1,
|
||||
isPrimary: true,
|
||||
});
|
||||
target.dispatchEvent(newEvent);
|
||||
}
|
||||
7
packages/marts/deno.json
Normal file
7
packages/marts/deno.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "@ppc/marts",
|
||||
"imports": {},
|
||||
"exports": {
|
||||
".": "./index.ts"
|
||||
}
|
||||
}
|
||||
2
packages/marts/index.ts
Normal file
2
packages/marts/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export { task_obsidian_otask_parse } from "./task/obsidian-otask-parse";
|
||||
export { c2vi_obsidian_canvas_patch } from "./c2vi/obsidian-canvas-patch";
|
||||
27
packages/marts/package.json
Normal file
27
packages/marts/package.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "marts",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"packageManager": "pnpm@10.15.1",
|
||||
"dependencies": {
|
||||
"@flowershow/remark-wiki-link": "^3.4.0",
|
||||
"builtin-modules": "^5.0.0",
|
||||
"esbuild": "^0.27.3",
|
||||
"mdast": "^3.0.0",
|
||||
"obsidian": "^1.12.2",
|
||||
"remark-frontmatter": "^5.0.0",
|
||||
"remark-gfm": "^4.0.1",
|
||||
"remark-parse": "^11.0.0",
|
||||
"remark-stringify": "^11.0.0",
|
||||
"typescript": "^5.9.3",
|
||||
"unified": "^11.0.5",
|
||||
"unist-util-visit": "^5.1.0"
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Plugin, TFile, Vault, MetadataCache } from "obsidian";
|
||||
import { id, i, init, InstaQLEntity } from "@instantdb/react";
|
||||
import remarkParse from "remark-parse";
|
||||
import remarkStringify from "remark-stringify";
|
||||
@@ -8,8 +7,6 @@ import { Root, Content, Heading, List, ListItem, Text } from "mdast";
|
||||
import remarkFrontmatter from "remark-frontmatter";
|
||||
import remarkGfm from "remark-gfm";
|
||||
import wikiLinkPlugin from "@flowershow/remark-wiki-link";
|
||||
import wasmBinary from "./rust_dist/ppc_bg.wasm";
|
||||
import * as wasmNamespace from "./rust_dist/ppc";
|
||||
|
||||
const OTASK_PROP_NAMES = ["short", "outcome", "priority"];
|
||||
const ACTION_PROP_NAMES = [];
|
||||
@@ -20,119 +17,18 @@ const REMARK = unified()
|
||||
.use(remarkGfm)
|
||||
.use(remarkStringify, { bullet: "-" });
|
||||
|
||||
export default class PPCObsidianPlugin extends Plugin {
|
||||
async onload() {
|
||||
// init mize from wasm
|
||||
const wasmModule = await import("./rust_dist/ppc.js");
|
||||
await wasmModule.default({ module_or_path: wasmBinary });
|
||||
console.log("hoooo wasmModule:", wasmModule);
|
||||
wasmModule.initSync();
|
||||
export function task_obsidian_otask_parse(mize: any) {
|
||||
const obsidian_plugin = mize.get_part_native("obsidian");
|
||||
|
||||
//console.log("");
|
||||
//const buffer = Uint8Array.from(atob(rustPlugin), (c) => c.charCodeAt(0));
|
||||
wasmModule.obsidian_mize_entrypoint();
|
||||
|
||||
// Listen for file modifications in the vault
|
||||
//this.registerEvent(
|
||||
//this.app.vault.on("modify", (file: TFile) => {
|
||||
//this.handleFileUpdate(file);
|
||||
//})
|
||||
//);
|
||||
|
||||
//this.registerView(
|
||||
//"system-c2-app",
|
||||
//(leaf) => new AppReactView(leaf, this)
|
||||
//);
|
||||
|
||||
this.addCommand({
|
||||
id: "app",
|
||||
name: "Open SystemC2 App page",
|
||||
callback: async () => {
|
||||
const leaf = this.app.workspace.getLeaf(true);
|
||||
await leaf.setViewState({
|
||||
type: "system-c2-app",
|
||||
active: true,
|
||||
});
|
||||
this.app.workspace.revealLeaf(leaf);
|
||||
},
|
||||
});
|
||||
|
||||
this.addCommand({
|
||||
id: "full-parse",
|
||||
name: "Parse all otask files into the db",
|
||||
callback: async () => {
|
||||
await full_parse();
|
||||
},
|
||||
});
|
||||
|
||||
//full_parse(this.db)
|
||||
}
|
||||
|
||||
async handleFileUpdate(file: TFile) {
|
||||
if (!(file instanceof TFile) || file.extension !== "md") {
|
||||
return; // only care about markdown files
|
||||
}
|
||||
|
||||
const metadata = this.app.metadataCache.getFileCache(file);
|
||||
|
||||
// Example: check if the file has a specific tag
|
||||
if (metadata?.frontmatter?.tags?.includes("t/otask")) {
|
||||
this.parseOtask(file);
|
||||
}
|
||||
}
|
||||
|
||||
async parseOtask(file: TFile) {
|
||||
if (!this.isLoggedIn()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isRrootOtask = file.basename === "my-projects";
|
||||
|
||||
if (isRrootOtask) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
async isLoggedIn() {
|
||||
const user = this.db.getAuth();
|
||||
user;
|
||||
}
|
||||
|
||||
onunload() {
|
||||
this.app.workspace.detachLeavesOfType("system-c2-app");
|
||||
}
|
||||
}
|
||||
|
||||
let OTASK_PARSE_QUEUE = [];
|
||||
|
||||
let OTASK_LIST = [];
|
||||
|
||||
let DBG = false;
|
||||
|
||||
function dbg() {
|
||||
if (DBG) {
|
||||
console.log(arguments);
|
||||
}
|
||||
}
|
||||
|
||||
function queue_otasks_from_list_item(listItem, otask_path, priority = 0) {
|
||||
OTASK_PARSE_QUEUE.push({
|
||||
listItem,
|
||||
otask_path,
|
||||
priority,
|
||||
obsidian_plugin.addCommand({
|
||||
id: "full-parse",
|
||||
name: "Parse all otask files into the db",
|
||||
callback: async () => {
|
||||
await full_parse();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function queue_otasks_from_file(file, otask_path, priority = 0) {
|
||||
OTASK_PARSE_QUEUE.push({
|
||||
file,
|
||||
otask_path,
|
||||
priority,
|
||||
});
|
||||
}
|
||||
|
||||
// parsing helper functions
|
||||
|
||||
async function full_parse() {
|
||||
console.log("full parse.......................... yay");
|
||||
let otasks = [];
|
||||
@@ -181,6 +77,34 @@ async function full_parse() {
|
||||
render_sub0_file(OTASK_LIST);
|
||||
}
|
||||
|
||||
let OTASK_PARSE_QUEUE = [];
|
||||
let OTASK_LIST = [];
|
||||
let DBG = false;
|
||||
|
||||
function dbg() {
|
||||
if (DBG) {
|
||||
console.log(arguments);
|
||||
}
|
||||
}
|
||||
|
||||
function queue_otasks_from_list_item(listItem, otask_path, priority = 0) {
|
||||
OTASK_PARSE_QUEUE.push({
|
||||
listItem,
|
||||
otask_path,
|
||||
priority,
|
||||
});
|
||||
}
|
||||
|
||||
function queue_otasks_from_file(file, otask_path, priority = 0) {
|
||||
OTASK_PARSE_QUEUE.push({
|
||||
file,
|
||||
otask_path,
|
||||
priority,
|
||||
});
|
||||
}
|
||||
|
||||
// parsing helper functions
|
||||
|
||||
async function render_sub0_file(otasks) {
|
||||
const sub0_file = app.vault.getAbstractFileByPath("private/sub0-tasks.md");
|
||||
if (!(sub0_file instanceof TFile)) {
|
||||
@@ -39,7 +39,7 @@ toml = { version = "0.8.13", features = ["parse"], optional = false }
|
||||
dyn-clone = "1.0.17"
|
||||
sha2 = "0.10.8"
|
||||
flume = "0.11.1"
|
||||
mize_macros = { path = "../macro_mize" }
|
||||
mize_macros = { path = "../ac_mize_macros" }
|
||||
async-trait = "0.1.89"
|
||||
|
||||
# builtin modules
|
||||
@@ -270,6 +270,7 @@ rec {
|
||||
#_shell_type = "rust";
|
||||
nativeBuildInputs = attrs.nativeBuildInputs or [] ++ [
|
||||
pkgs.wasm-pack
|
||||
pkgs.deno
|
||||
pkgs.pkg-config
|
||||
pkgs.wasm-bindgen-cli
|
||||
(fenix.packages."x86_64-linux".combine [
|
||||
@@ -56,36 +56,38 @@ static BUILD_TIME_CONFIG: &str = include_str!(std::env!("MIZE_BUILD_CONFIG"));
|
||||
#[derive(Clone)]
|
||||
pub struct Mize {
|
||||
// a bit a lot of Mutexes isn't it???
|
||||
pub store: Arc<Mutex<Box<dyn Store>>>,
|
||||
pub(crate) store: Arc<Mutex<Box<dyn Store>>>,
|
||||
connections: Arc<Mutex<Vec<Connection>>>,
|
||||
next_con_id: Arc<Mutex<u64>>,
|
||||
subs: Arc<Mutex<HashMap<MizeId, Vec<Subscription>>>>,
|
||||
pub modules: Arc<Mutex<HashMap<String, Box<dyn Module + Sync + Send>>>>,
|
||||
pub id_pool: Arc<Mutex<VecStringPool>>,
|
||||
pub namespace_pool: Arc<Mutex<StringPool>>,
|
||||
pub(crate) modules: Arc<Mutex<HashMap<String, Box<dyn Module + Sync + Send>>>>,
|
||||
pub(crate) id_pool: Arc<Mutex<VecStringPool>>,
|
||||
pub(crate) namespace_pool: Arc<Mutex<StringPool>>,
|
||||
|
||||
pub(crate) parts: Arc<Mutex<HashMap<&'static str, Option<Box<dyn MizePart + Sync + Send>>>>>,
|
||||
|
||||
part_names: Arc<Mutex<Vec<&'static str>>>,
|
||||
|
||||
pub config_opts: Arc<Mutex<HashMap<String, ConfigOpt>>>,
|
||||
pub(crate) config_opts: Arc<Mutex<HashMap<String, ConfigOpt>>>,
|
||||
|
||||
// the namespace the instance operates in
|
||||
pub namespace: Arc<Mutex<Namespace>>,
|
||||
pub(crate) namespace: Arc<Mutex<Namespace>>,
|
||||
|
||||
// the namespace of the instance itself
|
||||
// TODO: set to a random uuid
|
||||
pub self_namespace: Arc<Mutex<Namespace>>,
|
||||
pub op_tx: Sender<Operation>,
|
||||
pub(crate) self_namespace: Arc<Mutex<Namespace>>,
|
||||
pub(crate) op_tx: Sender<Operation>,
|
||||
threads: Arc<Mutex<Vec<(u32, String)>>>,
|
||||
next_thread_id: Arc<Mutex<u32>>,
|
||||
give_msg_wait: Arc<Mutex<HashMap<MizeId, Vec<Sender<ItemData>>>>>,
|
||||
create_msg_wait: Arc<Mutex<Option<Sender<MizeId>>>>,
|
||||
|
||||
#[cfg(feature = "async")]
|
||||
pub runtime: Arc<Mutex<Runtime>>,
|
||||
pub(crate) runtime: Arc<Mutex<Runtime>>,
|
||||
}
|
||||
|
||||
// the public Mize API
|
||||
|
||||
pub struct InstanceRef {
|
||||
inner: Arc<Mutex<Mize>>,
|
||||
}
|
||||
@@ -16,7 +16,7 @@ path = "src/platform/os/main.rs"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
path = "src/lib.rs"
|
||||
path = "lib.rs"
|
||||
|
||||
[features]
|
||||
default = ["target-os"]
|
||||
23
packages/ppc/platform/obsidian/deno.json
Normal file
23
packages/ppc/platform/obsidian/deno.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "@ppc/obsidian-plugin",
|
||||
"tasks": {
|
||||
"build_rust": "wasm-pack -vvvvv build -d src/platform/obsidian/rust_dist --target web --no-default-features --features target-obsidian",
|
||||
"build": "deno run -A build_rust && mkdir -p dist && touch dist/.hotreload && cp manifest.json dist && deno -A esbuild.config.mjs production",
|
||||
"dev": ""
|
||||
},
|
||||
"imports": {
|
||||
"@deno/esbuild-plugin": "jsr:@deno/esbuild-plugin@^1.2.1",
|
||||
"@flowershow/remark-wiki-link": "npm:@flowershow/remark-wiki-link@^3.4.0",
|
||||
"builtin-modules": "npm:builtin-modules@^5.0.0",
|
||||
"esbuild": "npm:esbuild@^0.27.3",
|
||||
"mdast": "npm:mdast@^3.0.0",
|
||||
"obsidian": "npm:obsidian@^1.12.2",
|
||||
"remark-frontmatter": "npm:remark-frontmatter@^5.0.0",
|
||||
"remark-gfm": "npm:remark-gfm@^4.0.1",
|
||||
"remark-parse": "npm:remark-parse@^11.0.0",
|
||||
"remark-stringify": "npm:remark-stringify@^11.0.0",
|
||||
"typescript": "npm:typescript@^5.9.3",
|
||||
"unified": "npm:unified@^11.0.5",
|
||||
"unist-util-visit": "npm:unist-util-visit@^5.1.0"
|
||||
}
|
||||
}
|
||||
1340
packages/ppc/platform/obsidian/deno.lock
generated
Normal file
1340
packages/ppc/platform/obsidian/deno.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
56
packages/ppc/platform/obsidian/esbuild.config.mjs
Normal file
56
packages/ppc/platform/obsidian/esbuild.config.mjs
Normal file
@@ -0,0 +1,56 @@
|
||||
import esbuild from "esbuild";
|
||||
import process from "node:process";
|
||||
import builtins from "builtin-modules";
|
||||
import { denoPlugin } from "@deno/esbuild-plugin";
|
||||
|
||||
const banner = `/*
|
||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||
*/
|
||||
`;
|
||||
|
||||
const prod = process.argv[2] === "production";
|
||||
|
||||
const context = await esbuild.context({
|
||||
banner: {
|
||||
js: banner,
|
||||
},
|
||||
entryPoints: ["plugin.ts"],
|
||||
bundle: true,
|
||||
external: [
|
||||
"obsidian",
|
||||
"electron",
|
||||
"@codemirror/autocomplete",
|
||||
"@codemirror/collab",
|
||||
"@codemirror/commands",
|
||||
"@codemirror/language",
|
||||
"@codemirror/lint",
|
||||
"@codemirror/search",
|
||||
"@codemirror/state",
|
||||
"@codemirror/view",
|
||||
"@lezer/common",
|
||||
"@lezer/highlight",
|
||||
"@lezer/lr",
|
||||
...builtins,
|
||||
],
|
||||
format: "cjs",
|
||||
target: "es2020",
|
||||
logLevel: "info",
|
||||
sourcemap: prod ? false : "inline",
|
||||
treeShaking: true,
|
||||
outfile: "dist/main.js",
|
||||
loader: {
|
||||
".wasm": "binary",
|
||||
".workerjs": "text",
|
||||
},
|
||||
define: {
|
||||
"import.meta.url": '"obsidian-plugin"',
|
||||
},
|
||||
plugins: [denoPlugin()],
|
||||
});
|
||||
|
||||
if (prod) {
|
||||
await context.rebuild();
|
||||
process.exit(0);
|
||||
} else {
|
||||
await context.watch();
|
||||
}
|
||||
8
packages/ppc/platform/obsidian/main.ts
Normal file
8
packages/ppc/platform/obsidian/main.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export function add(a: number, b: number): number {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
// Learn more at https://docs.deno.com/runtime/manual/examples/module_metadata#concepts
|
||||
if (import.meta.main) {
|
||||
console.log("Add 2 + 3 =", add(2, 3));
|
||||
}
|
||||
6
packages/ppc/platform/obsidian/main_test.ts
Normal file
6
packages/ppc/platform/obsidian/main_test.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { assertEquals } from "@std/assert";
|
||||
import { add } from "./main.ts";
|
||||
|
||||
Deno.test(function addTest() {
|
||||
assertEquals(add(2, 3), 5);
|
||||
});
|
||||
40
packages/ppc/platform/obsidian/plugin.ts
Normal file
40
packages/ppc/platform/obsidian/plugin.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Plugin, TFile } from "obsidian";
|
||||
import wasmBinary from "./rust_dist/ppc_bg.wasm";
|
||||
import * as wasmNamespace from "./rust_dist/ppc";
|
||||
import { c2vi_obsidian_canvas_patch } from "@ppc/marts";
|
||||
import { task_obsidian_otask_parse } from "@ppc/marts";
|
||||
|
||||
export default class PPCObsidianPlugin extends Plugin {
|
||||
async onload() {
|
||||
// init mize from wasm
|
||||
const wasmModule = await import("./rust_dist/ppc.js");
|
||||
await wasmModule.default({ module_or_path: wasmBinary });
|
||||
wasmModule.initSync();
|
||||
wasmModule.obsidian_mize_entrypoint();
|
||||
|
||||
const mize = {};
|
||||
mize.get_part_native = (name) => this;
|
||||
|
||||
// c2vi part which patches canvas movement
|
||||
c2vi_obsidian_canvas_patch(mize);
|
||||
|
||||
task_obsidian_otask_parse(mize);
|
||||
|
||||
this.addCommand({
|
||||
id: "app",
|
||||
name: "Open ppc app main page",
|
||||
callback: async () => {
|
||||
const leaf = this.app.workspace.getLeaf(true);
|
||||
await leaf.setViewState({
|
||||
type: "ppc-app",
|
||||
active: true,
|
||||
});
|
||||
this.app.workspace.revealLeaf(leaf);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
onunload() {
|
||||
this.app.workspace.detachLeavesOfType("ppc-app");
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user