From a8ffd31c8a5fd0a20d8b434e1cc1c89d28c15a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Sun, 19 Jan 2020 11:08:38 +0800 Subject: [PATCH] replace system timer with doric timer when debug --- doric-js/bundle/doric-vm.js | 4 ++++ doric-js/index.debug.ts | 7 +++++++ doric-js/lib/index.debug.js | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/doric-js/bundle/doric-vm.js b/doric-js/bundle/doric-vm.js index f188286c..73f8301e 100644 --- a/doric-js/bundle/doric-vm.js +++ b/doric-js/bundle/doric-vm.js @@ -3749,6 +3749,10 @@ let context = process.cwd() + '/build/context'; const contextId = fs.readFileSync(context, { encoding: 'utf8' }); console.log("debugging context id: " + contextId); let global$2 = new Function('return this')(); +global$2.setTimeout = global$2.doricSetTimeout; +global$2.setInterval = global$2.doricSetInterval; +global$2.clearTimeout = global$2.doricClearTimeout; +global$2.clearInterval = global$2.doricClearInterval; global$2.doric = doric; global$2.context = jsObtainContext(contextId); global$2.Entry = jsObtainEntry(contextId); diff --git a/doric-js/index.debug.ts b/doric-js/index.debug.ts index 47711f4e..5583b296 100644 --- a/doric-js/index.debug.ts +++ b/doric-js/index.debug.ts @@ -15,12 +15,19 @@ */ import * as doric from './src/runtime/sandbox' import * as WebSocket from 'ws' + const WebSocketClient = require('ws') const fs = require('fs') let context = process.cwd() + '/build/context' const contextId = fs.readFileSync(context, { encoding: 'utf8' }) console.log("debugging context id: " + contextId) + let global = new Function('return this')() +global.setTimeout = global.doricSetTimeout +global.setInterval = global.doricSetInterval +global.clearTimeout = global.doricClearTimeout +global.clearInterval = global.doricClearInterval + global.doric = doric global.context = doric.jsObtainContext(contextId) global.Entry = doric.jsObtainEntry(contextId) diff --git a/doric-js/lib/index.debug.js b/doric-js/lib/index.debug.js index 5abb7633..877cf512 100644 --- a/doric-js/lib/index.debug.js +++ b/doric-js/lib/index.debug.js @@ -21,6 +21,10 @@ let context = process.cwd() + '/build/context'; const contextId = fs.readFileSync(context, { encoding: 'utf8' }); console.log("debugging context id: " + contextId); let global = new Function('return this')(); +global.setTimeout = global.doricSetTimeout; +global.setInterval = global.doricSetInterval; +global.clearTimeout = global.doricClearTimeout; +global.clearInterval = global.doricClearInterval; global.doric = doric; global.context = doric.jsObtainContext(contextId); global.Entry = doric.jsObtainEntry(contextId);