Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

docs: Precompiled, packaged & minified version

This commit updates the playground build to be precompiled (hsp, and js
transpiled) packaged and minified.

The goal is to optimize the initial display of the playground.

Closes #242
  • Loading branch information...
commit 452815de85b3f826740f2c3a1791865515cedb41 1 parent b3ed244
@benouat benouat authored
Showing with 626 additions and 309 deletions.
  1. +158 −20 build/grunt/docs.js
  2. +5 −1 docs/_css/site.less
  3. +1 −0  docs/_layouts/sample_desc.html
  4. +10 −14 docs/playground/index.md
  5. +44 −3 docs/playground/layout.hsp
  6. +60 −63 docs/playground/playground.js
  7. +6 −2 docs/samples/clickhandler/clickhandler.hsp
  8. +9 −6 docs/samples/clock/clock.hsp
  9. +7 −4 docs/samples/component1/timer.hsp
  10. +35 −30 docs/samples/component2/nbrfield.hsp
  11. +16 −12 docs/samples/component3/pagination.hsp
  12. +13 −7 docs/samples/conditions/conditions.hsp
  13. +9 −5 docs/samples/cssclass/cssclass.hsp
  14. +8 −5 docs/samples/dynpath/dynpath.hsp
  15. +7 −2 docs/samples/dyntemplates/dyntemplates.hsp
  16. +7 −3 docs/samples/gestures/gestures.hsp
  17. +9 −2 docs/samples/global/global.hsp
  18. +15 −1 docs/samples/helloworld/description.md
  19. +6 −2 docs/samples/helloworld/hello.hsp
  20. +10 −6 docs/samples/inputsample/inputsample.hsp
  21. +7 −3 docs/samples/let/let.hsp
  22. +12 −8 docs/samples/list1/list.hsp
  23. +11 −7 docs/samples/list2/list.hsp
  24. +7 −4 docs/samples/listsorting/list.hsp
  25. +10 −6 docs/samples/listupdate/list.hsp
  26. +8 −4 docs/samples/logs/logs.hsp
  27. +8 −2 docs/samples/modifiers/modifiers.hsp
  28. +9 −5 docs/samples/panel/panel.hsp
  29. +0 −1  docs/samples/samples.js
  30. +7 −4 docs/samples/simplelist/simplelist.hsp
  31. +7 −2 docs/samples/subtemplates/subtemplates.hsp
  32. +5 −2 docs/samples/tabbar/tabbar.hsp
  33. +6 −1 docs/samples/textarea/textarea.hsp
  34. +11 −3 docs/samples/thirdpartycpts/chart.hsp
  35. +9 −3 docs/samples/timer/timer.hsp
  36. +7 −2 docs/samples/todolist/todolist.hsp
  37. +67 −64 gruntfile.js
View
178 build/grunt/docs.js
@@ -22,6 +22,7 @@ module.exports = function(grunt) {
var DOCS_PATH = "./docs/";
var DOCS_MD_GLOB = [ '**/*.md', '!samples/**/*.md' ],
+ DOCS_MD_SAMPlES = [ 'samples/**/*.md' ],
DOCS_STATICS_GLOB = [
'css/**',
'images/*',
@@ -49,9 +50,10 @@ module.exports = function(grunt) {
WATCH_PLAYGROUND_GLOB = DOCS_PLAYGROUND_GLOB.map(pathifyFromDocs);
-
- // Less compilation
-
+ /* ------------------
+ * Less compilation
+ * ------------------
+ */
grunt.config.set('less', {
"docs": {
options: {
@@ -71,9 +73,12 @@ module.exports = function(grunt) {
});
- // Uglify TODOMVC
+ /* ----------------
+ * Uglify Playground + Samples + TODOMVC
+ * ----------------
+ */
var uglifyConfig = grunt.config("uglify");
- uglifyConfig.todomvc = {
+ uglifyConfig["todomvc"] = {
files: [
{
expand: true,
@@ -82,11 +87,21 @@ module.exports = function(grunt) {
]
};
- grunt.config("uglify", uglifyConfig);
-
+ uglifyConfig["playground"] = {
+ files: [
+ {
+ expand: true,
+ src: [ GH_PAGES_PATH + 'playground/*-all.js' ]
+ }
+ ]
+ };
- // Markdown Generation
+ grunt.config("uglify", uglifyConfig);
+ /* ----------------------
+ * Markadown Generation
+ * ----------------------
+ */
function extractYamlHeader(src, context) {
var splits = src.split(yamlheadsep), yamlheader, markdown = src;
// we might have a yaml markdown header
@@ -158,10 +173,33 @@ module.exports = function(grunt) {
highlight: "manual"
}
}
+ },
+ "samples": {
+ files: [
+ {
+ expand: true,
+ cwd: DOCS_PATH,
+ src: DOCS_MD_SAMPlES,
+ dest: GH_PAGES_PATH,
+ ext: '.html'
+ }
+ ],
+ options: {
+ template: DOCS_PATH + '_layouts/sample_desc.html',
+ postCompile: function(markdown, context) {
+ return markdown.replace("<p>[#output]</p>", "[#output]");
+ },
+ markdownOptions: {
+ gfm: true
+ }
+ }
}
});
- // TODOMVC precompilation
+ /* ------------------------
+ * TODOMVC precompilation
+ * ------------------------
+ */
grunt.registerTask("docs:todo-compile", "Precompile all related files for TODOMVC example", function() {
var renderer = require("../../hsp/compiler/renderer"),
tranpiler = require("../../hsp/transpiler");
@@ -212,7 +250,10 @@ module.exports = function(grunt) {
});
}
- // Playground Express Server
+ /* ---------------------------
+ * Playground Express Server
+ * ---------------------------
+ */
grunt.registerTask("docs:playground-server", "Launch local version of documentation including playground", function() {
grunt.config.requires('hspserver.port');
grunt.config.requires('hspserver.base');
@@ -276,18 +317,77 @@ module.exports = function(grunt) {
});
- // Building all needed files for the playground
+ /* ----------------------------------------------
+ * Building all needed files for the playground
+ * ----------------------------------------------
+ */
+
+ // updating atpackager config to package the playground
+ var atpackagerConfig = grunt.config('atpackager');
+ atpackagerConfig["docs-playground"] = {
+ options: {
+ sourceDirectories : [
+ GH_PAGES_PATH
+ ],
+ outputDirectory : GH_PAGES_PATH + 'playground/',
+ visitors: [],
+ defaultBuilder : {
+ type : "NoderPackage",
+ cfg : {
+ outputFileWrapper : "(function(define){$CONTENT$;})(noder.define);"
+ }
+ },
+ packages : [{
+ name : "playground-samples-all.js",
+ files : [ 'samples/**/*.js']
+ }, {
+ name : "playground-all.js",
+ files : [ 'playground/**/*.js']
+ }]
+ }
+ };
+ grunt.config('atpackager', atpackagerConfig);
+
+ grunt.registerTask("docs:samples-list-build", "Build a json file containing the samples list", function() {
+ // Merging those markdown content into `samples/samples.js`
+ var samplesList = require('../../docs/samples/samples'), samplesListString;
+
+ grunt.file.expand({ cwd: DOCS_PATH, filter: "isDirectory" }, ['samples/*']).forEach(function(sample) {
+ var name = sample.split("/").pop(),
+ item = (samplesList.filter(function(s) { return s.folder === name; }) || [])[0],
+ hsp, html, desc, hsptext;
+
+ if (item) {
+ hsp = sample + "/" + item.files[0].src;
+ html = sample + "/description.html";
+ desc = grunt.file.read(GH_PAGES_PATH + html);
+ hsptext = grunt.file.read(DOCS_PATH + hsp);
+
+ item.description = desc;
+ item.files[0].text = hsptext;
+ item.sample = "require('/"+hsp+".js')";
+ }
+ });
+
+ samplesListString = JSON.stringify(samplesList, null, 2);
+ samplesListString = samplesListString.replace(/"(require\('.*'\))"/gi, "$1");
+ grunt.file.write(GH_PAGES_PATH + "samples/samples.js", "module.exports = " + samplesListString + ";");
+ });
grunt.registerTask("docs:playground-build", "Build a static playground version", function() {
+ var renderer = require("../../hsp/compiler/renderer"),
+ tranpiler = require("../../hsp/transpiler");
grunt.log.subhead("Building playground and samples files");
+
// We copy the Playground files
- grunt.verbose.or.write("Copying playground file...");
+ grunt.verbose.or.write("Copying playground files...");
grunt.file.expand({ cwd: DOCS_PATH, filter: "isFile" }, DOCS_PLAYGROUND_GLOB).forEach(function(file) {
grunt.file.copy(DOCS_PATH + file, GH_PAGES_PATH + file);
});
grunt.verbose.or.ok();
+
// We copy the Samples files
grunt.verbose.or.write("Copying samples file...");
grunt.file.expand({ cwd: DOCS_PATH, filter: "isFile" }, DOCS_SAMPLES_GLOB).forEach(function(file) {
@@ -295,11 +395,42 @@ module.exports = function(grunt) {
});
grunt.verbose.or.ok();
- });
+ grunt.verbose.or.write("Compiling playground & samples hsp files...");
+ grunt.file.expand({ cwd: DOCS_PATH }, ['playground/**/*.hsp', 'samples/**/*.hsp']).forEach(function(file) {
+ grunt.file.copy(pathifyFromDocs(file),
+ GH_PAGES_PATH + file + ".js",
+ {
+ process: function(content) {
+ var compiled = renderer.renderString(content, "inline.js");
+ if (compiled.serverErrors && compiled.serverErrors.length) {
+ grunt.fail.fatal("Hashspace compilation " + compiled.serverErrors[0].description);
+ return false;
+ }
+ return compiled.code;
+ }
+ });
+ });
+ grunt.file.expand({ cwd: DOCS_PATH }, ['playground/**/*.js']).forEach(function(file) {
+ grunt.file.copy(pathifyFromDocs(file),
+ GH_PAGES_PATH + file,
+ {
+ process: function(content) {
+ var tranpiled = tranpiler.processString(content, "inline.js");
+ return tranpiled.code;
+ }
+ });
+ });
+ grunt.verbose.or.ok();
+
+ grunt.task.run(["markdown:samples", "docs:samples-list-build", "atpackager:docs-playground", "uglify:playground"]);
+ });
- // Preparing the build
+ /* ---------------------
+ * Preparing the build
+ * ---------------------
+ */
grunt.registerTask("docs:setup", "Verify that everything is fine before we start", function() {
if (!grunt.file.exists(GH_PAGES_PATH)) {
grunt.verbose.or.write(GH_PAGES_PATH + " does not exist, let's create it...");
@@ -317,8 +448,10 @@ module.exports = function(grunt) {
});
- // Copying static files
-
+ /* ----------------------
+ * Copying static files
+ * ----------------------
+ */
grunt.registerTask("docs:copy-statics", "Copy static files", function() {
// Moving previously built uglify.js to /libs
grunt.file.copy("tmp/uglify-js.js", GH_PAGES_PATH + 'libs/uglify-js.js');
@@ -347,8 +480,10 @@ module.exports = function(grunt) {
});
- // Watching stuff...
-
+ /* -------------------
+ * Watching stuff...
+ * -------------------
+ */
grunt.registerTask("docs:watch", "Watching any file where local website should be rebuild", function() {
var watchConfig = grunt.config("watch");
@@ -379,8 +514,10 @@ module.exports = function(grunt) {
- // Public tasks definition
-
+ /* -------------------------
+ * Public tasks definition
+ * -------------------------
+ */
grunt.registerTask("docs:todo-package", [
"docs:todo-compile",
"uglify:todomvc"
@@ -397,6 +534,7 @@ module.exports = function(grunt) {
]);
grunt.registerTask("docs:playground", [
+ "package",
"docs:prepare",
"docs:playground-build",
"docs:playground-server"
View
6 docs/_css/site.less
@@ -298,6 +298,11 @@ body.playground {
.item {
cursor: pointer;
padding-left: 12px;
+ a {
+ display: block;
+ color: inherit;
+ text-decoration: inherit;
+ }
&:hover {
background-color: #f0f0f0;
}
@@ -481,4 +486,3 @@ body.playground {
}
}
-
View
1  docs/_layouts/sample_desc.html
@@ -0,0 +1 @@
+<%=content%>
View
24 docs/playground/index.md
@@ -9,31 +9,27 @@ footerscripts: |
<script src="/libs/noder.dev.min.js">
{
packaging: {
- baseUrl: "/",
- preprocessors: [{
- pattern: /\.hsp$/,
- module: "hsp/compiler/compile"
- }, {
- pattern: /^(?!hsp\/|libs\/).*\.js$/,
- module: "hsp/transpiler/transpile"
- }]
+ baseUrl: "/"
},
resolver: {
- "default" : {
+ "default" : (location.href.indexOf("dev") !== -1 ? {
"uglify-js" : "/libs/uglify-js"
- }
+ } : {})
}
}
</script>
<script src="/dist/<%=version%>/hashspace-noder.min.js" type="text/javascript"></script>
- <script src="/dist/<%=version%>/hashspace-noder-compiler.min.js" type="text/javascript"></script>
+ <script src="/playground/playground-samples-all.js" type="text/javascript"></script>
+ <script src="/playground/playground-all.js" type="text/javascript"></script>
<script type="noder">
+ window.hashspace_version = "<%=version%>";
var Playground = require("/playground/playground");
+ var playground = new Playground("main", location.href.indexOf("dev") !== -1);
+ var sample = window.location.hash.length > 0 ? window.location.hash.substr(1) : 0;
+ playground.showSample(sample);
- var playground = new Playground("main");
- playground.showSample(0);
Router({
- ':key': playground.loadSample.bind(playground)
+ ':key': playground.loadSample.bind(playground)
}).init();
</script>
---
View
47 docs/playground/layout.hsp
@@ -1,4 +1,46 @@
-var splitter = require("./splitter.hsp");
+var splitter = require("./splitter.hsp.js");
+
+var Class = require("hsp/klass");
+
+var DescriptionCtrl = Class({
+ attributes: {
+ sample: { type: "object", binding: "1-way" }
+ },
+ $init: function() {
+ this.onSampleChange();
+ },
+ $refresh: function() {
+ if (!this.sample) return;
+ var root = this.$getElement(0), before, after;
+ if (root) {
+ before = root.querySelector(".before");
+ after = root.querySelector(".after");
+ before.innerHTML = this.before;
+ after.innerHTML = this.after;
+ }
+ },
+
+ onSampleChange: function() {
+ if (!this.sample) return;
+ var parts = this.sample.description.split("[#output]");
+ this.before = parts[0];
+ this.after = parts[1];
+ }
+});
+
+{template desc using ctrl:DescriptionCtrl}
+ <div id="description">
+ {if ctrl.sample}
+ <div class="before"></div>
+ {/if}
+ <div id="output" class="output"></div>
+ <div id="logs" class="logoutput"></div>
+ {if ctrl.sample}
+ <div class="after"></div>
+ {/if}
+ </div>
+{/template}
+
{export template mainLayout(data, playground)}
<#sampleList data="{data}" playground="{playground}"/>
@@ -19,8 +61,7 @@ var splitter = require("./splitter.hsp");
<div class="description" style="left: {data.splitterPos}">
<div>
<h4>Description</h4>
- // TODO remove this fixed id
- <div id="description"></div>
+ <#desc sample="{data.samples[data.sampleIndex]}" />
</div>
</div>
</div>
View
123 docs/playground/playground.js
@@ -1,20 +1,13 @@
// Playground controller
-var jx = require("/libs/jx");
-var markdown = require("/libs/markdown");
-
var hsp = require("hsp/rt");
-var compile = require("hsp/compiler/compile");
var klass = require("hsp/klass");
var log = require("hsp/rt/log");
+var compile;
-var layout = require("./layout.hsp");
+var layout = require("./layout.hsp.js");
var samples = require("../samples/samples");
-
-
-
-
var samplesMap = {}; // a map of the samples, using their containing folders as keys
for (var index = 0, length = samples.length; index < length; index++) {
var sample = samples[index];
@@ -26,8 +19,6 @@ for (var index = 0, length = samples.length; index < length; index++) {
var count = 0; // number of playgrounds that have been created
var playgrounds = {}; // collection of playground instances
-
-
var Playground = module.exports = klass({
containerId : "",
@@ -35,22 +26,30 @@ var Playground = module.exports = klass({
* Class constructor
* @param {String} containerId the id of the HTML element where the playground should be displayed
*/
- $constructor : function (containerId) {
+ $constructor : function (containerId, devMode) {
count++;
this.idx = count;
playgrounds['p' + this.idx] = this; // register in the global list - cf. notifyScriptError
this.containerId = containerId;
+ this.devMode = devMode;
this.data = {
errors : [],
sampleIndex : -1,
sampleTitle : "",
- files : [],
samples : samples,
navCollapsed : false,
navHover : false,
splitterPos : "50%"
};
+
+
+ if (!devMode) {
+ var compiler = document.createElement("script");
+ compiler.type = "text/javascript";
+ compiler.src = "/dist/" + window.hashspace_version + "/hashspace-noder-compiler.min.js";
+ document.querySelector("head").appendChild(compiler);
+ }
},
$dispose : function () {
@@ -81,20 +80,36 @@ var Playground = module.exports = klass({
clearTimeout(self.changeTimeout);
self.changeTimeout = null;
}
- // only one file for now
+
var data = self.data;
- var fileName = data.samples[data.sampleIndex].files[0].src;
+ var sample = data.samples[data.sampleIndex];
+ var fileName = sample.files[0].src;
+
self.changeTimeout = setTimeout(function () {
- // the value is evaluated once the socket replies with a compiled template
self.changeTimeout = null;
- self.compileAndUpdate(fileName, self.editor.getValue());
- }, 200);
+ if (sample.changed) {
+ self.compileAndUpdate(fileName, self.editor.getValue());
+ } else {
+ sample.changed = true;
+ self.executeSampleTpl(sample);
+ }
+ }, 100);
});
}
},
+ executeSampleTpl: function(sample) {
+ var template = sample.sample.template,
+ data = sample.sample.data || [];
+ if (typeof data === 'function') {
+ data = data.call(sample.sample);
+ }
+ template.apply(sample.sample, data).render("output");
+ },
+
/**
- * static method called
+ * Notify the playground about compilation errors
+ * @static
*/
notifyScriptError : function (playgroundIndex, errorDescription, fileName) {
var error = {
@@ -108,7 +123,6 @@ var Playground = module.exports = klass({
* Compile and update the code associated to one of the sample files
*/
compileAndUpdate : function (fileName, newCode) {
- // alert(fileName + " : " + newCode);
var self = this;
var callback = function (error, code) {
@@ -131,24 +145,32 @@ var Playground = module.exports = klass({
require.cache[moduleName] = null;
}
- noder.execute(code, moduleName).then(function () {
+ // reexecute the module
+ noder.execute(code, moduleName).then(function (sampleExports) {
+ var spl = data.samples[data.sampleIndex];
+ spl.sample = sampleExports;
+ self.executeSampleTpl(spl);
}, function (exception) {
self.notifyScriptError(self.idx, exception, fileName);
}).end();
} catch (exception) {
- console.warn("[compileAndUpdate] " + exception.message + " (line:" + exception.line + ", column:" + exception.column
- + ")");
+ console.warn("[compileAndUpdate] " + exception.message + " (line:" + exception.line +
+ ", column:" + exception.column + ")");
}
}
};
+ if (!compile) {
+ compile = module.require("hsp/compiler/compile");
+ }
+
var compiledCode = compile(newCode, fileName);
callback(null, compiledCode);
},
/**
- * Show a particular sample
- * @param {Integer} index the index of the sample in the sample collection
+ * Initialize the playground layout, and load a sample
+ * @param {Integer|String} index the index of the sample in the sample collection, or its name (folder based)
*/
showSample : function (index) {
// load layout template
@@ -157,49 +179,24 @@ var Playground = module.exports = klass({
this.loadSample(index);
},
+ /**
+ * Show a particular sample
+ * @param {Integer|String} index the index of the sample in the sample collection, or its name (folder based)
+ */
loadSample : function (index) {
- var sample;
- if (typeof index === 'number') {
- sample = samples[index];
- } else {
- sample = samplesMap[index];
- }
- var self = this;
- var data = this.data;
+ var sample = (typeof index === 'number') ? samples[index] : samplesMap[index];
- if (!sample.description) {
- sample.description = "description.md";
- }
-
- jx.load("/samples/" + sample.folder + "/" + sample.description, function (error, data) {
- if (!error) {
- var descriptionElement = document.getElementById("description");
-
- var descriptionContent = markdown.toHTML(data); // 'Hello *World*! [#output] [#snippet 0]'
- descriptionContent = descriptionContent.replace(
- /\[\#output\]/i,
- '<div id="output" class="output"></div><div id="logs" class="logoutput"></div>'
- );
-
- descriptionElement.innerHTML = descriptionContent;
+ if (this.data.sampleIndex === sample.index) return;
- if (!data.errors) {
- data.errors = [];
- }
-
- layout.errorList(data.errors).render("logs");
- }
- });
+ console.log("loading", index);
+ sample.changed = sample.changed || false;
- data.sampleIndex = sample.index;
- data.sampleTitle = sample.title;
- data.files = sample.files;
+ this.data.errors = [];
+ layout.errorList(this.data.errors).render("logs");
- jx.load("/samples/" + sample.folder + "/" + sample.files[0].src, function (error, data) {
- if (!error) {
- self.editor.setValue(data, -1);
- }
- });
+ this.data.sampleIndex = sample.index;
+ this.data.sampleTitle = sample.title;
+ this.editor.setValue(sample.files[0].text, -1);
},
log : function (message) {
View
8 docs/samples/clickhandler/clickhandler.hsp
@@ -26,6 +26,10 @@ function changeMessage() {
// set a first message value
changeMessage();
-// display the template in the #output div
-message(msg).render("output");
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: message,
+ data: [msg]
+};
View
15 docs/samples/clock/clock.hsp
@@ -23,11 +23,11 @@ var ClockController=klass({
},
onCityChange:function() {
// dynamic city change: check city validity and refresh the display
- if (!CITIES[this.city]) {
+ if (!CITIES[this.city]) {
// unsupported city
this.city="PAR"; // default
}
- this.tick();
+ this.tick();
},
tick:function() {
var d=new Date();
@@ -48,10 +48,10 @@ var ClockController=klass({
<svg viewBox="0 0 100 100">
<g transform="translate(50,50)">
<circle class="clock-face" r="48"/>
- // minute markers
+ // minute markers
{foreach idx,m in c.minuteMarkers}
// {foreach i in [1..60]} should be supported in a future version
- <line class="{'major':m.major,'minor':!m.major}" y1="{m.major?35:42}"
+ <line class="{'major':m.major,'minor':!m.major}" y1="{m.major?35:42}"
y2="45" transform="rotate({360*idx/c.minuteMarkers.length})"/>
{/foreach}
// hour hand
@@ -75,5 +75,8 @@ var ClockController=klass({
<#clock city="TYO"/>
{/template}
-// display the template in the #output div
-demo().render("output");
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: demo
+};
View
11 docs/samples/component1/timer.hsp
@@ -13,13 +13,12 @@ var Timer=klass({
clearInterval(this._iid);
},
tick:function() {
- console.log("tick");
this.secondsElapsed++;
}
});
{template timer using t:Timer}
- Elapsed time: {t.secondsElapsed}s
+ Elapsed time: {t.secondsElapsed}s
{/template}
{template test}
@@ -28,5 +27,9 @@ var Timer=klass({
<#timer initvalue="10"/>
{/template}
-// display the test template in the #output div
-test().render("output");
+
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: test
+};
View
65 docs/samples/component2/nbrfield.hsp
@@ -1,51 +1,51 @@
var klass=require("hsp/klass");
// Component controller
-var NbrField = klass({
- attributes:{
- "value":{type:"float",defaultValue:0,binding:"2-way"},
- "defaultvalue":{type:"float",defaultValue:0},
- "min":{type:"float",defaultValue:-Number.MAX_VALUE,binding:"1-way"},
+var NbrField = klass({
+ attributes:{
+ "value":{type:"float",defaultValue:0,binding:"2-way"},
+ "defaultvalue":{type:"float",defaultValue:0},
+ "min":{type:"float",defaultValue:-Number.MAX_VALUE,binding:"1-way"},
"max":{type:"float",defaultValue:Number.MAX_VALUE,binding:"1-way"},
"onreset":{type:"callback"}
},
/**
* init method called when all attributes have been initialized
*/
- $init:function() {
+ $init:function() {
// set and init internal properties
this.internalValue=''+this.value; // type:string but bound to value
this.isValid=true; // bound to internalValue, min and max
this.checkValidity();
},
- /**
+ /**
* attribute change handlers - notify the controller that an external object
* (template or host) updated the value attribute
*/
onValueChange:function(newValue,oldValue) {
var n=getNumber(newValue);
this.internalValue = n!==null? n : 0;
- this.checkValidity();
+ this.checkValidity();
},
onMinChange:function(newValue,oldValue) {
- this.checkValidity();
+ this.checkValidity();
},
onMaxChange:function(newValue,oldValue) {
- this.checkValidity();
+ this.checkValidity();
},
- /**
+ /**
* property change handler - notify the controller that the template
- * changed an internal property
- */
- onInternalValueChange:function(newValue,oldValue) {
+ * changed an internal property
+ */
+ onInternalValueChange:function(newValue,oldValue) {
// validate and expose as attribute if ok
this.value = this.checkValidity()? parseInt(this.internalValue,10) : this.defaultvalue;
- },
- /**
- * Check if the internal value is valid and update the isValid property accordingly
- */
- checkValidity:function() {
- var n=getNumber(this.internalValue);
+ },
+ /**
+ * Check if the internal value is valid and update the isValid property accordingly
+ */
+ checkValidity:function() {
+ var n=getNumber(this.internalValue);
var v=(n===null)? false : (n>=this.min) && (n<=this.max);
return this.isValid = v;
},
@@ -61,18 +61,18 @@ var NbrField = klass({
}
})
-// transform a string to a number
-var NBR_DIGITS=/^(\-|\.|\+)?\d+(\.)?(\d+)?$/;
-function getNumber(s) {
- s=""+s;
- if (!NBR_DIGITS.test(s)) return null;
- return Number(s);
+// transform a string to a number
+var NBR_DIGITS=/^(\-|\.|\+)?\d+(\.)?(\d+)?$/;
+function getNumber(s) {
+ s=""+s;
+ if (!NBR_DIGITS.test(s)) return null;
+ return Number(s);
}
// component template associated with the NbrField controller
{export template nbrfield using c:NbrField}
<span class="nbrfield">
- <input type="text" model="{c.internalValue}"
+ <input type="text" model="{c.internalValue}"
class="{'nbrfield', 'error': !c.isValid}"/>
<button onclick="{c.resetField()}">reset</button>
</span>
@@ -81,12 +81,17 @@ function getNumber(s) {
// component usage
{template test(d)}
Component #1: <#nbrfield value="{d.value1}" min="-10" max="1000"/><br/>
- Value in the data model: <span class="textValue">{d.value1}</span>
+ Value in the data model: <span class="textValue">{d.value1}</span>
(min:-10 / max:1000 / default:0)
<hr/>
Component #2: <#nbrfield value="{d.value2}"/><br/>
Value in the data model: <span class="textValue">{d.value2}</span>
{/template}
-// display the template in the #output div
-test({value1:123}).render("output");
+
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: test,
+ data: [{ value1 : 123 }]
+};
View
28 docs/samples/component3/pagination.hsp
@@ -1,5 +1,5 @@
var klass=require("hsp/klass");
-
+
function calculateNoOfPages(collectionSize, pageSize) {
return Math.ceil(collectionSize / pageSize);
}
@@ -7,7 +7,7 @@ function calculateNoOfPages(collectionSize, pageSize) {
function rebuildPagesModel(noOfPages) {
var pages = [];
for (var i=0; i<noOfPages; i++) {
- pages.push(i);
+ pages.push(i);
}
return pages;
}
@@ -15,7 +15,7 @@ function rebuildPagesModel(noOfPages) {
function rebuildInternalModel(ctl) {
ctl.noOfPages = calculateNoOfPages(ctl.collectionsize, ctl.pagesize);
ctl.pages = rebuildPagesModel(ctl.noOfPages);
- ctl.selectPage(ctl.activepage);
+ ctl.selectPage(ctl.activepage);
}
var Pagination=klass({
@@ -26,7 +26,7 @@ var Pagination=klass({
"onpageselect":{type:"callback"}
},
$init:function() {
- rebuildInternalModel(this);
+ rebuildInternalModel(this);
},
selectPage: function(newPageNo) {
newPageNo = Math.min(Math.max(0, newPageNo), this.noOfPages-1);
@@ -35,11 +35,11 @@ var Pagination=klass({
this.onpageselect({pageNumber:this.activepage});
}
},
- onCollectionsizeChange: function() {
- rebuildInternalModel(this);
+ onCollectionsizeChange: function() {
+ rebuildInternalModel(this);
},
onPagesizeChange: function() {
- rebuildInternalModel(this);
+ rebuildInternalModel(this);
}
});
@@ -52,13 +52,13 @@ var Pagination=klass({
<li class="{'active':page==p.activepage}">
<a onclick="{p.selectPage(page)}">{page + 1}</a>
</li>
- {/foreach}
+ {/foreach}
<li class="{'disabled':p.activepage>=p.noOfPages-1}">
<a onclick="{p.selectPage(p.activepage+1)}">Next</a>
</li>
</ul>
{/template}
-
+
{template paginationTest(model)}
<div class="section3">
<label class="fieldlabel">Active page: </label><input type="number" model="{model.active}"/><br/>
@@ -66,7 +66,7 @@ var Pagination=klass({
<label class="fieldlabel">Page size: </label><input type="number" model="{model.pageSize}"/><br/>
Last page selection <i> - from event</i>: <span class="textValue">{model.lastSelectedPage}</span>
</div>
- <#pagination activepage="{model.active}" collectionsize="{model.collectionSize}"
+ <#pagination activepage="{model.active}" collectionsize="{model.collectionSize}"
pagesize="{model.pageSize}" onpageselect="{updateSelection(event.pageNumber)}"/>
{/template}
@@ -82,5 +82,9 @@ function updateSelection(newPageNumber) {
model.lastSelectedPage = newPageNumber;
}
-// display the test template in the #output div
-paginationTest(model).render("output");
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: paginationTest,
+ data: [model]
+};
View
20 docs/samples/conditions/conditions.hsp
@@ -12,18 +12,18 @@ var klass=require("hsp/klass");
(Number is less than zero)
{/if}
<br/>
- Condition using ternary operator: Number is
- <span class="textvalue">
- {nt.number>0? "strictly positive" : "negative or null"}
+ Condition using ternary operator: Number is
+ <span class="textvalue">
+ {nt.number>0? "strictly positive" : "negative or null"}
</span>
</div>
<div class="section2">
- <a onclick="{nt.increment(1)}">Increment Number</a> -
+ <a onclick="{nt.increment(1)}">Increment Number</a> -
<a onclick="{nt.increment(-1)}">Decrement Number</a>
</div>
{/template}
-// klass is a little utility to create a JS object constructor
+// klass is a little utility to create a JS object constructor
// from a simple JSON structure - main goals are to
// to simplify prototypal inheritance and ease code reading
var NumberTester=klass({
@@ -35,5 +35,11 @@ var NumberTester=klass({
}
});
-// display the template in the #output div
-test(new NumberTester()).render("output");
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: test,
+ data: function() {
+ return [new NumberTester()];
+ }
+};
View
14 docs/samples/cssclass/cssclass.hsp
@@ -1,8 +1,8 @@
{template message(msg)}
// onselectstart: prevent double-click selection on a elements
- <div onselectstart="return false">
- <a onclick="{toggleUrgency()}">Change Urgency</a> -
- <a onclick="{setCategory('personal')}">Set "Personal"</a> -
+ <div onselectstart="return false">
+ <a onclick="{toggleUrgency()}">Change Urgency</a> -
+ <a onclick="{setCategory('personal')}">Set "Personal"</a> -
<a onclick="{setCategory('professional')}">Set "Professional"</a>
<div class="{'msg', 'urgent':msg.urgency, msg.category}">
Message: {msg.text}
@@ -26,5 +26,9 @@ function setCategory(cat) {
msg.category = cat;
}
-// display the template in the #output div
-message(msg).render("output");
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: message,
+ data: [msg]
+};
View
13 docs/samples/dynpath/dynpath.hsp
@@ -1,9 +1,9 @@
{template grid(data)}
- <div>
+ <div>
{foreach idx in data.rows}
<div>
{foreach name in data.columns}
- {if name==="c"}
+ {if name==="c"}
<input class="cell" type="text" model="{data.items[idx][name]}">
{/if}
<div class="cell" title="Ref: {idx}/{name}">
@@ -51,6 +51,9 @@ function swapC() {
}
}
-// display the template in the #output div
-grid(model).render("output");
-
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: grid,
+ data: [model]
+};
View
9 docs/samples/dyntemplates/dyntemplates.hsp
@@ -26,5 +26,10 @@ function swapTemplate() {
model.view = newtpl;
}
-// display the template in the #output div
-test(model).render("output");
+
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: test,
+ data: [model]
+};
View
10 docs/samples/gestures/gestures.hsp
@@ -1,5 +1,5 @@
{template gestures(msgList)}
- <div class="touchboard" style="height:200px; background: #27AAFC;text-align:center;"
+ <div class="touchboard" style="height:200px; background: #27AAFC;text-align:center;"
ontap="{addMsg(event)}" ontapstart="{addMsg(event)}" ontapcancel="{addMsg(event)}"
onlongpress="{addMsg(event)}" onlongpressstart="{addMsg(event)}" onlongpresscancel="{addMsg(event)}"
onsingletap="{addMsg(event)}" onsingletapstart="{addMsg(event)}" onsingletapcancel="{addMsg(event)}"
@@ -28,5 +28,9 @@ function clearMsg() {
}
-// display the template in the #output div
-gestures(eventLog).render("output");
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: gestures,
+ data: [eventLog]
+};
View
11 docs/samples/global/global.hsp
@@ -19,5 +19,12 @@ hsp.global.ln={personDetails:"Person details"};
</div>
{/template}
-// render template in the #output div
-test({firstName:"Homer",lastName:"Simpson"}).render("output");
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: test,
+ data: [{
+ firstName:"Homer",
+ lastName:"Simpson"
+ }]
+};
View
16 docs/samples/helloworld/description.md
@@ -11,7 +11,21 @@ Then calling the template function generates a **template node** that can be ins
As templates are functions, it means that the same template can be used to generate multiple fragments of the same DOM - usually with different arguments, of course.
-As Hashspace currently relies on a [commonJS] dependency manager, it also means that templates can be easily exported to be used from other files (cf. *sub-template* example).
+As Hashspace currently relies on a [commonJS] dependency manager, it also means that templates can be easily exported to be used from other files (cf. *sub-template* example).
+
+To be able to execute the sample code you can read on the left, the playground needs to know which template function
+has to be executed, and what data to be injected.
+
+Hence this code at the bottom:
+
+```javascript
+module.exports = {
+ template: hello, // javascript reference to the template function
+ data: [ "World" ] // the data to be injected
+}
+```
+
+Each sample will declare this export object to be compatible with the playground application.
*NB: In future releases, Hashspace should provide compilation options to generate code independent from commonJS so that any module system can be used*
View
8 docs/samples/helloworld/hello.hsp
@@ -5,5 +5,9 @@
</div>
{/template}
-// display the template in the #output div
-hello("World").render("output");
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: hello,
+ data: ["World"]
+};
View
16 docs/samples/inputsample/inputsample.hsp
@@ -8,7 +8,7 @@
<div class="section">
<input id="cb1" type="checkbox" value="{data.isChecked}"/>
<label for="cb1">Check me!</label> -
-
+
<input id="cb2" type="checkbox" model="{data.isChecked}"/>
<label for="cb2">Check me (2)!</label> -
Checked: <span class="textValue">{data.isChecked}</span>
@@ -16,16 +16,16 @@
<div class="section">
<input id="rb1" type="radio" model="{data.selection}" value="A"/>
<label for="rb1">Select A</label> -
-
+
<input id="rb2" type="radio" model="{data.selection}" value="B"/>
<label for="rb2">Select B</label> -
-
+
<input id="rb3" type="radio" model="{data.selection}" value="C"/>
<label for="rb3">Select C</label> -
Selection in model:<span class="textValue">{data.selection}</span>
</div>
<div class="section">
- Input with dynamic type:
+ Input with dynamic type:
<input type="{data.dtype}" value="{data.comment}" style="width:100px"/> -
change type: <input type="text" value="{data.dtype}" style="width:100px"/>
</div>
@@ -33,5 +33,9 @@
var d={comment:"edit me!", isChecked:false, selection:"B", dtype:"text"}
-// display the template in the #output div
-inputSample(d).render("output");
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: inputSample,
+ data: [d]
+};
View
10 docs/samples/let/let.hsp
@@ -5,7 +5,7 @@
Part 1.1: <span class="textValue">{p11.msg}</span><br/>
</div>
<div>
- Part 2.1: <span class="textValue">{m21}</span> -
+ Part 2.1: <span class="textValue">{m21}</span> -
{if !p11}
p11 is of course not visible in the 2nd element scope
{/if}
@@ -29,5 +29,9 @@ function updateModel() {
model.part2.part21.msg = "(2.1 update: "+count+")";
}
-// render template in the #output div
-test(model).render("output");
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: test,
+ data: [model]
+};
View
20 docs/samples/list1/list.hsp
@@ -1,5 +1,5 @@
var klass=require("hsp/klass");
-
+
// simple list controller
var ListController = klass({
attributes: {
@@ -20,7 +20,7 @@ var ListController = klass({
{if lc.head}
<div class="head"><#lc.head/></div>
{/if}
- {if !lc.content}
+ {if !lc.content}
<span class="nodata">Empty list</span>
{else}
<ul class="">
@@ -45,10 +45,10 @@ var ListController = klass({
<#list class="listcpt">
<@head>
- Dynamic list:
- <a onclick="{toggle()}">Toggle favourite</a> -
- <a onclick="{empty()}">Empty</a> -
- <a onclick="{update()}">Update list</a>
+ Dynamic list:
+ <a onclick="{toggle()}">Toggle favourite</a> -
+ <a onclick="{empty()}">Empty</a> -
+ <a onclick="{update()}">Update list</a>
</@head>
{if d.preferredOption}
<@option>{d.preferredOption} (!)</@option>
@@ -81,5 +81,9 @@ function update() {
}
}
-// display the test template in the #output div
-test(model).render("output");
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: test,
+ data: [model]
+};
View
18 docs/samples/list2/list.hsp
@@ -42,7 +42,7 @@ var ListCtrl = klass({
{if lc.head}
<div class="head"><#lc.head/></div>
{/if}
- {if !lc.content}
+ {if !lc.content}
<span class="nodata">Empty list</span>
{else}
<ul class="">
@@ -63,7 +63,7 @@ var ListCtrl = klass({
// test template
{template test(d)}
Click on an item to select it:
-
+
<#list head="Static list" class="listcpt" onselect="{showSelection(event.value)}">
<@option value="A" label="First {d.itemName}"/>
<@option value="B">Second {d.itemName}</@option>
@@ -71,9 +71,9 @@ var ListCtrl = klass({
<#list class="listcpt" onselect="{showSelection(event.value)}">
<@head>
- Dynamic list:
- <a onclick="{empty()}">Empty</a> -
- <a onclick="{update()}">Update list</a>
+ Dynamic list:
+ <a onclick="{empty()}">Empty</a> -
+ <a onclick="{update()}">Update list</a>
</@head>
{foreach idx,itm in d.items}
<@option value="K{idx}">{idx+1}. {itm}</@option>
@@ -103,5 +103,9 @@ function showSelection(v) {
model.selectedItem = v;
}
-// display the test template in the #output div
-test(model).render("output");
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: test,
+ data: [model]
+};
View
11 docs/samples/listsorting/list.hsp
@@ -1,5 +1,5 @@
{template list(persons)}
- <div onselectstart="return false">
+ <div onselectstart="return false">
<div class="msg">
<span class="info">
List sorted with the orderBy() function:
@@ -34,6 +34,9 @@ var people = [
{name:"Maggie", age:1}
];
-// display the template in the #output div
-list(people).render("output");
-
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: list,
+ data: [people]
+};
View
16 docs/samples/listupdate/list.hsp
@@ -1,9 +1,9 @@
{template list(persons)}
// onselectstart: prevents double-click selection on elements
- <div onselectstart="return false">
+ <div onselectstart="return false">
<div class="msg">
- <a onclick="{addElement()}">Add element</a> -
- <a onclick="{deleteElement()}">Delete element</a> -
+ <a onclick="{addElement()}">Add element</a> -
+ <a onclick="{deleteElement()}">Delete element</a> -
<a onclick="{changeAll()}">Change all elements</a>
</div>
<ol>
@@ -39,7 +39,7 @@ function addElement() {
function deleteElement() {
// remove one element at position 0
- persons.shift(); // same as persons.splice(0,1);
+ persons.shift(); // same as persons.splice(0,1);
}
function changeAll() {
@@ -53,6 +53,10 @@ function changeAll() {
]);
}
-// display the template in the #output div
-list(persons).render("output");
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: list,
+ data: [persons]
+};
View
12 docs/samples/logs/logs.hsp
@@ -2,8 +2,8 @@ var log=require("hsp/rt/log");
{template test(cities, logs)}
{log "top-level:",scope}
- <a onclick="{increaseList()}">Increase list</a> -
- <a onclick="{decreaseList()}">Decrease list</a> -
+ <a onclick="{increaseList()}">Increase list</a> -
+ <a onclick="{decreaseList()}">Decrease list</a> -
<a onclick="{clearLogs()}">Clear logs</a>
<ul>
{foreach idx,city in cities}
@@ -50,5 +50,9 @@ function clearLogs() {
logs.splice(0,logs.length);
}
-// render template in the #output div
-test(cities,logs).render("output");
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: test,
+ data: [cities, logs]
+};
View
10 docs/samples/modifiers/modifiers.hsp
@@ -5,7 +5,7 @@ function changeCase(s,arg) {
return (""+s).toUpperCase();
} else if (arg==="lower") {
return (""+s).toLowerCase();
- }
+ }
return s;
}
@@ -71,4 +71,10 @@ var data={
]
};
-sample(data).render("output");
+
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: sample,
+ data: [data]
+};
View
14 docs/samples/panel/panel.hsp
@@ -1,8 +1,8 @@
var klass=require("hsp/klass");
-
-var PanelController = klass({
+
+var PanelController = klass({
attributes: {
- "head":{type:"template"},
+ "head":{type:"template"},
"body":{type:"template",defaultContent:true}
}
});
@@ -39,5 +39,9 @@ function update(incr) {
model.text = "Hello World ("+count+")";
}
-// display the test template in the #output div
-test(model).render("output");
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: test,
+ data: [model]
+};
View
1  docs/samples/samples.js
@@ -207,5 +207,4 @@ module.exports = [{
main : true
}]
}
-
];
View
11 docs/samples/simplelist/simplelist.hsp
@@ -2,7 +2,7 @@
<div class="msg">Click on a person to see more details:</div>
<ul>
{foreach p in d.people}
- <li class="{'details':p.showdetails, 'special':p.name==='Bart'}"
+ <li class="{'details':p.showdetails, 'special':p.name==='Bart'}"
onclick="{toggleDetails(p)}">
{p.name}
{if p.showdetails}: {p.age} years old{/if}
@@ -28,6 +28,9 @@ var d={
]
}
-// display the template in the #output div
-people(d).render("output");
-
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: people,
+ data: [d]
+};
View
9 docs/samples/subtemplates/subtemplates.hsp
@@ -33,5 +33,10 @@ var persons=[
{firstName:"Maggy"}
]
-// display the template in the #output div
-personList(persons).render("output");
+
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: personList,
+ data: [persons]
+};
View
7 docs/samples/tabbar/tabbar.hsp
@@ -89,5 +89,8 @@ var TabBarCtrl = klass({
</label>
{/template}
-
-test().render("output");
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: test
+};
View
7 docs/samples/textarea/textarea.hsp
@@ -25,4 +25,9 @@ function changeText(d) {
d.text=msg.join("\n");
}
-sample(d).render("output");
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: sample,
+ data: [d]
+};
View
14 docs/samples/thirdpartycpts/chart.hsp
@@ -37,7 +37,7 @@ var ChartCpt=klass({
});
{template chart using c:ChartCpt}
- <canvas width="{c.width}" height="{c.height}"></canvas>
+ <canvas width="{c.width}" height="{c.height}"></canvas>
{/template}
{template test(data)}
@@ -55,5 +55,13 @@ var ChartCpt=klass({
</div>
{/template}
-// display the template in the #output div
-test({type:"line",ds:"d1"}).render("output");
+
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: test,
+ data: [{
+ type:"line",
+ ds:"d1"
+ }]
+};
View
12 docs/samples/timer/timer.hsp
@@ -4,7 +4,7 @@ var klass=require("hsp/klass");
Seconds Elapsed: {timer.secondsElapsed}
{/template}
-// klass is a little utility to create a JS object constructor
+// klass is a little utility to create a JS object constructor
// from a simple JSON structure - main goals are to
// to simplify prototypal inheritance and ease code reading
var Timer=klass({
@@ -20,5 +20,11 @@ var Timer=klass({
}
});
-// display the template in the #output div
-elapsedTime(new Timer()).render("output");
+// Needed by the playground application.
+// Update it, but do not remove it!
+module.exports = {
+ template: elapsedTime,
+ data: function() {
+ return [new Timer()];
+ }
+};
View
9 docs/samples/todolist/todolist.hsp
@@ -34,5 +34,10 @@ var TodoCtl=klass({
}
});
-// display the template in the #output div
-todolist(new TodoCtl()).render("output");
+// Needed by the playground application.
+// Update it, but do not remove it!
+var ctrl = new TodoCtl();
+module.exports = {
+ template: todolist,
+ data: [ctrl]
+};
View
131 gruntfile.js
@@ -218,10 +218,10 @@ module.exports = function (grunt) {
}
},
jscs: {
- src: ['hsp/**/*.js', 'docs/**/*.js', '!docs/**/*.js'],
- options: {
- config: '.jscs.json'
- }
+ src: ['hsp/**/*.js', 'docs/**/*.js', '!docs/**/*.js'],
+ options: {
+ config: '.jscs.json'
+ }
},
hspserver: {
port: 8000,
@@ -281,72 +281,75 @@ module.exports = function (grunt) {
}
},
peg:{
- grammar: {
- src: "hsp/compiler/parser/hspblocks.pegjs",
- dest: "hsp/compiler/parser/hspblocks.peg.js",
- options:{
- cache:true,
- trackLineAndColumn : true
- }
+ grammar: {
+ src: "hsp/compiler/parser/hspblocks.pegjs",
+ dest: "hsp/compiler/parser/hspblocks.peg.js",
+ options:{
+ cache:true,
+ trackLineAndColumn : true
}
+ }
},
atpackager : {
- options : {
- sourceDirectories : ['.'],
- sourceFiles : ['hsp/**/*.js'],
- outputDirectory : 'dist/',
- visitors : [{
- type : "ImportSourceFile",
- cfg : {
- sourceFile : "tmp/uglify-js.js",
- targetLogicalPath : "uglify-js.js"
- }
- }, {
- type : "ImportSourceFile",
- cfg : {
- sourceFile : require.resolve("acorn/acorn"),
- targetLogicalPath : "acorn/acorn.js"
- }
- }, "NoderDependencies", {
- type : "CheckDependencies",
- cfg : {
- noCircularDependencies : false
- }
- }]
+ options : {
+ sourceDirectories : ['.'],
+ sourceFiles : ['hsp/**/*.js'],
+ outputDirectory : 'dist/',
+ visitors : [{
+ type : "ImportSourceFile",
+ cfg : {
+ sourceFile : "tmp/uglify-js.js",
+ targetLogicalPath : "uglify-js.js"
+ }
+ }, {
+ type : "ImportSourceFile",
+ cfg : {
+ sourceFile : require.resolve("acorn/acorn"),
+ targetLogicalPath : "acorn/acorn.js"
+ }
+ },
+ "NoderDependencies", {
+ type : "CheckDependencies",
+ cfg : {
+ noCircularDependencies : false
+ }
+ }]
+ },
- },
- uglify : {
- options : {
- sourceDirectories : ["node_modules/uglify-js/lib"],
- sourceFiles : [],
- outputDirectory : 'tmp',
- visitors : ["NoderExportVars"],
- packages : [{
- builder : "Concat",
- name : 'uglify-js.js',
- files : ["utils.js", "ast.js", "parse.js", "transform.js", "scope.js", "output.js",
- "compress.js"]
- }]
- }
- },
- runtime : {
- options : {
- defaultBuilder : {
- type : "NoderPackage",
- cfg : {
- outputFileWrapper : "(function(define){$CONTENT$;})(noder.define);"
- }
- },
- packages : [{
- name : "hashspace-noder.js",
- files : ['hsp/*.js', 'hsp/rt/*.js', 'hsp/gestures/*.js']
- }, {
- name : "hashspace-noder-compiler.js",
- files : ['hsp/compiler/compile.js','hsp/transpiler/transpile.js']
- }]
- }
+ uglify : {
+ options : {
+ sourceDirectories : ["node_modules/uglify-js/lib"],
+ sourceFiles : [],
+ outputDirectory : 'tmp',
+ visitors : ["NoderExportVars"],
+ packages : [{
+ builder : "Concat",
+ name : 'uglify-js.js',
+ files : [
+ "utils.js", "ast.js", "parse.js", "transform.js", "scope.js", "output.js",
+ "compress.js" ]
+ }]
+ }
+ },
+
+ runtime : {
+ options : {
+ defaultBuilder : {
+ type : "NoderPackage",
+ cfg : {
+ outputFileWrapper : "(function(define){$CONTENT$;})(noder.define);"
}
+ },
+ packages : [{
+ name : "hashspace-noder.js",
+ files : ['hsp/*.js', 'hsp/rt/*.js', 'hsp/gestures/*.js']
+ }, {
+ name : "hashspace-noder-compiler.js",
+ files : ['hsp/compiler/compile.js','hsp/transpiler/transpile.js']
+ }]
}
+ }
+ }
});
// Automatically load all the grunt tasks
Please sign in to comment.
Something went wrong with that request. Please try again.