mnaoumov / obsidian-fix-require-modules

An Obsidian plugin that fixes require() calls, supporting JavaScript and TypeScript modules, enabling easy invocation, and adding code buttons for enhanced scripting capabilities.
MIT License
13 stars 0 forks source link

Mobile Support (IOS/Android) #1

Open emilio-toledo opened 3 months ago

emilio-toledo commented 3 months ago

Hello, thank you so much for this plugin!

I have one question, is it possible to get mobile support?

I have found "fix-require-modules" extremely helpful, and I believe adding mobile support would greatly its popularity.

mnaoumov commented 3 months ago

@emilio-toledo what is scenario you are looking for using the plugin on Mobile?

emilio-toledo commented 3 months ago

@mnaoumov I am currently using dataviewjs to render the following snippet:

const { init } = require("/views/pitch.ts")
const data = init(dv)

This snippet invokes a file which renders custom HTML to display Japanese Kana in a specific way and style. Not only that but all throughout my vault I am using this module to import .ts scripts to add a bunch of extra functionality when paired with templater, such as modifying the frontmatter data on template load and fetching data using fetch.

My whole vault and ideas that I have to enhance my Obsidian workflow without having to develop a plugin from scratch depend on custom JS/TS. I have tried most of the plugins related to creating modules and this one is by far the best.

I know that there are similar plugins that work on mobile, but the only one that lets me (without hassle) use Typescript as my language is this one.

mnaoumov commented 3 months ago

@emilio-toledo That's very unlikely we could make the plugin work on Mobile because on Mobile we don't have Node.js infrastructure. All the plugins that aim to run scripts on Mobile don't use require(), they use eval(). But I will double check

emilio-toledo commented 3 months ago

@mnaoumov maybe this is out of the scope for this plugin, but what CustomJS is doing is adding a global function that returns your modules (they export classes). Maybe it would be possible that depending on the platform, we either use require or circumvent mobile limitations by using eval in a similar way.

mnaoumov commented 3 months ago

@emilio-toledo I know for a fact, CustomJS is using eval() inside. I was a contributor to CustomJS for a while and decided to write my own version of it to do things that eval() can't