| global.location = { href: "file://" + process.cwd() + "/" }; |
| global.scheduleImmediate = setImmediate; |
| global.self = global; |
| global.require = require; |
| global.process = process; |
| |
| function computeCurrentScript() { |
| try { |
| throw new Error(); |
| } catch(e) { |
| var stack = e.stack; |
| var re = new RegExp("^ *at [^(]*\\((.*):[0-9]*:[0-9]*\\)$", "mg"); |
| var lastMatch = null; |
| do { |
| var match = re.exec(stack); |
| if (match != null) lastMatch = match; |
| } while (match != null); |
| return lastMatch[1]; |
| } |
| } |
| |
| var cachedCurrentScript = null; |
| global.document = { |
| get currentScript() { |
| if (cachedCurrentScript == null) { |
| cachedCurrentScript = {src: computeCurrentScript()}; |
| } |
| return cachedCurrentScript; |
| } |
| }; |
| |
| global.dartDeferredLibraryLoader = function(uri, successCallback, errorCallback) { |
| try { |
| load(uri); |
| successCallback(); |
| } catch (error) { |
| errorCallback(error); |
| } |
| }; |