@@ -40,6 +40,8 @@ function debugModule(module, runtime) {
40 var recordedEvents = [];
40 var recordedEvents = [];
41 var asyncCallbacks = [];
41 var asyncCallbacks = [];
42 var watchTracker = Elm.Native.Debug.make(runtime).watchTracker;
42 var watchTracker = Elm.Native.Debug.make(runtime).watchTracker;
44 function wrapNotify(id, v) {
46 function wrapNotify(id, v) {
45 var timestep = Date.now();
47 var timestep = Date.now();
@@ -68,7 +70,7 @@ function debugModule(module, runtime) {
68 var cbObj = { func:func, delayMs:delayMs, timerId:0, executed:false };
70 var cbObj = { func:func, delayMs:delayMs, timerId:0, executed:false };
69 var timerId = setTimeout(function() {
71 var timerId = setTimeout(function() {
70 cbObj.executed = true;
72 cbObj.executed = true;
71− func();
73+ func(timerOffset);
72 }, delayMs);
74 }, delayMs);
73 cbObj.timerId = timerId;
75 cbObj.timerId = timerId;
74 asyncCallbacks.push(cbObj);
76 asyncCallbacks.push(cbObj);
@@ -108,19 +110,25 @@ function debugModule(module, runtime) {
108 recordedEvents = events.slice();
110 recordedEvents = events.slice();
113+ function resetTimeOffset() {
111 function setPaused() {
117 function setPaused() {
112 programPaused = true;
118 programPaused = true;
113 clearAsyncCallbacks();
119 clearAsyncCallbacks();
114 tracePath.stopRecording();
120 tracePath.stopRecording();
117 function setContinue(position) {
124 function setContinue(position) {
125+ timerOffset += Date.now() - now;
118 programPaused = false;
126 programPaused = false;
119 if (position > 0) {
127 if (position > 0) {
120 // If we're not unpausing at the head, then we need to dump the
128 // If we're not unpausing at the head, then we need to dump the
121 // events that are ahead of where we're continuing.
129 // events that are ahead of where we're continuing.
122 recordedEvents = recordedEvents.slice(0,position);
130 recordedEvents = recordedEvents.slice(0,position);
123− executeCallbacks(asyncCallbacks, false);
131+ executeCallbacks(asyncCallbacks, false, timerOffset);
125 tracePath.startRecording();
133 tracePath.startRecording();
@@ -165,6 +173,7 @@ function debugModule(module, runtime) {
165 getRecordedEventAt: getRecordedEventAt,
173 getRecordedEventAt: getRecordedEventAt,
166 copyRecordedEvents: copyRecordedEvents,
174 copyRecordedEvents: copyRecordedEvents,
167 loadRecordedEvents: loadRecordedEvents,
175 loadRecordedEvents: loadRecordedEvents,
176+ resetTimeOffset: resetTimeOffset,
168 getPaused: getPaused,
177 getPaused: getPaused,
169 setPaused: setPaused,
178 setPaused: setPaused,
170 setContinue: setContinue,
179 setContinue: setContinue,
@@ -188,7 +197,8 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
188 debugModule.tracePath.clearTraces();
197 debugModule.tracePath.clearTraces();
189 debugModule.clearRecordedEvents();
198 debugModule.clearRecordedEvents();
190 debugModule.setContinue(0);
199 debugModule.setContinue(0);
200+ debugModule.resetTimeOffset();
191− executeCallbacks(debugModule.initialAsyncCallbacks, true);
201+ executeCallbacks(debugModule.initialAsyncCallbacks, true, 0);
194 function pauseProgram() {
204 function pauseProgram() {
@@ -443,12 +453,12 @@ function tracePathInit(runtime, mainNode) {
446−function executeCallbacks(callbacks, reexecute) {
456+function executeCallbacks(callbacks, reexecute, offset) {
447 callbacks.forEach(function(timer) {
457 callbacks.forEach(function(timer) {
448 if (reexecute || !timer.executed) {
458 if (reexecute || !timer.executed) {
449 var func = timer.func;
459 var func = timer.func;
450 timer.executed = true;
460 timer.executed = true;
451− func();
461+ func(offset);