Permalink
Browse files

Merge remote-tracking branch 'upstream/sourcemint' into 00

Conflicts:
	package.json
  • Loading branch information...
2 parents 43e543f + eeeaf7d commit a831eef3e8019b6a68e53c4746245cdf8a75a385 @nightwing nightwing committed May 4, 2012
@@ -0,0 +1,16 @@
+{
+ "main": "./demo.js",
+ "mappings": {
+ "ace": "../.."
+ },
+ "config": {
+ "github.com/sourcemint/bundler-js/0/-meta/config/0": {
+ "adapter": "github.com/sourcemint/sdk-requirejs/0",
+ "resources": [
+ "./icons/*",
+ "./logo.png",
+ "./styles.css"
+ ]
+ }
+ }
+}
@@ -50,7 +50,14 @@ var WorkerClient = function(topLevelNamespaces, packagedJs, mod, classname) {
this.$worker = new Worker(config.get("workerPath") + "/" + packagedJs);
}
else {
- var workerUrl = this.$normalizePath(require.nameToUrl("ace/worker/worker", null, "_"));
+ var workerUrl;
+ if (typeof require.supports !== "undefined" && require.supports.indexOf("ucjs2-pinf-0") >= 0) {
+ // We are running in the sourcemint loader.
+ workerUrl = require.nameToUrl("ace/worker/worker_sourcemint");
+ } else {
+ // We are running in RequireJS.
+ workerUrl = this.$normalizePath(require.nameToUrl("ace/worker/worker", null, "_"));
+ }
this.$worker = new Worker(workerUrl);
var tlns = {};
@@ -0,0 +1,73 @@
+
+define(function(require, exports, module) {
+
+ "no use strict";
+
+ exports.main = function()
+ {
+ var console = {
+ log: function(msg) {
+ postMessage({type: "log", data: msg});
+ }
+ };
+
+ // NOTE: This sets the global `window` object used by workers.
+ // TODO: Pass into worker what it needs and don't set global here.
+ window = {
+ console: console
+ };
+
+ function initSender() {
+
+ var EventEmitter = require("ace/lib/event_emitter").EventEmitter;
+ var oop = require("ace/lib/oop");
+
+ var Sender = function() {};
+
+ (function() {
+
+ oop.implement(this, EventEmitter);
+
+ this.callback = function(data, callbackId) {
+ postMessage({
+ type: "call",
+ id: callbackId,
+ data: data
+ });
+ };
+
+ this.emit = function(name, data) {
+ postMessage({
+ type: "event",
+ name: name,
+ data: data
+ });
+ };
+
+ }).call(Sender.prototype);
+
+ return new Sender();
+ }
+
+ var main;
+ var sender;
+
+ onmessage = function(e) {
+ var msg = e.data;
+ if (msg.command) {
+ main[msg.command].apply(main, msg.args);
+ }
+ else if (msg.init) {
+ require("ace/lib/fixoldbrowsers");
+ sender = initSender();
+ require.async(msg.module, function(WORKER) {
+ var clazz = WORKER[msg.classname];
+ main = new clazz(sender);
+ });
+ }
+ else if (msg.event && sender) {
+ sender._emit(msg.event, msg.data);
+ }
+ };
+ }
+});
View
@@ -24,6 +24,9 @@
"engines": {
"node": "~0.6.0"
},
+ "mappings": {
+ "ace": "."
+ },
"licenses": [{
"type": "MPL",
"url": "http://www.mozilla.org/MPL/"
@@ -39,5 +42,28 @@
},
"scripts": {
"test": "node lib/ace/test/all.js"
+ },
+ "config": {
+ "github.com/sourcemint/bundler-js/0/-meta/config/0": {
+ "adapter": "github.com/sourcemint/sdk-requirejs/0",
+ "modules": {
+ "/lib/ace/virtual_renderer.js": {
+ "dynamicLinks": [
+ "/lib/ace/theme/*.js"
+ ]
+ },
+ "/lib/ace/worker/worker_client.js": {
+ "dynamicLinks": [
+ "/lib/ace/worker/worker_sourcemint.js"
+ ]
+ },
+ "/lib/ace/worker/worker_sourcemint.js": {
+ "bundleLoader": true,
+ "dynamicLinks": [
+ "/lib/ace/mode/*_worker.js"
+ ]
+ }
+ }
+ }
}
}
View
@@ -0,0 +1,2 @@
+/dist/
+/node_modules/
View
@@ -0,0 +1,63 @@
+Develop & Distribute ACE using the Sourcemint Loader
+====================================================
+
+The [Sourcemint JavaScript Loader](https://github.com/sourcemint/loader-js) is an optimized
+module loader that boots sets of *statically linked* modules from *bundles*. An application may
+load additional bundles by using *dynamic links*.
+
+*Bundles* are generated from the AMD formatted source files on the fly during development (using a server helper)
+and in-batch for production builds. To generate bundles the Sourcemint [RequireJS SDK](https://github.com/sourcemint/sdk-requirejs)
+and [Platform NodeJS](https://github.com/sourcemint/platform-nodejs) projects are used.
+
+
+Development
+===========
+
+**Requirements:**
+
+ * [NodeJS](http://nodejs.org/)
+
+**Install:**
+
+ git clone git://github.com/ajaxorg/ace.git
+ cd ace
+ # TMP: Switch to sourcemint branch
+ git checkout sourcemint
+ cd sourcemint
+ npm install
+
+**Start development server:**
+
+ node dev
+
+**NOTE:** Modified source files are automatically reloaded on browser refresh so there is no
+need to restart the server during development.
+
+
+Production
+==========
+
+To generate production bundles, use the same setup as for *Development*, then run:
+
+ // NOT YET IMPLEMENTED
+ node build ../demo/kitchen-sink ./dist
+
+Where `../demo/kitchen-sink` is the path to your ACE bootstrap package which embeds ACE in the page
+or provides an interface for the rest of your application to interact with ACE.
+
+Everything needed for ACE (and your bootstrap package) to run will be written to the `./dist` directory which can be
+used in a production application by serving these static files via a web server. To load the bootstrap file use:
+
+ <!-- Load the Sourcemint JavaScript Loader -->
+ <script type="text/javascript" src="./dist/loader.min.js"></script>
+ <!-- Load ACE bootstrap file -->
+ <script type="text/javascript">
+ require.sandbox("./dist/kitchen-sink.js", function(sandbox) {
+ sandbox.main();
+ });
+ </script>
+
+See `../demo/kitchen-sink` for an example of how to write an ACE bootstrap package.
+
+See [Embedding Ace](https://github.com/ajaxorg/ace) and [Embedding API](https://github.com/ajaxorg/ace/wiki/Embedding---API)
+for more information on how to embed and interact with ACE.
View
@@ -0,0 +1,47 @@
+
+var PATH = require("path"),
+ FS = require("fs"),
+ CONNECT = require("connect"),
+ BUNDLER = require("sourcemint-platform-nodejs/lib/bundler");
+
+
+exports.main = function(options) {
+
+ var server = CONNECT();
+
+ server.use(CONNECT.router(function(app) {
+
+ app.get(/^\/loader.js/, CONNECT.static(PATH.dirname(require.resolve("sourcemint-loader-js/loader.js"))));
+
+ app.get(/^(?:\/demo\/kitchen-sink)(?:\.js)?(\/.*)?$/, BUNDLER.hoist(PATH.dirname(__dirname) + "/demo/kitchen-sink", {
+ distributionBasePath: __dirname + "/dist",
+ packageIdHashSeed: "__ACE__",
+ bundleLoader: false,
+ logger: {
+ log: function() {
+ console.log.apply(null, arguments);
+ }
+ }
+ }));
+
+ app.get(/^\//, function(req, res)
+ {
+ CONNECT.static(__dirname)(req, res, function()
+ {
+ res.writeHead(404);
+ res.end("Not found!");
+ });
+ });
+ }));
+
+ server.listen(options.port, "127.0.0.1");
+
+ console.log("ACE development server running at http://127.0.0.1:" + options.port + "/");
+}
+
+if (require.main === module) {
+ // TODO: Make configurable via command-line flag.
+ exports.main({
+ port: 8888
+ });
+}
View
@@ -0,0 +1,16 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd">
+
+<html lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <title>Ace Development Server</title>
+</head>
+<body>
+
+ <h1>Demos</h1>
+
+ <p><a href="kitchen-sink.html">Kitchen Sink</a></p>
+
+</body>
+</html>
Oops, something went wrong.

0 comments on commit a831eef

Please sign in to comment.