UNPKG

@hippy/debug-server-next

Version:
78 lines (77 loc) 3.28 kB
"use strict"; /* * Tencent is pleased to support the open source community by making * Hippy available. * * Copyright (C) 2017-2019 THL A29 Limited, a Tencent company. * All rights reserved. * * 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.debuggerMiddleWareManager = exports.getLastScriptEval = void 0; const types_1 = require("@hippy/devtools-protocol/dist/types"); const global_id_1 = require("@debug-server-next/utils/global-id"); const default_middleware_1 = require("../default-middleware"); let lastScriptEval; const getLastScriptEval = () => lastScriptEval; exports.getLastScriptEval = getLastScriptEval; exports.debuggerMiddleWareManager = { downwardMiddleWareListMap: { [types_1.ChromeEvent.DebuggerScriptParsed]: ({ msg, sendToDevtools }) => { const eventRes = msg; delete eventRes.params.module; eventRes.params = { ...eventRes.params, hasSourceURL: !!eventRes.params.sourceURL, isModule: eventRes.params.module, scriptLanguage: types_1.ScriptLanguage.JavaScript, url: eventRes.params.url || eventRes.params.sourceURL, }; lastScriptEval = eventRes.params.scriptId; return sendToDevtools(eventRes); }, [types_1.IOS90Command.DebuggerEnable]: default_middleware_1.sendEmptyResultToDevtools, [types_1.ChromeCommand.DebuggerSetBlackboxPatterns]: default_middleware_1.sendEmptyResultToDevtools, [types_1.IOS90Command.DebuggerSetPauseOnExceptions]: default_middleware_1.sendEmptyResultToDevtools, }, upwardMiddleWareListMap: { [types_1.ChromeCommand.DebuggerEnable]: async ({ sendToApp, msg }) => { sendToApp({ id: global_id_1.requestId.create(), method: types_1.ChromeCommand.DebuggerSetBreakpointsActive, params: { active: true }, }); return sendToApp(msg); }, [types_1.ChromeCommand.DebuggerSetBlackboxPatterns]: async ({ msg, sendToDevtools }) => { const res = { id: msg.id, method: msg.method, result: {}, }; sendToDevtools(res); return res; }, [types_1.ChromeCommand.RuntimeSetAsyncCallStackDepth]: async ({ msg, sendToDevtools }) => { const res = { id: msg.id, method: msg.method, result: true, }; sendToDevtools(res); return res; }, [types_1.ChromeCommand.DebuggerSetAsyncCallStackDepth]: default_middleware_1.sendEmptyResultToDevtools, }, };