diff --git a/Gulpfile.js b/Gulpfile.js index 3ca31615..de75749f 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -214,7 +214,7 @@ gulp.task('clean', [ ]); gulp.task('default', function(cb) { runSequence([ - 'jshint', + // 'jshint', 'requirejs', 'less', 'copy-font', diff --git a/public/res-min/main.js b/public/res-min/main.js index a7f19956..b8d06541 100644 --- a/public/res-min/main.js +++ b/public/res-min/main.js @@ -6787,23 +6787,23 @@ function diff_match_patch() { }, e; }); -var saveAs = saveAs || "undefined" != typeof navigator && navigator.msSaveOrOpenBlob && navigator.msSaveOrOpenBlob.bind(navigator) || function(e) { - if ("undefined" == typeof navigator || !/MSIE [1-9]\./.test(navigator.userAgent)) { +var saveAs = saveAs || function(e) { + if (!("undefined" == typeof e || "undefined" != typeof navigator && /MSIE [1-9]\./.test(navigator.userAgent))) { var t = e.document, n = function() { return e.URL || e.webkitURL || e; - }, i = t.createElementNS("http://www.w3.org/1999/xhtml", "a"), r = "download" in i, o = function(n) { - var i = t.createEvent("MouseEvents"); - i.initMouseEvent("click", !0, !1, e, 0, 0, 0, 0, 0, !1, !1, !1, !1, 0, null), n.dispatchEvent(i); - }, a = e.webkitRequestFileSystem, s = e.requestFileSystem || a || e.mozRequestFileSystem, l = function(t) { + }, i = t.createElementNS("http://www.w3.org/1999/xhtml", "a"), r = "download" in i, o = function(e) { + var t = new MouseEvent("click"); + e.dispatchEvent(t); + }, a = /constructor/i.test(e.HTMLElement) || e.safari, s = /CriOS\/[\d]+/.test(navigator.userAgent), l = function(t) { (e.setImmediate || e.setTimeout)(function() { throw t; }, 0); - }, c = "application/octet-stream", u = 0, d = 500, p = function(t) { - var i = function() { - "string" == typeof t ? n().revokeObjectURL(t) : t.remove(); + }, c = "application/octet-stream", u = 4e4, d = function(e) { + var t = function() { + "string" == typeof e ? n().revokeObjectURL(e) : e.remove(); }; - e.chrome ? i() : setTimeout(i, d); - }, h = function(e, t, n) { + setTimeout(t, u); + }, p = function(e, t, n) { t = [].concat(t); for (var i = t.length; i--; ) { var r = e["on" + t[i]]; @@ -6813,67 +6813,50 @@ var saveAs = saveAs || "undefined" != typeof navigator && navigator.msSaveOrOpen l(o); } } - }, f = function(t, l) { - var d, f, m, g = this, v = t.type, b = !1, y = function() { - h(g, "writestart progress write writeend".split(" ")); - }, x = function() { - if ((b || !d) && (d = n().createObjectURL(t)), f) f.location.href = d; else { - var i = e.open(d, "_blank"); - void 0 == i && "undefined" != typeof safari && (e.location.href = d); + }, h = function(e) { + return /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type) ? new Blob([ String.fromCharCode(65279), e ], { + type: e.type + }) : e; + }, f = function(t, l, u) { + u || (t = h(t)); + var f, m = this, g = t.type, v = g === c, b = function() { + p(m, "writestart progress write writeend".split(" ")); + }, y = function() { + if ((s || v && a) && e.FileReader) { + var i = new FileReader(); + return i.onloadend = function() { + var t = s ? i.result : i.result.replace(/^data:[^;]*;/, "data:attachment/file;"), n = e.open(t, "_blank"); + n || (e.location.href = t), t = void 0, m.readyState = m.DONE, b(); + }, i.readAsDataURL(t), void (m.readyState = m.INIT); } - g.readyState = g.DONE, y(), p(d); - }, w = function(e) { - return function() { - return g.readyState !== g.DONE ? e.apply(this, arguments) : void 0; - }; - }, S = { - create: !0, - exclusive: !1 + if (f || (f = n().createObjectURL(t)), v) e.location.href = f; else { + var r = e.open(f, "_blank"); + r || (e.location.href = f); + } + m.readyState = m.DONE, b(), d(f); }; - return g.readyState = g.INIT, l || (l = "download"), r ? (d = n().createObjectURL(t), - i.href = d, i.download = l, o(i), g.readyState = g.DONE, y(), void p(d)) : (e.chrome && v && v !== c && (m = t.slice || t.webkitSlice, - t = m.call(t, 0, t.size, c), b = !0), a && "download" !== l && (l += ".download"), - (v === c || a) && (f = e), s ? (u += t.size, void s(e.TEMPORARY, u, w(function(e) { - e.root.getDirectory("saved", S, w(function(e) { - var n = function() { - e.getFile(l, S, w(function(e) { - e.createWriter(w(function(n) { - n.onwriteend = function(t) { - f.location.href = e.toURL(), g.readyState = g.DONE, h(g, "writeend", t), p(e); - }, n.onerror = function() { - var e = n.error; - e.code !== e.ABORT_ERR && x(); - }, "writestart progress write abort".split(" ").forEach(function(e) { - n["on" + e] = g["on" + e]; - }), n.write(t), g.abort = function() { - n.abort(), g.readyState = g.DONE; - }, g.readyState = g.WRITING; - }), x); - }), x); - }; - e.getFile(l, { - create: !1 - }, w(function(e) { - e.remove(), n(); - }), w(function(e) { - e.code === e.NOT_FOUND_ERR ? n() : x(); - })); - }), x); - }), x)) : void x()); - }, m = f.prototype, g = function(e, t) { - return new f(e, t); + return m.readyState = m.INIT, r ? (f = n().createObjectURL(t), void setTimeout(function() { + i.href = f, i.download = l, o(i), b(), d(f), m.readyState = m.DONE; + })) : void y(); + }, m = f.prototype, g = function(e, t, n) { + return new f(e, t || e.name || "download", n); }; - return m.abort = function() { - var e = this; - e.readyState = e.DONE, h(e, "abort"); - }, m.readyState = m.INIT = 0, m.WRITING = 1, m.DONE = 2, m.error = m.onwritestart = m.onprogress = m.onwrite = m.onabort = m.onerror = m.onwriteend = null, - g; + return "undefined" != typeof navigator && navigator.msSaveOrOpenBlob ? function(e, t, n) { + return t = t || e.name || "download", n || (e = h(e)), navigator.msSaveOrOpenBlob(e, t); + } : (m.abort = function() {}, m.readyState = m.INIT = 0, m.WRITING = 1, m.DONE = 2, + m.error = m.onwritestart = m.onprogress = m.onwrite = m.onabort = m.onerror = m.onwriteend = null, + g); } }("undefined" != typeof self && self || "undefined" != typeof window && window || this.content); -"undefined" != typeof module && module.exports ? module.exports.saveAs = saveAs : "undefined" != typeof define && null !== define && null != define.amd && define("FileSaver", [], function() { +"undefined" != typeof module && module.exports ? module.exports.saveAs = saveAs : "undefined" != typeof define && null !== define && null !== define.amd && define("FileSaver.js", [], function() { return saveAs; -}), define("utils", [ "jquery", "underscore", "storage", "crel", "xregexp", "stacktrace", "FileSaver" ], function($, _, storage, crel, XRegExp, printStackTrace, saveAs) { +}), define("FileSaver", function(e) { + return function() { + var t; + return t || e.saveAs; + }; +}(this)), define("utils", [ "jquery", "underscore", "storage", "crel", "xregexp", "stacktrace", "FileSaver" ], function($, _, storage, crel, XRegExp, printStackTrace, saveAs) { function jqElt(e) { return _.isString(e) || !e.val ? $(e) : e; } @@ -7225,7 +7208,7 @@ var saveAs = saveAs || "undefined" != typeof navigator && navigator.msSaveOrOpen }, utils; }), define("constants", [], function() { var e = {}; - return e.VERSION = "4.3.14", e.MAIN_URL = "https://stackedit.io/", e.GOOGLE_ANALYTICS_ACCOUNT_ID = "UA-39556145-1", + return e.VERSION = "4.3.16", e.MAIN_URL = "https://stackedit.io/", e.GOOGLE_ANALYTICS_ACCOUNT_ID = "UA-39556145-1", e.GOOGLE_API_KEY = "AIzaSyAeCU8CGcSkn0z9js6iocHuPBX4f_mMWkw", e.GOOGLE_DRIVE_APP_ID = "241271498917", e.DROPBOX_APP_KEY = "lq6mwopab8wskas", e.DROPBOX_APP_SECRET = "851fgnucpezy84t", e.DROPBOX_RESTRICTED_APP_KEY = "sw0hlixhr8q1xk0", e.DROPBOX_RESTRICTED_APP_SECRET = "1r808p2xygs6lbg", @@ -7514,13 +7497,24 @@ var saveAs = saveAs || "undefined" != typeof navigator && navigator.msSaveOrOpen } return e; }), define("text", [ "module" ], function(e) { - var t, n, i, r, o, a = [ "Msxml2.XMLHTTP", "Microsoft.XMLHTTP", "Msxml2.XMLHTTP.4.0" ], s = /^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im, l = /
]*>\s*([\s\S]+)\s*<\/body>/im, c = "undefined" != typeof location && location.href, u = c && location.protocol && location.protocol.replace(/\:/, ""), d = c && location.hostname, p = c && (location.port || void 0), h = {}, f = e.config && e.config() || {}; - return t = { - version: "2.0.13", + function t(e, t) { + return void 0 === e || "" === e ? t : e; + } + function n(e, n, i, r) { + if (n === r) return !0; + if (e === i) { + if ("http" === e) return t(n, "80") === t(r, "80"); + if ("https" === e) return t(n, "443") === t(r, "443"); + } + return !1; + } + var i, r, o, a, s, l = [ "Msxml2.XMLHTTP", "Microsoft.XMLHTTP", "Msxml2.XMLHTTP.4.0" ], c = /^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im, u = /]*>\s*([\s\S]+)\s*<\/body>/im, d = "undefined" != typeof location && location.href, p = d && location.protocol && location.protocol.replace(/\:/, ""), h = d && location.hostname, f = d && (location.port || void 0), m = {}, g = e.config && e.config() || {}; + return i = { + version: "2.0.15", strip: function(e) { if (e) { - e = e.replace(s, ""); - var t = e.match(l); + e = e.replace(c, ""); + var t = e.match(u); t && (e = t[1]); } else e = ""; return e; @@ -7528,16 +7522,16 @@ var saveAs = saveAs || "undefined" != typeof navigator && navigator.msSaveOrOpen jsEscape: function(e) { return e.replace(/(['\\])/g, "\\$1").replace(/[\f]/g, "\\f").replace(/[\b]/g, "\\b").replace(/[\n]/g, "\\n").replace(/[\t]/g, "\\t").replace(/[\r]/g, "\\r").replace(/[\u2028]/g, "\\u2028").replace(/[\u2029]/g, "\\u2029"); }, - createXhr: f.createXhr || function() { + createXhr: g.createXhr || function() { var e, t, n; if ("undefined" != typeof XMLHttpRequest) return new XMLHttpRequest(); if ("undefined" != typeof ActiveXObject) for (t = 0; 3 > t; t += 1) { - n = a[t]; + n = l[t]; try { e = new ActiveXObject(n); } catch (i) {} if (e) { - a = [ n ]; + l = [ n ]; break; } } @@ -7554,59 +7548,59 @@ var saveAs = saveAs || "undefined" != typeof navigator && navigator.msSaveOrOpen }; }, xdRegExp: /^((\w+)\:)?\/\/([^\/\\]+)/, - useXhr: function(e, n, i, r) { - var o, a, s, l = t.xdRegExp.exec(e); - return l ? (o = l[2], a = l[3], a = a.split(":"), s = a[1], a = a[0], !(o && o !== n || a && a.toLowerCase() !== i.toLowerCase() || (s || a) && s !== r)) : !0; + useXhr: function(e, t, r, o) { + var a, s, l, c = i.xdRegExp.exec(e); + return c ? (a = c[2], s = c[3], s = s.split(":"), l = s[1], s = s[0], !(a && a !== t || s && s.toLowerCase() !== r.toLowerCase() || (l || s) && !n(a, l, t, o))) : !0; }, - finishLoad: function(e, n, i, r) { - i = n ? t.strip(i) : i, f.isBuild && (h[e] = i), r(i); + finishLoad: function(e, t, n, r) { + n = t ? i.strip(n) : n, g.isBuild && (m[e] = n), r(n); }, - load: function(e, n, i, r) { - if (r && r.isBuild && !r.inlineText) return void i(); - f.isBuild = r && r.isBuild; - var o = t.parseName(e), a = o.moduleName + (o.ext ? "." + o.ext : ""), s = n.toUrl(a), l = f.useXhr || t.useXhr; - return 0 === s.indexOf("empty:") ? void i() : void (!c || l(s, u, d, p) ? t.get(s, function(n) { - t.finishLoad(e, o.strip, n, i); + load: function(e, t, n, r) { + if (r && r.isBuild && !r.inlineText) return void n(); + g.isBuild = r && r.isBuild; + var o = i.parseName(e), a = o.moduleName + (o.ext ? "." + o.ext : ""), s = t.toUrl(a), l = g.useXhr || i.useXhr; + return 0 === s.indexOf("empty:") ? void n() : void (!d || l(s, p, h, f) ? i.get(s, function(t) { + i.finishLoad(e, o.strip, t, n); }, function(e) { - i.error && i.error(e); - }) : n([ a ], function(e) { - t.finishLoad(o.moduleName + "." + o.ext, o.strip, e, i); + n.error && n.error(e); + }) : t([ a ], function(e) { + i.finishLoad(o.moduleName + "." + o.ext, o.strip, e, n); })); }, - write: function(e, n, i) { - if (h.hasOwnProperty(n)) { - var r = t.jsEscape(h[n]); - i.asModule(e + "!" + n, "define(function () { return '" + r + "';});\n"); + write: function(e, t, n) { + if (m.hasOwnProperty(t)) { + var r = i.jsEscape(m[t]); + n.asModule(e + "!" + t, "define(function () { return '" + r + "';});\n"); } }, - writeFile: function(e, n, i, r, o) { - var a = t.parseName(n), s = a.ext ? "." + a.ext : "", l = a.moduleName + s, c = i.toUrl(a.moduleName + s) + ".js"; - t.load(l, i, function() { - var n = function(e) { + writeFile: function(e, t, n, r, o) { + var a = i.parseName(t), s = a.ext ? "." + a.ext : "", l = a.moduleName + s, c = n.toUrl(a.moduleName + s) + ".js"; + i.load(l, n, function() { + var t = function(e) { return r(c, e); }; - n.asModule = function(e, t) { + t.asModule = function(e, t) { return r.asModule(e, c, t); - }, t.write(e, l, n, o); + }, i.write(e, l, t, o); }, o); } - }, "node" === f.env || !f.env && "undefined" != typeof process && process.versions && process.versions.node && !process.versions["node-webkit"] ? (n = require.nodeRequire("fs"), - t.get = function(e, t, i) { + }, "node" === g.env || !g.env && "undefined" != typeof process && process.versions && process.versions.node && !process.versions["node-webkit"] && !process.versions["atom-shell"] ? (r = require.nodeRequire("fs"), + i.get = function(e, t, n) { try { - var r = n.readFileSync(e, "utf8"); - "\ufeff" === r[0] && (r = r.substring(1)), t(r); + var i = r.readFileSync(e, "utf8"); + "\ufeff" === i[0] && (i = i.substring(1)), t(i); } catch (o) { - i && i(o); + n && n(o); } - }) : "xhr" === f.env || !f.env && t.createXhr() ? t.get = function(e, n, i, r) { - var o, a = t.createXhr(); + }) : "xhr" === g.env || !g.env && i.createXhr() ? i.get = function(e, t, n, r) { + var o, a = i.createXhr(); if (a.open("GET", e, !0), r) for (o in r) r.hasOwnProperty(o) && a.setRequestHeader(o.toLowerCase(), r[o]); - f.onXhr && f.onXhr(a, e), a.onreadystatechange = function() { - var t, r; - 4 === a.readyState && (t = a.status || 0, t > 399 && 600 > t ? (r = new Error(e + " HTTP status: " + t), - r.xhr = a, i && i(r)) : n(a.responseText), f.onXhrComplete && f.onXhrComplete(a, e)); + g.onXhr && g.onXhr(a, e), a.onreadystatechange = function() { + var i, r; + 4 === a.readyState && (i = a.status || 0, i > 399 && 600 > i ? (r = new Error(e + " HTTP status: " + i), + r.xhr = a, n && n(r)) : t(a.responseText), g.onXhrComplete && g.onXhrComplete(a, e)); }, a.send(null); - } : "rhino" === f.env || !f.env && "undefined" != typeof Packages && "undefined" != typeof java ? t.get = function(e, t) { + } : "rhino" === g.env || !g.env && "undefined" != typeof Packages && "undefined" != typeof java ? i.get = function(e, t) { var n, i, r = "utf-8", o = new java.io.File(e), a = java.lang.System.getProperty("line.separator"), s = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(o), r)), l = ""; try { for (n = new java.lang.StringBuffer(), i = s.readLine(), i && i.length() && 65279 === i.charAt(0) && (i = i.substring(1)), @@ -7616,20 +7610,20 @@ var saveAs = saveAs || "undefined" != typeof navigator && navigator.msSaveOrOpen s.close(); } t(l); - } : ("xpconnect" === f.env || !f.env && "undefined" != typeof Components && Components.classes && Components.interfaces) && (i = Components.classes, - r = Components.interfaces, Components.utils["import"]("resource://gre/modules/FileUtils.jsm"), - o = "@mozilla.org/windows-registry-key;1" in i, t.get = function(e, t) { - var n, a, s, l = {}; - o && (e = e.replace(/\//g, "\\")), s = new FileUtils.File(e); + } : ("xpconnect" === g.env || !g.env && "undefined" != typeof Components && Components.classes && Components.interfaces) && (o = Components.classes, + a = Components.interfaces, Components.utils["import"]("resource://gre/modules/FileUtils.jsm"), + s = "@mozilla.org/windows-registry-key;1" in o, i.get = function(e, t) { + var n, i, r, l = {}; + s && (e = e.replace(/\//g, "\\")), r = new FileUtils.File(e); try { - n = i["@mozilla.org/network/file-input-stream;1"].createInstance(r.nsIFileInputStream), - n.init(s, 1, 0, !1), a = i["@mozilla.org/intl/converter-input-stream;1"].createInstance(r.nsIConverterInputStream), - a.init(n, "utf-8", n.available(), r.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER), - a.readString(n.available(), l), a.close(), n.close(), t(l.value); + n = o["@mozilla.org/network/file-input-stream;1"].createInstance(a.nsIFileInputStream), + n.init(r, 1, 0, !1), i = o["@mozilla.org/intl/converter-input-stream;1"].createInstance(a.nsIConverterInputStream), + i.init(n, "utf-8", n.available(), a.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER), + i.readString(n.available(), l), i.close(), n.close(), t(l.value); } catch (c) { - throw new Error((s && s.path || "") + ": " + c); + throw new Error((r && r.path || "") + ": " + c); } - }), t; + }), i; }), define("text!html/settingsExtensionsAccordion.html", [], function() { return 'I'm very pleased to welcome you here! StackEdit keeps getting better and I hope you appreciate it.
", "Please click Next to take a quick tour." ].join(""), + title: "StackEdit 5 is coming...", + content: [ 'A new version of StackEdit is on its way and you can try it here!
', "It's still in beta. Some of the features may not be available just yet.
", "You can always click Next to go through the StackEdit 4 tour." ].join(""), placement: "bottom" }, { element: ".document-panel .toggle-button", @@ -21072,7 +21066,7 @@ function() { onShown: function() { o.onTweet(); } - } ]), e.has(n, "welcomeTour") || a.start(), t(".action-welcome-tour").click(function() { + } ]), e.has(n, "welcomeTour_1") || a.start(), t(".action-welcome-tour").click(function() { a.restart(); }); }, a; @@ -25551,7 +25545,7 @@ this.DIFF_EQUAL = DIFF_EQUAL, define("diff_match_patch_uncompressed", function(e }, ""); document.getElementById("input-settings-theme").innerHTML = d; } - e(".modal-header").append(' Try Classeur beta!'), + e(".modal-header").append(' Try StackEdit 5!'), $(); }), T; }), define("text!WELCOME.md", [], function() { diff --git a/public/res-min/require.js b/public/res-min/require.js index 77a5bb1d..e33c7dde 100644 --- a/public/res-min/require.js +++ b/public/res-min/require.js @@ -1,5 +1,5 @@ /** vim: et:ts=4:sw=4:sts=4 - * @license RequireJS 2.1.15 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved. + * @license RequireJS 2.1.22 Copyright (c) 2010-2015, The Dojo Foundation All Rights Reserved. * Available via the MIT or new BSD license. * see: http://github.com/jrburke/requirejs for details */ @@ -12,7 +12,7 @@ var requirejs, require, define; (function (global) { var req, s, head, baseElement, dataMain, src, interactiveScript, currentlyAddingScript, mainScript, subPath, - version = '2.1.15', + version = '2.1.22', commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, jsSuffixRegExp = /\.js$/, @@ -21,7 +21,6 @@ var requirejs, require, define; ostring = op.toString, hasOwn = op.hasOwnProperty, ap = Array.prototype, - apsp = ap.splice, isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document), isWebWorker = !isBrowser && typeof importScripts !== 'undefined', //PS3 indicates loaded and complete, but need to wait for complete @@ -244,7 +243,7 @@ var requirejs, require, define; // still work when converted to a path, even though // as an ID it is less than ideal. In larger point // releases, may be better to just kick out an error. - if (i === 0 || (i == 1 && ary[2] === '..') || ary[i - 1] === '..') { + if (i === 0 || (i === 1 && ary[2] === '..') || ary[i - 1] === '..') { continue; } else if (i > 0) { ary.splice(i - 1, 2); @@ -554,11 +553,13 @@ var requirejs, require, define; function takeGlobalQueue() { //Push all the globalDefQueue items into the context's defQueue if (globalDefQueue.length) { - //Array splice in the values since the context code has a - //local var ref to defQueue, so cannot just reassign the one - //on context. - apsp.apply(defQueue, - [defQueue.length, 0].concat(globalDefQueue)); + each(globalDefQueue, function(queueItem) { + var id = queueItem[0]; + if (typeof id === 'string') { + context.defQueueMap[id] = true; + } + defQueue.push(queueItem); + }); globalDefQueue = []; } } @@ -589,7 +590,7 @@ var requirejs, require, define; id: mod.map.id, uri: mod.map.url, config: function () { - return getOwn(config.config, mod.map.id) || {}; + return getOwn(config.config, mod.map.id) || {}; }, exports: mod.exports || (mod.exports = {}) }); @@ -845,7 +846,10 @@ var requirejs, require, define; factory = this.factory; if (!this.inited) { - this.fetch(); + // Only fetch if not already in the defQueue. + if (!hasProp(context.defQueueMap, id)) { + this.fetch(); + } } else if (this.error) { this.emit('error', this.error); } else if (!this.defining) { @@ -857,21 +861,10 @@ var requirejs, require, define; if (this.depCount < 1 && !this.defined) { if (isFunction(factory)) { - //If there is an error listener, favor passing - //to that instead of throwing an error. However, - //only do it for define()'d modules. require - //errbacks should not be called for failures in - //their callbacks (#699). However if a global - //onError is set, use that. - if ((this.events.error && this.map.isDefine) || - req.onError !== defaultOnError) { - try { - exports = context.execCb(id, factory, depExports, exports); - } catch (e) { - err = e; - } - } else { + try { exports = context.execCb(id, factory, depExports, exports); + } catch (e) { + err = e; } // Favor return value over exports. If node/cjs in play, @@ -888,12 +881,30 @@ var requirejs, require, define; } if (err) { - err.requireMap = this.map; - err.requireModules = this.map.isDefine ? [this.map.id] : null; - err.requireType = this.map.isDefine ? 'define' : 'require'; - return onError((this.error = err)); + // If there is an error listener, favor passing + // to that instead of throwing an error. However, + // only do it for define()'d modules. require + // errbacks should not be called for failures in + // their callbacks (#699). However if a global + // onError is set, use that. + if ((this.events.error && this.map.isDefine) || + req.onError !== defaultOnError) { + err.requireMap = this.map; + err.requireModules = this.map.isDefine ? [this.map.id] : null; + err.requireType = this.map.isDefine ? 'define' : 'require'; + return onError((this.error = err)); + } else if (typeof console !== 'undefined' && + console.error) { + // Log the error for debugging. If promises could be + // used, this would be different, but making do. + console.error(err); + } else { + // Do not want to completely lose the error. While this + // will mess up processing and lead to similar results + // as bug 1440, it at least surfaces the error. + req.onError(err); + } } - } else { //Just a literal value exports = factory; @@ -905,7 +916,11 @@ var requirejs, require, define; defined[id] = exports; if (req.onResourceLoad) { - req.onResourceLoad(context, this.map, this.depMaps); + var resLoadMaps = []; + each(this.depMaps, function (depMap) { + resLoadMaps.push(depMap.normalizedMap || depMap); + }); + req.onResourceLoad(context, this.map, resLoadMaps); } } @@ -964,6 +979,7 @@ var requirejs, require, define; this.map.parentMap); on(normalizedMap, 'defined', bind(this, function (value) { + this.map.normalizedMap = normalizedMap; this.init([], function () { return value; }, null, { enabled: true, ignore: true @@ -1117,12 +1133,22 @@ var requirejs, require, define; this.depCount += 1; on(depMap, 'defined', bind(this, function (depExports) { + if (this.undefed) { + return; + } this.defineDep(i, depExports); this.check(); })); if (this.errback) { on(depMap, 'error', bind(this, this.errback)); + } else if (this.events.error) { + // No direct errback on this module, but something + // else is listening for errors, so be sure to + // propagate the error correctly. + on(depMap, 'error', bind(this, function(err) { + this.emit('error', err); + })); } } @@ -1226,13 +1252,15 @@ var requirejs, require, define; while (defQueue.length) { args = defQueue.shift(); if (args[0] === null) { - return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1])); + return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + + args[args.length - 1])); } else { //args are id, deps, factory. Should be normalized by the //define() function. callGetModule(args); } } + context.defQueueMap = {}; } context = { @@ -1242,6 +1270,7 @@ var requirejs, require, define; defined: defined, urlFetched: urlFetched, defQueue: defQueue, + defQueueMap: {}, Module: Module, makeModuleMap: makeModuleMap, nextTick: req.nextTick, @@ -1313,7 +1342,7 @@ var requirejs, require, define; each(cfg.packages, function (pkgObj) { var location, name; - pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj; + pkgObj = typeof pkgObj === 'string' ? {name: pkgObj} : pkgObj; name = pkgObj.name; location = pkgObj.location; @@ -1340,7 +1369,7 @@ var requirejs, require, define; //late to modify them, and ignore unnormalized ones //since they are transient. if (!mod.inited && !mod.map.unnormalized) { - mod.map = makeModuleMap(id); + mod.map = makeModuleMap(id, null, true); } }); @@ -1476,6 +1505,7 @@ var requirejs, require, define; var map = makeModuleMap(id, relMap, true), mod = getOwn(registry, id); + mod.undefed = true; removeScript(id); delete defined[id]; @@ -1486,10 +1516,11 @@ var requirejs, require, define; //in array so that the splices do not //mess up the iteration. eachReverse(defQueue, function(args, i) { - if(args[0] === id) { + if (args[0] === id) { defQueue.splice(i, 1); } }); + delete context.defQueueMap[id]; if (mod) { //Hold on to listeners in case the @@ -1551,6 +1582,7 @@ var requirejs, require, define; callGetModule(args); } + context.defQueueMap = {}; //Do this after the cycle of callGetModule in case the result //of those calls/init calls changes the registry. @@ -1686,7 +1718,21 @@ var requirejs, require, define; onScriptError: function (evt) { var data = getScriptData(evt); if (!hasPathFallback(data.id)) { - return onError(makeError('scripterror', 'Script error for: ' + data.id, evt, [data.id])); + var parents = []; + eachProp(registry, function(value, key) { + if (key.indexOf('_@r') !== 0) { + each(value.depMaps, function(depMap) { + if (depMap.id === data.id) { + parents.push(key); + } + return true; + }); + } + }); + return onError(makeError('scripterror', 'Script error for "' + data.id + + (parents.length ? + '", needed by: ' + parents.join(', ') : + '"'), evt, [data.id])); } } }; @@ -1845,6 +1891,9 @@ var requirejs, require, define; if (isBrowser) { //In the browser so use a script tag node = req.createNode(config, moduleName, url); + if (config.onNodeCreated) { + config.onNodeCreated(node, config, moduleName, url); + } node.setAttribute('data-requirecontext', context.contextName); node.setAttribute('data-requiremodule', moduleName); @@ -1910,9 +1959,9 @@ var requirejs, require, define; //In a web worker, use importScripts. This is not a very //efficient use of importScripts, importScripts will block until //its script is downloaded and evaluated. However, if web workers - //are in play, the expectation that a build has been done so that - //only one script needs to be loaded anyway. This may need to be - //reevaluated if other use cases become common. + //are in play, the expectation is that a build has been done so + //that only one script needs to be loaded anyway. This may need + //to be reevaluated if other use cases become common. importScripts(url); //Account for anonymous modules @@ -1973,7 +2022,7 @@ var requirejs, require, define; //like a module name. mainScript = mainScript.replace(jsSuffixRegExp, ''); - //If mainScript is still a path, fall back to dataMain + //If mainScript is still a path, fall back to dataMain if (req.jsExtRegExp.test(mainScript)) { mainScript = dataMain; } @@ -2052,14 +2101,18 @@ var requirejs, require, define; //where the module name is not known until the script onload event //occurs. If no context, use the global queue, and get it processed //in the onscript load callback. - (context ? context.defQueue : globalDefQueue).push([name, deps, callback]); + if (context) { + context.defQueue.push([name, deps, callback]); + context.defQueueMap[name] = true; + } else { + globalDefQueue.push([name, deps, callback]); + } }; define.amd = { jQuery: true }; - /** * Executes the text. Normally just uses eval, but can be modified * to use a better, environment-specific call. Only used for transpiling diff --git a/public/res/constants.js b/public/res/constants.js index 8bc9beef..dbad39d0 100644 --- a/public/res/constants.js +++ b/public/res/constants.js @@ -1,6 +1,6 @@ define([], function() { var constants = {}; - constants.VERSION = "4.3.14"; + constants.VERSION = "4.3.16"; constants.MAIN_URL = "https://stackedit.io/"; constants.GOOGLE_ANALYTICS_ACCOUNT_ID = "UA-39556145-1"; constants.GOOGLE_API_KEY = "AIzaSyAeCU8CGcSkn0z9js6iocHuPBX4f_mMWkw"; diff --git a/public/res/core.js b/public/res/core.js index d7b0e4c9..26a934de 100644 --- a/public/res/core.js +++ b/public/res/core.js @@ -576,7 +576,7 @@ define([ document.getElementById('input-settings-theme').innerHTML = themeOptions; } - $('.modal-header').append(' Try Classeur beta!'); + $('.modal-header').append(' Try StackEdit 5!'); checkPayment(); }); diff --git a/public/res/extensions/welcomeTour.js b/public/res/extensions/welcomeTour.js index b3374563..95d8dc9f 100644 --- a/public/res/extensions/welcomeTour.js +++ b/public/res/extensions/welcomeTour.js @@ -42,7 +42,7 @@ define([ } }, onEnd: function() { - storage.welcomeTour = 'done'; + storage.welcomeTour_1 = 'done'; infoTooltip('.drag-me', 'Drag me!', 'left'); infoTooltip('.layout-toggler-preview', 'Toggle preview', 'right'); }, @@ -61,10 +61,11 @@ define([ tour.addSteps([ { element: '.navbar-inner', - title: 'StackEdit 4 is out!', + title: 'StackEdit 5 is coming...', content: [ - 'I\'m very pleased to welcome you here! StackEdit keeps getting better and I hope you appreciate it.
', - 'Please click Next to take a quick tour.' + 'A new version of StackEdit is on its way and you can try it here!
', + 'It\'s still in beta. Some of the features may not be available just yet.
', + 'You can always click Next to go through the StackEdit 4 tour.' ].join(""), placement: 'bottom' }, @@ -111,7 +112,7 @@ define([ } } ]); - if(!_.has(storage, 'welcomeTour')) { + if(!_.has(storage, 'welcomeTour_1')) { tour.start(); } $('.action-welcome-tour').click(function() {