oak-frontend-base/lib/features/index.js

63 lines
2.5 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.initializeStep2 = initializeStep2;
exports.initializeStep1 = initializeStep1;
const tslib_1 = require("tslib");
const cache_1 = require("./cache");
const location_1 = require("./location");
const runningTree_1 = require("./runningTree");
const locales_1 = require("./locales");
const localStorage_1 = require("./localStorage");
const notification_1 = require("./notification");
const environment_1 = require("./environment");
const message_1 = require("./message");
const navigator_1 = require("./navigator");
const port_1 = require("./port");
// import { RelationAuth } from './relationAuth';
const style_1 = require("./style");
const subscriber_1 = require("./socket/subscriber");
const socketPoint_1 = tslib_1.__importDefault(require("./socket/socketPoint"));
const socket_1 = require("./socket/socket");
const contextMenuFactory_1 = require("./contextMenuFactory");
const geo_1 = require("./geo");
function initializeStep2(features, connector, storageSchema, frontendContextBuilder, checkers, common, render) {
const { localStorage, environment, message } = features;
const cache = new cache_1.Cache(storageSchema, connector, frontendContextBuilder, checkers, localStorage, common);
const runningTree = new runningTree_1.RunningTree(cache, storageSchema);
const geo = new geo_1.Geo(cache);
const port = new port_1.Port(cache);
const style = new style_1.Style(render.styleDict);
const locales = new locales_1.Locales(cache, localStorage, environment, 'zh-CN'); // 临时性代码,应由上层传入
const contextMenuFactory = new contextMenuFactory_1.ContextMenuFactory(cache);
const socketPoint = new socketPoint_1.default(() => connector.getSocketPoint());
const subscriber = new subscriber_1.SubScriber(cache, message, socketPoint);
const socket = new socket_1.Socket(message, socketPoint);
return {
cache,
socket,
runningTree,
locales,
port,
style,
geo,
contextMenuFactory,
subscriber,
};
}
function initializeStep1() {
const location = new location_1.Location();
const environment = new environment_1.Environment();
const localStorage = new localStorage_1.LocalStorage();
const notification = new notification_1.Notification();
const message = new message_1.Message();
const navigator = new navigator_1.Navigator();
return {
location,
environment,
notification,
message,
localStorage,
navigator,
};
}