@@ -21,7 +21,6 @@ Elm.debuggerAttach = function(module, hotSwapState /* =undefined */) {
23var EVENTS_PER_SAVE = 100;
23var EVENTS_PER_SAVE = 100;
26function dispatchElmDebuggerInit() {
25function dispatchElmDebuggerInit() {
27 if (parent.window) {
26 if (parent.window) {
@@ -45,6 +44,8 @@ function debugModule(module, runtime) {
45 var watchTracker = Elm.Native.Debug.make(runtime).watchTracker;
44 var watchTracker = Elm.Native.Debug.make(runtime).watchTracker;
46 var pauseTime = 0;
45 var pauseTime = 0;
47 var eventsUntilSnapshot = EVENTS_PER_SAVE;
46 var eventsUntilSnapshot = EVENTS_PER_SAVE;
47+ runtime.debuggerStatus = runtime.debuggerStatus || {};
48+ runtime.debuggerStatus.eventCounter = runtime.debuggerStatus.eventCounter || 0;
49 // runtime is the prototype of wrappedRuntime
50 // runtime is the prototype of wrappedRuntime
50 // so we can access all runtime properties too
51 // so we can access all runtime properties too
@@ -111,7 +112,7 @@ function debugModule(module, runtime) {
111 function recordEvent(id, v, timestep) {
112 function recordEvent(id, v, timestep) {
112 watchTracker.pushFrame();
113 watchTracker.pushFrame();
113 recordedEvents.push({ id:id, value:v, timestep:timestep });
114 recordedEvents.push({ id:id, value:v, timestep:timestep });
114− eventCounter += 1;
115+ runtime.debuggerStatus.eventCounter += 1;
117 function clearAsyncCallbacks() {
118 function clearAsyncCallbacks() {
@@ -124,7 +125,7 @@ function debugModule(module, runtime) {
125 function clearRecordedEvents() {
126 function clearRecordedEvents() {
126 recordedEvents = [];
127 recordedEvents = [];
127− eventCounter = 0;
128+ runtime.debuggerStatus.eventCounter = 0;
130 function getRecordedEventsLength() {
131 function getRecordedEventsLength() {
@@ -187,7 +188,7 @@ function debugModule(module, runtime) {
188 recordedEvents = recordedEvents.slice(0, position);
189 recordedEvents = recordedEvents.slice(0, position);
189 tracePath.clearTracesAfter(position);
190 tracePath.clearTracesAfter(position);
190− eventCounter = position;
191+ runtime.debuggerStatus.eventCounter = position;
191 executeCallbacks(asyncCallbacks, false);
192 executeCallbacks(asyncCallbacks, false);
193 tracePath.startRecording();
194 tracePath.startRecording();
@@ -325,14 +326,14 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
325 debugModule.setPaused();
326 debugModule.setPaused();
326 debugModule.loadRecordedEvents(hotSwapState.recordedEvents);
327 debugModule.loadRecordedEvents(hotSwapState.recordedEvents);
327 var index = getMaxSteps();
328 var index = getMaxSteps();
328− eventCounter = 0;
329+ runtime.debuggerStatus.eventCounter = 0;
329 debugModule.tracePath.clearTraces();
330 debugModule.tracePath.clearTraces();
331 // draw new trace path
332 // draw new trace path
332 debugModule.tracePath.startRecording();
333 debugModule.tracePath.startRecording();
333 while(currentEventIndex < index) {
334 while(currentEventIndex < index) {
334 var nextEvent = debugModule.getRecordedEventAt(currentEventIndex);
335 var nextEvent = debugModule.getRecordedEventAt(currentEventIndex);
335− eventCounter += 1;
336+ runtime.debuggerStatus.eventCounter += 1;
336 runtime.notify(nextEvent.id, nextEvent.value, nextEvent.timestep);
337 runtime.notify(nextEvent.id, nextEvent.value, nextEvent.timestep);
337 debugModule.snapshotOnCheckpoint();
338 debugModule.snapshotOnCheckpoint();
338 currentEventIndex += 1;
339 currentEventIndex += 1;
@@ -422,14 +423,14 @@ function tracePathInit(runtime, signalGraphMain) {
423 tracePositions[id] = [pos];
424 tracePositions[id] = [pos];
425− if (tracePositions[id].length < eventCounter) {
426+ if (tracePositions[id].length < runtime.debuggerStatus.eventCounter) {
426− var padCount = eventCounter - tracePositions[id].length;
427+ var padCount = runtime.debuggerStatus.eventCounter - tracePositions[id].length;
427 var lastTracePosition = tracePositions[id][tracePositions[id].length - 1];
428 var lastTracePosition = tracePositions[id][tracePositions[id].length - 1];
428 for (var i = padCount; i--;) {
429 for (var i = padCount; i--;) {
429 tracePositions[id].push(lastTracePosition)
430 tracePositions[id].push(lastTracePosition)
432− assert(tracePositions[id].length === eventCounter,
433+ assert(tracePositions[id].length === runtime.debuggerStatus.eventCounter,
433 "We don't have a 1-1 mapping of trace positions to events");
434 "We don't have a 1-1 mapping of trace positions to events");