WIP: use es-modules

This commit is contained in:
j 2026-02-16 22:16:19 +01:00
commit f70967f9bc
144 changed files with 741 additions and 57 deletions

View file

@ -2,15 +2,7 @@
'use strict';
/*@
Ox <f> The `Ox` object
See `Ox.wrap` for details.
(value) -> <o> wrapped value
value <*> Any value
@*/
this.Ox = function(value) {
return Ox.wrap(value);
};
import Ox from './Namespace.js';
/*@
Ox.load <f> Loads OxJS and, optionally, one or more modules
@ -76,20 +68,17 @@ Ox.load = function() {
if (!length) {
callback(true);
} else {
Ox.forEach(modules, function(options, module) {
Ox.getFile(
Ox.PATH + module + '/' + module + '.js?' + Ox.VERSION,
function() {
Ox.load[module](options, function(success) {
succeeded += success;
if (++loaded == length) {
Ox.setLocale(Ox.LOCALE, function() {
callback(succeeded == length);
});
}
Ox.forEach(modules, async function(options, module) {
console.log("load module!", module, options)
const obj = await import('../../' + module + '/index.js?' + Ox.VERSION);
Ox.load[module](options, function(success) {
succeeded += success;
if (++loaded == length) {
Ox.setLocale(Ox.LOCALE, function() {
callback(succeeded == length);
});
}
);
});
});
}
});
@ -114,7 +103,7 @@ Ox.localStorage = function(namespace) {
var localStorage;
try {
// this will fail if third party cookies/storage is not allowed
localStorage = window.localStorage || {};
localStorage = globalThis.localStorage || {};
// FF 3.6 can't assign to or iterate over localStorage
for (var key in localStorage) {}
// In Safari (OS X or iOS) is in private browsing mode,
@ -206,7 +195,7 @@ Ox.Log = (function() {
args.unshift(
Ox.formatDate(date, '%H:%M:%S.') + (+date).toString().slice(-3)
);
window.console && window.console.log && window.console.log.apply(window.console, args);
globalThis.console && globalThis.console.log && globalThis.console.log.apply(globalThis.console, args);
ret = args.join(' ');
}
return ret;
@ -268,7 +257,7 @@ Ox.print = function() {
args.unshift(
date.toString().split(' ')[4] + '.' + (+date).toString().slice(-3)
);
window.console && window.console.log.apply(window.console, args);
globalThis.console && globalThis.console.log.apply(globalThis.console, args);
return args.join(' ');
};