simple-boot-front 1.0.98 → 1.0.101

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.
@@ -50,6 +50,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
50
50
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
51
  }
52
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
+ };
53
62
  Object.defineProperty(exports, "__esModule", { value: true });
54
63
  exports.SimpleBootFront = void 0;
55
64
  var SimFrontOption_1 = require("./option/SimFrontOption");
@@ -66,8 +75,9 @@ var SimstanceManager_1 = require("simple-boot-core/simstance/SimstanceManager");
66
75
  var IntentManager_1 = require("simple-boot-core/intent/IntentManager");
67
76
  var RouterManager_1 = require("simple-boot-core/route/RouterManager");
68
77
  var ScriptUtils_1 = require("dom-render/utils/script/ScriptUtils");
69
- var SimGlobal_1 = require("simple-boot-core/global/SimGlobal");
70
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");
71
81
  var SimpleBootFront = (function (_super) {
72
82
  __extends(SimpleBootFront, _super);
73
83
  function SimpleBootFront(rootRouter, option) {
@@ -78,44 +88,71 @@ var SimpleBootFront = (function (_super) {
78
88
  _this.domRenderTargetElements = [];
79
89
  _this.domRenderTargetAttrs = [];
80
90
  _this.domRenderConfig = {
91
+ window: option.window,
81
92
  targetElements: _this.domRenderTargetElements,
82
93
  targetAttrs: _this.domRenderTargetAttrs,
83
94
  onElementInit: function (name, obj, rawSet, targetElement) {
84
95
  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);
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
+ }
86
109
  },
87
- onAttrInit: function (attrName, attrValue, obj) {
110
+ onAttrInit: function (attrName, attrValue, obj, rawSet) {
88
111
  var _a, _b;
89
112
  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);
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
+ }
92
127
  }
93
128
  },
94
- scripts: { 'application': _this },
129
+ scripts: { application: _this },
95
130
  applyEvents: [{
96
- attrName: 'router-link', callBack: function (elements, attrValue, obj) {
131
+ attrName: 'router-link',
132
+ callBack: function (elements, attrValue, obj) {
97
133
  elements.addEventListener('click', function (event) {
98
134
  var _a;
99
- (_a = (0, SimGlobal_1.SimGlobal)().application.simstanceManager.getOrNewSim(Navigation_1.Navigation)) === null || _a === void 0 ? void 0 : _a.go(attrValue);
135
+ (_a = _this.getSimstanceManager().getOrNewSim(Navigation_1.Navigation)) === null || _a === void 0 ? void 0 : _a.go(attrValue);
100
136
  });
101
137
  }
102
138
  }],
103
139
  proxyExcludeTyps: _this.domRendoerExcludeProxy
104
140
  };
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;
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);
117
151
  }
152
+ var fag = _this.option.window.document.createDocumentFragment();
153
+ return fag;
118
154
  });
155
+ _this.domRenderTargetAttrs.push(targetAttribute);
119
156
  option.proxy = {
120
157
  onProxy: function (it) { return _this.createDomRender(it); }
121
158
  };
@@ -124,7 +161,7 @@ var SimpleBootFront = (function (_super) {
124
161
  SimpleBootFront.prototype.getComponentInnerHtml = function (targetObj) {
125
162
  var _a, _b, _c;
126
163
  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(' ');
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(' ');
128
165
  var template = ((_c = component === null || component === void 0 ? void 0 : component.template) !== null && _c !== void 0 ? _c : '');
129
166
  return styles + template;
130
167
  };
@@ -135,20 +172,19 @@ var SimpleBootFront = (function (_super) {
135
172
  }
136
173
  return obj;
137
174
  };
138
- SimpleBootFront.prototype.run = function () {
175
+ SimpleBootFront.prototype.initRun = function (otherInstanceSim) {
139
176
  var _this = this;
140
177
  var _a, _b, _c, _d, _e;
141
- _super.prototype.run.call(this);
178
+ _super.prototype.run.call(this, otherInstanceSim);
142
179
  this.initDomRenderScripts();
143
180
  this.initDomRenderTargetElements();
144
181
  this.navigation = this.simstanceManager.getOrNewSim(Navigation_1.Navigation);
145
- var routerAtomic = new SimAtomic_1.SimAtomic(this.rootRouter);
182
+ var routerAtomic = new SimAtomic_1.SimAtomic(this.rootRouter, this.getSimstanceManager());
146
183
  var target = this.option.window.document.querySelector(this.option.selector);
147
184
  if (target && routerAtomic.value) {
148
185
  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 : '');
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 : '');
152
188
  var val = routerAtomic.value;
153
189
  var domRenderProxy = val._DomRender_proxy;
154
190
  domRenderProxy.initRender(target);
@@ -160,15 +196,58 @@ var SimpleBootFront = (function (_super) {
160
196
  });
161
197
  this.option.window.addEventListener('popstate', function (event) {
162
198
  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
- }); });
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
+ });
170
242
  });
243
+ };
244
+ SimpleBootFront.prototype.run = function (otherInstanceSim, url) {
245
+ this.initRun(otherInstanceSim);
246
+ if (url) {
247
+ this.navigation.go(url);
248
+ }
171
249
  this.option.window.dispatchEvent(new Event('popstate'));
250
+ return this;
172
251
  };
173
252
  SimpleBootFront.prototype.afterSetting = function () {
174
253
  var _this = this;
@@ -208,7 +287,7 @@ var SimpleBootFront = (function (_super) {
208
287
  for (var _i = 0; _i < arguments.length; _i++) {
209
288
  args[_i] = arguments[_i];
210
289
  }
211
- var obj = undefined;
290
+ var obj;
212
291
  try {
213
292
  obj = simstanceManager.getOrNewSim(val);
214
293
  }
@@ -217,7 +296,9 @@ var SimpleBootFront = (function (_super) {
217
296
  }
218
297
  var render = this.__render;
219
298
  var scriptRunnable = obj;
220
- scriptRunnable.rawSets.set(render.rawset, this);
299
+ if (render.rawset) {
300
+ scriptRunnable.rawSets.set(render.rawset, this);
301
+ }
221
302
  return scriptRunnable.run.apply(scriptRunnable, args);
222
303
  };
223
304
  });
@@ -227,13 +308,20 @@ var SimpleBootFront = (function (_super) {
227
308
  var selectors = Component_1.componentSelectors;
228
309
  selectors.forEach(function (val, name) {
229
310
  var component = (0, Component_1.getComponent)(val);
230
- var items = RawSet_1.RawSet.createComponentTargetElement(name, function (e, o, r) {
311
+ var items = RawSet_1.RawSet.createComponentTargetElement(name, function (e, obj, r) {
231
312
  var newSim = _this.simstanceManager.newSim(val);
232
313
  return newSim;
233
- }, component === null || component === void 0 ? void 0 : component.template, component === null || component === void 0 ? void 0 : component.styles, _this.domRenderConfig.scripts);
314
+ }, component === null || component === void 0 ? void 0 : component.template, component === null || component === void 0 ? void 0 : component.styles, _this.domRenderConfig);
234
315
  _this.domRenderTargetElements.push(items);
235
316
  });
236
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
+ };
237
325
  return SimpleBootFront;
238
326
  }(SimpleApplication_1.SimpleApplication));
239
327
  exports.SimpleBootFront = SimpleBootFront;
@@ -1,19 +1,4 @@
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
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.getComponent = exports.Component = exports.ComponentMetadataKey = exports.componentSelectors = void 0;
19
4
  var ReflectUtils_1 = require("simple-boot-core/utils/reflect/ReflectUtils");
@@ -27,17 +12,8 @@ var Component = function (config) {
27
12
  if (!config.selector) {
28
13
  config.selector = target.name;
29
14
  }
30
- exports.componentSelectors.set(config.selector.toLowerCase(), target);
31
15
  ReflectUtils_1.ReflectUtils.defineMetadata(exports.ComponentMetadataKey, config, target);
32
- return (function (_super) {
33
- __extends(class_1, _super);
34
- function class_1() {
35
- var _this = _super !== null && _super.apply(this, arguments) || this;
36
- _this.__componentInstances = {};
37
- return _this;
38
- }
39
- return class_1;
40
- }(target));
16
+ exports.componentSelectors.set(config.selector.toLowerCase(), target);
41
17
  };
42
18
  };
43
19
  exports.Component = Component;
@@ -0,0 +1,3 @@
1
+ export declare enum InjectFrontSituationType {
2
+ OPENER = "SIMPLE_BOOT_FRONT://OPENER"
3
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InjectFrontSituationType = void 0;
4
+ var InjectFrontSituationType;
5
+ (function (InjectFrontSituationType) {
6
+ InjectFrontSituationType["OPENER"] = "SIMPLE_BOOT_FRONT://OPENER";
7
+ })(InjectFrontSituationType = exports.InjectFrontSituationType || (exports.InjectFrontSituationType = {}));
@@ -1,3 +1,8 @@
1
+ import { RawSet } from 'dom-render/RawSet';
2
+ export declare type OnInitParameter = {
3
+ makerObj: any;
4
+ rawSet: RawSet;
5
+ };
1
6
  export interface OnInit {
2
- onInit(): void;
7
+ onInit(...data: any): any;
3
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simple-boot-front",
3
- "version": "1.0.98",
3
+ "version": "1.0.101",
4
4
  "main": "SimpleApplication.js",
5
5
  "license": "MIT",
6
6
  "description": "front end SPA frameworks",
@@ -54,12 +54,14 @@
54
54
  "npm-build": "rm -rf dist && tsc --outDir dist --declarationDir dist && cp package-prod.json dist/package.json && cp README.MD dist",
55
55
  "npm-publish": "npm run npm-build && npm publish ./dist",
56
56
  "tsc": "tsc",
57
+ "setting:root-dist": "rm -rf ../dist-simple-boot-front && mkdirp ../dist-simple-boot-front && cp package-root-dist.json ../dist-simple-boot-front/package.json",
58
+ "tsc:root-dist": "npm run setting:root-dist && tsc --outDir ../dist-simple-boot-front --declarationDir ../dist-simple-boot-front",
57
59
  "tsc:watch": "rm -rf ./dist && mkdir dist && cp package.json dist && tsc --watch --sourceMap true",
60
+ "tsc:watch:root-dist": "npm run setting:root-dist && tsc --outDir ../dist-simple-boot-front --declarationDir ../dist-simple-boot-front --watch --sourceMap true",
58
61
  "tsc:watch:dev": "rm -rf ./dist && mkdir dist && cp package-dev.json dist && tsc --watch --sourceMap true",
59
62
  "test": "jest --detectOpenHandles --forceExit"
60
63
  },
61
- "alias": {
62
- },
64
+ "alias": {},
63
65
  "devDependencies": {
64
66
  "@types/jest": "^26.0.22",
65
67
  "@typescript-eslint/eslint-plugin": "^4.16.1",
@@ -72,11 +74,10 @@
72
74
  "jest": "^26.6.3",
73
75
  "supertest": "^6.1.3",
74
76
  "ts-jest": "^26.5.4",
75
- "typescript": "^4.3.5"
77
+ "typescript": "^4.4.3"
76
78
  },
77
79
  "dependencies": {
78
- "dom-render": "^1.0.66",
79
- "simple-boot-core": "^1.0.22",
80
- "reflect-metadata": "^0.1.13"
80
+ "dom-render": "^1.0.70",
81
+ "simple-boot-core": "^1.0.29"
81
82
  }
82
83
  }
@@ -1,8 +1,11 @@
1
+ import { SimFrontOption } from '../option/SimFrontOption';
1
2
  export declare class CookieService {
3
+ private option;
4
+ constructor(option: SimFrontOption);
2
5
  get(key: string): string | undefined;
3
6
  getAll(): {
4
7
  [k: string]: string;
5
8
  };
6
- set(name: string, value: string, exp: number): void;
7
- delete(name: string): void;
9
+ set(name: string, value: string, exp?: number): void;
10
+ delete(name: string, path?: string): void;
8
11
  }
@@ -5,11 +5,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
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
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
12
  exports.CookieService = void 0;
10
13
  var SimDecorator_1 = require("simple-boot-core/decorators/SimDecorator");
14
+ var SimFrontOption_1 = require("../option/SimFrontOption");
11
15
  var CookieService = (function () {
12
- function CookieService() {
16
+ function CookieService(option) {
17
+ this.option = option;
13
18
  }
14
19
  CookieService.prototype.get = function (key) {
15
20
  return this.getAll()[key];
@@ -17,7 +22,7 @@ var CookieService = (function () {
17
22
  CookieService.prototype.getAll = function () {
18
23
  var _a;
19
24
  var all = {};
20
- var strings = (_a = document.cookie.split(';')) !== null && _a !== void 0 ? _a : [];
25
+ var strings = (_a = this.option.window.document.cookie.split(';')) !== null && _a !== void 0 ? _a : [];
21
26
  strings.forEach(function (it) {
22
27
  var set = it.split('=');
23
28
  if (set[0] && set[1] && set[0].trim().length > 0 && set[1].trim().length > 0) {
@@ -27,15 +32,22 @@ var CookieService = (function () {
27
32
  return all;
28
33
  };
29
34
  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=/';
35
+ if (exp === undefined) {
36
+ this.option.window.document.cookie = name + '=' + value + ';path=/';
37
+ }
38
+ else {
39
+ var date = new Date();
40
+ date.setTime(date.getTime() + exp);
41
+ this.option.window.document.cookie = name + '=' + value + ';expires=' + date.toUTCString() + ';path=/';
42
+ }
33
43
  };
34
- CookieService.prototype.delete = function (name) {
35
- document.cookie = name + '=; expires=Thu, 01 Jan 1999 00:00:10 GMT;';
44
+ CookieService.prototype.delete = function (name, path) {
45
+ if (path === void 0) { path = '/'; }
46
+ this.option.window.document.cookie = name + '=; expires=Thu, 01 Jan 1999 00:00:10 GMT;' + " path=".concat(path);
36
47
  };
37
48
  CookieService = __decorate([
38
- (0, SimDecorator_1.Sim)()
49
+ (0, SimDecorator_1.Sim)(),
50
+ __metadata("design:paramtypes", [SimFrontOption_1.SimFrontOption])
39
51
  ], CookieService);
40
52
  return CookieService;
41
53
  }());
@@ -0,0 +1,11 @@
1
+ import { SimFrontOption } from '../option/SimFrontOption';
2
+ export declare class MetaTagService {
3
+ option: SimFrontOption;
4
+ constructor(option: SimFrontOption);
5
+ setMetaTag(selector: string, set: {
6
+ [key: string]: string;
7
+ }): void;
8
+ createMetaTag(set: {
9
+ [p: string]: string;
10
+ }): HTMLMetaElement;
11
+ }
@@ -0,0 +1,52 @@
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
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.MetaTagService = void 0;
13
+ var SimDecorator_1 = require("simple-boot-core/decorators/SimDecorator");
14
+ var SimFrontOption_1 = require("../option/SimFrontOption");
15
+ var MetaTagService = (function () {
16
+ function MetaTagService(option) {
17
+ this.option = option;
18
+ }
19
+ MetaTagService.prototype.setMetaTag = function (selector, set) {
20
+ var target = this.option.window.document.querySelector(selector);
21
+ if (!target) {
22
+ this.option.window.document.head.appendChild(this.createMetaTag(set));
23
+ }
24
+ else {
25
+ Object.entries(set).forEach(function (_a) {
26
+ var key = _a[0], value = _a[1];
27
+ if (null === value) {
28
+ target.removeAttribute(key);
29
+ }
30
+ else {
31
+ target.setAttribute(key, value);
32
+ }
33
+ });
34
+ }
35
+ };
36
+ MetaTagService.prototype.createMetaTag = function (set) {
37
+ var meta = this.option.window.document.createElement('meta');
38
+ Object.entries(set).forEach(function (_a) {
39
+ var key = _a[0], value = _a[1];
40
+ if (value !== null) {
41
+ meta.setAttribute(key, value);
42
+ }
43
+ });
44
+ return meta;
45
+ };
46
+ MetaTagService = __decorate([
47
+ (0, SimDecorator_1.Sim)(),
48
+ __metadata("design:paramtypes", [SimFrontOption_1.SimFrontOption])
49
+ ], MetaTagService);
50
+ return MetaTagService;
51
+ }());
52
+ exports.MetaTagService = MetaTagService;
@@ -1,12 +1,18 @@
1
1
  import { SimFrontOption } from '../option/SimFrontOption';
2
2
  export declare class Navigation {
3
- private option;
3
+ option: SimFrontOption;
4
4
  constructor(option: SimFrontOption);
5
+ get url(): string;
5
6
  get path(): string;
6
7
  get queryParams(): Map<string, string>;
8
+ get queryParamsObject(): any;
7
9
  get pathInfo(): {
8
10
  path: string;
9
11
  queryParams: Map<string, string>;
10
12
  };
11
- go(path: string, data?: {}, title?: string): void;
13
+ reload(): void;
14
+ pathAndSearch(): string;
15
+ goNoPopStateEvent(path: string, data?: any, title?: string): void;
16
+ go(path: string, data?: any, title?: string): void;
17
+ state(): any;
12
18
  }
@@ -12,18 +12,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Navigation = void 0;
13
13
  var SimDecorator_1 = require("simple-boot-core/decorators/SimDecorator");
14
14
  var SimFrontOption_1 = require("../option/SimFrontOption");
15
- var LocationUtils_1 = require("../utils/window/LocationUtils");
15
+ var LocationUtils_1 = require("dom-render/utils/location/LocationUtils");
16
16
  var Navigation = (function () {
17
17
  function Navigation(option) {
18
18
  this.option = option;
19
19
  }
20
+ Object.defineProperty(Navigation.prototype, "url", {
21
+ get: function () {
22
+ var queryParams = this.queryParamsObject;
23
+ var queryString = Object.entries(queryParams).map(function (_a) {
24
+ var key = _a[0], value = _a[1];
25
+ return "".concat(key, "=").concat(value);
26
+ }).join('&');
27
+ var path = this.path;
28
+ return path + (queryString.length > 0 ? ('?' + queryString) : '');
29
+ },
30
+ enumerable: false,
31
+ configurable: true
32
+ });
20
33
  Object.defineProperty(Navigation.prototype, "path", {
21
34
  get: function () {
22
35
  if (SimFrontOption_1.UrlType.path === this.option.urlType) {
23
- return LocationUtils_1.LocationUtils.path();
36
+ return LocationUtils_1.LocationUtils.path(this.option.window);
24
37
  }
25
38
  else if (SimFrontOption_1.UrlType.hash === this.option.urlType) {
26
- return LocationUtils_1.LocationUtils.hashPath();
39
+ return LocationUtils_1.LocationUtils.hashPath(this.option.window);
27
40
  }
28
41
  else {
29
42
  return '';
@@ -35,10 +48,10 @@ var Navigation = (function () {
35
48
  Object.defineProperty(Navigation.prototype, "queryParams", {
36
49
  get: function () {
37
50
  if (SimFrontOption_1.UrlType.path === this.option.urlType) {
38
- return LocationUtils_1.LocationUtils.pathQueryParams();
51
+ return LocationUtils_1.LocationUtils.pathQueryParams(this.option.window);
39
52
  }
40
53
  else if (SimFrontOption_1.UrlType.hash === this.option.urlType) {
41
- return LocationUtils_1.LocationUtils.hashQueryParams();
54
+ return LocationUtils_1.LocationUtils.hashQueryParams(this.option.window);
42
55
  }
43
56
  else {
44
57
  return new Map();
@@ -47,6 +60,21 @@ var Navigation = (function () {
47
60
  enumerable: false,
48
61
  configurable: true
49
62
  });
63
+ Object.defineProperty(Navigation.prototype, "queryParamsObject", {
64
+ get: function () {
65
+ if (SimFrontOption_1.UrlType.path === this.option.urlType) {
66
+ return LocationUtils_1.LocationUtils.pathQueryParamsObject(this.option.window);
67
+ }
68
+ else if (SimFrontOption_1.UrlType.hash === this.option.urlType) {
69
+ return LocationUtils_1.LocationUtils.hashQueryParamsObject(this.option.window);
70
+ }
71
+ else {
72
+ return {};
73
+ }
74
+ },
75
+ enumerable: false,
76
+ configurable: true
77
+ });
50
78
  Object.defineProperty(Navigation.prototype, "pathInfo", {
51
79
  get: function () {
52
80
  return { path: this.path, queryParams: this.queryParams };
@@ -54,17 +82,31 @@ var Navigation = (function () {
54
82
  enumerable: false,
55
83
  configurable: true
56
84
  });
57
- Navigation.prototype.go = function (path, data, title) {
85
+ Navigation.prototype.reload = function () {
86
+ this.option.window.dispatchEvent(new Event('popstate'));
87
+ };
88
+ Navigation.prototype.pathAndSearch = function () {
89
+ return this.option.window.location.pathname + this.option.window.location.search;
90
+ };
91
+ Navigation.prototype.goNoPopStateEvent = function (path, data, title) {
58
92
  if (data === void 0) { data = {}; }
59
93
  if (title === void 0) { title = ''; }
60
94
  if (SimFrontOption_1.UrlType.path === this.option.urlType) {
61
- history.pushState(data, title, path);
95
+ this.option.window.history.pushState(data, title, path);
62
96
  }
63
97
  else if (SimFrontOption_1.UrlType.hash === this.option.urlType) {
64
98
  path = '#' + path.substring(1);
65
- history.pushState(data, title, path);
99
+ this.option.window.history.pushState(data, title, path);
66
100
  }
67
- window.dispatchEvent(new Event('popstate'));
101
+ };
102
+ Navigation.prototype.go = function (path, data, title) {
103
+ if (data === void 0) { data = {}; }
104
+ if (title === void 0) { title = ''; }
105
+ this.goNoPopStateEvent(path, data, title);
106
+ this.option.window.dispatchEvent(new Event('popstate'));
107
+ };
108
+ Navigation.prototype.state = function () {
109
+ return this.option.window.history.state;
68
110
  };
69
111
  Navigation = __decorate([
70
112
  (0, SimDecorator_1.Sim)(),
@@ -0,0 +1,12 @@
1
+ import { SimFrontOption } from '../option/SimFrontOption';
2
+ export declare class StorageService {
3
+ option: SimFrontOption;
4
+ constructor(option: SimFrontOption);
5
+ setLocalStorageItem(k: string, v: string | any, window?: Window): void;
6
+ getLocalStorageItem(k: string, window?: Window): string | null;
7
+ cutLocalStorageItem(k: string, window?: Window): string | null;
8
+ removeLocalStorageItem(k: string, window?: Window): void;
9
+ getLocalStorageJsonItem<T>(k: string, window?: Window): T | undefined;
10
+ cutLocalStorageJsonItem<T>(k: string, window?: Window): T | undefined;
11
+ clearLocalStorage(window?: Window): void;
12
+ }