simple-boot-front 1.0.69 → 1.0.73
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 +11 -71
- package/SimpleBootFront.d.ts +4 -0
- package/SimpleBootFront.js +57 -21
- package/decorators/Component.d.ts +3 -3
- package/decorators/Component.js +29 -1
- package/package.json +3 -3
- package/service/CookieService.d.ts +8 -0
- package/service/CookieService.js +42 -0
- package/service/HttpService.js +1 -1
- package/service/Navigation.js +1 -1
- package/service/view/ViewService.js +1 -1
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
|
-
|
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
|
-
//
|
215
|
-
//
|
216
|
-
//
|
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="
|
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
|
-
-
|
242
|
+
- intent
|
299
243
|
```typescript
|
300
|
-
|
244
|
+
showStore(i: Intent) {
|
301
245
|
this.datas = i.data + '->' + i.params.aa
|
302
246
|
}
|
303
|
-
|
304
|
-
|
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
|
package/SimpleBootFront.d.ts
CHANGED
@@ -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;
|
package/SimpleBootFront.js
CHANGED
@@ -75,34 +75,70 @@ 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
|
+
var any;
|
87
|
+
if (set) {
|
88
|
+
var comEvalTargetObj_1 = { '$attribute': any = {} };
|
89
|
+
element.getAttributeNames().forEach(function (it) {
|
90
|
+
comEvalTargetObj_1['$attribute'][it] = element.getAttribute(it);
|
91
|
+
});
|
92
|
+
comEvalTargetObj_1['$innerHTML'] = element.innerHTML;
|
93
|
+
comEvalTargetObj_1['$element'] = element;
|
94
|
+
comEvalTargetObj_1[name] = componentObj;
|
95
|
+
var script = "var " + name + " = this['" + name + "']; var $element = this['$element']; var $innerHTML = this['$innerHTML']; var $attribute = this['$attribute']; " + set + " ";
|
96
|
+
ScriptUtils_1.ScriptUtils.eval(script, Object.assign(comEvalTargetObj_1, obj));
|
97
|
+
}
|
98
|
+
var componentOption = (0, Component_1.getComponent)(componentObj);
|
99
|
+
var fag = _this.option.window.document.createDocumentFragment();
|
100
|
+
if (componentOption) {
|
101
|
+
obj.__componentInstances[rawSet.uuid] = componentObj;
|
102
|
+
var template = _this.option.window.document.createElement('div');
|
103
|
+
template.innerHTML = _this.getComponentInnerHtml(componentObj);
|
104
|
+
fag.append(RawSet_1.RawSet.drThisCreate(template, "this.__componentInstances['" + rawSet.uuid + "']", '', true, obj));
|
105
|
+
}
|
106
|
+
return fag;
|
107
|
+
}
|
108
|
+
});
|
109
|
+
});
|
110
|
+
_this.targetAttrs = [{
|
111
|
+
name: 'component', callBack: function (element, attrValue, obj, rawSet) {
|
112
|
+
var fag = _this.option.window.document.createDocumentFragment();
|
113
|
+
if (attrValue) {
|
114
|
+
var targetObj = ScriptUtils_1.ScriptUtils.eval("return " + attrValue, obj);
|
115
|
+
var n = element.cloneNode(true);
|
116
|
+
var innerHTML = _this.getComponentInnerHtml(targetObj);
|
117
|
+
n.innerHTML = innerHTML;
|
118
|
+
fag.append(RawSet_1.RawSet.drThisCreate(n, attrValue, '', true, obj));
|
119
|
+
}
|
120
|
+
return fag;
|
121
|
+
}
|
122
|
+
}];
|
78
123
|
option.proxy = {
|
79
124
|
onProxy: function (it) { return _this.createDomRender(it); }
|
80
125
|
};
|
81
126
|
return _this;
|
82
127
|
}
|
128
|
+
SimpleBootFront.prototype.getComponentInnerHtml = function (targetObj) {
|
129
|
+
var _a, _b, _c;
|
130
|
+
var component = (0, Component_1.getComponent)(targetObj);
|
131
|
+
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(' ');
|
132
|
+
var template = ((_c = component === null || component === void 0 ? void 0 : component.template) !== null && _c !== void 0 ? _c : '');
|
133
|
+
return styles + template;
|
134
|
+
};
|
83
135
|
SimpleBootFront.prototype.createDomRender = function (obj) {
|
84
|
-
var
|
85
|
-
var component = Component_1.getComponent(obj);
|
136
|
+
var component = (0, Component_1.getComponent)(obj);
|
86
137
|
if (component && typeof obj === 'object') {
|
87
138
|
return DomRender_1.DomRender.run(obj, undefined, {
|
88
|
-
|
89
|
-
|
90
|
-
|
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) {
|
139
|
+
targetElements: this.targetElements,
|
140
|
+
targetAttrs: this.targetAttrs,
|
141
|
+
onAttrInit: function (attrName, attrValue, obj) {
|
106
142
|
var _a, _b;
|
107
143
|
if (attrName === 'component') {
|
108
144
|
var bindObj = ScriptUtils_1.ScriptUtils.evalReturn(attrValue, obj);
|
@@ -113,7 +149,7 @@ var SimpleBootFront = (function (_super) {
|
|
113
149
|
attrName: 'router-link', callBack: function (elements, attrValue, obj) {
|
114
150
|
elements.addEventListener('click', function (event) {
|
115
151
|
var _a;
|
116
|
-
(_a = SimGlobal_1.SimGlobal().application.simstanceManager.getOrNewSim(Navigation_1.Navigation)) === null || _a === void 0 ? void 0 : _a.go(attrValue);
|
152
|
+
(_a = (0, SimGlobal_1.SimGlobal)().application.simstanceManager.getOrNewSim(Navigation_1.Navigation)) === null || _a === void 0 ? void 0 : _a.go(attrValue);
|
117
153
|
});
|
118
154
|
}
|
119
155
|
}],
|
@@ -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
|
-
|
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>>;
|
package/decorators/Component.js
CHANGED
@@ -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.
|
3
|
+
"version": "1.0.73",
|
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.
|
76
|
+
"dom-render": "^1.0.34",
|
77
77
|
"reflect-metadata": "^0.1.13",
|
78
|
-
"simple-boot-core": "^1.0.
|
78
|
+
"simple-boot-core": "^1.0.20"
|
79
79
|
}
|
80
80
|
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
+
};
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
9
|
+
exports.CookieService = void 0;
|
10
|
+
var SimDecorator_1 = require("simple-boot-core/decorators/SimDecorator");
|
11
|
+
var CookieService = (function () {
|
12
|
+
function CookieService() {
|
13
|
+
}
|
14
|
+
CookieService.prototype.get = function (key) {
|
15
|
+
return this.getAll()[key];
|
16
|
+
};
|
17
|
+
CookieService.prototype.getAll = function () {
|
18
|
+
var _a;
|
19
|
+
var all = {};
|
20
|
+
var strings = (_a = document.cookie.split(';')) !== null && _a !== void 0 ? _a : [];
|
21
|
+
strings.forEach(function (it) {
|
22
|
+
var set = it.split('=');
|
23
|
+
if (set[0] && set[1] && set[0].trim().length > 0 && set[1].trim().length > 0) {
|
24
|
+
all[set[0].trim()] = set[1].trim();
|
25
|
+
}
|
26
|
+
});
|
27
|
+
return all;
|
28
|
+
};
|
29
|
+
CookieService.prototype.set = function (name, value, exp) {
|
30
|
+
var date = new Date();
|
31
|
+
date.setTime(date.getTime() + exp);
|
32
|
+
document.cookie = name + '=' + value + ';expires=' + date.toUTCString() + ';path=/';
|
33
|
+
};
|
34
|
+
CookieService.prototype.delete = function (name) {
|
35
|
+
document.cookie = name + '=; expires=Thu, 01 Jan 1999 00:00:10 GMT;';
|
36
|
+
};
|
37
|
+
CookieService = __decorate([
|
38
|
+
(0, SimDecorator_1.Sim)()
|
39
|
+
], CookieService);
|
40
|
+
return CookieService;
|
41
|
+
}());
|
42
|
+
exports.CookieService = CookieService;
|
package/service/HttpService.js
CHANGED
package/service/Navigation.js
CHANGED
@@ -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;
|