DMT ENGINE EXTENSIONS pt. 1
Core component of DMT SYSTEM is DMT PROCESS.
DMT PROCESS is a running instance of DMT ENGINE.
DMT ENGINE consists of CORE ENGINE plus EXTENSIONS.
There are three ways to extend the DMT ENGINE:
- SYSTEM EXTIONS
- USER EXTENSIONS
- DEVICE EXTENSIONS
They all work in exactly the same way, the difference is in deployment:
- SYSTEM EXTENSIONS come bundled with CORE ENGINE
- USER EXTENSIONS are added by the user and apply to all user's devices once DMT ENGINE is replicated from user's MAIN DEVICE to the rest of their devices
- DEVICE EXTENSIONS are also added by user — separately for each device
Location of extensions:
- SYSTEM EXTENSIONS: ~/.dmt/apps
- USER EXTENSIONS: ~/.dmt/user/apps
- DEVICE EXTENSIONS: ~/.dmt-here/apps
Extensions concern separation:
- backend part: apps/[app_name]
- frontend part: apps/[app_name]/gui or apps/[app_name] if
gui
subdir is not present
Access to DMT API
DMT API has two parts:
- importable modules like
import dmt from 'dmt/common'
program
instance
Main entry point for backend part of each extension is apps/[app_name]/index.js
file. This file exports init
function which accepts the program
instance to be supplied by DMT ENGINE:
function init(program) {
...
}
export { init };
If an extension doesn't need their own additional packages via node modules, then there package.json
files will be utilized:
~/.dmt/apps/package.json
for SYSTEM EXTENSIONS~/.dmt/user/apps/package.json
for USER EXTENSIONS~/.dmt-here/apps/package.json
for DEVICE EXTENSIONS
They all look like this:
{
"name": "dmt",
"version": "0.0.1",
"description": "",
"main": "index.js",
"type": "module",
"exports": {
"./common": "./_dmt_deps/common",
"./notify": "./_dmt_deps/notify",
"./search": "./_dmt_deps/search",
"./connectome": "./_dmt_deps/connectome",
"./connectome-stores": "./_dmt_deps/connectome-stores"
}
}
This enables imports like this:
import { dmt } from 'dmt/common';
import { push } from 'dmt/notify';
...
If ENGINE EXTENSION does need their own node modules then they will have a separate `package.json` present in apps/[app_ame]/package.json
:
{
"name": "dmt",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "uniqpath",
"license": "ISC",
"exports": {
"./common": "./_dmt_deps/common",
"./notify": "./_dmt_deps/notify",
"./search": "./_dmt_deps/search",
"./connectome": "./_dmt_deps/connectome",
"./connectome-stores": "./_dmt_deps/connectome-stores"
},
"dependencies": {
"bcrypt": "^5.0.1",
"hyperbee": "^1.7.0",
"hypercore": "^10.0.0-alpha.24",
"hyperswarm": "^3.0.1",
"mediasoup": "^3.9.2",
"tweetnacl": "^1.0.3",
"tweetnacl-util": "^0.15.1"
}
}
For now the exports
field has to be maintained by extension developer as opposed to other base package.json
which are kept in sync with DMT API automatically.
In next posts we will look into how gui
parts work and in the next post after this we see options for installing USER and DEVICE EXTENSIONS (apps) from various sources.