update module sample with worker code injection

This commit is contained in:
Stewart Allen 2022-11-13 11:16:30 -05:00
commit ed6c771c5f
3 changed files with 18 additions and 3 deletions

View file

@ -6,9 +6,12 @@ module.exports = function(server) {
server.util.log("--- sample server-side module installed ---");
// insert script after all others in kiri browser code
// insert script after all others in kiri main code
server.inject("kiri", "kiri.js", {end: true});
// insert script after all others in kiri worker code
server.inject("kiri_work", "work.js", {end: true});
server.onload(() => {
server.util.log("--- called after all modules loaded ---");
});

View file

@ -1,8 +1,8 @@
console.log('--- in the browser main loop ---');
console.log('--- kiri main module start ---');
// the kiri api starts around line `260` of `src/kiri/main.js`
kiri.load(function(api) {
console.log('--- kiri startup complete ---');
console.log('--- kiri main module started ---');
// send data to our "/postit" endpoint
fetch("/postit", {

12
sample/work.js Normal file
View file

@ -0,0 +1,12 @@
console.log('--- kiri worker module start ---');
kiri.load(function(api) {
console.log('--- kiri worker module started ---');
// augment worker code here. for example,
// to ovveride fdm extrusion calculations
// kiri.driver.FDM.extrudeMM = function(dist, perMM, factor) {
// return dist * perMM * factor;
// };
});