Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import raxCode from '!!raw-loader!rax/dist/rax.min.js';
import createDriver from 'driver-worker';
import { log, worker } from 'miniapp-framework-shared';
import { applyFactory } from './getModule';
import { emit as emitPageLifecycle } from './lifecycles/page';
const raxFactory = new Function('module', 'exports', raxCode);
const { getPage, getUnknownPageFactory } = worker.pageHub;
const { on: addClientEvent } = worker.clientHub;
const CURRENT_CLIENT_ID = '__current_client_id__';
const MINIAPP_ENV = '__miniapp_env__';
export default class Client {
constructor(clientId, pageName, pageQuery = {}) {
this.clientId = clientId;
this.pageName = pageName;
this.pageQuery = pageQuery;
this.raxInstance = createRax();
this.eventListeners = {};
this.setup();
}
setup() {
const { createElement, render } = this.raxInstance;
import { call } from './remoteCall';
import * as appLifecycle from './lifecycles/app';
import Client from './Client';
import getModule from './getModule';
setupGlobalObject({
my,
require: getModule,
/**
* @Note: Internal varibale to judge IDE/Web env.
*/
__framework_type__: frameworkType,
});
addEventListener('message', messageHandler);
const { emit: emitToClient, addClient, getClient } = worker.clientHub;
const CURRENT_CLIENT_ID = '__current_client_id__';
const MINIAPP_ENV = '__miniapp_env__';
const EVENT_IMPORT_SCRIPTS = 'importScripts';
const EVENT_REGISTER_API = 'registerAPI';
const EVENT_START_RENDER = 'init';
const EVENT_EVALUATOR_EVENT = 'event';
const EVENT_EVALUATOR_RETURN = 'return';
const EVENT_CYCLE_APP = 'app:lifecycle';
const EVENT_CYCLE_PAGE = 'page:lifecycle';
const EVENT_NAVIGATOR = 'navigate';
const EVENT_UPDATE_PAGEDATA = 'updatePageData';
const EVENT_SET_ENV = 'setEnv';
/**
* Worker message handler.
* @param data