Skip to content

Commit 81ee115

Browse files
committed
update deps; fix some issues
1 parent b1449c4 commit 81ee115

File tree

19 files changed

+96
-60
lines changed

19 files changed

+96
-60
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ return engine.markdown.create('*test*');
1616
```
1717
````
1818

19+
### Debugging your Code
20+
21+
Debugging your code blocks can be difficult, but JS Engine aims to make it a bit simpler.
22+
While writing your code blocks, you can use the `js-engine-debug` code block language.
23+
The special language adds a small icon to the top right corner of the code block that lets you easily rerun and view stats about the code block.
24+
Once you are happy with your code block you can switch back to the `js-engine` code block language to get rid of the small icon.
25+
Other than the icon, the two codeblocks behave identically.
26+
1927
## API Docs
2028

2129
Docs are available [here](https://www.moritzjung.dev/obsidian-js-engine-plugin-docs/).

bun.lockb

13.2 KB
Binary file not shown.

exampleVault/Test.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,10 @@ le)
231231

232232
```js-engine
233233
engine.getPlugin(false)
234-
```
234+
```
235+
236+
# Debug Mode
237+
238+
```js-engine-debug
239+
return "foo";
240+
```

jsEngine/JsMDRC.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ export class JsMDRC extends MarkdownRenderChild {
1010
content: string;
1111
ctx: MarkdownPostProcessorContext;
1212
jsExecution: JsExecution | undefined;
13+
debugMode: boolean;
1314

14-
constructor(containerEl: HTMLElement, plugin: JsEnginePlugin, content: string, ctx: MarkdownPostProcessorContext) {
15+
constructor(containerEl: HTMLElement, plugin: JsEnginePlugin, content: string, debugMode: boolean, ctx: MarkdownPostProcessorContext) {
1516
super(containerEl);
1617
this.plugin = plugin;
1718
this.content = content;
19+
this.debugMode = debugMode;
1820
this.ctx = ctx;
1921
}
2022

@@ -68,6 +70,10 @@ export class JsMDRC extends MarkdownRenderChild {
6870
}
6971

7072
renderExecutionStats(container: HTMLElement): void {
73+
if (!this.debugMode) {
74+
return;
75+
}
76+
7177
const menu = new Menu();
7278
menu.addItem(item => {
7379
item.setTitle('Info');

jsEngine/api/API.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type { Validators } from 'jsEngine/utils/Validators';
1313
import { validateAPIArgs } from 'jsEngine/utils/Validators';
1414
import type { App, Plugin, TFile } from 'obsidian';
1515
import * as Obsidian from 'obsidian';
16-
import { z } from 'zod';
16+
import * as z from 'zod';
1717

1818
export class API {
1919
/**

jsEngine/api/Internal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { ResultRenderer } from 'jsEngine/engine/ResultRenderer';
1616
import { validateAPIArgs } from 'jsEngine/utils/Validators';
1717
import { Component, TFile } from 'obsidian';
1818
import * as Obsidian from 'obsidian';
19-
import { z } from 'zod';
19+
import * as z from 'zod';
2020

2121
export type ExecuteFileEngineExecutionParams = Omit<EngineExecutionParams, 'code' | 'context'> & {
2222
context?: JSFileExecutionContext | MarkdownCallingJSFileExecutionContext;

jsEngine/api/MarkdownAPI.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
import { MarkdownBuilder } from 'jsEngine/api/markdown/MarkdownBuilder';
1414
import { MarkdownString } from 'jsEngine/api/markdown/MarkdownString';
1515
import { validateAPIArgs } from 'jsEngine/utils/Validators';
16-
import { z } from 'zod';
16+
import * as z from 'zod';
1717

1818
/**
1919
* The markdown API provides utilities for creating markdown using js.

jsEngine/api/MessageAPI.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { API } from 'jsEngine/api/API';
22
import type { MessageManager, MessageType, MessageWrapper } from 'jsEngine/messages/MessageManager';
33
import { Message } from 'jsEngine/messages/MessageManager';
44
import { validateAPIArgs } from 'jsEngine/utils/Validators';
5-
import { z } from 'zod';
5+
import * as z from 'zod';
66

77
export class MessageAPI {
88
readonly apiInstance: API;

jsEngine/api/PromptAPI.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { AnySvelteComponent } from 'jsEngine/utils/SvelteUtils';
77
import { ButtonStyleType } from 'jsEngine/utils/Util';
88
import { validateAPIArgs } from 'jsEngine/utils/Validators';
99
import { mount } from 'svelte';
10-
import { z } from 'zod';
10+
import * as z from 'zod';
1111

1212
/**
1313
* Basic options for a prompt modal.

jsEngine/api/QueryAPI.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { API } from 'jsEngine/api/API';
22
import { validateAPIArgs, zodFunction } from 'jsEngine/utils/Validators';
33
import type { CachedMetadata, TFile } from 'obsidian';
44
import { getAllTags } from 'obsidian';
5-
import { z } from 'zod';
5+
import * as z from 'zod';
66

77
export class QueryAPI {
88
readonly apiInstance: API;

0 commit comments

Comments
 (0)