@@ -41,6 +41,31 @@ function debugModule(module, runtime) {
41 var watchTracker = Elm.Native.Debug.make(runtime).watchTracker;
41 var watchTracker = Elm.Native.Debug.make(runtime).watchTracker;
42 var pauseTime = 0;
42 var pauseTime = 0;
44+ // runtime is the prototype of wrappedRuntime
45+ // so we can access all runtime properties too
46+ var wrappedRuntime = Object.create(runtime);
47+ wrappedRuntime.notify = wrapNotify;
48+ wrappedRuntime.runDelayed = wrapRunDelayed;
50+ // make a copy of the wrappedRuntime
51+ var assignedPropTracker = Object.create(wrappedRuntime);
52+ var debuggedModule = module.make(assignedPropTracker);
54+ // make sure the signal graph is actually a signal & extract the visual model
55+ if ( !('recv' in debuggedModule.main) ) {
56+ debuggedModule.main = Elm.Signal.make(runtime).constant(debuggedModule.main);
59+ // The main module stores imported modules onto the runtime.
60+ // To ensure only one instance of each module is created,
61+ // we assign them back on the original runtime object.
62+ Object.keys(assignedPropTracker).forEach(function(key) {
63+ runtime[key] = assignedPropTracker[key];
66+ var signalGraphNodes = flattenSignalGraph(wrappedRuntime.inputs);
67+ var tracePath = tracePathInit(runtime, debuggedModule.main);
44 function wrapNotify(id, v) {
69 function wrapNotify(id, v) {
45 var timestep = runtime.timer.now();
70 var timestep = runtime.timer.now();
@@ -132,30 +157,6 @@ function debugModule(module, runtime) {
132 return programPaused;
157 return programPaused;
135− // runtime is the prototype of wrappedRuntime
136− // so we can access all runtime properties too
137− var wrappedRuntime = Object.create(runtime);
138− wrappedRuntime.notify = wrapNotify;
139− wrappedRuntime.runDelayed = wrapRunDelayed;
141− var assignedPropTracker = Object.create(wrappedRuntime);
142− var debuggedModule = module.make(assignedPropTracker);
144− // make sure the signal graph is actually a signal & extract the visual model
145− if ( !('recv' in debuggedModule.main) ) {
146− debuggedModule.main = Elm.Signal.make(runtime).constant(debuggedModule.main);
149− // The main module stores imported modules onto the runtime.
150− // To ensure only one instance of each module is created,
151− // we assign them back on the original runtime object.
152− Object.keys(assignedPropTracker).forEach(function(key) {
153− runtime[key] = assignedPropTracker[key];
156− var signalGraphNodes = flattenSignalGraph(wrappedRuntime.inputs);
157− var tracePath = tracePathInit(runtime, debuggedModule.main);
160 debuggedModule: debuggedModule,
161 debuggedModule: debuggedModule,
161 signalGraphNodes: signalGraphNodes,
162 signalGraphNodes: signalGraphNodes,