peryl 1.5.21 → 1.5.22

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 (47) hide show
  1. package/demo/hsml-appel_demo.html +1 -1
  2. package/demo/hsml-appel_demo.ts +14 -10
  3. package/dist/browser-esmodule/hsml-app.js +24 -25
  4. package/dist/browser-esmodule/hsml-app.js.map +1 -1
  5. package/dist/browser-esmodule/index.js +24 -25
  6. package/dist/browser-esmodule/index.js.map +1 -1
  7. package/dist/browser-umd/hsml-app.js +1 -1
  8. package/dist/browser-umd/hsml-app.js.map +1 -1
  9. package/dist/browser-umd/index.js +1 -1
  10. package/dist/browser-umd/index.js.map +1 -1
  11. package/dist/demo/hsml-app-bysquare_demo.html +1 -1
  12. package/dist/demo/hsml-app-form-validation_demo.html +1 -1
  13. package/dist/demo/hsml-app-form_demo.html +1 -1
  14. package/dist/demo/hsml-app-test_demo.html +1 -1
  15. package/dist/demo/hsml-app-tictactoe_demo.html +1 -1
  16. package/dist/demo/hsml-app_demo.html +1 -1
  17. package/dist/demo/hsml-appel_demo.39c5c95a.js +2 -0
  18. package/dist/demo/hsml-appel_demo.39c5c95a.js.map +1 -0
  19. package/dist/demo/hsml-appel_demo.fd0c6348.js +2 -0
  20. package/dist/demo/hsml-appel_demo.fd0c6348.js.map +1 -0
  21. package/dist/demo/hsml-appel_demo.html +1 -1
  22. package/dist/demo/hsml-appi_demo.26745db2.js +2 -0
  23. package/dist/demo/hsml-appi_demo.26745db2.js.map +1 -0
  24. package/dist/demo/hsml-appi_demo.eab18b83.js +2 -0
  25. package/dist/demo/hsml-appi_demo.eab18b83.js.map +1 -0
  26. package/dist/demo/hsml-appi_demo.html +1 -1
  27. package/dist/hsml-app.d.ts +8 -8
  28. package/dist/hsml-app.js +22 -17
  29. package/dist/hsml-app.js.map +1 -1
  30. package/package.json +1 -1
  31. package/src/hsml-app.ts +51 -29
  32. package/dist/browser-esmodule/google-analytics.js +0 -50
  33. package/dist/browser-esmodule/google-analytics.js.map +0 -1
  34. package/dist/browser-umd/google-analytics.js +0 -2
  35. package/dist/browser-umd/google-analytics.js.map +0 -1
  36. package/dist/demo/hsml-appel_demo.1da052b6.js +0 -2
  37. package/dist/demo/hsml-appel_demo.1da052b6.js.map +0 -1
  38. package/dist/demo/hsml-appel_demo.7fcc74a6.js +0 -2
  39. package/dist/demo/hsml-appel_demo.7fcc74a6.js.map +0 -1
  40. package/dist/demo/hsml-appi_demo.3d3d0e4e.js +0 -2
  41. package/dist/demo/hsml-appi_demo.3d3d0e4e.js.map +0 -1
  42. package/dist/demo/hsml-appi_demo.eac28520.js +0 -2
  43. package/dist/demo/hsml-appi_demo.eac28520.js.map +0 -1
  44. package/dist/google-analytics.d.ts +0 -21
  45. package/dist/google-analytics.js +0 -63
  46. package/dist/google-analytics.js.map +0 -1
  47. package/src/google-analytics.ts +0 -79
@@ -9,7 +9,7 @@
9
9
  <body>
10
10
  <h1>PeRyL hsml app demo</h1>
11
11
 
12
- <happ-app></happ-app>
12
+ <happ-app count="11"></happ-app>
13
13
 
14
14
  <script type="module" src="hsml-appel_demo.ts"></script>
15
15
  <script type="module">
@@ -1,5 +1,4 @@
1
- import { HElements } from "../src/hsml";
2
- import { HAction, HAppActions, happel, HDispatch, HDispatcher, HDispatchScopes, HState, HView } from "../src/hsml-app";
1
+ import { HAction, HAppActions, happel, HDispatcher, HDispatchScopes, HState, HView } from "../src/hsml-app";
3
2
 
4
3
  interface CounterState {
5
4
  count: number;
@@ -30,7 +29,7 @@ const counterView: HView<CounterState, CounterActions> = function (state) {
30
29
  };
31
30
 
32
31
  const counterDispatcher: HDispatcher<CounterState, CounterActions> = async function (action, state, dispatch) {
33
- console.log("action counter:", action);
32
+ // console.log("action counter:", action);
34
33
  // console.log("state counter:", state);
35
34
  // console.log("happ counter:", this);
36
35
 
@@ -63,8 +62,8 @@ happel<CounterState, CounterActions>({
63
62
  state: counterState,
64
63
  view: counterView,
65
64
  dispatcher: counterDispatcher,
66
- name: "counter",
67
- attributes: ["count"],
65
+ id: "happ-counter",
66
+ // attributes: ["count"],
68
67
  debug: true
69
68
  });
70
69
 
@@ -79,7 +78,7 @@ enum AppActions {
79
78
 
80
79
  const appState: HState<AppState> = function () {
81
80
  return {
82
- count: 0
81
+ count: 33
83
82
  }
84
83
  };
85
84
 
@@ -87,18 +86,23 @@ const appView: HView<AppState, AppActions> = function (state) {
87
86
  return [
88
87
  ["h2", ["App count: ", state.count]],
89
88
  ["happ-counter", {
90
- count: 33,
89
+ count: state.count,
91
90
  on: [HAppActions.action, AppActions.action]
92
91
  }]
93
92
  ];
94
93
  };
95
94
 
96
95
  const appDispatcher: HDispatcher<AppState, AppActions | CounterActions> = async function (action, state, dispatch) {
97
- console.log("action:", action);
96
+ // console.log("action:", action);
98
97
  // console.log("state:", state);
99
98
  // console.log("happ:", this);
100
99
 
101
100
  switch (action.type) {
101
+ case HAppActions.attribute:
102
+ if (action.data.attrName === "count") {
103
+ state.count = Number(action.data.newVal);
104
+ }
105
+ break;
102
106
  case AppActions.action:
103
107
  const a = action.data as HAction<AppActions | CounterActions>;
104
108
  switch (a.type) {
@@ -118,7 +122,7 @@ happel<AppState, AppActions | CounterActions>({
118
122
  state: appState,
119
123
  view: appView,
120
124
  dispatcher: appDispatcher,
121
- name: "app",
122
- attributes: [],
125
+ id: "happ-app",
126
+ // attributes: [],
123
127
  debug: true
124
128
  });
@@ -998,16 +998,18 @@ const $9adf8bc2f1ba310f$var$msgRender = "render:";
998
998
  const $9adf8bc2f1ba310f$var$msgUpdate = "update:";
999
999
  const $9adf8bc2f1ba310f$var$HAPP = "happ";
1000
1000
  function $9adf8bc2f1ba310f$export$eb8950696418f795(hAppI) {
1001
- return new $9adf8bc2f1ba310f$export$8cfef5dc37c46888(hAppI.state, hAppI.view, hAppI.dispatcher, hAppI.element, hAppI.debug, hAppI.name);
1001
+ return new $9adf8bc2f1ba310f$export$8cfef5dc37c46888(hAppI.state, hAppI.view, hAppI.dispatcher, hAppI.element, hAppI.debug, hAppI.id);
1002
1002
  }
1003
1003
  function $9adf8bc2f1ba310f$export$1cfc54b3834d3c50(hAppI) {
1004
- customElements.define(`${$9adf8bc2f1ba310f$var$HAPP}-${hAppI.name}`, class HAppElement extends HTMLElement {
1004
+ customElements.define(hAppI.id, class HAppElement extends HTMLElement {
1005
1005
  static get observedAttributes() {
1006
- return hAppI.attributes;
1006
+ var _a;
1007
+ const state = hAppI.state();
1008
+ return ((_a = hAppI.attributes) !== null && _a !== void 0 ? _a : typeof state === "object") ? Object.keys(state) : [];
1007
1009
  }
1008
1010
  constructor(){
1009
1011
  super();
1010
- this._happel = new $9adf8bc2f1ba310f$export$8cfef5dc37c46888(hAppI.state, hAppI.view, hAppI.dispatcher, undefined, hAppI.debug, hAppI.name, hAppI.attributes);
1012
+ this._happel = new $9adf8bc2f1ba310f$export$8cfef5dc37c46888(hAppI.state, hAppI.view, hAppI.dispatcher, undefined, hAppI.debug, hAppI.id);
1011
1013
  this._happel.customElement = this;
1012
1014
  }
1013
1015
  connectedCallback() {
@@ -1032,7 +1034,7 @@ function $9adf8bc2f1ba310f$export$1cfc54b3834d3c50(hAppI) {
1032
1034
  });
1033
1035
  }
1034
1036
  class $9adf8bc2f1ba310f$export$8cfef5dc37c46888 {
1035
- constructor(state, view, dispatcher, element, debug, name, attributes){
1037
+ constructor(state, view, dispatcher, element, debug, id){
1036
1038
  this.refs = {};
1037
1039
  this.dispatch = (type, data, scope)=>$9adf8bc2f1ba310f$var$__awaiter(this, void 0, void 0, function*() {
1038
1040
  return this._dispatchAction(type, data, undefined, scope);
@@ -1044,17 +1046,17 @@ class $9adf8bc2f1ba310f$export$8cfef5dc37c46888 {
1044
1046
  try {
1045
1047
  hsmls = this.view(this.state);
1046
1048
  } catch (e) {
1047
- $9adf8bc2f1ba310f$export$8cfef5dc37c46888.error(this.name, $9adf8bc2f1ba310f$var$msgRender, e);
1049
+ $9adf8bc2f1ba310f$export$8cfef5dc37c46888.error(this.id, $9adf8bc2f1ba310f$var$msgRender, e);
1048
1050
  }
1049
1051
  const t1 = performance.now();
1050
- $9adf8bc2f1ba310f$export$8cfef5dc37c46888.log(this.name, $9adf8bc2f1ba310f$var$msgRender, `${t1 - t0} ms`, hsmls);
1052
+ $9adf8bc2f1ba310f$export$8cfef5dc37c46888.log(this.id, $9adf8bc2f1ba310f$var$msgRender, `${t1 - t0} ms`, hsmls);
1051
1053
  return hsmls !== null && hsmls !== void 0 ? hsmls : [];
1052
1054
  } else {
1053
1055
  let hsmls;
1054
1056
  try {
1055
1057
  hsmls = this.view(this.state);
1056
1058
  } catch (e) {
1057
- $9adf8bc2f1ba310f$export$8cfef5dc37c46888.error(this.name, $9adf8bc2f1ba310f$var$msgRender, e);
1059
+ $9adf8bc2f1ba310f$export$8cfef5dc37c46888.error(this.id, $9adf8bc2f1ba310f$var$msgRender, e);
1058
1060
  }
1059
1061
  return hsmls !== null && hsmls !== void 0 ? hsmls : [];
1060
1062
  }
@@ -1136,20 +1138,19 @@ class $9adf8bc2f1ba310f$export$8cfef5dc37c46888 {
1136
1138
  this.toHtml = ()=>{
1137
1139
  return this.element ? this.element.outerHTML : "";
1138
1140
  };
1141
+ this.id = id !== null && id !== void 0 ? id : $9adf8bc2f1ba310f$var$HAPP;
1139
1142
  this.debug = debug !== null && debug !== void 0 ? debug : false;
1140
- this.name = name !== null && name !== void 0 ? name : $9adf8bc2f1ba310f$var$HAPP;
1141
- this.attributes = attributes !== null && attributes !== void 0 ? attributes : [];
1142
1143
  this.state = state();
1143
1144
  this.view = view;
1144
1145
  this.dispatcher = dispatcher !== null && dispatcher !== void 0 ? dispatcher : (a)=>$9adf8bc2f1ba310f$var$__awaiter(this, void 0, void 0, function*() {
1145
- return $9adf8bc2f1ba310f$export$8cfef5dc37c46888.log(this.name, $9adf8bc2f1ba310f$var$msgAction, a.type, a.data);
1146
+ return $9adf8bc2f1ba310f$export$8cfef5dc37c46888.log(this.id, $9adf8bc2f1ba310f$var$msgAction, a.type, a.data);
1146
1147
  });
1147
1148
  this._dispatchAction($9adf8bc2f1ba310f$export$3dcd9fad60135c2c.init, this).then(()=>element && this.mount(element));
1148
1149
  }
1149
1150
  _dispatchAction(type, data, event, scope) {
1150
1151
  return $9adf8bc2f1ba310f$var$__awaiter(this, void 0, void 0, function*() {
1151
1152
  if (this.debug) {
1152
- $9adf8bc2f1ba310f$export$8cfef5dc37c46888.log(this.name, $9adf8bc2f1ba310f$var$msgAction, {
1153
+ $9adf8bc2f1ba310f$export$8cfef5dc37c46888.log(this.id, $9adf8bc2f1ba310f$var$msgAction, {
1153
1154
  type: type,
1154
1155
  data: data,
1155
1156
  event: event
@@ -1157,23 +1158,21 @@ class $9adf8bc2f1ba310f$export$8cfef5dc37c46888 {
1157
1158
  const t0 = performance.now();
1158
1159
  yield this._dispatch(type, data, event, scope);
1159
1160
  const t1 = performance.now();
1160
- $9adf8bc2f1ba310f$export$8cfef5dc37c46888.log(this.name, $9adf8bc2f1ba310f$var$msgDispatch, `${t1 - t0} ms`, this.state);
1161
+ $9adf8bc2f1ba310f$export$8cfef5dc37c46888.log(this.id, $9adf8bc2f1ba310f$var$msgDispatch, `${t1 - t0} ms`, this.state);
1161
1162
  } else yield this._dispatch(type, data, event, scope);
1162
1163
  });
1163
1164
  }
1164
1165
  _dispatch(type, data, event, scope) {
1165
1166
  return $9adf8bc2f1ba310f$var$__awaiter(this, void 0, void 0, function*() {
1166
- if (!scope) {
1167
- try {
1168
- yield this.dispatcher({
1169
- type: type,
1170
- data: data,
1171
- event: event
1172
- }, this.state, this.dispatch);
1173
- } catch (e) {
1174
- $9adf8bc2f1ba310f$export$8cfef5dc37c46888.error(this.name, $9adf8bc2f1ba310f$var$msgDispatch, e);
1175
- }
1176
- this.update();
1167
+ if (!scope) try {
1168
+ const skipUpdate = yield this.dispatcher({
1169
+ type: type,
1170
+ data: data,
1171
+ event: event
1172
+ }, this.state, this.dispatch);
1173
+ if (!skipUpdate) this.update();
1174
+ } catch (e) {
1175
+ $9adf8bc2f1ba310f$export$8cfef5dc37c46888.error(this.id, $9adf8bc2f1ba310f$var$msgDispatch, e);
1177
1176
  }
1178
1177
  scope === "element" && this._dispatchElement(type, data);
1179
1178
  scope === "window" && this._dispatchWindow(type, data);
@@ -1215,7 +1214,7 @@ class $9adf8bc2f1ba310f$export$8cfef5dc37c46888 {
1215
1214
  const t0 = performance.now();
1216
1215
  (0, $32c8c7b45dace799$export$ccb3a8beff05eea9)(el, hsml, ctx);
1217
1216
  const t1 = performance.now();
1218
- $9adf8bc2f1ba310f$export$8cfef5dc37c46888.log(this.name, $9adf8bc2f1ba310f$var$msgUpdate, `${t1 - t0} ms`, el);
1217
+ $9adf8bc2f1ba310f$export$8cfef5dc37c46888.log(this.id, $9adf8bc2f1ba310f$var$msgUpdate, `${t1 - t0} ms`, el);
1219
1218
  } else (0, $32c8c7b45dace799$export$ccb3a8beff05eea9)(el, hsml, ctx);
1220
1219
  }
1221
1220
  }