Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

minispade transport

  • Loading branch information...
commit 060dcc9fa60814e630b5dd557ddfce83b7149521 1 parent 92c930f
@wycats authored
Showing with 64 additions and 8 deletions.
  1. +38 −1 lib/main.js
  2. +13 −7 package.json
  3. +13 −0 transport.js
View
39 lib/main.js
@@ -1 +1,38 @@
-// TODO: Add package code
+if (typeof document !== "undefined") {
+ (function() {
+ minispade = {
+ modules: {},
+ loaded: {},
+
+ require: function(name) {
+ var loaded = minispade.loaded[name];
+ var mod = minispade.modules[name];
+
+ if (!loaded) {
+ if (mod) {
+ loaded = mod();
+ minispade.loaded[name] = loaded;
+ } else {
+ throw "The module '" + name + "' could not be found";
+ }
+ }
+
+ return loaded;
+ },
+
+ register: function(name, callback) {
+ minispade.modules[name] = callback;
+ }
+ };
+
+ setTimeout(function() {
+ var modules = minispade.modules;
+
+ for (var name in modules) {
+ if (modules.hasOwnProperty(name)) {
+ minispade.require(name);
+ }
+ }
+ });
+ })();
+}
View
20 package.json
@@ -1,18 +1,24 @@
{
- "name": "my_package",
- "summary": "Short package description",
- "description": "Long package description",
- "homepage": "http://mypackage.com",
- "author": "Your Name",
- "version": "1.0.0",
+ "name": "minispade",
+ "summary": "A tiny runtime dependency management solution",
+ "description": "A tiny runtime dependency management solution that makes it easy to wrap up an entire package as a dependency",
+ "homepage": "http://yehudakatz.com",
+ "author": "Yehuda Katz",
+ "version": "1.0.0.pre2",
"directories": {
"lib": "lib"
},
-
+
"bpm:build": {
"bpm_libs.js": {
"files": ["lib"]
}
+ },
+
+ "bpm:provides": {
+ "transport": {
+ "main": "minispade/transport"
+ }
}
}
View
13 transport.js
@@ -0,0 +1,13 @@
+BPM_PLUGIN.compileTransport = function(code, context, filename) {
+ var ret = '', packageName = context.package.name, id;
+
+ if (context.moduleId === 'main') {
+ id = packageName;
+ } else {
+ id = [packageName, moduleId].join("/");
+ }
+
+ code = "function() { " + code + "}";
+ ret += "minispade.register('"+id+"',"+code+");";
+ return ret;
+};
Please sign in to comment.
Something went wrong with that request. Please try again.