@operato/shell 1.0.14 → 1.0.16
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/CHANGELOG.md +17 -0
- package/dist/src/actions/app.d.ts +11 -0
- package/dist/src/actions/app.js +12 -0
- package/dist/src/actions/app.js.map +1 -0
- package/dist/src/actions/const.d.ts +6 -0
- package/dist/src/actions/const.js +7 -0
- package/dist/src/actions/const.js.map +1 -0
- package/dist/src/actions/index.d.ts +3 -0
- package/dist/src/actions/index.js +4 -0
- package/dist/src/actions/index.js.map +1 -0
- package/dist/src/actions/route.d.ts +20 -0
- package/dist/src/actions/route.js +77 -0
- package/dist/src/actions/route.js.map +1 -0
- package/dist/src/app/app-style.d.ts +1 -0
- package/dist/src/app/app-style.js +69 -0
- package/dist/src/app/app-style.js.map +1 -0
- package/dist/src/app/app.d.ts +1 -0
- package/dist/src/app/app.js +193 -0
- package/dist/src/app/app.js.map +1 -0
- package/dist/src/app/pages/page-404.d.ts +8 -0
- package/dist/src/app/pages/page-404.js +57 -0
- package/dist/src/app/pages/page-404.js.map +1 -0
- package/dist/src/app/pages/page-view.d.ts +16 -0
- package/dist/src/app/pages/page-view.js +131 -0
- package/dist/src/app/pages/page-view.js.map +1 -0
- package/dist/src/entries/public/home.d.ts +17 -0
- package/dist/src/entries/public/home.js +87 -0
- package/dist/src/entries/public/home.js.map +1 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +0 -1
- package/dist/src/index.js.map +1 -0
- package/dist/src/module-importer.import +0 -0
- package/dist/src/object-store.d.ts +16 -0
- package/dist/src/object-store.js +129 -0
- package/dist/src/object-store.js.map +1 -0
- package/dist/src/reducers/app.d.ts +36 -0
- package/dist/src/reducers/app.js +36 -0
- package/dist/src/reducers/app.js.map +1 -0
- package/dist/src/reducers/route.d.ts +16 -0
- package/dist/src/reducers/route.js +57 -0
- package/dist/src/reducers/route.js.map +1 -0
- package/dist/src/store.d.ts +6 -0
- package/dist/src/store.js +15 -0
- package/dist/src/store.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +4 -3
- package/src/index.ts +0 -1
@@ -0,0 +1,131 @@
|
|
1
|
+
import { __decorate } from "tslib";
|
2
|
+
import { LitElement } from 'lit';
|
3
|
+
import { property } from 'lit/decorators.js';
|
4
|
+
import isEqual from 'lodash-es/isEqual';
|
5
|
+
import { UPDATE_CONTEXT } from '../../actions/const';
|
6
|
+
import { store } from '../../store';
|
7
|
+
function diff(after, before) {
|
8
|
+
var changed = false;
|
9
|
+
var changes = {};
|
10
|
+
Object.getOwnPropertyNames(after).forEach(function (key) {
|
11
|
+
let before_val = before[key];
|
12
|
+
let after_val = after[key];
|
13
|
+
if (!isEqual(before_val, after_val)) {
|
14
|
+
changes[key] = after_val;
|
15
|
+
changed = true;
|
16
|
+
}
|
17
|
+
});
|
18
|
+
return changed && changes;
|
19
|
+
}
|
20
|
+
export class PageView extends LitElement {
|
21
|
+
constructor() {
|
22
|
+
super(...arguments);
|
23
|
+
this.active = false;
|
24
|
+
}
|
25
|
+
// Only render this page if it's actually visible.
|
26
|
+
shouldUpdate(changes) {
|
27
|
+
var active = String(this.active) == 'true';
|
28
|
+
var { active: oldActive = false } = this._oldLifecycleInfo$ || {};
|
29
|
+
/*
|
30
|
+
* page lifecycle
|
31
|
+
* case 1. page가 새로 activate 되었다.
|
32
|
+
* case 2. page가 active 상태에서 lifecycle 정보가 바뀌었다.
|
33
|
+
**/
|
34
|
+
if (active) {
|
35
|
+
this.pageUpdate({
|
36
|
+
active
|
37
|
+
});
|
38
|
+
}
|
39
|
+
else if (oldActive) {
|
40
|
+
this.pageUpdate({
|
41
|
+
active
|
42
|
+
});
|
43
|
+
}
|
44
|
+
return active;
|
45
|
+
}
|
46
|
+
/* lifecycle */
|
47
|
+
async pageUpdate(changes = {}, force = false) {
|
48
|
+
var before = this._oldLifecycleInfo$ || {};
|
49
|
+
var after = {
|
50
|
+
...before,
|
51
|
+
...this.lifecycle,
|
52
|
+
contextPath: this.contextPath,
|
53
|
+
...changes
|
54
|
+
};
|
55
|
+
if (!('initialized' in changes) && after.active && !before.initialized) {
|
56
|
+
after.initialized = true;
|
57
|
+
}
|
58
|
+
if (force) {
|
59
|
+
after.updated = Date.now();
|
60
|
+
}
|
61
|
+
var changed = diff(after, before);
|
62
|
+
if (!changed) {
|
63
|
+
return;
|
64
|
+
}
|
65
|
+
this._oldLifecycleInfo$ = after;
|
66
|
+
/* page의 이미 초기화된 상태에서 contextPath가 바뀐다면, 무조건 page가 리셋되어야 한다. */
|
67
|
+
if (before.initialized && changed.contextPath) {
|
68
|
+
await this.pageReset();
|
69
|
+
return;
|
70
|
+
}
|
71
|
+
if (changed.initialized) {
|
72
|
+
await this.pageInitialized(after);
|
73
|
+
}
|
74
|
+
if ('initialized' in changed) {
|
75
|
+
if (changed.initialized) {
|
76
|
+
/*
|
77
|
+
* 방금 초기화된 경우라면, 엘리먼트들이 만들어지지 않았을 가능성이 있으므로,
|
78
|
+
* 다음 animationFrame에서 pageUpdated 콜백을 호출한다.
|
79
|
+
*/
|
80
|
+
requestAnimationFrame(async () => {
|
81
|
+
await this.pageUpdated(changed, after, before);
|
82
|
+
/* active page인 경우에는, page Context 갱신도 필요할 것이다. */
|
83
|
+
after.active && this.updateContext();
|
84
|
+
});
|
85
|
+
}
|
86
|
+
else {
|
87
|
+
await this.pageDisposed(after);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
else {
|
91
|
+
await this.pageUpdated(changed, after, before);
|
92
|
+
/* active page인 경우에는, page Context 갱신도 필요할 것이다. */
|
93
|
+
after.active && this.updateContext();
|
94
|
+
}
|
95
|
+
}
|
96
|
+
async pageReset() {
|
97
|
+
var { initialized } = this._oldLifecycleInfo$ || {};
|
98
|
+
if (initialized) {
|
99
|
+
await this.pageDispose();
|
100
|
+
await this.pageUpdate({}, true);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
async pageDispose() {
|
104
|
+
await this.pageUpdate({
|
105
|
+
initialized: false
|
106
|
+
});
|
107
|
+
}
|
108
|
+
pageInitialized(pageInfo) { }
|
109
|
+
pageUpdated(changes, after, before) { }
|
110
|
+
pageDisposed(pageInfo) { }
|
111
|
+
/* context */
|
112
|
+
updateContext(override) {
|
113
|
+
store.dispatch({
|
114
|
+
type: UPDATE_CONTEXT,
|
115
|
+
context: override ? { ...this.context, ...override } : this.context
|
116
|
+
});
|
117
|
+
}
|
118
|
+
get context() {
|
119
|
+
return {};
|
120
|
+
}
|
121
|
+
}
|
122
|
+
__decorate([
|
123
|
+
property({ type: Boolean })
|
124
|
+
], PageView.prototype, "active", void 0);
|
125
|
+
__decorate([
|
126
|
+
property({ type: Object })
|
127
|
+
], PageView.prototype, "lifecycle", void 0);
|
128
|
+
__decorate([
|
129
|
+
property({ type: String, attribute: 'context-path' })
|
130
|
+
], PageView.prototype, "contextPath", void 0);
|
131
|
+
//# sourceMappingURL=page-view.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"page-view.js","sourceRoot":"","sources":["../../../../src/app/pages/page-view.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAkB,MAAM,KAAK,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,OAAO,MAAM,mBAAmB,CAAA;AAEvC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC,SAAS,IAAI,CAAC,KAAU,EAAE,MAAW;IACnC,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,IAAI,OAAO,GAA2B,EAAE,CAAA;IAExC,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,UAAU,GAAG;QACrD,IAAI,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;QAC5B,IAAI,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA;QAE1B,IAAI,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AC,WAAW;QACf,MAAM,IAAI,CAAC,UAAU,CAAC;YACpB,WAAW,EAAE,KAAK;SACnB,CAAC,CAAA;IACJ,CAAC;IAED,eAAe,CAAC,QAAa,IAAG,CAAC;IACjC,WAAW,CAAC,OAAY,EAAE,KAAU,EAAE,MAAW,IAAG,CAAC;IACrD,YAAY,CAAC,QAAa,IAAG,CAAC;IAE9B,aAAa;IACb,aAAa,CAAC,QAAc;QAC1B,KAAK,CAAC,QAAQ,CAAC;YACb,IAAI,EAAE,cAAc;YACpB,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO;SACpE,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,OAAO;QACT,OAAO,EAAE,CAAA;IACX,CAAC;CACF;AA7F8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCAAwB;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAe;AACa;IAAtD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;6CAAqB","sourcesContent":["import { LitElement, PropertyValues } from 'lit'\nimport { property } from 'lit/decorators.js'\nimport isEqual from 'lodash-es/isEqual'\n\nimport { UPDATE_CONTEXT } from '../../actions/const'\nimport { store } from '../../store'\n\nfunction diff(after: any, before: any): any {\n var changed = false\n var changes: { [key: string]: any } = {}\n\n Object.getOwnPropertyNames(after).forEach(function (key) {\n let before_val = before[key]\n let after_val = after[key]\n\n if (!isEqual(before_val, after_val)) {\n changes[key] = after_val\n changed = true\n }\n })\n\n return changed && changes\n}\n\nexport class PageView extends LitElement {\n // Only render this page if it's actually visible.\n shouldUpdate(changes: PropertyValues<this>) {\n var active = String(this.active) == 'true'\n var { active: oldActive = false } = this._oldLifecycleInfo$ || {}\n\n /*\n * page lifecycle\n * case 1. page가 새로 activate 되었다.\n * case 2. page가 active 상태에서 lifecycle 정보가 바뀌었다.\n **/\n if (active) {\n this.pageUpdate({\n active\n })\n } else if (oldActive) {\n this.pageUpdate({\n active\n })\n }\n\n return active\n }\n\n @property({ type: Boolean }) active: boolean = false\n @property({ type: Object }) lifecycle: any\n @property({ type: String, attribute: 'context-path' }) contextPath?: string\n\n _oldLifecycleInfo$: any\n\n /* lifecycle */\n async pageUpdate(changes: any = {}, force: boolean = false) {\n var before = this._oldLifecycleInfo$ || {}\n\n var after = {\n ...before,\n ...this.lifecycle,\n contextPath: this.contextPath,\n ...changes\n }\n\n if (!('initialized' in changes) && after.active && !before.initialized) {\n after.initialized = true\n }\n\n if (force) {\n after.updated = Date.now()\n }\n\n var changed = diff(after, before)\n if (!changed) {\n return\n }\n\n this._oldLifecycleInfo$ = after\n\n /* page의 이미 초기화된 상태에서 contextPath가 바뀐다면, 무조건 page가 리셋되어야 한다. */\n if (before.initialized && changed.contextPath) {\n await this.pageReset()\n return\n }\n\n if (changed.initialized) {\n await this.pageInitialized(after)\n }\n\n if ('initialized' in changed) {\n if (changed.initialized) {\n /*\n * 방금 초기화된 경우라면, 엘리먼트들이 만들어지지 않았을 가능성이 있으므로,\n * 다음 animationFrame에서 pageUpdated 콜백을 호출한다.\n */\n requestAnimationFrame(async () => {\n await this.pageUpdated(changed, after, before)\n /* active page인 경우에는, page Context 갱신도 필요할 것이다. */\n after.active && this.updateContext()\n })\n } else {\n await this.pageDisposed(after)\n }\n } else {\n await this.pageUpdated(changed, after, before)\n /* active page인 경우에는, page Context 갱신도 필요할 것이다. */\n after.active && this.updateContext()\n }\n }\n\n async pageReset() {\n var { initialized } = this._oldLifecycleInfo$ || {}\n\n if (initialized) {\n await this.pageDispose()\n await this.pageUpdate({}, true)\n }\n }\n\n async pageDispose() {\n await this.pageUpdate({\n initialized: false\n })\n }\n\n pageInitialized(pageInfo: any) {}\n pageUpdated(changes: any, after: any, before: any) {}\n pageDisposed(pageInfo: any) {}\n\n /* context */\n updateContext(override?: any) {\n store.dispatch({\n type: UPDATE_CONTEXT,\n context: override ? { ...this.context, ...override } : this.context\n })\n }\n\n get context() {\n return {}\n }\n}\n"]}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import '@material/mwc-icon-button';
|
2
|
+
import '@material/mwc-button';
|
3
|
+
import { LitElement } from 'lit';
|
4
|
+
export declare class HomePage extends LitElement {
|
5
|
+
static styles: import("lit").CSSResult;
|
6
|
+
_applicationMeta?: {
|
7
|
+
icon: string;
|
8
|
+
title: string;
|
9
|
+
description: string;
|
10
|
+
};
|
11
|
+
render(): import("lit-html").TemplateResult<1>;
|
12
|
+
get applicationMeta(): {
|
13
|
+
icon: string;
|
14
|
+
title: string;
|
15
|
+
description: string;
|
16
|
+
};
|
17
|
+
}
|
@@ -0,0 +1,87 @@
|
|
1
|
+
import { __decorate } from "tslib";
|
2
|
+
import '@material/mwc-icon-button';
|
3
|
+
import '@material/mwc-button';
|
4
|
+
import { css, html, LitElement } from 'lit';
|
5
|
+
import { customElement } from 'lit/decorators.js';
|
6
|
+
let HomePage = class HomePage extends LitElement {
|
7
|
+
render() {
|
8
|
+
var { icon, title, description } = this.applicationMeta;
|
9
|
+
return html `
|
10
|
+
<mwc-icon-button home icon="home" @click=${() => (window.location.href = '/')}></mwc-icon-button>
|
11
|
+
|
12
|
+
<div message>
|
13
|
+
<strong>${title}</strong>
|
14
|
+
${description}
|
15
|
+
<img src="/assets/images/home.png" />
|
16
|
+
</div>
|
17
|
+
`;
|
18
|
+
}
|
19
|
+
get applicationMeta() {
|
20
|
+
if (!this._applicationMeta) {
|
21
|
+
var iconLink = document.querySelector('link[rel="application-icon"]');
|
22
|
+
var titleMeta = document.querySelector('meta[name="application-name"]');
|
23
|
+
var descriptionMeta = document.querySelector('meta[name="application-description"]');
|
24
|
+
this._applicationMeta = {
|
25
|
+
icon: iconLink === null || iconLink === void 0 ? void 0 : iconLink.href,
|
26
|
+
title: titleMeta ? titleMeta.content : 'Things Factory',
|
27
|
+
description: descriptionMeta ? descriptionMeta.content : 'Reimagining Software'
|
28
|
+
};
|
29
|
+
}
|
30
|
+
return this._applicationMeta;
|
31
|
+
}
|
32
|
+
};
|
33
|
+
HomePage.styles = css `
|
34
|
+
:host {
|
35
|
+
background-color: var(--main-section-background-color);
|
36
|
+
|
37
|
+
display: block;
|
38
|
+
position: relative;
|
39
|
+
|
40
|
+
--mdc-theme-primary: white;
|
41
|
+
}
|
42
|
+
|
43
|
+
[home] {
|
44
|
+
position: absolute;
|
45
|
+
left: 20px;
|
46
|
+
top: 20px;
|
47
|
+
font-size: 2em;
|
48
|
+
color: white;
|
49
|
+
}
|
50
|
+
|
51
|
+
[message] {
|
52
|
+
background-color: rgba(50, 66, 97, 0.8);
|
53
|
+
padding: 60px 50px 0 50px;
|
54
|
+
color: #fff;
|
55
|
+
text-align: center;
|
56
|
+
font-size: 20px;
|
57
|
+
}
|
58
|
+
[message] strong {
|
59
|
+
display: block;
|
60
|
+
font-size: 2.5rem;
|
61
|
+
}
|
62
|
+
[message] img {
|
63
|
+
width: 450px;
|
64
|
+
max-width: 90%;
|
65
|
+
display: block;
|
66
|
+
margin: auto;
|
67
|
+
margin-top: 20px;
|
68
|
+
}
|
69
|
+
|
70
|
+
@media screen and (max-width: 480px) {
|
71
|
+
[message] {
|
72
|
+
padding: 60px 30px 0 30px;
|
73
|
+
color: #fff;
|
74
|
+
text-align: center;
|
75
|
+
font-size: 15px;
|
76
|
+
}
|
77
|
+
|
78
|
+
[message] strong {
|
79
|
+
font-size: 1.6rem;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
`;
|
83
|
+
HomePage = __decorate([
|
84
|
+
customElement('home-page')
|
85
|
+
], HomePage);
|
86
|
+
export { HomePage };
|
87
|
+
//# sourceMappingURL=home.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"home.js","sourceRoot":"","sources":["../../../../src/entries/public/home.ts"],"names":[],"mappings":";AAAA,OA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AAC,WAAW,CAAC;GACd,QAAQ,CAuFpB;SAvFY,QAAQ","sourcesContent":["import '@material/mwc-icon-button'\nimport '@material/mwc-button'\n\nimport { css, html, LitElement } from 'lit'\nimport { customElement } from 'lit/decorators.js'\n\n@customElement('home-page')\nexport class HomePage extends LitElement {\n static styles = css`\n :host {\n background-color: var(--main-section-background-color);\n\n display: block;\n position: relative;\n\n --mdc-theme-primary: white;\n }\n\n [home] {\n position: absolute;\n left: 20px;\n top: 20px;\n font-size: 2em;\n color: white;\n }\n\n [message] {\n background-color: rgba(50, 66, 97, 0.8);\n padding: 60px 50px 0 50px;\n color: #fff;\n text-align: center;\n font-size: 20px;\n }\n [message] strong {\n display: block;\n font-size: 2.5rem;\n }\n [message] img {\n width: 450px;\n max-width: 90%;\n display: block;\n margin: auto;\n margin-top: 20px;\n }\n\n @media screen and (max-width: 480px) {\n [message] {\n padding: 60px 30px 0 30px;\n color: #fff;\n text-align: center;\n font-size: 15px;\n }\n\n [message] strong {\n font-size: 1.6rem;\n }\n }\n `\n\n _applicationMeta?: {\n icon: string\n title: string\n description: string\n }\n\n render() {\n var { icon, title, description } = this.applicationMeta\n\n return html`\n <mwc-icon-button home icon=\"home\" @click=${() => (window.location.href = '/')}></mwc-icon-button>\n\n <div message>\n <strong>${title}</strong>\n ${description}\n <img src=\"/assets/images/home.png\" />\n </div>\n `\n }\n\n get applicationMeta() {\n if (!this._applicationMeta) {\n var iconLink = document.querySelector('link[rel=\"application-icon\"]') as HTMLLinkElement\n var titleMeta = document.querySelector('meta[name=\"application-name\"]') as HTMLMetaElement\n var descriptionMeta = document.querySelector('meta[name=\"application-description\"]') as HTMLMetaElement\n\n this._applicationMeta = {\n icon: iconLink?.href,\n title: titleMeta ? titleMeta.content : 'Things Factory',\n description: descriptionMeta ? descriptionMeta.content : 'Reimagining Software'\n }\n }\n\n return this._applicationMeta\n }\n}\n"]}
|
package/dist/src/index.js
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,uBAAuB,CAAA","sourcesContent":["export * from './store'\nexport * from './actions'\nexport * from './app/pages/page-view'\n"]}
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
declare type OxObjectStore = {
|
2
|
+
add: (value: any, key?: IDBValidKey | undefined) => IDBValidKey;
|
3
|
+
delete: (query: IDBValidKey | IDBKeyRange) => undefined;
|
4
|
+
clear: () => undefined;
|
5
|
+
get: (query: IDBValidKey | IDBKeyRange) => any;
|
6
|
+
getAll: (query?: IDBValidKey | IDBKeyRange | null | undefined, count?: number | undefined) => any[];
|
7
|
+
getAllKeys: (query?: IDBValidKey | IDBKeyRange | null | undefined, count?: number | undefined) => IDBValidKey[];
|
8
|
+
count: (query?: IDBValidKey | IDBKeyRange | undefined) => number;
|
9
|
+
put: (value: any, key?: IDBValidKey | undefined) => IDBValidKey;
|
10
|
+
openCursor: (query?: IDBValidKey | IDBKeyRange | null | undefined, direction?: IDBCursorDirection | undefined) => IDBCursorWithValue | null;
|
11
|
+
openKeyCursor: (query?: IDBValidKey | IDBKeyRange | null | undefined, direction?: IDBCursorDirection | undefined) => IDBCursor | null;
|
12
|
+
limit: (limit?: number) => undefined;
|
13
|
+
};
|
14
|
+
export declare const clientSettingStore: OxObjectStore;
|
15
|
+
export declare const notificationStore: OxObjectStore;
|
16
|
+
export {};
|
@@ -0,0 +1,129 @@
|
|
1
|
+
/*
|
2
|
+
* [ Caution ]
|
3
|
+
* Since this module is being used by a service worker, be very careful about adding imports or using functions for browsers.
|
4
|
+
*/
|
5
|
+
/* promise queue */
|
6
|
+
class Queue {
|
7
|
+
static enqueue(promise) {
|
8
|
+
return new Promise((resolve, reject) => {
|
9
|
+
this.queue.push({
|
10
|
+
promise,
|
11
|
+
resolve,
|
12
|
+
reject
|
13
|
+
});
|
14
|
+
this.dequeue();
|
15
|
+
});
|
16
|
+
}
|
17
|
+
static dequeue() {
|
18
|
+
if (this.workingOnPromise) {
|
19
|
+
return false;
|
20
|
+
}
|
21
|
+
const item = this.queue.shift();
|
22
|
+
if (!item) {
|
23
|
+
return false;
|
24
|
+
}
|
25
|
+
try {
|
26
|
+
this.workingOnPromise = true;
|
27
|
+
item.promise
|
28
|
+
.then(value => {
|
29
|
+
this.workingOnPromise = false;
|
30
|
+
item.resolve(value);
|
31
|
+
this.dequeue();
|
32
|
+
})
|
33
|
+
.catch(err => {
|
34
|
+
this.workingOnPromise = false;
|
35
|
+
item.reject(err);
|
36
|
+
this.dequeue();
|
37
|
+
});
|
38
|
+
}
|
39
|
+
catch (err) {
|
40
|
+
this.workingOnPromise = false;
|
41
|
+
item.reject(err);
|
42
|
+
this.dequeue();
|
43
|
+
}
|
44
|
+
return true;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
Queue.queue = [];
|
48
|
+
Queue.workingOnPromise = false;
|
49
|
+
function getStore(storeName) {
|
50
|
+
return [
|
51
|
+
'add',
|
52
|
+
'delete',
|
53
|
+
'clear',
|
54
|
+
'get',
|
55
|
+
'getAll',
|
56
|
+
'getAllKeys',
|
57
|
+
'count',
|
58
|
+
'put',
|
59
|
+
'openCursor',
|
60
|
+
'openKeyCursor'
|
61
|
+
].reduce((sum, m) => {
|
62
|
+
sum[m] = async (...params) => {
|
63
|
+
const db = (await getIndexDB());
|
64
|
+
const transaction = db.transaction(storeName, 'readwrite');
|
65
|
+
const store = transaction.objectStore(storeName);
|
66
|
+
const method = store[m];
|
67
|
+
const request = method.apply(store, params);
|
68
|
+
return await new Promise((resolve, reject) => {
|
69
|
+
request.onsuccess = (event) => {
|
70
|
+
var _a;
|
71
|
+
resolve((_a = event.target) === null || _a === void 0 ? void 0 : _a.result);
|
72
|
+
};
|
73
|
+
request.onerror = (event) => {
|
74
|
+
reject(event);
|
75
|
+
};
|
76
|
+
});
|
77
|
+
};
|
78
|
+
return sum;
|
79
|
+
}, {
|
80
|
+
async limit(limit = 50) {
|
81
|
+
const keys = (await this.getAllKeys()).slice(0, -limit);
|
82
|
+
for (let i = 0; i < keys.length; i++) {
|
83
|
+
await this.delete(keys[i]);
|
84
|
+
}
|
85
|
+
}
|
86
|
+
});
|
87
|
+
}
|
88
|
+
function getIndexedDB() {
|
89
|
+
if (typeof window !== 'undefined') {
|
90
|
+
return window.indexedDB;
|
91
|
+
}
|
92
|
+
else {
|
93
|
+
return self.indexedDB;
|
94
|
+
}
|
95
|
+
}
|
96
|
+
var db;
|
97
|
+
function getIndexDB() {
|
98
|
+
if (db) {
|
99
|
+
return db;
|
100
|
+
}
|
101
|
+
return Queue.enqueue(new Promise(function (resolve, reject) {
|
102
|
+
const indexedDB = getIndexedDB();
|
103
|
+
if (!indexedDB) {
|
104
|
+
reject('this browser does not support indexedDB');
|
105
|
+
}
|
106
|
+
const request = indexedDB.open('things-factory-database');
|
107
|
+
request.onerror = function (event) {
|
108
|
+
console.log("Why didn't you allow my web app to use IndexedDB?!");
|
109
|
+
reject(event);
|
110
|
+
};
|
111
|
+
request.onupgradeneeded = function (event) {
|
112
|
+
var _a;
|
113
|
+
var db = (_a = event.target) === null || _a === void 0 ? void 0 : _a.result;
|
114
|
+
var store = db.createObjectStore('notifications', { keyPath: 'id', autoIncrement: true });
|
115
|
+
store.createIndex('notification_id_unqiue', 'id', { unique: true });
|
116
|
+
var store = db.createObjectStore('client_settings', { keyPath: 'key', autoIncrement: true });
|
117
|
+
store.createIndex('client_setting_key_unqiue', 'key', { unique: true });
|
118
|
+
};
|
119
|
+
request.onsuccess = function (event) {
|
120
|
+
console.log('IndexedDB opened successfully');
|
121
|
+
db = request.result;
|
122
|
+
resolve(db);
|
123
|
+
};
|
124
|
+
}));
|
125
|
+
}
|
126
|
+
/* ready indexedDB Stores */
|
127
|
+
export const clientSettingStore = getStore('client_settings');
|
128
|
+
export const notificationStore = getStore('notifications');
|
129
|
+
//# sourceMappingURL=object-store.js.map
|
@@ -0,0 +1 @@
|
|
1
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IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;YAEnE,IAAI,KAAK,GAAG,EAAE,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;YAC5F,KAAK,CAAC,WAAW,CAAC,2BAA2B,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;QACzE,CAAC,CAAA;QAED,OAAO,CAAC,SAAS,GAAG,UAAU,KAAK;YACjC,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAA;YAC5C,EAAE,GAAG,OAAO,CAAC,MAAM,CAAA;YACnB,OAAO,CAAC,EAAE,CAAC,CAAA;QACb,CAAC,CAAA;IACH,CAAC,CAAC,CACH,CAAA;AACH,CAAC;AAED,4BAA4B;AAC5B,MAAM,CAAC,MAAM,kBAAkB,GAAkB,QAAQ,CAAC,iBAAiB,CAAC,CAAA;AAC5E,MAAM,CAAC,MAAM,iBAAiB,GAAkB,QAAQ,CAAC,eAAe,CAAC,CAAA","sourcesContent":["/*\n * [ Caution ]\n * Since this module is being used by a service worker, be very careful about adding imports or using functions for browsers.\n */\n\ntype OxObjectStore = {\n add: (value: any, key?: IDBValidKey | undefined) => IDBValidKey\n delete: (query: IDBValidKey | IDBKeyRange) => undefined\n clear: () => undefined\n get: (query: IDBValidKey | IDBKeyRange) => any\n getAll: (query?: IDBValidKey | IDBKeyRange | null | undefined, count?: number | undefined) => any[]\n getAllKeys: (query?: IDBValidKey | IDBKeyRange | null | undefined, count?: number | undefined) => IDBValidKey[]\n count: (query?: IDBValidKey | IDBKeyRange | undefined) => number\n put: (value: any, key?: IDBValidKey | undefined) => IDBValidKey\n openCursor: (\n query?: IDBValidKey | IDBKeyRange | null | undefined,\n direction?: IDBCursorDirection | undefined\n ) => IDBCursorWithValue | null\n openKeyCursor: (\n query?: IDBValidKey | IDBKeyRange | null | undefined,\n direction?: IDBCursorDirection | undefined\n ) => IDBCursor | null\n limit: (limit?: number) => undefined\n}\n\n/* promise queue */\nclass Queue {\n private static queue: {\n promise: Promise<IDBDatabase>\n resolve: (db: IDBDatabase) => void\n reject: (reason?: any) => void\n }[] = []\n\n private static workingOnPromise: boolean = false\n\n static enqueue(promise: Promise<any>) {\n return new Promise((resolve, reject) => {\n this.queue.push({\n promise,\n resolve,\n reject\n })\n this.dequeue()\n })\n }\n\n static dequeue() {\n if (this.workingOnPromise) {\n return false\n }\n const item = this.queue.shift()\n if (!item) {\n return false\n }\n try {\n this.workingOnPromise = true\n item.promise\n .then(value => {\n this.workingOnPromise = false\n item.resolve(value)\n this.dequeue()\n })\n .catch(err => {\n this.workingOnPromise = false\n item.reject(err)\n this.dequeue()\n })\n } catch (err) {\n this.workingOnPromise = false\n item.reject(err)\n this.dequeue()\n }\n return true\n }\n}\n\nfunction getStore(storeName: string): OxObjectStore {\n return [\n 'add',\n 'delete',\n 'clear',\n 'get',\n 'getAll',\n 'getAllKeys',\n 'count',\n 'put',\n 'openCursor',\n 'openKeyCursor'\n ].reduce(\n (sum, m) => {\n sum[m] = async (...params: any) => {\n const db = (await getIndexDB()) as IDBDatabase\n\n const transaction = db.transaction(storeName, 'readwrite')\n const store = transaction.objectStore(storeName)\n const method: (...p: any) => any = (store as any)[m]\n const request = method.apply(store, params)\n\n return await new Promise((resolve, reject) => {\n request.onsuccess = (event: Event) => {\n resolve((event.target as IDBRequest)?.result)\n }\n\n request.onerror = (event: Event) => {\n reject(event)\n }\n })\n }\n\n return sum\n },\n {\n async limit(this: OxObjectStore, limit = 50) {\n const keys = (await this.getAllKeys()).slice(0, -limit)\n for (let i = 0; i < keys.length; i++) {\n await this.delete(keys[i])\n }\n }\n } as any\n )\n}\n\nfunction getIndexedDB(): IDBFactory {\n if (typeof window !== 'undefined') {\n return window.indexedDB\n } else {\n return self.indexedDB\n }\n}\n\nvar db: IDBDatabase\n\nfunction getIndexDB() {\n if (db) {\n return db\n }\n\n return Queue.enqueue(\n new Promise(function (resolve, reject) {\n const indexedDB = getIndexedDB()\n\n if (!indexedDB) {\n reject('this browser does not support indexedDB')\n }\n const request = indexedDB.open('things-factory-database')\n\n request.onerror = function (event) {\n console.log(\"Why didn't you allow my web app to use IndexedDB?!\")\n reject(event)\n }\n\n request.onupgradeneeded = function (event: IDBVersionChangeEvent) {\n var db: IDBDatabase = (event.target as IDBRequest)?.result\n\n var store = db.createObjectStore('notifications', { keyPath: 'id', autoIncrement: true })\n store.createIndex('notification_id_unqiue', 'id', { unique: true })\n\n var store = db.createObjectStore('client_settings', { keyPath: 'key', autoIncrement: true })\n store.createIndex('client_setting_key_unqiue', 'key', { unique: true })\n }\n\n request.onsuccess = function (event) {\n console.log('IndexedDB opened successfully')\n db = request.result\n resolve(db)\n }\n })\n )\n}\n\n/* ready indexedDB Stores */\nexport const clientSettingStore: OxObjectStore = getStore('client_settings')\nexport const notificationStore: OxObjectStore = getStore('notifications')\n"]}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
declare const app: (state: {
|
2
|
+
baseUrl: string;
|
3
|
+
contextPath: string;
|
4
|
+
domains: {
|
5
|
+
name: string;
|
6
|
+
subdomain: string;
|
7
|
+
}[];
|
8
|
+
} | undefined, action: any) => {
|
9
|
+
modules: any;
|
10
|
+
baseUrl: string;
|
11
|
+
contextPath: string;
|
12
|
+
domains: {
|
13
|
+
name: string;
|
14
|
+
subdomain: string;
|
15
|
+
}[];
|
16
|
+
} | {
|
17
|
+
baseUrl: any;
|
18
|
+
contextPath: string;
|
19
|
+
domains: {
|
20
|
+
name: string;
|
21
|
+
subdomain: string;
|
22
|
+
}[];
|
23
|
+
} | {
|
24
|
+
contextPath: any;
|
25
|
+
baseUrl: string;
|
26
|
+
domains: {
|
27
|
+
name: string;
|
28
|
+
subdomain: string;
|
29
|
+
}[];
|
30
|
+
} | {
|
31
|
+
domains: any;
|
32
|
+
domain: any;
|
33
|
+
baseUrl: string;
|
34
|
+
contextPath: string;
|
35
|
+
};
|
36
|
+
export default app;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { getPathInfo } from '@operato/utils';
|
2
|
+
import { SET_DOMAINS, UPDATE_BASE_URL, UPDATE_CONTEXT_PATH, UPDATE_MODULES } from '../actions/app.js';
|
3
|
+
const INITIAL_STATE = {
|
4
|
+
baseUrl: location.origin,
|
5
|
+
contextPath: getPathInfo(location.pathname).contextPath,
|
6
|
+
domains: []
|
7
|
+
};
|
8
|
+
const app = (state = INITIAL_STATE, action) => {
|
9
|
+
switch (action.type) {
|
10
|
+
case UPDATE_MODULES:
|
11
|
+
return {
|
12
|
+
...state,
|
13
|
+
modules: action.modules
|
14
|
+
};
|
15
|
+
case UPDATE_BASE_URL:
|
16
|
+
return {
|
17
|
+
...state,
|
18
|
+
baseUrl: action.baseUrl
|
19
|
+
};
|
20
|
+
case UPDATE_CONTEXT_PATH:
|
21
|
+
return {
|
22
|
+
...state,
|
23
|
+
contextPath: action.contextPath
|
24
|
+
};
|
25
|
+
case SET_DOMAINS:
|
26
|
+
return {
|
27
|
+
...state,
|
28
|
+
domains: action.domains,
|
29
|
+
domain: action.domain
|
30
|
+
};
|
31
|
+
default:
|
32
|
+
return state;
|
33
|
+
}
|
34
|
+
};
|
35
|
+
export default app;
|
36
|
+
//# sourceMappingURL=app.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../../src/reducers/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAErG,MAAM,aAAa,GAOf;IACF,OAAO,EAAE,QAAQ,CAAC,MAAM;IACxB,WAAW,EAAE,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,WAAW;IACvD,OAAO,EAAE,EAAE;CACZ,CAAA;AAED,MAAM,GAAG,GAAG,CAAC,KAAK,GAAG,aAAa,EAAE,MAAW,EAAE,EAAE;IACjD,QAAQ,MAAM,CAAC,IAAI,EAAE;QACnB,KAAK,cAAc;YACjB,OAAO;gBACL,GAAG,KAAK;gBACR,OAAO,EAAE,MAAM,CAAC,OAAO;aACxB,CAAA;QACH,KAAK,eAAe;YAClB,OAAO;gBACL,GAAG,KAAK;gBACR,OAAO,EAAE,MAAM,CAAC,OAAO;aACxB,CAAA;QACH,KAAK,mBAAmB;YACtB,OAAO;gBACL,GAAG,KAAK;gBACR,WAAW,EAAE,MAAM,CAAC,WAAW;aAChC,CAAA;QAEH,KAAK,WAAW;YACd,OAAO;gBACL,GAAG,KAAK;gBACR,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,MAAM,EAAE,MAAM,CAAC,MAAM;aACtB,CAAA;QAEH;YACE,OAAO,KAAK,CAAA;KACf;AACH,CAAC,CAAA;AAED,eAAe,GAAG,CAAA","sourcesContent":["import { getPathInfo } from '@operato/utils'\n\nimport { SET_DOMAINS, UPDATE_BASE_URL, UPDATE_CONTEXT_PATH, UPDATE_MODULES } from '../actions/app.js'\n\nconst INITIAL_STATE: {\n baseUrl: string\n contextPath: string\n domains: {\n name: string\n subdomain: string\n }[]\n} = {\n baseUrl: location.origin,\n contextPath: getPathInfo(location.pathname).contextPath,\n domains: []\n}\n\nconst app = (state = INITIAL_STATE, action: any) => {\n switch (action.type) {\n case UPDATE_MODULES:\n return {\n ...state,\n modules: action.modules\n }\n case UPDATE_BASE_URL:\n return {\n ...state,\n baseUrl: action.baseUrl\n }\n case UPDATE_CONTEXT_PATH:\n return {\n ...state,\n contextPath: action.contextPath\n }\n\n case SET_DOMAINS:\n return {\n ...state,\n domains: action.domains,\n domain: action.domain\n }\n\n default:\n return state\n }\n}\n\nexport default app\n"]}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
declare const route: (state: {
|
2
|
+
page: string;
|
3
|
+
resourceId: string;
|
4
|
+
params: any;
|
5
|
+
activePage: any;
|
6
|
+
context: any;
|
7
|
+
callbacks: any[];
|
8
|
+
} | undefined, action: any) => {
|
9
|
+
page: any;
|
10
|
+
resourceId: any;
|
11
|
+
params: any;
|
12
|
+
activePage: any;
|
13
|
+
context: any;
|
14
|
+
callbacks: any[];
|
15
|
+
};
|
16
|
+
export default route;
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import startCase from 'lodash-es/startCase';
|
2
|
+
import { updateMetadata } from 'pwa-helpers/metadata.js';
|
3
|
+
import { REGISTER_NAVIGATION_CALLBACK, UNREGISTER_NAVIGATION_CALLBACK, UPDATE_ACTIVE_PAGE, UPDATE_CONTEXT, UPDATE_PAGE } from '../actions/const';
|
4
|
+
const APP_TITLE_EL = document.querySelector('meta[name="application-name"]');
|
5
|
+
var appTitle;
|
6
|
+
if (APP_TITLE_EL) {
|
7
|
+
appTitle = APP_TITLE_EL.content;
|
8
|
+
}
|
9
|
+
const INITIAL_STATE = {
|
10
|
+
page: '',
|
11
|
+
resourceId: '',
|
12
|
+
params: {},
|
13
|
+
activePage: null,
|
14
|
+
context: {},
|
15
|
+
callbacks: []
|
16
|
+
};
|
17
|
+
const route = (state = INITIAL_STATE, action) => {
|
18
|
+
var _a;
|
19
|
+
switch (action.type) {
|
20
|
+
case UPDATE_PAGE:
|
21
|
+
return {
|
22
|
+
...state,
|
23
|
+
page: action.page,
|
24
|
+
resourceId: action.resourceId,
|
25
|
+
params: action.params
|
26
|
+
};
|
27
|
+
case UPDATE_CONTEXT:
|
28
|
+
let title = (_a = action.context) === null || _a === void 0 ? void 0 : _a.title;
|
29
|
+
let text = typeof title === 'object' ? title.text : title;
|
30
|
+
updateMetadata({
|
31
|
+
title: appTitle + (text ? ` - ${startCase(text)}` : '')
|
32
|
+
});
|
33
|
+
return {
|
34
|
+
...state,
|
35
|
+
context: action.context || (state.activePage && state.activePage.context) || {}
|
36
|
+
};
|
37
|
+
case UPDATE_ACTIVE_PAGE:
|
38
|
+
return {
|
39
|
+
...state,
|
40
|
+
activePage: action.activePage
|
41
|
+
};
|
42
|
+
case REGISTER_NAVIGATION_CALLBACK:
|
43
|
+
return {
|
44
|
+
...state,
|
45
|
+
callbacks: [...state.callbacks, action.callback]
|
46
|
+
};
|
47
|
+
case UNREGISTER_NAVIGATION_CALLBACK:
|
48
|
+
return {
|
49
|
+
...state,
|
50
|
+
callbacks: state.callbacks.filter(callback => callback !== action.callback)
|
51
|
+
};
|
52
|
+
default:
|
53
|
+
return state;
|
54
|
+
}
|
55
|
+
};
|
56
|
+
export default route;
|
57
|
+
//# sourceMappingURL=route.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../src/reducers/route.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,OAAO,EACL,4BAA4B,EAC5B,8BAA8B,EAC9B,kBAAkB,EAClB,cAAc,EACd,WAAW,EACZ,MAAM,kBAAkB,CAAA;AAEzB,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,+BAA+B,CAAoB,CAAA;AAE/F,IAAI,QAA4B,CAAA;AAChC,IAAI,YAAY,EAAE;IAChB,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAA;CAChC;AAED,MAAM,aAAa,GAOf;IACF,IAAI,EAAE,EAAE;IACR,UAAU,EAAE,EAAE;IACd,MAAM,EAAE,EAAE;IACV,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,EAAE;IACX,SAAS,EAAE,EAAE;CACd,CAAA;AAED,MAAM,KAAK,GAAG,CAAC,KAAK,GAAG,aAAa,EAAE,MAAW,EAAE,EAAE;;IACnD,QAAQ,MAAM,CAAC,IAAI,EAAE;QACnB,KAAK,WAAW;YACd,OAAO;gBACL,GAAG,KAAK;gBACR,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,MAAM,EAAE,MAAM,CAAC,MAAM;aACtB,CAAA;QACH,KAAK,cAAc;YACjB,IAAI,KAAK,GAAG,MAAA,MAAM,CAAC,OAAO,0CAAE,KAAK,CAAA;YACjC,IAAI,IAAI,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAA;YAEzD,cAAc,CAAC;gBACb,KAAK,EAAE,QAAQ,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACxD,CAAC,CAAA;YACF,OAAO;gBACL,GAAG,KAAK;gBACR,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE;aAChF,CAAA;QACH,KAAK,kBAAkB;YACrB,OAAO;gBACL,GAAG,KAAK;gBACR,UAAU,EAAE,MAAM,CAAC,UAAU;aAC9B,CAAA;QAEH,KAAK,4BAA4B;YAC/B,OAAO;gBACL,GAAG,KAAK;gBACR,SAAS,EAAE,CAAC,GAAG,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC;aACjD,CAAA;QACH,KAAK,8BAA8B;YACjC,OAAO;gBACL,GAAG,KAAK;gBACR,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,KAAK,MAAM,CAAC,QAAQ,CAAC;aAC5E,CAAA;QAEH;YACE,OAAO,KAAK,CAAA;KACf;AACH,CAAC,CAAA;AAED,eAAe,KAAK,CAAA","sourcesContent":["import startCase from 'lodash-es/startCase'\nimport { updateMetadata } from 'pwa-helpers/metadata.js'\n\nimport {\n REGISTER_NAVIGATION_CALLBACK,\n UNREGISTER_NAVIGATION_CALLBACK,\n UPDATE_ACTIVE_PAGE,\n UPDATE_CONTEXT,\n UPDATE_PAGE\n} from '../actions/const'\n\nconst APP_TITLE_EL = document.querySelector('meta[name=\"application-name\"]') as HTMLMetaElement\n\nvar appTitle: string | undefined\nif (APP_TITLE_EL) {\n appTitle = APP_TITLE_EL.content\n}\n\nconst INITIAL_STATE: {\n page: string\n resourceId: string\n params: any\n activePage: any\n context: any\n callbacks: any[]\n} = {\n page: '',\n resourceId: '',\n params: {},\n activePage: null,\n context: {},\n callbacks: []\n}\n\nconst route = (state = INITIAL_STATE, action: any) => {\n switch (action.type) {\n case UPDATE_PAGE:\n return {\n ...state,\n page: action.page,\n resourceId: action.resourceId,\n params: action.params\n }\n case UPDATE_CONTEXT:\n let title = action.context?.title\n let text = typeof title === 'object' ? title.text : title\n\n updateMetadata({\n title: appTitle + (text ? ` - ${startCase(text)}` : '')\n })\n return {\n ...state,\n context: action.context || (state.activePage && state.activePage.context) || {}\n }\n case UPDATE_ACTIVE_PAGE:\n return {\n ...state,\n activePage: action.activePage\n }\n\n case REGISTER_NAVIGATION_CALLBACK:\n return {\n ...state,\n callbacks: [...state.callbacks, action.callback]\n }\n case UNREGISTER_NAVIGATION_CALLBACK:\n return {\n ...state,\n callbacks: state.callbacks.filter(callback => callback !== action.callback)\n }\n\n default:\n return state\n }\n}\n\nexport default route\n"]}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { lazyReducerEnhancer } from 'pwa-helpers/lazy-reducer-enhancer.js';
|
2
|
+
import { applyMiddleware, combineReducers, compose, createStore } from 'redux';
|
3
|
+
import thunk from 'redux-thunk';
|
4
|
+
import app from './reducers/app';
|
5
|
+
import route from './reducers/route';
|
6
|
+
// Sets up a Chrome extension for time travel debugging.
|
7
|
+
// See https://github.com/zalmoxisus/redux-devtools-extension for more information.
|
8
|
+
const devCompose = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
|
9
|
+
export const store = createStore(state => state, devCompose(lazyReducerEnhancer(combineReducers), applyMiddleware(thunk)));
|
10
|
+
// Initially loaded reducers.
|
11
|
+
store.addReducers({
|
12
|
+
app,
|
13
|
+
route
|
14
|
+
});
|
15
|
+
//# sourceMappingURL=store.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAa,MAAM,sCAAsC,CAAA;AACrF,OAAO,EAAU,eAAe,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW,EAAS,MAAM,OAAO,CAAA;AAC7F,OAAO,KAAK,MAAM,aAAa,CAAA;AAE/B,OAAO,GAAG,MAAM,gBAAgB,CAAA;AAChC,OAAO,KAAK,MAAM,kBAAkB,CAAA;AAMpC,wDAAwD;AACxD,mFAAmF;AACnF,MAAM,UAAU,GAAG,MAAM,CAAC,oCAAoC,IAAI,OAAO,CAAA;AAEzE,MAAM,CAAC,MAAM,KAAK,GAA4C,WAAW,CACvE,KAAK,CAAC,EAAE,CAAC,KAAK,EACd,UAAU,CAAC,mBAAmB,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC,CACzE,CAAA;AAED,6BAA6B;AAC7B,KAAK,CAAC,WAAW,CAAC;IAChB,GAAG;IACH,KAAK;CACN,CAAC,CAAA","sourcesContent":["import { lazyReducerEnhancer, LazyStore } from 'pwa-helpers/lazy-reducer-enhancer.js'\nimport { Action, applyMiddleware, combineReducers, compose, createStore, Store } from 'redux'\nimport thunk from 'redux-thunk'\n\nimport app from './reducers/app'\nimport route from './reducers/route'\n\ndeclare global {\n var __REDUX_DEVTOOLS_EXTENSION_COMPOSE__: any\n}\n\n// Sets up a Chrome extension for time travel debugging.\n// See https://github.com/zalmoxisus/redux-devtools-extension for more information.\nconst devCompose = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose\n\nexport const store: Store<unknown, Action<any>> & LazyStore = createStore(\n state => state,\n devCompose(lazyReducerEnhancer(combineReducers), applyMiddleware(thunk))\n)\n\n// Initially loaded reducers.\nstore.addReducers({\n app,\n route\n})\n"]}
|