simple-boot-front 1.0.68 → 1.0.72

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.
package/README.MD CHANGED
@@ -169,9 +169,9 @@ npm install simple-boot-front
169
169
  console.log('poo->', testService)
170
170
  }
171
171
  }
172
-
173
172
  ```
174
- * @After, @Before
173
+
174
+ * @After, @Before (AOP)
175
175
  ```typescript
176
176
  fire($event: MouseEvent, view: View<Element>) {
177
177
  console.log('fire method')
@@ -187,18 +187,7 @@ npm install simple-boot-front
187
187
  console.log('after', obj, protoType)
188
188
  }
189
189
  ```
190
- * @EventListener
191
- ```typescript
192
- @EventListener({target: window, name: 'resize'})
193
- callBackResize($event: Event, view: View<any>) {
194
- console.log('----resize-----', view, $event)
195
- }
196
190
 
197
- @EventListener({target: '#zzz', name: 'input'})
198
- callBackInput($event: Event, view: View<any>) {
199
- console.log('----input-----', view, $event)
200
- }
201
- ```
202
191
  * @ExceptionHandler
203
192
  ```typescript
204
193
  @ExceptionHandler()
@@ -211,9 +200,10 @@ npm install simple-boot-front
211
200
  ```typescript
212
201
  click() {
213
202
  intentManager.publish(new Intent('layout://info/data?a=wow&aa=zzz', Math.floor(RandomUtils.random(0, 100))));
214
- // this.publish(new Intent('layout://info/datas', Math.floor(RandomUtils.random(0, 100))));
215
- // this.publish(new Intent('layout://', Math.floor(RandomUtils.random(0, 100)))); // default callback method -> subscribe(i: Intent)
216
- // this.publish(new Intent('://info/datas', Math.floor(RandomUtils.random(0, 100))));
203
+ // const data = new CustomEvent('intent', {detail: {uri: 'index://showStore', data: {id: ${it.ID}}}}); window.dispatchEvent(data);
204
+ //intentManager(new Intent('layout://info/datas', Math.floor(RandomUtils.random(0, 100))));
205
+ //intentManager(new Intent('layout://', Math.floor(RandomUtils.random(0, 100)))); // default callback method -> subscribe(i: Intent)
206
+ //intentManager(new Intent('://info/datas', Math.floor(RandomUtils.random(0, 100))));
217
207
  }
218
208
  ```
219
209
 
@@ -239,73 +229,23 @@ export class AppInfo {
239
229
  ## Reserved key word
240
230
  * html
241
231
  - attribute
242
- - **[router-outlet]**: child module space
243
- - **module-event-click**: click event
244
- - value: method name, parameter($event, View)
245
- ```html
246
- <button dr-event-click="changeData">change</button>
247
- ```
248
- - **module-event-change**: change event
249
- - value: method name, parameter($event, View)
250
- ```html
251
- <input dr-event-change="changeData">
252
- ```
253
- - **module-event-keyup**: keyup event
254
- - value: method name, parameter($event, View)
255
- ```html
256
- <input dr-event-keyup="changeData">
257
- ```
258
- - **module-event-keydown**: keydown event
259
- - value: method name, parameter($event, View)
260
- ```html
261
- <input dr-event-keydown="changeData">
262
- ```
263
- - **module-event-input**: input event
264
- - value: method name, parameter($event, View)
265
- ```html
266
- <input dr-event-input="changeData">
267
- ```
268
- - **module-value-link**: link event (value change <-> input)
269
- - value: variable name
270
- ```html
271
- <input dr-value-link="value">
272
- ```
273
- - **module-value**: value injection
274
- - value: variable name
275
- ```html
276
- <input dr-value="value">
277
- ```
278
- - **module-change-attr**: change value setAttribute
279
- - value: script
280
- ```html
281
- <img src="https://cdn.imweb.me/thumbnail/20190912/460132b4e4fce.jpg" module-change-attr="return {height: this.size, width: this.size}">
282
- ```
283
- - **module-change-style**: change value set Style
284
- - value: script
285
- ```html
286
- <div module-change-style="return {fontSize: `${this.size}px`, color: this.randomColor()}">hello</div>
287
- ```
288
232
  - **router-active-class**: url === href attribute => class add
289
233
  - value: add and remove class name
290
234
  ```html
291
- <a router-link="ajax" router-active-class="['active']">Ajax</a>
235
+ <a router-link="ajax" router-active-class="active">Ajax</a>
292
236
  ```
293
237
  - **router-link**:
294
238
  - value: router link
295
239
  ```html
296
240
  <a router-link="ajax">Ajax</a>
297
241
  ```
298
- - subscribe
242
+ - intent
299
243
  ```typescript
300
- data(i: Intent) {
244
+ showStore(i: Intent) {
301
245
  this.datas = i.data + '->' + i.params.aa
302
246
  }
303
- viewSubscribe(i: Intent<View<HTMLInputElement>>) {
304
- this.datas = i.data?.value + '->' + i.params.aa + '-->' + i.event
305
- }
306
- ```
307
-
308
-
247
+ call -> const data = new CustomEvent('intent', {detail: {uri: 'index://showStore', data: {id: ${it.ID}}}}); window.dispatchEvent(data);
248
+ ```
309
249
  ## License
310
250
  * MIT
311
251
  * visualkhh@gmail.com
@@ -6,12 +6,16 @@ import { HttpService } from './service/HttpService';
6
6
  import { SimstanceManager } from 'simple-boot-core/simstance/SimstanceManager';
7
7
  import { IntentManager } from 'simple-boot-core/intent/IntentManager';
8
8
  import { RouterManager } from 'simple-boot-core/route/RouterManager';
9
+ import { TargetElement, TargetAttr } from 'dom-render/Config';
9
10
  export declare class SimpleBootFront extends SimpleApplication {
10
11
  rootRouter: ConstructorType<any>;
11
12
  option: SimFrontOption;
12
13
  navigation: Navigation;
13
14
  domRendoerExcludeProxy: (typeof SimFrontOption | typeof SimstanceManager | typeof SimpleApplication | typeof Navigation | typeof HttpService | typeof IntentManager | typeof RouterManager)[];
15
+ targetElements: TargetElement[];
16
+ targetAttrs: TargetAttr[];
14
17
  constructor(rootRouter: ConstructorType<any>, option: SimFrontOption);
18
+ getComponentInnerHtml(targetObj: any): string;
15
19
  createDomRender<T extends object>(obj: T): T;
16
20
  run(): void;
17
21
  private afterSetting;
@@ -75,34 +75,64 @@ var SimpleBootFront = (function (_super) {
75
75
  _this.option = option;
76
76
  _this.domRendoerExcludeProxy = [SimpleApplication_1.SimpleApplication, IntentManager_1.IntentManager, RouterManager_1.RouterManager, SimstanceManager_1.SimstanceManager, SimFrontOption_1.SimFrontOption, Navigation_1.Navigation, ViewService_1.ViewService, HttpService_1.HttpService];
77
77
  window.__dirname = 'simple-boot-front__dirname';
78
+ _this.targetElements = [];
79
+ var selectors = Component_1.componentSelectors;
80
+ selectors.forEach(function (val, name) {
81
+ _this.targetElements.push({
82
+ name: name,
83
+ callBack: function (element, obj, rawSet) {
84
+ var componentObj = _this.simstanceManager.newSim(val);
85
+ var set = element.getAttribute('dr-set');
86
+ if (set) {
87
+ var comEvalTargetObj = {};
88
+ comEvalTargetObj[name] = componentObj;
89
+ var script = "var " + name + " = this['" + name + "']; " + set + " ";
90
+ ScriptUtils_1.ScriptUtils.eval(script, Object.assign(comEvalTargetObj, obj));
91
+ }
92
+ var componentOption = (0, Component_1.getComponent)(componentObj);
93
+ var fag = _this.option.window.document.createDocumentFragment();
94
+ if (componentOption) {
95
+ obj.__componentInstances[rawSet.uuid] = componentObj;
96
+ var template = _this.option.window.document.createElement('div');
97
+ template.innerHTML = _this.getComponentInnerHtml(componentObj);
98
+ fag.append(RawSet_1.RawSet.drThisCreate(template, "this.__componentInstances['" + rawSet.uuid + "']", '', true, obj));
99
+ }
100
+ return fag;
101
+ }
102
+ });
103
+ });
104
+ _this.targetAttrs = [{
105
+ name: 'component', callBack: function (element, attrValue, obj, rawSet) {
106
+ var fag = _this.option.window.document.createDocumentFragment();
107
+ if (attrValue) {
108
+ var targetObj = ScriptUtils_1.ScriptUtils.eval("return " + attrValue, obj);
109
+ var n = element.cloneNode(true);
110
+ var innerHTML = _this.getComponentInnerHtml(targetObj);
111
+ n.innerHTML = innerHTML;
112
+ fag.append(RawSet_1.RawSet.drThisCreate(n, attrValue, '', true, obj));
113
+ }
114
+ return fag;
115
+ }
116
+ }];
78
117
  option.proxy = {
79
118
  onProxy: function (it) { return _this.createDomRender(it); }
80
119
  };
81
120
  return _this;
82
121
  }
122
+ SimpleBootFront.prototype.getComponentInnerHtml = function (targetObj) {
123
+ var _a, _b, _c;
124
+ var component = (0, Component_1.getComponent)(targetObj);
125
+ var styles = ((_b = (_a = component === null || component === void 0 ? void 0 : component.styles) === null || _a === void 0 ? void 0 : _a.map(function (it) { return "<style>" + it + "</style>"; })) !== null && _b !== void 0 ? _b : []).join(' ');
126
+ var template = ((_c = component === null || component === void 0 ? void 0 : component.template) !== null && _c !== void 0 ? _c : '');
127
+ return styles + template;
128
+ };
83
129
  SimpleBootFront.prototype.createDomRender = function (obj) {
84
- var _this = this;
85
- var component = Component_1.getComponent(obj);
130
+ var component = (0, Component_1.getComponent)(obj);
86
131
  if (component && typeof obj === 'object') {
87
132
  return DomRender_1.DomRender.run(obj, undefined, {
88
- targets: [{
89
- attrName: 'component', callBack: function (element, attrValue, obj) {
90
- var _a, _b, _c;
91
- var fag = _this.option.window.document.createDocumentFragment();
92
- if (attrValue) {
93
- var targetObj = ScriptUtils_1.ScriptUtils.eval("return " + attrValue, obj);
94
- var component_1 = Component_1.getComponent(targetObj);
95
- var styles = ((_b = (_a = component_1 === null || component_1 === void 0 ? void 0 : component_1.styles) === null || _a === void 0 ? void 0 : _a.map(function (it) { return "<style>" + it + "</style>"; })) !== null && _b !== void 0 ? _b : []).join(' ');
96
- var template = ((_c = component_1 === null || component_1 === void 0 ? void 0 : component_1.template) !== null && _c !== void 0 ? _c : '');
97
- var n = element.cloneNode(true);
98
- var innerHTML = styles + template;
99
- n.innerHTML = innerHTML;
100
- fag.append(RawSet_1.RawSet.drThisCreate(n, attrValue, '', true, obj));
101
- }
102
- return fag;
103
- }
104
- }],
105
- onInit: function (attrName, attrValue, obj) {
133
+ targetElements: this.targetElements,
134
+ targetAttrs: this.targetAttrs,
135
+ onAttrInit: function (attrName, attrValue, obj) {
106
136
  var _a, _b;
107
137
  if (attrName === 'component') {
108
138
  var bindObj = ScriptUtils_1.ScriptUtils.evalReturn(attrValue, obj);
@@ -113,7 +143,7 @@ var SimpleBootFront = (function (_super) {
113
143
  attrName: 'router-link', callBack: function (elements, attrValue, obj) {
114
144
  elements.addEventListener('click', function (event) {
115
145
  var _a;
116
- (_a = SimGlobal_1.SimGlobal().application.simstanceManager.getOrNewSim(Navigation_1.Navigation)) === null || _a === void 0 ? void 0 : _a.go(attrValue);
146
+ (_a = (0, SimGlobal_1.SimGlobal)().application.simstanceManager.getOrNewSim(Navigation_1.Navigation)) === null || _a === void 0 ? void 0 : _a.go(attrValue);
117
147
  });
118
148
  }
119
149
  }],
@@ -1,10 +1,10 @@
1
1
  import { ConstructorType, GenericClassDecorator } from 'simple-boot-core/types/Types';
2
+ export declare const componentSelectors: Map<string, ConstructorType<any>>;
2
3
  export interface ComponentConfig {
4
+ selector?: string;
3
5
  template?: string;
4
6
  styles?: (string)[];
5
- modules?: {
6
- [name: string]: ConstructorType<any>;
7
- };
7
+ using?: (ConstructorType<any>)[];
8
8
  }
9
9
  export declare const ComponentMetadataKey: unique symbol;
10
10
  export declare const Component: (config?: ComponentConfig | undefined) => GenericClassDecorator<ConstructorType<any>>;
@@ -1,11 +1,39 @@
1
1
  "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
2
17
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getComponent = exports.Component = exports.ComponentMetadataKey = void 0;
18
+ exports.getComponent = exports.Component = exports.ComponentMetadataKey = exports.componentSelectors = void 0;
4
19
  var ReflectUtils_1 = require("simple-boot-core/utils/reflect/ReflectUtils");
20
+ exports.componentSelectors = new Map();
5
21
  exports.ComponentMetadataKey = Symbol('Component');
6
22
  var Component = function (config) {
7
23
  return function (target) {
24
+ if (config === null || config === void 0 ? void 0 : config.selector) {
25
+ exports.componentSelectors.set(config === null || config === void 0 ? void 0 : config.selector, target);
26
+ }
8
27
  ReflectUtils_1.ReflectUtils.defineMetadata(exports.ComponentMetadataKey, config, target);
28
+ return (function (_super) {
29
+ __extends(class_1, _super);
30
+ function class_1() {
31
+ var _this = _super !== null && _super.apply(this, arguments) || this;
32
+ _this.__componentInstances = {};
33
+ return _this;
34
+ }
35
+ return class_1;
36
+ }(target));
9
37
  };
10
38
  };
11
39
  exports.Component = Component;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simple-boot-front",
3
- "version": "1.0.68",
3
+ "version": "1.0.72",
4
4
  "main": "SimpleApplication.js",
5
5
  "license": "MIT",
6
6
  "description": "front end SPA frameworks",
@@ -73,8 +73,8 @@
73
73
  "typescript": "^4.3.5"
74
74
  },
75
75
  "dependencies": {
76
- "dom-render": "^1.0.27",
76
+ "dom-render": "^1.0.33",
77
77
  "reflect-metadata": "^0.1.13",
78
- "simple-boot-core": "^1.0.19"
78
+ "simple-boot-core": "^1.0.20"
79
79
  }
80
80
  }
@@ -15,7 +15,7 @@ var HttpService = (function () {
15
15
  function HttpService() {
16
16
  }
17
17
  HttpService = __decorate([
18
- SimDecorator_1.Sim(),
18
+ (0, SimDecorator_1.Sim)(),
19
19
  __metadata("design:paramtypes", [])
20
20
  ], HttpService);
21
21
  return HttpService;
@@ -67,7 +67,7 @@ var Navigation = (function () {
67
67
  window.dispatchEvent(new Event('popstate'));
68
68
  };
69
69
  Navigation = __decorate([
70
- SimDecorator_1.Sim(),
70
+ (0, SimDecorator_1.Sim)(),
71
71
  __metadata("design:paramtypes", [SimFrontOption_1.SimFrontOption])
72
72
  ], Navigation);
73
73
  return Navigation;
@@ -38,7 +38,7 @@ var ViewService = (function () {
38
38
  return (_a = this.e("." + selector)) !== null && _a !== void 0 ? _a : undefined;
39
39
  };
40
40
  ViewService = __decorate([
41
- SimDecorator_1.Sim(),
41
+ (0, SimDecorator_1.Sim)(),
42
42
  __metadata("design:paramtypes", [])
43
43
  ], ViewService);
44
44
  return ViewService;