simple-boot-front 1.0.98 → 1.0.99

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. package/README.MD +335 -335
  2. package/SimpleBootFront.d.ts +32 -25
  3. package/SimpleBootFront.js +327 -239
  4. package/decorators/Component.d.ts +11 -11
  5. package/decorators/Component.js +30 -54
  6. package/decorators/Script.d.ts +10 -10
  7. package/decorators/Script.js +31 -31
  8. package/decorators/inject/InjectFrontSituationType.d.ts +3 -0
  9. package/decorators/inject/InjectFrontSituationType.js +7 -0
  10. package/fetch/Fetcher.d.ts +4 -4
  11. package/fetch/Fetcher.js +9 -9
  12. package/lifecycle/OnChangedRender.d.ts +3 -3
  13. package/lifecycle/OnChangedRender.js +2 -2
  14. package/lifecycle/OnDestroy.d.ts +3 -3
  15. package/lifecycle/OnDestroy.js +2 -2
  16. package/lifecycle/OnFinish.d.ts +3 -3
  17. package/lifecycle/OnFinish.js +2 -2
  18. package/lifecycle/OnInit.d.ts +8 -3
  19. package/lifecycle/OnInit.js +2 -2
  20. package/lifecycle/OnInitedChild.d.ts +3 -3
  21. package/lifecycle/OnInitedChild.js +2 -2
  22. package/option/SimFrontOption.d.ts +14 -14
  23. package/option/SimFrontOption.js +45 -45
  24. package/package.json +84 -82
  25. package/script/ScriptRunnable.d.ts +7 -7
  26. package/script/ScriptRunnable.js +22 -22
  27. package/service/CookieService.d.ts +11 -8
  28. package/service/CookieService.js +54 -42
  29. package/service/HttpService.d.ts +3 -3
  30. package/service/HttpService.js +23 -23
  31. package/service/MetaTagService.d.ts +11 -0
  32. package/service/MetaTagService.js +52 -0
  33. package/service/Navigation.d.ts +18 -12
  34. package/service/Navigation.js +117 -75
  35. package/service/ScriptService.d.ts +7 -7
  36. package/service/ScriptService.js +39 -39
  37. package/service/StorageService.d.ts +12 -0
  38. package/service/StorageService.js +67 -0
  39. package/service/view/View.d.ts +6 -6
  40. package/service/view/View.js +29 -29
  41. package/service/view/ViewService.d.ts +7 -7
  42. package/service/view/ViewService.js +46 -46
  43. package/throwable/RouterError.d.ts +4 -4
  44. package/throwable/RouterError.js +27 -27
  45. package/throwable/RouterIntentError.d.ts +4 -4
  46. package/throwable/RouterIntentError.js +27 -27
  47. package/throwable/RouterNotFount.d.ts +4 -4
  48. package/throwable/RouterNotFount.js +27 -27
  49. package/utils/dom/DomUtils.d.ts +0 -13
  50. package/utils/dom/DomUtils.js +0 -45
  51. package/utils/node/NodeUtils.d.ts +0 -10
  52. package/utils/node/NodeUtils.js +0 -25
  53. package/utils/window/LocationUtils.d.ts +0 -8
  54. package/utils/window/LocationUtils.js +0 -34
@@ -1,239 +1,327 @@
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
- })();
17
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
- return new (P || (P = Promise))(function (resolve, reject) {
20
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
- step((generator = generator.apply(thisArg, _arguments || [])).next());
24
- });
25
- };
26
- var __generator = (this && this.__generator) || function (thisArg, body) {
27
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
- function verb(n) { return function (v) { return step([n, v]); }; }
30
- function step(op) {
31
- if (f) throw new TypeError("Generator is already executing.");
32
- while (_) try {
33
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
- if (y = 0, t) op = [op[0] & 2, t.value];
35
- switch (op[0]) {
36
- case 0: case 1: t = op; break;
37
- case 4: _.label++; return { value: op[1], done: false };
38
- case 5: _.label++; y = op[1]; op = [0]; continue;
39
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
- default:
41
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
- if (t[2]) _.ops.pop();
46
- _.trys.pop(); continue;
47
- }
48
- op = body.call(thisArg, _);
49
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
- }
52
- };
53
- Object.defineProperty(exports, "__esModule", { value: true });
54
- exports.SimpleBootFront = void 0;
55
- var SimFrontOption_1 = require("./option/SimFrontOption");
56
- var Component_1 = require("./decorators/Component");
57
- var Script_1 = require("./decorators/Script");
58
- var DomRender_1 = require("dom-render/DomRender");
59
- var SimAtomic_1 = require("simple-boot-core/simstance/SimAtomic");
60
- var SimpleApplication_1 = require("simple-boot-core/SimpleApplication");
61
- var Intent_1 = require("simple-boot-core/intent/Intent");
62
- var Navigation_1 = require("./service/Navigation");
63
- var ViewService_1 = require("./service/view/ViewService");
64
- var HttpService_1 = require("./service/HttpService");
65
- var SimstanceManager_1 = require("simple-boot-core/simstance/SimstanceManager");
66
- var IntentManager_1 = require("simple-boot-core/intent/IntentManager");
67
- var RouterManager_1 = require("simple-boot-core/route/RouterManager");
68
- var ScriptUtils_1 = require("dom-render/utils/script/ScriptUtils");
69
- var SimGlobal_1 = require("simple-boot-core/global/SimGlobal");
70
- var RawSet_1 = require("dom-render/RawSet");
71
- var SimpleBootFront = (function (_super) {
72
- __extends(SimpleBootFront, _super);
73
- function SimpleBootFront(rootRouter, option) {
74
- var _this = _super.call(this, rootRouter, option) || this;
75
- _this.rootRouter = rootRouter;
76
- _this.option = option;
77
- _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, HTMLElement];
78
- _this.domRenderTargetElements = [];
79
- _this.domRenderTargetAttrs = [];
80
- _this.domRenderConfig = {
81
- targetElements: _this.domRenderTargetElements,
82
- targetAttrs: _this.domRenderTargetAttrs,
83
- onElementInit: function (name, obj, rawSet, targetElement) {
84
- var _a, _b, _c;
85
- (_c = (_b = (_a = targetElement === null || targetElement === void 0 ? void 0 : targetElement.__render) === null || _a === void 0 ? void 0 : _a.component) === null || _b === void 0 ? void 0 : _b.onInit) === null || _c === void 0 ? void 0 : _c.call(_b);
86
- },
87
- onAttrInit: function (attrName, attrValue, obj) {
88
- var _a, _b;
89
- if (attrName === 'component') {
90
- var bindObj = ScriptUtils_1.ScriptUtils.evalReturn(attrValue, obj);
91
- (_b = (_a = bindObj) === null || _a === void 0 ? void 0 : _a.onInit) === null || _b === void 0 ? void 0 : _b.call(_a);
92
- }
93
- },
94
- scripts: { 'application': _this },
95
- applyEvents: [{
96
- attrName: 'router-link', callBack: function (elements, attrValue, obj) {
97
- elements.addEventListener('click', function (event) {
98
- var _a;
99
- (_a = (0, SimGlobal_1.SimGlobal)().application.simstanceManager.getOrNewSim(Navigation_1.Navigation)) === null || _a === void 0 ? void 0 : _a.go(attrValue);
100
- });
101
- }
102
- }],
103
- proxyExcludeTyps: _this.domRendoerExcludeProxy
104
- };
105
- window.__dirname = 'simple-boot-front__dirname';
106
- _this.domRenderTargetAttrs.push({
107
- name: 'component', callBack: function (element, attrValue, obj, rawSet) {
108
- var fag = _this.option.window.document.createDocumentFragment();
109
- if (attrValue) {
110
- var targetObj = ScriptUtils_1.ScriptUtils.eval("return " + attrValue, obj);
111
- var n = element.cloneNode(true);
112
- var innerHTML = _this.getComponentInnerHtml(targetObj);
113
- n.innerHTML = innerHTML;
114
- fag.append(RawSet_1.RawSet.drThisCreate(n, attrValue, '', true, obj));
115
- }
116
- return fag;
117
- }
118
- });
119
- option.proxy = {
120
- onProxy: function (it) { return _this.createDomRender(it); }
121
- };
122
- return _this;
123
- }
124
- SimpleBootFront.prototype.getComponentInnerHtml = function (targetObj) {
125
- var _a, _b, _c;
126
- var component = (0, Component_1.getComponent)(targetObj);
127
- 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(' ');
128
- var template = ((_c = component === null || component === void 0 ? void 0 : component.template) !== null && _c !== void 0 ? _c : '');
129
- return styles + template;
130
- };
131
- SimpleBootFront.prototype.createDomRender = function (obj) {
132
- var component = (0, Component_1.getComponent)(obj);
133
- if (component && typeof obj === 'object') {
134
- return DomRender_1.DomRender.run(obj, undefined, this.domRenderConfig);
135
- }
136
- return obj;
137
- };
138
- SimpleBootFront.prototype.run = function () {
139
- var _this = this;
140
- var _a, _b, _c, _d, _e;
141
- _super.prototype.run.call(this);
142
- this.initDomRenderScripts();
143
- this.initDomRenderTargetElements();
144
- this.navigation = this.simstanceManager.getOrNewSim(Navigation_1.Navigation);
145
- var routerAtomic = new SimAtomic_1.SimAtomic(this.rootRouter);
146
- var target = this.option.window.document.querySelector(this.option.selector);
147
- if (target && routerAtomic.value) {
148
- var component = routerAtomic.getConfig(Component_1.ComponentMetadataKey);
149
- var template = this.option.window.document.createElement('template');
150
- 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(' ');
151
- target.innerHTML = styles + " " + ((_c = component === null || component === void 0 ? void 0 : component.template) !== null && _c !== void 0 ? _c : '');
152
- var val = routerAtomic.value;
153
- var domRenderProxy = val._DomRender_proxy;
154
- domRenderProxy.initRender(target);
155
- (_e = (_d = val) === null || _d === void 0 ? void 0 : _d.onInit) === null || _e === void 0 ? void 0 : _e.call(_d);
156
- }
157
- this.option.window.addEventListener('intent', function (event) {
158
- var cevent = event;
159
- _this.publishIntent(new Intent_1.Intent(cevent.detail.uri, cevent.detail.data, event));
160
- });
161
- this.option.window.addEventListener('popstate', function (event) {
162
- var _a;
163
- var intent = new Intent_1.Intent((_a = _this.navigation.path) !== null && _a !== void 0 ? _a : '');
164
- _this.routing(intent).then(function (it) { return __awaiter(_this, void 0, void 0, function () {
165
- return __generator(this, function (_a) {
166
- this.afterSetting();
167
- return [2];
168
- });
169
- }); });
170
- });
171
- this.option.window.dispatchEvent(new Event('popstate'));
172
- };
173
- SimpleBootFront.prototype.afterSetting = function () {
174
- var _this = this;
175
- this.option.window.document.querySelectorAll('[router-link]').forEach(function (it) {
176
- var _a, _b, _c, _d;
177
- var link = it.getAttribute('router-link');
178
- if (link) {
179
- var activeClasss = it.getAttribute('router-active-class');
180
- var aClasss = activeClasss === null || activeClasss === void 0 ? void 0 : activeClasss.split(',');
181
- var inActiveClasss = it.getAttribute('router-inactive-class');
182
- var iClasss = inActiveClasss === null || inActiveClasss === void 0 ? void 0 : inActiveClasss.split(',');
183
- if (_this.navigation.path === link) {
184
- if (aClasss && aClasss.length > 0) {
185
- (_a = it.classList).add.apply(_a, aClasss);
186
- }
187
- if (iClasss && iClasss.length > 0) {
188
- (_b = it.classList).remove.apply(_b, iClasss);
189
- }
190
- }
191
- else {
192
- if (aClasss && aClasss.length > 0) {
193
- (_c = it.classList).remove.apply(_c, aClasss);
194
- }
195
- if (iClasss && iClasss.length > 0) {
196
- (_d = it.classList).add.apply(_d, iClasss);
197
- }
198
- }
199
- }
200
- });
201
- };
202
- SimpleBootFront.prototype.initDomRenderScripts = function () {
203
- var _this = this;
204
- var simstanceManager = this.simstanceManager;
205
- Script_1.scripts.forEach(function (val, name) {
206
- _this.domRenderConfig.scripts[name] = function () {
207
- var args = [];
208
- for (var _i = 0; _i < arguments.length; _i++) {
209
- args[_i] = arguments[_i];
210
- }
211
- var obj = undefined;
212
- try {
213
- obj = simstanceManager.getOrNewSim(val);
214
- }
215
- catch (e) {
216
- obj = simstanceManager.newSim(val);
217
- }
218
- var render = this.__render;
219
- var scriptRunnable = obj;
220
- scriptRunnable.rawSets.set(render.rawset, this);
221
- return scriptRunnable.run.apply(scriptRunnable, args);
222
- };
223
- });
224
- };
225
- SimpleBootFront.prototype.initDomRenderTargetElements = function () {
226
- var _this = this;
227
- var selectors = Component_1.componentSelectors;
228
- selectors.forEach(function (val, name) {
229
- var component = (0, Component_1.getComponent)(val);
230
- var items = RawSet_1.RawSet.createComponentTargetElement(name, function (e, o, r) {
231
- var newSim = _this.simstanceManager.newSim(val);
232
- return newSim;
233
- }, component === null || component === void 0 ? void 0 : component.template, component === null || component === void 0 ? void 0 : component.styles, _this.domRenderConfig.scripts);
234
- _this.domRenderTargetElements.push(items);
235
- });
236
- };
237
- return SimpleBootFront;
238
- }(SimpleApplication_1.SimpleApplication));
239
- exports.SimpleBootFront = SimpleBootFront;
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
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
54
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
55
+ if (ar || !(i in from)) {
56
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
57
+ ar[i] = from[i];
58
+ }
59
+ }
60
+ return to.concat(ar || Array.prototype.slice.call(from));
61
+ };
62
+ Object.defineProperty(exports, "__esModule", { value: true });
63
+ exports.SimpleBootFront = void 0;
64
+ var SimFrontOption_1 = require("./option/SimFrontOption");
65
+ var Component_1 = require("./decorators/Component");
66
+ var Script_1 = require("./decorators/Script");
67
+ var DomRender_1 = require("dom-render/DomRender");
68
+ var SimAtomic_1 = require("simple-boot-core/simstance/SimAtomic");
69
+ var SimpleApplication_1 = require("simple-boot-core/SimpleApplication");
70
+ var Intent_1 = require("simple-boot-core/intent/Intent");
71
+ var Navigation_1 = require("./service/Navigation");
72
+ var ViewService_1 = require("./service/view/ViewService");
73
+ var HttpService_1 = require("./service/HttpService");
74
+ var SimstanceManager_1 = require("simple-boot-core/simstance/SimstanceManager");
75
+ var IntentManager_1 = require("simple-boot-core/intent/IntentManager");
76
+ var RouterManager_1 = require("simple-boot-core/route/RouterManager");
77
+ var ScriptUtils_1 = require("dom-render/utils/script/ScriptUtils");
78
+ var RawSet_1 = require("dom-render/RawSet");
79
+ var Types_1 = require("dom-render/types/Types");
80
+ var InjectFrontSituationType_1 = require("./decorators/inject/InjectFrontSituationType");
81
+ var SimpleBootFront = (function (_super) {
82
+ __extends(SimpleBootFront, _super);
83
+ function SimpleBootFront(rootRouter, option) {
84
+ var _this = _super.call(this, rootRouter, option) || this;
85
+ _this.rootRouter = rootRouter;
86
+ _this.option = option;
87
+ _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, HTMLElement];
88
+ _this.domRenderTargetElements = [];
89
+ _this.domRenderTargetAttrs = [];
90
+ _this.domRenderConfig = {
91
+ window: option.window,
92
+ targetElements: _this.domRenderTargetElements,
93
+ targetAttrs: _this.domRenderTargetAttrs,
94
+ onElementInit: function (name, obj, rawSet, targetElement) {
95
+ var _a, _b, _c;
96
+ var target = (_a = targetElement === null || targetElement === void 0 ? void 0 : targetElement.__render) === null || _a === void 0 ? void 0 : _a.component;
97
+ var targetKey = 'onInit';
98
+ var firstCheckMaker = [function (ownerObj, type, idx, saveInjectionConfig) {
99
+ if (InjectFrontSituationType_1.InjectFrontSituationType.OPENER === (saveInjectionConfig === null || saveInjectionConfig === void 0 ? void 0 : saveInjectionConfig.config.situationType) && rawSet.point.thisVariableName) {
100
+ return new Proxy(ScriptUtils_1.ScriptUtils.evalReturn(rawSet.point.thisVariableName, obj), new Types_1.DomRenderFinalProxy());
101
+ }
102
+ }];
103
+ if (rawSet.point.thisVariableName) {
104
+ (_b = target === null || target === void 0 ? void 0 : target.onInit) === null || _b === void 0 ? void 0 : _b.call.apply(_b, __spreadArray([target], _this.simstanceManager.getParameterSim({ target: target, targetKey: targetKey, firstCheckMaker: firstCheckMaker }), false));
105
+ }
106
+ else {
107
+ (_c = target === null || target === void 0 ? void 0 : target.onInit) === null || _c === void 0 ? void 0 : _c.call.apply(_c, __spreadArray([target], _this.simstanceManager.getParameterSim({ target: target, targetKey: targetKey, firstCheckMaker: firstCheckMaker }), false));
108
+ }
109
+ },
110
+ onAttrInit: function (attrName, attrValue, obj, rawSet) {
111
+ var _a, _b;
112
+ if (attrName === 'component') {
113
+ var target_1 = ScriptUtils_1.ScriptUtils.evalReturn(attrValue, obj);
114
+ var targetKey = 'onInit';
115
+ var firstCheckMaker = [function (obj, type, idx, saveInjectionConfig) {
116
+ var _a, _b;
117
+ if (InjectFrontSituationType_1.InjectFrontSituationType.OPENER === (saveInjectionConfig === null || saveInjectionConfig === void 0 ? void 0 : saveInjectionConfig.config.situationType) && ((_a = target_1 === null || target_1 === void 0 ? void 0 : target_1.__domrender_component_new) === null || _a === void 0 ? void 0 : _a.creator)) {
118
+ return (_b = target_1 === null || target_1 === void 0 ? void 0 : target_1.__domrender_component_new) === null || _b === void 0 ? void 0 : _b.creator;
119
+ }
120
+ }];
121
+ if (rawSet.point.thisVariableName) {
122
+ (_a = target_1 === null || target_1 === void 0 ? void 0 : target_1.onInit) === null || _a === void 0 ? void 0 : _a.call.apply(_a, __spreadArray([target_1], _this.simstanceManager.getParameterSim({ target: target_1, targetKey: targetKey, firstCheckMaker: firstCheckMaker }), false));
123
+ }
124
+ else {
125
+ (_b = target_1 === null || target_1 === void 0 ? void 0 : target_1.onInit) === null || _b === void 0 ? void 0 : _b.call.apply(_b, __spreadArray([target_1], _this.simstanceManager.getParameterSim({ target: target_1, targetKey: targetKey, firstCheckMaker: firstCheckMaker }), false));
126
+ }
127
+ }
128
+ },
129
+ scripts: { application: _this },
130
+ applyEvents: [{
131
+ attrName: 'router-link',
132
+ callBack: function (elements, attrValue, obj) {
133
+ elements.addEventListener('click', function (event) {
134
+ var _a;
135
+ (_a = _this.getSimstanceManager().getOrNewSim(Navigation_1.Navigation)) === null || _a === void 0 ? void 0 : _a.go(attrValue);
136
+ });
137
+ }
138
+ }],
139
+ proxyExcludeTyps: _this.domRendoerExcludeProxy
140
+ };
141
+ _this.option.window.__dirname = 'simple-boot-front__dirname';
142
+ var targetAttribute = RawSet_1.RawSet.createComponentTargetAttribute('component', function (element, attrValue, obj, rawSet) {
143
+ return ScriptUtils_1.ScriptUtils.eval("return ".concat(attrValue), obj);
144
+ }, function (element, attrValue, obj, rawSet) {
145
+ if (attrValue) {
146
+ var targetObj = ScriptUtils_1.ScriptUtils.eval("return ".concat(attrValue), obj);
147
+ var n = element.cloneNode(true);
148
+ var innerHTML = _this.getComponentInnerHtml(targetObj);
149
+ n.innerHTML = innerHTML;
150
+ return RawSet_1.RawSet.drThisCreate(n, attrValue, '', true, obj, _this.option);
151
+ }
152
+ var fag = _this.option.window.document.createDocumentFragment();
153
+ return fag;
154
+ });
155
+ _this.domRenderTargetAttrs.push(targetAttribute);
156
+ option.proxy = {
157
+ onProxy: function (it) { return _this.createDomRender(it); }
158
+ };
159
+ return _this;
160
+ }
161
+ SimpleBootFront.prototype.getComponentInnerHtml = function (targetObj) {
162
+ var _a, _b, _c;
163
+ var component = (0, Component_1.getComponent)(targetObj);
164
+ 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>".concat(it, "</style>"); })) !== null && _b !== void 0 ? _b : []).join(' ');
165
+ var template = ((_c = component === null || component === void 0 ? void 0 : component.template) !== null && _c !== void 0 ? _c : '');
166
+ return styles + template;
167
+ };
168
+ SimpleBootFront.prototype.createDomRender = function (obj) {
169
+ var component = (0, Component_1.getComponent)(obj);
170
+ if (component && typeof obj === 'object') {
171
+ return DomRender_1.DomRender.run(obj, undefined, this.domRenderConfig);
172
+ }
173
+ return obj;
174
+ };
175
+ SimpleBootFront.prototype.initRun = function (otherInstanceSim) {
176
+ var _this = this;
177
+ var _a, _b, _c, _d, _e;
178
+ _super.prototype.run.call(this, otherInstanceSim);
179
+ this.initDomRenderScripts();
180
+ this.initDomRenderTargetElements();
181
+ this.navigation = this.simstanceManager.getOrNewSim(Navigation_1.Navigation);
182
+ var routerAtomic = new SimAtomic_1.SimAtomic(this.rootRouter, this.getSimstanceManager());
183
+ var target = this.option.window.document.querySelector(this.option.selector);
184
+ if (target && routerAtomic.value) {
185
+ var component = routerAtomic.getConfig(Component_1.ComponentMetadataKey);
186
+ 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>".concat(it, "</style>"); })) !== null && _b !== void 0 ? _b : []).join(' ');
187
+ target.innerHTML = "".concat(styles, " ").concat((_c = component === null || component === void 0 ? void 0 : component.template) !== null && _c !== void 0 ? _c : '');
188
+ var val = routerAtomic.value;
189
+ var domRenderProxy = val._DomRender_proxy;
190
+ domRenderProxy.initRender(target);
191
+ (_e = (_d = val) === null || _d === void 0 ? void 0 : _d.onInit) === null || _e === void 0 ? void 0 : _e.call(_d);
192
+ }
193
+ this.option.window.addEventListener('intent', function (event) {
194
+ var cevent = event;
195
+ _this.publishIntent(new Intent_1.Intent(cevent.detail.uri, cevent.detail.data, event));
196
+ });
197
+ this.option.window.addEventListener('popstate', function (event) {
198
+ var _a;
199
+ var intent = new Intent_1.Intent((_a = _this.navigation.url) !== null && _a !== void 0 ? _a : '');
200
+ _this.routing(intent).then(function (it) {
201
+ _this.afterSetting();
202
+ });
203
+ });
204
+ };
205
+ SimpleBootFront.prototype.goRouting = function (url) {
206
+ var _a;
207
+ return __awaiter(this, void 0, void 0, function () {
208
+ var intent, data;
209
+ return __generator(this, function (_b) {
210
+ switch (_b.label) {
211
+ case 0:
212
+ this.navigation.goNoPopStateEvent(url);
213
+ intent = new Intent_1.Intent((_a = this.navigation.url) !== null && _a !== void 0 ? _a : '');
214
+ return [4, this.routing(intent)];
215
+ case 1:
216
+ data = _b.sent();
217
+ this.afterSetting();
218
+ return [2, data];
219
+ }
220
+ });
221
+ });
222
+ };
223
+ SimpleBootFront.prototype.runRouting = function (otherInstanceSim, url) {
224
+ var _a;
225
+ return __awaiter(this, void 0, void 0, function () {
226
+ var intent, data;
227
+ return __generator(this, function (_b) {
228
+ switch (_b.label) {
229
+ case 0:
230
+ this.initRun(otherInstanceSim);
231
+ if (url) {
232
+ this.navigation.goNoPopStateEvent(url);
233
+ }
234
+ intent = new Intent_1.Intent((_a = this.navigation.url) !== null && _a !== void 0 ? _a : '');
235
+ return [4, this.routing(intent)];
236
+ case 1:
237
+ data = _b.sent();
238
+ this.afterSetting();
239
+ return [2, data];
240
+ }
241
+ });
242
+ });
243
+ };
244
+ SimpleBootFront.prototype.run = function (otherInstanceSim, url) {
245
+ this.initRun(otherInstanceSim);
246
+ if (url) {
247
+ this.navigation.go(url);
248
+ }
249
+ this.option.window.dispatchEvent(new Event('popstate'));
250
+ return this;
251
+ };
252
+ SimpleBootFront.prototype.afterSetting = function () {
253
+ var _this = this;
254
+ this.option.window.document.querySelectorAll('[router-link]').forEach(function (it) {
255
+ var _a, _b, _c, _d;
256
+ var link = it.getAttribute('router-link');
257
+ if (link) {
258
+ var activeClasss = it.getAttribute('router-active-class');
259
+ var aClasss = activeClasss === null || activeClasss === void 0 ? void 0 : activeClasss.split(',');
260
+ var inActiveClasss = it.getAttribute('router-inactive-class');
261
+ var iClasss = inActiveClasss === null || inActiveClasss === void 0 ? void 0 : inActiveClasss.split(',');
262
+ if (_this.navigation.path === link) {
263
+ if (aClasss && aClasss.length > 0) {
264
+ (_a = it.classList).add.apply(_a, aClasss);
265
+ }
266
+ if (iClasss && iClasss.length > 0) {
267
+ (_b = it.classList).remove.apply(_b, iClasss);
268
+ }
269
+ }
270
+ else {
271
+ if (aClasss && aClasss.length > 0) {
272
+ (_c = it.classList).remove.apply(_c, aClasss);
273
+ }
274
+ if (iClasss && iClasss.length > 0) {
275
+ (_d = it.classList).add.apply(_d, iClasss);
276
+ }
277
+ }
278
+ }
279
+ });
280
+ };
281
+ SimpleBootFront.prototype.initDomRenderScripts = function () {
282
+ var _this = this;
283
+ var simstanceManager = this.simstanceManager;
284
+ Script_1.scripts.forEach(function (val, name) {
285
+ _this.domRenderConfig.scripts[name] = function () {
286
+ var args = [];
287
+ for (var _i = 0; _i < arguments.length; _i++) {
288
+ args[_i] = arguments[_i];
289
+ }
290
+ var obj;
291
+ try {
292
+ obj = simstanceManager.getOrNewSim(val);
293
+ }
294
+ catch (e) {
295
+ obj = simstanceManager.newSim(val);
296
+ }
297
+ var render = this.__render;
298
+ var scriptRunnable = obj;
299
+ if (render.rawset) {
300
+ scriptRunnable.rawSets.set(render.rawset, this);
301
+ }
302
+ return scriptRunnable.run.apply(scriptRunnable, args);
303
+ };
304
+ });
305
+ };
306
+ SimpleBootFront.prototype.initDomRenderTargetElements = function () {
307
+ var _this = this;
308
+ var selectors = Component_1.componentSelectors;
309
+ selectors.forEach(function (val, name) {
310
+ var component = (0, Component_1.getComponent)(val);
311
+ var items = RawSet_1.RawSet.createComponentTargetElement(name, function (e, obj, r) {
312
+ var newSim = _this.simstanceManager.newSim(val);
313
+ return newSim;
314
+ }, component === null || component === void 0 ? void 0 : component.template, component === null || component === void 0 ? void 0 : component.styles, _this.domRenderConfig.scripts, _this.domRenderConfig);
315
+ _this.domRenderTargetElements.push(items);
316
+ });
317
+ };
318
+ SimpleBootFront.prototype.getSimstanceManager = function () {
319
+ return this.simstanceManager;
320
+ };
321
+ SimpleBootFront.prototype.go = function (url) {
322
+ var _a;
323
+ (_a = this.getSimstanceManager().getOrNewSim(Navigation_1.Navigation)) === null || _a === void 0 ? void 0 : _a.go(url);
324
+ };
325
+ return SimpleBootFront;
326
+ }(SimpleApplication_1.SimpleApplication));
327
+ exports.SimpleBootFront = SimpleBootFront;
@@ -1,11 +1,11 @@
1
- import { ConstructorType, GenericClassDecorator } from 'simple-boot-core/types/Types';
2
- export declare const componentSelectors: Map<string, ConstructorType<any>>;
3
- export interface ComponentConfig {
4
- selector?: string;
5
- template?: string;
6
- styles?: (string)[];
7
- using?: (ConstructorType<any>)[];
8
- }
9
- export declare const ComponentMetadataKey: unique symbol;
10
- export declare const Component: (config?: ComponentConfig | undefined) => GenericClassDecorator<ConstructorType<any>>;
11
- export declare const getComponent: (target: ConstructorType<any> | Function | any) => ComponentConfig | undefined;
1
+ import { ConstructorType, GenericClassDecorator } from 'simple-boot-core/types/Types';
2
+ export declare const componentSelectors: Map<string, ConstructorType<any>>;
3
+ export interface ComponentConfig {
4
+ selector?: string;
5
+ template?: string;
6
+ styles?: (string)[];
7
+ using?: (ConstructorType<any>)[];
8
+ }
9
+ export declare const ComponentMetadataKey: unique symbol;
10
+ export declare const Component: (config?: ComponentConfig | undefined) => GenericClassDecorator<ConstructorType<any>>;
11
+ export declare const getComponent: (target: ConstructorType<any> | Function | any) => ComponentConfig | undefined;