Spaces:
Sleeping
Sleeping
Download src/backend/src/extension/RuntimeModuleRegistry.js from AZILS/puter-deploy: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/spaces/AZILS/puter-deploy/resolve/main/src/backend/src/extension/RuntimeModuleRegistry.js
- Command line
-
hf download hf://spaces/AZILS/puter-deploy/src/backend/src/extension/RuntimeModuleRegistry.js
-
curl -L -o RuntimeModuleRegistry.js https://huggingface.co/spaces/AZILS/puter-deploy/resolve/main/src/backend/src/extension/RuntimeModuleRegistry.js
1.12 kB
| const { AdvancedBase } = require('@heyputer/putility'); | |
| const { RuntimeModule } = require('./RuntimeModule'); | |
| class RuntimeModuleRegistry extends AdvancedBase { | |
| constructor () { | |
| super(); | |
| this.modules_ = {}; | |
| } | |
| register (extensionModule, options = {}) { | |
| if ( ! (extensionModule instanceof RuntimeModule) ) { | |
| throw new Error(`expected a RuntimeModule, but got: ${ | |
| extensionModule?.constructor?.name ?? typeof extensionModule})`); | |
| } | |
| const uniqueName = options.as ?? extensionModule.name ?? require('uuid').v4(); | |
| if ( this.modules_.hasOwnProperty(uniqueName) ) { | |
| throw new Error(`duplicate runtime module: ${uniqueName}`); | |
| } | |
| this.modules_[uniqueName] = extensionModule; | |
| extensionModule.runtimeModuleRegistry = this; | |
| } | |
| exportsOf (name) { | |
| if ( ! this.modules_[name] ) { | |
| throw new Error(`could not find runtime module: ${name}`); | |
| } | |
| return this.modules_[name].exports; | |
| } | |
| } | |
| module.exports = { | |
| RuntimeModuleRegistry, | |
| }; | |