Skip to content

Commit

Permalink
Merge pull request #504 from socketstream/feature/465-bundler
Browse files Browse the repository at this point in the history
#465 bundler basics. More tests required.
  • Loading branch information
thepian committed Mar 3, 2015
2 parents efbcf5f + d1beae0 commit bc724bb
Show file tree
Hide file tree
Showing 51 changed files with 2,068 additions and 628 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules
dump.rdb
npm-debug.log
*.tgz
test/fixtures/project/client/static/assets/abc
2 changes: 0 additions & 2 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"curly" : true,
"eqeqeq" : true,
"eqnull" : true,
"forin" : true,
"immed" : true,
"latedef" : "nofunc",
"newcap" : true,
Expand All @@ -20,7 +19,6 @@
"sub" : true,
"supernew" : true,
"node" : true,
"onevar" : true,
"unused" : true,
"multistr" : true,
"smarttabs": true,
Expand Down
153 changes: 143 additions & 10 deletions docs/js/docs-setup.js

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions docs/partials/api/bundler.default.default.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<h1><code ng:non-bindable="">default</code>
<div><span class="hint">service in module <code ng:non-bindable="">bundler</code>
</span>
</div>
</h1>
<div><h2 id="description">Description</h2>
<div class="description"><div class="bundler-default-page bundler-default-default-page"><p>The default bundler of HTML, CSS &amp; JS</p>
</div></div>
<div class="member method"><h2 id="methods">Methods</h2>
<ul class="methods"><li><h3 id="methods_assetloader">assetLoader()</h3>
<div class="assetloader"><div class="bundler-default-page bundler-default-default-assetloader-page"><p>Return entry for the JS loader depending on the includes.system client config.</p>
</div><h5 id="methods_assetloader_returns">Returns</h5><table class="variables-matrix"><tr><td><a href="" class="label type-hint type-hint-assetentry">AssetEntry</a></td><td><div class="bundler-default-page bundler-default-default-assetloader-page"><p>Loader resource</p>
</div></td></tr></table></div>
</li>
<li><h3 id="methods_assetstart">assetStart()</h3>
<div class="assetstart"><div class="bundler-default-page bundler-default-default-assetstart-page"><p>Return the resource for starting the view. It is code for immediate execution at the end of the page.</p>
</div><h5 id="methods_assetstart_returns">Returns</h5><table class="variables-matrix"><tr><td><a href="" class="label type-hint type-hint-assetentry">AssetEntry</a></td><td><div class="bundler-default-page bundler-default-default-assetstart-page"><p>Start Script resource</p>
</div></td></tr></table></div>
</li>
<li><h3 id="methods_entries">entries(assetType, systemAssets)</h3>
<div class="entries"><div class="bundler-default-page bundler-default-default-entries-page"><p>Provides the view and the pack functions with a
list of entries for an asset type relative to the client directory.
The default implementation is used.</p>
</div><h5 id="methods_entries_parameters">Parameters</h5><table class="variables-matrix table table-bordered table-striped"><thead><tr><th>Param</th><th>Type</th><th>Details</th></tr></thead><tbody><tr><td>assetType</td><td><a href="" class="label type-hint type-hint-string">String</a></td><td><div class="bundler-default-page bundler-default-default-entries-page"><p>js/css</p>
</div></td></tr><tr><td>systemAssets</td><td><a href="" class="label type-hint type-hint-object">Object</a></td><td><div class="bundler-default-page bundler-default-default-entries-page"><p>Collection of libs, modules, initCode</p>
</div></td></tr></tbody></table><h5 id="methods_entries_returns">Returns</h5><table class="variables-matrix"><tr><td><a href="" class="label type-hint type-hint-object">[AssetEntry]</a></td><td><div class="bundler-default-page bundler-default-default-entries-page"><p>List of output entries</p>
</div></td></tr></table></div>
</li>
<li><h3 id="methods_systemmodule">systemModule(name)</h3>
<div class="systemmodule"><div class="bundler-default-page bundler-default-default-systemmodule-page"><p>Return the resource for a registered system module by the given name. It uses
the default wrapCode for module registration with require.</p>
</div><h5 id="methods_systemmodule_parameters">Parameters</h5><table class="variables-matrix table table-bordered table-striped"><thead><tr><th>Param</th><th>Type</th><th>Details</th></tr></thead><tbody><tr><td>name</td><td><a href="" class="label type-hint type-hint-string">String</a></td><td><div class="bundler-default-page bundler-default-default-systemmodule-page"><p>Logical Module Name</p>
</div></td></tr></tbody></table><h5 id="methods_systemmodule_returns">Returns</h5><table class="variables-matrix"><tr><td><a href="" class="label type-hint type-hint-assetentry">AssetEntry</a></td><td><div class="bundler-default-page bundler-default-default-systemmodule-page"><p>Module resource</p>
</div></td></tr></table></div>
</li>
</ul>
</div>
</div>
8 changes: 8 additions & 0 deletions docs/partials/api/bundler.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<h1><code ng:non-bindable="">bundler</code>
<div><span class="hint"></span>
</div>
</h1>
<div><h2 id="description">Description</h2>
<div class="description"><div class="bundler-page"><p>Bundlers included.</p>
</div></div>
</div>
21 changes: 21 additions & 0 deletions docs/partials/api/bundler.webpack.webpack.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<h1><code ng:non-bindable="">webpack</code>
<div><span class="hint">service in module <code ng:non-bindable="">bundler</code>
</span>
</div>
</h1>
<div><h2 id="description">Description</h2>
<div class="description"><div class="bundler-webpack-page bundler-webpack-webpack-page"><p>The webpack bundler of HTML, CSS &amp; JS</p>
<p>This is just for demonstration purposes and to validate the custom bundler concept. It can be improved.</p>
</div></div>
<div class="member method"><h2 id="methods">Methods</h2>
<ul class="methods"><li><h3 id="methods_entries">entries(assetType, systemAssets)</h3>
<div class="entries"><div class="bundler-webpack-page bundler-webpack-default-entries-page"><p>Provides the view and the pack functions with a
list of entries for an asset type relative to the client directory.</p>
</div><h5 id="methods_entries_parameters">Parameters</h5><table class="variables-matrix table table-bordered table-striped"><thead><tr><th>Param</th><th>Type</th><th>Details</th></tr></thead><tbody><tr><td>assetType</td><td><a href="" class="label type-hint type-hint-string">String</a></td><td><div class="bundler-webpack-page bundler-webpack-default-entries-page"><p>js/css</p>
</div></td></tr><tr><td>systemAssets</td><td><a href="" class="label type-hint type-hint-object">Object</a></td><td><div class="bundler-webpack-page bundler-webpack-default-entries-page"><p>Collection of libs, modules, initCode</p>
</div></td></tr></tbody></table><h5 id="methods_entries_returns">Returns</h5><table class="variables-matrix"><tr><td><a href="" class="label type-hint type-hint-object">[AssetEntry]</a></td><td><div class="bundler-webpack-page bundler-webpack-default-entries-page"><p>List of output entries</p>
</div></td></tr></table></div>
</li>
</ul>
</div>
</div>
10 changes: 10 additions & 0 deletions docs/partials/api/events.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<h1><code ng:non-bindable="">events</code>
<div><span class="hint"></span>
</div>
</h1>
<div><h2 id="description">Description</h2>
<div class="description"><div class="events-page"><p>Internal Event bus.</p>
<p>Note: only used by the ss-console module for now. This idea will be expended upon in SocketStream 0.4</p>
<p>&#39;server:start&#39; is emitted when the server starts. If in production the assets will be saved before the event.</p>
</div></div>
</div>
18 changes: 18 additions & 0 deletions docs/partials/api/ss.add.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<h1><code ng:non-bindable="">add</code>
<div><span class="hint">service in module <code ng:non-bindable="">ss</code>
</span>
</div>
</h1>
<div><h2 id="description">Description</h2>
<div class="description"><div class="ss-add-page"><p>Call from your app to safely extend the &#39;ss&#39; internal API object passed through to your /server code</p>
</div></div>
<h2 id="usage">Usage</h2>
<div class="usage"><pre class="prettyprint linenums">add(name, fn);</pre>
<h4 id="usage_parameters">Parameters</h4><table class="variables-matrix table table-bordered table-striped"><thead><tr><th>Param</th><th>Type</th><th>Details</th></tr></thead><tbody><tr><td>name</td><td><a href="" class="label type-hint type-hint-string">string</a></td><td><div class="ss-add-page"><ul>
<li>Key in the <code>ss</code> API.</li>
</ul>
</div></td></tr><tr><td>fn</td><td><a href="" class="label type-hint type-hint-function">function</a><a href="" class="label type-hint type-hint-number">number</a><a href="" class="label type-hint type-hint-boolean">boolean</a><a href="" class="label type-hint type-hint-string">string</a></td><td><div class="ss-add-page"><ul>
<li>value or function</li>
</ul>
</div></td></tr></tbody></table></div>
</div>
44 changes: 44 additions & 0 deletions docs/partials/api/ss.bundler.bundler.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<h1><code ng:non-bindable="">bundler</code>
<div><span class="hint">service in module <code ng:non-bindable="">ss</code>
</span>
</div>
</h1>
<div><h2 id="description">Description</h2>
<div class="description"><div class="ss-bundler-page ss-bundler-bundler-page"><h4 id="description_client-bundling-api">Client bundling API</h4>
<p>Client bundling API for implementing a custom bundler.</p>
</div></div>
<div class="member method"><h2 id="methods">Methods</h2>
<ul class="methods"><li><h3 id="methods_define">define(client, args)</h3>
<div class="define"><h5 id="methods_define_parameters">Parameters</h5><table class="variables-matrix table table-bordered table-striped"><thead><tr><th>Param</th><th>Type</th><th>Details</th></tr></thead><tbody><tr><td>client</td><td><a href="" class="label type-hint type-hint-string">string</a></td><td><div class="ss-bundler-page ss-bundler-bundler-define-page"><p>object to store the definition in</p>
</div></td></tr><tr><td>args</td><td><a href="" class="label type-hint type-hint-object">object</a></td><td><div class="ss-bundler-page ss-bundler-bundler-define-page"><p>arguments passed to define</p>
</div></td></tr></tbody></table></div>
</li>
<li><h3 id="methods_destsfor">destsFor(client)</h3>
<div class="destsfor"><div class="ss-bundler-page ss-bundler-bundler-destsfor-page"><p>The define client method of all bundlers must return the file locations for the client.</p>
<pre><code>return ss.bundler.destsFor(client);
</code></pre><p>To offer a very different way to define the entry-points for assets the bundler can tweak
the paths or replace them.</p>
</div><h5 id="methods_destsfor_parameters">Parameters</h5><table class="variables-matrix table table-bordered table-striped"><thead><tr><th>Param</th><th>Type</th><th>Details</th></tr></thead><tbody><tr><td>client</td><td><a href="" class="label type-hint type-hint-object">object</a></td><td><div class="ss-bundler-page ss-bundler-bundler-destsfor-page"><p>Object describing the client.</p>
</div></td></tr></tbody></table><h5 id="methods_destsfor_returns">Returns</h5><table class="variables-matrix"><tr><td><a href="" class="label type-hint type-hint-object">object</a></td><td><div class="ss-bundler-page ss-bundler-bundler-destsfor-page"><p>Destinations paths, relPaths, dir, containerDir</p>
</div></td></tr></table></div>
</li>
<li><h3 id="methods_get">get(client)</h3>
<div class="get"><div class="ss-bundler-page ss-bundler-bundler-get-page"><p>Determine the bundler for a client</p>
</div><h5 id="methods_get_parameters">Parameters</h5><table class="variables-matrix table table-bordered table-striped"><thead><tr><th>Param</th><th>Type</th><th>Details</th></tr></thead><tbody><tr><td>client</td><td><a href="" class="label type-hint type-hint-object">object</a><a href="" class="label type-hint type-hint-string">string</a></td><td><div class="ss-bundler-page ss-bundler-bundler-get-page"><p>Query params with client=name or an actual client object</p>
</div></td></tr></tbody></table></div>
</li>
<li><h3 id="methods_systemlibs">systemLibs()</h3>
<div class="systemlibs"><div class="ss-bundler-page ss-bundler-bundler-systemlibs-page"><p>A single entry for all system libraries.</p>
</div><h5 id="methods_systemlibs_returns">Returns</h5><table class="variables-matrix"><tr><td><a href="" class="label type-hint type-hint-assetentry">AssetEntry</a></td><td><div class="ss-bundler-page ss-bundler-bundler-systemlibs-page"><p>Entry</p>
</div></td></tr></table></div>
</li>
<li><h3 id="methods_systemmodule">systemModule(name, wrap)</h3>
<div class="systemmodule"><div class="ss-bundler-page ss-bundler-bundler-systemmodule-page"><p>Describe a system module.</p>
</div><h5 id="methods_systemmodule_parameters">Parameters</h5><table class="variables-matrix table table-bordered table-striped"><thead><tr><th>Param</th><th>Type</th><th>Details</th></tr></thead><tbody><tr><td>name</td><td><a href="" class="label type-hint type-hint-string">String</a></td><td><div class="ss-bundler-page ss-bundler-bundler-systemmodule-page"><p>Name of the system module to return in a descriptor</p>
</div></td></tr><tr><td>wrap</td><td><a href="" class="label type-hint type-hint-boolean">boolean</a></td><td><div class="ss-bundler-page ss-bundler-bundler-systemmodule-page"><p>Shall the content be wrapped in <code>require.define</code>. Default is true.</p>
</div></td></tr></tbody></table><h5 id="methods_systemmodule_returns">Returns</h5><table class="variables-matrix"><tr><td><a href="" class="label type-hint type-hint-assetentry">AssetEntry</a></td><td><div class="ss-bundler-page ss-bundler-bundler-systemmodule-page"><p>Entry</p>
</div></td></tr></table></div>
</li>
</ul>
</div>
</div>
26 changes: 26 additions & 0 deletions docs/partials/api/ss.client.client.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<h1><code ng:non-bindable="">client</code>
<div><span class="hint">service in module <code ng:non-bindable="">ss</code>
</span>
</div>
</h1>
<div><h2 id="description">Description</h2>
<div class="description"><div class="ss-client-page ss-client-client-page"><h4 id="description_client-serving,-bundling,-development,-building">Client serving, bundling, development, building.</h4>
<p>One or more clients are defined and will be served in production as a single HTML, CSS, and JS file.</p>
</div></div>
<div class="member method"><h2 id="methods">Methods</h2>
<ul class="methods"><li><h3 id="methods_send">send(name, content, options)</h3>
<div class="send"><div class="ss-client-page ss-client-client-send-page"><p>Allow other libs to send assets to the client. add new System Library or Module</p>
</div><h5 id="methods_send_parameters">Parameters</h5><table class="variables-matrix table table-bordered table-striped"><thead><tr><th>Param</th><th>Type</th><th>Details</th></tr></thead><tbody><tr><td>name</td><td><a href="" class="label type-hint type-hint-string">string</a></td><td><div class="ss-client-page ss-client-client-send-page"><ul>
<li>Module name for require.</li>
</ul>
</div></td></tr><tr><td>content</td><td><a href="" class="label type-hint type-hint-string">string</a></td><td><div class="ss-client-page ss-client-client-send-page"><ul>
<li>The JS code</li>
</ul>
</div></td></tr><tr><td>options</td><td><a href="" class="label type-hint type-hint-object">Object</a></td><td><div class="ss-client-page ss-client-client-send-page"><ul>
<li>Allows you to specify <code>compress</code> and <code>coffee</code> format flags.</li>
</ul>
</div></td></tr></tbody></table></div>
</li>
</ul>
</div>
</div>
10 changes: 10 additions & 0 deletions docs/partials/api/ss.env.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<h1><code ng:non-bindable="">env</code>
<div><span class="hint">service in module <code ng:non-bindable="">ss</code>
</span>
</div>
</h1>
<div><h2 id="usage">Usage</h2>
<div class="usage"><pre class="prettyprint linenums">ss.env</pre>
<h4 id="usage_returns">Returns</h4><table class="variables-matrix"><tr><td><a href="" class="label type-hint type-hint-string">string</a></td><td><div class="ss-env-page"><p>Execution environment type. To change set environment variable <code>NODE_ENV</code> or <code>SS_ENV</code>. &#39;development&#39; by default.</p>
</div></td></tr></table></div>
</div>
7 changes: 7 additions & 0 deletions docs/partials/api/ss.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<h1><code ng:non-bindable=""></code>
<div><span class="hint"></span>
</div>
</h1>
<div><div class="ss-page"><p>Internal API object which is passed to sub-modules and can be used within your app</p>
<p>To access it without it being passed <code>var ss = require(&#39;socketstream&#39;).api;</code></p>
</div></div>
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
<h1><code ng:non-bindable="">log</code>
<div><span class="hint">service in module <code ng:non-bindable="">utils</code>
<div><span class="hint">service in module <code ng:non-bindable="">ss</code>
</span>
</div>
</h1>
<div><h2 id="description">Description</h2>
<div class="description"><div class="utils-log-page utils-log-log-page"><p>Contains method stubs for logging to console (by default) or
<div class="description"><div class="ss-log-page ss-log-log-page"><p>Contains method stubs for logging to console (by default) or
whatever logging provider you choose.</p>
</div></div>
<div class="member method"><h2 id="methods">Methods</h2>
<ul class="methods"><li><h3 id="methods_debug">debug()</h3>
<div class="debug"><div class="utils-log-debug-page"><p>Debug level logging, uses console.log by default. Override by assigning a
<div class="debug"><div class="ss-log-debug-page"><p>Debug level logging, uses console.log by default. Override by assigning a
function that takes the same parameters as console.log:</p>
<pre><code>var ss = require(&#39;socketstream&#39;);
ss.api.log.debug = console.log;
</code></pre></div><h4 id="methods_debug_example">Example</h4>
<div class="example"><div class="utils-log-debug-page"><pre><code>ss.api.log.debug(&quot;Something fairly trivial happened&quot;);
<div class="example"><div class="ss-log-debug-page"><pre><code>ss.log.debug(&quot;Something fairly trivial happened&quot;);
</code></pre></div></div>
</div>
</li>
<li><h3 id="methods_error">error()</h3>
<div class="error"><div class="utils-log-error-page"><p>Error level logging, uses console.error by default. Override by assigning a
<div class="error"><div class="ss-log-error-page"><p>Error level logging, uses console.error by default. Override by assigning a
function that takes the same parameters as console.error.</p>
</div><h4 id="methods_error_example">Example</h4>
<div class="example"><div class="utils-log-error-page"><pre><code>ss.api.log.error(&quot;Time to wakeup the sysadmin&quot;);
<div class="example"><div class="ss-log-error-page"><pre><code>ss.log.error(&quot;Time to wakeup the sysadmin&quot;);
</code></pre></div></div>
</div>
</li>
<li><h3 id="methods_info">info()</h3>
<div class="info"><div class="utils-log-info-page"><p>Info level logging, uses console.log by default. Override by assigning a
<div class="info"><div class="ss-log-info-page"><p>Info level logging, uses console.log by default. Override by assigning a
function that takes the same parameters as console.log.</p>
</div><h4 id="methods_info_example">Example</h4>
<div class="example"><div class="utils-log-info-page"><pre><code>ss.api.log.info(&quot;Just keeping you informed&quot;);
<div class="example"><div class="ss-log-info-page"><pre><code>ss.log.info(&quot;Just keeping you informed&quot;);
</code></pre></div></div>
</div>
</li>
<li><h3 id="methods_warn">warn()</h3>
<div class="warn"><div class="utils-log-warn-page"><p>Warn level logging, uses console.log by default. Override by assigning a
<div class="warn"><div class="ss-log-warn-page"><p>Warn level logging, uses console.log by default. Override by assigning a
function that takes the same parameters as console.log:</p>
<pre><code>var ss = require(&#39;socketstream&#39;),
winston = require(&#39;winston&#39;);
ss.api.log.warn = winston.warn;
ss.log.warn = winston.warn;
</code></pre></div><h4 id="methods_warn_example">Example</h4>
<div class="example"><div class="utils-log-warn-page"><pre><code>ss.api.log.warn(&quot;Something unexpected happened!&quot;);
<div class="example"><div class="ss-log-warn-page"><pre><code>ss.log.warn(&quot;Something unexpected happened!&quot;);
</code></pre></div></div>
</div>
</li>
Expand Down
13 changes: 13 additions & 0 deletions docs/partials/api/ss.root.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<h1><code ng:non-bindable="">root</code>
<div><span class="hint">service in module <code ng:non-bindable="">ss</code>
</span>
</div>
</h1>
<div><h2 id="description">Description</h2>
<div class="description"><div class="ss-root-page"><p>By default the project root is the current working directory</p>
</div></div>
<h2 id="usage">Usage</h2>
<div class="usage"><pre class="prettyprint linenums">ss.root</pre>
<h4 id="usage_returns">Returns</h4><table class="variables-matrix"><tr><td><a href="" class="label type-hint type-hint-string">string</a></td><td><div class="ss-root-page"><p>Project root</p>
</div></td></tr></table></div>
</div>

0 comments on commit bc724bb

Please sign in to comment.