Likely other methods are affected by not tested (e.g: element.insertAfter(node, refNode)
)
https://github.com/c-smile/sciter-js-sdk/blob/main/status.md
I managed to run a build generated by a svelte project after applying some fixes:
Svelte Project
npx degit sveltejs/template my-svelte-project
cd my-svelte-project
Open rollup.config.js and uncomment terser plugin (this should help tracking some errors from terminal)
// production && terser(),
Build the project and execute sciter. you also need to fix paths (styles, scripts, etc..) in index.html by removing the leading forward slash
npm run build
scapp ./public/index.html
Reported Error:
error:script: TypeError: Node was deleted
After some checks, I discovered that sciter is claiming about invoking the second parameter (reNode) with a 'null' value.
element.insertBefore(node, null) // Accepted by chrome but not sciter
element.insertBefore(node) // Accepted by sciter but not chrome
I tried to fix Node.prototype.insertBefore
but the moment I write Node.prototype, I get this error:
console.log(Node.prototype)
Reported Error:
terminate called after throwing an instance of 'qjs::exception'
Aborted (core dumped)
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! [email protected] sciter: scapp ./public/index.html
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the [email protected] sciter script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
But I managed to apply a temporary fix either by using @rollup/plugin-replace or by invoking some code before executing the script
Method 1 (@rollup/plugin-replace):
// rollup.config.js
replace({
include: ['node_modules/svelte/internal/**'],
delimiters: ['', ''],
'target.insertBefore(node, anchor || null);': 'let sciter_detected = false; try { navigator } catch { sciter_detected = true } ; (!anchor && sciter_detected) ? target.insertBefore(node) : target.insertBefore(node, anchor || null);',
}),
Method 2 (replacing insertBefore for document.body and any other element created at runtime):
// at the top of src/main.js, add these lines
let sciter_detected = false; try { navigator; } catch { sciter_detected = true; }
if (sciter_detected) {
document.body.__insertBefore = document.body.insertBefore
document.body.insertBefore = function (node, anchor) {
const params = [node, ...(anchor ? [anchor] : [])]
document.body.__insertBefore(...params)
}
document.__createElement = document.createElement
document.createElement = function (...rest) {
const element = document.__createElement(...rest)
element.__insertBefore = element.insertBefore
element.insertBefore = function (node, anchor) {
const params = [node, ...(anchor ? [anchor] : [])]
element.__insertBefore(...params)
}
return element
}
}
Sorry for the long text, I only tried to prove to others the possibility to benefit from some wide spread reactive frameworks