@btfuse/core
Version:
A native-first framework for building hybdrid web-native applications
80 lines (77 loc) • 2.65 kB
JavaScript
"use strict";
/*
Copyright 2023 Breautek
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.FuseContext = void 0;
const FuseRuntime_1 = require("./plugins/FuseRuntime");
const Version_1 = require("./Version");
const FuseMemoryStore_1 = require("./plugins/FuseMemoryStore");
/**
* A context class that holds Fuse Framework state
*/
class FuseContext {
constructor(platform, apiFactory, logger) {
this.$platform = platform;
this.$logger = logger;
this.$runtimeVersion = null;
this.$defaultAPIFactory = apiFactory;
this.$runtime = new FuseRuntime_1.FuseRuntime(this);
this.$memStore = new FuseMemoryStore_1.FuseMemoryStore(this);
}
getLogger() {
return this.$logger;
}
getDefaultAPIFactory() {
return this.$defaultAPIFactory;
}
getPlatform() {
return this.$platform;
}
_getRuntime() {
return this.$runtime;
}
async $getRuntimeInfo() {
if (!this.$runtimeInfo) {
this.$runtimeInfo = await this.$runtime.getInfo();
}
return this.$runtimeInfo;
}
async getPlatformVersion() {
if (!this.$runtimeVersion) {
const info = await this.$getRuntimeInfo();
this.$runtimeVersion = Version_1.Version.parseVersionString(info.version);
}
return this.$runtimeVersion;
}
async isDebugMode() {
const info = await this.$getRuntimeInfo();
return info.debugMode;
}
async registerPauseHandler(callback) {
return await this.$runtime.registerPauseHandler(callback);
}
async unregisterPauseHandler(callbackID) {
return await this.$runtime.unregisterPauseHandler(callbackID);
}
async registerResumeHandler(callback) {
return await this.$runtime.registerResumeHandler(callback);
}
async unregisterResumeHandler(callbackID) {
return await this.$runtime.unregisterResumeHandler(callbackID);
}
getMemoryStore() {
return this.$memStore;
}
}
exports.FuseContext = FuseContext;
//# sourceMappingURL=FuseContext.js.map