From 99c749ac2b8f778f73e28af2c8dc4e02925831b6 Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Wed, 6 Jul 2016 11:00:37 +0200 Subject: [PATCH 01/27] 3.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 85adacf..8035b1d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "choo", - "version": "3.0.0", + "version": "3.0.1", "description": "A 5kb framework for creating sturdy frontend applications", "main": "index.js", "scripts": { From e8b1dcff9fd93f0a5c6f90b9cd9951a97feb6699 Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Wed, 6 Jul 2016 12:57:14 +0200 Subject: [PATCH 02/27] docs: emojify demos --- README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 75b5fb1..f5e1b1f 100644 --- a/README.md +++ b/README.md @@ -98,14 +98,16 @@ - __very cute:__ choo choo! ## Demos -- [Input example](examples/title/) - ([requirebin](http://requirebin.com/?gist=e589473373b3100a6ace29f7bbee3186)) -- [HTTP effects example](https://fork-fang.hyperdev.space/) - ([hyperdev](https://hyperdev.com/#!/project/fork-fang)) -- [Mailbox routing example](examples/mailbox/) - (@examples directory) -- [TodoMVC](http://shuheikagawa.com/todomvc-choo/) - ([github](https://github.com/shuhei/todomvc-choo)) +- :truck: [Input example](http://requirebin.com/?gist=e589473373b3100a6ace29f7bbee3186) + ([repo](examples/title/)) +- :water_buffalo: [HTTP effects example](https://hyperdev.com/#!/project/fork-fang) + ([repo](https://fork-fang.hyperdev.space/)) +- :mailbox: [Mailbox routing](examples/mailbox/) +- :ok_hand: [TodoMVC](http://shuheikagawa.com/todomvc-choo/) + ([repo](https://github.com/shuhei/todomvc-choo)) +- :fire: [Choo-firebase](https://github.com/mw222rs/choo-firebase) +- :seedling: [Grow](https://grow.static.land/) + ([repo](https://github.com/sethvincent/grow)) _note: If you've built something cool using `choo` or are using it in production, we'd love to hear from you!_ From 332706486f507780bbe10dc19cb92ccd658bd750 Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Wed, 6 Jul 2016 14:56:18 +0200 Subject: [PATCH 03/27] docs: fix subs signature --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f5e1b1f..272cdae 100644 --- a/README.md +++ b/README.md @@ -397,7 +397,7 @@ arguments: Triggered by `actions`, can call `actions`. Signature of `(data, state, send, done)` - __subscriptions:__ asynchronous read-only operations that don't modify state - directly. Can call `actions`. Signature of `(state, send, done)`. + directly. Can call `actions`. Signature of `(send, done)`. #### send(actionName, data?) Send a new action to the models with optional data attached. Namespaced models From d5502263567ff098e81da12bc8add881fc1ee4a7 Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Wed, 6 Jul 2016 17:56:21 +0200 Subject: [PATCH 04/27] docs: add awesome-choo --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 272cdae..836cf6b 100644 --- a/README.md +++ b/README.md @@ -624,6 +624,8 @@ $ npm install choo ## See Also - [choo-handbook](https://github.com/yoshuawuyts/choo-handbook) - the little `choo` guide +- [awesome-choo](https://github.com/YerkoPalma/awesome-choo) - Awesome things + related with choo framework - [budo](https://github.com/mattdesl/budo) - quick prototyping tool for `browserify` - [stack.gl](http://stack.gl/) - open software ecosystem for WebGL From f5f8d01c0baa76d5ff77505b446476f8f56fa71a Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Tue, 5 Jul 2016 12:14:29 +0200 Subject: [PATCH 05/27] index: add raf guard --- index.js | 11 +++++++++-- package.json | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 5c140f6..bb7974d 100644 --- a/index.js +++ b/index.js @@ -6,6 +6,7 @@ const href = require('sheet-router/href') const hash = require('sheet-router/hash') const hashMatch = require('hash-match') const barracks = require('barracks') +const nanoraf = require('nanoraf') const assert = require('assert') const xtend = require('xtend') const yo = require('yo-yo') @@ -22,6 +23,7 @@ function choo (opts) { var _defaultRoute = null var _rootNode = null var _routes = null + var _frame = null start.toString = toString start.router = router @@ -85,8 +87,13 @@ function choo (opts) { opts.onStateChange(data, state, prev, name, createSend) } - const newTree = _router(state.location.pathname, state, prev) - _rootNode = yo.update(_rootNode, newTree) + if (!_frame) { + _frame = nanoraf(function (state, prev) { + const newTree = _router(state.location.pathname, state, prev) + _rootNode = yo.update(_rootNode, newTree) + }) + } + _frame(state, prev) } // register all routes on the router diff --git a/package.json b/package.json index 8035b1d..85abb3b 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "document-ready": "~1.0.2", "global": "^4.3.0", "hash-match": "^1.0.2", + "nanoraf": "^2.0.0", "sheet-router": "^3.1.0", "xhr": "^2.2.0", "xtend": "^4.0.1", From d9a14130b3be25788a90318d6674fc9f537ee05f Mon Sep 17 00:00:00 2001 From: Brad Simantel Date: Wed, 6 Jul 2016 14:35:46 -0700 Subject: [PATCH 06/27] Add pathname-match dependency to mailbox example The pathname-match module is being required in the pathname element, but wasn't actually included as a dependency. --- examples/mailbox/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/mailbox/package.json b/examples/mailbox/package.json index 9a1e58b..c14dfc1 100644 --- a/examples/mailbox/package.json +++ b/examples/mailbox/package.json @@ -11,6 +11,7 @@ "dependencies": { "css-wipe": "^4.2.1", "dateformat": "^1.0.12", + "pathname-match": "^1.1.3", "tachyons": "^4.0.0-beta.33" }, "devDependencies": { From 4bea3b53f0c893db3da5c815096de21a3ce14299 Mon Sep 17 00:00:00 2001 From: traducer Date: Thu, 7 Jul 2016 09:46:14 +0000 Subject: [PATCH 07/27] updated readme example for subscriptions, sending data from inside a model expects exactly 3 arguments --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 836cf6b..ced5ebd 100644 --- a/README.md +++ b/README.md @@ -302,7 +302,11 @@ app.model({ namespace: 'app', subscriptions: [ (send, done) => { - setInterval(() => send('app:print', { payload: 'dog?' }), 1000) + setInterval(() => { + send('app:print', { payload: 'dog?', myOtherValue: 1000 }, (err) => { + if (err) return done(err) + }) + }, 1000) } ], effects: { @@ -399,11 +403,13 @@ arguments: - __subscriptions:__ asynchronous read-only operations that don't modify state directly. Can call `actions`. Signature of `(send, done)`. -#### send(actionName, data?) +#### send(actionName, data?[,callback]) Send a new action to the models with optional data attached. Namespaced models can be accessed by prefixing the name with the namespace separated with a `:`, e.g. `namespace:name`. +When sending data from inside a `model` it expects exactly three arguments: the name of the action you're calling, the data you want to send, and finally a callback to handle errors through the global `onError()` hook. So if you want to send two values, you'd have to either send an array or object containing them. + #### done(err?, res?) When an `effect` or `subscription` is done executing, or encounters an error, it should call the final `done(err, res)` callback. If an `effect` was called From 5fc2cab1f01ec203ff9edafda4f74b59b306ec26 Mon Sep 17 00:00:00 2001 From: Tim Wisniewski Date: Fri, 8 Jul 2016 06:13:39 -0400 Subject: [PATCH 08/27] Correct model namespace example (#143) --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ced5ebd..c97fc80 100644 --- a/README.md +++ b/README.md @@ -236,17 +236,17 @@ namespaced or not. Namespacing means that only state within the model can be accessed. Models can still trigger actions on other models, though it's recommended to keep that to a minimum. -So say we have a `myTodos` namespace, an `add` reducer and a `todos` model. +So say we have a `todos` namespace, an `add` reducer and a `todos` model. Outside the model they're called by `send('todos:add')` and -`state.todos.todos`. Inside the namespaced model they're called by -`send('todos:add')` and `state.todos`. An example namespaced model: +`state.todos.items`. Inside the namespaced model they're called by +`send('todos:add')` and `state.items`. An example namespaced model: ```js const app = choo() app.model({ - namespace: 'myTodos', - state: { todos: [] }, + namespace: 'todos', + state: { items: [] }, reducers: { - add: (data, state) => ({ todos: state.todos.concat(data.payload) }) + add: (data, state) => ({ todos: state.items.concat(data.payload) }) } }) ``` From 3cb9364c3d15a4997cb49afe549aa5ff6183ef75 Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Fri, 8 Jul 2016 12:19:15 +0200 Subject: [PATCH 09/27] onAction: prefix views with view --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 5c140f6..f87b02d 100644 --- a/index.js +++ b/index.js @@ -117,7 +117,7 @@ function choo (opts) { } function wrap (child, route) { - const send = createSend(route, true) + const send = createSend('view: ' + route, true) return function chooWrap (params, state) { const nwPrev = prev const nwState = prev = xtend(state, { params: params }) From 745aa25017ba4fc400903f32039c1655cbfdc1fd Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Fri, 8 Jul 2016 13:46:23 +0200 Subject: [PATCH 10/27] 3.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8035b1d..aaef47a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "choo", - "version": "3.0.1", + "version": "3.0.2", "description": "A 5kb framework for creating sturdy frontend applications", "main": "index.js", "scripts": { From 1601d1cc72b04d33be4cfbcc2edfa1dd66ae17de Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Sat, 9 Jul 2016 13:42:20 +0200 Subject: [PATCH 11/27] docs: fix budo script --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c97fc80..db851e4 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,7 @@ To run it, save it as `client.js` and run with [budo][budo] and [es2020][es2020]. These tools are convenient but any [browserify][browserify] based tool should do: ```sh -$ budo 'client.js' -p 8080 --open -- -t es2020 +$ budo client.js -p 8080 --open -- -t es2020 ``` And to save the output to files so it can be deployed, open a new terminal and From 7c0fd896bf1ed759cf030f67b8be3b16c823d742 Mon Sep 17 00:00:00 2001 From: Tim Wisniewski Date: Sun, 10 Jul 2016 09:02:18 -0400 Subject: [PATCH 12/27] Docs: Correct code sample in models per #143 (#150) thx @slaskis! --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index db851e4..4a80617 100644 --- a/README.md +++ b/README.md @@ -246,7 +246,7 @@ app.model({ namespace: 'todos', state: { items: [] }, reducers: { - add: (data, state) => ({ todos: state.items.concat(data.payload) }) + add: (data, state) => ({ items: state.items.concat(data.payload) }) } }) ``` From d917e59aa4b4d8beebe85b1449055a625662a963 Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Sun, 10 Jul 2016 15:04:26 +0200 Subject: [PATCH 13/27] test: fix broken hooks test --- tests/browser/hooks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/browser/hooks.js b/tests/browser/hooks.js index b38caea..e26c961 100644 --- a/tests/browser/hooks.js +++ b/tests/browser/hooks.js @@ -15,7 +15,7 @@ test('hooks', function (t) { t.deepEqual(action, {foo: 'bar'}, 'onAction: action data') t.equal(state.clicks, 0, 'onAction: current state: 0 clicks') t.equal(name, 'click', 'onAction: action name') - t.equal(caller, '/', 'onAction: caller name') + t.equal(caller, 'view: /', 'onAction: caller name') t.equal(typeof createSend, 'function', 'onAction: createSend fn') }, onStateChange: function (action, state, prev, createSend) { From 1b1326946d87f7e178715012a74fa2102ebc2739 Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Sun, 10 Jul 2016 16:42:33 +0200 Subject: [PATCH 14/27] badges: add --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 4a80617..3cbaba6 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@
  • Example
  • Philosophy
  • Concepts
  • +
  • Badges
  • API
  • FAQ
  • Installation
  • @@ -361,6 +362,15 @@ const view = (state, prev, send) => { ``` In this example, when the `Add` button is clicked, the view will dispatch an `add` action that the model’s `add` reducer will receive. [As seen above](#models), the reducer will add an item to the state’s `todos` array. The state change will cause this view to be run again with the new state, and the resulting DOM tree will be used to [efficiently patch the DOM](#does-choo-use-a-virtual-dom). +## Badges +Using `choo` in a project? Show off which version you've used using a badge: + + +[![built with choo v3](https://img.shields.io/badge/built%20with%20choo-v3-ffc3e4.svg?style=flat-square)](https://github.com/yoshuawuyts/choo) +```md +[![built with choo v3](https://img.shields.io/badge/built%20with%20choo-v3-ffc3e4.svg?style=flat-square)](https://github.com/yoshuawuyts/choo) +``` + ## API This section provides documentation on how each function in `choo` works. It's intended to be a technical reference. If you're interested in learning choo for From 57b6ec588ba598df8762608c82b004f3c7fec98a Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Sun, 10 Jul 2016 18:38:27 +0200 Subject: [PATCH 15/27] docs: mv IRC to big menu thingy --- README.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4a80617..397d329 100644 --- a/README.md +++ b/README.md @@ -43,11 +43,6 @@ Standard - - - IRC - Freenode -
    @@ -55,12 +50,16 @@ Handbook - | - Packages - | + | + Packages + | Contributing + | + + Chat +
    From c03bcd21e5fe3d6d568f705f4efdcae468e68b8b Mon Sep 17 00:00:00 2001 From: Boris Serdiuk Date: Fri, 1 Jul 2016 11:38:53 +0200 Subject: [PATCH 16/27] prepare umd build before publish --- .gitignore | 9 ++++---- examples/vanilla/index.html | 42 +++++++++++++++++++++++++++++++++++++ package.json | 17 ++++++++++++++- 3 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 examples/vanilla/index.html diff --git a/.gitignore b/.gitignore index 7582006..03944d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,11 @@ node_modules/ coverage/ -coverage.json +dist/ tmp/ -npm-debug.log* -.DS_Store .sauce-credentials.json -*.swp sauce_connect.log +npm-debug.log* +coverage.json +.DS_Store +*.swp .zuulrc diff --git a/examples/vanilla/index.html b/examples/vanilla/index.html new file mode 100644 index 0000000..cd93a66 --- /dev/null +++ b/examples/vanilla/index.html @@ -0,0 +1,42 @@ + + + Vanilla example + + + + + + diff --git a/package.json b/package.json index aaef47a..f6fe061 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,10 @@ "test:browser": "standard && npm run deps && NODE_ENV=test zuul tests/browser/*", "test:browser:local": "standard && npm run deps && NODE_ENV=test zuul --local 8080 -- tests/browser/*", "preversion": "if [ ! -z $SKIP_TEST ]; then npm run test:browser; fi", - "test": "npm run test:electron" + "test": "npm run test:electron", + "build:dev": "NODE_ENV=development browserify index.js --standalone=choo -t envify > dist/choo.js", + "build:min": "NODE_ENV=production browserify index.js --standalone=choo -t envify -g unassertify -g uglifyify | uglifyjs > dist/choo.min.js", + "prepublish": "mkdir -p 'dist/' && npm run build:dev && npm run build:min" }, "repository": "yoshuawuyts/choo", "keywords": [ @@ -22,6 +25,11 @@ "composable", "tiny" ], + "files": [ + "index.js", + "http.js", + "dist" + ], "license": "MIT", "dependencies": { "barracks": "^8.0.0", @@ -40,6 +48,7 @@ "browserify-istanbul": "^2.0.0", "bundle-collapser": "^1.2.1", "dependency-check": "^2.5.1", + "envify": "^3.4.1", "es2020": "^1.0.1", "geval": "~2.1.1", "insert-css": "^0.2.0", @@ -54,9 +63,15 @@ "standard": "^7.1.0", "tachyons": "^4.0.0-beta.19", "tape": "^4.5.1", +<<<<<<< HEAD "tape-istanbul": "~1.0.2", "tape-run": "~2.1.4", "yo-yoify": "^3.1.0", +======= + "uglifyify": "^3.0.2", + "uglifyjs": "^2.4.10", + "unassertify": "^2.0.3", +>>>>>>> 7370fd0... prepare umd build before publish "zuul": "toddself/zuul" } } From 50daf1f481fbb412c4a0b47795cdcb42acc26cdc Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Tue, 12 Jul 2016 15:24:36 +0200 Subject: [PATCH 17/27] script/build: add --- package.json | 11 +++---- scripts/build | 54 +++++++++++++++++++++++++++++++ scripts/{test-size => instrument} | 4 ++- 3 files changed, 61 insertions(+), 8 deletions(-) create mode 100755 scripts/build rename scripts/{test-size => instrument} (97%) diff --git a/package.json b/package.json index f6fe061..c8a0624 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,9 @@ "test:browser:local": "standard && npm run deps && NODE_ENV=test zuul --local 8080 -- tests/browser/*", "preversion": "if [ ! -z $SKIP_TEST ]; then npm run test:browser; fi", "test": "npm run test:electron", - "build:dev": "NODE_ENV=development browserify index.js --standalone=choo -t envify > dist/choo.js", - "build:min": "NODE_ENV=production browserify index.js --standalone=choo -t envify -g unassertify -g uglifyify | uglifyjs > dist/choo.min.js", - "prepublish": "mkdir -p 'dist/' && npm run build:dev && npm run build:min" + "build:dev": "./scripts/build dev", + "build:min": "./scripts/build min", + "prepublish": "npm run build:dev && npm run build:min" }, "repository": "yoshuawuyts/choo", "keywords": [ @@ -63,15 +63,12 @@ "standard": "^7.1.0", "tachyons": "^4.0.0-beta.19", "tape": "^4.5.1", -<<<<<<< HEAD "tape-istanbul": "~1.0.2", "tape-run": "~2.1.4", - "yo-yoify": "^3.1.0", -======= "uglifyify": "^3.0.2", "uglifyjs": "^2.4.10", "unassertify": "^2.0.3", ->>>>>>> 7370fd0... prepare umd build before publish + "yo-yoify": "^3.1.0", "zuul": "toddself/zuul" } } diff --git a/scripts/build b/scripts/build new file mode 100755 index 0000000..6f743b2 --- /dev/null +++ b/scripts/build @@ -0,0 +1,54 @@ +#!/bin/sh + +dirname=$(dirname "$(readlink -f "$0")") + +browserify="$dirname/../node_modules/.bin/browserify" +uglify="$dirname/../node_modules/.bin/uglifyjs" + +usage () { + printf "Usage: build-umd \n" +} + +build_dev () { + mkdir -p dist/ + NODE_ENV=development "$browserify" index.js \ + --standalone=choo \ + -t envify \ + > dist/choo.js +} + +build_min () { + mkdir -p dist/ + NODE_ENV=production "$browserify" index.js \ + --standalone=choo \ + -t envify \ + -g unassertify \ + -g uglifyify \ + | "$uglify" \ + > dist/choo.min.js +} + +# set CLI flags +getopt -T > /dev/null +if [ "$?" -eq 4 ]; then + args="$(getopt --long help dev min --options hdm -- "$*")" +else + args="$(getopt h "$*")"; +fi +[ ! $? -eq 0 ] && { usage && exit 2; } +eval set -- "$args" + +# parse CLI flags +while true; do + case "$1" in + -h|--help) usage && exit 1 ;; + -- ) shift; break ;; + * ) break ;; + esac +done + +case "$1" in + d|dev) shift; build_dev "$@" ;; + m|min) shift; build_min "$@" ;; + *) shift; build_min "$@" ;; +esac diff --git a/scripts/test-size b/scripts/instrument similarity index 97% rename from scripts/test-size rename to scripts/instrument index 009daf9..123c132 100755 --- a/scripts/test-size +++ b/scripts/instrument @@ -48,7 +48,9 @@ run_discify () { getopt -T > /dev/null if [ "$?" -eq 4 ]; then args="$(getopt --long help discify minified --options hmdg -- "$*")" -else args="$(getopt h "$*")"; fi +else + args="$(getopt h "$*")"; +fi [ ! $? -eq 0 ] && { usage && exit 2; } eval set -- "$args" From 5357ca2614985619ed2497b9ba88632d6209dc1f Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Tue, 12 Jul 2016 16:11:04 +0200 Subject: [PATCH 18/27] scripts: add test --- package.json | 12 ++++---- scripts/build | 10 ------ scripts/test | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 16 deletions(-) create mode 100755 scripts/test diff --git a/package.json b/package.json index c8a0624..05454e4 100644 --- a/package.json +++ b/package.json @@ -4,12 +4,12 @@ "description": "A 5kb framework for creating sturdy frontend applications", "main": "index.js", "scripts": { - "deps": "dependency-check . && dependency-check . --extra --no-dev -i xhr", - "test:electron": "browserify tests/**/*.js -t es2020 -p proxyquire-universal | tape-run", - "test:cov": "browserify tests/**/*.js -t es2020 -p proxyquire-universal -p tape-istanbul/plugin | tape-run | tape-istanbul && istanbul report", - "test:server": "standard && npm run deps && NODE_ENV=test node tests/server/*", - "test:browser": "standard && npm run deps && NODE_ENV=test zuul tests/browser/*", - "test:browser:local": "standard && npm run deps && NODE_ENV=test zuul --local 8080 -- tests/browser/*", + "deps": "./scripts/test deps", + "test:electron": "./scripts/test electron", + "test:cov": "./scripts/test cov", + "test:server": "./scripts/test server", + "test:browser": "./scripts/test browser", + "test:browser-local": "./scripts/test browser-local", "preversion": "if [ ! -z $SKIP_TEST ]; then npm run test:browser; fi", "test": "npm run test:electron", "build:dev": "./scripts/build dev", diff --git a/scripts/build b/scripts/build index 6f743b2..c99a807 100755 --- a/scripts/build +++ b/scripts/build @@ -28,16 +28,6 @@ build_min () { > dist/choo.min.js } -# set CLI flags -getopt -T > /dev/null -if [ "$?" -eq 4 ]; then - args="$(getopt --long help dev min --options hdm -- "$*")" -else - args="$(getopt h "$*")"; -fi -[ ! $? -eq 0 ] && { usage && exit 2; } -eval set -- "$args" - # parse CLI flags while true; do case "$1" in diff --git a/scripts/test b/scripts/test new file mode 100755 index 0000000..08ddca3 --- /dev/null +++ b/scripts/test @@ -0,0 +1,85 @@ +#!/bin/sh + +# setting exit because we're linting and need to exit on failure +set -e + +dirname=$(dirname "$(readlink -f "$0")") + +dependency_check="$dirname/../node_modules/.bin/dependency-check" +tape_istanbul="$dirname/../node_modules/.bin/tape-istanbul" +browserify="$dirname/../node_modules/.bin/browserify" +standard="$dirname/../node_modules/.bin/standard" +tape_run="$dirname/../node_modules/.bin/tape-run" +istanbul="$dirname/../node_modules/.bin/istanbul" +zuul="$dirname/../node_modules/.bin/zuul" + +usage () { + printf "Usage: test\n" +} + +lint () { + "$standard" +} + +test_electron () { + check_deps + lint + "$browserify" tests/**/*.js \ + -t es2020 \ + -p proxyquire-universal \ + | "$tape_run" +} + +test_cov () { + check_deps + lint + "$browserify" tests/**/*.js \ + -t es2020 \ + -p proxyquire-universal \ + -p tape-istanbul/plugin \ + | "$tape_run" \ + | "$tape_istanbul" \ + && "$istanbul" report +} + +test_server () { + lint + standard + check_deps + NODE_ENV=test node tests/server/* +} + +test_browser () { + NODE_ENV=test "$zuul" tests/browser/* +} + +test_browser_local () { + lint + check_deps + NODE_ENV=test "$zuul" --local 8080 -- tests/browser/* +} + +check_deps () { + "$dependency_check" . --entry 'index.js' + "$dependency_check" . --entry 'index.js' --extra --no-dev \ + -i xhr +} + +# set CLI flags +# parse CLI flags +while true; do + case "$1" in + -h|--help) usage && exit 1 ;; + -- ) shift; break ;; + * ) break ;; + esac +done + +case "$1" in + e|electron) shift; test_electron "$@" && exit ;; + b|browser) shift; test_browser "$@" && exit ;; + l|browser-local) shift; test_browser_local "$@" && exit ;; + s|server) shift; test_server "$@" && exit ;; + c|cov) shift; test_cov "$@" && exit ;; + d|deps) shift; check_deps "$@" && exit ;; +esac From 4c935b32cd283e3ea8abbae12a8b2a01c1fb1d38 Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Tue, 12 Jul 2016 19:29:09 +0200 Subject: [PATCH 19/27] script/build: prune the prod builds --- scripts/build | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/build b/scripts/build index c99a807..28c2f80 100755 --- a/scripts/build +++ b/scripts/build @@ -14,6 +14,8 @@ build_dev () { NODE_ENV=development "$browserify" index.js \ --standalone=choo \ -t envify \ + -g yo-yoify \ + -g es2020 \ > dist/choo.js } @@ -23,7 +25,12 @@ build_min () { --standalone=choo \ -t envify \ -g unassertify \ + -g yo-yoify \ + -g es2020 \ -g uglifyify \ + -t envify \ + -p bundle-collapser/plugin \ + | uglifyjs \ | "$uglify" \ > dist/choo.min.js } From ed384bc54f963daf9d7305c8218a24e59b83eae9 Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Tue, 12 Jul 2016 23:05:54 +0200 Subject: [PATCH 20/27] scripts/instrument: include deps But also use zopfli if available! --- package.json | 3 +++ scripts/instrument | 41 +++++++++++++++++++++++++++++++---------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 212e161..fcb93ad 100644 --- a/package.json +++ b/package.json @@ -49,13 +49,16 @@ "browserify-istanbul": "^2.0.0", "bundle-collapser": "^1.2.1", "dependency-check": "^2.5.1", + "disc": "^1.3.2", "envify": "^3.4.1", "es2020": "^1.0.1", "geval": "~2.1.1", + "gzip-size-cli": "^1.0.0", "insert-css": "^0.2.0", "istanbul": "^0.4.4", "karma-sauce-launcher": "^1.0.0", "min-document": "~2.18.0", + "pretty-bytes-cli": "^1.0.0", "proxyquire": "~1.7.10", "proxyquire-universal": "~1.0.8", "proxyquireify": "~3.2.0", diff --git a/scripts/instrument b/scripts/instrument index 123c132..ced46c4 100755 --- a/scripts/instrument +++ b/scripts/instrument @@ -1,5 +1,13 @@ #!/bin/sh +dirname=$(dirname "$(readlink -f "$0")") + +browserify="$dirname/../node_modules/.bin/browserify" +uglify="$dirname/../node_modules/.bin/uglifyjs" +pretty_bytes="$dirname/../node_modules/.bin/pretty-bytes" +gzip_size="$dirname/../node_modules/.bin/gzip-size" +discify="$dirname/../node_modules/.bin/discify" + usage () { cat << USAGE script/test-size @@ -10,38 +18,51 @@ script/test-size USAGE } +# use zopfli for better compression if available +gzip () { + zopfli -h 2>/dev/null + if [ $? -eq 0 ]; then + zopfli "$1" -i1000 -c | wc -c + else + "$gzip_size" < "$1" + fi +} + gzip_size () { - browserify index.js \ + mkdir -p tmp/ + "$browserify" index.js \ -g unassertify \ -g yo-yoify \ -g es2020 \ -g uglifyify \ -p bundle-collapser/plugin \ - | uglifyjs \ - | gzip-size \ - | pretty-bytes + | "$uglify" \ + > tmp/bundle.min.js + + gzip tmp/bundle.min.js | "$pretty_bytes" + rm -rf tmp/ } min_size () { - browserify index.js \ + "$browserify" index.js \ -g unassertify \ -g yo-yoify \ -g es2020 \ -g uglifyify \ -p bundle-collapser/plugin \ - | uglifyjs \ + | "$uglify" \ | wc -c \ - | pretty-bytes + | "$pretty_bytes" } run_discify () { - browserify index.js --full-paths \ + "$browserify" index.js --full-paths \ -g unassertify \ -g yo-yoify \ -g es2020 \ -g uglifyify \ - | uglifyjs \ - | discify --open + | "$uglify" \ + | "$discify" --open } # set CLI flags From a18324d63ca9d8638cec9eea0d122fa9e7515abd Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Tue, 12 Jul 2016 23:47:18 +0200 Subject: [PATCH 21/27] changelog: 3.1.0 --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60c7349..f6cf156 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## `3.1.0` +And another patch down. This time around it's mostly maintenance and a bit of +perf: +- The addition of the [nanoraf](https://github.com/yoshuawuyts/nanoraf) + dependency prevents bursts of DOM updates thrashing application performance, + quite possibly making choo amongst the fastest frameworks out there. +- We now ship standalone `UMD` bundles on each release, available through + [https://npmcdn.com/choo](https://npmcdn.com/choo). The goal of this is to + support sites like codepen and the like; __this should not be used for + production__. + ## `3.0.0` Woooh, happy third birthday `choo` - _thanks dad_. You're all grown up now; look at how far you've come in the last month. You've grown... tinier? But yet From 89f1daaafba9367fb377abffe009ae44640d7cce Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Wed, 13 Jul 2016 01:15:21 +0200 Subject: [PATCH 22/27] 3.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fcb93ad..207683f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "choo", - "version": "3.0.2", + "version": "3.1.0", "description": "A 5kb framework for creating sturdy frontend applications", "main": "index.js", "scripts": { From f995cac579ea5df4ee9acef4b3780e9215dbebe5 Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Wed, 13 Jul 2016 01:35:53 +0200 Subject: [PATCH 23/27] script/build: add gz variant --- scripts/build | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/scripts/build b/scripts/build index 28c2f80..8853679 100755 --- a/scripts/build +++ b/scripts/build @@ -9,6 +9,16 @@ usage () { printf "Usage: build-umd \n" } +# use zopfli for better compression if available +gzip () { + zopfli -h 2>/dev/null + if [ $? -eq 0 ]; then + zopfli "$1" -i1000 -c + else + gzip -c "$1" + fi +} + build_dev () { mkdir -p dist/ NODE_ENV=development "$browserify" index.js \ @@ -35,6 +45,12 @@ build_min () { > dist/choo.min.js } +build_gz () { + build_min + gzip dist/choo.min.js > dist/choo.min.js.gz + cp dist/choo.min.js.gz dist/choo.gz +} + # parse CLI flags while true; do case "$1" in @@ -47,5 +63,6 @@ done case "$1" in d|dev) shift; build_dev "$@" ;; m|min) shift; build_min "$@" ;; + g|gzip) shift; build_gz "$@" ;; *) shift; build_min "$@" ;; esac From 3cfca5495027c94b7e2889652f886950e5017df1 Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Wed, 13 Jul 2016 02:01:51 +0200 Subject: [PATCH 24/27] deps: fix missing html file --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 207683f..b993934 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,8 @@ "files": [ "index.js", "http.js", - "dist" + "html.js", + "dist/" ], "license": "MIT", "dependencies": { From a1795c29ee9ebc94ec1669b5512e4e90c6e630c1 Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Wed, 13 Jul 2016 02:03:21 +0200 Subject: [PATCH 25/27] 3.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b993934..6299a47 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "choo", - "version": "3.1.0", + "version": "3.1.1", "description": "A 5kb framework for creating sturdy frontend applications", "main": "index.js", "scripts": { From 3434d681a496a362feb4ac3b50da58febba50e01 Mon Sep 17 00:00:00 2001 From: Tim Wisniewski Date: Thu, 14 Jul 2016 06:26:16 -0400 Subject: [PATCH 26/27] Update args in examples/vanilla to 3.0 (#170) --- examples/vanilla/index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/vanilla/index.html b/examples/vanilla/index.html index cd93a66..e98fdef 100644 --- a/examples/vanilla/index.html +++ b/examples/vanilla/index.html @@ -13,13 +13,13 @@ count: 0 }, reducers: { - increment: (action, state) => ({count: state.count + 1}), - decrement: (action, state) => ({count: state.count - 1}) + increment: (data, state) => ({count: state.count + 1}), + decrement: (data, state) => ({count: state.count - 1}) } }) - const mainView = (params, state, send) => { - return choo.view` + const mainView = (state, prev, send) => { + return html`

    Counter example

    From dd88941d774aea03ffc061cb75a93cc5a7d8cbcc Mon Sep 17 00:00:00 2001 From: Lucas Cherkewski Date: Thu, 14 Jul 2016 15:10:08 -0400 Subject: [PATCH 27/27] Use properly formatted assert() statement for send() on server --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 1bd34d4..a047d75 100644 --- a/index.js +++ b/index.js @@ -47,7 +47,7 @@ function choo (opts) { function createSend () { return function send () { - assert.fail('choo: send() cannot be called from Node') + assert.ok(false, 'choo: send() cannot be called from Node') } } }