Basic script deployer - #9543
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the script-deployer application, a development harness designed for writing and deploying Trilium scripts to a local instance. The package includes a deployment engine that manages metadata parsing, TypeScript transpilation, and note synchronization, alongside a development server with file-watching and hot-reloading capabilities. Additionally, it provides a utility script for importing Xournal++ (.xopp) files into Trilium canvas notes. Review feedback highlights the need to remove a debug log, ensure that metadata like labels and render note titles are updated during redeployment, and use parameterized inputs when injecting scripts via websockets to prevent syntax errors from special characters.
| console.log("Stroke width ", widths[0], el.strokeWidth); | ||
| el.opacity = isHighlighter ? 40 : extractOpacity(color); |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
| script: `function() { | ||
| for (const ctx of api.getNoteContexts()) { | ||
| if (ctx.noteId === "${renderId}") { | ||
| api.triggerEvent("refreshData", { ntxId: ctx.ntxId }); | ||
| console.log("[script-deployer] refreshed", "${meta.title}", "in context", ctx.ntxId); | ||
| } | ||
| } | ||
| }`, | ||
| params: [], |
There was a problem hiding this comment.
Injecting variables directly into the script string via template literals can lead to syntax errors if the values contain quotes (e.g., if meta.title contains a double quote). It is safer to pass these values via the params array.
script: "function(title, renderId) {\n for (const ctx of api.getNoteContexts()) {\n if (ctx.noteId === renderId) {\n api.triggerEvent(\"refreshData\", { ntxId: ctx.ntxId });\n console.log(\"[script-deployer] refreshed\", title, \"in context\", ctx.ntxId);\n }\n }\n }",\n params: [meta.title, renderId],
No description provided.