UNPKG

chocolate

Version:

A full stack Node.js web framework built using Coffeescript

1,454 lines (1,375 loc) 51.4 kB
if (typeof window !== "undefined" && window !== null) { window.previousExports = window.exports; window.exports = {} }; // Generated by CoffeeScript 1.12.6 /* Intention Data Action Document Workflow Interface Actor Reserve Prototype */ (function() { var previousRequire, ref, require, resolve, use_cache; if ((typeof window !== "undefined" && window !== null) && (((ref = window.modules) != null ? ref.locco : void 0) == null)) { window.modules = { locco: window[window.exports != null ? "exports" : "Locco"] = {} }; if (!($ && $.ajax)) { if (window.require == null) { window.require = function() { return window.exports; }; } return; } previousRequire = window.require; use_cache = true; window.require = require = function(modulename, filename, options) { var _previousExports, _previous_use_cache, cachedModule, result, url; if (arguments.length === 2 && Object.prototype.toString.apply(filename !== '[object String]')) { options = filename; filename = null; } if (filename == null) { filename = modulename; } filename = resolve(filename); if ((options != null ? options.use_cache : void 0) != null) { _previous_use_cache = use_cache; use_cache = options.use_cache; } result = typeof previousRequire === "function" ? previousRequire(filename) : void 0; if (result != null) { return result; } if (use_cache) { cachedModule = window.modules[filename]; if (cachedModule != null) { return cachedModule; } } _previousExports = window.exports; window.exports = {}; url = '/static/lib/' + filename + '.js'; $.ajax({ url: url, async: false, cache: true, error: function(type, xhr, settings) { return console.log('require("' + url + '") failed' + (xhr.status != null ? ' with error ' + (xhr.status != null) : '')); }, dataType: 'script' }); result = window.modules[filename] = window.exports; window.exports = _previousExports; if ((options != null ? options.use_cache : void 0) != null) { use_cache = _previous_use_cache; } return result; }; window.require.resolve = resolve = function(filename) { var i; filename = filename.toLowerCase().replace(/^\.\//, '').replace(/\.\.\//g, '').replace(/chocolate\//g, '').replace(/^general\//, '').replace(/^client\//, '').replace(/^server\//, ''); return filename = (i = filename.lastIndexOf('.')) >= 0 ? filename.slice(0, i) : filename; }; window.require.cache = function(used) { return use_cache = used; }; } }).call(this); if (typeof window !== "undefined" && window !== null) { window.modules['locco/intention'] = window.exports; window.exports = window.previousExports }; if (typeof window !== "undefined" && window !== null) { window.previousExports = window.exports; window.exports = {} }; // Generated by CoffeeScript 1.12.6 (function() { var Data, _, _module; _ = require('../../general/chocodash'); Data = _.prototype({ constructor: function(uuid, name, data) { this.uuid = uuid != null ? uuid : _.Uuid(); this.name = name; this.data = data; } }); _module = typeof window !== "undefined" && window !== null ? window : module; if (_module.exports != null) { _module.exports = Data; } else { if (window.Locco == null) { window.Locco = {}; } window.Locco.Data = Data; } }).call(this); if (typeof window !== "undefined" && window !== null) { window.modules['locco/data'] = window.exports; window.exports = window.previousExports }; if (typeof window !== "undefined" && window !== null) { window.previousExports = window.exports; window.exports = {} }; // Generated by CoffeeScript 1.12.6 (function() { var Action, _, _module; _ = require('../../general/chocodash'); Action = _.prototype({ constructor: function() { return this.actions = []; }, "do": function(what, value, type) { this.actions.push({ so: 'do', what: what, value: value }); return this; }, move: function(what, where, how) { this.actions.push({ so: 'move', what: what, where: where, how: how }); return this; }, "eval": function(what, value) { this.actions.push({ so: 'eval', what: what, value: value }); return this; }, go: function(what, where) { if (where == null) { where = Action.go.Where.Inside; } this.actions.push({ so: 'go', what: what, where: where }); return this; } }); Action.prototype["do"].What = { New: 0, Set: 1, Delete: 2 }; Action.prototype.move.How = { Replace: 0, Append: 1, Prepend: 2, InsertBefore: 3, InsertAfter: 4 }; Action.prototype.go.Where = { Front: 0, Inside: 1, Through: 2 }; _module = typeof window !== "undefined" && window !== null ? window : module; if (_module.exports != null) { _module.exports = Action; } else { if (window.Locco == null) { window.Locco = {}; } window.Locco.Action = Action; } }).call(this); if (typeof window !== "undefined" && window !== null) { window.modules['locco/action'] = window.exports; window.exports = window.previousExports }; if (typeof window !== "undefined" && window !== null) { window.previousExports = window.exports; window.exports = {} }; // Generated by CoffeeScript 1.12.6 (function() { var Data, Document, _, _module; _ = require('../../general/chocodash'); Data = require('../../general/locco/data'); Document = _.prototype({ constructor: function(definition) { var helpers, i, len, methodName, ref; helpers = { set: function(key, value) { _["do"].set(this.definition, key, value); return this.value(this.definition); } }; ref = ["pop", "push", "reverse", "shift", "sort", "splice", "unshift"]; for (i = 0, len = ref.length; i < len; i++) { methodName = ref[i]; helpers[methodName] = (function(methodName) { return function() { var result; Array.prototype.unshift.call(arguments, this.definition); result = _["do"][methodName].apply(null, arguments); this.value(this.definition); return result; }; })(methodName); } return this.signal = new _.Signal(definition, helpers); }, use: function() { var i, len, methodName, ref, results; this.set = function(key, value) { return this.signal.set(key, value); }; this["delete"] = function(key) { return this.signal["delete"](key); }; this.get = function() { return this.signal.value(); }; ref = ["pop", "push", "reverse", "shift", "sort", "splice", "unshift"]; results = []; for (i = 0, len = ref.length; i < len; i++) { methodName = ref[i]; results.push(this[methodName] = (function(methodName) { return function() { var output; output = this.signal[methodName].apply(this.signal, arguments); return output; }; })(methodName)); } return results; } }); _module = typeof window !== "undefined" && window !== null ? window : module; if (_module.exports != null) { _module.exports = Document; } else { if (window.Locco == null) { window.Locco = {}; } window.Locco.Document = Document; } }).call(this); if (typeof window !== "undefined" && window !== null) { window.modules['locco/document'] = window.exports; window.exports = window.previousExports }; if (typeof window !== "undefined" && window !== null) { window.previousExports = window.exports; window.exports = {} }; // Generated by CoffeeScript 1.12.6 (function() { var Action, Workflow, _, _module, slice = [].slice; _ = require('../../general/chocodash'); Action = require('../locco/action'); Workflow = _.prototype({ adopt: { Status: { Public: 'public', Private: 'private' } }, constructor: function(options) { var connect, is_ready, sync, when_ready; if (options == null) { options = {}; } when_ready = new _.Publisher; is_ready = false; this.is_ready = function() { return is_ready; }; this.actors = {}; this.ready = function(func) { if (this.ws.readyState === 1) { return setTimeout(((function(_this) { return function() { is_ready = true; return func.call(_this); }; })(this)), 0); } else { return when_ready.subscribe(((function(_this) { return function() { is_ready = true; return func.call(_this); }; })(this))); } }; sync = function() { var actions; actions = _["do"].flush(); if (actions == null) { } }; if (typeof module === "undefined" || module === null) { if ($ && $.websocket) { (connect = (function(_this) { return function() { var _id, callbacks; callbacks = {}; _id = 1; _this.message_id = function(callback) { callbacks[_id.toString()] = callback; return _id++; }; _this.ws = $.websocket("wss://" + window.location.host + "/~"); _this.ws.onmessage = function(evt) { var callback, data, ref; if (options.debug) { if (evt.data !== '') { console.log("Message is received:" + evt.data); } } data = JSON.parse(evt.data); if (data != null) { if (data.result !== void 0 && data.id) { callback = callbacks[data.id]; callback(data.result); return delete callbacks[data.id]; } else { if (((ref = data.console) != null ? ref.log : void 0) != null) { return console.log(data.console.log); } } } }; _this.ws.onopen = function() { var actor, id, ref; if (options.debug) { console.log("Connection opened"); } when_ready.notify(); ref = _this.actors; for (id in ref) { actor = ref[id]; actor.status.notify(Workflow.Status.Public); } }; return _this.ws.onclose = function() { var actor, id, ref; if (options.debug) { console.log("Connection closed. Reopening..."); } setTimeout(connect, 300); ref = _this.actors; for (id in ref) { actor = ref[id]; actor.status.notify(Workflow.Status.Private); } }; }; })(this))(); return setInterval(sync, 300); } } }, enter: function(actor) { return this.actors[actor.id()] = actor; }, call: function() { var callback, i, location, module, name, object, param, params, ref, service; object = arguments[0], service = arguments[1], params = 4 <= arguments.length ? slice.call(arguments, 2, i = arguments.length - 1) : (i = 2, []), callback = arguments[i++]; if (typeof window !== "undefined" && window !== null) { location = null; ref = window.modules; for (name in ref) { module = ref[name]; if (module === object.constructor) { location = 'general/' + name; break; } } if (location == null) { location = window.location.pathname.substr(1); } if (service != null) { params = ((function() { var j, len, results; results = []; for (j = 0, len = params.length; j < len; j++) { param = params[j]; results.push(_.param(param)); } return results; })()).join('&'); if (params.length > 0) { params = '&' + params; } return this.ws.send(JSON.stringify({ url: "/" + location + "?" + service + params, id: this.message_id(callback) })); } } }, execute: function(action) { var i, len, ref, results; ref = action.actions; results = []; for (i = 0, len = ref.length; i < len; i++) { action = ref[i]; switch (so) { case 'go': break; default: results.push(void 0); } } return results; } }); Workflow.main = new Workflow; Workflow.actor = function(id) { return Workflow.main.actors[id]; }; _module = typeof window !== "undefined" && window !== null ? window : module; if (_module.exports != null) { _module.exports = Workflow; } else { if (window.Locco == null) { window.Locco = {}; } window.Locco.Workflow = Workflow; } }).call(this); if (typeof window !== "undefined" && window !== null) { window.modules['locco/workflow'] = window.exports; window.exports = window.previousExports }; if (typeof window !== "undefined" && window !== null) { window.previousExports = window.exports; window.exports = {} }; // Generated by CoffeeScript 1.12.6 (function() { var Chocokup, Interface, _, _module, hasProp = {}.hasOwnProperty, indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; _ = require('../../general/chocodash'); Chocokup = require('../../general/chocokup'); Interface = _.prototype({ constructor: function(defaults, use, service) { var item, name; if (service == null) { service = use; use = void 0; } if (service == null) { service = defaults; defaults = void 0; } if (typeof service === 'function') { service = { render: service }; } if ((service != null) && (defaults != null)) { service.defaults = defaults; } if ((service != null) && (use != null)) { service.use = use; } if (service != null) { if (service.defaults != null) { if (typeof service.defaults === 'function') { this.defaults = service.defaults; } else { this.defaults = _.defaults(this.defaults, service.defaults); } } if (service.locks != null) { if (typeof service.locks === 'function') { this.locks = service.locks; } else { this.locks = (this.locks != null ? this.locks : this.locks = []).concat(service.locks); } } if (service.use != null) { if (typeof service.use === 'function') { this.use = service.use; } else { this.use = _.defaults(this.use, service.use); } } if (service.check != null) { this.check = service.check; } if (service.steps != null) { this.steps = service.steps; } if (service.action != null) { this.render = service.action; } for (name in service) { item = service[name]; if (name !== 'defaults' && name !== 'use' && name !== 'locks' && name !== 'check' && name !== 'steps') { this[name] = item; } } if (this.embedded == null) { this.embedded = void 0; } this.module_path = (function() { var files_stack, found, i, j, len, len1, line, oldPST, stack; files_stack = []; if (Error.prepareStackTrace != null) { oldPST = Error.prepareStackTrace; Error.prepareStackTrace = function(err, stack) { return stack; }; stack = (new Error).stack; Error.prepareStackTrace = oldPST; if (typeof stack === 'string') { files_stack = stack.split('\n'); } else { for (i = 0, len = stack.length; i < len; i++) { line = stack[i]; files_stack.push(line.getFileName()); } } } else { stack = (new Error).stack; files_stack = stack.toString().split('\n'); } found = false; for (j = 0, len1 = files_stack.length; j < len1; j++) { line = files_stack[j]; if (line.indexOf('/chocodash.') >= 0) { found = true; } else if (line.indexOf('\\chocodash.') >= 0) { found = true; } else if (found) { return line; } } return 'global'; })(); } }, bind: function(actor, document, name1) { this.name = name1; if (!((this.actor != null) && (this.document != null))) { this.actor = actor; this.document = document; switch (_.type(this.update)) { case _.Type.Function: return this.observe(this.update); case _.Type.String: return this.observe((function(_this) { return function(html) { $(_this.update).html(html); }; })(this)); } } }, review: function(bin, reaction) { var check, ref, ref1, ref2, self; if (reaction.certified == null) { reaction.certified = true; } if (this.embedded != null) { this.embedded.review(bin, reaction); } if (reaction.certified) { self = { bin: bin, props: bin, space: bin != null ? (ref = bin.__) != null ? ref.space : void 0 : void 0, document: this.document, 'interface': this, actor: this.actor }; check = { defaults: (function(_this) { return function(object, defaults) { var set; if (typeof defaults === 'function') { defaults = defaults.call(self, object); } set = function(o, d) { var dk, dv; for (dk in d) { if (!hasProp.call(d, dk)) continue; dv = d[dk]; if ((_.isBasicObject(o[dk]) || o[dk] instanceof Interface.Web.Global) && (_.isBasicObject(dv) || dv instanceof Interface.Web.Global)) { set(o[dk], dv); } else { if (o[dk] == null) { o[dk] = dv; } } } return o; }; return set(object, defaults); }; })(this), use: (function(_this) { return function(object, required) { var set; if (typeof required === 'function') { required = required.call(self, object); } set = function(o, d) { var dk, dv; for (dk in d) { if (!hasProp.call(d, dk)) continue; dv = d[dk]; if ((_.isBasicObject(o[dk]) || o[dk] instanceof Interface.Web.Global) && (_.isBasicObject(dv) || dv instanceof Interface.Web.Global)) { set(o[dk], dv); } else { o[dk] = dv; } } return o; }; return set(object, required); }; })(this), locks: (function(_this) { return function(keys, locks) { var i, len, lock, ref1; if (locks == null) { return true; } if (typeof locks === 'function') { locks = locks.call(self); } for (i = 0, len = locks.length; i < len; i++) { lock = locks[i]; if (!(((ref1 = lock.key) != null ? ref1 : lock) in keys)) { return false; } } return true; }; })(this), values: (function(_this) { return function(bin, controller) { return controller.call(self, bin); }; })(this) }; if (this.defaults != null) { check.defaults(bin, this.defaults); } if (this.use != null) { check.use(bin, this.use); } if (reaction.certified) { if (this.locks != null) { reaction.certified = check.locks((ref1 = bin.__) != null ? (ref2 = ref1.session) != null ? ref2.keys : void 0 : void 0, this.locks); } } if (reaction.certified) { if (this.check != null) { reaction.certified = check.values(bin, this.check); } } } }, submit: function(bin) { var publisher, reaction; if (bin == null) { bin = {}; } publisher = new _.Publisher; reaction = new Interface.Reaction; _.flow({ self: this }, function(run) { var getSelf; getSelf = function(end) { var ref, respond, transmit; respond = function(o) { reaction.props = reaction.bin = o; return end(); }; respond.later = end.later; transmit = function(actor, service, bin) { var interface_; if (bin == null) { bin = {}; } if (typeof service !== 'string') { interface_ = actor; bin = service; service = ''; } else { interface_ = actor[service]; } interface_.submit(_.extend(this.bin, bin)).subscribe((function(_this) { return function(reaction) { return _this.respond(reaction.bin); }; })(this)); return respond.later; }; return { bin: bin, props: bin, space: bin != null ? (ref = bin.__) != null ? ref.space : void 0 : void 0, document: this.document, 'interface': this, actor: this.actor, reaction: reaction, respond: respond, transmit: transmit }; }; run(function(end) { var ref, result, self; this.review(bin, reaction); if (reaction.certified && ((ref = this.embedded) != null ? ref.steps : void 0)) { self = getSelf.call(this.embedded, end); result = this.embedded.steps.call(self, bin); } return end["with"](result); }); run(function(end) { var result, self; if (reaction.certified && (this.steps != null)) { self = getSelf.call(this, end); result = this.steps.call(self, bin); } return end["with"](result); }); run(function(end) { var redirect, result, self; if (reaction.certified) { if (this.render != null) { self = getSelf.call(this, end); result = this.render.call(self, bin); if (!((reaction.bin != null) || result === end.later)) { reaction.props = reaction.bin = result; } } } else { redirect = this.embedded != null ? this.embedded.redirect : this.redirect; if (redirect != null) { self = getSelf.call(this, end); reaction.redirect = typeof redirect === 'function' ? redirect.call(self) : redirect; } } return end["with"](result); }); return run(function() { return publisher.notify(reaction); }); }); return publisher; }, observe: function(render) { return new _.Observer((function(_this) { return function() { var ref; if ((ref = _this.document.signal) != null) { ref.value(); } return _this.submit().subscribe(function(arg) { var bin; bin = arg.bin; return render(typeof bin.render === 'function' ? bin.render() : bin); }); }; })(this)); } }); Interface.Reaction = _.prototype({ constructor: function(bin1, certified) { this.bin = bin1; this.certified = certified; this.props = this.bin; } }); Interface.Remote = _.prototype({ inherit: Interface, use: function() { return this.submit = function(bin) { if (bin == null) { bin = {}; } if ('__' in bin) { return _["super"](this, bin); } else { return this.actor.submit(this.name, bin); } }; } }); Interface.Web = _.prototype({ inherit: Interface, use: function() { var get_declare_kups; get_declare_kups = function(kups) { var declare_kups, declare_path, i, j, kup, len, len1, path, ref, step; declare_kups = []; declare_path = {}; for (i = 0, len = kups.length; i < len; i++) { kup = kups[i]; path = "this.locals"; ref = kup.scope; for (j = 0, len1 = ref.length; j < len1; j++) { step = ref[j]; path += "." + step; if (declare_path[path] == null) { declare_path[path] = path + " = " + path + " ? " + path + " : {}"; declare_kups.push(declare_path[path]); } } declare_kups.push("this.locals" + (kup.scope.length > 0 ? '.' + kup.scope.join('.') : '') + "." + kup.name + " = _kup_" + kup.id); } return declare_kups; }; this.type = 'App'; this.review = function(bin, reaction) { var check_interfaces, checked, checked_kups, scope; _["super"](Interface.Web.prototype.review, this, bin, reaction); if (reaction.certified) { reaction.props = reaction.bin = ''; if (reaction.kups === false) { return; } scope = []; checked = []; checked_kups = {}; check_interfaces = function(bin) { var base, declare_kups, defaults, kups, local_kups, name, name1, ref, ref1, ref2, ref3, ref4, scope_, self, service, service_id, service_kup, use; local_kups = []; for (name in bin) { service = bin[name]; if (service instanceof Interface.Web) { if ((service.defaults != null) && indexOf.call(checked, service) < 0) { checked.push(service); defaults = service.defaults; self = { bin: bin, props: bin, space: bin != null ? (ref = bin.__) != null ? ref.space : void 0 : void 0, document: this.document, 'interface': this, actor: this.actor }; if (typeof defaults === 'function') { defaults = defaults.call(self, bin); } scope_ = scope; scope = []; kups = checked_kups[service] = check_interfaces.call(this, defaults); scope = scope_; } else { } if ((service.use != null) && indexOf.call(checked, service) < 0) { checked.push(service); use = service.use; self = { bin: bin, props: bin, space: bin != null ? (ref1 = bin.__) != null ? ref1.space : void 0 : void 0, document: this.document, 'interface': this, actor: this.actor }; if (typeof use === 'function') { use = use.call(self, bin); } scope_ = scope; scope = []; kups = checked_kups[service] = check_interfaces.call(this, use); scope = scope_; } else { kups = (ref2 = checked_kups[service]) != null ? ref2 : []; } declare_kups = get_declare_kups(kups); service_id = _.Uuid().replace(/\-/g, '_'); service_kup = new Function('args', "var interface = this.interface, bin = this.bin, props = this.props, keys = this.keys, actor = this.actor, space = this.space, module_path = this.module_path, local_ids = this.local_ids, __hasProp = {}.hasOwnProperty, Interface = this.params.Interface;\ntry {this.interface = bin" + (scope.length > 0 ? '.' + scope.join('.') : '') + "." + name + ";} \ncatch (error) { try {this.interface = bin." + name + ";} catch (error) {}; };\nthis.actor = this.interface != null ? (this.interface.actor != null ? this.interface.actor : actor) : actor;\nthis.keys = [];\nthis.props = this.bin = {__:bin.__};\nthis.space = this.bin != null && this.bin.__ != null ? this.bin.__.space : {};\nthis.module_path = '" + service.module_path + "';\nthis.local_ids = {};\nbin_cp = function(b_, _b) {\n var done = false, k, v;\n for (k in _b) {\n if (!hasProp.call(_b, k) || (k === '__')) continue; \n if (((v = _b[k]) != null ? v.constructor : void 0) === {}.constructor) { b_[k] = {}; if (!(done = bin_cp(b_[k], v))) { delete b_[k]; } } \n else if ((v instanceof Interface.Web) || (v instanceof Interface.Web.Global)) { b_[k] = v; done = true; }\n }\n return done;\n};\nbin_cp(this.bin, bin);\nif (args != null) {for (k in args) {if (__hasProp.call(args, k)) { this.bin[k] = args[k]; this.keys.push(k); }}}\nreaction = {kups:false};\nif (this.interface != null)\n this.interface.review(this.bin, reaction);\nif (reaction.certified) {\n " + (declare_kups.join(';\n')) + ";\n with (this.locals) {(" + (((ref3 = (ref4 = service.render) != null ? ref4.overriden : void 0) != null ? ref3 : service.render).toString()) + ").call(this, this.bin);}\n}\nthis.bin = bin; this.props = props; this.keys = keys; this.interface = interface; this.actor = actor; this.space = space; this.module_path = module_path; this.local_ids = local_ids;\nreturn reaction.certified;"); if (reaction.kups == null) { reaction.kups = {}; } if ((base = reaction.kups)[name1 = "_kup_" + service_id] == null) { base[name1] = service_kup; } local_kups.push({ name: name, scope: [].concat(scope), id: service_id }); } else { if (name !== '__' && (_.isBasicObject(service) || service instanceof Interface.Web.Global)) { scope.push(name); checked.push(service); local_kups = local_kups.concat(check_interfaces.call(this, service)); scope.pop(); } } } return local_kups; }; checked.push(bin); return reaction.local_kups = check_interfaces.call(this, bin); } }; return this.submit = function(bin) { var callback, chocokup_code, ref, ref1, render_code, result; if (!((ref = this.render) != null ? ref.overriden : void 0)) { render_code = (ref1 = this.render) != null ? ref1 : function() {}; chocokup_code = null; this.render = function(bin) { var declare_kups, kups, local_kups, options, ref2, transmit; if (bin == null) { bin = {}; } kups = this.reaction.kups; delete this.reaction.kups; local_kups = this.reaction.local_kups; delete this.reaction.local_kups; declare_kups = get_declare_kups(local_kups); chocokup_code = declare_kups.length > 0 ? new Function('args', "this.self.keys = [];\nthis.module_path = this.self.module_path = '" + this["interface"].module_path + "';\nthis.local_ids = {};\nif (args != null) {for (k in args) {if ({}.hasOwnProperty.call(args, k)) { this.self.bin[k] = args[k]; this.self.keys.push(k); }}}\n" + (declare_kups.join(';\n')) + ";\nwith (this.locals) {return (" + (render_code.toString()) + ").apply(this.self, arguments);}") : new Function('args', "this.module_path = this.self.module_path = '" + this["interface"].module_path + "';\nthis.local_ids = {};\nreturn (" + (render_code.toString()) + ").apply(this.self, arguments);"); transmit = function(actor, service, bin_) { var interface_; if (bin_ == null) { bin_ = {}; } if (typeof service !== 'string') { interface_ = actor; bin_ = service; service = ''; } else { interface_ = actor[service]; } return interface_.call(options, _.extend(bin, bin_)); }; if (this.transmit != null) { this.transmit = transmit; } options = { bin: bin, props: bin, space: bin != null ? (ref2 = bin.__) != null ? ref2.space : void 0 : void 0, document: this.document, Interface: Interface, 'self': this, actor: this.actor, kups: kups, transmit: transmit }; if (bin.theme != null) { options.theme = bin.theme; } if (bin.with_coffee != null) { options.with_coffee = bin.with_coffee; } if (bin.manifest != null) { options.manifest = bin.manifest; } return this.reaction.props = this.reaction.bin = (function() { var ref3; switch (this["interface"].type) { case 'Panel': return new Chocokup.Panel(options, chocokup_code); default: return new Chocokup[this["interface"].type]((ref3 = bin != null ? bin.name : void 0) != null ? ref3 : '', options, chocokup_code); } }).call(this); }; this.render.overriden = chocokup_code != null ? chocokup_code : render_code; } if (typeof bin === 'function') { callback = bin; bin = {}; } result = _["super"](this, bin); if (callback != null) { result.subscribe(function(reaction) { return callback(reaction.bin.render()); }); } return result; }; } }); Interface.Web.Global = _.prototype({ constructor: function(o) { var k, results, v; results = []; for (k in o) { if (!hasProp.call(o, k)) continue; v = o[k]; results.push(this[k] = v); } return results; } }); Interface.Web.App = Interface.Web; Interface.Web.Document = _.prototype({ inherit: Interface.Web, use: function() { return this.type = 'Document'; } }); Interface.Web.Panel = Interface.Web.Html = _.prototype({ inherit: Interface.Web, use: function() { return this.type = 'Panel'; } }); _module = typeof window !== "undefined" && window !== null ? window : module; if (_module.exports != null) { _module.exports = Interface; } else { if (window.Locco == null) { window.Locco = {}; } window.Locco.Interface = Interface; } }).call(this); if (typeof window !== "undefined" && window !== null) { window.modules['locco/interface'] = window.exports; window.exports = window.previousExports }; if (typeof window !== "undefined" && window !== null) { window.previousExports = window.exports; window.exports = {} }; // Generated by CoffeeScript 1.12.6 (function() { var Actor, Chocokup, Document, Interface, Workflow, _, _module, slice = [].slice; _ = require('../../general/chocodash'); Interface = require('../locco/interface'); Workflow = require('../locco/workflow'); Document = require('../locco/document'); Chocokup = require('chocolate/general/chocokup'); Actor = _.prototype({ adopt: { go: function(who, where, callback) { return _.go(who[where], function() { callback.apply(who, arguments); if (who.stage.is_ready()) { return who.status.notify(Workflow.Status.Public); } }); }, awake: function(uuid, __) { if (typeof window === "undefined" || window === null) { if ((uuid != null) && (__.session.frozen != null) && (__.session.frozen[uuid] == null)) { return void 0; } return __.space.select(uuid); } } }, constructor: function(options) { var _bind, doc, k, ref, ref1, ref2, v, when_ready; when_ready = new _.Publisher; this.ready = function(callback) { return when_ready.subscribe(((function(_this) { return function() { return callback.call(_this); }; })(this))); }; this.stage = (ref = options != null ? options.workflow : void 0) != null ? ref : Workflow.main; when_ready.subscribe(((function(_this) { return function() { return _this.stage.enter(_this); }; })(this))); if (typeof window !== "undefined" && window !== null) { this.stage.ready((function(_this) { return function() { return _this.stage.call(_this, 'awake', options != null ? options.uuid : void 0, { how: 'json' }, function(frozen) { var k, v; if (frozen != null) { for (k in frozen) { v = frozen[k]; _this[k] = v; } } return when_ready.notify(); }); }; })(this)); } else { setTimeout((function() { return when_ready.notify(); }), 0); } ref1 = this; for (k in ref1) { v = ref1[k]; if (v instanceof Document) { doc = v; break; } } if (doc == null) { doc = new Document({}); } this.document = doc; ref2 = this; for (k in ref2) { v = ref2[k]; if (v instanceof Actor) { _["do"].internal(v, 'parent', this); } } _bind = (function(_this) { return function(o) { for (k in o) { v = o[k]; if (v instanceof Interface) { v.bind(_this, doc, k); } else if ((v != null ? v.constructor : void 0) === {}.constructor) { _bind(v); } } }; })(this); _bind(this); }, id: function() { var ref, ref1; if (((ref = this._) != null ? (ref1 = ref._) != null ? ref1.uuid : void 0 : void 0) == null) { _["do"].identify(this, { filter: [Document] }); } return this._._.uuid; }, status: new _.Publisher, submit: function() { var params, publisher, ref, service; service = arguments[0], params = 2 <= arguments.length ? slice.call(arguments, 1) : []; publisher = new _.Publisher; if ((typeof window !== "undefined" && window !== null) && this.stage.is_ready()) { (ref = this.stage).call.apply(ref, [this, service].concat(slice.call(params), [function(data) { if (((data != null ? data.bin : void 0) != null) && (data.props == null)) { data.props = data.bin; } return publisher.notify(data); }])); } else { setTimeout((function() { return publisher.notify(); }), 0); } return publisher; }, show: function() {}, area: function(name, id) { var k, set, v; _["do"].internal(this, 'area', {}); set = (function(_this) { return function(k, v) { var area, parent, ref, ref1; if (v == null) { if (_this._._.area[k] != null) { return _this._._.area[k]; } parent = _this; while ((parent = (ref = parent._) != null ? (ref1 = ref._) != null ? ref1.parent : void 0 : void 0) != null) { if ((area = parent.area(k)) != null) { return area; } } } else { return _this._._.area[k] = v; } }; })(this); if (_.isBasicObject(name)) { for (k in name) { v = name[k]; set(k, v); } } else { return set(name, id); } } }); Actor.Web = _.prototype({ inherit: Actor, use: function() { var _shown; _shown = {}; this.show = function(path, source, area) { var j, len, ref, step, steps, where; steps = path.split('.'); where = this; for (j = 0, len = steps.length; j < len; j++) { step = steps[j]; where = where[step]; if (where == null) { return; } } if (area == null) { area = (ref = where.area) != null ? ref : 'inline'; } switch (area) { case 'inline': return typeof where.submit === "function" ? where.submit(function(result) { var ref1, uuid; if (((uuid = _shown[path]) == null) || $("#" + uuid).length === 0) { uuid = _shown[path] = '_' + _.Uuid(); result = "<div id='" + uuid + "'>" + result + "</div>"; if (!source.after) { source = $(source); } return (ref1 = source.after) != null ? ref1.call(source, result) : void 0; } }) : void 0; case 'view': break; case 'modal': break; case 'popup': } }; this["interface"] = new Interface.Web({ defaults: function() { var basename, end, filename, i, j, ref, ref1, ref2, ref3, ref4, ref5, start; if ((filename = (ref = this.actor.options) != null ? ref.filename : void 0) != null) { start = end = null; for (i = j = 0, ref1 = filename.length; 0 <= ref1 ? j < ref1 : j > ref1; i = 0 <= ref1 ? ++j : --j) { if ((ref2 = filename[filename.length - 1 - i]) === '/' || ref2 === '\\') { start = filename.length - i; if (end == null) { end = filename.length; } break; } if (filename[filename.length - 1 - i] === '.') { end = filename.length - i - 1; } } if (start == null) { start = 0; } if (end == null) { end = filename.length; } basename = filename.substring(start, end); } return { options: this.actor.options, name: (ref3 = (ref4 = (ref5 = this.actor.options) != null ? ref5.name : void 0) != null ? ref4 : basename) != null ? ref3 : '', theme: 'writer', manifest: (basename != null ? basename : '/') + "?manifest&how=manifest" }; }, use: function() { var ref; return { actor: { source: "var Service = (" + (_.stringify((ref = this.actor.constructor.__prototyper__) != null ? ref : function() { return {}; })) + ")();" } }; }, render: function() { var href, j, l, len, len1, ref, ref1, ref2, ref3, ref4, ref5, ref6, src; ref2 = ((ref = (ref1 = this.props.options) != null ? ref1.script : void 0) != null ? ref : '').split('\n'); for (j = 0, len = ref2.length; j < len; j++) { src = ref2[j]; script({ src: src, charset: "utf-8" }); } ref5 = ((ref3 = (ref4 = this.props.options) != null ? ref4.stylesheet : void 0) != null ? ref3 : '').split('\n'); for (l = 0, len1 = ref5.length; l < len1; l++) { href = ref5[l]; link({ rel: "stylesheet", href: href }); } script(function() { return text(this.props.actor.source); }); return coffeescript({ main: (ref6 = this.props.options) != null ? ref6.main : void 0 }, function() { return $(function() { var cache; Workflow = require('general/locco/workflow'); Actor = require('general/locco/actor'); if (window.applicationCache != null) { (cache = window.applicationCache).addEventListener('updateready', function(e) { if (cache.status === cache.UPDATEREADY) { cache.swapCache(); return window.location.reload(); } }); } return Workflow.main.ready(function() { var service; service = new Service; return service.ready(function() { return Actor.go(service, typeof main !== "undefined" && main !== null ? main : 'main', function(str) { return $('body').html(str); }); }); }); }); }); } }); return this.manifest = function(__) { var Fs, filename, j, l, len, len1, line, pathname, ref, ref1, ref2, ref3, ref4, ref5, stats, time_stamps, time_stamps_list, to_cache, to_cache_list; Fs = require('fs'); to_cache = Chocokup.App.manifest.cache + "\n/static/lib/chocodown.js\n/static/lib/coffeekup.js\n/static/lib/chocokup.js\n" + ((ref = (ref1 = this.options) != null ? ref1.script : void 0) != null ? ref : '') + "\n" + ((ref2 = (ref3 = this.options) != null ? ref3.stylesheet : void 0) != null ? ref2 : ''); to_cache_list = []; ref4 = to_cache.split('\n'); for (j = 0, len = ref4.length; j < len; j++) { line = ref4[j]; to_cache_list.push((line.split('?'))[0].replace('/-', '')); } time_stamps_list = []; for (l = 0, len1 = to_cache_list.length; l < len1; l++) { filename = to_cache_list[l]; try { pathname = require.resolve('/' + __.sysdir + filename); stats = Fs.statSync(pathname); time_stamps_list.push('#' + filename + ' : ' + stats.mtime.getTime()); } catch (error) {} } time_stamps = time_stamps_list.join('\n'); return "CACHE MANIFEST\n# v1.00.000\n# Actor Version:" + (((ref5 = this.options) != null ? ref5.filename : void 0) != null ? (Fs.statSync(this.options.filename)).mtime.getTime() : -1) + "\n#\n# Files Timestamp\n#\n" + time_stamps + "\n \nCACHE:\n" + to_cache + "\n\nFALLBACK:\nfavicon.ico /\n \nNETWORK:\n/~"; }; } }); _module = typeof window !== "undefined" && window !== null ? window : module; if (_module.exports != null) { _module.exports = Actor; } else { if (window.Locco == null) { window.Locco = {}; } window.Locco.Actor = Actor; } }).call(this); if (typeof window !== "undefined" && window !== null) { window.modules['locco/actor'] = window.exports; window.exports = window.previousExports }; if (typeof window !== "undefined" && window !== null) { window.previousExports = window.exports; window.exports = {} }; // Generated by CoffeeScript 1.12.6 (function() { var Reserve, TransientReserve, Workflow, _, _module; _ = require('../../general/chocodash'); Workflow = require('../locco/workflow'); TransientReserve = _.prototype({ use: function() { var all; all = {}; return this.Space = { request: function(query) {}, read: function(uuid) { return all[uuid]; }, write: function(io) { return all[io.uuid] = io; }, forget: function(io) { return delete all[io.uuid]; } }; } }); Reserve = typeof module !== "undefined" && module !== null ? require("../../server/reserve") : new TransientReserve; _module = typeof window !== "undefined" && window !== null ? window : module; if (_module.exports != null) { _module.exports = Reserve; } else { if (window.Locco == null) { window.Locco = {}; } window.Locco.Reserve = Reserve; } }).call(this); if (typeof window !== "undefined" && window !== null) { window.modules['locco/reserve'] = window.exports; window.exports = window.previousExports }; if (typeof window !== "undefined" && window !==