summaryrefslogtreecommitdiff
path: root/node_modules/@jet/environment/runtime/runtime.js
blob: 3c885c5d741a8cef7f2c1ae58d1632965a6e891f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LegacyRuntime = exports.Runtime = void 0;
const isJetEnvironment = typeof exportService === "function";
function nativeExportService(name, service) {
    exportService(name, service);
}
class Runtime {
    constructor(dispatcher, objectGraph) {
        this.dispatcher = dispatcher;
        this.objectGraph = objectGraph;
    }
    async dispatch(intent) {
        return await this.dispatcher.dispatch(intent, this.objectGraph);
    }
}
exports.Runtime = Runtime;
class LegacyRuntime extends Runtime {
    constructor(dispatcher, objectGraph, services) {
        super(dispatcher, objectGraph);
        this.services = services;
    }
    serviceWithName(name) {
        return this.services[name];
    }
    exportingService(name, service) {
        if (isJetEnvironment) {
            nativeExportService(name, service);
        }
        this.services[name] = service;
        return this;
    }
}
exports.LegacyRuntime = LegacyRuntime;
//# sourceMappingURL=runtime.js.map