From fcb3331d695c07473e850bf7f51c51a6c2fbbc17 Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 20 Jun 2014 02:26:10 +0400 Subject: [PATCH 1/6] remove special build version for bookmarklet --- Makefile.dryice.js | 27 ---- ...{editor_textarea.html => bookmarklet.html} | 69 +++++----- lib/ace/ext/textarea.js | 118 +++++++----------- 3 files changed, 79 insertions(+), 135 deletions(-) rename build_support/{editor_textarea.html => bookmarklet.html} (62%) diff --git a/Makefile.dryice.js b/Makefile.dryice.js index 19ba9192..f0f1f391 100755 --- a/Makefile.dryice.js +++ b/Makefile.dryice.js @@ -69,8 +69,6 @@ function main(args) { ace(); } else if (type == "demo") { demo(); - } else if (type == "bm") { - bookmarklet(); } else if (type == "full") { demo(ace()); bookmarklet(); @@ -98,7 +96,6 @@ function main(args) { console.log(" minimal Places necessary Ace files out in build dir; uses configuration flags below [default]"); console.log(" normal Runs four Ace builds--minimal, minimal-noconflict, minimal-min, and minimal-noconflict-min"); console.log(" demo Runs demo build of Ace"); - console.log(" bm Runs bookmarklet build of Ace"); console.log(" full all of above"); console.log(" highlighter "); console.log("args:"); @@ -113,30 +110,6 @@ function main(args) { console.log(" output generated in " + type + __dirname + "/" + BUILD_DIR) } -function bookmarklet() { - var targetDir = BUILD_DIR + "/textarea"; - copy({ - source: "build_support/editor_textarea.html", - dest: targetDir + '/editor.html' - }); - copy({ - source: "build_support/style.css", - dest: targetDir + '/style.css' - }); - - buildAce({ - targetDir: targetDir + "/src", - ns: "__ace_shadowed__", - exportModule: "ace/ext/textarea", - compress: false, - noconflict: true, - suffix: "", - name: "ace-bookmarklet", - workers: [], - keybindings: [] - }); -} - function ace() { console.log('# ace ---------'); diff --git a/build_support/editor_textarea.html b/build_support/bookmarklet.html similarity index 62% rename from build_support/editor_textarea.html rename to build_support/bookmarklet.html index bb691c11..f3d95ee7 100644 --- a/build_support/editor_textarea.html +++ b/build_support/bookmarklet.html @@ -20,7 +20,7 @@ function foo() { var bar = true; }
SourceUrl:
-
+

@@ -49,63 +49,60 @@ function foo() { ')} - scripts.forEach(function(s) { - s = s.replace(/"/g, ""); - if (s == "ace/ace") { - comment("load ace") - script("ace") - } else { - var extName = s.match(/[^/]*$/)[0]; - comment("load ace " + extName + " extension"); - script("ext-" + extName); - } - }); - result.push("')} + scripts.forEach(function(s) { + s = s.replace(/"/g, ""); + if (s == "ace/ace") { + comment("load ace"); + script("ace"); + } else { + var extName = s.match(/[^/]*$/)[0]; + comment("load ace " + extName + " extension"); + script("ext-" + extName); + } + }); + result.push(" - diff --git a/package.json b/package.json index cbabb3a0..58aabdf9 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "asyncjs": "0.0.x", "jsdom": "0.2.x", "amd-loader": "~0.0.4", - "dryice": "0.4.10" + "dryice": "0.4.11" }, "mappings": { "ace": "." From b42108a2c993b684036620e606201f6989ff91b4 Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 20 Jun 2014 10:37:23 +0400 Subject: [PATCH 3/6] remove unnecessary use of async --- Makefile.dryice.js | 104 ++++++++++++++++++++++----------------------- 1 file changed, 51 insertions(+), 53 deletions(-) diff --git a/Makefile.dryice.js b/Makefile.dryice.js index 8bf54562..5f5d69bc 100755 --- a/Makefile.dryice.js +++ b/Makefile.dryice.js @@ -33,7 +33,6 @@ var fs = require("fs"); var path = require("path"); var copy = require('architect-build/copy'); var build = require('architect-build/build'); -var async = require("asyncjs"); var ACE_HOME = __dirname; var BUILD_DIR = ACE_HOME + "/build"; @@ -346,58 +345,57 @@ function buildSubmodule(options, extra, file, callback) { function buildAce(options) { var snippetFiles = jsFileList("lib/ace/snippets"); var modeNames = modeList(); - async.forEach([ - buildCore.bind(null, options, {outputFile: "ace.js"}), - // modes - async.forEach.bind(null, modeNames, function(name, next) { - buildSubmodule(options, { - projectType: "mode", - require: ["ace/mode/" + name] - }, "mode-" + name, next); - }), - // snippets - async.forEach.bind(null, modeNames, function(name, next) { - if (snippetFiles.indexOf(name + ".js") == -1) - addSnippetFile(name); - - buildSubmodule(options, { - require: ["ace/snippets/" + name], - }, "snippets/" + name, next); - }), - // themes - async.forEach.bind(null, jsFileList("lib/ace/theme"), function(name, next) { - buildSubmodule(options, { - projectType: "theme", - require: ["ace/theme/" + name] - }, "theme-" + name.replace("_theme", ""), next); - }), - // keybindings - async.forEach.bind(null, ["vim", "emacs"], function(name, next) { - buildSubmodule(options, { - projectType: "keybinding", - require: ["ace/keyboard/" + name ] - }, "keybinding-" + name, next); - }), - // extensions - async.forEach.bind(null, jsFileList("lib/ace/ext"), function(name, next) { - buildSubmodule(options, { - projectType: "ext", - require: ["ace/ext/" + name] - }, "ext-" + name, next); - }), - // workers - async.forEach.bind(null, workers("lib/ace/mode"), function(name, next) { - buildSubmodule(options, { - projectType: "worker", - require: ["ace/mode/" + name + "_worker"], - additional: [{ - id: "ace/worker/worker", - loaderModule: true, - order: -1000 - }], - }, "worker-" + name, next); - }), - ], function(f, next) { f(next); }); + + buildCore(options, {outputFile: "ace.js"}), + // modes + modeNames.forEach(function(name) { + buildSubmodule(options, { + projectType: "mode", + require: ["ace/mode/" + name] + }, "mode-" + name); + }); + // snippets + modeNames.forEach(function(name) { + if (snippetFiles.indexOf(name + ".js") == -1) + addSnippetFile(name); + + buildSubmodule(options, { + require: ["ace/snippets/" + name], + }, "snippets/" + name); + }); + // themes + jsFileList("lib/ace/theme").forEach(function(name) { + buildSubmodule(options, { + projectType: "theme", + require: ["ace/theme/" + name] + }, "theme-" + name.replace("_theme", "")); + }); + // keybindings + ["vim", "emacs"].forEach(function(name) { + buildSubmodule(options, { + projectType: "keybinding", + require: ["ace/keyboard/" + name ] + }, "keybinding-" + name); + }); + // extensions + jsFileList("lib/ace/ext").forEach(function(name) { + buildSubmodule(options, { + projectType: "ext", + require: ["ace/ext/" + name] + }, "ext-" + name); + }); + // workers + workers("lib/ace/mode").forEach(function(name) { + buildSubmodule(options, { + projectType: "worker", + require: ["ace/mode/" + name + "_worker"], + additional: [{ + id: "ace/worker/worker", + loaderModule: true, + order: -1000 + }], + }, "worker-" + name); + }); } function getLoadedFileList(options, callback, result) { From e52884761d447c85e6a597732abfcfae4874e00a Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 20 Jun 2014 10:38:05 +0400 Subject: [PATCH 4/6] keep demo/kitchein-sink folders location in the build --- Makefile.dryice.js | 15 +++++---------- kitchen-sink.html | 10 ++-------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/Makefile.dryice.js b/Makefile.dryice.js index 5f5d69bc..a0982577 100755 --- a/Makefile.dryice.js +++ b/Makefile.dryice.js @@ -132,25 +132,20 @@ function demo() { ); } - function fixDocPaths(data) { - return data.replace(/"(demo|build)\//g, "\""); - } - - copy(ACE_HOME + "/demo/kitchen-sink", BUILD_DIR + "/kitchen-sink", { + copy(ACE_HOME + "/demo/kitchen-sink", BUILD_DIR + "/demo/kitchen-sink", { shallow: true, - replace: [changeComments, fixDocPaths], + replace: [changeComments], include: /\.(css|html)$/ }); - copy(ACE_HOME +"/demo/kitchen-sink/docs/", BUILD_DIR + "/kitchen-sink/docs/"); + copy(ACE_HOME +"/demo/kitchen-sink/docs/", BUILD_DIR + "/demo/kitchen-sink/docs/"); - copy.file(ACE_HOME + "/demo/kitchen-sink/logo.png", BUILD_DIR + "/kitchen-sink/logo.png"); + copy.file(ACE_HOME + "/demo/kitchen-sink/logo.png", BUILD_DIR + "/demo/kitchen-sink/logo.png"); buildSubmodule({}, { require: ["kitchen-sink/demo"], - filters: [fixDocPaths], projectType: "demo" - }, BUILD_DIR + "/kitchen-sink/demo"); + }, BUILD_DIR + "/demo/kitchen-sink/demo"); copy(ACE_HOME + "/demo/", BUILD_DIR + "/demo/", { shallow: true, diff --git a/kitchen-sink.html b/kitchen-sink.html index f55cfa14..d32b98b5 100644 --- a/kitchen-sink.html +++ b/kitchen-sink.html @@ -11,16 +11,10 @@ commit %commit% --> - - - - + + -
From e5b2eed5c58425c3ae3db35da9328320a57582f2 Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 20 Jun 2014 20:54:08 +0400 Subject: [PATCH 5/6] add architect build to package.json --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 58aabdf9..31a4dec9 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "asyncjs": "0.0.x", "jsdom": "0.2.x", "amd-loader": "~0.0.4", - "dryice": "0.4.11" + "dryice": "0.4.11", + "architect-build": "https://github.com/c9/architect-build/tarball/42723e152bb" }, "mappings": { "ace": "." From 67143599981cadec7b9898d0fdd028f73ff8d7ba Mon Sep 17 00:00:00 2001 From: nightwing Date: Sat, 21 Jun 2014 00:45:50 +0400 Subject: [PATCH 6/6] tweak --- Makefile | 1 - Makefile.dryice.js | 61 +++++++++++++++++----------------------------- kitchen-sink.html | 2 +- 3 files changed, 24 insertions(+), 40 deletions(-) diff --git a/Makefile b/Makefile index 95dcf964..29cf0495 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,6 @@ pre_build: build: pre_build ./Makefile.dryice.js normal ./Makefile.dryice.js demo - ./Makefile.dryice.js bm # Minimal build: call Makefile.dryice.js only if our sources changed basic: build/src/ace.js diff --git a/Makefile.dryice.js b/Makefile.dryice.js index a0982577..2bc36f8b 100755 --- a/Makefile.dryice.js +++ b/Makefile.dryice.js @@ -112,14 +112,11 @@ function ace() { function demo() { console.log('# kitchen sink ---------'); - var version, ref; + var version = "", ref = ""; try { version = JSON.parse(fs.readFileSync(ACE_HOME + "/package.json")).version; ref = fs.readFileSync(ACE_HOME + "/.git-ref").toString(); - } catch(e) { - ref = ""; - version = ""; - } + } catch(e) {} function changeComments(data) { return (data @@ -131,16 +128,12 @@ function demo() { .replace("%commit%", ref) ); } - - copy(ACE_HOME + "/demo/kitchen-sink", BUILD_DIR + "/demo/kitchen-sink", { - shallow: true, - replace: [changeComments], - include: /\.(css|html)$/ - }); copy(ACE_HOME +"/demo/kitchen-sink/docs/", BUILD_DIR + "/demo/kitchen-sink/docs/"); copy.file(ACE_HOME + "/demo/kitchen-sink/logo.png", BUILD_DIR + "/demo/kitchen-sink/logo.png"); + copy.file(ACE_HOME + "/demo/kitchen-sink/styles.css", BUILD_DIR + "/demo/kitchen-sink/styles.css"); + copy.file(ACE_HOME + "/kitchen-sink.html", BUILD_DIR + "/kitchen-sink.html", changeComments); buildSubmodule({}, { require: ["kitchen-sink/demo"], @@ -214,9 +207,9 @@ function buildAceModule(opts, callback) { buildAceModule.dequeue = function() { if (buildAceModule.running) return; var call = buildAceModule.queue.shift(); + buildAceModule.running = call; if (call) buildAceModuleInternal.apply(null, call); - buildAceModule.running = call; }; } @@ -235,7 +228,7 @@ function buildAceModule(opts, callback) { function buildAceModuleInternal(opts, callback) { var cache = opts.cache == undefined ? CACHE : opts.cache; - var key = opts.require + "|" + opts.compress + "|" + opts.projectType; + var key = opts.require + "|" + opts.projectType; if (cache && cache.configs && cache.configs[key]) return write(null, cache.configs[key]); @@ -249,19 +242,23 @@ function buildAceModuleInternal(opts, callback) { }; function write(err, result) { - if (opts.compress) - result.code = compress(result.code); - - if (cache && key) { + if (cache && key && !(cache.configs && cache.configs[key])) { cache.configs = cache.configs || Object.create(null); cache.configs[key] = result; result.sources = result.sources.map(function(pkg) { return {deps: pkg.deps}; }); - } + } if (!opts.outputFile) return callback(err, result); + + var code = result.code; + if (opts.compress) { + if (!result.codeMin) + result.codeMin = compress(result.code); + code = result.codeMin; + } var targetDir = BUILD_DIR + "/src"; if (opts.compress) @@ -287,7 +284,6 @@ function buildAceModuleInternal(opts, callback) { opts.noconflict ? ns : "", projectType == "ext")); } - var code = result.code; filters.forEach(function(f) { code = f(code); }); build.writeToFile({code: code}, { @@ -331,7 +327,7 @@ function buildSubmodule(options, extra, file, callback) { options = extend(extra, options); getLoadedFileList(options, function(coreFiles) { options.outputFile = file + ".js"; - options.ignore = coreFiles; + options.ignore = options.ignore || coreFiles; options.quiet = true; buildAceModule(options, callback); }); @@ -384,9 +380,10 @@ function buildAce(options) { buildSubmodule(options, { projectType: "worker", require: ["ace/mode/" + name + "_worker"], + ignore: [], additional: [{ id: "ace/worker/worker", - loaderModule: true, + transforms: [], order: -1000 }], }, "worker-" + name); @@ -467,9 +464,7 @@ function namespace(ns) { return function(text) { text = text .toString() - .replace('var ACE_NAMESPACE = "";', 'var ACE_NAMESPACE = "' + ns +'";') - // .replace(/(\.define)|([,;\n]|^\s*?)define\(/g, function(_, a, b) { - // return a || b + ns + ".define("; + .replace(/ACE_NAMESPACE\s*=\s*""/, 'ACE_NAMESPACE = "' + ns +'"') .replace(/(\.define)|\bdefine\(/g, function(_, a) { return a || ns + ".define("; }); @@ -551,20 +546,10 @@ function addSnippetFile(modeName) { } function compress(text) { - return asciify(require("dryice").copy.filter.uglifyjs(text)); - // copy.filter.uglifyjs.options.ascii_only = true; doesn't work with some uglify.js versions - function asciify(text) { - return text.replace(/[\x00-\x08\x0b\x0c\x0e\x19\x80-\uffff]/g, function(c) { - c = c.charCodeAt(0).toString(16); - if (c.length == 1) - return "\\x0" + c; - if (c.length == 2) - return "\\x" + c; - if (c.length == 3) - return "\\u0" + c; - return "\\u" + c; - }); - } + var ujs = require("dryice").copy.filter.uglifyjs; + ujs.options.mangle_toplevel = {except: ["ACE_NAMESPACE", "requirejs"]}; + ujs.options.beautify = {ascii_only: true, inline_script: true} + return ujs(text); } function extend(base, extra) { diff --git a/kitchen-sink.html b/kitchen-sink.html index d32b98b5..65fe2a2a 100644 --- a/kitchen-sink.html +++ b/kitchen-sink.html @@ -281,7 +281,7 @@ - +