add fallback module code injection, api.beta and api.new endpoint for apps

This commit is contained in:
Stewart Allen 2025-07-08 22:38:16 -04:00
commit 418b5ba6a3
2 changed files with 16 additions and 2 deletions

11
app.js
View file

@ -240,7 +240,16 @@ function initModule(mod, file, dir) {
any: arg => { mod.add(arg) },
code() {
const [ path, file ] = [ ...arguments ];
code[path] = fs.readFileSync(file);
if (lastmod(file)) {
code[path] = fs.readFileSync(file);
// console.log({ CODE: path, file });
} else if (lastmod(mod.dir + '/' + file)) {
const alt = mod.dir + '/' + file;
code[path] = fs.readFileSync(alt);
// console.log({ CODE: path, alt });
} else {
console.log({ MISSING_CODE: path, file });
}
},
full: arg => { mod.add(fullpath(arg)) },
map: arg => { mod.add(fixedmap(arg)) },

View file

@ -16,9 +16,10 @@ import { functions } from './function.js';
import { platform } from './platform.js';
import { selection } from './selection.js';
import { stats } from '../kiri/stats.js';
import { newWidget } from './widget.js';
import { widgets } from './widgets.js';
import { updateTool } from '../kiri-mode/cam/tools.js';
import { version } from '../moto/license.js';
import { beta, version } from '../moto/license.js';
import { space as SPACE } from '../moto/space.js';
import { LANG } from './lang.js';
@ -120,6 +121,7 @@ function localSet(key, val) {
export const api = {
ajax,
beta,
alerts,
busy,
catalog,
@ -147,6 +149,9 @@ export const api = {
local,
modal,
mode,
new: {
widget: newWidget
},
noop,
o2js,
onkey,