binhend 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/example_api/routes/test/bb.js +1 -1
  2. package/example_api/routes/test/index.js +1 -1
  3. package/example_api/routes/test/some.js +1 -1
  4. package/example_api/routes/test.js +5 -1
  5. package/example_api/routes/testa.js +1 -1
  6. package/example_webcomp/components/common/InputText.js +11 -1
  7. package/example_webcomp/components/common/Link.js +1 -1
  8. package/example_webcomp/components/common/Link2.js +1 -1
  9. package/example_webcomp/components/index.js +9 -1
  10. package/example_webcomp/components/layouts/AppMainLayout.js +1 -1
  11. package/example_webcomp/components/layouts/AppToDos.js +7 -5
  12. package/example_webcomp/components/layouts/Link.js +16 -0
  13. package/example_webcomp/components/layouts/PageContent.js +1 -1
  14. package/example_webcomp/components/layouts/PageHeader.js +2 -2
  15. package/example_webcomp/components/layouts/ToDoItem.js +3 -2
  16. package/example_webcomp/components/styles/temp.css +4 -1
  17. package/example_webcomp/public/Link3.js +18 -0
  18. package/example_webcomp/public/common/InputText.js +58 -1
  19. package/example_webcomp/public/common/Link.js +2 -1
  20. package/example_webcomp/public/common/Link2.js +1 -1
  21. package/example_webcomp/public/index.js +9 -1
  22. package/example_webcomp/public/layouts/AppMainLayout.js +78 -7
  23. package/example_webcomp/public/layouts/AppToDos.js +124 -6
  24. package/example_webcomp/public/layouts/Link.js +18 -0
  25. package/example_webcomp/public/layouts/PageContent.js +3 -2
  26. package/example_webcomp/public/layouts/PageHeader.js +21 -1
  27. package/example_webcomp/public/layouts/ToDoItem.js +11 -3
  28. package/example_webcomp/public/services/AnyService.js +1 -0
  29. package/example_webcomp/public/services/ServiceToDos.js +1 -0
  30. package/example_webcomp/public/styles/ToDoItemStyle.js +1 -0
  31. package/example_webcomp/public/styles/ToDoItemStyle2.js +1 -0
  32. package/example_webcomp/public/styles/temp.css +4 -1
  33. package/example_webcomp/public/styles/todo.css.js +1 -0
  34. package/package.json +5 -13
  35. package/src/binh.js +20 -207
  36. package/src/binh.server.app.js +70 -0
  37. package/src/binh.server.config.js +79 -0
  38. package/src/binh.web.builder.js +72 -0
  39. package/src/code.js +85 -15
  40. package/src/component.js +2 -2
  41. package/src/cryptography.js +6 -1
  42. package/testa.js +0 -28
@@ -1,4 +1,4 @@
1
- const { get } = binh().Router(module);
1
+ const { get } = binh.router(module);
2
2
 
3
3
  // get('/', function(req, res) {
4
4
  // res.json({ path:'/', dir: __dirname, file: __filename });
@@ -1,4 +1,4 @@
1
- const { router, get, post } = binh().Router(module);
1
+ const { router, get, post } = binh.router(module);
2
2
 
3
3
  get('/', function(req, res) {
4
4
  res.json({ path:'/', dir: __dirname, file: __filename });
@@ -1,4 +1,4 @@
1
- const { router, get, post } = binh().Router(module);
1
+ const { router, get, post } = binh.router(module);
2
2
 
3
3
  get('/', function(req, res) {
4
4
  res.json({ path:'/', dir: __dirname, file: __filename });
@@ -1,4 +1,8 @@
1
- const { get } = binh().Router(module);
1
+ const { get } = binh.router(module);
2
+
3
+ get('/', function(req, res) {
4
+ res.json({ path:'/', dir: __dirname, file: __filename });
5
+ });
2
6
 
3
7
  get('/bb', function(req, res) {
4
8
  res.json({ path:'/bb', dir: __dirname, file: __filename });
@@ -1,4 +1,4 @@
1
- const { router, get, post } = binh().Router(module);
1
+ const { router, get, post } = binh.router(module);
2
2
 
3
3
  get('/', function(req, res) {
4
4
  res.json({ path:'/', dir: __dirname, file: __filename });
@@ -1,10 +1,20 @@
1
1
 
2
+ require('./../services/ServiceToDos').as('Toto');
3
+
2
4
  function main() {
5
+ // var addTodoItem = Toto.debounce('add', 1500, true);
6
+
7
+ // setTimeout(function() {
8
+ // addTodoItem('over 10kms');
9
+ // }, 10000);
10
+
3
11
  var inputbox = input({ type: 'text', placeholder: 'Enter to-do item' });
12
+
13
+ var submit = inputbox.action('submit');
4
14
 
5
15
  inputbox.on('keypress', function (event) {
6
16
  if (event.key === "Enter") {
7
- inputbox.does('submit', inputbox.element.value);
17
+ submit(inputbox.element.value);
8
18
  }
9
19
  });
10
20
 
@@ -1,7 +1,7 @@
1
1
 
2
2
 
3
3
  function Link() {
4
- var { a } = Binh.elements;
4
+ var { a } = Binh.element();
5
5
 
6
6
  var text = arguments[0];
7
7
  var path = arguments[1];
@@ -1,6 +1,6 @@
1
1
 
2
2
  Binh.ui(function() {
3
- var { a } = Binh.elements;
3
+ var { a } = Binh.element('a');
4
4
 
5
5
  var text = arguments[0];
6
6
  var path = arguments[1];
@@ -1,6 +1,14 @@
1
1
 
2
+ Binh.script('https://cdn.jsdelivr.net/gh/jquery/jquery@3.5.1/dist/jquery.min.js', function() {
3
+ Binh.link('https://cdn.jsdelivr.net/npm/bootstrap@3.4.1/dist/css/bootstrap.min.css');
4
+ Binh.script('https://cdn.jsdelivr.net/npm/bootstrap@3.4.1/dist/js/bootstrap.min.js');
5
+ });
6
+
7
+ Binh.Router.onload(function() {
8
+ console.log('#### ON ROUTING !!!');
9
+ });
10
+
2
11
  Binh({
3
12
  '': '/layouts/AppMainLayout.js',
4
13
  '/todos': '/layouts/AppToDos.js'
5
14
  });
6
-
@@ -19,4 +19,4 @@ function AppMainLayout() {
19
19
  return MainLayout;
20
20
  }
21
21
 
22
- binh.ui(module, AppMainLayout, ['div'], ['https://code.jquery.com/jquery-3.7.0.min.js']);
22
+ binh.ui(module, AppMainLayout, ['div'], ['https://code.jquery.com/jquery-3.7.0.min.js', 'https://code.jquery.com/jquery-3.7.0.min.js']);
@@ -1,13 +1,15 @@
1
1
 
2
- // require('./PageHeader');
2
+ require('./PageHeader');
3
3
  // require('./ToDoItem');
4
4
  require('./../common/InputText');
5
- require('./../services/ServiceToDos');
5
+ require('./Link');
6
+ require('./../services/ServiceToDos').as('Dodo');
6
7
 
7
8
 
8
9
  function main() {
9
- var PageHeader = this.ui('/layouts/PageHeader.js');
10
- var ToDoItem = this.ui('/layouts/ToDoItem.js');
10
+ var ServiceToDos = Dodo;
11
+ // var PageHeader = Binh.ui('/layouts/PageHeader.js');
12
+ var ToDoItem = Binh.ui('/layouts/ToDoItem.js');
11
13
  // var addTodoItem = ServiceToDos.does('add');
12
14
  // var addTodoItem = ServiceToDos.debounce('add', 1500); // trailing only
13
15
  var addTodoItem = ServiceToDos.debounce('add', 1500, true); // both leading & trailing
@@ -44,4 +46,4 @@ function main() {
44
46
  return maindiv;
45
47
  }
46
48
 
47
- binh.ui(module, main, ['div', 'span']);
49
+ binh.ui(module, main, ['div', 'span'], ['https://code.jquery.com/jquery-3.7.0.min.js']);
@@ -0,0 +1,16 @@
1
+
2
+
3
+ function Link() {
4
+ var { a } = Binh.element('a');
5
+
6
+ var text = arguments[0];
7
+ var path = arguments[1];
8
+
9
+ var link = a(text).on('click', function() {
10
+ Binh.Router.navigate(path);
11
+ });
12
+
13
+ return link;
14
+ }
15
+
16
+ binh.ui(module, Link);
@@ -22,4 +22,4 @@ function PageContent() {
22
22
  return PageContent;
23
23
  }
24
24
 
25
- binh.ui(module, PageContent, ['div', 'trans']);
25
+ binh.ui(module, PageContent, ['div', 'trans'], ['https://code.jquery.com/jquery-3.7.0.min.js']);
@@ -1,8 +1,8 @@
1
1
 
2
- // var { Link } = require('./../common/Link');
2
+ var { Link } = require('./../common/Link');
3
3
 
4
4
  function PageHeader() {
5
- var Link = this.ui('/common/Link2.js');
5
+ // var Link = Binh.ui('/common/Link2.js');
6
6
 
7
7
  var PageHeader = div({ id: 'page-header' });
8
8
 
@@ -4,14 +4,15 @@ require('./../styles/ToDoItemStyle2');
4
4
  // require('../styles/todo.css.js');
5
5
 
6
6
  function main(props) {
7
- // var ToDoItemStyle = this.style('/styles/todo.css');
7
+ // var ToDoItemStyle = Binh.style('/styles/todo.css');
8
8
 
9
9
  var todoitem = div({ style: 'margin: 3px;' });
10
+ var removeToDoItem = todoitem.action('remove');
10
11
 
11
12
  var remove_button = span({ class: 'btn-remove' })('X');
12
13
 
13
14
  remove_button.on('click', function() {
14
- todoitem.does('remove', props.id);
15
+ removeToDoItem(props.id);
15
16
  });
16
17
 
17
18
  todoitem(span(props.text), span('-------'), remove_button);
@@ -1,4 +1,7 @@
1
+
2
+ @import url("/styles/todo.css");
3
+
1
4
  .btn-remove {
2
5
  color: purple;
3
6
  margin-left: '15px';
4
- }
7
+ }
@@ -0,0 +1,18 @@
1
+ !function(){
2
+
3
+
4
+ Binh.ui(function Link() {
5
+ var { a } = Binh.element();
6
+
7
+ var text = arguments[0];
8
+ var path = arguments[1];
9
+
10
+ var link = a(text).on('click', function() {
11
+ Binh.Router.navigate(path);
12
+ });
13
+
14
+ return link;
15
+ });
16
+
17
+
18
+ }();
@@ -1,11 +1,68 @@
1
1
  !function(){
2
2
 
3
+ !function(){
4
+
5
+ Toto = Binh.service('/services/ServiceToDos.js', function(define, state, http) {
6
+ var todos = state.as('todos');
7
+
8
+ todos.schema(function(resolve) {
9
+ new http(api('get'))
10
+ .get(function(response) {
11
+ resolve(parseResponse(response));
12
+ });
13
+ });
14
+
15
+ function handleResponse(response) {
16
+ todos.set(parseResponse(response));
17
+ }
18
+
19
+ function parseResponse(response) {
20
+ var todoitems = [];
21
+
22
+ Object.keys(response).forEach(function(key) {
23
+ var each = response[key];
24
+ todoitems.push({ id: key, text: each.text });
25
+ });
26
+
27
+ return todoitems;
28
+ }
29
+
30
+ define('add', function(value) {
31
+ new http(api('add'))
32
+ .body({ text: value })
33
+ .post(handleResponse);
34
+ });
35
+
36
+ define('remove', function(id) {
37
+ new http(api('remove'))
38
+ .body({ id: id })
39
+ .post(handleResponse);
40
+ });
41
+
42
+ function api(relative_url) {
43
+ return 'https://todolist-of-binh.fly.dev/todos/' + relative_url;
44
+ }
45
+ });
46
+
47
+
48
+ }();
49
+
50
+ var Toto;
51
+
3
52
  Binh.ui(function main() {
53
+ // var addTodoItem = Toto.debounce('add', 1500, true);
54
+
55
+ // setTimeout(function() {
56
+ // addTodoItem('over 10kms');
57
+ // }, 10000);
58
+
4
59
  var inputbox = input({ type: 'text', placeholder: 'Enter to-do item' });
60
+
61
+ var submit = inputbox.action('submit');
5
62
 
6
63
  inputbox.on('keypress', function (event) {
7
64
  if (event.key === "Enter") {
8
- inputbox.does('submit', inputbox.element.value);
65
+ submit(inputbox.element.value);
9
66
  }
10
67
  });
11
68
 
@@ -1,7 +1,8 @@
1
1
  !function(){
2
2
 
3
+
3
4
  Binh.ui(function Link() {
4
- var { a } = Binh.elements;
5
+ var { a } = Binh.element();
5
6
 
6
7
  var text = arguments[0];
7
8
  var path = arguments[1];
@@ -1,6 +1,6 @@
1
1
 
2
2
  Binh.ui(function() {
3
- var { a } = Binh.elements;
3
+ var { a } = Binh.element('a');
4
4
 
5
5
  var text = arguments[0];
6
6
  var path = arguments[1];
@@ -1,6 +1,14 @@
1
1
 
2
+ Binh.script('https://cdn.jsdelivr.net/gh/jquery/jquery@3.5.1/dist/jquery.min.js', function() {
3
+ Binh.link('https://cdn.jsdelivr.net/npm/bootstrap@3.4.1/dist/css/bootstrap.min.css');
4
+ Binh.script('https://cdn.jsdelivr.net/npm/bootstrap@3.4.1/dist/js/bootstrap.min.js');
5
+ });
6
+
7
+ Binh.Router.onload(function() {
8
+ console.log('#### ON ROUTING !!!');
9
+ });
10
+
2
11
  Binh({
3
12
  '': '/layouts/AppMainLayout.js',
4
13
  '/todos': '/layouts/AppToDos.js'
5
14
  });
6
-
@@ -1,7 +1,9 @@
1
- Binh.requires(['https://code.jquery.com/jquery-3.7.0.min.js'], function() {
1
+ Binh.prequire(['https://code.jquery.com/jquery-3.7.0.min.js'], function() {
2
2
 
3
- var PageHeader = Binh.ui('/layouts/PageHeader.js', function PageHeader() {
4
- var Link = this.ui('/common/Link2.js');
3
+ !function(){
4
+
5
+ PageHeader = Binh.ui('/layouts/PageHeader.js', function PageHeader() {
6
+ // var Link = Binh.ui('/common/Link2.js');
5
7
 
6
8
  var PageHeader = div({ id: 'page-header' });
7
9
 
@@ -43,7 +45,31 @@ var PageHeader = Binh.ui('/layouts/PageHeader.js', function PageHeader() {
43
45
  return PageHeader;
44
46
  });
45
47
 
46
- var PageContent = Binh.ui('/layouts/PageContent.js', function PageContent() {
48
+ !function(){
49
+
50
+ Link = Binh.ui('/common/Link.js', function Link() {
51
+ var { a } = Binh.element();
52
+
53
+ var text = arguments[0];
54
+ var path = arguments[1];
55
+
56
+ var link = a(text).on('click', function() {
57
+ Binh.Router.navigate(path);
58
+ });
59
+
60
+ return link;
61
+ });
62
+
63
+
64
+ }();
65
+
66
+ var Link;
67
+
68
+ }();
69
+
70
+ !function(){
71
+
72
+ PageContent = Binh.ui('/layouts/PageContent.js', function PageContent() {
47
73
  var { Router } = Binh;
48
74
 
49
75
  var PageContent = div({ id: 'page-content' });
@@ -66,10 +92,53 @@ var PageContent = Binh.ui('/layouts/PageContent.js', function PageContent() {
66
92
  return PageContent;
67
93
  });
68
94
 
69
- var AnyService = Binh.service('/services/AnyService.js', function AnyService() {
70
95
 
96
+ }();
97
+
98
+ !function(){
99
+
100
+ AnyService = Binh.service('/services/AnyService.js', function AnyService() {
101
+
102
+ });
103
+
104
+
105
+ }();
106
+
107
+ !function(){
108
+
109
+ Button = Binh.ui('npm://binhjsx/node/ui/button/Button.js', function main() {
110
+ var abutton = button();
111
+ var trigger = abutton.action('trigger');
112
+
113
+ abutton.on('click', trigger);
114
+ abutton.on('touchend', trigger);
115
+
116
+ return abutton;
71
117
  });
72
118
 
119
+
120
+ }();
121
+
122
+ !function(){
123
+
124
+ Link3 = Binh.ui('', function Link() {
125
+ var { a } = Binh.element();
126
+
127
+ var text = arguments[0];
128
+ var path = arguments[1];
129
+
130
+ var link = a(text).on('click', function() {
131
+ Binh.Router.navigate(path);
132
+ });
133
+
134
+ return link;
135
+ });
136
+
137
+
138
+ }();
139
+
140
+ var PageHeader, PageContent, AnyService, Button, Link3;
141
+
73
142
  Binh.ui(function AppMainLayout() {
74
143
  var MainLayout = div({ id: 'app-main-layout' });
75
144
 
@@ -80,7 +149,8 @@ Binh.ui(function AppMainLayout() {
80
149
  setTimeout(function() {
81
150
  console.log('>>> App Main Layout:', thisEl);
82
151
  }, 1000);
83
- }
152
+ },
153
+ Button()('test this button')
84
154
  );
85
155
 
86
156
  return MainLayout;
@@ -91,6 +161,7 @@ nav = Binh.el('nav'),
91
161
  ul = Binh.el('ul'),
92
162
  li = Binh.el('li'),
93
163
  a = Binh.el('a'),
94
- trans = Binh.el('trans');
164
+ trans = Binh.el('trans'),
165
+ button = Binh.el('button');
95
166
 
96
167
  });
@@ -1,18 +1,126 @@
1
+ Binh.prequire(['https://code.jquery.com/jquery-3.7.0.min.js'], function() {
2
+
3
+ !function(){
4
+
5
+ PageHeader = Binh.ui('/layouts/PageHeader.js', function PageHeader() {
6
+ // var Link = Binh.ui('/common/Link2.js');
7
+
8
+ var PageHeader = div({ id: 'page-header' });
9
+
10
+ PageHeader(
11
+ div({ class: 'container' })(
12
+ div({ class: 'row' })(
13
+ nav({ class: 'navbar navbar-default' })(
14
+ div({ class: 'container-fluid' })([
15
+ div({ class: 'navbar-header' })(
16
+ a({ class: 'navbar-brand', href: '#' })(
17
+ 'Website Name'
18
+ )
19
+ ),
20
+ ul({ class: 'nav navbar-nav' })(
21
+ li({ class: 'active' })(
22
+ Link('Home', '/')
23
+ ),
24
+ li(
25
+ Link('Abc', '/abc')
26
+ ),
27
+ li(
28
+ Link('Haha', '/haha')
29
+ ),
30
+ li(
31
+ a('Page 3')
32
+ )
33
+ )
34
+ ])
35
+ )
36
+ )
37
+ ),
38
+ function (thisEl) {
39
+ setTimeout(function() {
40
+ console.log('>>> Page Header:', thisEl);
41
+ }, 1000);
42
+ }
43
+ );
44
+
45
+ return PageHeader;
46
+ });
47
+
1
48
  !function(){
2
49
 
3
- var InputText = Binh.ui('/common/InputText.js', function main() {
50
+ Link = Binh.ui('/common/Link.js', function Link() {
51
+ var { a } = Binh.element();
52
+
53
+ var text = arguments[0];
54
+ var path = arguments[1];
55
+
56
+ var link = a(text).on('click', function() {
57
+ Binh.Router.navigate(path);
58
+ });
59
+
60
+ return link;
61
+ });
62
+
63
+
64
+ }();
65
+
66
+ var Link;
67
+
68
+ }();
69
+
70
+ !function(){
71
+
72
+ InputText = Binh.ui('/common/InputText.js', function main() {
73
+ // var addTodoItem = Toto.debounce('add', 1500, true);
74
+
75
+ // setTimeout(function() {
76
+ // addTodoItem('over 10kms');
77
+ // }, 10000);
78
+
4
79
  var inputbox = input({ type: 'text', placeholder: 'Enter to-do item' });
80
+
81
+ var submit = inputbox.action('submit');
5
82
 
6
83
  inputbox.on('keypress', function (event) {
7
84
  if (event.key === "Enter") {
8
- inputbox.does('submit', inputbox.element.value);
85
+ submit(inputbox.element.value);
9
86
  }
10
87
  });
11
88
 
12
89
  return inputbox;
13
90
  });
14
91
 
15
- var ServiceToDos = Binh.service('/services/ServiceToDos.js', function(define, state, http) {
92
+ !function(){
93
+
94
+ Toto = Binh.service('/services/ServiceToDos.js');
95
+
96
+
97
+ }();
98
+
99
+ var Toto;
100
+
101
+ }();
102
+
103
+ !function(){
104
+
105
+ Link = Binh.ui('/layouts/Link.js', function Link() {
106
+ var { a } = Binh.element('a');
107
+
108
+ var text = arguments[0];
109
+ var path = arguments[1];
110
+
111
+ var link = a(text).on('click', function() {
112
+ Binh.Router.navigate(path);
113
+ });
114
+
115
+ return link;
116
+ });
117
+
118
+
119
+ }();
120
+
121
+ !function(){
122
+
123
+ Dodo = Binh.service('/services/ServiceToDos.js', function(define, state, http) {
16
124
  var todos = state.as('todos');
17
125
 
18
126
  todos.schema(function(resolve) {
@@ -54,9 +162,15 @@ var ServiceToDos = Binh.service('/services/ServiceToDos.js', function(define, st
54
162
  }
55
163
  });
56
164
 
165
+
166
+ }();
167
+
168
+ var PageHeader, InputText, Link, Dodo;
169
+
57
170
  Binh.ui(function main() {
58
- var PageHeader = this.ui('/layouts/PageHeader.js');
59
- var ToDoItem = this.ui('/layouts/ToDoItem.js');
171
+ var ServiceToDos = Dodo;
172
+ // var PageHeader = Binh.ui('/layouts/PageHeader.js');
173
+ var ToDoItem = Binh.ui('/layouts/ToDoItem.js');
60
174
  // var addTodoItem = ServiceToDos.does('add');
61
175
  // var addTodoItem = ServiceToDos.debounce('add', 1500); // trailing only
62
176
  var addTodoItem = ServiceToDos.debounce('add', 1500, true); // both leading & trailing
@@ -95,6 +209,10 @@ Binh.ui(function main() {
95
209
 
96
210
  var div = Binh.el('div'),
97
211
  span = Binh.el('span'),
212
+ nav = Binh.el('nav'),
213
+ ul = Binh.el('ul'),
214
+ li = Binh.el('li'),
215
+ a = Binh.el('a'),
98
216
  input = Binh.el('input');
99
217
 
100
- }();
218
+ });
@@ -0,0 +1,18 @@
1
+ !function(){
2
+
3
+
4
+ Binh.ui(function Link() {
5
+ var { a } = Binh.element('a');
6
+
7
+ var text = arguments[0];
8
+ var path = arguments[1];
9
+
10
+ var link = a(text).on('click', function() {
11
+ Binh.Router.navigate(path);
12
+ });
13
+
14
+ return link;
15
+ });
16
+
17
+
18
+ }();
@@ -1,4 +1,5 @@
1
- !function(){
1
+ Binh.prequire(['https://code.jquery.com/jquery-3.7.0.min.js'], function() {
2
+
2
3
 
3
4
  Binh.ui(function PageContent() {
4
5
  var { Router } = Binh;
@@ -26,4 +27,4 @@ Binh.ui(function PageContent() {
26
27
  var div = Binh.el('div'),
27
28
  trans = Binh.el('trans');
28
29
 
29
- }();
30
+ });
@@ -1,7 +1,27 @@
1
1
  !function(){
2
2
 
3
+ !function(){
4
+
5
+ Link = Binh.ui('/common/Link.js', function Link() {
6
+ var { a } = Binh.element();
7
+
8
+ var text = arguments[0];
9
+ var path = arguments[1];
10
+
11
+ var link = a(text).on('click', function() {
12
+ Binh.Router.navigate(path);
13
+ });
14
+
15
+ return link;
16
+ });
17
+
18
+
19
+ }();
20
+
21
+ var Link;
22
+
3
23
  Binh.ui(function PageHeader() {
4
- var Link = this.ui('/common/Link2.js');
24
+ // var Link = Binh.ui('/common/Link2.js');
5
25
 
6
26
  var PageHeader = div({ id: 'page-header' });
7
27