Open cargilcm opened 3 months ago
Hi @cargilcm, there is indeed some basic support using PCREmu but it needs to be installed as a plugin and does not yet support many PCRE functions - I moved away from the libpcre wasm approach due to size. I'll put together an example for you later today as the documentation is still a bit lacking in this area unfortunately!
Essentially you need to import the plugin in the plugins
section of a uniter.config.js
, here is an example for a different plugin: https://github.com/uniter/markdown-plugin-example/blob/master/uniter.config.js#L13
In your case though you'll need:
uniter.config.js
module.exports = {
plugins: [
// Import the PCRE plugin.
require('phpruntime/src/plugin/pcre/basicSupport'),
],
settings: {
// ...
},
};
I tried adding the src/plugin/pcre/basicSupport/* directories and files structure at the root of the webserver and incorporating
plugins: [
// Import the PCRE plugin.
require('phpruntime/src/plugin/pcre/basicSupport'),
],
in the module exports for interactive.js to begin using the preg_* functions from PHP demo but this did not succeed. I would really love to know how as I'm not well versed in modules and node and love the demo.
Further, hindering my development is that npm i uniter fails on my phone (termux environment) 8)
Sorry about that, I definitely need to improve the documentation urgently! I will find time over the next few days to put together a proper example for you, because the interactive demo isn't going to load the config file in quite that way.
In the meantime could you try setting up this project https://github.com/uniter/markdown-plugin-example (the instructions in the readme should still be current)? I know that's not quite what you're trying to do, but it would be good to just test whether it will work at all for your environment. This will not involve using the interactive demo at all, instead it will build a custom browser bundle for you.
Once we have that demo working, we can then add the PCRE plugin into the uniter.config.js
in the root of the project.
It might take me a little while longer to get to, but I'll also look into what might be stopping Uniter installing on Termux too.
Thanks for raising this!
I think the environment is working now I've used a fix for gyp running in termux and had the markdown printing via CLI but failing with npm run until I used this.
Still, as noted there npm run dev doesn't build but using npm run build:browser:prod
using prod instead of dev does ultimately pass im not sure if prod is actually a build target I just know it resulted in webpack building dist/browser.js and ..visiting index.html afterwards is success.
How big is the preg_* wasm and or looking forward to playing with preg support via uniter.config.js :)
@cargilcm just to let you know, I am still looking into this - I don't have the demo working yet though as there are various issues I've found along the way that I'm having to fix.
For the failing dev build, I wonder if it's because the file watching isn't working under Termux, could you try with the --watch
flag removed for that script in package.json
?
"could you try with the --watch flag removed for that script in package.json?" 👍 This is a build:dev success
I saw in another issue discussed in this repo that the scope for functions added to phpruntime may have started with the pcre* library and i am interested in this aspect of uniter and may be able to lend my time doing some google searches if it would help. I know regex101 has a closed source wasm /JS library and regexr.com may have an open sourced one but my interest is in making launching into a browser based pcre app as simple as uniter interactive demo.
Can the pcre* functions be used somehow already as I got a fatal error when I tried but this looks promising: https://github.com/uniter/phpruntime/blob/master/src%2Fbuiltin%2Ffunctions%2Fpcre%2FbasicSupport.js
Thank you