@@ -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,7 @@ 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.eventCounter = runtime.eventCounter || 0;
49 // runtime is the prototype of wrappedRuntime
49 // runtime is the prototype of wrappedRuntime
50 // so we can access all runtime properties too
50 // so we can access all runtime properties too
@@ -111,7 +111,7 @@ function debugModule(module, runtime) {
111 function recordEvent(id, v, timestep) {
111 function recordEvent(id, v, timestep) {
112 watchTracker.pushFrame();
112 watchTracker.pushFrame();
113 recordedEvents.push({ id:id, value:v, timestep:timestep });
113 recordedEvents.push({ id:id, value:v, timestep:timestep });
114− eventCounter += 1;
114+ runtime.eventCounter += 1;
117 function clearAsyncCallbacks() {
117 function clearAsyncCallbacks() {
@@ -124,7 +124,7 @@ function debugModule(module, runtime) {
125 function clearRecordedEvents() {
125 function clearRecordedEvents() {
126 recordedEvents = [];
126 recordedEvents = [];
127− eventCounter = 0;
127+ runtime.eventCounter = 0;
130 function getRecordedEventsLength() {
130 function getRecordedEventsLength() {
@@ -182,7 +182,7 @@ function debugModule(module, runtime) {
182 snapshots = snapshots.slice(0, lastSnapshotPosition + 1);
182 snapshots = snapshots.slice(0, lastSnapshotPosition + 1);
183 recordedEvents = recordedEvents.slice(0, position);
183 recordedEvents = recordedEvents.slice(0, position);
184 tracePath.clearTracesAfter(position);
184 tracePath.clearTracesAfter(position);
185− eventCounter = position;
185+ runtime.eventCounter = position;
186 executeCallbacks(asyncCallbacks, false);
186 executeCallbacks(asyncCallbacks, false);
188 tracePath.startRecording();
188 tracePath.startRecording();
@@ -320,14 +320,14 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
320 debugModule.setPaused();
320 debugModule.setPaused();
321 debugModule.loadRecordedEvents(hotSwapState.recordedEvents);
321 debugModule.loadRecordedEvents(hotSwapState.recordedEvents);
322 var index = getMaxSteps();
322 var index = getMaxSteps();
323− eventCounter = 0;
323+ runtime.eventCounter = 0;
324 debugModule.tracePath.clearTraces();
324 debugModule.tracePath.clearTraces();
326 // draw new trace path
326 // draw new trace path
327 debugModule.tracePath.startRecording();
327 debugModule.tracePath.startRecording();
328 while(currentEventIndex < index) {
328 while(currentEventIndex < index) {
329 var nextEvent = debugModule.getRecordedEventAt(currentEventIndex);
329 var nextEvent = debugModule.getRecordedEventAt(currentEventIndex);
330− eventCounter += 1;
330+ runtime.eventCounter += 1;
331 runtime.notify(nextEvent.id, nextEvent.value, nextEvent.timestep);
331 runtime.notify(nextEvent.id, nextEvent.value, nextEvent.timestep);
332 debugModule.snapshotOnCheckpoint();
332 debugModule.snapshotOnCheckpoint();
333 currentEventIndex += 1;
333 currentEventIndex += 1;
@@ -412,14 +412,14 @@ function tracePathInit(runtime, signalGraphMain) {
413 tracePositions[id] = [pos];
413 tracePositions[id] = [pos];
415− if (tracePositions[id].length < eventCounter) {
415+ if (tracePositions[id].length < runtime.eventCounter) {
416− var padCount = eventCounter - tracePositions[id].length;
416+ var padCount = runtime.eventCounter - tracePositions[id].length;
417 var lastTracePosition = tracePositions[id][tracePositions[id].length - 1];
417 var lastTracePosition = tracePositions[id][tracePositions[id].length - 1];
418 for (var i = padCount; i--;) {
418 for (var i = padCount; i--;) {
419 tracePositions[id].push(lastTracePosition)
419 tracePositions[id].push(lastTracePosition)
422− assert(tracePositions[id].length === eventCounter,
422+ assert(tracePositions[id].length === runtime.eventCounter,
423 "We don't have a 1-1 mapping of trace positions to events");
423 "We don't have a 1-1 mapping of trace positions to events");