@@ -21,7 +21,6 @@ Elm.debuggerAttach = function(module, hotSwapState /* =undefined */) {
2121};
2222
2323var EVENTS_PER_SAVE = 100;
24−var eventCounter = 0;
2524
2625function dispatchElmDebuggerInit() {
2726 if (parent.window) {
@@ -45,6 +44,7 @@ function debugModule(module, runtime) {
4544 var watchTracker = Elm.Native.Debug.make(runtime).watchTracker;
4645 var pauseTime = 0;
4746 var eventsUntilSnapshot = EVENTS_PER_SAVE;
47+ runtime.eventCounter = runtime.eventCounter || 0;
4848
4949 // runtime is the prototype of wrappedRuntime
5050 // so we can access all runtime properties too
@@ -111,7 +111,7 @@ function debugModule(module, runtime) {
111111 function recordEvent(id, v, timestep) {
112112 watchTracker.pushFrame();
113113 recordedEvents.push({ id:id, value:v, timestep:timestep });
114− eventCounter += 1;
114+ runtime.eventCounter += 1;
115115 }
116116
117117 function clearAsyncCallbacks() {
@@ -124,7 +124,7 @@ function debugModule(module, runtime) {
124124
125125 function clearRecordedEvents() {
126126 recordedEvents = [];
127− eventCounter = 0;
127+ runtime.eventCounter = 0;
128128 }
129129
130130 function getRecordedEventsLength() {
@@ -182,7 +182,7 @@ function debugModule(module, runtime) {
182182 snapshots = snapshots.slice(0, lastSnapshotPosition + 1);
183183 recordedEvents = recordedEvents.slice(0, position);
184184 tracePath.clearTracesAfter(position);
185− eventCounter = position;
185+ runtime.eventCounter = position;
186186 executeCallbacks(asyncCallbacks, false);
187187 }
188188 tracePath.startRecording();
@@ -320,14 +320,14 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
320320 debugModule.setPaused();
321321 debugModule.loadRecordedEvents(hotSwapState.recordedEvents);
322322 var index = getMaxSteps();
323− eventCounter = 0;
323+ runtime.eventCounter = 0;
324324 debugModule.tracePath.clearTraces();
325325
326326 // draw new trace path
327327 debugModule.tracePath.startRecording();
328328 while(currentEventIndex < index) {
329329 var nextEvent = debugModule.getRecordedEventAt(currentEventIndex);
330− eventCounter += 1;
330+ runtime.eventCounter += 1;
331331 runtime.notify(nextEvent.id, nextEvent.value, nextEvent.timestep);
332332 debugModule.snapshotOnCheckpoint();
333333 currentEventIndex += 1;
@@ -412,14 +412,14 @@ function tracePathInit(runtime, signalGraphMain) {
412412 else {
413413 tracePositions[id] = [pos];
414414 }
415− if (tracePositions[id].length < eventCounter) {
416− var padCount = eventCounter - tracePositions[id].length;
415+ if (tracePositions[id].length < runtime.eventCounter) {
416+ var padCount = runtime.eventCounter - tracePositions[id].length;
417417 var lastTracePosition = tracePositions[id][tracePositions[id].length - 1];
418418 for (var i = padCount; i--;) {
419419 tracePositions[id].push(lastTracePosition)
420420 }
421421 }
422− assert(tracePositions[id].length === eventCounter,
422+ assert(tracePositions[id].length === runtime.eventCounter,
423423 "We don't have a 1-1 mapping of trace positions to events");
424424 }
425425 }