mirror of
https://github.com/HeyPuter/puter.git
synced 2026-02-22 14:38:48 -06:00
dev: expose more core definitions to extensions
This commit is contained in:
@@ -57,7 +57,13 @@ const install = async ({ services, app, useapi, modapi }) => {
|
||||
def('Module', AdvancedBase);
|
||||
def('Library', Library);
|
||||
|
||||
def('core.util.helpers', require('./helpers'));
|
||||
def('puter.middlewares.auth', require('./middleware/auth2'));
|
||||
def('puter.middlewares.anticsrf', require('./middleware/anticsrf'));
|
||||
|
||||
def('core.APIError', require('./api/APIError'));
|
||||
|
||||
def('core', require('./services/auth/Actor'), { assign: true });
|
||||
});
|
||||
|
||||
// === LIBRARIES ===
|
||||
@@ -69,7 +75,7 @@ const install = async ({ services, app, useapi, modapi }) => {
|
||||
services.registerService('lib-type-tagged', LibTypeTagged);
|
||||
});
|
||||
|
||||
modapi.libdir('lib.core', './util');
|
||||
modapi.libdir('core.util', './util');
|
||||
|
||||
// === SERVICES ===
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ let default_fn = () => {
|
||||
};
|
||||
const library = {
|
||||
use,
|
||||
def: (name, value) => {
|
||||
def: (name, value, options = {}) => {
|
||||
const parts = name.split('.');
|
||||
let obj = use;
|
||||
for ( const part of parts.slice(0, -1) ) {
|
||||
@@ -89,7 +89,17 @@ let default_fn = () => {
|
||||
obj = obj[part];
|
||||
}
|
||||
|
||||
obj[parts[parts.length - 1]] = value;
|
||||
const lastpart = parts[parts.length - 1];
|
||||
|
||||
if ( options.assign ) {
|
||||
if ( ! obj[lastpart] ) {
|
||||
obj[lastpart] = {};
|
||||
}
|
||||
Object.assign(obj[lastpart], value);
|
||||
return;
|
||||
}
|
||||
|
||||
obj[lastpart] = value;
|
||||
},
|
||||
withuse: fn => {
|
||||
return globalwith({
|
||||
|
||||
Reference in New Issue
Block a user