Skip to content

Commit a94dd37

Browse files
committed
init
0 parents  commit a94dd37

16 files changed

+291
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
jspm_packages
2+
node_modules
3+
*.log

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# bitbox-component

app.box

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import bitbox from 'bitbox'
2+
import component from 'component/view.box'
3+
4+
export default bitbox(app => {
5+
<app return new>
6+
<h1 new>`app`</h1>
7+
<component:demo />
8+
</app>
9+
})

app.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import bitbox from 'bitbox'
2+
import component from 'component'
3+
4+
const app = bitbox.app({})
5+
6+
app.addModules({
7+
demo: component()
8+
})
9+
10+
export default app;

dist/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# bitbox-component

dist/index.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
(function (global, factory) {
2+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3+
typeof define === 'function' && define.amd ? define(factory) :
4+
(global.demoModule = factory());
5+
}(this, function () { 'use strict';
6+
7+
var index = (function () {
8+
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
9+
10+
return function (mod) {
11+
12+
mod.addState({
13+
message: 'Hello World'
14+
});
15+
16+
mod.addSignals({
17+
message: [function action(_ref) {
18+
var state = _ref.state;
19+
var input = _ref.input;
20+
21+
state.select(mod.path).set('message', input.value);
22+
}]
23+
});
24+
25+
return {
26+
title: 'Demo Component'
27+
};
28+
};
29+
})
30+
31+
return index;
32+
33+
}));

dist/package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "bitbox-component",
3+
"version": "1.0.0",
4+
"description": "bitbox component demo",
5+
"keywords": [
6+
"bitbox",
7+
"bitbox component",
8+
"bitbox demo"
9+
],
10+
"main": "index.js",
11+
"registry": "npm",
12+
"jspmPackage": true,
13+
"format": "amd",
14+
"author": "Sergiu Toderascu <sergiu.toderascu@gmail.com> (http://bitboxjs.com)",
15+
"license": "ISC",
16+
"repository": {
17+
"type": "git",
18+
"url": "https://github.com/bitboxjs/bitbox-component"
19+
},
20+
"homepage": "http://bitboxjs.com"
21+
}

dist/view.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
(function (global, factory) {
2+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('bitbox'), require('bitbox/elements')) :
3+
typeof define === 'function' && define.amd ? define(['bitbox', 'bitbox/elements'], factory) :
4+
(global.demoView = factory(global.bitbox,global.bitbox_elements));
5+
}(this, function (bitbox,bitbox_elements) { 'use strict';
6+
7+
bitbox = 'default' in bitbox ? bitbox['default'] : bitbox;
8+
9+
var view = bitbox(function (_ref) {
10+
var state = _ref.state;
11+
var signals = _ref.signals;
12+
13+
var onInput = function onInput(e) {
14+
return signals.message({
15+
value: e.target.value
16+
});
17+
};
18+
return bitbox.h('demo', {}, function ($tree) {
19+
$tree.push(bitbox_elements.h1({}, state.message));
20+
$tree.push(bitbox_elements.input({
21+
value: state.message,
22+
on: {
23+
input: onInput
24+
}
25+
}));
26+
return $tree;
27+
}([]));
28+
});
29+
30+
return view;
31+
32+
}));

index.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!doctype html>
2+
<meta charset="utf-8">
3+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
4+
<meta name="mobile-web-app-capable" content="yes">
5+
<script src="jspm_packages/system.js"></script>
6+
<script src="jspm.browser.js"></script>
7+
<script src="jspm.config.js"></script>
8+
<body>
9+
<script>
10+
var readyForMainLoad
11+
System.trace = true
12+
readyForMainLoad = System.import('systemjs-hot-reloader').then(function(HR){
13+
hr = new HR.default() // chokidar-socket-emitter port
14+
})
15+
Promise.resolve(readyForMainLoad).then(() => {
16+
System.import('index.js').then(function (m) {
17+
console.log('@ready', m);
18+
})
19+
})
20+
</script>
21+
</body>

index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import bitbox from 'bitbox'
2+
import app from './app.js'
3+
import box from './app.box'
4+
5+
/** hot reload hook */
6+
export const __reload = app.reload
7+
8+
app.run(box, document.body)

jspm.browser.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
SystemJS.config({
2+
baseURL: "/",
3+
paths: {
4+
"github:*": "jspm_packages/github/*",
5+
"npm:*": "jspm_packages/npm/*",
6+
"bitbox-component/": "src/"
7+
}
8+
});

jspm.config.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
SystemJS.config({
2+
transpiler: "plugin-babel",
3+
packages: {
4+
"bitbox-component": {
5+
"main": "index.js",
6+
"meta": {
7+
"*.js": {
8+
"loader": "plugin-babel"
9+
}
10+
}
11+
}
12+
},
13+
meta: {
14+
"*.box": {
15+
"loader": "bitbox-transpiler"
16+
}
17+
}
18+
});
19+
20+
SystemJS.config({
21+
packageConfigPaths: [
22+
"npm:@*/*.json",
23+
"npm:*.json",
24+
"github:*/*.json"
25+
],
26+
map: {
27+
"bitbox": "npm:bitbox@1.0.29",
28+
"bitbox-transpiler": "npm:bitbox-transpiler@1.0.2",
29+
"fs": "github:jspm/nodelibs-fs@0.2.0-alpha",
30+
"net": "github:jspm/nodelibs-net@0.2.0-alpha",
31+
"plugin-babel": "npm:systemjs-plugin-babel@0.0.9",
32+
"process": "github:jspm/nodelibs-process@0.2.0-alpha",
33+
"systemjs-hot-reloader": "github:capaj/systemjs-hot-reloader@0.5.7",
34+
"tty": "github:jspm/nodelibs-tty@0.2.0-alpha",
35+
"util": "github:jspm/nodelibs-util@0.2.0-alpha"
36+
},
37+
packages: {
38+
"github:capaj/systemjs-hot-reloader@0.5.7": {
39+
"map": {
40+
"debug": "npm:debug@2.2.0",
41+
"socket.io-client": "github:socketio/socket.io-client@1.4.5",
42+
"weakee": "npm:weakee@1.0.0"
43+
}
44+
},
45+
"npm:debug@2.2.0": {
46+
"map": {
47+
"ms": "npm:ms@0.7.1"
48+
}
49+
}
50+
}
51+
});

package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"jspm": {
3+
"name": "bitbox-component",
4+
"main": "index.js",
5+
"directories": {
6+
"lib": "src"
7+
},
8+
"dependencies": {
9+
"bitbox": "npm:bitbox@^1.0.29"
10+
},
11+
"devDependencies": {
12+
"bitbox-transpiler": "npm:bitbox-transpiler@^1.0.2",
13+
"fs": "github:jspm/nodelibs-fs@^0.2.0-alpha",
14+
"net": "github:jspm/nodelibs-net@^0.2.0-alpha",
15+
"plugin-babel": "npm:systemjs-plugin-babel@^0.0.9",
16+
"process": "github:jspm/nodelibs-process@^0.2.0-alpha",
17+
"systemjs-hot-reloader": "github:capaj/systemjs-hot-reloader@^0.5.7",
18+
"tty": "github:jspm/nodelibs-tty@^0.2.0-alpha",
19+
"util": "github:jspm/nodelibs-util@^0.2.0-alpha"
20+
}
21+
},
22+
"devDependencies": {
23+
"chokidar-socket-emitter": "^0.5.1",
24+
"http-server": "^0.9.0",
25+
"jspm": "^0.17.0-beta.13"
26+
},
27+
"scripts": {
28+
"build:module": "jspm build bitbox-component dist/index.js --format umd --global-name demoModule --skip-source-maps",
29+
"build:view": "jspm build bitbox-component/view.box - bitbox - bitbox/elements dist/view.js --format umd --global-name demoView --global-deps \"{'bitbox':'bitbox', 'bitbox/elements':'bitbox_elements'}\" --skip-source-maps",
30+
"build": "npm run build:module && npm run build:view",
31+
"dist": "cp README.md ./dist && npm run build && npm publish ./dist"
32+
}
33+
}

server.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict'
2+
const httpServer = require('http-server')
3+
4+
const port = 3003
5+
6+
let cache = 3600
7+
if (process.env.NODE_ENV === 'production') {
8+
console.log('running in production mode(with caching)-make sure you have "Disable cache (while DevTools is open)" checked in the browser to see the changes while developing')
9+
} else {
10+
cache = -1
11+
}
12+
13+
const server = httpServer.createServer({
14+
root: '.',
15+
cache: cache,
16+
robots: true,
17+
headers: {
18+
'Access-Control-Allow-Origin': '*',
19+
'Access-Control-Allow-Credentials': 'true'
20+
}
21+
})
22+
23+
require('chokidar-socket-emitter')({
24+
app: server.server
25+
})
26+
27+
server.listen(port, () => console.log(`listening on *:${port}`))

src/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export default (options = {}) => {
2+
return (mod) => {
3+
4+
mod.addState({
5+
message: 'Hello World'
6+
})
7+
8+
mod.addSignals({
9+
message: [
10+
function action({ state, input }) {
11+
state.select(mod.path).set('message', input.value)
12+
}
13+
]
14+
})
15+
16+
return {
17+
title: 'Demo Component'
18+
}
19+
}
20+
}

src/view.box

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import bitbox from 'bitbox'
2+
import {div,h1,input} from 'bitbox/elements'
3+
4+
export default bitbox(({ state, signals }) => {
5+
6+
const onInput = (e) => signals.message({ value: e.target.value })
7+
8+
<demo return new>
9+
<h1>state.message</h1>
10+
<input on-input value=state.message />
11+
</demo>
12+
13+
})

0 commit comments

Comments
 (0)